diff --git a/kwmr_solver.py b/kwmr_solver.py index f1b00dc1201510f9505c4c94fdb7aac6a139dd58..72cef3c53ac3d0232bdc8e2355af209d48956d8a 100644 --- a/kwmr_solver.py +++ b/kwmr_solver.py @@ -1,5 +1,6 @@ import argparse import os +import random import subprocess proc = None @@ -22,10 +23,8 @@ def solve(params): # 必要な変数があるか確認 assert('problem' in params) - assert('timeout' in params) problem = params['problem'] - timeout = params['timeout'] basedir = os.path.abspath(os.path.dirname(__file__)) @@ -33,7 +32,9 @@ def solve(params): if os.path.exists(solution_filepath): os.remove(solution_filepath) - cmds = f'{basedir}/solver_soft/sim -o {solution_filepath}'.split() + seed = random.randint(0, 2147483647) # seed: uint32_t <= 2147483647 + + cmds = f'{basedir}/solver_soft/sim -o {solution_filepath} -s {seed}'.split() proc = subprocess.Popen( cmds, @@ -43,20 +44,15 @@ def solve(params): ) try: - # outs, errs = proc.communicate() proc.communicate(problem.encode()) status = 'done' except Exception as ex: status = 'failed' finally: returncode = proc.returncode - # outs = outs.decode() - # errs = errs.decode() - # print(outs) - # print(errs) solution = '' - if returncode == 0: # 10 when SAT + if returncode == 0: status = 'done' if os.path.exists(solution_filepath): with open(solution_filepath, 'r') as fp: