y_petri 2.2.4 → 2.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +675 -0
- data/README.md +6 -3
- data/Rakefile +1 -1
- data/lib/y_petri/agent/{petri_net_related.rb → petri_net_aspect.rb} +34 -10
- data/lib/y_petri/agent/{simulation_related.rb → simulation_aspect.rb} +49 -34
- data/lib/y_petri/agent.rb +5 -5
- data/lib/y_petri/core/guarded.rb +24 -0
- data/lib/y_petri/core/timed/euler.rb +4 -8
- data/lib/y_petri/core/timed/gillespie.rb +11 -17
- data/lib/y_petri/core/timed/methods.rb +23 -0
- data/lib/y_petri/core/timed/pseudo_euler.rb +10 -13
- data/lib/y_petri/core/timed/quasi_euler.rb +9 -8
- data/lib/y_petri/core/timed/runge_kutta.rb +10 -18
- data/lib/y_petri/core/timed.rb +6 -14
- data/lib/y_petri/core/timeless/methods.rb +15 -0
- data/lib/y_petri/core/timeless/pseudo_euler.rb +4 -8
- data/lib/y_petri/core/timeless.rb +9 -4
- data/lib/y_petri/core.rb +44 -42
- data/lib/y_petri/net/data_set.rb +246 -142
- data/lib/y_petri/net/node_access.rb +282 -0
- data/lib/y_petri/net/own_state.rb +14 -4
- data/lib/y_petri/net/state/feature/assignment.rb +123 -0
- data/lib/y_petri/net/state/feature/delta.rb +55 -35
- data/lib/y_petri/net/state/feature/firing.rb +68 -25
- data/lib/y_petri/net/state/feature/flux.rb +9 -2
- data/lib/y_petri/net/state/feature/gradient.rb +36 -19
- data/lib/y_petri/net/state/feature/marking.rb +10 -5
- data/lib/y_petri/net/state/feature.rb +105 -11
- data/lib/y_petri/net/state/features/record.rb +144 -99
- data/lib/y_petri/net/state/features.rb +327 -200
- data/lib/y_petri/net/state.rb +48 -82
- data/lib/y_petri/net/visualization.rb +1 -1
- data/lib/y_petri/net.rb +62 -47
- data/lib/y_petri/place/arcs.rb +44 -0
- data/lib/y_petri/place/features.rb +115 -0
- data/lib/y_petri/place.rb +62 -29
- data/lib/y_petri/simulation/dependency.rb +31 -67
- data/lib/y_petri/simulation/feature_set.rb +1 -1
- data/lib/y_petri/simulation/initial_marking/access.rb +42 -26
- data/lib/y_petri/simulation/marking_clamps/access.rb +22 -17
- data/lib/y_petri/simulation/marking_clamps.rb +0 -2
- data/lib/y_petri/simulation/marking_vector/access.rb +102 -40
- data/lib/y_petri/simulation/marking_vector.rb +35 -37
- data/lib/y_petri/simulation/matrix.rb +1 -1
- data/lib/y_petri/simulation/node_representation.rb +25 -0
- data/lib/y_petri/simulation/nodes/access.rb +78 -0
- data/lib/y_petri/simulation/{elements.rb → nodes.rb} +14 -13
- data/lib/y_petri/simulation/place_mapping.rb +2 -2
- data/lib/y_petri/simulation/place_representation.rb +8 -7
- data/lib/y_petri/simulation/places/access.rb +89 -70
- data/lib/y_petri/simulation/places/free.rb +1 -1
- data/lib/y_petri/simulation/places/types.rb +20 -22
- data/lib/y_petri/simulation/places.rb +23 -18
- data/lib/y_petri/simulation/recorder.rb +23 -18
- data/lib/y_petri/simulation/timed/recorder.rb +19 -11
- data/lib/y_petri/simulation/timed.rb +93 -29
- data/lib/y_petri/simulation/timeless/recorder.rb +11 -6
- data/lib/y_petri/simulation/timeless.rb +13 -3
- data/lib/y_petri/simulation/transition_representation/A.rb +24 -4
- data/lib/y_petri/simulation/transition_representation/S.rb +11 -1
- data/lib/y_petri/simulation/transition_representation/T.rb +1 -1
- data/lib/y_petri/simulation/transition_representation/Ts.rb +1 -1
- data/lib/y_petri/simulation/transition_representation/a.rb +1 -1
- data/lib/y_petri/simulation/transition_representation/s.rb +12 -1
- data/lib/y_petri/simulation/transition_representation/t.rb +1 -1
- data/lib/y_petri/simulation/transition_representation/tS.rb +1 -1
- data/lib/y_petri/simulation/transition_representation/ts.rb +1 -1
- data/lib/y_petri/simulation/transition_representation/types.rb +1 -1
- data/lib/y_petri/simulation/transition_representation.rb +4 -11
- data/lib/y_petri/simulation/transitions/A.rb +17 -2
- data/lib/y_petri/simulation/transitions/S.rb +1 -1
- data/lib/y_petri/simulation/transitions/T.rb +1 -1
- data/lib/y_petri/simulation/transitions/Ts.rb +6 -5
- data/lib/y_petri/simulation/transitions/a.rb +1 -1
- data/lib/y_petri/simulation/transitions/access.rb +195 -168
- data/lib/y_petri/simulation/transitions/s.rb +1 -1
- data/lib/y_petri/simulation/transitions/t.rb +1 -1
- data/lib/y_petri/simulation/transitions/tS.rb +1 -1
- data/lib/y_petri/simulation/transitions/ts.rb +1 -1
- data/lib/y_petri/simulation/transitions/types.rb +1 -1
- data/lib/y_petri/simulation/transitions.rb +5 -7
- data/lib/y_petri/simulation.rb +84 -90
- data/lib/y_petri/transition/A.rb +8 -2
- data/lib/y_petri/transition/T.rb +25 -2
- data/lib/y_petri/transition/arcs.rb +19 -3
- data/lib/y_petri/transition/construction_convenience.rb +11 -10
- data/lib/y_petri/transition/t.rb +14 -1
- data/lib/y_petri/transition/types.rb +6 -1
- data/lib/y_petri/transition.rb +9 -12
- data/lib/y_petri/version.rb +1 -1
- data/lib/y_petri/world/dependency.rb +3 -3
- data/lib/y_petri/world/{petri_net_related.rb → petri_net_aspect.rb} +4 -4
- data/lib/y_petri/world/simulation_aspect.rb +352 -0
- data/lib/y_petri/world.rb +4 -4
- data/lib/y_petri.rb +1 -1
- data/test/agent_test.rb +2 -1
- data/test/examples/demonstrator.rb +4 -1
- data/test/examples/demonstrator_2.rb +5 -0
- data/test/examples/demonstrator_4.rb +6 -5
- data/test/examples/example_2.rb +2 -0
- data/test/examples/manual_examples.rb +4 -4
- data/test/net_test.rb +457 -54
- data/test/place_test.rb +11 -7
- data/test/simulation_test.rb +358 -331
- data/test/transition_test.rb +11 -10
- data/test/world_test.rb +2 -0
- data/test/y_petri_test.rb +2 -1
- data/y_petri.gemspec +24 -18
- metadata +71 -17
- data/LICENSE +0 -22
- data/lib/y_petri/net/element_access.rb +0 -239
- data/lib/y_petri/simulation/element_representation.rb +0 -20
- data/lib/y_petri/simulation/elements/access.rb +0 -57
- data/lib/y_petri/transition/type.rb +0 -103
- data/lib/y_petri/transition/type_information.rb +0 -103
- data/lib/y_petri/world/simulation_related.rb +0 -176
@@ -1,4 +1,4 @@
|
|
1
|
-
#encoding: utf-8
|
1
|
+
# encoding: utf-8
|
2
2
|
|
3
3
|
# A mixin for collections of A transitions.
|
4
4
|
#
|
@@ -7,12 +7,18 @@ class YPetri::Simulation::Transitions
|
|
7
7
|
def initialize
|
8
8
|
end
|
9
9
|
|
10
|
-
# Assignment closures
|
10
|
+
# Assignment closures.
|
11
11
|
#
|
12
12
|
def assignment_closures
|
13
13
|
map &:assignment_closure
|
14
14
|
end
|
15
15
|
|
16
|
+
# Assignment closures that directly affect the marking when called.
|
17
|
+
#
|
18
|
+
def direct_assignment_closures
|
19
|
+
map &:direct_assignment_closure
|
20
|
+
end
|
21
|
+
|
16
22
|
# Combined assignment action, as it would occur if these A transitions fired
|
17
23
|
# in order, as hash place >> action.
|
18
24
|
#
|
@@ -34,5 +40,14 @@ class YPetri::Simulation::Transitions
|
|
34
40
|
-> { closures.each &:call }
|
35
41
|
end
|
36
42
|
alias assignment_closure to_assignment_closure
|
43
|
+
|
44
|
+
# Builds a joint direct assignment closure, directly bound to the marking
|
45
|
+
# vector and changing its values when called.
|
46
|
+
#
|
47
|
+
def to_direct_assignment_closure
|
48
|
+
closures = direct_assignment_closures
|
49
|
+
-> { closures.each &:call }
|
50
|
+
end
|
51
|
+
alias direct_assignment_closure to_direct_assignment_closure
|
37
52
|
end # Type_A
|
38
53
|
end # class YPetri::Simulation::Transitions
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#encoding: utf-8
|
1
|
+
# encoding: utf-8
|
2
2
|
|
3
3
|
# A mixin for collections of Ts transitions.
|
4
4
|
#
|
@@ -31,10 +31,11 @@ class YPetri::Simulation::Transitions
|
|
31
31
|
# in this collection.
|
32
32
|
#
|
33
33
|
def to_gradient_closure
|
34
|
-
fp = free_places
|
35
|
-
closures = gradient_closures
|
34
|
+
fp = free_places #.tap { |fp| puts; print "fp: "; Kernel::p fp }
|
35
|
+
closures = gradient_closures #.tap { |cl| puts; print "closures: "; Kernel::p cl }
|
36
36
|
sMV = simulation.MarkingVector
|
37
37
|
stu = simulation.time_unit
|
38
|
+
zero = ( sMV.zero( fp ) / stu ) #.tap { |z| puts; print "zero mv: "; Kernel::p z }
|
38
39
|
|
39
40
|
code_sections = map.with_index do |t, i|
|
40
41
|
"a = closures[ #{i} ].call\n" +
|
@@ -43,12 +44,12 @@ class YPetri::Simulation::Transitions
|
|
43
44
|
body = code_sections.join( "\n" )
|
44
45
|
λ = <<-LAMBDA
|
45
46
|
-> do
|
46
|
-
g =
|
47
|
+
g = zero
|
47
48
|
#{body}
|
48
49
|
return g
|
49
50
|
end
|
50
51
|
LAMBDA
|
51
|
-
eval λ
|
52
|
+
eval λ #.tap { |l| puts; puts "eval code: "; puts l }
|
52
53
|
end
|
53
54
|
alias gradient_closure to_gradient_closure
|
54
55
|
end # module Type_Ts
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#encoding: utf-8
|
1
|
+
# encoding: utf-8
|
2
2
|
|
3
3
|
# Simulation mixin providing access to transitions.
|
4
4
|
#
|
@@ -6,9 +6,8 @@ class YPetri::Simulation::Transitions
|
|
6
6
|
module Access
|
7
7
|
# Does a transition belong to the simulation?
|
8
8
|
#
|
9
|
-
def includes_transition?(
|
10
|
-
true.tap { begin; transition(
|
11
|
-
rescue NameError, TypeError
|
9
|
+
def includes_transition?( transition )
|
10
|
+
true.tap { begin; transition( transition ); rescue NameError, TypeError
|
12
11
|
return false
|
13
12
|
end }
|
14
13
|
end
|
@@ -16,239 +15,267 @@ class YPetri::Simulation::Transitions
|
|
16
15
|
|
17
16
|
# Net's transition.
|
18
17
|
#
|
19
|
-
def t(
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
#
|
24
|
-
#
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
18
|
+
def t( transition )
|
19
|
+
transition( transition ).source
|
20
|
+
end
|
21
|
+
|
22
|
+
# Makes it so that when "transitions" is abbreviated to "tt", transitions
|
23
|
+
# of the underlying net are returned rather than simulation's transition
|
24
|
+
# representations.
|
25
|
+
#
|
26
|
+
chain Tt: :Transitions,
|
27
|
+
tt: :transitions,
|
28
|
+
ts_Tt: :ts_Transitions,
|
29
|
+
ts_tt: :ts_transitions,
|
30
|
+
tS_Tt: :tS_Transitions,
|
31
|
+
tS_tt: :tS_transitions,
|
32
|
+
Ts_Tt: :Ts_Transitions,
|
33
|
+
Ts_tt: :Ts_transitions,
|
34
|
+
TS_Tt: :TS_Transitions,
|
35
|
+
TS_tt: :TS_transitions,
|
36
|
+
A_Tt: :A_Transitions,
|
37
|
+
A_tt: :A_transitions,
|
38
|
+
S_Tt: :S_Transitions,
|
39
|
+
S_tt: :S_transitions,
|
40
|
+
s_Tt: :S_Transitions,
|
41
|
+
s_tt: :S_transitions,
|
42
|
+
T_Tt: :T_Transitions,
|
43
|
+
T_tt: :T_transitions,
|
44
|
+
t_Tt: :t_Transitions,
|
45
|
+
t_tt: :t_transitions,
|
46
|
+
&:sources
|
47
|
+
|
48
|
+
# Makes it so that +Tn+/+tn+ means "names of transitions", and that when
|
49
|
+
# message "n" + transition_type is sent to the simulation, it returns names
|
50
|
+
# of the trasitions of the specified type.
|
51
|
+
#
|
52
|
+
chain Tn: :Tt,
|
53
|
+
tn: :tt,
|
54
|
+
nts: :ts_tt,
|
55
|
+
ntS: :tS_tt,
|
56
|
+
nTs: :Ts_tt,
|
57
|
+
nTS: :TS_tt,
|
58
|
+
nA: :A_tt,
|
59
|
+
nS: :S_tt,
|
60
|
+
ns: :s_tt,
|
61
|
+
nT: :T_tt,
|
62
|
+
nt: :t_tt do |r| r.names( true ) end
|
41
63
|
|
42
|
-
|
43
|
-
#
|
44
|
-
def Ts_tt( ids=nil )
|
45
|
-
Ts_transitions( ids ).sources
|
46
|
-
end
|
47
|
-
|
48
|
-
# Net's *TS* transitions.
|
49
|
-
#
|
50
|
-
def TS_tt( ids=nil )
|
51
|
-
TS_transitions( ids ).sources
|
52
|
-
end
|
53
|
-
|
54
|
-
# Net's *A* transitions.
|
55
|
-
#
|
56
|
-
def A_tt( ids=nil )
|
57
|
-
A_transitions( ids ).sources
|
58
|
-
end
|
59
|
-
|
60
|
-
# Net's *S* transitions.
|
61
|
-
#
|
62
|
-
def S_tt( ids=nil )
|
63
|
-
S_transitions( ids ).sources
|
64
|
-
end
|
65
|
-
|
66
|
-
# Net's *s* (non-stoichiometric) transitions.
|
67
|
-
#
|
68
|
-
def s_tt( ids=nil )
|
69
|
-
s_transitions( ids ).sources
|
70
|
-
end
|
71
|
-
|
72
|
-
# Net's *T* transitions.
|
73
|
-
#
|
74
|
-
def T_tt( ids=nil )
|
75
|
-
T_transitions( ids ).sources
|
76
|
-
end
|
64
|
+
protected
|
77
65
|
|
78
|
-
#
|
66
|
+
# Transition instance identification.
|
79
67
|
#
|
80
|
-
def
|
81
|
-
|
82
|
-
|
68
|
+
def transition( transition )
|
69
|
+
begin; Transition().instance( transition ); rescue NameError, TypeError
|
70
|
+
begin
|
71
|
+
transition = net.transition( transition )
|
72
|
+
Transition().instances.find { |t_rep| t_rep.source == transition } ||
|
73
|
+
Transition().instance( transition.name )
|
74
|
+
rescue NameError, TypeError => msg
|
75
|
+
fail TypeError, "Unknown transition instance: #{transition}! (#{msg})"
|
76
|
+
end
|
77
|
+
end
|
83
78
|
end
|
84
79
|
|
85
|
-
#
|
80
|
+
# Constructs an instance of @Transitions parametrized subclass. Expects a
|
81
|
+
# single array of transitions or transition ids and returns an array of
|
82
|
+
# corresponding transition representations in the simulation. Note that the
|
83
|
+
# includer of the +Transitions::Access+ module normally overloads
|
84
|
+
# :Transitions message in such way, that even without an argument, it does
|
85
|
+
# not fil, but returns @Transitions parametrized subclass itself.
|
86
86
|
#
|
87
|
-
def
|
88
|
-
|
87
|
+
def Transitions( array )
|
88
|
+
Transitions().load array.map &method( :transition )
|
89
89
|
end
|
90
90
|
|
91
|
-
#
|
91
|
+
# Without arguments, returns all the transition representations in the
|
92
|
+
# simulation. Otherwise, it accepts an arbitrary number of nodes or node
|
93
|
+
# ids as arguments, and returns an array of the corresponding transition
|
94
|
+
# representations.
|
92
95
|
#
|
93
|
-
def
|
94
|
-
|
96
|
+
def transitions( *transitions )
|
97
|
+
return @transitions if transitions.empty?
|
98
|
+
Transitions( transitions )
|
95
99
|
end
|
96
100
|
|
97
|
-
#
|
101
|
+
# Simulation's *ts* transitions. Expects a single array of +ts+ transitions
|
102
|
+
# or their ids and returns an array of the corresponding ts transition
|
103
|
+
# representations.
|
98
104
|
#
|
99
|
-
def
|
100
|
-
|
105
|
+
def ts_Transitions( array )
|
106
|
+
transitions.ts.subset( array )
|
101
107
|
end
|
102
108
|
|
103
|
-
#
|
109
|
+
# Simulation's *ts* transitions. Without arguments, returns all the ts
|
110
|
+
# transitions of the simulation. Otherwise, it accepts an arbitrary number
|
111
|
+
# of ts transitions or transition ids as arguments, and returns an array of
|
112
|
+
# the corresponding ts transitions of the simulation.
|
104
113
|
#
|
105
|
-
def
|
106
|
-
|
114
|
+
def ts_transitions( *transitions )
|
115
|
+
return transitions().ts if transitions.empty?
|
116
|
+
ts_Transitions( transitions )
|
107
117
|
end
|
108
118
|
|
109
|
-
#
|
119
|
+
# Simulation's *tS* transitions. Expects a single array of +tS+ transitions
|
120
|
+
# or their ids and returns an array of the corresponding tS transition
|
121
|
+
# representations.
|
110
122
|
#
|
111
|
-
def
|
112
|
-
|
123
|
+
def tS_Transitions( array )
|
124
|
+
transitions.tS.subset( array )
|
113
125
|
end
|
114
126
|
|
115
|
-
#
|
127
|
+
# Simulation's *tS* transitions. Without arguments, returns all the tS
|
128
|
+
# transitions of the simulation. Otherwise, it accepts an arbitrary number
|
129
|
+
# of tS transitions or transition ids as arguments, and returns an array of
|
130
|
+
# the corresponding tS transitions of the simulation.
|
116
131
|
#
|
117
|
-
def
|
118
|
-
|
132
|
+
def tS_transitions( *transitions )
|
133
|
+
return transitions().tS if transitions.empty?
|
134
|
+
tS_Transitions( transitions )
|
119
135
|
end
|
120
136
|
|
121
|
-
#
|
137
|
+
# Simulation's *Ts* transitions. Expects a single array of +Ts+ transitions
|
138
|
+
# or their ids and returns an array of the corresponding Ts transition
|
139
|
+
# representations.
|
122
140
|
#
|
123
|
-
def
|
124
|
-
|
141
|
+
def Ts_Transitions( array )
|
142
|
+
transitions.Ts.subset( array )
|
125
143
|
end
|
126
144
|
|
127
|
-
#
|
145
|
+
# Simulation's *Ts* transitions. Without arguments, returns all the Ts
|
146
|
+
# transitions of the simulation. Otherwise, it accepts an arbitrary number
|
147
|
+
# of Ts transitions or transition ids as arguments, and returns an array of
|
148
|
+
# the corresponding Ts transitions of the simulation.
|
128
149
|
#
|
129
|
-
def
|
130
|
-
|
150
|
+
def Ts_transitions( *transitions )
|
151
|
+
return transitions().Ts if transitions.empty?
|
152
|
+
Ts_Transitions( transitions )
|
131
153
|
end
|
132
154
|
|
133
|
-
#
|
155
|
+
# Simulation's *TS* transitions. Expects a single array of +TS+ transitions
|
156
|
+
# or their ids and returns an array of the corresponding TS transition
|
157
|
+
# representations.
|
134
158
|
#
|
135
|
-
def
|
136
|
-
|
159
|
+
def TS_Transitions( array )
|
160
|
+
transitions.TS.subset( array )
|
137
161
|
end
|
138
162
|
|
139
|
-
#
|
163
|
+
# Simulation's *TS* transitions. Without arguments, returns all the TS
|
164
|
+
# transitions of the simulation. Otherwise, it accepts an arbitrary number
|
165
|
+
# of TS transitions or transition ids as arguments, and returns an array of
|
166
|
+
# the corresponding TS transitions of the simulation.
|
140
167
|
#
|
141
|
-
def
|
142
|
-
|
168
|
+
def TS_transitions( *transitions )
|
169
|
+
return transitions().TS if transitions.empty?
|
170
|
+
TS_Transitions( transitions )
|
143
171
|
end
|
144
172
|
|
145
|
-
|
146
|
-
|
147
|
-
#
|
173
|
+
# Simulation's *A* transitions. Expects a single array of +A+ transitions
|
174
|
+
# or their ids and returns an array of the corresponding A transition
|
175
|
+
# representations.
|
148
176
|
#
|
149
|
-
def
|
150
|
-
|
151
|
-
Transition().instance( id )
|
152
|
-
rescue NameError, TypeError
|
153
|
-
begin
|
154
|
-
tr = net.transition( id )
|
155
|
-
Transition().instances.find { |t_rep| t_rep.source == tr } ||
|
156
|
-
Transition().instance( tr.name )
|
157
|
-
rescue NameError, TypeError => msg
|
158
|
-
raise TypeError, "The argument #{id} does not identify a " +
|
159
|
-
"transition instance! (#{msg})"
|
160
|
-
end
|
161
|
-
end
|
177
|
+
def A_Transitions( array )
|
178
|
+
transitions.A.subset( array )
|
162
179
|
end
|
163
180
|
|
164
|
-
# Without arguments, returns all the
|
165
|
-
#
|
181
|
+
# Simulation's *A* transitions. Without arguments, returns all the A
|
182
|
+
# transitions of the simulation. Otherwise, it accepts an arbitrary number
|
183
|
+
# of A transitions or transition ids as arguments, and returns an array of
|
184
|
+
# the corresponding A transitions of the simulation.
|
166
185
|
#
|
167
|
-
def transitions
|
168
|
-
return
|
169
|
-
|
186
|
+
def A_transitions( *transitions )
|
187
|
+
return transitions().A if transitions.empty?
|
188
|
+
A_Transitions( transitions )
|
170
189
|
end
|
171
190
|
|
172
|
-
# Simulation's *
|
173
|
-
#
|
174
|
-
#
|
175
|
-
# of this method.
|
191
|
+
# Simulation's *a* transitions. Expects a single array of +a+ transitions
|
192
|
+
# or their ids and returns an array of the corresponding a transition
|
193
|
+
# representations.
|
176
194
|
#
|
177
|
-
def
|
178
|
-
|
179
|
-
transitions.ts.subset( transitions ids )
|
195
|
+
def a_Transitions( array )
|
196
|
+
transitions.a.subset( array )
|
180
197
|
end
|
181
198
|
|
182
|
-
# Simulation's *
|
183
|
-
#
|
199
|
+
# Simulation's *a* transitions. Without arguments, returns all the a
|
200
|
+
# transitions of the simulation. Otherwise, it accepts an arbitrary number
|
201
|
+
# of a transitions or transition ids as arguments, and returns an array of
|
202
|
+
# the corresponding a transitions of the simulation.
|
184
203
|
#
|
185
|
-
def
|
186
|
-
return transitions.
|
187
|
-
|
204
|
+
def a_transitions( *transitions )
|
205
|
+
return transitions().a if transitions.empty?
|
206
|
+
a_Transitions( transitions )
|
188
207
|
end
|
189
208
|
|
190
|
-
# Simulation's *
|
191
|
-
#
|
209
|
+
# Simulation's *S* transitions. Expects a single array of +S+ transitions
|
210
|
+
# or their ids and returns an array of the corresponding S transition
|
211
|
+
# representations.
|
192
212
|
#
|
193
|
-
def
|
194
|
-
|
195
|
-
transitions.Ts.subset( transitions ids )
|
213
|
+
def S_Transitions( array )
|
214
|
+
transitions.S.subset( array )
|
196
215
|
end
|
197
216
|
|
198
|
-
# Simulation's *
|
199
|
-
#
|
217
|
+
# Simulation's *S* transitions. Without arguments, returns all the S
|
218
|
+
# transitions of the simulation. Otherwise, it accepts an arbitrary number
|
219
|
+
# of S transitions or transition ids as arguments, and returns an array of
|
220
|
+
# the corresponding S transitions of the simulation.
|
200
221
|
#
|
201
|
-
def
|
202
|
-
return transitions.
|
203
|
-
|
222
|
+
def S_transitions( *transitions )
|
223
|
+
return transitions().S if transitions.empty?
|
224
|
+
S_Transitions( transitions )
|
204
225
|
end
|
205
226
|
|
206
|
-
# Simulation's *
|
207
|
-
#
|
227
|
+
# Simulation's *s* transitions. Expects a single array of +s+ transitions
|
228
|
+
# or their ids and returns an array of the corresponding s transition
|
229
|
+
# representations.
|
208
230
|
#
|
209
|
-
def
|
210
|
-
|
211
|
-
transitions.A.subset( transitions ids )
|
231
|
+
def s_Transitions( array )
|
232
|
+
transitions.s.subset( array )
|
212
233
|
end
|
213
234
|
|
214
|
-
# Simulation's *
|
215
|
-
#
|
235
|
+
# Simulation's *s* transitions. Without arguments, returns all the s
|
236
|
+
# transitions of the simulation. Otherwise, it accepts an arbitrary number
|
237
|
+
# of s transitions or transition ids as arguments, and returns an array of
|
238
|
+
# the corresponding s transitions of the simulation.
|
216
239
|
#
|
217
|
-
def
|
218
|
-
return transitions.
|
219
|
-
|
240
|
+
def s_transitions( *transitions )
|
241
|
+
return transitions().s if transitions.empty?
|
242
|
+
s_Transitions( transitions )
|
220
243
|
end
|
221
244
|
|
222
|
-
# Simulation's *
|
223
|
-
#
|
245
|
+
# Simulation's *T* transitions. Expects a single array of +T+ transitions
|
246
|
+
# or their ids and returns an array of the corresponding T transition
|
247
|
+
# representations.
|
224
248
|
#
|
225
|
-
def
|
226
|
-
|
227
|
-
transitions.S.subset( transitions ids )
|
249
|
+
def T_Transitions( array )
|
250
|
+
transitions.T.subset( array )
|
228
251
|
end
|
229
252
|
|
230
|
-
# Simulation's *
|
231
|
-
#
|
253
|
+
# Simulation's *T* transitions. Without arguments, returns all the T
|
254
|
+
# transitions of the simulation. Otherwise, it accepts an arbitrary number
|
255
|
+
# of T transitions or transition ids as arguments, and returns an array of
|
256
|
+
# the corresponding T transitions of the simulation.
|
232
257
|
#
|
233
|
-
def
|
234
|
-
return transitions.
|
235
|
-
|
258
|
+
def T_transitions( *transitions )
|
259
|
+
return transitions().T if transitions.empty?
|
260
|
+
T_Transitions( transitions )
|
236
261
|
end
|
237
262
|
|
238
|
-
# Simulation's *
|
239
|
-
#
|
263
|
+
# Simulation's *t* transitions. Expects a single array of +t+ transitions
|
264
|
+
# or their ids and returns an array of the corresponding t transition
|
265
|
+
# representations.
|
240
266
|
#
|
241
|
-
def
|
242
|
-
|
243
|
-
transitions.T.subset( transitions ids )
|
267
|
+
def t_Transitions( array )
|
268
|
+
transitions.t.subset( array )
|
244
269
|
end
|
245
270
|
|
246
|
-
# Simulation's *t* transitions.
|
247
|
-
#
|
271
|
+
# Simulation's *t* transitions. Without arguments, returns all the t
|
272
|
+
# transitions of the simulation. Otherwise, it accepts an arbitrary number
|
273
|
+
# of t transitions or transition ids as arguments, and returns an array of
|
274
|
+
# the corresponding t transitions of the simulation.
|
248
275
|
#
|
249
|
-
def t_transitions
|
250
|
-
return transitions.t if
|
251
|
-
|
276
|
+
def t_transitions( *transitions )
|
277
|
+
return transitions().t if transitions.empty?
|
278
|
+
t_Transitions( transitions )
|
252
279
|
end
|
253
280
|
end # Access
|
254
281
|
end # class YPetri::Simulation::Transitions
|
@@ -1,18 +1,16 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
# Transition collection for YPetri::Simulation.
|
4
|
-
#
|
5
3
|
class YPetri::Simulation
|
6
|
-
|
4
|
+
# Transition collection for YPetri::Simulation.
|
5
|
+
#
|
6
|
+
class Transitions < Nodes
|
7
7
|
require_relative 'transitions/types'
|
8
|
-
|
8
|
+
★ Types # ★ means include
|
9
9
|
|
10
10
|
# Pushes a transition to the collection.
|
11
11
|
#
|
12
12
|
def push transition
|
13
|
-
t = begin
|
14
|
-
net.transition( transition )
|
15
|
-
rescue NameError, TypeError
|
13
|
+
t = begin; net.transition( transition ); rescue NameError, TypeError
|
16
14
|
return super transition( transition )
|
17
15
|
end
|
18
16
|
super t.name ? Transition().new( t, name: t.name ) : Transition().new( t )
|