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.
- checksums.yaml +4 -4
- data/lib/y_petri/manipulator/simulation_related_methods.rb +10 -5
- data/lib/y_petri/net.rb +4 -4
- data/lib/y_petri/place/guard.rb +17 -12
- data/lib/y_petri/simulation/collections.rb +460 -0
- data/lib/y_petri/{timed_simulation.rb → simulation/timed.rb} +55 -68
- data/lib/y_petri/simulation.rb +192 -724
- data/lib/y_petri/transition/construction.rb +1 -1
- data/lib/y_petri/transition.rb +82 -86
- data/lib/y_petri/version.rb +1 -1
- data/lib/y_petri/workspace/parametrized_subclassing.rb +2 -1
- data/lib/y_petri.rb +1 -2
- data/test/acceptance/basic_usage_test.rb +1 -1
- data/test/manipulator_test.rb +1 -1
- data/test/net_test.rb +2 -1
- data/test/place_test.rb +3 -1
- data/test/simulation_test.rb +14 -13
- data/test/timed_simulation_test.rb +30 -26
- data/test/workspace_test.rb +1 -1
- data/test/y_petri_test.rb +2 -4
- metadata +4 -3
@@ -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:
|
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
|
data/lib/y_petri/transition.rb
CHANGED
@@ -8,119 +8,115 @@ require_relative 'transition/timed'
|
|
8
8
|
require_relative 'transition/ordinary_timeless'
|
9
9
|
require_relative 'transition/assignment'
|
10
10
|
|
11
|
-
#
|
12
|
-
#
|
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_
|
18
|
-
#
|
19
|
-
# transition
|
20
|
-
#
|
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
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
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
|
-
# ===
|
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
|
-
#
|
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* –
|
39
|
-
# * *tS* –
|
40
|
-
# * *Tsr* –
|
41
|
-
# * *TSr* –
|
42
|
-
# * *sR* –
|
43
|
-
# * *SR* –
|
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
|
-
#
|
46
|
-
# the following 3 dimensions:
|
54
|
+
# They arise by combining the 3 basic qualities:
|
47
55
|
#
|
48
|
-
#
|
49
|
-
#
|
50
|
-
#
|
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
|
-
#
|
55
|
-
#
|
56
|
-
#
|
57
|
-
#
|
58
|
-
#
|
59
|
-
#
|
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
|
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
|
-
#
|
67
|
-
#
|
68
|
-
#
|
69
|
-
#
|
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
|
72
|
-
# closure result 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
|
-
#
|
77
|
-
#
|
78
|
-
#
|
79
|
-
#
|
80
|
-
#
|
81
|
-
#
|
82
|
-
#
|
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
|
85
|
-
# time step duration as the first argument to the action closure
|
86
|
-
# transitions with rate are
|
87
|
-
#
|
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
|
99
|
+
# === Other transition attributes
|
90
100
|
#
|
91
|
-
# ==== Assignment transitions (
|
92
|
-
# If +:assignment_action+ is set to _true_, it
|
93
|
-
#
|
94
|
-
#
|
95
|
-
# not
|
96
|
-
#
|
97
|
-
#
|
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
|
-
# ====
|
102
|
-
#
|
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
|
data/lib/y_petri/version.rb
CHANGED
@@ -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
|
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
|
-
|
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::
|
26
|
+
@m.simulation.must_be_kind_of ::YPetri::Simulation
|
27
27
|
@m.plot_state
|
28
28
|
sleep 3
|
29
29
|
end
|
data/test/manipulator_test.rb
CHANGED
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
|
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
|
-
|
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
|
data/test/simulation_test.rb
CHANGED
@@ -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
|
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.
|
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.
|
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.
|
147
|
-
@s.S.must_equal @s.
|
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.Δ
|
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
|
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.Δ
|
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.Δ
|
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.
|
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( :
|
265
|
-
@s.Δ
|
266
|
-
@s.free_pp( :Δ
|
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::
|
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::
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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[
|
43
|
-
assert_in_delta 1.8, m[
|
44
|
-
assert_in_delta 3.2, m[
|
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
|
-
|
49
|
-
|
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
|
-
|
52
|
-
|
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::
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
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.
|
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::
|
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::
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
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
|
data/test/workspace_test.rb
CHANGED
@@ -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,
|
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
|
-
|
15
|
-
|
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.
|
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-
|
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/
|
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
|