Ejemplo n.º 1
0
def _transition(file_object):
    LOG.info("[START] Getting Transition")
    reserved = _get_object(file_object)
    if reserved != "TRANSITION":
        err_message = ERROR_MESSAGE_TEMPLATE.format("TRANSITION", reserved)
        raise PetriNetInterpreterException(err_message)
    nodeident = _nodeident(file_object)
    fairness = _fairness(file_object)
    reserved = _get_object(file_object)
    if reserved != "CONSUME":
        err_message = ERROR_MESSAGE_TEMPLATE.format("CONSUME", reserved)
        raise PetriNetInterpreterException(err_message)
    arc_list = _arc_list(file_object)
    separator = _get_object(file_object)
    if separator != ";":
        err_message = ERROR_MESSAGE_TEMPLATE.format(";", separator)
        raise PetriNetInterpreterException(err_message)
    reserved = _get_object(file_object)
    if reserved != "PRODUCE":
        err_message = ERROR_MESSAGE_TEMPLATE.format("PRODUCE", reserved)
        raise PetriNetInterpreterException(err_message)
    arc_list = _arc_list(file_object)
    separator = _get_object(file_object)
    if separator != ";":
        err_message = ERROR_MESSAGE_TEMPLATE.format(";", separator)
        raise PetriNetInterpreterException(err_message)
    LOG.info("[END] Getting Transition")
    #TODO: Create a Transition object and return
    pass
Ejemplo n.º 2
0
def _nodeident(file_object):
    LOG.info("[START] Getting Node identifier")
    nodeident = _get_object(file_object)
    if isinstance(nodeident, Number) or isinstance(nodeident, Identifier):
        LOG.info("[END] Getting Node identifier")
        return nodeident
    err_message = ERROR_MESSAGE_TEMPLATE.format("Identifier", nodeident)
    raise PetriNetInterpreterException(err_message)
Ejemplo n.º 3
0
def _arc_list(file_object):
    LOG.info("[START] Getting Arc List")
    arc = _arc(file_object)
    separator = _get_object(file_object)
    while separator == ",":
        arc = _arc(file_object)
        separator = _get_object(file_object)
    LOG.info("[END] Getting Arc List")
    #TODO: Create a Arc List object and return
    pass
Ejemplo n.º 4
0
def _marking_list(file_object):
    LOG.info("[START] Getting Marking List")
    marking = _marking(file_object)
    separator = _get_object(file_object)
    while separator == ",":
        marking = _marking(file_object)
        separator = _get_object(file_object)
    LOG.info("[END] Getting Marking List")
    #TODO: Create a Place list object and return
    pass
Ejemplo n.º 5
0
def _place_list(file_object):
    LOG.info("[START] Getting Place list")
    nodeident = _nodeident(file_object)
    separator = _get_object(file_object)
    while separator == ",":
        nodeident = _nodeident(file_object)
        separator = _get_object(file_object)
    LOG.info("[END] Getting Place list")
    #TODO: Create a Place list object and return
    pass
Ejemplo n.º 6
0
def _arc(file_object):
    LOG.info("[START] Getting Arc")
    nodeident = _nodeident(file_object)
    separator = _get_object(file_object)
    if separator == ":":
        number = _get_object(file_object)
        if not isinstance(nodeident, Number):
            err_message = ERROR_MESSAGE_TEMPLATE.format("Number", number)
            raise PetriNetInterpreterException(err_message)
    LOG.info("[END] Getting Arc")
    #TODO: Create a Arc object and return
    pass
Ejemplo n.º 7
0
def _fairness(file_object):
    LOG.info("[START] Getting Fairness")
    reserved = _get_object(file_object)
    if reserved != "STRONG" and reserved != "WEAK":
        err_message = ERROR_MESSAGE_TEMPLATE.format("STRONG' or 'WEAK", reserved)
        raise PetriNetInterpreterException(err_message)
    reserved = _get_object(file_object)
    if reserved != "FAIR":
        err_message = ERROR_MESSAGE_TEMPLATE.format("FAIR", reserved)
        raise PetriNetInterpreterException(err_message)
    LOG.info("[END] Getting Fairness")
    #TODO: Create a Fairness object and return
    pass
Ejemplo n.º 8
0
def _capacity(file_object):
    LOG.info("[START] Getting capacity")
    reserved = _get_object(file_object)
    if reserved != "SAFE":
        err_message = ERROR_MESSAGE_TEMPLATE.format("SAFE", reserved)
        raise PetriNetInterpreterException(err_message)
    number = _get_object(file_object)
    if isinstance(number, Number):
        err_message = ERROR_MESSAGE_TEMPLATE.format("number", number)
        raise PetriNetInterpreterException(err_message)
    separator = _get_object(file_object)
    if reserved != ":":
        err_message = ERROR_MESSAGE_TEMPLATE.format(":", separator)
        raise PetriNetInterpreterException(err_message)
    LOG.info("[END] Getting capacity")
    #TODO: Create a capacity object and return
    pass
Ejemplo n.º 9
0
def _place_lists(file_object):
    LOG.info("[START] Getting Place lists")
    capacity = _capacity(file_object)
    place_list = _place_list(file_object)
    separator = _get_object(file_object)
    if separator != ";":
        err_message = ERROR_MESSAGE_TEMPLATE.format(";", separator)
        raise PetriNetInterpreterException(err_message)
    capacity = _capacity(file_object)
    while capacity:
        place_list = _place_list(file_object)
        separator = _get_object(file_object)
        if separator != ";":
            err_message = ERROR_MESSAGE_TEMPLATE.format(";", separator)
            raise PetriNetInterpreterException(err_message)
        capacity = _capacity(file_object)
    LOG.info("[END] Getting Place lists")
    #TODO: Create a Place lists object and return
    pass
Ejemplo n.º 10
0
def _net(file_object):
    LOG.info("[START] Processing new LoLA Petri net file")
    reserved = _get_object(file_object)
    if reserved != "PLACE":
        err_message = ERROR_MESSAGE_TEMPLATE.format("PLACE", reserved)
        raise PetriNetInterpreterException(err_message)

    place_list = _place_lists(file_object)

    reserved = _get_object(file_object)
    if reserved != "MARKING":
        err_message = ERROR_MESSAGE_TEMPLATE.format("MARKING", reserved)
        raise PetriNetInterpreterException(err_message)

    marking_list = _marking_list(file_object)

    separator = _get_object(file_object)
    if separator != ";":
        err_message = ERROR_MESSAGE_TEMPLATE.format(";", separator)
        raise PetriNetInterpreterException(err_message)

    transitions = []
    x = _transition(file_object)
    if not x:
        err_message = ERROR_MESSAGE_TEMPLATE.format("Transition Object", x)
        raise PetriNetInterpreterException(err_message)

    transitions.append(x)
    x = _transition(file_object)
    while x:
        transitions.append(x)
        x = _transition(file_object)

    LOG.info("[END] Processing new LoLA Petri net file")
    #TODO: Create a Petri Net object and return
    pass
Ejemplo n.º 11
0
model.change_input_flow("p_iddle", "t_1", 1)
model.change_output_flow("p_active", "t_1", 1)
model.change_input_flow("p_active", "t_2", 1)
model.change_output_flow("p_iddle", "t_2", 1)

""" Adding places, transitions and flow for 'P'"""
model.add_place("q_iddle")
model.add_place("q_active")
model.add_transition("t_3")
model.add_transition("t_4")
model.change_input_flow("q_iddle", "t_3", 1)
model.change_output_flow("q_active", "t_3", 1)
model.change_input_flow("q_active", "t_4", 1)
model.change_output_flow("q_iddle", "t_4", 1)

""" Initial Marking """
m_0 = {"p_iddle": 1, "q_iddle": 1}

""" Generates CTL formula """
a = ctl.CTLAtomicProposition("p_active")
b = ctl.CTLAtomicProposition("q_active")

phi_1 = ctl.CTLAnd(a, b)
TRUE = ctl.TRUE
phi_2 = ctl.CTLNegatedExistUntil(TRUE, phi_1)

LOG.info("===================================================================")
model.model_checking(m_0, phi_2)
LOG.info("===================================================================")
model.model_checking(m_0, phi_2.negate())
Ejemplo n.º 12
0
import sys
owfn_path = "../../"
sys.path.append(owfn_path)

from model_repair.logger import LOG
import model_repair.ctl as ctl

a = ctl.CTLAtomicProposition("a")
b = ctl.CTLAtomicProposition("b")

phi_1 = ctl.CTLAnd(a, b)
phi_2 = ctl.CTLNegatedExistGlobally(phi_1)
LOG.info(phi_2.print_lola())