Commit 4f078fc0 authored by VIGNET Pierre's avatar VIGNET Pierre
Browse files

Add ability to limit the number of solutions

parent a1763f22
......@@ -310,6 +310,8 @@ def main():
"given elements on each line")
parser_input_file.add_argument('--steps', type=int, nargs='?', default=10,
help="Maximum of allowed steps to find macs")
parser_input_file.add_argument('--limit', type=int, nargs='?', default=400,
help="Limit the number of solutions.")
# https://docs.python.org/dev/library/argparse.html#action
# all_macs to False by default
parser_input_file.add_argument('--all_macs', action='store_true',
......
......@@ -128,7 +128,7 @@ def make_logical_formula(previous_frontier_places, start_prop):
def main2(chart_file, mac_file, mac_step_file, mac_complete_file, mac_strong_file,
steps, final_prop, start_prop, inv_prop, all_macs, continue_run):
steps, final_prop, start_prop, inv_prop, all_macs, continue_run, limit):
"""
:param arg1: Model file (bcx, xml, cal).
......@@ -144,6 +144,7 @@ def main2(chart_file, mac_file, mac_step_file, mac_complete_file, mac_strong_fil
less or equal steps than previous, by limiting steps.
:param arg11: If set to True (not default), previous macs from a previous
run, will be reloaded.
:param arg12: Limit the number of solutions.
:type arg1: <str>
:type arg2: <str>
:type arg3: <str>
......@@ -155,6 +156,7 @@ def main2(chart_file, mac_file, mac_step_file, mac_complete_file, mac_strong_fil
:type arg9: <str>
:type arg10: <boolean>
:type arg11: <boolean>
:type arg12: <int>
.. todo: handle these QUERY PARAMETERS... from GUI program
......@@ -199,18 +201,15 @@ def main2(chart_file, mac_file, mac_step_file, mac_complete_file, mac_strong_fil
current_start_prop = start_prop
# i = 0
# with PyCallGraph(output=GraphvizOutput()):
i = 0
#with PyCallGraph(output=GraphvizOutput()):
while True:
print("START PROP:", current_start_prop)
ret = \
find_mac(mcla,
mac_file, mac_step_file, mac_complete_file,
steps, final_prop, current_start_prop, inv_prop)
# EXIT
# i += 1
# if i == 3:
# return
if ret:
frontier_places, min_steps = ret
else:
......@@ -236,6 +235,11 @@ def main2(chart_file, mac_file, mac_step_file, mac_complete_file, mac_strong_fil
if not all_macs:
steps = min_steps
# EXIT
i += 1
if i == limit:
return
LOGGER.debug("%s:: Next start_prop formula: %s in %s steps",
final_prop,
current_start_prop,
......@@ -654,7 +658,7 @@ def compute_macs(params):
mac_strong_file, # mac_strong_file
params['steps'], params['final_prop'],
params['start_prop'], params['inv_prop'],
params['all_macs'], params['continue'],
params['all_macs'], params['continue'], params['limit'],
)
def read_mac_file(file):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment