y_nelson 0.1.5 → 2.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0d19c1eb4d0fca009913f2c4632ea803aafee8a0
4
- data.tar.gz: 2ae45a24959f7041a7017a0ef44ee1f5023f4b44
3
+ metadata.gz: ea818e5d4cb9055a77287cadec64a7050333f638
4
+ data.tar.gz: 152909e30337e411763ad7f1c5b4d0edcddfa3a3
5
5
  SHA512:
6
- metadata.gz: e42a83132fbecca38473d47c05ef1e7ecb3d1e134e517c7eda1c18b79b10df80d1d1340eae7e1e896e0027a3dca2339c35b703fb472ea38c5cf7a1874fd29b19
7
- data.tar.gz: 51d15c79f5210d76e936dc0777285dccf7447b2a5faa59013822429798776c06ee092771f285af058d0c302a8cff0e9912fed75b4b87238cf32ba7fc4b344f2b
6
+ metadata.gz: e15d5d83f1adb7299448d2517193f0b7caee251bd10a97480537d73d7c472dd7b1cf645fc0a187a0e73196905cbf7f0d001db90bc8697aa11e505240a66e3966
7
+ data.tar.gz: c77ff082eb96e5f092d1624c72f019dce938f70ff329bc82c12f7f111f6183a2ec3aa7fe582a19ee8ae26cc624abd679f85c5cbae407074413dc22b62537c2cd
data/.gitignore CHANGED
@@ -17,4 +17,5 @@ rdoc
17
17
  spec/reports
18
18
  test/tmp
19
19
  test/version_tmp
20
+ test/*.png
20
21
  tmp
@@ -0,0 +1,6 @@
1
+ development:
2
+ sessions:
3
+ default:
4
+ database: mongoid
5
+ hosts:
6
+ - localhost:27017
@@ -1,30 +1,34 @@
1
- # -*- coding: utf-8 -*-
2
- # YNelson user inteface. Ted Nelson, in his introduction of zz structures, has
3
- # remarks regarding a desired UI, such as:
1
+ # encoding: utf-8
2
+
3
+ # YNelson's user inteface. As the name suggests, represents an agent that
4
+ # manipulates the YNelson world. In his introduction to zz structures,
5
+ # Ted Nelson has remarks regarding the desired UI, such as:
4
6
  #
5
7
  # <em>Selection</em> is a pointer to a collection of cells.
6
8
  # <em>View</em> consists of selection and a coordinate system.
7
9
  # <em>Field<em> is a connected (contiguous) selection.
8
10
  # <em>Coordinate system</em> is a collection of oriented dimensions.
9
11
  #
10
- # Apart from that, this manipulator should offer similar functionality as
11
- # YPetri::Manipulator - that is, should allow constructing a Petri net
12
- # without much ado about zz aspect, just like YPetri does.
12
+ # Apart from these author's suggestions, the interface should offer similar
13
+ # functionality as YPetri::Agent that is, should allow constructing a Petri
14
+ # net with the same commands as YPetri does.
13
15
  #
14
- class YNelson::Manipulator
15
- attr_reader :workspace
16
+ class YNelson::Agent
17
+ attr_reader :world
16
18
 
17
- include YPetri::Manipulator::PetriNetRelatedMethods
18
- include YPetri::Manipulator::SimulationRelatedMethods
19
+ include YPetri::Agent::PetriNetRelated
20
+ include YPetri::Agent::SimulationRelated
19
21
 
22
+ # Initialization of a YNelson::Agent instance. For YNelson manipulators, the
23
+ # world is always YNelson itself.
24
+ #
20
25
  def initialize
21
- # For YNelson manipulators, the workspace is always YNelson itself.
22
- @workspace = ::YNelson
26
+ @world = ::YNelson
23
27
  super
24
- # A hash of sheets. For the moment being, YNelson acts as a spreadsheet.
28
+ # A hash of sheets. (For the moment being, YNelson acts like a spreadsheet.)
25
29
  @sheets = {}
26
30
  # Default dimension of this manipulator.
27
- @default_dimension = YNelson.Dimension :row
31
+ @default_dimension = YNelson.Dimension( :row )
28
32
  # Zz object pointers of this manipulator.
29
33
  @primary_point = YNelson::ZzPoint.new
30
34
  @secondary_point = YNelson::ZzPoint.new
@@ -45,7 +49,7 @@ class YNelson::Manipulator
45
49
 
46
50
  # Dimension convenience constructor from
47
51
  delegate( :Dimension,
48
- to: :workspace )
52
+ to: :world )
49
53
 
50
54
  # Creation of a single-output formula known well from spreadseets. Given a
51
55
  # place, it creates a new assignment transition.
@@ -60,24 +64,38 @@ class YNelson::Manipulator
60
64
 
61
65
  # Now let's look into the graph visualization.
62
66
 
63
- def default_dimension; @default_dimension end
67
+ def default_dimension
68
+ @default_dimension
69
+ end
64
70
 
65
- def primary_point; @primary_point end
71
+ def primary_point
72
+ @primary_point
73
+ end
66
74
  alias p1 primary_point
67
75
 
68
- def secondary_point; @secondary_point end
76
+ def secondary_point
77
+ @secondary_point
78
+ end
69
79
  alias p2 secondary_point
70
80
 
71
- def primary_dimension_point; @primary_dimension_point end
81
+ def primary_dimension_point
82
+ @primary_dimension_point
83
+ end
72
84
  alias d1 primary_dimension_point
73
85
 
74
- def secondary_dimension_point; @secondary_dimension_point end
86
+ def secondary_dimension_point
87
+ @secondary_dimension_point
88
+ end
75
89
  alias d2 secondary_dimension_point
76
90
 
77
- # Define function to display it with kioclient
78
- def visualize *args, &block; graphviz *args, &block end
91
+ # Define function to display it with kioclient.
92
+ #
93
+ def visualize *args, &block
94
+ graphviz *args, &block
95
+ end
79
96
 
80
- # Define graphviz places
97
+ # Define graphviz places.
98
+ #
81
99
  def graphviz dim1=primary_dimension_point, dim2=secondary_dimension_point
82
100
  γ = GraphViz.new :G, type: :digraph # Create a new graph
83
101
 
@@ -1,4 +1,5 @@
1
- # -*- coding: utf-8 -*-
1
+ # encoding: utf-8
2
+
2
3
  # Zz dimension can in principle be any object, in YNelson, special class
3
4
  # Dimension is used.
4
5
  #
@@ -0,0 +1,77 @@
1
+ # encoding: utf-8
2
+
3
+ module YNelson
4
+ # YNelson DSL.
5
+ #
6
+ module DSL
7
+ def y_nelson_agent
8
+ @y_nelson_agent ||= Agent.new
9
+ .tap { puts "Defining YNelson agent for #{self}" if YNelson::DEBUG }
10
+ end
11
+ end
12
+
13
+ delegate :world, to: :y_nelson_agent
14
+
15
+ # Petri net aspect.
16
+ delegate( :Place,
17
+ :Transition, :T, :A,
18
+ :Net,
19
+ :place, :transition, :pl, :tr,
20
+ :places, :transitions, :nets,
21
+ :pn, :tn, :nn,
22
+ :net_point,
23
+ :net_selection,
24
+ :net, :nnet,
25
+ :net_point_reset,
26
+ :net_point=,
27
+ to: :y_nelson_agent )
28
+
29
+ # Simulation aspect.
30
+ delegate( :simulation_point, :ssc_point, :cc_point, :imc_point,
31
+ :simulation_selection, :ssc_selection,
32
+ :cc_selection, :imc_selection,
33
+ :simulations,
34
+ :clamp_collections,
35
+ :initial_marking_collections,
36
+ :simulation_settings_collections,
37
+ :clamp_collection_names, :ncc,
38
+ :initial_marking_collection_names, :nimc,
39
+ :simulation_settings_collection_names, :nssc,
40
+ :set_clamp_collection, :set_cc,
41
+ :set_initial_marking_collection, :set_imc,
42
+ :set_simulation_settings_collection, :set_ssc,
43
+ :new_simulation,
44
+ :clamp_cc, :initial_marking_cc, :simulation_settings_cc,
45
+ :simulation_point_position,
46
+ :simulation,
47
+ :clamp_collection, :cc,
48
+ :initial_marking_collection, :imc,
49
+ :simulation_settings_collection, :ssc,
50
+ :clamp,
51
+ :initial_marking,
52
+ :set_step, :set_step_size,
53
+ :set_time, :set_target_time,
54
+ :set_sampling,
55
+ :set_simulation_method,
56
+ :new_timed_simulation,
57
+ :run!,
58
+ :print_recording,
59
+ :plot,
60
+ :plot_selected,
61
+ :plot_state,
62
+ :plot_flux,
63
+ to: :y_nelson_agent )
64
+
65
+
66
+ # Zz aspect.
67
+ delegate( :Dimension,
68
+ :ϝ,
69
+ :default_dimension,
70
+ :primary_point, :p1,
71
+ :secondary_point, :p2,
72
+ :primary_dimension_point, :d1,
73
+ :secondary_dimension_point, :d2,
74
+ :visualize,
75
+ :graphviz,
76
+ to: :y_nelson_agent )
77
+ end # module YNelson
data/lib/y_nelson/net.rb CHANGED
@@ -1,12 +1,4 @@
1
1
  # Represents Petri nets inside the Nelson net.
2
2
  #
3
3
  class YNelson::Net < YPetri::Net
4
-
5
- private
6
-
7
- # Place, Transition, Net class
8
- #
9
- def Place; ::YNelson::Place end
10
- def Transition; ::YNelson::Transition end
11
- def Net; ::YNelson::Net end
12
4
  end # class YNelson::Net
@@ -3,26 +3,29 @@
3
3
  #
4
4
  class YNelson::Place < YPetri::Place
5
5
  include YNelson::Yzz
6
+
7
+ # include Mongoid::Document
8
+ # store_in collection: "places", database: "y_nelson"
9
+
6
10
  alias call along # .( :dim ) instead of .along( :dim )
7
11
 
8
12
  class << self
13
+ private :new
14
+ end
15
+
16
+ def initialize( *args )
17
+ super
18
+
9
19
  end
10
20
 
11
21
  # Subclass of YTed::Zz::Side.
12
22
  #
13
23
  class Side < Side
14
- # "Budding": creation of new cells from the cell sides
24
+ # "Budding": creation of new cells from the cell sides.
25
+ #
15
26
  def bud( value: L!, f: nil )
16
27
  # FIXME
17
28
  end
18
29
  alias :>> :bud
19
30
  end
20
-
21
- private
22
-
23
- # Place, Transition, Net class
24
- #
25
- def Place; ::YNelson::Place end
26
- def Transition; ::YNelson::Transition end
27
- def Net; ::YNelson::Net end
28
31
  end
@@ -29,10 +29,4 @@ class YNelson::Transition < YPetri::Transition
29
29
  }
30
30
  super
31
31
  end
32
-
33
- # Place, Transition, Net class.
34
- #
35
- def Place; ::YNelson::Place end
36
- def Transition; ::YNelson::Transition end
37
- def Net; ::YNelson::Net end
38
32
  end
@@ -1,4 +1,4 @@
1
1
  module YNelson
2
2
  DEBUG = false
3
- VERSION = "0.1.5"
3
+ VERSION = "2.0.1"
4
4
  end
data/lib/y_nelson/yzz.rb CHANGED
@@ -8,4 +8,4 @@ module YNelson::Yzz
8
8
  args.size == 1 && args[0].is_a?( ::YNelson::Dimension )
9
9
  super( ::YNelson.Dimension *args )
10
10
  end
11
- end # module YzzPrepend
11
+ end # module Yzz
data/lib/y_nelson.rb CHANGED
@@ -1,4 +1,5 @@
1
- # -*- coding: utf-8 -*-
1
+ # encoding: utf-8
2
+
2
3
  require 'yzz'
3
4
  require 'y_petri'
4
5
  require 'y_support/kde'
@@ -13,134 +14,73 @@ require_relative 'y_nelson/transition'
13
14
  require_relative 'y_nelson/net'
14
15
  require_relative 'y_nelson/zz_point'
15
16
  require_relative 'y_nelson/dimension_point'
16
- require_relative 'y_nelson/manipulator'
17
+ require_relative 'y_nelson/agent'
18
+ require_relative 'y_nelson/dsl'
17
19
 
18
20
  # YNelson is an implementation of a cross between Ted Nelson's Zz structure, and
19
- # a functional Petri net (FPN). The resulting data structure, which combines
20
- # qualities of FPNs with those of relational databases, I refer to as Nelson net
21
- # throughout this text.
21
+ # the functional Petri net (FPN). The resulting data structure, which combines
22
+ # the qualities of FPNs with those of relational databases, I refer to as Nelson
23
+ # net throughout this text.
22
24
  #
23
- # One way to understand Nelson nets is as a genralization of a spreadsheet. In
24
- # his explanations of Zz structures, Ted Nelson makes wide use of spreadsheet
25
- # metaphors: cells, ranks, rows, columns, cursors, selections... Nelson net
26
- # implemented here adds "formulas" to the mix, represented by FPN transitions.
25
+ # A Nelson net, from a certain point of view, is as a genralization of a
26
+ # spreadsheet software. In his explanations of Zz structures, Ted Nelson makes
27
+ # wide use of metaphors well known from spreadsheets: cells, ranks, rows,
28
+ # columns, cursors, selections... Nelson net, as implemented here, adds
29
+ # "formulas" to the mix: Spreadsheet "formulas" are simply represented by FPN
30
+ # transitions.
27
31
  #
28
- # Nelson net disposes of the arbitrary constraints on FPNs as well as the
29
- # orthogonal structure of "cells" seen in most practical spreadsheet
30
- # implementations:
32
+ # Nelson net disposes of the arbitrary constraints on FPNs, and also extends the
33
+ # plain orthogonal structure of spreadsheet "cells", as can be seen in the
34
+ # existing spreadsheet implementations:
31
35
  #
32
36
  # 1. Both places and transitions of the FPN take part in zz structure.
33
37
  # 2. Formula-based transitions are upgraded to standalone FPN transitions.
34
38
  #
35
- # The implications of the zz structure differences from ordinary hyperorthogonal
36
- # structures hav been, to a degree, explained by Ted Nelson himself. There is a
37
- # growing body of literature on zz structure applications, including in
38
- # bioinformatics.
39
+ # The implications of the differences of a zz structure from ordinary
40
+ # hyperorthogonal structures have been, to a degree, explained by Ted Nelson
41
+ # himself. There is a growing body of literature on zz structure applications,
42
+ # including the applications in bioinformatics.
39
43
  #
40
44
  # As for functional Petri nets, their power in computing is well recognized (eg.
41
45
  # Funnel, Odersky 2000). FPNs are sometimes just called functional nets, because
42
46
  # Petri originally described his nets as timeless and functionless. However, in
43
47
  # special-purpose applications, such as biochemical applications, to which I
44
48
  # incline, it is appropriate to honor Petri, who designed his nets specifically
45
- # with chemical modeling in mind as one of their main applications. In
46
- # biochemistry, it is common to call functional nets Petri nets (Miyano, 200?).
49
+ # with chemical modeling in mind. In biochemistry, it is common to call
50
+ # functional nets Petri nets (Miyano, 200?).
47
51
  #
48
52
  module YNelson
49
- # Singleton class of YNelson is partial descendant of YPetri::Workspace. More
50
- # specifically, it mixes in most YPetri::Workspace instance methods and
51
- # provides interface, which should be a superset of YPetri::Workspace. The
52
- # difference is, that while YPetri::Workspace can have multiple instances,
53
- # representing workdesks, YNelson is a singleton representing relational
54
- # database.
53
+ # Singleton class of YNelson is a partial descendant of YPetri::World. It
54
+ # aspires to be a database that represents the world. More specifically, it
55
+ # mixes in most of the YPetri::World methods, and provides interface, which
56
+ # is a superset of YPetri::World interface. The difference is, that while
57
+ # YPetri::World can have multiple instances workspaces in which we possibly
58
+ # represent the world in different ways – YNelson::World is a singleton.
55
59
  #
56
60
  class << self
57
- # YNelson metaclass includes instance methods of YPetri::Workspace.
58
- include YPetri::Workspace::PetriNetRelatedMethods
59
- include YPetri::Workspace::SimulationRelatedMethods
61
+ attr_reader :dimensions
62
+
63
+ # Including instance methods of YPetri::World:
64
+ include YPetri::World::PetriNetRelated
65
+ include YPetri::World::SimulationRelated
60
66
 
61
- # Allows summoning DSL by 'include YNelson' (like YPetri does).
67
+ # Allows summoning YNelson::DSL by 'include YNelson'.
62
68
  #
63
69
  def included receiver
64
- # receiver.instance_variable_set :@NelsonManipulator, Manipulator.new
65
- # puts "included in #{receiver}"
66
- receiver.module_exec {
67
- define_method :nelson_manipulator do
68
- singleton_class.instance_variable_get :@NelsonManipulator or
69
- ( puts "defining Manipulator for #{self} singleton class" if YNelson::DEBUG
70
- singleton_class.instance_variable_set :@NelsonManipulator, Manipulator.new )
71
- end
72
- }
70
+ receiver.extend YNelson::DSL
71
+ receiver.delegate :y_nelson_agent, to: "self.class"
73
72
  end
74
-
75
- def dimensions; @dimensions end
76
73
  end # class << self
77
74
 
78
- # Instance variables @Place, @Transition, @Net are expected by
79
- # YPetri::Workspace module.
80
- @Place, @Transition, @Net = self::Place, self::Transition, self::Net
75
+ # Parametrize the Place / Transition / Net classes.
76
+ param_class!( { Place: YNelson::Place,
77
+ Transition: YNelson::Transition,
78
+ Net: YNelson::Net },
79
+ with: { world: self } )
81
80
 
82
- # Atypical call to #initialize in the course of module execution.
83
- initialize
84
-
85
- delegate( :workspace, to: :nelson_manipulator )
81
+ # Make them their own namespaces.
82
+ [ Place(), Transition(), Net() ].each &:namespace!
86
83
 
87
- # Petri net aspect.
88
- delegate( :Place, :Transition, :Net,
89
- :place, :transition, :pl, :tr,
90
- :places, :transitions, :nets,
91
- :pp, :tt, :nn,
92
- :net_point,
93
- :net_selection,
94
- :net, :ne,
95
- :net_point_reset,
96
- :net_point_set,
97
- to: :nelson_manipulator )
98
-
99
- # Simulation aspect.
100
- delegate( :simulation_point, :ssc_point, :cc_point, :imc_point,
101
- :simulation_selection, :ssc_selection,
102
- :cc_selection, :imc_selection,
103
- :simulations,
104
- :clamp_collections,
105
- :initial_marking_collections,
106
- :simulation_settings_collections,
107
- :clamp_collection_names, :cc_names,
108
- :initial_marking_collection_names, :imc_names,
109
- :simulation_settings_collection_names, :ssc_names,
110
- :set_clamp_collection, :set_cc,
111
- :set_initial_marking_collection, :set_imc,
112
- :set_simulation_settings_collection, :set_ssc,
113
- :new_timed_simulation,
114
- :clamp_cc, :initial_marking_cc, :simulation_settings_cc,
115
- :simulation_point_position,
116
- :simulation,
117
- :clamp_collection, :cc,
118
- :initial_marking_collection, :imc,
119
- :simulation_settings_collection, :ssc,
120
- :clamp,
121
- :initial_marking,
122
- :set_step, :set_step_size,
123
- :set_time, :set_target_time,
124
- :set_sampling,
125
- :set_simulation_method,
126
- :new_timed_simulation,
127
- :run!,
128
- :print_recording,
129
- :plot,
130
- :plot_selected,
131
- :plot_state,
132
- :plot_flux,
133
- to: :nelson_manipulator )
134
-
135
- # Zz aspect.
136
- delegate( :Dimension,
137
- :ϝ,
138
- :default_dimension,
139
- :primary_point, :p1,
140
- :secondary_point, :p2,
141
- :primary_dimension_point, :d1,
142
- :secondary_dimension_point, :d2,
143
- :visualize,
144
- :graphviz,
145
- to: :nelson_manipulator )
84
+ # Atypical initialize call.
85
+ initialize
146
86
  end
@@ -0,0 +1,100 @@
1
+ require 'y_support/all'
2
+
3
+ # Places are basically glorified variables, with current contents (marking), and
4
+ # default contents (default_marking).
5
+ #
6
+ class Place
7
+ attr_reader :name, :default_marking
8
+ attr_accessor :marking
9
+ def initialize name, default_marking=0
10
+ @name, @default_marking = name, default_marking
11
+ end
12
+ def reset!; @marking = default_marking end
13
+ end
14
+
15
+ # Transitions specify how marking changes when the transition "fires" (activates).
16
+ # "Arcs" attribute is a hash of { place => change } pairs.
17
+ #
18
+ class Transition
19
+ attr_reader :name, :arcs
20
+ def initialize( name, arcs: {} )
21
+ @name, @arcs = name, arcs
22
+ end
23
+ def fire!
24
+ arcs.each { |place, change| place.marking = place.marking + change }
25
+ end
26
+ end
27
+
28
+ A, B, C = Place.new( "A" ), Place.new( "B" ), Place.new( "C" )
29
+
30
+ # Marking of A is incremented by 1
31
+ AddA = Transition.new( "AddA", arcs: { A => 1 } )
32
+
33
+ # 1 piece of A dissociates into 1 piece of B and 1 piece of C
34
+ DissocA = Transition.new( "DissocA", arcs: { A => -1, B => +1, C => +1 } )
35
+
36
+ [ A, B, C ].each &:reset!
37
+ [ A, B, C ].map &:marking #=> [0, 0, 0]
38
+ AddA.fire!
39
+ [ A, B, C ].map &:marking #=> [1, 0, 0]
40
+ DissocA.fire!
41
+ [ A, B, C ].map &:marking #=> [0, 1, 1]
42
+
43
+ require 'yaml'
44
+
45
+ class Place
46
+ def to_yaml
47
+ YAML.dump( { name: name, default_marking: default_marking } )
48
+ end
49
+
50
+ def to_ruby
51
+ "Place( name: #{name}, default_marking: #{default_marking} )\n"
52
+ end
53
+ end
54
+
55
+ puts A.to_yaml
56
+ puts B.to_yaml
57
+ puts C.to_yaml
58
+ puts A.to_ruby
59
+ puts B.to_ruby
60
+ puts C.to_ruby
61
+
62
+ class Transition
63
+ def to_yaml
64
+ YAML.dump( { name: name, arcs: arcs.modify { |k, v| [k.name, v] } } )
65
+ end
66
+
67
+ def to_ruby
68
+ "Transition( name: #{name}, default_marking: #{arcs.modify { |k, v| [k.name.to_sym, v] }} )\n"
69
+ end
70
+ end
71
+
72
+ puts AddA.to_yaml
73
+ puts DissocA.to_yaml
74
+ puts AddA.to_ruby
75
+ puts DissocA.to_ruby
76
+
77
+ # Now save that to a file
78
+ # and use
79
+
80
+ Place.from_yaml YAML.load( yaml_place_string )
81
+ Transition.from_yaml YAML.load( yaml_transition_string )
82
+ # or
83
+ YNelson::Manipulator.load( yaml: YAML.load( system_definition ) )
84
+
85
+ # then decorate #to_yaml and #to_ruby methods with Zz-structure-specific parts.
86
+
87
+ class Zz
88
+ def to_yaml
89
+ super + "\n" +
90
+ YAML.dump( { along: dump_connectivity() } )
91
+ end
92
+
93
+ def to_ruby
94
+ super + "\n" +
95
+ "#{name}.along( #{dimension} ).posward #{along( dimension ).posward.name}\n" +
96
+ "#{name}.along( #{dimension} ).negward #{along( dimension ).negward.name}"
97
+ end
98
+ end
99
+
100
+ # etc.
@@ -1,7 +1,5 @@
1
- #! /usr/bin/ruby
2
- # -*- coding: utf-8 -*-
1
+ # encoding: utf-8
3
2
 
4
- require 'minitest/spec'
5
3
  require 'minitest/autorun'
6
4
  # tested component itself
7
5
  require './../lib/y_nelson'
@@ -9,11 +7,10 @@ require './../lib/y_nelson'
9
7
  # **************************************************************************
10
8
  # Nelson net test
11
9
  # **************************************************************************
12
- #
10
+ #
13
11
  describe YNelson do
14
12
  before do
15
- skip
16
- @m = YNelson::Manipulator.new
13
+ @m = YNelson::Agent.new
17
14
  @p = @m.Place default_marking: 3.2,
18
15
  marking: 1.1,
19
16
  quantum: 0.1
@@ -29,9 +26,11 @@ describe YNelson do
29
26
  it "should work as expected" do
30
27
  assert_equal [], @p.neighbors
31
28
  assert_equal [], @p.connectivity # 'connectivity' now exclusively a zz keyword
32
- t = @m.Transition codomain: @p, action: lambda { 0.1 }, assignment: true
29
+ t = @m.Transition codomain: @p,
30
+ action: -> { 0.1 },
31
+ assignment: true
33
32
  assert_equal [ @p ], t.neighbors
34
- dim = @m.Dimension( :codomain, 0 )
33
+ dim = @m.Dimension( t, :codomain, 0 )
35
34
  assert_equal @p, t.along( dim ).posward.neighbor
36
35
  # And then, it would be the job of dimension reduction to determine if
37
36
  # some dimensions should be visualized or otherwise used together.
@@ -77,7 +76,7 @@ end
77
76
 
78
77
  describe "visualization" do
79
78
  before do
80
- @m = YNelson::Manipulator.new
79
+ @m = YNelson::Agent.new
81
80
  @m.Place name: :A, m!: 3.2
82
81
  @m.Place name: :B, m!: 5
83
82
  @m.Transition name: :T1, s: { A: -1, B: 1 }, rate: 1
@@ -86,8 +85,11 @@ describe "visualization" do
86
85
  end
87
86
 
88
87
  it "should work" do
89
- dim1 = YNelson::Dimension( :domain, 0 )
90
- dim2 = YNelson::Dimension( :codomain, 1 )
88
+ dim1 = YNelson::Dimension( @m.transition( :T1 ), :domain, 0 )
89
+ dim2 = YNelson::Dimension( @m.transition( :T2 ), :domain, 0 )
90
+ @m.visualize dim1, dim2
91
+ dim1 = YNelson::Dimension( @m.transition( :T1 ), :codomain, 0 )
92
+ dim2 = YNelson::Dimension( @m.transition( :T2 ), :codomain, 0 )
91
93
  @m.visualize dim1, dim2
92
94
  end
93
95
  end
data/test/zz.png CHANGED
Binary file
data/zz.png ADDED
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: y_nelson
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - boris
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-14 00:00:00.000000000 Z
11
+ date: 2013-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yzz
@@ -78,10 +78,12 @@ files:
78
78
  - LICENSE.txt
79
79
  - README.md
80
80
  - Rakefile
81
+ - config/mongoid.yml
81
82
  - lib/y_nelson.rb
83
+ - lib/y_nelson/agent.rb
82
84
  - lib/y_nelson/dimension.rb
83
85
  - lib/y_nelson/dimension_point.rb
84
- - lib/y_nelson/manipulator.rb
86
+ - lib/y_nelson/dsl.rb
85
87
  - lib/y_nelson/net.rb
86
88
  - lib/y_nelson/place.rb
87
89
  - lib/y_nelson/transition.rb
@@ -89,9 +91,11 @@ files:
89
91
  - lib/y_nelson/yzz.rb
90
92
  - lib/y_nelson/zz.png
91
93
  - lib/y_nelson/zz_point.rb
94
+ - test/mongoid_example.rb
92
95
  - test/y_nelson_test.rb
93
96
  - test/zz.png
94
97
  - y_nelson.gemspec
98
+ - zz.png
95
99
  homepage: ''
96
100
  licenses:
97
101
  - MIT
@@ -117,5 +121,6 @@ signing_key:
117
121
  specification_version: 4
118
122
  summary: A fusion of functional Petri net with a zz structure.
119
123
  test_files:
124
+ - test/mongoid_example.rb
120
125
  - test/y_nelson_test.rb
121
126
  - test/zz.png