adding support for network of automata...
This commit is contained in:
@@ -8,3 +8,4 @@ from rs.reaction_system_with_automaton import ReactionSystemWithAutomaton
|
||||
|
||||
from rs.extended_context_automaton import ExtendedContextAutomaton
|
||||
|
||||
from rs.network_of_context_automata import NetworkOfContextAutomata
|
||||
@@ -8,6 +8,7 @@ class ContextAutomaton(object):
|
||||
self._transitions = []
|
||||
self._init_state = None
|
||||
self._reaction_system = reaction_system
|
||||
self._name = ""
|
||||
|
||||
@property
|
||||
def states(self):
|
||||
@@ -17,6 +18,14 @@ class ContextAutomaton(object):
|
||||
def transitions(self):
|
||||
return self._transitions
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self._name
|
||||
|
||||
@name.setter
|
||||
def name(self, automaton_name):
|
||||
self._name = automaton_name
|
||||
|
||||
def add_state(self, name):
|
||||
if name not in self._states:
|
||||
self._states.append(name)
|
||||
@@ -126,7 +135,13 @@ class ContextAutomaton(object):
|
||||
else:
|
||||
print()
|
||||
|
||||
def show_header(self):
|
||||
if self.name:
|
||||
name_string = ": " + colour_str(C_BOLD, self.name)
|
||||
print(C_MARK_INFO + " Context automaton" + name_string)
|
||||
|
||||
def show(self):
|
||||
self.show_header()
|
||||
self.show_states()
|
||||
self.show_transitions()
|
||||
|
||||
|
||||
@@ -97,6 +97,5 @@ class ExtendedContextAutomaton(ContextAutomaton):
|
||||
print(" - " + act + " (id=" + str(self.get_action_id(act)) + ")")
|
||||
|
||||
def show(self):
|
||||
self.show_states()
|
||||
super(ExtendedContextAutomaton, self).show()
|
||||
self.show_actions()
|
||||
self.show_transitions()
|
||||
|
||||
14
rs/network_of_context_automata.py
Normal file
14
rs/network_of_context_automata.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from sys import exit
|
||||
|
||||
class NetworkOfContextAutomata(object):
|
||||
|
||||
def __init__(self, context_automata):
|
||||
self.cas = list(context_automata)
|
||||
|
||||
def show(self):
|
||||
for ca in self.cas:
|
||||
print()
|
||||
ca.show()
|
||||
|
||||
def add(self, aut):
|
||||
self.cas.append(aut)
|
||||
@@ -3,6 +3,7 @@ from colour import *
|
||||
|
||||
from rs.reaction_system_with_concentrations import ReactionSystemWithConcentrations
|
||||
from rs.context_automaton_with_concentrations import ContextAutomatonWithConcentrations
|
||||
from rs.network_of_context_automata import NetworkOfContextAutomata
|
||||
|
||||
class ReactionSystemWithAutomaton(object):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user