y_petri 2.4.2 → 2.4.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.rb +0 -2
- data/lib/y_petri/agent/petri_net_aspect.rb +1 -1
- data/lib/y_petri/place/guard.rb +1 -1
- data/lib/y_petri/simulation/timed.rb +18 -3
- data/lib/y_petri/transition/A.rb +7 -9
- data/lib/y_petri/transition/T.rb +6 -8
- data/lib/y_petri/transition/t.rb +6 -8
- data/lib/y_petri/version.rb +1 -1
- data/lib/y_petri/world/simulation_aspect.rb +1 -1
- data/test/agent_test.rb +1 -1
- data/test/net_test.rb +3 -3
- data/test/place_test.rb +1 -1
- data/test/world_test.rb +13 -11
- 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: 06d8f9b1a6908fc67194dfd3191b23507f464902
|
4
|
+
data.tar.gz: 48003b2be2c2ec91037fff8da8af9105db5a2e1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36b5c04eba5b0890245f665d2275aa27668e8bec8080cf26b211e4b061302a7358bf7537b41d1acb9c81ea841680cb0b56075e170f79c78b34de77dbddffb88a
|
7
|
+
data.tar.gz: 7bed185007a8c5cbc55da85f8e654678a359c3f7d8157c8abe651f8d6735b1950e90e62bcbff2f1eb0323ebd747c487d7e6e4f60d7f94c0961c5eea55580a74a
|
data/lib/y_petri.rb
CHANGED
@@ -6,10 +6,8 @@ require 'y_support/respond_to' # Symbol#~@ + RespondTo#===
|
|
6
6
|
require 'y_support/name_magic' # naming by assignment & more
|
7
7
|
require 'y_support/unicode' # ç means self.class
|
8
8
|
require 'y_support/typing' # run-time assertions
|
9
|
-
require 'y_support/try' # increased awareness in danger
|
10
9
|
require 'y_support/core_ext' # core extensions
|
11
10
|
require 'y_support/stdlib_ext/matrix' # matrix extensions
|
12
|
-
require 'y_support/abstract_algebra' #
|
13
11
|
require 'y_support/kde' # popup file with kioclient
|
14
12
|
|
15
13
|
# ActiveSupport components:
|
@@ -153,7 +153,7 @@ module YPetri::Agent::PetriNetAspect
|
|
153
153
|
|
154
154
|
# Sets the net point to a given net, or to world.Net::Top if none given.
|
155
155
|
#
|
156
|
-
def net_point_reset id=world.Net
|
156
|
+
def net_point_reset id=world.Net.instance( :Top )
|
157
157
|
@net_point = world.net( id )
|
158
158
|
end
|
159
159
|
|
data/lib/y_petri/place/guard.rb
CHANGED
@@ -240,7 +240,12 @@ module YPetri::Simulation::Timed
|
|
240
240
|
when Range then
|
241
241
|
time_range = settings[:time]
|
242
242
|
@initial_time, @target_time = time_range.begin, time_range.end
|
243
|
-
@time_unit = initial_time
|
243
|
+
@time_unit = case initial_time
|
244
|
+
when Float then 1.0
|
245
|
+
when Integer then 1
|
246
|
+
else
|
247
|
+
initial_time.class.one
|
248
|
+
end
|
244
249
|
else
|
245
250
|
# TODO: When using simulation after some time, I found this behavior
|
246
251
|
# surprising. I wanted to call simulation time: 100, expecting it
|
@@ -261,7 +266,12 @@ module YPetri::Simulation::Timed
|
|
261
266
|
# users can always modify time later (simulation.time = something).
|
262
267
|
#
|
263
268
|
@initial_time = settings[:time]
|
264
|
-
@time_unit = initial_time
|
269
|
+
@time_unit = case initial_time
|
270
|
+
when Float then 1.0
|
271
|
+
when Integer then 1
|
272
|
+
else
|
273
|
+
initial_time.class.one
|
274
|
+
end
|
265
275
|
@target_time = time_unit * Float::INFINITY
|
266
276
|
end
|
267
277
|
else
|
@@ -269,7 +279,12 @@ module YPetri::Simulation::Timed
|
|
269
279
|
msg = "The simulation is timed, but the constructor lacks any of the " +
|
270
280
|
"time-related arguments: :time, :step, or :sampling!"
|
271
281
|
fail ArgumentError, msg unless anything
|
272
|
-
@time_unit = anything
|
282
|
+
@time_unit = case anything
|
283
|
+
when Float then 1.0
|
284
|
+
when Integer then 1
|
285
|
+
else
|
286
|
+
anything.class.one
|
287
|
+
end
|
273
288
|
@initial_time, @target_time = time_unit * 0, time_unit * Float::INFINITY
|
274
289
|
end
|
275
290
|
# Set up a parametrized subclas of the sampler for timed simulation.
|
data/lib/y_petri/transition/A.rb
CHANGED
@@ -19,15 +19,13 @@ module YPetri::Transition::Type_A
|
|
19
19
|
# Assigns the action closure result to the codomain, regardless of cocking.
|
20
20
|
#
|
21
21
|
def fire!
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
}
|
30
|
-
end
|
22
|
+
act = Array( action )
|
23
|
+
fail TypeError, "Wrong output arity of the action " +
|
24
|
+
"closure of #{self}" if act.size != codomain.size
|
25
|
+
codomain.each_with_index { |place, index|
|
26
|
+
# assigning action node no. index to place
|
27
|
+
place.marking = act.fetch( index )
|
28
|
+
}
|
31
29
|
return nil
|
32
30
|
end
|
33
31
|
|
data/lib/y_petri/transition/T.rb
CHANGED
@@ -25,14 +25,12 @@ module YPetri::Transition::Type_T
|
|
25
25
|
# Δt as an argument.
|
26
26
|
#
|
27
27
|
def fire! Δt
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
p.add note( "marking change", is: act.fetch( i ) )
|
35
|
-
end
|
28
|
+
action = Array( action Δt )
|
29
|
+
fail TypeError, "Wrong output arity of the action " +
|
30
|
+
"closure of #{self}!" if action.size != codomain.size
|
31
|
+
codomain.each_with_index do |place, index|
|
32
|
+
# Adding action place no. index to place"
|
33
|
+
place.add action.fetch( index )
|
36
34
|
end
|
37
35
|
return nil
|
38
36
|
end
|
data/lib/y_petri/transition/t.rb
CHANGED
@@ -24,14 +24,12 @@ module YPetri::Transition::Type_t
|
|
24
24
|
# Fires the transition regardless of cocking.
|
25
25
|
#
|
26
26
|
def fire!
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
p.add note( "marking change", is: act.fetch( i ) )
|
34
|
-
end
|
27
|
+
act = Array( action )
|
28
|
+
fail TypeError, "Wrong output arity of the action " +
|
29
|
+
"closure of #{self}!" if act.size != codomain.size
|
30
|
+
codomain.each_with_index do |place, index|
|
31
|
+
# adding action node no. index to place
|
32
|
+
place.add act.fetch( index )
|
35
33
|
end
|
36
34
|
return nil
|
37
35
|
end
|
data/lib/y_petri/version.rb
CHANGED
@@ -282,7 +282,7 @@ module YPetri::World::SimulationAspect
|
|
282
282
|
settings.may_have :cc, syn!: :clamp_collection
|
283
283
|
settings.may_have :imc, syn!: :initial_marking_collection
|
284
284
|
settings.may_have :ssc, syn!: :simulation_settings_collection
|
285
|
-
{ net: net( settings[:net] || self.Net
|
285
|
+
{ net: net( settings[:net] || self.Net.instance( :Top ) ), # the key
|
286
286
|
cc: settings[:cc] || :Base,
|
287
287
|
imc: settings[:imc] || :Base,
|
288
288
|
ssc: settings[:ssc] || :Base }
|
data/test/agent_test.rb
CHANGED
@@ -15,7 +15,7 @@ describe YPetri::Agent do
|
|
15
15
|
# --- net point related assets ---
|
16
16
|
@m.net_point_reset
|
17
17
|
@m.net_point_reset @m.world.net( :Top )
|
18
|
-
@m.net.must_equal @m.world.Net
|
18
|
+
@m.net.must_equal @m.world.Net.instance( :Top )
|
19
19
|
# --- simulation point related assets ---
|
20
20
|
@m.simulation_point.reset
|
21
21
|
@m.simulation.must_equal nil
|
data/test/net_test.rb
CHANGED
@@ -89,9 +89,9 @@ describe YPetri::Net do
|
|
89
89
|
|
90
90
|
describe "plus 1 stoichio. transition with rate" do
|
91
91
|
before do
|
92
|
-
@t1 = @w.Transition.
|
93
|
-
|
94
|
-
|
92
|
+
@t1 = @w.Transition.new( ɴ: "T1", avid: true,
|
93
|
+
s: { @p1 => 1, @p2 => -1, @p3 => -1 },
|
94
|
+
rate: 0.01 )
|
95
95
|
@net.include_transition @t1
|
96
96
|
end
|
97
97
|
|
data/test/place_test.rb
CHANGED
@@ -67,7 +67,7 @@ describe YPetri::Place do
|
|
67
67
|
g = p.common_guard_closure
|
68
68
|
-> { g.( 11.1 ) }.must_raise YPetri::GuardError
|
69
69
|
begin; p.marking = -1.11; rescue YPetri::GuardError => err
|
70
|
-
err.message.must_equal 'Marking
|
70
|
+
err.message.must_equal 'Marking Float:-1.11 of P1 should not be negative!'
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
data/test/world_test.rb
CHANGED
@@ -12,16 +12,18 @@ include Pyper if require 'pyper'
|
|
12
12
|
describe YPetri::World do
|
13
13
|
before do
|
14
14
|
@w = YPetri::World.new
|
15
|
-
a = @w.Place.
|
16
|
-
b = @w.Place.
|
17
|
-
c = @w.Place.
|
18
|
-
t1 = @w.Transition.
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
15
|
+
a = @w.Place.new( default_marking: 1.0, name: "AA", avid: true )
|
16
|
+
b = @w.Place.new( default_marking: 2.0, name: "BB", avid: true )
|
17
|
+
c = @w.Place.new( ɴ: "CC", avid: true, default_marking: 3.0 )
|
18
|
+
t1 = @w.Transition.new s: { a => -1, b => -1, c => 1 },
|
19
|
+
rate: 0.1,
|
20
|
+
ɴ: "AA_BB_assembly",
|
21
|
+
avid: true
|
22
|
+
t2 = @w.Transition.new ɴ: "AA_appearing",
|
23
|
+
avid: true,
|
24
|
+
codomain: a,
|
25
|
+
rate: -> { 0.1 },
|
26
|
+
stoichiometry: 1
|
25
27
|
@pp, @tt = [a, b, c], [t1, t2]
|
26
28
|
@f_name = "test_output.csv"
|
27
29
|
@w.set_imc @pp >> @pp.map( &:default_marking )
|
@@ -32,7 +34,7 @@ describe YPetri::World do
|
|
32
34
|
end
|
33
35
|
|
34
36
|
it "should present places, transitions, nets, simulations" do
|
35
|
-
assert_kind_of YPetri::Net, @w.Net
|
37
|
+
assert_kind_of YPetri::Net, @w.Net.instance( :Top )
|
36
38
|
assert_equal @pp[0], @w.place( "AA" )
|
37
39
|
assert_equal @tt[0], @w.transition( "AA_BB_assembly" )
|
38
40
|
assert_equal @pp, @w.places
|
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.4.
|
4
|
+
version: 2.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- boris
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|