-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcombisat
executable file
·50 lines (31 loc) · 1.09 KB
/
combisat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/python
from __future__ import with_statement
import optparse
import sys
from optparse import OptionParser
from solvers import PortfolioSolver
from solvers import ExternalSolver
from dimacs import parseDIMACSFormula
from dimacs import emitDIMACSSolution
def main():
# Read the command line arguments
parser = OptionParser()
parser.add_option("-s", "--solver", action="append", dest="solver_paths")
(options, args) = parser.parse_args()
if len(args) != 1:
parser.print_usage(sys.stderr)
exit(1)
if options.solver_paths is None:
sys.stderr.write("You need to specify at least one solver.\n")
exit(1)
formula = None
with open(args[0]) as inputFile:
formula = parseDIMACSFormula(inputFile)
solvers = []
for path in options.solver_paths:
solvers.append(ExternalSolver(path))
portfolio = PortfolioSolver(solvers)
solution = portfolio.solve(formula)
emitDIMACSSolution(sys.stdout, solution)
if __name__ == "__main__":
main()