Home | Trees | Indices | Help |
|
---|
|
Mealy machine.
Traffic Light: Fig. 3.14, p.72 [LS11]
>>> m = MealyMachine() >>> pure_signal = {'present', 'absent'} >>> m.add_inputs([('tick', pure_signal) ]) >>> m.add_outputs([('go', pure_signal), ('stop', pure_signal) ]) >>> m.states.add_from(['red', 'green', 'yellow']) >>> m.states.initial.add('red')
For brevity:
>>> p = 'present' >>> a = 'absent'
The transitions can equivalently be defined with dict(). So instead
of the previous m.transitions.add
, we can use:
>>> label = {'tick':p, 'go':p, 'stop':a} >>> m.transitions.add('red', 'green', **label) >>> label = {'tick':p, 'go':a, 'stop':p} >>> m.transitions.add('green', 'yellow', **label) >>> label = {'tick':p, 'go':a, 'stop':p} >>> m.transitions.add('yellow', 'red', **label)
This avoids any ordering issues, i.e., changing the order of the sublabels does not matter:
>>> label = {'go':p, 'tick':p, 'stop':a} >>> m.transitions.add('red', 'green', **label)
A Mealy machine implements the discrete dynamics:
x[k+1] = f(x[k], u[k] ) y[k] = g(x[k], u[k] )
where:
Observe that the output is defined when a reaction occurs to an input.
valuation: assignment of values to each port
Nested Classes | |
Inherited from Inherited from |
Instance Methods | |||
|
|||
|
|||
|
|||
(outputs, next_state) where outputs :
{'port_name':port_value, ...}
|
|
||
|
|||
|
|||
Inherited from Inherited from Inherited from Inherited from Inherited from Inherited from Inherited from |
Properties | |
Inherited from Inherited from |
Method Details |
Initialize a graph with edges, name, graph attributes. Parameters ---------- data : input graph Data to initialize graph. If data=None (default) an empty graph is created. The data can be an edge list, or any NetworkX graph object. If the corresponding optional Python packages are installed the data can also be a NumPy matrix or 2d ndarray, a SciPy sparse matrix, or a PyGraphviz graph. name : string, optional (default='') An optional name for the graph. attr : keyword arguments, optional (default= no attributes) Attributes to add to graph as key=value pairs. See Also -------- convert Examples -------- >>> G = nx.Graph() # or DiGraph, MultiGraph, MultiDiGraph, etc >>> G = nx.Graph(name='my graph') >>> e = [(1,2),(2,3),(3,4)] # list of edges >>> G = nx.Graph(e) Arbitrary graph attribute pairs (key=value) may be assigned >>> G=nx.Graph(e, day="Friday") >>> G.graph {'day': 'Friday'}
|
Get informal string representation.
|
Add new outputs.
|
Return next state and output, when reacting to given inputs. The machine must be deterministic. (for each state and input at most a single transition enabled, this notion does not coincide with output-determinism) Not exactly a wrapper of
|
Guided or interactive run.
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sat Nov 19 00:11:17 2016 | http://epydoc.sourceforge.net |