Class: YPetri::Simulation::TransitionRepresentation

Inherits:
NodeRepresentation show all
Defined in:
lib/y_petri/simulation/transition_representation/S.rb,
lib/y_petri/simulation/transition_representation.rb,
lib/y_petri/simulation/transition_representation/T.rb,
lib/y_petri/simulation/transition_representation/s.rb,
lib/y_petri/simulation/transition_representation/t.rb,
lib/y_petri/simulation/transition_representation/TS.rb,
lib/y_petri/simulation/transition_representation/Ts.rb,
lib/y_petri/simulation/transition_representation/tS.rb,
lib/y_petri/simulation/transition_representation/ts.rb,
lib/y_petri/simulation/transition_representation/types.rb

Overview

A mixin with transition types.

Defined Under Namespace

Modules: Type_A, Type_S, Type_T, Type_TS, Type_Ts, Type_a, Type_s, Type_t, Type_tS, Type_ts, Types

Instance Attribute Summary collapse

Attributes inherited from NodeRepresentation

#source

Instance Method Summary collapse

Methods inherited from NodeRepresentation

#to_s

Constructor Details

#initialize(net_transition) ⇒ TransitionRepresentation

Expect a single YPetri place as an argument.



16
17
18
19
20
# File 'lib/y_petri/simulation/transition_representation.rb', line 16

def initialize net_transition
  super
  @domain, @codomain = Places( source.domain ), Places( source.codomain )
  type_init
end

Instance Attribute Details

#codomainObject (readonly)

Returns the value of attribute codomain.



11
12
13
# File 'lib/y_petri/simulation/transition_representation.rb', line 11

def codomain
  @codomain
end

#domainObject (readonly)

Returns the value of attribute domain.



11
12
13
# File 'lib/y_petri/simulation/transition_representation.rb', line 11

def domain
  @domain
end

#functionObject (readonly)

source transition function



12
13
14
# File 'lib/y_petri/simulation/transition_representation.rb', line 12

def function
  @function
end

Instance Method Details

#codomain_assignment_code(vector: (fail ArgumentError, "No vector!"), source: (fail ArgumentError, "No source array!")) ⇒ Object

Builds a code string that assigns to the free places of the codomain.



56
57
58
59
60
61
# File 'lib/y_petri/simulation/transition_representation.rb', line 56

def codomain_assignment_code vector: (fail ArgumentError, "No vector!"),
                             source: (fail ArgumentError, "No source array!")
  Matrix.column_vector_assignment_code( vector: vector,
                                        indices: free_codomain_indices,
                                        source: source )
end

#codomain_indicesObject

Returns the indices of this transition’s codomain in the marking vector.



30
31
32
# File 'lib/y_petri/simulation/transition_representation.rb', line 30

def codomain_indices
  codomain.map { |p| places.index p }
end

#domain_access_code(vector: :m_vector) ⇒ Object

Builds a code string for accessing the domain directly from a marking vector, given as argument.



49
50
51
52
# File 'lib/y_petri/simulation/transition_representation.rb', line 49

def domain_access_code( vector: :m_vector )
  Matrix.column_vector_access_code( vector: vector,
                                    indices: domain_indices )
end

#domain_indicesObject

Returns the indices of this transition’s domain in the marking vector.



24
25
26
# File 'lib/y_petri/simulation/transition_representation.rb', line 24

def domain_indices
  domain.map { |p| places.index p }
end

#free_codomain_indicesObject

Returns the indices of this transition’s codomain among the free places.



42
43
44
# File 'lib/y_petri/simulation/transition_representation.rb', line 42

def free_codomain_indices
  codomain.map { |p| free_places.index p }
end

#free_domain_indicesObject

Returns the indices of this transition’s domain among the free places.



36
37
38
# File 'lib/y_petri/simulation/transition_representation.rb', line 36

def free_domain_indices
  domain.map { |p| free_places.index p }
end

#increment_by_codomain_code(vector: (fail ArgumentError, "No vector!"), source: (fail ArgumentError, "No source array!")) ⇒ Object

Builds a closure that increments a vector with this transition’s codomain.



65
66
67
68
69
70
# File 'lib/y_petri/simulation/transition_representation.rb', line 65

def increment_by_codomain_code vector: (fail ArgumentError, "No vector!"),
                               source: (fail ArgumentError, "No source array!")
  Matrix.column_vector_increment_by_array_code vector: vector,
                                               indices: free_codomain_indices,
                                               source: source
end