Class: YPetri::Core::Timed
- Inherits:
-
Object
- Object
- YPetri::Core::Timed
- Defined in:
- lib/y_petri/core/timed.rb
Overview
Timed simulation core. Knows several simulation methods applicable to timed nets.
Defined Under Namespace
Modules: Basic, Euler, Gillespie, RungeKutta, Ticked
Constant Summary collapse
- METHODS =
{ basic: Basic, # simple PN execution, timeless tt fire after each step ticked: Ticked, # like basic, but timeless tt fire at every time tick euler: Euler, # for timed nets only runge_kutta: RungeKutta, # for timed nets only gillespie: Gillespie # for timed nets only }
Instance Attribute Summary collapse
-
#time ⇒ Object
readonly
From now on, core has its own time attribute and selector.
Instance Method Summary collapse
-
#flux_vector ⇒ Object
Flux vector.
-
#flux_vector_TS ⇒ Object
(also: #propensity_vector_TS)
Flux vector of TS transitions.
-
#gradient ⇒ Object
(also: #∇)
Gradient for free places.
-
#gradient_TS ⇒ Object
Gradient contribution by TS transitions.
-
#gradient_Ts ⇒ Object
Gradient contribution by Ts transitions.
-
#increment_time!(Δt) ⇒ Object
Increments core time by Δt.
-
#initialize(**named_args) ⇒ Timed
constructor
A new instance of Timed.
-
#step!(Δt = simulation.step) ⇒ Object
Makes a single step by Δt.
-
#timed? ⇒ Boolean
This inquirer (=Boolean selector) is always true for timed cores.
-
#timeless? ⇒ Boolean
This inquirer (=Boolean selector) is always false for timed cores.
Constructor Details
#initialize(**named_args) ⇒ Timed
Returns a new instance of Timed.
34 35 36 37 38 39 40 |
# File 'lib/y_petri/core/timed.rb', line 34 def initialize **named_args super # TODO: Net type checking. @time = 0.0 extend METHODS.fetch simulation_method @delta_s = simulation.MarkingVector.zero( @free_pp ) @delta_S = simulation.MarkingVector.zero( @free_pp ) end |
Instance Attribute Details
#time ⇒ Object (readonly)
From now on, core has its own time attribute and selector.
24 25 26 |
# File 'lib/y_petri/core/timed.rb', line 24 def time @time end |
Instance Method Details
#flux_vector ⇒ Object
Flux vector. The caller asserts that all the timed transitions are stoichiometric, or error.
83 84 85 86 87 88 |
# File 'lib/y_petri/core/timed.rb', line 83 def flux_vector msg = "#flux_vector method only applies to the timed simulations with " + "no Ts transitions. Try #flux_vector_TS instead!" fail msg unless Ts_transitions().empty? simulation.TS_rate_closure.call end |
#flux_vector_TS ⇒ Object Also known as: propensity_vector_TS
Flux vector of TS transitions.
92 93 94 |
# File 'lib/y_petri/core/timed.rb', line 92 def flux_vector_TS simulation.TS_rate_closure.call end |
#gradient ⇒ Object Also known as: ∇
Gradient for free places.
61 62 63 |
# File 'lib/y_petri/core/timed.rb', line 61 def gradient gradient_Ts + gradient_TS end |
#gradient_TS ⇒ Object
Gradient contribution by TS transitions.
76 77 78 |
# File 'lib/y_petri/core/timed.rb', line 76 def gradient_TS ( simulation.TS_stoichiometry_matrix * flux_vector_TS ) end |
#gradient_Ts ⇒ Object
Gradient contribution by Ts transitions.
68 69 70 71 72 |
# File 'lib/y_petri/core/timed.rb', line 68 def gradient_Ts simulation.Ts_gradient_closure.call # this could be # @Ts_gradient_closure.call end |
#increment_time!(Δt) ⇒ Object
Increments core time by Δt.
44 45 46 |
# File 'lib/y_petri/core/timed.rb', line 44 def increment_time! Δt @time += Δt end |
#step!(Δt = simulation.step) ⇒ Object
Makes a single step by Δt.
50 51 52 53 54 55 56 57 |
# File 'lib/y_petri/core/timed.rb', line 50 def step! Δt=simulation.step # TODO: This one will act directly upon simulation. Subject of potential # change later. increment_marking_vector Δ( Δt ) # TODO: The bottom two, obviously, act directly upon simulation. simulation.increment_time! Δt simulation.recorder.alert end |
#timed? ⇒ Boolean
This inquirer (=Boolean selector) is always true for timed cores.
28 |
# File 'lib/y_petri/core/timed.rb', line 28 def timed?; true end |
#timeless? ⇒ Boolean
This inquirer (=Boolean selector) is always false for timed cores.
32 |
# File 'lib/y_petri/core/timed.rb', line 32 def timeless?; false end |