Commit e3f4e51a authored by Adéla Štěpková's avatar Adéla Štěpková
Browse files

minor changes

parent 49276b31
Loading
Loading
Loading
Loading
+17 −6
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@ import automata_parser as parser
import gate_finder
import powerset_complement as cmpl
from gate_complement import gate_complement
from port_complement import port_complement
from port_complement import port_complement, PartitionMethod
from compliments.generator import generate_compliment
import experiments.exp_utils as exp_utils
from typing import Optional
@@ -22,6 +22,7 @@ R_POWERSET = "r"
F_GATE = "g"
R_GATE = "gr"
PORT = "p"
PORT_2COMP = "p2"

############### Complementing functions #########################

@@ -54,7 +55,7 @@ def run_gate_complement(ext_nfa: ExtendedNFA,
        data["num_gates"] = "N/A"
        data["A1_size"] = "N/A"
        data["A2_size"] = "N/A"
        data["gate_size"] = "N/A"
        data["gate_comp_size"] = "N/A"
        data["deterministic"] = "N/A"
        data["type"] = "NONE"
        data["complement_time_ns"] = "N/A"
@@ -84,7 +85,8 @@ def run_port_complement(ext_nfa: ExtendedNFA,
                        data: dict,
                        minify_rabit: bool = False,
                        minify_dfa: bool = False,
                        lookahead: int = cmpl.LOOKAHEAD_DEFAULT) \
                        lookahead: int = cmpl.LOOKAHEAD_DEFAULT,
                        partition_method: PartitionMethod = PartitionMethod.BASIC) \
                            -> ExtendedNFA:
    
    start_time = time_ns()
@@ -92,7 +94,8 @@ def run_port_complement(ext_nfa: ExtendedNFA,
                           minify_rabit=minify_rabit, 
                           minify_dfa=minify_dfa,
                           lookahead=lookahead, 
                           data_dict=data)
                           data_dict=data,
                           partition_method=partition_method)
    comp_time = time_ns() - start_time

    data["port_comp_size"] = len(comp.states)
@@ -231,6 +234,13 @@ def complement_from_file(file_path: str,
                                       minify_dfa=dfa_min,
                                       lookahead=lookahead)
            
        elif mode == PORT_2COMP:
            comp = run_port_complement(ext_nfa, data, 
                                       minify_rabit=rabit_min_during, 
                                       minify_dfa=dfa_min,
                                       lookahead=lookahead,
                                       partition_method=PartitionMethod.TWO_COMP)

        elif mode == F_POWERSET:
            comp = run_forward_powerset_complement(ext_nfa, data)
        
@@ -356,14 +366,15 @@ def parse_arguments():

    # Optional arguments
    parser.add_argument('-m', '--mode',
                        choices=[F_GATE, R_GATE, F_POWERSET, R_POWERSET, PORT], default=F_GATE, 
                        choices=[F_GATE, R_GATE, F_POWERSET, R_POWERSET, PORT, PORT_2COMP], default=F_GATE, 
                        help=
f"""complementation algorithm to be used: 
{F_GATE}   gate complement (default)
{R_GATE}   gate complement on reversed automaton
{F_POWERSET}   forward powerset complement
{R_POWERSET}   reverse powerset complement
{PORT}   port complement
{PORT}   port complement with partition into sccs
{PORT_2COMP}   port complement with partition into 2 components
""")
    parser.add_argument('-O', '--options',
                        choices=[VALIDATE, DFA_MIN, RABIT_MIN, RABIT_MIN_AFTER], 
+2 −0
Original line number Diff line number Diff line
@@ -357,12 +357,14 @@ def vtf_to_ext_nfa(file_path: str):
                line = line.removeprefix("%Initial")
                add = line.split()
                initial_states.update(add)
                states.update(add)

            elif line.startswith("%Final"):
                # final states
                line = line.removeprefix("%Final")
                add = line.split()
                final_states.update(add)
                states.update(add)

            elif line.startswith("%Alphabet"):
                # input symbols
+1 −0
Original line number Diff line number Diff line
@@ -406,6 +406,7 @@ def port_complement(nfa: ExtendedNFA,

    comp_infos = partition_function(nfa, sccs, alphabet=nfa.input_symbols)
    data_dict["component_count"] = len(comp_infos)
    data_dict["last_comp_size"] = len(comp_infos[-1].aut.states)

    # print(nfa.states)
    # for ci in comp_infos: