y_petri 2.0.14 → 2.0.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -56,7 +56,7 @@ class YPetri::Transition
56
56
  # the stoichiometry vector, as in all other stoichiometric transitions).
57
57
  #
58
58
  # Transition.new stoichiometry: { A: -1, B: 1 },
59
- # rate: λ { |a| a * 0.5 }
59
+ # rate: -> a { a * 0.5 }
60
60
  #
61
61
  def initialize *args
62
62
  check_in_arguments *args # the big work of checking in args
@@ -8,119 +8,115 @@ require_relative 'transition/timed'
8
8
  require_relative 'transition/ordinary_timeless'
9
9
  require_relative 'transition/assignment'
10
10
 
11
- # A Petri net transition. Usually depicted as square boxes, transitions
12
- # represent operations over the net's marking vector -- how the marking changes
13
- # when the transition activates (_fires_).
11
+ # Transitions -- little boxes in Petri net drawings -- represent atomic
12
+ # operations on the Petri net's marking.
14
13
  #
15
14
  # === Domain and codomin
16
15
  #
17
- # Each transition has a _domain_ -- upstream places. Upstream places are those,
18
- # whose marking directly affects the transition's operation. Also, each
19
- # transition has a _codomain_ -- downstream places. Downstream places are those,
20
- # whose marking is directly affected by the transition's operation.
16
+ # Each transition has a _domain_ (upstream places) and _codomain_ (downstream
17
+ # places). Upstream places are those, whose marking directly affects
18
+ # the transition. Downstream places are those, whose marking is directly affected
19
+ # by the transition.
21
20
  #
22
21
  # === Action and action vector
23
22
  #
24
- # Every transition has an _action_ -- the operation it represents, the of what
25
- # happens to the marking of its codomain when it fires. With respect to the
26
- # transition's codomain, we can talk about the _action vector_ -- Δ state of the
27
- # codomain. For _non-stoichiometric_ transitions, this action vector is given
28
- # as the output of the _action closure_, or (for transitions with rate) of _rate
29
- # vector_ * Δ_time. For _stoichiometric_ transitions, this output needs to be
30
- # additionally multiplied by the transition's _stoichiometry vector_.
23
+ # Every transition has an _action_ -- the operation it represents. The action
24
+ # of _non-stoichiometric_ transitions is directly specified by the _action_
25
+ # _closure_ (whose output arity should match the codomain size.) For
26
+ # _stoichiometric_ transitions, the result of the action closure has to be
27
+ # multiplied by the transition's _stoichiometry_ _vector_ to obtain the action.
28
+ # Action of the _transitions_ _with_ _rate_ is specified indirectly by the
29
+ # _rate_ _closure_.
31
30
  #
32
- # === Basic types of transitions
31
+ # === Rate
32
+ #
33
+ # In YPetri domain model, marking is always a discrete number of _tokens_ -- as
34
+ # Carl Adam Petri handed it down to us. YPetri recognizes the usefulness of
35
+ # representing a large number of tokens by a floating point number, but sees it
36
+ # as a pragmatic measure only. Other Petri net implementations often make class
37
+ # distincion between discrete and continuous places, and also distinguish between
38
+ # _flux_ ("flow" of the continous transitions) and _propensity_ (firing
39
+ # probability of discrete transitions). In YPetri, flux and propensity are
40
+ # unified under the term _rate_, and the choice between discrete and stochastic
41
+ # computation is seen as a concern of the simulation, not of the model.
42
+ #
43
+ # === Basic transition types
33
44
  #
34
- # We have already mentioned different types of transitions _stoichiometric_ and
35
- # _non-stoichometric_, with or without rate... In total, there are 6 basic types
36
- # of transitions in *YPetri*:
45
+ # There are 6 basic types of transitions in YPetri:
37
46
  #
38
- # * *ts* – _timeless nonstoichiometric_
39
- # * *tS* – _timeless stoichiometric_
40
- # * *Tsr* – _timed rateless nonstoichiometric_
41
- # * *TSr* – _timed rateless stoichiometric_
42
- # * *sR* – _nonstoichiometric with rate_
43
- # * *SR* – _stoichiometric with rate_
47
+ # * *ts* – timeless nonstoichiometric
48
+ # * *tS* – timeless stoichiometric
49
+ # * *Tsr* – timed rateless nonstoichiometric
50
+ # * *TSr* – timed rateless stoichiometric
51
+ # * *sR* – nonstoichiometric with rate
52
+ # * *SR* – stoichiometric with rate
44
53
  #
45
- # These 6 kinds of YPetri transitions correspond to the vertices of a cube, with
46
- # the following 3 dimensions:
54
+ # They arise by combining the 3 basic qualities:
47
55
  #
48
- # - *Stoichiometricity*: _stoichiometric_ (S) / _nonstoichiometric_ (s)
49
- # - *Timedness*: _timed_ (T) / _timeless_ (t)
50
- # - *Having rate*: _having rate_ (R) / _not having rate_, _rateless_ (r)
56
+ # 1. *Stoichiometricity*: _stoichiometric_ (*S*) / _nonstoichiometric_ (*s*)
57
+ # 2. *Timedness*: _timed_ (*T*) / _timeless_ (*t*)
58
+ # 3. *Having* *rate*: having _rate_ (*R*) / not having rate (_rateless_) (*r*)
51
59
  #
52
- # ==== Stoichiometricity
60
+ # ==== 1. Stoichiometricity
53
61
  #
54
- # I. For stoichiometric transitions:
55
- # 1. Either *rate vector* is computed as *rate * stoichiometry vector*,
56
- # 2. or *action vector* is computed a *action * stoichiometry vector*.
57
- # II. For non-stoichiometric transitions:
58
- # 1. Either *Rate vector* is obtained as the *rate closure result*,
59
- # 2. or *action vector* is obtained as the *action closure result*.
62
+ # * For *stoichiometric* transitions:
63
+ # - _either_ <b>rate vector</b> is obtained as
64
+ # <b>rate * stoichiometry vector</b>,
65
+ # - _or_ <b>action vector</b> is obtained as
66
+ # <b>action * stoichiometry vector</b>
67
+ # * For *non-stoichiometric* transitions:
68
+ # - _either_ <b>rate vector</b> is obtained as the <b>rate closure result</b>,
69
+ # - _or_ <b>action vector</b> is obtained as the <b>action closure result</b>.
60
70
  #
61
- # Summary: stoichiometricity distinguishes the *need to multiply the rate/action
62
- # closure result by stoichiometry*.
71
+ # Summary: stoichiometricity distinguishes the <b>need to multiply the
72
+ # rate/action closure result by stoichiometry</b>.
63
73
  #
64
- # ==== Having rate
74
+ # ==== 2. Having rate
65
75
  #
66
- # I. For transitions with rate, the closure *returns the rate*. The rate has to
67
- # be multiplied by the time step (Δt) to get the action value.
68
- # II. For transitions without rate (_rateless transitions_), the closure result
69
- # directly specifies the action.
76
+ # * Transitions *with* *rate* have a _rate_ _closure_, whose result is to be
77
+ # multiplied by t+.
78
+ # * For transitions *without* *rate* (*rateless* transitions), the action
79
+ # closure specifies the action *directly*.
70
80
  #
71
- # Summary: Having vs. not having rate distinguishes the *need to multiply the
72
- # closure result by Δ time* -- differentiability of the action by time.
81
+ # Summary: Having vs. not having rate distinguishes the <b>need to multiply the
82
+ # closure result by Δ time</b> -- differentiability of the action by time.
73
83
  #
74
- # ==== Timedness
84
+ # ==== 3. Timedness
75
85
  #
76
- # I. Timed transitions are defined as those, whose action has time as a
77
- # parameter. Transitions with rate are thus always timed. For rateless
78
- # transitions, being timed means that the action closure expects time step
79
- # (Δt) as its first argument -- its arity is thus its codomain size + 1.
80
- # II. Timeless transitions, in turn, are those, whose action is does not have
81
- # time a parameter. Timeless transitions are necessarily also rateless.
82
- # Arity of their action closure can be expected to match the domain size.
86
+ # * Timed transitions are defined as those, whose action has time as a parameter.
87
+ # - Transitions with rate are therefore always timed.
88
+ # - For rateless transitions, being timed means, that their action closure
89
+ # <b>expects Δt as its first argument</b> -- arity thus equals codomain
90
+ # size + 1.
91
+ # * Timeless transitions are those, whose action does not have time as
92
+ # a parameter. Timeless transitions are necessarily also rateless.
83
93
  #
84
- # Summary: In rateless transitions, timedness distinguishes the *need to supply
85
- # time step duration as the first argument to the action closure*. Whereas the
86
- # transitions with rate are always timed, and vice-versa, timeless transitions
87
- # always rateless, there are only 6 instead of 2 ** 3 == 8 basic types.
94
+ # Summary: In rateless transitions, timedness distinguishes the <b>need to
95
+ # supply time step duration as the first argument to the action closure</b>.
96
+ # As the transitions with rate are necessarily timed, and timeless transitions
97
+ # necessarily rateless, there are only 6 instead of 2 ** 3 == 8 transition types.
88
98
  #
89
- # === Other transition types
99
+ # === Other transition attributes
90
100
  #
91
- # ==== Assignment transitions (_A transitions_)
92
- # If +:assignment_action+ is set to _true_, it indicates that the transition
93
- # action entirely replaces the marking of its codomain with the result of its
94
- # action closure -- like we are used to from spreadsheets. This behavior does
95
- # not represent a truly novel type of a transition -- assignment transition is
96
- # merely a *ts transition that cares to clear the codomain before adding the
97
- # new value to it*. In other words, this behavior is (at least for numeric
98
- # types) already achievable with ordinary ts transitions, and existence of
99
- # specialized A transitions is just a convenience.
101
+ # ==== Assignment transitions (_A_ _transitions_)
102
+ # If +:assignment_action+ option is set to _true_, it makes the transition
103
+ # entirely replace the codomain marking with its action closure result -- just
104
+ # like spreadsheet functions do. This, however, is just a convenience, and does
105
+ # not constitue a novel transition type, as it can be easily emulated by an
106
+ # ordinary ts transition caring to subtract the current domain marking before
107
+ # adding the desired values.
100
108
  #
101
- # ==== Functional / Functionless transitions
102
- # YPetri is a domain model of _functional Petri nets_. Original Petri's
109
+ # ==== _Functional_ / _functionless_ transitions
110
+ # Other Petri net implementation often make a distinction between "ordinary"
111
+ # and "functional" transitions, where "ordinary" ("functionless") are the
112
+ # transitions as Carl Adam Petri handed them down to us. YPetri transtions
113
+ # are generally "functional", but the possibility of functionless transitions
114
+ # is also provided -- stoichiometric transitions with no action or rate
115
+ # specified become functionless transitions.
103
116
  # definition does not speak about transition "functions". The transitions are
104
117
  # defined as timeless and more or less assumed to be stoichiometric. Therefore,
105
118
  # in +YPetri::Transition+ constructor, stoichiometric transitions with no
106
119
  # function specified become functionless vanilla Petri net transitions.
107
- #
108
- # === "Discrete" vs. "continuous" in YPetri
109
- #
110
- # YPetri uses terminology of both "discrete" and "continuous" Petri nets. But
111
- # in fact, in YPetri domain model, place marking is always considered discrete
112
- # -- a discrete number of _tokens_, as defined by Carl Adam Petri. The meaning
113
- # of _continuous_ in YPetri is different: A pragmatic measure of approximating
114
- # this integer by a floating point number when the integer is so large, that the
115
- # impact of this approximation is acceptable. The responsibility for the
116
- # decision of how to represent the number of tokens is not a concern of the
117
- # domain model, but only of the simulation method. Therefore, in YPetri, there
118
- # are no _a priori_ "discrete" and "continuous" places or transitions.
119
- #
120
- # As for the transitions, terms _flux_ (flow), associated with continuous
121
- # transitions, and _propensity_, associated with discrete stochastic
122
- # transitions, are unified as _rate_. Again, the decision between "discrete"
123
- # and "stochastic" is a concern of the simulation method, not the domain model.
124
120
  #
125
121
  class YPetri::Transition
126
122
  include NameMagic
@@ -1,4 +1,4 @@
1
1
  module YPetri
2
- VERSION = "2.0.14"
2
+ VERSION = "2.0.15"
3
3
  DEBUG = false
4
4
  end
@@ -8,7 +8,8 @@ module YPetri::Workspace::ParametrizedSubclassing
8
8
 
9
9
  # Make them namespaces and inject dependencies:
10
10
  [ @Place, @Transition, @Net ].each do |klass|
11
- klass.namespace!.class_exec do # make'em work together
11
+ klass.namespace!
12
+ klass.class_exec do # make'em work together
12
13
  define_method :Place do place_subclass end
13
14
  define_method :Transition do transition_subclass end
14
15
  define_method :Net do net_subclass end
data/lib/y_petri.rb CHANGED
@@ -22,7 +22,6 @@ require_relative 'y_petri/place'
22
22
  require_relative 'y_petri/transition'
23
23
  require_relative 'y_petri/net'
24
24
  require_relative 'y_petri/simulation'
25
- require_relative 'y_petri/timed_simulation'
26
25
  require_relative 'y_petri/workspace'
27
26
  require_relative 'y_petri/manipulator'
28
27
 
@@ -48,7 +47,7 @@ module YPetri
48
47
  DEFAULT_SIMULATION_SETTINGS = lambda do
49
48
  { step_size: 0.02,
50
49
  sampling_period: 2,
51
- target_time: 60 }
50
+ time: 0..60 }
52
51
  end
53
52
 
54
53
  GuardError = Class.new TypeError
@@ -23,7 +23,7 @@ describe "Basic use of TimedSimulation" do
23
23
  it "should work" do
24
24
  @m.net.must_be_kind_of ::YPetri::Net
25
25
  @m.run!
26
- @m.simulation.must_be_kind_of ::YPetri::TimedSimulation
26
+ @m.simulation.must_be_kind_of ::YPetri::Simulation
27
27
  @m.plot_state
28
28
  sleep 3
29
29
  end
@@ -79,7 +79,7 @@ describe ::YPetri::Manipulator do
79
79
  @m.initial_marking @q => 2
80
80
  @m.set_step 0.01
81
81
  @m.set_sampling 1
82
- @m.set_time 30
82
+ @m.set_time 0..30
83
83
  end
84
84
 
85
85
  it "works" do
data/test/net_test.rb CHANGED
@@ -13,7 +13,8 @@ describe YPetri::Net do
13
13
  @pç = pç = Class.new YPetri::Place
14
14
  @nç = nç = Class.new YPetri::Net
15
15
  [ tç, pç, nç ].each { |ç|
16
- ç.namespace!.class_exec {
16
+ ç.namespace!
17
+ ç.class_exec {
17
18
  define_method :Place do pç end
18
19
  define_method :Transition do tç end
19
20
  define_method :Net do nç end
data/test/place_test.rb CHANGED
@@ -79,6 +79,8 @@ describe YPetri::Place do
79
79
  @p.guards.size.must_equal 4
80
80
  g = @p.federated_guard_closure
81
81
  -> { g.( 11.1 ) }.must_raise YPetri::GuardError
82
- -> { @p.marking = -1.11 }.must_raise YPetri::GuardError
82
+ begin; @p.marking = -1.11; rescue YPetri::GuardError => err
83
+ err.message.must_equal 'Marking -1.11:Float of P1 should not be negative!'
84
+ end
83
85
  end
84
86
  end
@@ -13,7 +13,8 @@ describe ::YPetri::Simulation do
13
13
  @tç = tç = Class.new( ::YPetri::Transition )
14
14
  @nç = nç = Class.new( ::YPetri::Net )
15
15
  [ @pç, @tç, @nç ].each { |klass|
16
- klass.namespace!.class_exec {
16
+ klass.namespace!
17
+ klass.class_exec {
17
18
  private
18
19
  define_method :Place do pç end
19
20
  define_method :Transition do tç end
@@ -135,16 +136,16 @@ describe ::YPetri::Simulation do
135
136
  end
136
137
 
137
138
  it "has stoichiometry matrix for 3. tS transitions" do
138
- @s.S_for_tS.must_equal Matrix.empty( 3, 0 )
139
+ @s.S_tS.must_equal Matrix.empty( 3, 0 )
139
140
  end
140
141
 
141
142
  it "has stoichiometry matrix for 4. Sr transitions" do
142
- @s.S_for_TSr.must_equal Matrix.empty( 3, 0 )
143
+ @s.S_TSr.must_equal Matrix.empty( 3, 0 )
143
144
  end
144
145
 
145
146
  it "has stoichiometry matrix for 6. SR transitions" do
146
- @s.S_for_SR.must_equal Matrix[[-1, 0, -1], [0, 1, 0], [1, 0, 1]]
147
- @s.S.must_equal @s.S_for_SR
147
+ @s.S_SR.must_equal Matrix[[-1, 0, -1], [0, 1, 0], [1, 0, 1]]
148
+ @s.S.must_equal @s.S_SR
148
149
  end
149
150
 
150
151
  it "presents 1. ts" do
@@ -227,13 +228,13 @@ describe ::YPetri::Simulation do
227
228
 
228
229
  it "2. handles Tsr transitions" do
229
230
  @s.Δ_closures_for_Tsr.must_equal []
230
- @s.Δ_for_Tsr( 1.0 ).must_equal Matrix.zero( @s.free_pp.size, 1 )
231
+ @s.Δ_Tsr( 1.0 ).must_equal Matrix.zero( @s.free_pp.size, 1 )
231
232
  end
232
233
 
233
234
  it "3. handles tS transitions" do
234
235
  @s.action_closures_for_tS.must_equal []
235
236
  @s.action_vector_for_tS.must_equal Matrix.column_vector( [] )
236
- @s.α_for_t.must_equal Matrix.column_vector( [] )
237
+ @s.ᴀ_t.must_equal Matrix.column_vector( [] )
237
238
  @s.Δ_if_tS_fire_once.must_equal Matrix.zero( @s.free_pp.size, 1 )
238
239
  end
239
240
 
@@ -242,14 +243,14 @@ describe ::YPetri::Simulation do
242
243
  @s.action_closures_for_Tr.must_equal []
243
244
  @s.action_vector_for_TSr( 1.0 ).must_equal Matrix.column_vector( [] )
244
245
  @s.action_vector_for_Tr( 1.0 ).must_equal Matrix.column_vector( [] )
245
- @s.Δ_for_TSr( 1.0 ).must_equal Matrix.zero( @s.free_pp.size, 1 )
246
+ @s.Δ_TSr( 1.0 ).must_equal Matrix.zero( @s.free_pp.size, 1 )
246
247
  end
247
248
 
248
249
  it "5. handles sR transitions" do
249
250
  assert_equal [], @s.rate_closures_for_sR
250
251
  assert_equal [], @s.rate_closures_for_s
251
252
  # @s.gradient_for_sR.must_equal Matrix.zero( @s.free_pp.size, 1 )
252
- @s.Δ_Euler_for_sR( 1.0 ).must_equal Matrix.zero( @s.free_pp.size, 1 )
253
+ @s.Δ_sR( 1.0 ).must_equal Matrix.zero( @s.free_pp.size, 1 )
253
254
  end
254
255
 
255
256
  it "6. handles stoichiometric transitions with rate" do
@@ -259,11 +260,11 @@ describe ::YPetri::Simulation do
259
260
  @s.flux_vector_for_SR.must_equal Matrix.column_vector( [ 0.4, 1.0, 1.5 ] )
260
261
  @s.φ_for_SR.must_equal @s.flux_vector
261
262
  @s.SR_tt( :φ_for_SR ).must_equal( { T1: 0.4, T2: 1.0, T3: 1.5 } )
262
- @s.Euler_action_vector_for_SR( 1 )
263
+ @s.first_order_action_vector_for_SR( 1 )
263
264
  .must_equal Matrix.column_vector [ 0.4, 1.0, 1.5 ]
264
- @s.SR_tt( :Euler_action_for_SR, 1 ).must_equal( T1: 0.4, T2: 1.0, T3: 1.5 )
265
- @s.Δ_Euler_for_SR( 1 ).must_equal Matrix[[-1.9], [1.0], [1.9]]
266
- @s.free_pp( :Δ_Euler_for_SR, 1 ).must_equal( { P2: -1.9, P3: 1.0, P4: 1.9 } )
265
+ @s.SR_tt( :first_order_action_for_SR, 1 ).must_equal( T1: 0.4, T2: 1.0, T3: 1.5 )
266
+ @s.Δ_SR( 1 ).must_equal Matrix[[-1.9], [1.0], [1.9]]
267
+ @s.free_pp( :Δ_SR, 1 ).must_equal( { P2: -1.9, P3: 1.0, P4: 1.9 } )
267
268
  end
268
269
 
269
270
  it "presents sparse stoichiometry vectors for its transitions" do
@@ -13,7 +13,7 @@ include Pyper if require 'pyper'
13
13
  # Test of TimedSimulation class.
14
14
  # **************************************************************************
15
15
  #
16
- describe YPetri::TimedSimulation do
16
+ describe YPetri::Simulation::Timed do
17
17
  before do
18
18
  # skip "to speed up testing"
19
19
  @a = YPetri::Place.new default_marking: 1.0
@@ -30,37 +30,41 @@ describe YPetri::TimedSimulation do
30
30
 
31
31
  describe "simulation with step size 1" do
32
32
  before do
33
- @sim = YPetri::TimedSimulation.new net: @net,
34
- initial_marking: @im_collection,
35
- step: 1,
36
- sampling: 10,
37
- target_time: 100
33
+ @sim = YPetri::Simulation.new net: @net,
34
+ initial_marking: @im_collection,
35
+ step: 1,
36
+ sampling: 10,
37
+ time: 0..100
38
38
  end
39
39
 
40
40
  it "should #step! with expected results" do
41
41
  m = @sim.step!.marking
42
- assert_in_delta 0.8, m[ 0 ], 1e-9
43
- assert_in_delta 1.8, m[ 1 ], 1e-9
44
- assert_in_delta 3.2, m[ 2 ], 1e-9
42
+ assert_in_delta 0.8, m[0]
43
+ assert_in_delta 1.8, m[1]
44
+ assert_in_delta 3.2, m[2]
45
45
  end
46
46
 
47
47
  it "should behave" do
48
- assert_in_delta 0, ( Matrix.column_vector( [-0.02, -0.02, 0.02] ) -
49
- @sim.ΔE( 0.1 ) ).column( 0 ).norm, 1e-9
48
+ expect = Matrix.column_vector [-0.02, -0.02, 0.02]
49
+ ( expect - @sim.ΔE( 0.1 ) ).column( 0 ).norm.must_be_within_delta 0
50
+ @sim.Euler_step! 0.1
51
+ expect = Matrix.column_vector [0.98, 1.98, 3.02]
52
+ ( expect - @sim.marking_vector ).column( 0 ).norm.must_be_within_delta 0
53
+ @sim.method.must_equal :pseudo_Euler
54
+ @sim.send :reset!
50
55
  @sim.step! 0.1
51
- assert_in_delta 0, ( Matrix.column_vector( [0.98, 1.98, 3.02] ) -
52
- @sim.marking_vector ).column( 0 ).norm, 1e-9
53
-
56
+ expect = Matrix.column_vector [0.98, 1.98, 3.02]
57
+ ( expect - @sim.marking_vector ).column( 0 ).norm.must_be_within_delta 0
54
58
  end
55
59
  end
56
60
 
57
61
  describe "simulation with step size 0.1" do
58
62
  before do
59
- @sim = YPetri::TimedSimulation.new net: @net,
60
- initial_marking: @im_collection,
61
- step: 0.1,
62
- sampling: 10,
63
- target_time: 100
63
+ @sim = YPetri::Simulation.new net: @net,
64
+ initial_marking: @im_collection,
65
+ step: 0.1,
66
+ sampling: 10,
67
+ time: 0..100
64
68
  end
65
69
 
66
70
  it "should behave" do
@@ -72,7 +76,7 @@ describe YPetri::TimedSimulation do
72
76
  end
73
77
 
74
78
  it "should behave" do
75
- @sim.run_until_target_time! 31
79
+ @sim.run_until 31
76
80
  expected_recording = {
77
81
  0 => [ 1, 2, 3 ],
78
82
  10 => [ 0.22265, 1.22265, 3.77735 ],
@@ -102,7 +106,7 @@ describe YPetri::TimedSimulation do
102
106
 
103
107
  describe "behavior of #step" do
104
108
  before do
105
- @sim = YPetri::TimedSimulation.new net: @net,
109
+ @sim = YPetri::Simulation.new net: @net,
106
110
  initial_marking: [ @a, @b, @c ].τBᴍHτ( &:default_marking ),
107
111
  step: 1,
108
112
  sampling: 10
@@ -124,11 +128,11 @@ describe YPetri::TimedSimulation do
124
128
  domain: @b,
125
129
  rate: -> a { a * 0.5 }
126
130
  @net = YPetri::Net.new << @a << @b << @c << @t3
127
- @sim = YPetri::TimedSimulation.new net: @net,
128
- initial_marking: { @a => 1, @b => 0.6, @c => 3 },
129
- step: 1,
130
- sampling: 10,
131
- target_time: 2
131
+ @sim = YPetri::Simulation.new net: @net,
132
+ initial_marking: { @a => 1, @b => 0.6, @c => 3 },
133
+ step: 1,
134
+ sampling: 10,
135
+ time: 0..2
132
136
  end
133
137
 
134
138
  it "should exhibit correct behavior of #step" do
@@ -25,7 +25,7 @@ describe YPetri::Workspace do
25
25
  @pp, @tt = [a, b, c], [t1, t2]
26
26
  @f_name = "test_output.csv"
27
27
  @w.set_imc @pp.τBᴍHτ( &:default_marking )
28
- @w.set_ssc step: 0.1, sampling: 10, target_time: 50
28
+ @w.set_ssc step: 0.1, sampling: 10, time: 0..50
29
29
  @w.set_cc( {} )
30
30
  @sim = @w.new_timed_simulation
31
31
  File.delete @f_name rescue nil
data/test/y_petri_test.rb CHANGED
@@ -11,10 +11,8 @@ require_relative '../lib/y_petri' # tested component itself
11
11
  #
12
12
  describe YPetri do
13
13
  it "should have basic classes" do
14
- assert [ :Place, :Transition, :Net,
15
- :Simulation, :TimedSimulation,
16
- :Workspace, :Manipulator
17
- ].all? { |ß| YPetri.const_get( ß ).is_a? Module }
14
+ [ :Place, :Transition, :Net, :Simulation, :Workspace, :Manipulator ]
15
+ .each { |ß| YPetri.const_get( ß ).must_be_kind_of Module }
18
16
  end
19
17
  end
20
18
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: y_petri
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.14
4
+ version: 2.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - boris
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-27 00:00:00.000000000 Z
11
+ date: 2013-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: y_support
@@ -82,7 +82,8 @@ files:
82
82
  - lib/y_petri/place/arcs.rb
83
83
  - lib/y_petri/place/guard.rb
84
84
  - lib/y_petri/simulation.rb
85
- - lib/y_petri/timed_simulation.rb
85
+ - lib/y_petri/simulation/collections.rb
86
+ - lib/y_petri/simulation/timed.rb
86
87
  - lib/y_petri/transition.rb
87
88
  - lib/y_petri/transition/arcs.rb
88
89
  - lib/y_petri/transition/assignment.rb