y_petri 2.0.15 → 2.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/lib/y_petri/{manipulator → agent}/hash_key_pointer.rb +2 -2
  3. data/lib/y_petri/agent/petri_net_related.rb +115 -0
  4. data/lib/y_petri/{manipulator → agent}/selection.rb +2 -1
  5. data/lib/y_petri/{manipulator/simulation_related_methods.rb → agent/simulation_related.rb} +93 -110
  6. data/lib/y_petri/agent.rb +22 -0
  7. data/lib/y_petri/core/timed/euler.rb +20 -0
  8. data/lib/y_petri/core/timed/pseudo_euler.rb +31 -0
  9. data/lib/y_petri/core/timed/quasi_euler.rb +23 -0
  10. data/lib/y_petri/core/timed.rb +70 -0
  11. data/lib/y_petri/core/timeless/pseudo_euler.rb +20 -0
  12. data/lib/y_petri/core/timeless.rb +12 -0
  13. data/lib/y_petri/core.rb +100 -0
  14. data/lib/y_petri/dsl.rb +66 -0
  15. data/lib/y_petri/fixed_assets.rb +7 -0
  16. data/lib/y_petri/net/element_access.rb +239 -0
  17. data/lib/y_petri/net/state/feature/delta.rb +88 -0
  18. data/lib/y_petri/net/state/feature/firing.rb +57 -0
  19. data/lib/y_petri/net/state/feature/flux.rb +58 -0
  20. data/lib/y_petri/net/state/feature/gradient.rb +75 -0
  21. data/lib/y_petri/net/state/feature/marking.rb +62 -0
  22. data/lib/y_petri/net/state/feature.rb +79 -0
  23. data/lib/y_petri/net/state/features/dataset.rb +135 -0
  24. data/lib/y_petri/net/state/features/record.rb +50 -0
  25. data/lib/y_petri/net/state/features.rb +126 -0
  26. data/lib/y_petri/net/state.rb +121 -0
  27. data/lib/y_petri/net/timed.rb +8 -0
  28. data/lib/y_petri/net/visualization.rb +3 -3
  29. data/lib/y_petri/net.rb +73 -77
  30. data/lib/y_petri/place.rb +8 -3
  31. data/lib/y_petri/simulation/dependency.rb +107 -0
  32. data/lib/y_petri/simulation/element_representation.rb +20 -0
  33. data/lib/y_petri/simulation/elements/access.rb +57 -0
  34. data/lib/y_petri/simulation/elements.rb +45 -0
  35. data/lib/y_petri/simulation/feature_set.rb +21 -0
  36. data/lib/y_petri/simulation/initial_marking/access.rb +55 -0
  37. data/lib/y_petri/simulation/initial_marking.rb +15 -0
  38. data/lib/y_petri/simulation/marking_clamps/access.rb +34 -0
  39. data/lib/y_petri/simulation/marking_clamps.rb +18 -0
  40. data/lib/y_petri/simulation/marking_vector/access.rb +106 -0
  41. data/lib/y_petri/simulation/marking_vector.rb +156 -0
  42. data/lib/y_petri/simulation/matrix.rb +64 -0
  43. data/lib/y_petri/simulation/place_mapping.rb +62 -0
  44. data/lib/y_petri/simulation/place_representation.rb +74 -0
  45. data/lib/y_petri/simulation/places/access.rb +121 -0
  46. data/lib/y_petri/simulation/places/clamped.rb +8 -0
  47. data/lib/y_petri/simulation/places/free.rb +8 -0
  48. data/lib/y_petri/simulation/places/types.rb +25 -0
  49. data/lib/y_petri/simulation/places.rb +41 -0
  50. data/lib/y_petri/simulation/recorder.rb +54 -0
  51. data/lib/y_petri/simulation/timed/recorder.rb +53 -0
  52. data/lib/y_petri/simulation/timed.rb +161 -261
  53. data/lib/y_petri/simulation/timeless/recorder.rb +25 -0
  54. data/lib/y_petri/simulation/timeless.rb +35 -0
  55. data/lib/y_petri/simulation/transition_representation/A.rb +58 -0
  56. data/lib/y_petri/simulation/transition_representation/S.rb +45 -0
  57. data/lib/y_petri/simulation/transition_representation/T.rb +80 -0
  58. data/lib/y_petri/simulation/transition_representation/TS.rb +46 -0
  59. data/lib/y_petri/simulation/transition_representation/Ts.rb +32 -0
  60. data/lib/y_petri/simulation/transition_representation/a.rb +30 -0
  61. data/lib/y_petri/simulation/transition_representation/s.rb +29 -0
  62. data/lib/y_petri/simulation/transition_representation/t.rb +37 -0
  63. data/lib/y_petri/simulation/transition_representation/tS.rb +38 -0
  64. data/lib/y_petri/simulation/transition_representation/ts.rb +32 -0
  65. data/lib/y_petri/simulation/transition_representation/types.rb +62 -0
  66. data/lib/y_petri/simulation/transition_representation.rb +79 -0
  67. data/lib/y_petri/simulation/transitions/A.rb +40 -0
  68. data/lib/y_petri/simulation/transitions/S.rb +24 -0
  69. data/lib/y_petri/simulation/transitions/T.rb +34 -0
  70. data/lib/y_petri/simulation/transitions/TS.rb +57 -0
  71. data/lib/y_petri/simulation/transitions/Ts.rb +60 -0
  72. data/lib/y_petri/simulation/transitions/a.rb +8 -0
  73. data/lib/y_petri/simulation/transitions/access.rb +186 -0
  74. data/lib/y_petri/simulation/transitions/s.rb +9 -0
  75. data/lib/y_petri/simulation/transitions/t.rb +22 -0
  76. data/lib/y_petri/simulation/transitions/tS.rb +55 -0
  77. data/lib/y_petri/simulation/transitions/ts.rb +58 -0
  78. data/lib/y_petri/simulation/transitions/types.rb +98 -0
  79. data/lib/y_petri/simulation/transitions.rb +21 -0
  80. data/lib/y_petri/simulation.rb +176 -781
  81. data/lib/y_petri/transition/assignment.rb +7 -5
  82. data/lib/y_petri/transition/construction.rb +119 -187
  83. data/lib/y_petri/transition/init.rb +311 -0
  84. data/lib/y_petri/transition/ordinary_timeless.rb +8 -6
  85. data/lib/y_petri/transition/timed.rb +11 -18
  86. data/lib/y_petri/transition.rb +104 -132
  87. data/lib/y_petri/version.rb +1 -1
  88. data/lib/y_petri/world/dependency.rb +40 -0
  89. data/lib/y_petri/world/petri_net_related.rb +61 -0
  90. data/lib/y_petri/{workspace/simulation_related_methods.rb → world/simulation_related.rb} +42 -49
  91. data/lib/y_petri/world.rb +27 -0
  92. data/lib/y_petri.rb +47 -99
  93. data/test/{manipulator_test.rb → agent_test.rb} +19 -17
  94. data/{lib/y_petri → test/examples}/demonstrator.rb +0 -0
  95. data/{lib/y_petri → test/examples}/demonstrator_2.rb +1 -0
  96. data/{lib/y_petri → test/examples}/demonstrator_3.rb +0 -0
  97. data/{lib/y_petri → test/examples}/demonstrator_4.rb +0 -0
  98. data/test/examples/example_2.rb +16 -0
  99. data/test/{manual_examples.rb → examples/manual_examples.rb} +0 -0
  100. data/test/net_test.rb +126 -121
  101. data/test/place_test.rb +1 -1
  102. data/test/sim_test +565 -0
  103. data/test/simulation_test.rb +338 -264
  104. data/test/transition_test.rb +77 -174
  105. data/test/world_mock.rb +12 -0
  106. data/test/{workspace_test.rb → world_test.rb} +19 -20
  107. data/test/y_petri_test.rb +4 -5
  108. metadata +101 -26
  109. data/lib/y_petri/dependency_injection.rb +0 -45
  110. data/lib/y_petri/manipulator/petri_net_related_methods.rb +0 -74
  111. data/lib/y_petri/manipulator.rb +0 -20
  112. data/lib/y_petri/net/selections.rb +0 -209
  113. data/lib/y_petri/simulation/collections.rb +0 -460
  114. data/lib/y_petri/workspace/parametrized_subclassing.rb +0 -22
  115. data/lib/y_petri/workspace/petri_net_related_methods.rb +0 -88
  116. data/lib/y_petri/workspace.rb +0 -16
  117. data/test/timed_simulation_test.rb +0 -153
