Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kawamura-solver
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
adc2019
kawamura-solver
Commits
346a70f7
Commit
346a70f7
authored
Aug 20, 2019
by
Kento HASEGAWA
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a random seed to the solver arguments
parent
edb15677
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
9 deletions
+5
-9
kwmr_solver.py
kwmr_solver.py
+5
-9
No files found.
kwmr_solver.py
View file @
346a70f7
import
argparse
import
argparse
import
os
import
os
import
random
import
subprocess
import
subprocess
proc
=
None
proc
=
None
...
@@ -22,10 +23,8 @@ def solve(params):
...
@@ -22,10 +23,8 @@ def solve(params):
# 必要な変数があるか確認
# 必要な変数があるか確認
assert
(
'problem'
in
params
)
assert
(
'problem'
in
params
)
assert
(
'timeout'
in
params
)
problem
=
params
[
'problem'
]
problem
=
params
[
'problem'
]
timeout
=
params
[
'timeout'
]
basedir
=
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
))
basedir
=
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
))
...
@@ -33,7 +32,9 @@ def solve(params):
...
@@ -33,7 +32,9 @@ def solve(params):
if
os
.
path
.
exists
(
solution_filepath
):
if
os
.
path
.
exists
(
solution_filepath
):
os
.
remove
(
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
(
proc
=
subprocess
.
Popen
(
cmds
,
cmds
,
...
@@ -43,20 +44,15 @@ def solve(params):
...
@@ -43,20 +44,15 @@ def solve(params):
)
)
try
:
try
:
# outs, errs = proc.communicate()
proc
.
communicate
(
problem
.
encode
())
proc
.
communicate
(
problem
.
encode
())
status
=
'done'
status
=
'done'
except
Exception
as
ex
:
except
Exception
as
ex
:
status
=
'failed'
status
=
'failed'
finally
:
finally
:
returncode
=
proc
.
returncode
returncode
=
proc
.
returncode
# outs = outs.decode()
# errs = errs.decode()
# print(outs)
# print(errs)
solution
=
''
solution
=
''
if
returncode
==
0
:
# 10 when SAT
if
returncode
==
0
:
status
=
'done'
status
=
'done'
if
os
.
path
.
exists
(
solution_filepath
):
if
os
.
path
.
exists
(
solution_filepath
):
with
open
(
solution_filepath
,
'r'
)
as
fp
:
with
open
(
solution_filepath
,
'r'
)
as
fp
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment