Loading kwmr_solver.py +5 −9 Changes for kwmr_solver.py: 5 added lines, 9 removed lines. Original line number Diff line number Diff line import argparse import os import random import subprocess proc = None Loading @@ -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__)) Loading @@ -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, Loading @@ -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: Loading Loading
kwmr_solver.py +5 −9 Changes for kwmr_solver.py: 5 added lines, 9 removed lines. Original line number Diff line number Diff line import argparse import os import random import subprocess proc = None Loading @@ -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__)) Loading @@ -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, Loading @@ -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: Loading