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
6063b02b
Commit
6063b02b
authored
Aug 12, 2019
by
Kento HASEGAWA
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add scripts for ADC2019 system
parent
9a309441
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
154 additions
and
0 deletions
+154
-0
.gitignore
.gitignore
+59
-0
kwmr_solver.py
kwmr_solver.py
+95
-0
No files found.
.gitignore
0 → 100644
View file @
6063b02b
/*.txt
solver_soft/sim
### https://raw.github.com/github/gitignore/9d7ff09c7d38dce9ef03e7ea4dc908a622546757/C.gitignore
# Prerequisites
*.d
# Object files
*.o
*.ko
*.obj
*.elf
# Linker output
*.ilk
*.map
*.exp
# Precompiled Headers
*.gch
*.pch
# Libraries
*.lib
*.a
*.la
*.lo
# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib
# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex
# Debug files
*.dSYM/
*.su
*.idb
*.pdb
# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf
kwmr_solver.py
0 → 100644
View file @
6063b02b
import
argparse
import
os
import
subprocess
proc
=
None
stop_flag
=
False
def
stop
():
global
proc
global
stop_flag
stop_flag
=
True
if
not
proc
is
None
:
proc
.
terminate
()
print
(
'stopped'
)
def
solve
(
params
):
global
proc
global
stop_flag
stop_flag
=
False
# 必要な変数があるか確認
assert
(
'problem'
in
params
)
assert
(
'timeout'
in
params
)
problem
=
params
[
'problem'
]
timeout
=
params
[
'timeout'
]
basedir
=
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
))
solution_filepath
=
f
'{basedir}/a.txt'
if
os
.
path
.
exists
(
solution_filepath
):
os
.
remove
(
solution_filepath
)
cmds
=
f
'{basedir}/solver_soft/sim -o {solution_filepath}'
.
split
()
proc
=
subprocess
.
Popen
(
cmds
,
stdin
=
subprocess
.
PIPE
,
# stderr=subprocess.PIPE,
# stdout=subprocess.PIPE
)
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
status
=
'done'
if
os
.
path
.
exists
(
solution_filepath
):
with
open
(
solution_filepath
,
'r'
)
as
fp
:
solution
=
fp
.
read
()
else
:
status
=
'failed'
else
:
status
=
'failed'
return
{
'status'
:
status
,
'solution'
:
solution
}
def
main
(
args
):
with
open
(
args
[
'problem'
],
'r'
)
as
fp
:
problem
=
fp
.
read
()
params
=
{
'problem'
:
problem
,
'timeout'
:
args
[
'timeout'
]
}
ret
=
solve
(
params
)
print
(
ret
)
if
__name__
==
"__main__"
:
parser
=
argparse
.
ArgumentParser
(
description
=
'Wrapper Script for ADC2019 Solver'
)
parser
.
add_argument
(
'problem'
,
type
=
str
,
help
=
'File path to the problem file'
)
parser
.
add_argument
(
'-t'
,
'--timeout'
,
type
=
int
,
default
=
10
,
help
=
'Timeout for the process of the solver'
)
args
=
vars
(
parser
.
parse_args
())
main
(
args
)
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