Loading src/aligater.py +17 −6 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -22,6 +22,7 @@ R_POWERSET = "r" F_GATE = "g" R_GATE = "gr" PORT = "p" PORT_2COMP = "p2" ############### Complementing functions ######################### Loading Loading @@ -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" Loading Loading @@ -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() Loading @@ -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) Loading Loading @@ -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) Loading Loading @@ -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], Loading src/automata_parser.py +2 −0 Original line number Diff line number Diff line Loading @@ -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 Loading src/port_complement.py +1 −0 Original line number Diff line number Diff line Loading @@ -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: Loading Loading
src/aligater.py +17 −6 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -22,6 +22,7 @@ R_POWERSET = "r" F_GATE = "g" R_GATE = "gr" PORT = "p" PORT_2COMP = "p2" ############### Complementing functions ######################### Loading Loading @@ -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" Loading Loading @@ -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() Loading @@ -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) Loading Loading @@ -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) Loading Loading @@ -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], Loading
src/automata_parser.py +2 −0 Original line number Diff line number Diff line Loading @@ -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 Loading
src/port_complement.py +1 −0 Original line number Diff line number Diff line Loading @@ -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: Loading