-
Notifications
You must be signed in to change notification settings - Fork 0
/
rundlx.py
executable file
·64 lines (59 loc) · 2.47 KB
/
rundlx.py
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
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/python
import argparse
import subprocess
def main():
parser = argparse.ArgumentParser(
description = "Run a variant of the dlx binary")
binary = parser.add_mutually_exclusive_group()
binary.add_argument("--sharp", help="Use the sharp heuristic", action="store_true")
binary.add_argument("--skip", help="Use the skip heuristic", action="store_true")
binary.add_argument("--dlx1", help="Use dlx1 (original)", action="store_true")
binary.add_argument("--dlx2", help="Use dlx2 (variant with colors)", action="store_true")
binary.add_argument("--dlx3", help="Use dlx3 (variant with multiplicity)", action="store_true")
speed = parser.add_mutually_exclusive_group()
speed.add_argument("--fast", help="Output progress fast", action="store_true")
speed.add_argument("--faster", help="Output progress faster", action="store_true")
parser.add_argument("--pre", help="Run the preprocessor", nargs=1,
choices=["pipe", "stop"])
parser.add_argument("--verbose", help="Verbose output", action="store_true")
parser.add_argument("--stop", help="Stop at the nth solution", nargs="?",
default=None, type=int, metavar="n")
parser.add_argument("template", help="File template")
args = parser.parse_args()
if args.sharp:
executable = "dlx2.sharp"
elif args.skip:
executable = "dlx2.skip"
elif args.dlx1:
executable = "dlx1"
elif args.dlx3:
executable = "dlx3"
else:
executable = "dlx2"
verbose = "v391" if args.verbose else ""
if args.fast:
ticks = "d100000000"
elif args.faster:
ticks = "d10000000"
else:
ticks = "d1000000000"
stop = "t%d" % args.stop if args.stop else ""
if args.pre and args.pre[0] == "stop":
commandline = (
'(time /home/ricbit/work/knuth/dlx/dlx-pre < %s.dlx) > '
'%s.pre.dlx ' % #| grep -v -P "^(\s(?!after)|\d+:|Level|L\d+)"' %
(args.template, args.template))
else:
if args.pre and args.pre[0] == "pipe":
commandpipe = (
'/home/ricbit/work/knuth/dlx/dlx-pre < %s.dlx | '
'/home/ricbit/work/knuth/dlx/%s m1 %s %s %s ' %
(args.template, executable, ticks, stop, verbose))
else:
commandpipe = ('/home/ricbit/work/knuth/dlx/%s m1 %s %s %s < %s.dlx ' %
(executable, ticks, stop, verbose, args.template))
commandline = (
'(time (%s)) |& tee %s.out.txt | grep -v -P "^(\s(?!after)|\d+:|Level|L\d+)"' %
(commandpipe, args.template))
subprocess.call(commandline, shell=True, executable="/bin/bash")
main()