@@ -1,74 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- # Public command interface of YPetri.
3
- #
4
- module YPetri::Manipulator::PetriNetRelatedMethods
5
- # Net selection class.
6
- #
7
- NetSelection = Class.new YPetri::Manipulator::Selection
8
-
9
- # Net point
10
- #
11
- attr_reader :net_point
12
-
13
- # Net selection.
14
- #
15
- attr_reader :net_selection
16
-
17
- def initialize
18
- net_point_reset
19
- @net_selection = NetSelection.new
20
- super
21
- end
22
-
23
- delegate :place, :transition, :pl, :tr,
24
- :places, :transitions, :nets,
25
- :pp, :tt, :nn, to: :workspace
26
-
27
- # Place constructor: Creates a new place in the current workspace.
28
- #
29
- def Place( *ordered_args, **named_args, &block )
30
- fail ArgumentError, "If block is given, :guard named argument " +
31
- "must not be given!" if named_args.has? :guard if block
32
- named_args.update( guard: block ) if block # use block as a guard
33
- named_args.may_have :default_marking, syn!: :m!
34
- named_args.may_have :marking, syn!: :m
35
- workspace.Place.new *ordered_args, **named_args
36
- end
37
-
38
- # Transiton constructor: Creates a new transition in the current workspace.
39
- #
40
- def Transition( *aa, **oo, &b )
41
- workspace.Transition.new *aa, **oo, &b
42
- end
43
-
44
- # Net constructor: Creates a new Net instance in the current workspace.
45
- #
46
- def Net *aa, **oo, &b
47
- workspace.Net.new *aa, **oo, &b
48
- end
49
-
50
- # Returns the net identified, or the net at point (if no argument given).
51
- #
52
- def net id=nil
53
- id.nil? ? @net_point : workspace.net( id )
54
- end
55
-
56
- # Returns the name of the identified net, or of the net at point (if no
57
- # argument given).
58
- #
59
- def ne id=nil
60
- net( id ).name
61
- end
62
-
63
- # Sets net point to workspace.Net::Top
64
- #
65
- def net_point_reset
66
- net_point_set( workspace.Net::Top )
67
- end
68
-
69
- # Sets net point to the net identified by the argument (by name or instance).
70
- #
71
- def net_point_set id
72
- @net_point = workspace.net( id )
73
- end
74
- end # module YPetri::Manipulator::PetriNetRelatedMethods
@@ -1,20 +0,0 @@
1
- #encoding: utf-8
2
-
3
- # Public command interface of YPetri.
4
- #
5
- class YPetri::Manipulator
6
- attr_reader :workspace
7
-
8
- def initialize
9
- @workspace = YPetri::Workspace.new
10
- super
11
- end
12
-
13
- require_relative 'manipulator/selection'
14
- require_relative 'manipulator/hash_key_pointer'
15
- require_relative 'manipulator/petri_net_related_methods'
16
- require_relative 'manipulator/simulation_related_methods'
17
-
18
- include YPetri::Manipulator::PetriNetRelatedMethods
19
- include YPetri::Manipulator::SimulationRelatedMethods
20
- end # class YPetri::Manipulator
@@ -1,209 +0,0 @@
1
- # Selections of various kinds of places / transitions (place names / transition
2
- # names) in a Petri net.
3
- #
4
- class YPetri::Net
5
- # Names of places in the net.
6
- #
7
- def pp
8
- places.map &:name
9
- end
10
-
11
- # Names of transitions in the net.
12
- #
13
- def tt
14
- transitions.map &:name
15
- end
16
-
17
- # Array of _ts_ transitions in the net.
18
- #
19
- def timeless_nonstoichiometric_transitions
20
- transitions.select { |t| t.timeless? && t.nonstoichiometric? }
21
- end
22
- alias ts_transitions timeless_nonstoichiometric_transitions
23
-
24
- # Names of _ts_ transitions in the net.
25
- #
26
- def timeless_nonstoichiometric_tt
27
- timeless_nonstoichiometric_transitions.map &:name
28
- end
29
- alias ts_tt timeless_nonstoichiometric_tt
30
-
31
- # Array of _tsa_ transitions in the net.
32
- #
33
- def timeless_nonstoichiometric_nonassignment_transitions
34
- transitions.select { |t|
35
- t.timeless? && t.nonstoichiometric? && ! t.assignment_action?
36
- }
37
- end
38
- alias tsa_transitions timeless_nonstoichiometric_nonassignment_transitions
39
-
40
- # Names of _tsa_ transitions in the net.
41
- #
42
- def timeless_nonstoichiometric_nonassignment_tt
43
- timeless_nonstoichiometric_nonassignment_transitions.map &:name
44
- end
45
- alias tsa_tt timeless_nonstoichiometric_nonassignment_tt
46
-
47
- # Array of _tS_ transitions in the net.
48
- #
49
- def timeless_stoichiometric_transitions
50
- transitions.select { |t| t.timeless? && t.stoichiometric? }
51
- end
52
- alias tS_transitions timeless_stoichiometric_transitions
53
-
54
- # Names of _tS_ transitions in the net.
55
- #
56
- def timeless_stoichiometric_tt
57
- timeless_stoichiometric_transitions.map &:name
58
- end
59
- alias tS_tt timeless_stoichiometric_tt
60
-
61
- # Array of _Tsr_ transitions in the net.
62
- #
63
- def timed_nonstoichiometric_transitions_without_rate
64
- transitions.select { |t| t.timed? && t.nonstoichiometric? && t.rateless? }
65
- end
66
- alias timed_rateless_nonstoichiometric_transitions \
67
- timed_nonstoichiometric_transitions_without_rate
68
- alias Tsr_transitions timed_nonstoichiometric_transitions_without_rate
69
-
70
- # Names of _Tsr_ transitions in the net.
71
- #
72
- def timed_nonstoichiometric_tt_without_rate
73
- timed_nonstoichiometric_transitions_without_rate.map &:name
74
- end
75
- alias timed_rateless_nonstoichiometric_tt \
76
- timed_nonstoichiometric_tt_without_rate
77
- alias Tsr_tt timed_nonstoichiometric_tt_without_rate
78
-
79
- # Array of _TSr_ transitions in the net.
80
- #
81
- def timed_stoichiometric_transitions_without_rate
82
- transitions.select { |t| t.timed? && t.stoichiometric? && t.rateless? }
83
- end
84
- alias timed_rateless_stoichiometric_transitions \
85
- timed_stoichiometric_transitions_without_rate
86
- alias TSr_transitions timed_stoichiometric_transitions_without_rate
87
-
88
- # Names of _TSr_ transitions in the net.
89
- #
90
- def timed_stoichiometric_tt_without_rate
91
- timed_stoichiometric_transitions_without_rate.map &:name
92
- end
93
- alias timed_rateless_stoichiometric_tt timed_stoichiometric_tt_without_rate
94
- alias Tsr_tt timed_stoichiometric_tt_without_rate
95
-
96
- # Array of _sR_ transitions in the net.
97
- #
98
- def nonstoichiometric_transitions_with_rate
99
- transitions.select { |t| t.has_rate? && t.nonstoichiometric? }
100
- end
101
- alias sR_transitions nonstoichiometric_transitions_with_rate
102
-
103
- # Names of _sR_ transitions in the net.
104
- #
105
- def nonstoichiometric_tt_with_rate
106
- nonstoichiometric_transitions_with_rate.map &:name
107
- end
108
- alias sR_tt nonstoichiometric_tt_with_rate
109
-
110
- # Array of _SR_ transitions in the net.
111
- #
112
- def stoichiometric_transitions_with_rate
113
- transitions.select { |t| t.has_rate? and t.stoichiometric? }
114
- end
115
- alias SR_transitions stoichiometric_transitions_with_rate
116
-
117
- # Names of _SR_ transitions in the net.
118
- #
119
- def stoichiometric_tt_with_rate
120
- stoichiometric_transitions_with_rate.map &:name
121
- end
122
- alias SR_tt stoichiometric_tt_with_rate
123
-
124
- # Array of transitions with _explicit assignment action_ (_A transitions_)
125
- # in the net.
126
- #
127
- def assignment_transitions
128
- transitions.select { |t| t.assignment_action? }
129
- end
130
- alias A_transitions assignment_transitions
131
-
132
- # Names of transitions with _explicit assignment action_ (_A transitions_)
133
- # in the net.
134
- #
135
- def assignment_tt
136
- assignment_transitions.map &:name
137
- end
138
- alias A_tt assignment_tt
139
-
140
- # Array of _stoichiometric_ transitions in the net.
141
- #
142
- def stoichiometric_transitions
143
- transitions.select &:stoichiometric?
144
- end
145
- alias S_transitions stoichiometric_transitions
146
-
147
- # Names of _stoichiometric_ transitions in the net.
148
- #
149
- def stoichiometric_tt
150
- stoichiometric_transitions.map &:name
151
- end
152
- alias S_tt stoichiometric_tt
153
-
154
- # Array of _nonstoichiometric_ transitions in the net.
155
- #
156
- def nonstoichiometric_transitions
157
- transitions.select &:nonstoichiometric?
158
- end
159
- alias s_transitions nonstoichiometric_transitions
160
-
161
- # Names of _nonstoichimetric_ transitions in the net.
162
- #
163
- def nonstoichiometric_tt
164
- nonstoichiometric_transitions.map &:name
165
- end
166
- alias s_tt nonstoichiometric_tt
167
-
168
- # Array of _timed_ transitions in the net.
169
- #
170
- def timed_transitions; transitions.select &:timed? end
171
- alias T_transitions timed_transitions
172
-
173
- # Names of _timed_ transitions in the net.
174
- #
175
- def timed_tt; timed_transitions.map &:name end
176
- alias T_tt timed_tt
177
-
178
- # Array of _timeless_ transitions in the net.
179
- #
180
- def timeless_transitions; transitions.select &:timeless? end
181
- alias t_transitions timeless_transitions
182
-
183
- # Names of _timeless_ transitions in the net.
184
- #
185
- def timeless_tt; timeless_transitions.map &:name end
186
- alias t_tt timeless_tt
187
-
188
- # Array of _transitions with rate_ in the net.
189
- #
190
- def transitions_with_rate; transitions.select &:has_rate? end
191
- alias R_transitions transitions_with_rate
192
-
193
- # Names of _transitions with rate_ in the net.
194
- #
195
- def tt_with_rate; transitions_with_rate.map &:name end
196
- alias R_tt tt_with_rate
197
-
198
- # Array of _rateless_ transitions in the net.
199
- #
200
- def rateless_transitions; transitions.select &:rateless? end
201
- alias transitions_without_rate rateless_transitions
202
- alias r_transitions rateless_transitions
203
-
204
- # Names of _rateless_ transitions in the net.
205
- #
206
- def rateless_tt; rateless_transitions.map &:name end
207
- alias tt_without_rate rateless_tt
208
- alias r_tt rateless_tt
209
- end # class YPetri::Net