y_petri 2.1.42 → 2.1.44
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e7e84620c9fabe978f5052540808f8533dc6263
|
4
|
+
data.tar.gz: 8bbd7f73ee8d5bd53f3e4c4ff160f11615752109
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ed28df4ab7414b9a9aa165eff7861789a881caebfadba84c2e73d41a989f609a04117dddb2df78180861986a2b4bc957945ba446cfa1a0a369f5a4d15f49307
|
7
|
+
data.tar.gz: e591a344d139ae9ff39ee4459879341038154cd1509ea5f62a315755fb0764a9f7f2e2a505e891613fa88d177da5b15c54f6747e7560eb1fd65abe9983521832
|
@@ -73,7 +73,9 @@ class YPetri::Net::State::Features::Record < Array
|
|
73
73
|
#
|
74
74
|
def reconstruct **settings
|
75
75
|
marking_clamps = settings[:marking_clamps] || {}
|
76
|
-
|
76
|
+
clamped_places = net.places( marking_clamps.keys )
|
77
|
+
ff = features.marking - net.State.marking( clamped_places )
|
78
|
+
m_hsh = ff.map { |feat| feat.place } >> marking
|
77
79
|
net.simulation marking_clamps: marking_clamps, marking: m_hsh, **settings
|
78
80
|
end
|
79
81
|
|
@@ -119,12 +119,17 @@ class YPetri::Net::State::Features < Array
|
|
119
119
|
#
|
120
120
|
def infer_from_elements( net_elements )
|
121
121
|
new net_elements.map { |e| net.element( e ) }.map { |e|
|
122
|
-
element, element_type =
|
123
|
-
|
124
|
-
|
125
|
-
|
122
|
+
element, element_type = case e
|
123
|
+
when Feature() then [ e, :feature ]
|
124
|
+
else
|
125
|
+
begin
|
126
|
+
[ net.place( e ), :place ]
|
127
|
+
rescue TypeError, NameError
|
128
|
+
[ net.transition( e ), :transition ]
|
129
|
+
end
|
126
130
|
end
|
127
131
|
case element_type
|
132
|
+
when :feature then element
|
128
133
|
when :place then Marking( element )
|
129
134
|
when :transition then
|
130
135
|
fail TypeError, "Flux / firing features can only be auto-inferred " +
|
@@ -153,6 +153,7 @@ module YPetri::Simulation::Timed
|
|
153
153
|
#
|
154
154
|
def init **settings
|
155
155
|
method = settings[:method] # the simulation method
|
156
|
+
features_to_record = settings[:record]
|
156
157
|
if settings.has? :time, syn!: :time_range then # time range given
|
157
158
|
case settings[:time]
|
158
159
|
when Range then
|
@@ -177,7 +178,19 @@ module YPetri::Simulation::Timed
|
|
177
178
|
@step = settings[:step] || time_unit
|
178
179
|
@default_sampling = settings[:sampling] || step
|
179
180
|
@core = Core().new( method: method, guarded: guarded )
|
180
|
-
@recorder =
|
181
|
+
@recorder = if features_to_record then
|
182
|
+
# we'll have to figure out features
|
183
|
+
ff = case features_to_record
|
184
|
+
when Array then
|
185
|
+
net.State.Features
|
186
|
+
.infer_from_elements( features_to_record )
|
187
|
+
when Hash then
|
188
|
+
net.State.features( features_to_record )
|
189
|
+
end
|
190
|
+
Recorder().new( sampling: settings[:sampling], features: ff )
|
191
|
+
else
|
192
|
+
Recorder().new( sampling: settings[:sampling] )
|
193
|
+
end
|
181
194
|
end
|
182
195
|
|
183
196
|
# Sets up subclasses of +Core+ (the simulator) and +Recorder+ (the sampler)
|
@@ -20,9 +20,22 @@ class YPetri::Simulation
|
|
20
20
|
#
|
21
21
|
def init **settings
|
22
22
|
method = settings[:method] # the simulation method
|
23
|
+
features_to_record = settings[:record]
|
23
24
|
init_core_and_recorder_subclasses
|
24
25
|
@core = Core().new( method: method, guarded: guarded )
|
25
|
-
@recorder =
|
26
|
+
@recorder = if features_to_record then
|
27
|
+
# we'll have to figure out features
|
28
|
+
ff = case features_to_record
|
29
|
+
when Array then
|
30
|
+
net.State.Features
|
31
|
+
.infer_from_elements( features_to_record )
|
32
|
+
when Hash then
|
33
|
+
net.State.features( features_to_record )
|
34
|
+
end
|
35
|
+
Recorder().new( features: ff )
|
36
|
+
else
|
37
|
+
Recorder().new # init the recorder
|
38
|
+
end
|
26
39
|
end
|
27
40
|
|
28
41
|
# Sets up subclasses of +Core+ (the simulator) and +Recorder+ (the sampler)
|
data/lib/y_petri/simulation.rb
CHANGED
@@ -79,6 +79,12 @@ class YPetri::Simulation
|
|
79
79
|
delegate :recording,
|
80
80
|
to: :recorder
|
81
81
|
|
82
|
+
alias r recording
|
83
|
+
|
84
|
+
delegate :plot,
|
85
|
+
:print,
|
86
|
+
to: :recording
|
87
|
+
|
82
88
|
# The basic simulation parameter is :net – +YPetri::Net+ instance which to
|
83
89
|
# simulate. Net implies the collection of places and transitions. Other
|
84
90
|
# required attributes are +:marking_clamps+ and +:initial_marking+
|
@@ -124,17 +130,12 @@ class YPetri::Simulation
|
|
124
130
|
# Clamped places' mapping to the clamp values.
|
125
131
|
@marking_clamps = MarkingClamps().load( m_clamps )
|
126
132
|
# Free places' mapping to the initial marking values.
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
@initial_marking = InitialMarking().load( rslt )
|
134
|
-
else
|
135
|
-
@initial_marking = InitialMarking().load( init_m )
|
136
|
-
end
|
137
|
-
|
133
|
+
@initial_marking = InitialMarking()
|
134
|
+
.load( if m then # use :marking as :initial_marking when possible
|
135
|
+
init_m_from_init_m = PlaceMapping().load( init_m )
|
136
|
+
init_m_from_marking = PlaceMapping().load( m )
|
137
|
+
init_m_from_marking.merge init_m_from_init_m
|
138
|
+
else init_m end )
|
138
139
|
# Set up the place and transition collections.
|
139
140
|
@places.complete_initial_marking( use_default_marking: use_default_marking )
|
140
141
|
# Correspondence matrix free --> all
|
data/lib/y_petri/version.rb
CHANGED
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.1.
|
4
|
+
version: 2.1.44
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- boris
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: y_support
|