y_petri 2.2.2 → 2.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/y_petri/agent/simulation_related.rb +37 -3
- data/lib/y_petri/dsl.rb +7 -0
- data/lib/y_petri/net/state/features.rb +8 -7
- data/lib/y_petri/net/state.rb +1 -1
- data/lib/y_petri/place/guard.rb +22 -13
- data/lib/y_petri/place/guarded.rb +30 -38
- data/lib/y_petri/place.rb +35 -43
- data/lib/y_petri/simulation/marking_vector.rb +7 -0
- data/lib/y_petri/version.rb +1 -1
- data/test/acceptance/basic_usage_test.rb +0 -1
- data/test/acceptance/simulation_test.rb +0 -1
- data/test/acceptance/simulation_with_physical_units_test.rb +0 -1
- data/test/acceptance/token_game_test.rb +1 -2
- data/test/acceptance/visualization_test.rb +0 -1
- data/test/acceptance_tests.rb +0 -1
- data/test/agent_test.rb +0 -1
- data/test/net_test.rb +0 -1
- data/test/place_test.rb +1 -2
- data/test/simulation_test.rb +0 -1
- data/test/transition_test.rb +0 -1
- data/test/world_test.rb +0 -1
- data/test/y_petri_test.rb +0 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d21a38d5b195eb6616e741ee032954f2e3c8a5f
|
4
|
+
data.tar.gz: fe9679678f401d6842e9eecec61742a44e480882
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4329188c403e5c4491f0b716736ab70ff3094f49cc34c950713c9f881e233c52f853e5776bae401ddd5236e6cbcf03ab1b61d31616daf98a33d4233f3f1be2ee
|
7
|
+
data.tar.gz: b059ae5693243f584706b30457b0a9a2d593faa700f5f63ac30f5a5a68164e9041a8a82289338f1b54a3637586a3e8507def9f1d524863b4d5c9b7dab7890800
|
@@ -271,14 +271,14 @@ module YPetri::Agent::SimulationRelated
|
|
271
271
|
|
272
272
|
# Plot system state history.
|
273
273
|
#
|
274
|
-
def
|
274
|
+
def plot_marking( place_ids=nil, except: [],
|
275
275
|
title: "State plot", ylabel: "Marking [µM]",
|
276
276
|
**options )
|
277
277
|
rec = simulation.recording
|
278
278
|
pp = simulation.pp( place_ids ) - simulation.pp( except )
|
279
279
|
rec.marking( pp ).plot( title: title, ylabel: ylabel, **options )
|
280
280
|
end
|
281
|
-
alias plot_marking
|
281
|
+
alias plot_state plot_marking
|
282
282
|
|
283
283
|
# Plot flux history of TS transitions.
|
284
284
|
#
|
@@ -327,10 +327,44 @@ module YPetri::Agent::SimulationRelated
|
|
327
327
|
options.may_have :delta_time, syn!: :Δt
|
328
328
|
rec = simulation.recording
|
329
329
|
pp = simulation.pp( place_ids ) - simulation.ee( except )
|
330
|
-
tt = transitions.nil? ? simulation.tt :
|
330
|
+
tt = transitions.nil? ? simulation.tt : transitions
|
331
331
|
tt = simulation.tt( tt )
|
332
332
|
tt -= simulation.ee( except )
|
333
333
|
rec.delta( pp, transitions: tt, Δt: options[:delta_time] )
|
334
334
|
.plot( title: title, ylabel: ylabel, **options )
|
335
335
|
end
|
336
|
+
|
337
|
+
# # Pretty print marking of the current simulation.
|
338
|
+
# #
|
339
|
+
# def marking
|
340
|
+
|
341
|
+
# end
|
342
|
+
# alias state marking
|
343
|
+
|
344
|
+
# # Pretty print the flux for the current simulation state.
|
345
|
+
# #
|
346
|
+
# def flux
|
347
|
+
|
348
|
+
# end
|
349
|
+
|
350
|
+
# # Pretty print the firing for the current simulation state.
|
351
|
+
# #
|
352
|
+
# def firing
|
353
|
+
|
354
|
+
# end
|
355
|
+
|
356
|
+
# # Pretty print the gradient for the current simulation state.
|
357
|
+
# #
|
358
|
+
# def gradient
|
359
|
+
|
360
|
+
# end
|
361
|
+
|
362
|
+
# # Pretty print deltas for the current simulation state.
|
363
|
+
# #
|
364
|
+
# def delta( place_ids=nil, except: [], transitions: nil, **options )
|
365
|
+
# Δt = options.must_have :delta_time, syn!: :Δt
|
366
|
+
# pp = simulation.pp( place_ids )
|
367
|
+
# tt = transitions.nil? ? simulation.tt : transitions
|
368
|
+
# simulation.delta( place_id, except: except, transitions: transitions )
|
369
|
+
# end
|
336
370
|
end # module YPetri::Agent::SimulationRelated
|
data/lib/y_petri/dsl.rb
CHANGED
@@ -58,10 +58,17 @@ module YPetri
|
|
58
58
|
:print_recording,
|
59
59
|
:plot,
|
60
60
|
:plot_selected,
|
61
|
+
:plot_marking,
|
61
62
|
:plot_state,
|
62
63
|
:plot_flux,
|
63
64
|
:plot_firing,
|
64
65
|
:plot_gradient,
|
65
66
|
:plot_delta,
|
67
|
+
:_marking,
|
68
|
+
:_state,
|
69
|
+
:_flux,
|
70
|
+
:_firing,
|
71
|
+
:_gradient,
|
72
|
+
:_delta,
|
66
73
|
to: :y_petri_agent
|
67
74
|
end
|
@@ -156,44 +156,45 @@ class YPetri::Net::State::Features < Array
|
|
156
156
|
|
157
157
|
alias new_record load
|
158
158
|
|
159
|
-
# Extracts the features from a given target
|
159
|
+
# Extracts the features from a given target, returning a +Record+ instance.
|
160
160
|
#
|
161
161
|
def extract_from target, **nn
|
162
162
|
values = map { |feat| feat.extract_from( target, **nn ) }
|
163
163
|
new_record( values )
|
164
164
|
end
|
165
165
|
|
166
|
-
# Constructs a new
|
166
|
+
# Constructs a new +Record+ instance from the supplied values array. The
|
167
|
+
# values in the array must correspond to the receiver feature set.
|
167
168
|
#
|
168
169
|
def new_record values
|
169
170
|
Record().load values
|
170
171
|
end
|
171
172
|
|
172
|
-
# Constructs a new dataset
|
173
|
+
# Constructs a new dataset based on the receiver feature set.
|
173
174
|
#
|
174
175
|
def new_dataset *args, &blk
|
175
176
|
DataSet().new *args, &blk
|
176
177
|
end
|
177
178
|
|
178
|
-
#
|
179
|
+
# Summation of feature sets.
|
179
180
|
#
|
180
181
|
def + other
|
181
182
|
self.class.new( super )
|
182
183
|
end
|
183
184
|
|
184
|
-
#
|
185
|
+
# Subtraction of feature sets.
|
185
186
|
#
|
186
187
|
def - other
|
187
188
|
self.class.new( super )
|
188
189
|
end
|
189
190
|
|
190
|
-
#
|
191
|
+
# Multiplication (like in arrays).
|
191
192
|
#
|
192
193
|
def * other
|
193
194
|
self.class.new( super )
|
194
195
|
end
|
195
196
|
|
196
|
-
#
|
197
|
+
# Labels of the features of the receiver feature set.
|
197
198
|
#
|
198
199
|
def labels
|
199
200
|
map &:label
|
data/lib/y_petri/net/state.rb
CHANGED
@@ -8,7 +8,7 @@ class YPetri::Net::State < Array
|
|
8
8
|
|
9
9
|
class << self
|
10
10
|
# Customization of the parametrize method for the State class: Its
|
11
|
-
# dependents Feature and Features (
|
11
|
+
# dependents Feature and Features (feature set class) are also parametrized.
|
12
12
|
#
|
13
13
|
def parametrize net: ( fail ArgumentError, "No owning net!" )
|
14
14
|
Class.new( self ).tap do |ç|
|
data/lib/y_petri/place/guard.rb
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
# Marking guard of a place.
|
4
4
|
#
|
5
5
|
class YPetri::Place::Guard
|
6
|
+
# Error message template.
|
7
|
+
#
|
6
8
|
ERRMSG = -> m, of, assert do
|
7
9
|
"Marking #{m.insp}" +
|
8
10
|
if of then " of #{of.name || of}" else '' end +
|
@@ -11,16 +13,24 @@ class YPetri::Place::Guard
|
|
11
13
|
|
12
14
|
attr_reader :place, :assertion, :block
|
13
15
|
|
14
|
-
#
|
15
|
-
# block
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
16
|
+
# Expects a guard assetion in natural language, and a guard block. Guard block
|
17
|
+
# is a unary block that validates marking. A validation fails when:
|
18
|
+
#
|
19
|
+
# 1. The block returns _false_.
|
20
|
+
# 2. The block raises +YPetri::GuardError+.
|
21
|
+
#
|
22
|
+
# In all other cases, including when the block returns _nil_ (beware!),
|
23
|
+
# the marking is considered valid. Inside the block, +#fail+ keyword is
|
24
|
+
# redefined, so that it can (and must) be called without arguments, and it
|
25
|
+
# raises an appropriately worded +GuardError+. (Other exceptions can still be
|
26
|
+
# raised using +#raise+ keyword.) Practical example:
|
27
|
+
#
|
28
|
+
# YPetri::Place::Guard.new "should be a number" do |m|
|
29
|
+
# fail unless m.is_a? Numeric
|
30
|
+
# end
|
31
|
+
#
|
32
|
+
# Then <code>guard! :foobar</code> raises +GuardError+ with a message "Marking
|
33
|
+
# foobar:Symbol should be a number!"
|
24
34
|
#
|
25
35
|
def initialize( assertion_NL_string, place: nil, &block )
|
26
36
|
@place, @assertion, @block = place, assertion_NL_string, block
|
@@ -30,8 +40,7 @@ class YPetri::Place::Guard
|
|
30
40
|
end
|
31
41
|
end
|
32
42
|
|
33
|
-
# Validates a
|
34
|
-
# +YPetri::GuardError+ if the guard fails, otherwise returns _true_.
|
43
|
+
# Validates a marking value. Raises +YPetri::GuardError+ upon failure.
|
35
44
|
#
|
36
45
|
def validate( marking )
|
37
46
|
λ = __fail__( marking, assertion )
|
@@ -43,7 +52,7 @@ class YPetri::Place::Guard
|
|
43
52
|
|
44
53
|
# Constructs the fail closure.
|
45
54
|
#
|
46
|
-
def __fail__ marking,
|
55
|
+
def __fail__ marking, assertionq
|
47
56
|
pl = place
|
48
57
|
-> { fail YPetri::GuardError, ERRMSG.( marking, pl, assertion ) }
|
49
58
|
end
|
@@ -1,60 +1,49 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
#
|
3
|
+
# Support of places' marking guards.
|
4
4
|
#
|
5
5
|
module YPetri::Place::Guarded
|
6
6
|
# Expects a guard assertion in natural language, and a guard block. Guard
|
7
|
-
# block is a unary block
|
8
|
-
# is considered as having failed if:
|
7
|
+
# block is a unary block that validates marking. A validation fails when:
|
9
8
|
#
|
10
9
|
# 1. The block returns _false_.
|
11
10
|
# 2. The block raises +YPetri::GuardError+.
|
12
11
|
#
|
13
|
-
# In all other cases, including the block
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
# method.)
|
19
|
-
#
|
20
|
-
# As for the NL assertion, apart from self-documenting the code, it is used
|
21
|
-
# for constructing appropriately worded +GuardError+ messages:
|
12
|
+
# In all other cases, including when the block returns _nil_ (beware!),
|
13
|
+
# the marking is considered valid! Inside the block, +#fail+ keyword is
|
14
|
+
# redefined so that it can (and must) be called without arguments, and it
|
15
|
+
# raises an appropriately worded +GuardError+. (Other exceptions can still
|
16
|
+
# be raised using +#raise+ keyword.) Practical example:
|
22
17
|
#
|
23
18
|
# guard "should be a number" do |m| fail unless m.is_a? Numeric end
|
24
19
|
#
|
25
|
-
# Then
|
26
|
-
# should be a number!"
|
27
|
-
#
|
28
|
-
# The method returns the reference to the +YPetri::Guard+ object, that has
|
29
|
-
# been constructed and already included in the collection of this place's
|
30
|
-
# guards.
|
20
|
+
# Then <code>guard! :foobar</code> raises +GuardError+ with a message "Marking
|
21
|
+
# foobar:Symbol should be a number!"
|
31
22
|
#
|
32
23
|
# Finally, this method is overloaded in such way, that if no block is
|
33
|
-
# given to it, it acts as
|
34
|
-
# method: It either applies the federated closure to the marking value given
|
35
|
-
# in the argument, or returns the federated closure itself if no arguemnts
|
36
|
-
# were given (behaving as +#federated_guard_closure+ alias in this case).
|
24
|
+
# given to it, it acts as an alias of +#common_guard_closure+ method.
|
37
25
|
#
|
38
26
|
def guard *args, &block
|
39
27
|
if block then
|
40
28
|
@guards << YPetri::Place::Guard.new( *args, place: self, &block )
|
41
29
|
elsif args.size == 1 then
|
42
|
-
|
30
|
+
common_guard_closure.( args[0] )
|
43
31
|
elsif args.empty? then
|
44
|
-
|
32
|
+
common_guard_closure
|
45
33
|
end
|
46
34
|
end
|
47
35
|
|
48
|
-
# Returns a
|
49
|
-
#
|
50
|
-
#
|
36
|
+
# Returns a closure combining all the guards defined for the place so far,
|
37
|
+
# which passes if, and only if, all the included guards pass. The common
|
38
|
+
# closure, if it passes, returns the tested marking value.
|
51
39
|
#
|
52
|
-
def
|
40
|
+
def common_guard_closure
|
53
41
|
place_name, lineup = name.to_s, guards.dup
|
54
|
-
->
|
42
|
+
-> marking { lineup.each { |g| g.validate marking }; marking }
|
55
43
|
end
|
56
44
|
|
57
|
-
# Applies guards
|
45
|
+
# Applies the guards defined for the place on the current marking (contents
|
46
|
+
# of +@marking+ instance variable).
|
58
47
|
#
|
59
48
|
def guard!
|
60
49
|
guard.( marking )
|
@@ -62,21 +51,24 @@ module YPetri::Place::Guarded
|
|
62
51
|
|
63
52
|
private
|
64
53
|
|
65
|
-
# If no guards were specified by the user, this method can
|
66
|
-
#
|
67
|
-
#
|
68
|
-
# interchangeable, except
|
54
|
+
# If no guards were specified by the user, this method can construct standard
|
55
|
+
# guards based on the data type of places' +marking+ and/or +default_marking+.
|
56
|
+
# (For most data types, default guards enfore type compliance. Numeric
|
57
|
+
# descendants, however, are considered interchangeable, except for Complex
|
58
|
+
# class.)
|
69
59
|
#
|
70
60
|
def add_default_guards!( reference_marking )
|
71
61
|
case reference_marking
|
72
|
-
when Complex then
|
73
|
-
|
62
|
+
when Complex then # 1 guard
|
63
|
+
marking "should be Numeric" do |m| m.is_a? Numeric end
|
64
|
+
when Numeric then # 3 guards
|
74
65
|
marking "should be Numeric" do |m| m.is_a? Numeric end
|
75
66
|
marking "should not be complex" do |m| fail if m.is_a? Complex end
|
76
67
|
marking "should not be negative" do |m| m >= 0 end
|
77
68
|
when nil then # no guards
|
78
|
-
when true, false then
|
79
|
-
|
69
|
+
when true, false then # 1 guard
|
70
|
+
marking "should be Boolean" do |m| m == !!m end
|
71
|
+
else # 1 guard
|
80
72
|
reference_marking.class.tap do |klass|
|
81
73
|
marking "should be a #{klass}" do |m| m.is_a? klass end
|
82
74
|
end
|
data/lib/y_petri/place.rb
CHANGED
@@ -23,38 +23,30 @@ class YPetri::Place
|
|
23
23
|
attr_reader :guards
|
24
24
|
attr_accessor :default_marking
|
25
25
|
|
26
|
-
#
|
27
|
-
#
|
28
|
-
# *
|
29
|
-
# *
|
30
|
-
# *
|
31
|
-
# *
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
#
|
43
|
-
#
|
44
|
-
#
|
45
|
-
# the NL assertion string of the guard under the :guard named argument, and
|
46
|
-
# supplying the guard block to the constructor. More guards can be defined
|
47
|
-
# later for the place using its +#guard+ method.
|
26
|
+
# Arguments supplied upon place initialization may include:
|
27
|
+
#
|
28
|
+
# * +:marking+
|
29
|
+
# * +:default_marking+
|
30
|
+
# * +:quantum+
|
31
|
+
# * +:guard+
|
32
|
+
#
|
33
|
+
# +Marking+ is a standard attribute of a Petri net place, +default_marking+
|
34
|
+
# is marking upon calling the reset method. Default marking may also be used
|
35
|
+
# as the initial value in the simulations involving the place in question.
|
36
|
+
# +Quantum+ attribute is not in use presently. In the future, it will be used
|
37
|
+
# to decide when to switch between continuous and discrete stochastic modeling
|
38
|
+
# of a place value. +Guard+ means a restriction of the place marking. (For
|
39
|
+
# example, the place could only admit non-negative numbers, or numbers smaller
|
40
|
+
# than 1, or odd numbers etc.) Named argument :guard along with a block
|
41
|
+
# supplied to the constructor allow one to specify a single marking guard
|
42
|
+
# upon place initialization by putting an NL assertion (a string) under
|
43
|
+
# +:guard+ argument, along with a block expressing the same meaning in code.
|
44
|
+
# More guards, if necessary, can be specified later using +Place#guard+ method.
|
48
45
|
#
|
49
46
|
# If no guard block is supplied, default guards are constructed based on the
|
50
|
-
# type of the marking or
|
51
|
-
#
|
52
|
-
#
|
53
|
-
# negative values. For all other classes, there is just one guard enforcing
|
54
|
-
# the class compliance of the marking.
|
55
|
-
#
|
56
|
-
# To construct a place with no guards whatsoever, set :guard named argument
|
57
|
-
# to _false_.
|
47
|
+
# data type of the +:marking+ or +:default_marking+ argument. If it is wished
|
48
|
+
# that the place has no guards whatsoever, +:guard+ argumend should be set to
|
49
|
+
# _false_.
|
58
50
|
#
|
59
51
|
def initialize quantum: 1,
|
60
52
|
default_marking: nil,
|
@@ -64,32 +56,31 @@ class YPetri::Place
|
|
64
56
|
@upstream_arcs, @downstream_arcs, @guards = [], [], [] # init to empty
|
65
57
|
@quantum, @default_marking = quantum, default_marking
|
66
58
|
self.marking = marking || default_marking
|
67
|
-
|
68
|
-
# Check in :guard named argument and &block.
|
59
|
+
# Check in :guard value and the corresponding &block.
|
69
60
|
if guard.ℓ? then # guard NL assertion not given, use block or default guards
|
70
61
|
block ? guard( &block ) : add_default_guards!( @marking )
|
71
62
|
elsif guard then # guard NL assertion given
|
72
63
|
fail ArgumentError, "No guard block given!" unless block
|
73
64
|
guard( guard, &block )
|
74
65
|
else
|
75
|
-
fail ArgumentError, "Block given, but :guard
|
66
|
+
fail ArgumentError, "Block given, but :guard argument is falsey!" if block
|
76
67
|
end
|
77
68
|
end
|
78
69
|
|
79
|
-
# Getter of +@marking+ attribute.
|
70
|
+
# Getter of the place's +@marking+ attribute.
|
80
71
|
#
|
81
72
|
def m
|
82
73
|
@marking
|
83
74
|
end
|
84
75
|
alias value m
|
85
76
|
|
86
|
-
#
|
87
|
-
#
|
88
|
-
#
|
77
|
+
# Used without arguments, it is a getter of the place's +@marking+ attribute,
|
78
|
+
# just like the +Place#m+ method. However, if a string and a block is supplied
|
79
|
+
# to it, it acts as an alias of the +Place#guard+ method. This is because this:
|
89
80
|
#
|
90
81
|
# marking "should be a number" do |m| fail unless m.is_a? Numeric end
|
91
82
|
#
|
92
|
-
# reads better than
|
83
|
+
# reads better than this:
|
93
84
|
#
|
94
85
|
# guard "should be a number" do |m| fail unless m.is_a? Numeric end
|
95
86
|
#
|
@@ -119,32 +110,33 @@ class YPetri::Place
|
|
119
110
|
self.marking = marking
|
120
111
|
end
|
121
112
|
|
122
|
-
# Adds tokens to the place.
|
113
|
+
# Adds tokens to the place's +@marking+ instance variable.
|
123
114
|
#
|
124
115
|
def add( amount )
|
125
116
|
@marking = guard.( @marking + amount )
|
126
117
|
end
|
127
118
|
|
128
|
-
# Subtracts tokens from the place.
|
119
|
+
# Subtracts tokens from the place's +@marking+ instance variable.
|
129
120
|
#
|
130
121
|
def subtract( amount )
|
131
122
|
@marking = guard.( @marking - amount )
|
132
123
|
end
|
133
124
|
|
134
|
-
# Resets place marking back to its default
|
125
|
+
# Resets the place's marking back to its default value (+@default_marking
|
126
|
+
# instance variable).
|
135
127
|
#
|
136
128
|
def reset_marking
|
137
129
|
@marking = guard.( @default_marking )
|
138
130
|
end
|
139
131
|
|
140
|
-
#
|
132
|
+
# Builds an inspect string of the place.
|
141
133
|
#
|
142
134
|
def inspect
|
143
135
|
n, m, d, q = instance_description_strings
|
144
136
|
"#<Place: #{ ( [n, m, d, q].compact ).join ', ' }>"
|
145
137
|
end
|
146
138
|
|
147
|
-
# Returns a string
|
139
|
+
# Returns a string representing the place.
|
148
140
|
#
|
149
141
|
def to_s
|
150
142
|
n, m = name, marking
|
@@ -163,5 +163,12 @@ class YPetri::Simulation
|
|
163
163
|
indices_of_free_places = annotation.free.map { |p| annotation.index p }
|
164
164
|
increment_at_indices_closure( indices: indices_of_free_places )
|
165
165
|
end
|
166
|
+
|
167
|
+
# Pretty-prints the marking vector.
|
168
|
+
#
|
169
|
+
def pretty_print
|
170
|
+
to_h.pretty_print_numeric_values
|
171
|
+
end
|
172
|
+
alias pp pretty_print
|
166
173
|
end
|
167
174
|
end
|
data/lib/y_petri/version.rb
CHANGED
data/test/acceptance_tests.rb
CHANGED
data/test/agent_test.rb
CHANGED
data/test/net_test.rb
CHANGED
data/test/place_test.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
#! /usr/bin/ruby
|
2
2
|
# encoding: utf-8
|
3
3
|
|
4
|
-
# gem 'minitest', '=4.7.4' # try uncommenting this line if problems appear
|
5
4
|
require 'minitest/autorun'
|
6
5
|
require_relative '../lib/y_petri' # tested component itself
|
7
6
|
# require 'y_petri'
|
@@ -61,7 +60,7 @@ describe YPetri::Place do
|
|
61
60
|
-> { g2.validate Complex( 1, 1 ) }.must_raise YPetri::GuardError
|
62
61
|
p.marking "must be in 0..10" do |m| fail unless ( 0..10 ) === m end
|
63
62
|
p.guards.size.must_equal 4
|
64
|
-
g = p.
|
63
|
+
g = p.common_guard_closure
|
65
64
|
-> { g.( 11.1 ) }.must_raise YPetri::GuardError
|
66
65
|
begin; p.marking = -1.11; rescue YPetri::GuardError => err
|
67
66
|
err.message.must_equal 'Marking -1.11:Float of P1 should not be negative!'
|
data/test/simulation_test.rb
CHANGED
data/test/transition_test.rb
CHANGED
data/test/world_test.rb
CHANGED
data/test/y_petri_test.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.2.
|
4
|
+
version: 2.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- boris
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: y_support
|