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.extended_context_automaton import ExtendedContextAutomaton
|
||||||
|
|
||||||
|
from rs.network_of_context_automata import NetworkOfContextAutomata
|
||||||
@@ -8,6 +8,7 @@ class ContextAutomaton(object):
|
|||||||
self._transitions = []
|
self._transitions = []
|
||||||
self._init_state = None
|
self._init_state = None
|
||||||
self._reaction_system = reaction_system
|
self._reaction_system = reaction_system
|
||||||
|
self._name = ""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def states(self):
|
def states(self):
|
||||||
@@ -17,6 +18,14 @@ class ContextAutomaton(object):
|
|||||||
def transitions(self):
|
def transitions(self):
|
||||||
return self._transitions
|
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):
|
def add_state(self, name):
|
||||||
if name not in self._states:
|
if name not in self._states:
|
||||||
self._states.append(name)
|
self._states.append(name)
|
||||||
@@ -126,7 +135,13 @@ class ContextAutomaton(object):
|
|||||||
else:
|
else:
|
||||||
print()
|
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):
|
def show(self):
|
||||||
|
self.show_header()
|
||||||
self.show_states()
|
self.show_states()
|
||||||
self.show_transitions()
|
self.show_transitions()
|
||||||
|
|
||||||
|
|||||||
@@ -97,6 +97,5 @@ class ExtendedContextAutomaton(ContextAutomaton):
|
|||||||
print(" - " + act + " (id=" + str(self.get_action_id(act)) + ")")
|
print(" - " + act + " (id=" + str(self.get_action_id(act)) + ")")
|
||||||
|
|
||||||
def show(self):
|
def show(self):
|
||||||
self.show_states()
|
super(ExtendedContextAutomaton, self).show()
|
||||||
self.show_actions()
|
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.reaction_system_with_concentrations import ReactionSystemWithConcentrations
|
||||||
from rs.context_automaton_with_concentrations import ContextAutomatonWithConcentrations
|
from rs.context_automaton_with_concentrations import ContextAutomatonWithConcentrations
|
||||||
|
from rs.network_of_context_automata import NetworkOfContextAutomata
|
||||||
|
|
||||||
class ReactionSystemWithAutomaton(object):
|
class ReactionSystemWithAutomaton(object):
|
||||||
|
|
||||||
|
|||||||
@@ -12,15 +12,27 @@ def test_extended_automaton():
|
|||||||
r.add_bg_set_entity("inc")
|
r.add_bg_set_entity("inc")
|
||||||
r.add_bg_set_entity("dec")
|
r.add_bg_set_entity("dec")
|
||||||
|
|
||||||
c = ExtendedContextAutomaton(r)
|
c1 = ExtendedContextAutomaton(r)
|
||||||
c.add_init_state("init")
|
c1.add_init_state("init")
|
||||||
c.add_state("working")
|
c1.name = "catest"
|
||||||
c.add_action("act1")
|
c1.add_state("working")
|
||||||
c.add_action("act2")
|
c1.add_action("act1")
|
||||||
c.add_transition("init", ["act1", "act2"], ([],[],["inc"]), "working")
|
c1.add_action("act2")
|
||||||
c.add_transition("working", ["act2"], ([],[],["inc"]), "working")
|
c1.add_transition("init", ["act1", "act2"], ([],[],["inc"]), "working")
|
||||||
|
c1.add_transition("working", ["act2"], ([],[],["inc"]), "working")
|
||||||
|
|
||||||
rc = ReactionSystemWithAutomaton(r,c)
|
c2 = ExtendedContextAutomaton(r)
|
||||||
|
c2.add_init_state("init")
|
||||||
|
c2.name = "cxxxx"
|
||||||
|
c2.add_state("working")
|
||||||
|
c2.add_action("act1")
|
||||||
|
c2.add_action("act2")
|
||||||
|
c2.add_transition("init", ["act1", "act2"], ([],[],["inc"]), "working")
|
||||||
|
c2.add_transition("working", ["act2"], ([],[],["inc"]), "working")
|
||||||
|
|
||||||
|
na = NetworkOfContextAutomata([c1,c2])
|
||||||
|
|
||||||
|
rc = ReactionSystemWithAutomaton(r,na)
|
||||||
|
|
||||||
rc.show()
|
rc.show()
|
||||||
|
|
||||||
|
|||||||
7
rssmt.py
7
rssmt.py
@@ -18,12 +18,16 @@ import resource
|
|||||||
|
|
||||||
profiling = False
|
profiling = False
|
||||||
|
|
||||||
|
##################################################################
|
||||||
|
|
||||||
version = "2016/12/28/00"
|
version = "2016/12/28/00"
|
||||||
rsmc_banner = """Reaction Systems SMT-Based Model Checking
|
rsmc_banner = """Reaction Systems SMT-Based Model Checking
|
||||||
|
|
||||||
Version: """ + version + """
|
Version: """ + version + """
|
||||||
Author: Artur Męski <meski@ipipan.waw.pl> / <artur.meski@ncl.ac.uk>"""
|
Author: Artur Męski <meski@ipipan.waw.pl> / <artur.meski@ncl.ac.uk>"""
|
||||||
|
|
||||||
|
##################################################################
|
||||||
|
|
||||||
def print_banner():
|
def print_banner():
|
||||||
print()
|
print()
|
||||||
for line in rsmc_banner.split("\n"):
|
for line in rsmc_banner.split("\n"):
|
||||||
@@ -33,11 +37,12 @@ def print_banner():
|
|||||||
##################################################################
|
##################################################################
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
"""Main function"""
|
||||||
|
|
||||||
print_banner()
|
print_banner()
|
||||||
|
|
||||||
rs_testing.run_tests()
|
rs_testing.run_tests()
|
||||||
|
|
||||||
|
##################################################################
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user