1
0

Complete incremental benchmarks

This commit is contained in:
Jip J. Dekker 2021-07-26 12:39:48 +10:00
parent a8ef3e1312
commit 2ca68eb05b
No known key found for this signature in database
GPG Key ID: 517DF4A00618C9C3
28 changed files with 3366 additions and 15 deletions

168
gbac.py Executable file
View File

@ -0,0 +1,168 @@
#!/usr/bin/env python3
import os
import sys
import time
import csv
MZNR_HOME = os.getcwd() + "/software/install/minizinc/bin"
os.environ["PATH"] = MZNR_HOME + ":" + os.environ["PATH"]
os.environ["MZN_SOLVER_PATH"] = (
os.getcwd() + "/software/install/gecode/share/minizinc/solvers"
)
import minizinc
MZA_HOME = os.getcwd() + "/software/mza"
sys.path.append(MZA_HOME)
mza_lib = os.getcwd() + "/software/install/mza/lib"
if sys.platform == "linux" or sys.platform == "linux2":
rerun = True
if not "LD_LIBRARY_PATH" in os.environ:
os.environ["LD_LIBRARY_PATH"] = mza_lib
elif not mza_lib in os.environ.get("LD_LIBRARY_PATH"):
os.environ["LD_LIBRARY_PATH"] += ":" + mza_lib
else:
rerun = False
if rerun:
os.execve(os.path.realpath(__file__), sys.argv, os.environ)
import mza
from mza import Instance
mza.DEBUG = False
SOLVER = "gecode_presolver"
PROTO_MODEL = "gbac/proto.uzn"
RESTART_MODEL = "gbac/on_restart.mzn"
DATA = [
"gbac/reduced_UD4-gbac.dzn",
"gbac/UD2-gbac.dzn",
"gbac/UD4-gbac.dzn",
"gbac/UD5-gbac.dzn",
"gbac/UD8-gbac.dzn",
]
FN_ID = "f_lex_obj_i"
N_NBH = 2
ROUNDS = 1000
RUNS = 1
def gbac_restart(data_file):
os.environ["MZN_STDLIB_DIR"] = (
os.getcwd() + "/software/install/minizinc/share/minizinc"
)
gecode = minizinc.Solver.lookup("gecode")
inst = minizinc.Instance(gecode, minizinc.Model(RESTART_MODEL))
inst.add_file(data_file)
args = {
"--restart": "constant",
"--restart-scale": 500,
"--restart-limit": ROUNDS,
}
res = inst.solve(**args)
return (
res.statistics["flatTime"].total_seconds(),
(res.statistics["initTime"] + res.statistics["solveTime"]).total_seconds(),
)
def gbac_incr(data_file):
os.environ["MZN_STDLIB_DIR"] = os.getcwd() + "/software/mza/share/minizinc"
compile_time = 0.0
solve_time = 0.0
incumbent = None
start = time.perf_counter()
mza.set_rnd_seed(0)
inst = Instance(PROTO_MODEL, data_file, "gecode_presolver")
compile_time += time.perf_counter() - start
start = time.perf_counter()
status, sol = inst.solve()
solve_time += time.perf_counter() - start
# print(f"{status}: {sol}")
assert status in ["SAT", "OPT"]
incumbent = sol
for i in range(1, ROUNDS):
mza.set_rnd_seed(i)
inst.set_limit(500)
with inst.branch() as child:
start = time.perf_counter()
child.add_call("f_LNS_i", i % 2)
compile_time += time.perf_counter() - start
start = time.perf_counter()
status, sol = child.solve()
solve_time += time.perf_counter() - start
# print(f"{status}: {sol}")
if status == "SAT" or status == "OPT":
incumbent = sol
assert status != "ERROR"
return compile_time, solve_time
def gbac_redo(data_file):
os.environ["MZN_STDLIB_DIR"] = os.getcwd() + "/software/mza/share/minizinc"
compile_time = 0.0
solve_time = 0.0
incumbent = None
for i in range(ROUNDS):
start = time.perf_counter()
mza.set_rnd_seed(i)
inst = Instance(PROTO_MODEL, data_file, "gecode_presolver")
inst.output_dict(True)
limit = 0
if i > 0:
inst.set_limit(500)
assert incumbent is not None
limit = 500
inst.set_incumbent(incumbent)
inst.add_call("f_LNS_i", i % 2)
compile_time += time.perf_counter() - start
start = time.perf_counter()
status, sol = inst.solve()
solve_time += time.perf_counter() - start
# print(
# f"{i} {status}: [{ ', '.join([str(v) for k, v in sol.items()]) if isinstance(sol, dict) else sol}]"
# )
if status == "SAT" or status == "OPT":
incumbent = sol
elif status == "ERROR":
print("ERROR!!!!")
exit(0)
return compile_time, solve_time
if __name__ == "__main__":
fieldnames = ["Configuration", "Data", "Compile Time (s)", "Solve Time (s)"]
writer = csv.writer(sys.stdout)
writer.writerow(fieldnames)
# --- Run Restart based strategy
for d in DATA:
t1, t2 = 0, 0
for i in range(RUNS):
ct, st = gbac_restart(d)
t1 += ct
t2 += st
writer.writerow(["RBS", d, t1 / RUNS, t2 / RUNS])
# --- Run incremental rewriting
for d in DATA:
t1, t2 = 0, 0
for i in range(RUNS):
ct, st = gbac_incr(d)
t1 += ct
t2 += st
writer.writerow(["Incr.", d, t1 / RUNS, t2 / RUNS])
# --- Run baseline
for d in DATA:
t1, t2 = 0, 0
for i in range(RUNS):
ct, st = gbac_redo(d)
t1 += ct * 10
t2 += st * 10
writer.writerow(["Base", d, t1 / RUNS, t2 / RUNS])

View File

@ -15,6 +15,6 @@ w1 = 1;
w2 = 1;
course_load = [6, 6, 6, 6, 6, 5, 5, 6, 6, 6, 6, 16, 5, 6, 6, 6, 5, 5, 5, 6, 5, 5, 6, 5, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 7, 7, 5, 5, 7, 7, 7, 5, 5, 5, 6, 6, 6, 5, 7, 7, 5, 5, 7, 7, 6, 6, 7, 5, 5, 15, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 7, 5, 7, 7, 5, 5, 5, 7, 7, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 5, 6, 5, 5, 5, 6, 6, 5, 15, 17, 5, 5, 7, 7, 5, 6, 5, 6, 5, 5, 6, 6, 16, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 5, 6, 5, 5, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 5, 5, 5, 6, 5, 5, 6, 6, 2, 1, 1, 1, 1, 3, 3, 3, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 5, 5, 6, 16, 6, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 3, 15, 6, 6, 6, 6, 6, 6, 6, 6, 5, 6, 5, 6, 5, 5, 5, 5, 5, 6, 5, 5, 6, 5, 5, 5, 5, 5, 6, 5, 5, 5, 5, 5, 5, 5, 5, 6, 5] ;
courses_of = [{267, 268, 35, 39, 40, 45, 46, 47, 48, 49, 53, 189, 61, 62, 67, 103, 104, 105, 107, 108, 110, 115, 123}, {267, 268, 35, 38, 39, 40, 45, 46, 47, 48, 49, 53, 58, 62, 64, 67, 103, 104, 105, 107, 108, 109, 115}, {268, 16, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 47, 48, 190, 191, 79, 98, 99, 103, 106, 115, 117}, {136, 268, 35, 36, 37, 38, 39, 40, 41, 43, 44, 45, 46, 47, 48, 190, 191, 100, 101, 102, 103, 115, 117}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 147, 19, 22, 23, 24, 25, 31, 160, 186, 213, 215, 238, 111, 112, 239, 240, 241}, {2, 7, 8, 9, 10, 11, 13, 14, 16, 17, 147, 19, 20, 21, 23, 24, 25, 26, 27, 28, 29, 30, 32, 33, 34, 160, 186, 187, 214, 216, 238, 111, 239, 240, 241, 116}, {41, 49, 50, 51, 52, 53, 54, 55, 56, 185, 57, 58, 59, 60, 184, 201, 210, 113, 120, 121, 122, 123, 124}, {49, 50, 52, 53, 54, 55, 56, 185, 57, 184, 60, 61, 62, 63, 64, 201, 202, 209, 210, 211, 108, 113, 121, 122, 123}, {41, 49, 50, 51, 53, 54, 55, 56, 185, 57, 184, 60, 65, 66, 67, 68, 69, 202, 210, 82, 113, 121, 123}, {188, 192, 193, 194, 195, 196, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 96, 97, 114, 118, 119}, {16, 17, 192, 193, 194, 195, 196, 70, 71, 72, 73, 74, 203, 78, 79, 80, 83, 85, 86, 87, 88, 89, 96, 97, 114, 118, 119}, {188, 192, 193, 194, 195, 196, 70, 71, 72, 73, 74, 77, 78, 79, 80, 90, 91, 92, 93, 94, 95, 96, 97, 114, 118, 119}, {128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 267, 139, 140, 141, 142, 155, 156, 158, 159, 197, 198, 199, 200, 85, 89, 243, 244, 249, 250, 251, 252}, {128, 2, 267, 140, 142, 143, 144, 145, 146, 147, 14, 148, 149, 150, 151, 153, 152, 154, 155, 27, 157, 159, 160, 242, 243, 244, 245, 246, 247, 248, 125, 127}, {128, 2, 131, 258, 5, 267, 140, 142, 143, 144, 14, 148, 149, 151, 152, 153, 154, 27, 155, 157, 159, 160, 33, 242, 243, 244, 245, 246, 247, 248, 125, 126}, {259, 260, 261, 262, 263, 264, 265, 266, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 177, 182, 183, 205, 207, 212, 253, 254, 255}, {259, 260, 261, 262, 263, 264, 265, 266, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 175, 176, 182, 183, 205, 207, 212, 253, 254, 255}, {259, 260, 261, 262, 263, 264, 265, 266, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 178, 179, 183, 204, 205, 206, 207, 212, 253, 254, 255}, {259, 260, 261, 262, 263, 264, 265, 266, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 175, 180, 181, 183, 204, 207, 208, 212, 253, 254, 255}, {256, 257, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237}] ;
precedes = array2d(precedences,1..2, [213, 15, 7, 33, 7, 215, 7, 216, 10, 11, 16, 17, 20, 33, 20, 215, 20, 216, 24, 33, 24, 215, 24, 216, 25, 33, 25, 215, 25, 216, 26, 33, 26, 215, 26, 216, 28, 33, 28, 215, 28, 216, 31, 147, 35, 48, 35, 64, 36, 48, 36, 64, 16, 48, 16, 64, 43, 48, 43, 64, 49, 58, 49, 59, 49, 64, 49, 65, 49, 122, 49, 41, 50, 58, 50, 59, 50, 64, 50, 65, 50, 122, 50, 41, 51, 58, 51, 59, 51, 64, 51, 65, 51, 122, 51, 41, 52, 58, 52, 59, 52, 64, 52, 108, 52, 65, 52, 122, 52, 41, 53, 58, 61, 58, 61, 59, 61, 63, 61, 64, 61, 65, 61, 122, 61, 41, 66, 69, 97, 70, 104, 105, 104, 191, 107, 48, 107, 64, 108, 48, 108, 64, 49, 48, 109, 48, 109, 64, 117, 48, 117, 108, 117, 64, 121, 59, 125, 5, 127, 150, 129, 125, 129, 85, 129, 142, 129, 5, 129, 154, 131, 126, 134, 133, 135, 125, 135, 85, 135, 142, 135, 5, 135, 154, 143, 144, 147, 125, 147, 85, 147, 142, 147, 5, 147, 154, 160, 125, 160, 85, 160, 142, 160, 2, 160, 5, 160, 154, 14, 125, 14, 85, 14, 142, 14, 5, 14, 154, 148, 125, 148, 85, 148, 142, 148, 5, 148, 154, 149, 152, 151, 153, 154, 258, 155, 125, 155, 85, 155, 142, 155, 5, 155, 154, 160, 33, 160, 215, 160, 216, 166, 212, 184, 185, 190, 105, 190, 191, 197, 125, 197, 85, 197, 142, 197, 5, 197, 154, 199, 125, 199, 85, 199, 142, 199, 5, 199, 154, 213, 33, 213, 215, 213, 216, 222, 227, 222, 229, 222, 236, 223, 227, 223, 229, 223, 236, 225, 227, 225, 229, 225, 236, 239, 24, 242, 125, 242, 85, 242, 142, 242, 5, 242, 154, 246, 125, 246, 85, 246, 142, 246, 5, 246, 154, 249, 125, 249, 85, 249, 142, 249, 5, 249, 154, 252, 125, 252, 85, 252, 142, 252, 5, 252, 154, 268, 48, 268, 64] );
undesirable = array2d(undesirables,1..2, [226, 2, 226, 5, 210, 3, 210, 6, 245, 1, 245, 4, 90, 3, 90, 6, 75, 2, 75, 5, 128, 2, 128, 5, 98, 2, 98, 5, 256, 3, 256, 6, 171, 3, 171, 6, 38, 2, 38, 5, 5, 1, 5, 4, 37, 3, 37, 6, 42, 2, 42, 5, 35, 1, 35, 4, 268, 1, 268, 4, 138, 3, 138, 6, 165, 1, 165, 4, 171, 2, 171, 5, 133, 3, 133, 6, 79, 3, 79, 6, 142, 3, 142, 6, 108, 3, 108, 6, 76, 2, 76, 5, 217, 3, 217, 6, 19, 3, 19, 6, 141, 1, 141, 4, 52, 2, 52, 5, 239, 2, 239, 5, 18, 1, 18, 4, 123, 1, 123, 4, 64, 3, 64, 6, 242, 3, 242, 6, 72, 2, 72, 5, 101, 3, 101, 6, 143, 1, 143, 4, 118, 3, 118, 6, 250, 3, 250, 6, 77, 3, 77, 6, 172, 2, 172, 5, 185, 1, 185, 4, 223, 1, 223, 4, 62, 3, 62, 6, 94, 3, 94, 6, 257, 2, 257, 5, 177, 3, 177, 6, 107, 3, 107, 6, 184, 3, 184, 6, 130, 1, 130, 4, 255, 3, 255, 6, 40, 3, 40, 6, 167, 1, 167, 4, 211, 1, 211, 4, 120, 1, 120, 4, 51, 1, 51, 4, 150, 2, 150, 5, 46, 3, 46, 6, 28, 1, 28, 4, 264, 3, 264, 6, 184, 2, 184, 5, 201, 2, 201, 5, 79, 1, 79, 4, 157, 1, 157, 4, 41, 3, 41, 6, 34, 3, 34, 6, 44, 3, 44, 6, 20, 3, 20, 6, 15, 2, 15, 5, 48, 1, 48, 4, 214, 3, 214, 6, 176, 3, 176, 6, 172, 3, 172, 6, 26, 1, 26, 4, 140, 1, 140, 4, 19, 1, 19, 4, 124, 3, 124, 6, 154, 3, 154, 6, 14, 1, 14, 4, 239, 1, 239, 4, 234, 1, 234, 4] );
precedes = array2d(1..n_precedences,1..2, [213, 15, 7, 33, 7, 215, 7, 216, 10, 11, 16, 17, 20, 33, 20, 215, 20, 216, 24, 33, 24, 215, 24, 216, 25, 33, 25, 215, 25, 216, 26, 33, 26, 215, 26, 216, 28, 33, 28, 215, 28, 216, 31, 147, 35, 48, 35, 64, 36, 48, 36, 64, 16, 48, 16, 64, 43, 48, 43, 64, 49, 58, 49, 59, 49, 64, 49, 65, 49, 122, 49, 41, 50, 58, 50, 59, 50, 64, 50, 65, 50, 122, 50, 41, 51, 58, 51, 59, 51, 64, 51, 65, 51, 122, 51, 41, 52, 58, 52, 59, 52, 64, 52, 108, 52, 65, 52, 122, 52, 41, 53, 58, 61, 58, 61, 59, 61, 63, 61, 64, 61, 65, 61, 122, 61, 41, 66, 69, 97, 70, 104, 105, 104, 191, 107, 48, 107, 64, 108, 48, 108, 64, 49, 48, 109, 48, 109, 64, 117, 48, 117, 108, 117, 64, 121, 59, 125, 5, 127, 150, 129, 125, 129, 85, 129, 142, 129, 5, 129, 154, 131, 126, 134, 133, 135, 125, 135, 85, 135, 142, 135, 5, 135, 154, 143, 144, 147, 125, 147, 85, 147, 142, 147, 5, 147, 154, 160, 125, 160, 85, 160, 142, 160, 2, 160, 5, 160, 154, 14, 125, 14, 85, 14, 142, 14, 5, 14, 154, 148, 125, 148, 85, 148, 142, 148, 5, 148, 154, 149, 152, 151, 153, 154, 258, 155, 125, 155, 85, 155, 142, 155, 5, 155, 154, 160, 33, 160, 215, 160, 216, 166, 212, 184, 185, 190, 105, 190, 191, 197, 125, 197, 85, 197, 142, 197, 5, 197, 154, 199, 125, 199, 85, 199, 142, 199, 5, 199, 154, 213, 33, 213, 215, 213, 216, 222, 227, 222, 229, 222, 236, 223, 227, 223, 229, 223, 236, 225, 227, 225, 229, 225, 236, 239, 24, 242, 125, 242, 85, 242, 142, 242, 5, 242, 154, 246, 125, 246, 85, 246, 142, 246, 5, 246, 154, 249, 125, 249, 85, 249, 142, 249, 5, 249, 154, 252, 125, 252, 85, 252, 142, 252, 5, 252, 154, 268, 48, 268, 64] );
undesirable = array2d(1..n_undesirables,1..2, [226, 2, 226, 5, 210, 3, 210, 6, 245, 1, 245, 4, 90, 3, 90, 6, 75, 2, 75, 5, 128, 2, 128, 5, 98, 2, 98, 5, 256, 3, 256, 6, 171, 3, 171, 6, 38, 2, 38, 5, 5, 1, 5, 4, 37, 3, 37, 6, 42, 2, 42, 5, 35, 1, 35, 4, 268, 1, 268, 4, 138, 3, 138, 6, 165, 1, 165, 4, 171, 2, 171, 5, 133, 3, 133, 6, 79, 3, 79, 6, 142, 3, 142, 6, 108, 3, 108, 6, 76, 2, 76, 5, 217, 3, 217, 6, 19, 3, 19, 6, 141, 1, 141, 4, 52, 2, 52, 5, 239, 2, 239, 5, 18, 1, 18, 4, 123, 1, 123, 4, 64, 3, 64, 6, 242, 3, 242, 6, 72, 2, 72, 5, 101, 3, 101, 6, 143, 1, 143, 4, 118, 3, 118, 6, 250, 3, 250, 6, 77, 3, 77, 6, 172, 2, 172, 5, 185, 1, 185, 4, 223, 1, 223, 4, 62, 3, 62, 6, 94, 3, 94, 6, 257, 2, 257, 5, 177, 3, 177, 6, 107, 3, 107, 6, 184, 3, 184, 6, 130, 1, 130, 4, 255, 3, 255, 6, 40, 3, 40, 6, 167, 1, 167, 4, 211, 1, 211, 4, 120, 1, 120, 4, 51, 1, 51, 4, 150, 2, 150, 5, 46, 3, 46, 6, 28, 1, 28, 4, 264, 3, 264, 6, 184, 2, 184, 5, 201, 2, 201, 5, 79, 1, 79, 4, 157, 1, 157, 4, 41, 3, 41, 6, 34, 3, 34, 6, 44, 3, 44, 6, 20, 3, 20, 6, 15, 2, 15, 5, 48, 1, 48, 4, 214, 3, 214, 6, 176, 3, 176, 6, 172, 3, 172, 6, 26, 1, 26, 4, 140, 1, 140, 4, 19, 1, 19, 4, 124, 3, 124, 6, 154, 3, 154, 6, 14, 1, 14, 4, 239, 1, 239, 4, 234, 1, 234, 4] );
% {'c1079': 214, 'c412': 3, 'c1101': 223, 'c816': 147, 'c478': 53, 'c537': 93, 'c1146': 256, 'c676': 113, 'c489': 58, 'c527': 85, 'c420': 8, 'c526': 84, 'c446': 32, 'c431': 18, 'c922': 185, 'c1178': 265, 'c415': 4, 'c856': 173, 'c514': 75, 'c821': 149, 'c495': 61, 'c831': 156, 'c476': 51, 'c498': 64, 'c513': 74, 'c833': 157, 'c839': 161, 'c428': 15, 'c479': 54, 'c504': 68, 'c1072': 212, 'c1003': 194, 'c1105': 227, 'c455': 39, 'c828': 154, 'c865': 178, 'c532': 88, 'c1131': 245, 'c533': 89, 'c1137': 251, 'c1106': 228, 'c803': 136, 'c1065': 207, 'c1123': 238, 'c546': 100, 'c1179': 266, 'c519': 78, 'c474': 49, 'c718': 116, 'c598': 106, 'c1004': 195, 'c606': 109, 'c501': 65, 'c539': 95, 'c647': 111, 'c536': 92, 'c1062': 204, 'c812': 143, 'c848': 168, 'c1135': 249, 'c862': 177, 'c491': 59, 'c835': 159, 'c1096': 218, 'c798': 134, 'c1134': 248, 'c860': 175, 'c814': 145, 'c440': 26, 'c447': 33, 'c1185': 268, 'c871': 182, 'c419': 7, 'c1067': 209, 'c1097': 219, 'c806': 138, 'c1021': 197, 'c435': 21, 'c872': 183, 'c1127': 242, 'c1120': 236, 'c724': 118, 'c737': 121, 'c1063': 205, 'c502': 66, 'c1081': 215, 'c452': 36, 'c841': 163, 'c861': 176, 'c520': 79, 'c425': 12, 'c566': 105, 'c840': 162, 'c460': 43, 'c830': 155, 'c437': 23, 'c1132': 246, 'c1005': 196, 'c815': 146, 'c800': 135, 'c453': 37, 'c523': 81, 'c444': 30, 'c747': 124, 'c515': 76, 'c1122': 237, 'c852': 171, 'c738': 122, 'c510': 71, 'c1053': 201, 'c1099': 221, 'c426': 13, 'c795': 131, 'c721': 117, 'c409': 1, 'c487': 57, 'c1107': 229, 'c788': 125, 'c670': 112, 'c813': 144, 'c1102': 224, 'c599': 107, 'c461': 44, 'c1126': 241, 'c857': 174, 'c1125': 240, 'c869': 181, 'c450': 35, 'c429': 16, 'c1055': 202, 'c1147': 257, 'c506': 69, 'c1110': 231, 'c464': 47, 'c477': 52, 'c462': 45, 'c423': 11, 'c540': 96, 'c496': 62, 'c1142': 255, 'c1095': 217, 'c730': 120, 'c1047': 200, 'c422': 10, 'c1103': 225, 'c427': 14, 'c436': 22, 'c1071': 211, 'c1068': 210, 'c791': 128, 'c507': 70, 'c416': 5, 'c600': 108, 'c561': 103, 'c1001': 192, 'c449': 34, 'c1174': 261, 'c441': 27, 'c866': 179, 'c725': 119, 'c845': 165, 'c538': 94, 'c1184': 267, 'c1111': 232, 'c521': 80, 'c1064': 206, 'c853': 172, 'c432': 19, 'c933': 187, 'c524': 82, 'c454': 38, 'c475': 50, 'c810': 141, 'c849': 169, 'c1119': 235, 'c445': 31, 'c793': 129, 'c745': 123, 'c1066': 208, 'c1002': 193, 'c551': 101, 'c1138': 252, 'c834': 158, 'c804': 137, 'c531': 87, 'c921': 184, 'c534': 90, 'c1166': 259, 'c1140': 253, 'c1124': 239, 'c457': 41, 'c794': 130, 'c456': 40, 'c789': 126, 'c807': 139, 'c417': 6, 'c790': 127, 'c535': 91, 'c820': 148, 'c811': 142, 'c486': 56, 'c433': 20, 'c439': 25, 'c836': 160, 'c1057': 203, 'c868': 180, 'c421': 9, 'c997': 191, 'c1074': 213, 'c1104': 226, 'c544': 99, 'c541': 97, 'c463': 46, 'c1136': 250, 'c824': 152, 'c511': 72, 'c826': 153, 'c1022': 198, 'c458': 42, 'c1118': 234, 'c850': 170, 'c465': 48, 'c932': 186, 'c438': 24, 'c564': 104, 'c1129': 244, 'c494': 60, 'c822': 150, 'c516': 77, 'c1176': 263, 'c530': 86, 'c847': 167, 'c430': 17, 'c525': 83, 'c996': 190, 'c797': 133, 'c1128': 243, 'c1177': 264, 'c1175': 262, 'c1167': 260, 'c846': 166, 'c993': 189, 'c823': 151, 'c796': 132, 'c1133': 247, 'c808': 140, 'c1141': 254, 'c716': 115, 'c1046': 199, 'c607': 110, 'c543': 98, 'c443': 29, 'c1100': 222, 'c936': 188, 'c442': 28, 'c484': 55, 'c512': 73, 'c1109': 230, 'c1112': 233, 'c1148': 258, 'c411': 2, 'c844': 164, 'c678': 114, 'c497': 63, 'c503': 67, 'c1082': 216, 'c1098': 220, 'c554': 102}

View File

@ -15,6 +15,6 @@ w1 = 1;
w2 = 1;
course_load = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 12, 6, 6, 6, 6, 6, 6, 6, 12, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 12, 6, 6, 12, 6, 6, 6, 6, 12, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 12, 12, 6, 12, 6, 12, 12, 6, 6, 12, 6, 6, 6, 6, 6, 6, 6, 12, 12, 6, 6, 6, 6, 12, 6, 6, 6, 12, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 12, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6] ;
courses_of = [{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 131, 12, 13, 14, 135, 16, 136, 137, 132, 29, 30, 31, 32, 33, 34, 133, 36, 105, 107, 112, 113, 115, 116, 117, 118, 119}, {1, 2, 3, 4, 5, 6, 7, 131, 132, 10, 11, 133, 134, 135, 15, 136, 17, 18, 19, 20, 21, 29, 32, 35, 36, 137, 105, 107, 112, 113, 114, 115, 116, 117, 118, 119}, {1, 2, 3, 4, 5, 6, 7, 131, 132, 133, 135, 136, 13, 137, 16, 22, 23, 24, 25, 29, 34, 36, 105, 106, 107, 112, 113, 115, 116, 117, 118, 119}, {1, 2, 3, 4, 5, 6, 7, 131, 132, 133, 135, 136, 137, 19, 22, 24, 25, 26, 27, 28, 29, 35, 36, 105, 106, 107, 112, 113, 115, 116, 117, 118, 119}, {128, 130, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 111, 53, 54, 55, 58, 60, 61, 62}, {128, 129, 130, 37, 38, 39, 40, 41, 42, 43, 47, 48, 49, 50, 51, 53, 54, 55, 57, 58, 59, 62}, {128, 37, 38, 39, 40, 41, 42, 43, 44, 46, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 61, 62}, {138, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 76, 84, 86, 87, 88, 90, 94, 108, 109, 120, 121, 122, 126, 127}, {138, 63, 64, 65, 66, 67, 68, 69, 70, 73, 77, 78, 79, 82, 84, 86, 87, 88, 90, 94, 108, 109, 111, 120, 121, 122, 126, 127}, {138, 19, 35, 63, 64, 65, 66, 67, 68, 69, 70, 80, 84, 86, 87, 88, 90, 94, 98, 104, 108, 109, 111, 120, 121, 122, 126, 127}, {138, 63, 64, 65, 66, 67, 68, 69, 70, 81, 84, 86, 87, 88, 89, 90, 94, 108, 109, 111, 120, 121, 122, 126, 127}, {138, 47, 63, 64, 65, 66, 67, 68, 69, 70, 74, 75, 83, 84, 85, 86, 87, 88, 94, 108, 109, 111, 120, 121, 122, 126, 127}, {64, 96, 97, 99, 102, 103, 123, 139, 111, 124, 125, 120, 89, 90, 91, 92, 93, 94, 95}, {64, 96, 100, 101, 102, 73, 123, 139, 110, 124, 125, 120, 89, 90, 91, 92, 93, 94, 95}, {64, 96, 98, 35, 102, 104, 123, 139, 124, 81, 19, 125, 120, 89, 90, 91, 92, 93, 94, 95}, {64, 96, 102, 73, 123, 139, 77, 78, 124, 125, 120, 89, 90, 91, 92, 93, 94, 95}] ;
precedes = array2d(precedences,1..2, [1, 5, 1, 18, 1, 20, 1, 27, 1, 28, 1, 36, 1, 114, 1, 117, 1, 118, 1, 134, 2, 5, 2, 18, 2, 20, 2, 27, 2, 28, 2, 36, 2, 114, 2, 117, 2, 118, 2, 134, 8, 5, 8, 18, 8, 20, 8, 27, 8, 28, 8, 36, 8, 114, 8, 117, 8, 118, 8, 134, 9, 5, 9, 18, 9, 20, 9, 27, 9, 28, 9, 36, 9, 114, 9, 117, 9, 118, 9, 134, 11, 5, 11, 18, 11, 20, 11, 27, 11, 28, 11, 36, 11, 114, 11, 117, 11, 118, 11, 134, 37, 111, 37, 49, 37, 60, 37, 61, 37, 62, 38, 111, 38, 49, 38, 60, 38, 61, 38, 62, 39, 111, 39, 49, 39, 60, 39, 61, 39, 62, 63, 66, 63, 69, 63, 70, 63, 76, 63, 77, 63, 78, 63, 81, 63, 87, 63, 127, 63, 138, 65, 66, 65, 69, 65, 70, 65, 76, 65, 77, 65, 78, 65, 81, 65, 87, 65, 127, 65, 138, 90, 66, 90, 69, 90, 70, 90, 76, 90, 77, 90, 78, 90, 81, 90, 87, 90, 127, 90, 138, 71, 66, 71, 69, 71, 70, 71, 76, 71, 77, 71, 78, 71, 81, 71, 87, 71, 127, 71, 138, 74, 66, 74, 69, 74, 70, 74, 76, 74, 77, 74, 78, 74, 81, 74, 87, 74, 127, 74, 138, 90, 111, 90, 99, 90, 100, 90, 101, 90, 110, 90, 139, 91, 111, 91, 99, 91, 100, 91, 101, 91, 81, 91, 77, 91, 78, 91, 110, 91, 139, 92, 111, 92, 99, 92, 100, 92, 101, 92, 81, 92, 77, 92, 78, 92, 110, 92, 139, 105, 5, 105, 18, 105, 20, 105, 27, 105, 28, 105, 36, 105, 114, 105, 117, 105, 118, 105, 134, 108, 66, 108, 69, 108, 70, 108, 76, 108, 77, 108, 78, 108, 81, 108, 87, 108, 127, 108, 138, 124, 111, 124, 99, 124, 100, 124, 101, 124, 81, 124, 77, 124, 78, 124, 110, 124, 139, 126, 66, 126, 69, 126, 70, 126, 76, 126, 77, 126, 78, 126, 81, 126, 87, 126, 127, 126, 138, 131, 5, 131, 18, 131, 20, 131, 27, 131, 28, 131, 36, 131, 114, 131, 117, 131, 118, 131, 134] );
undesirable = array2d(undesirables,1..2, [117, 2, 117, 5, 109, 3, 109, 6, 127, 1, 127, 4, 47, 3, 47, 6, 39, 2, 39, 5, 67, 2, 67, 5, 51, 2, 51, 5, 133, 3, 133, 6, 89, 3, 89, 6, 20, 2, 20, 5, 3, 1, 3, 4, 20, 3, 20, 6, 22, 2, 22, 5, 19, 1, 19, 4, 139, 1, 139, 4, 72, 3, 72, 6, 86, 1, 86, 4, 89, 2, 89, 5, 69, 3, 69, 6, 41, 3, 41, 6, 74, 3, 74, 6, 56, 3, 56, 6, 40, 2, 40, 5, 113, 3, 113, 6, 10, 3, 10, 6, 74, 1, 74, 4, 27, 2, 27, 5, 124, 2, 124, 5, 9, 1, 9, 4, 64, 1, 64, 4, 34, 3, 34, 6, 126, 3, 126, 6, 38, 2, 38, 5, 53, 3, 53, 6, 61, 3, 61, 6, 130, 3, 130, 6, 40, 3, 40, 6, 96, 1, 96, 4, 62, 3, 62, 6, 116, 1, 116, 4] );
precedes = array2d(1..n_precedences,1..2, [1, 5, 1, 18, 1, 20, 1, 27, 1, 28, 1, 36, 1, 114, 1, 117, 1, 118, 1, 134, 2, 5, 2, 18, 2, 20, 2, 27, 2, 28, 2, 36, 2, 114, 2, 117, 2, 118, 2, 134, 8, 5, 8, 18, 8, 20, 8, 27, 8, 28, 8, 36, 8, 114, 8, 117, 8, 118, 8, 134, 9, 5, 9, 18, 9, 20, 9, 27, 9, 28, 9, 36, 9, 114, 9, 117, 9, 118, 9, 134, 11, 5, 11, 18, 11, 20, 11, 27, 11, 28, 11, 36, 11, 114, 11, 117, 11, 118, 11, 134, 37, 111, 37, 49, 37, 60, 37, 61, 37, 62, 38, 111, 38, 49, 38, 60, 38, 61, 38, 62, 39, 111, 39, 49, 39, 60, 39, 61, 39, 62, 63, 66, 63, 69, 63, 70, 63, 76, 63, 77, 63, 78, 63, 81, 63, 87, 63, 127, 63, 138, 65, 66, 65, 69, 65, 70, 65, 76, 65, 77, 65, 78, 65, 81, 65, 87, 65, 127, 65, 138, 90, 66, 90, 69, 90, 70, 90, 76, 90, 77, 90, 78, 90, 81, 90, 87, 90, 127, 90, 138, 71, 66, 71, 69, 71, 70, 71, 76, 71, 77, 71, 78, 71, 81, 71, 87, 71, 127, 71, 138, 74, 66, 74, 69, 74, 70, 74, 76, 74, 77, 74, 78, 74, 81, 74, 87, 74, 127, 74, 138, 90, 111, 90, 99, 90, 100, 90, 101, 90, 110, 90, 139, 91, 111, 91, 99, 91, 100, 91, 101, 91, 81, 91, 77, 91, 78, 91, 110, 91, 139, 92, 111, 92, 99, 92, 100, 92, 101, 92, 81, 92, 77, 92, 78, 92, 110, 92, 139, 105, 5, 105, 18, 105, 20, 105, 27, 105, 28, 105, 36, 105, 114, 105, 117, 105, 118, 105, 134, 108, 66, 108, 69, 108, 70, 108, 76, 108, 77, 108, 78, 108, 81, 108, 87, 108, 127, 108, 138, 124, 111, 124, 99, 124, 100, 124, 101, 124, 81, 124, 77, 124, 78, 124, 110, 124, 139, 126, 66, 126, 69, 126, 70, 126, 76, 126, 77, 126, 78, 126, 81, 126, 87, 126, 127, 126, 138, 131, 5, 131, 18, 131, 20, 131, 27, 131, 28, 131, 36, 131, 114, 131, 117, 131, 118, 131, 134] );
undesirable = array2d(1..n_undesirables,1..2, [117, 2, 117, 5, 109, 3, 109, 6, 127, 1, 127, 4, 47, 3, 47, 6, 39, 2, 39, 5, 67, 2, 67, 5, 51, 2, 51, 5, 133, 3, 133, 6, 89, 3, 89, 6, 20, 2, 20, 5, 3, 1, 3, 4, 20, 3, 20, 6, 22, 2, 22, 5, 19, 1, 19, 4, 139, 1, 139, 4, 72, 3, 72, 6, 86, 1, 86, 4, 89, 2, 89, 5, 69, 3, 69, 6, 41, 3, 41, 6, 74, 3, 74, 6, 56, 3, 56, 6, 40, 2, 40, 5, 113, 3, 113, 6, 10, 3, 10, 6, 74, 1, 74, 4, 27, 2, 27, 5, 124, 2, 124, 5, 9, 1, 9, 4, 64, 1, 64, 4, 34, 3, 34, 6, 126, 3, 126, 6, 38, 2, 38, 5, 53, 3, 53, 6, 61, 3, 61, 6, 130, 3, 130, 6, 40, 3, 40, 6, 96, 1, 96, 4, 62, 3, 62, 6, 116, 1, 116, 4] );
% {'c365': 78, 'c346': 64, 'c635': 117, 'c652': 128, 'c313': 32, 'c640': 121, 'c664': 139, 'c356': 72, 'c655': 130, 'c401': 103, 'c353': 70, 'c312': 31, 'c651': 127, 'c384': 92, 'c305': 24, 'c309': 28, 'c388': 96, 'c345': 63, 'c393': 99, 'c310': 29, 'c625': 111, 'c289': 8, 'c649': 125, 'c379': 88, 'c292': 11, 'c332': 50, 'c285': 4, 'c333': 51, 'c300': 19, 'c294': 13, 'c339': 57, 'c297': 16, 'c632': 114, 'c661': 136, 'c284': 3, 'c378': 87, 'c319': 38, 'c656': 131, 'c283': 2, 'c286': 5, 'c299': 18, 'c657': 132, 'c347': 65, 'c395': 101, 'c624': 110, 'c322': 41, 'c368': 80, 'c348': 66, 'c307': 26, 'c287': 6, 'c317': 36, 'c373': 84, 'c374': 85, 'c338': 56, 'c370': 82, 'c662': 137, 'c663': 138, 'c296': 15, 'c636': 118, 'c336': 54, 'c351': 68, 'c381': 89, 'c637': 119, 'c337': 55, 'c634': 116, 'c386': 94, 'c316': 35, 'c659': 134, 'c369': 81, 'c350': 67, 'c302': 21, 'c619': 107, 'c617': 105, 'c306': 25, 'c355': 71, 'c642': 123, 'c638': 120, 'c391': 98, 'c376': 86, 'c323': 42, 'c331': 49, 'c330': 48, 'c334': 52, 'c363': 76, 'c311': 30, 'c372': 83, 'c308': 27, 'c290': 9, 'c648': 124, 'c315': 34, 'c318': 37, 'c291': 10, 'c658': 133, 'c653': 129, 'c326': 45, 'c382': 90, 'c618': 106, 'c282': 1, 'c633': 115, 'c361': 74, 'c358': 73, 'c303': 22, 'c402': 104, 'c387': 95, 'c288': 7, 'c400': 102, 'c298': 17, 'c364': 77, 'c325': 44, 'c366': 79, 'c324': 43, 'c620': 108, 'c295': 14, 'c389': 97, 'c328': 47, 'c321': 40, 'c335': 53, 'c630': 112, 'c320': 39, 'c385': 93, 'c623': 109, 'c301': 20, 'c342': 60, 'c344': 62, 'c327': 46, 'c293': 12, 'c352': 69, 'c641': 122, 'c631': 113, 'c383': 91, 'c660': 135, 'c650': 126, 'c394': 100, 'c314': 33, 'c362': 75, 'c341': 59, 'c340': 58, 'c304': 23, 'c343': 61}

File diff suppressed because one or more lines are too long

View File

@ -15,6 +15,6 @@ w1 = 1;
w2 = 1;
course_load = [6, 6, 6, 6, 6, 5, 5, 6, 6, 6, 6, 16, 5, 6, 6, 6, 5, 5, 5, 6, 5, 5, 6, 5, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 7, 7, 5, 5, 7, 7, 7, 5, 5, 5, 6, 6, 6, 5, 7, 7, 5, 5, 7, 7, 6, 6, 7, 5, 5, 15, 5, 5, 5, 5, 5, 5, 5, 5, 5, 7, 5, 7, 7, 5, 5, 5, 7, 7, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 5, 6, 5, 6, 5, 5, 6, 6, 5, 15, 17, 5, 5, 7, 7, 5, 6, 5, 6, 5, 5, 6, 6, 16, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 5, 6, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 5, 5, 6, 6, 2, 1, 1, 1, 1, 5, 3, 3, 3, 3, 5, 5, 5, 5, 5, 5, 5, 6, 5, 5, 6, 16, 6, 7, 5] ;
courses_of = [{35, 39, 40, 45, 46, 47, 48, 49, 53, 181, 61, 62, 67, 102, 103, 104, 105, 107, 108, 109, 111, 116, 124}, {35, 38, 39, 40, 45, 46, 47, 48, 49, 53, 58, 62, 64, 67, 102, 103, 104, 105, 107, 108, 109, 110, 116}, {16, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46, 47, 48, 182, 183, 78, 97, 98, 102, 103, 106, 116, 118}, {138, 35, 36, 37, 38, 39, 40, 41, 43, 44, 45, 46, 47, 48, 182, 183, 99, 100, 101, 102, 103, 116, 118}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 149, 23, 25, 163, 178, 204, 206, 112, 113}, {2, 8, 9, 10, 11, 14, 16, 17, 19, 20, 149, 21, 22, 23, 24, 26, 27, 28, 29, 30, 25, 31, 32, 33, 34, 163, 179, 205, 207, 112, 117}, {41, 176, 177, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 189, 60, 194, 201, 114, 121, 122, 123, 124, 125}, {176, 177, 49, 50, 52, 53, 54, 55, 56, 57, 60, 189, 61, 62, 64, 63, 194, 195, 200, 201, 202, 108, 114, 122, 123, 124}, {41, 176, 177, 49, 50, 51, 53, 54, 55, 56, 57, 60, 189, 65, 66, 67, 68, 195, 201, 208, 81, 114, 122, 124}, {180, 184, 185, 186, 187, 188, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 95, 96, 115, 119, 120}, {16, 17, 184, 185, 186, 187, 188, 196, 69, 70, 71, 72, 73, 77, 78, 79, 82, 84, 85, 86, 87, 88, 95, 96, 115, 119, 120}, {180, 184, 185, 186, 187, 188, 69, 70, 71, 72, 73, 76, 77, 78, 79, 89, 90, 91, 92, 93, 94, 95, 96, 115, 119, 120}, {129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 158, 159, 161, 162, 190, 191, 192, 193, 84, 88, 109}, {128, 129, 2, 142, 14, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 27, 156, 157, 158, 160, 162, 163, 109, 126}, {129, 2, 132, 5, 142, 14, 144, 145, 146, 150, 151, 153, 154, 27, 155, 156, 158, 157, 160, 33, 162, 163, 109, 126, 127}, {164, 165, 166, 167, 168, 169, 170, 171, 172, 198, 203, 175}, {164, 165, 166, 167, 168, 169, 170, 171, 172, 198, 203, 175}, {164, 165, 166, 167, 168, 169, 170, 171, 197, 173, 198, 203}, {164, 165, 166, 167, 168, 169, 170, 171, 197, 199, 174, 203}] ;
precedes = array2d(precedences,1..2, [6, 33, 6, 206, 6, 207, 7, 33, 7, 206, 7, 207, 10, 11, 16, 17, 20, 33, 20, 206, 20, 207, 24, 33, 24, 206, 24, 207, 25, 33, 25, 206, 25, 207, 26, 33, 26, 206, 26, 207, 28, 33, 28, 206, 28, 207, 31, 149, 35, 48, 35, 64, 36, 48, 36, 64, 16, 48, 16, 64, 43, 48, 43, 64, 49, 59, 49, 64, 49, 65, 49, 123, 49, 41, 50, 59, 50, 64, 50, 65, 50, 123, 50, 41, 51, 59, 51, 64, 51, 65, 51, 123, 51, 41, 52, 59, 52, 64, 52, 108, 52, 65, 52, 123, 52, 41, 53, 58, 61, 59, 61, 63, 61, 64, 61, 65, 61, 123, 61, 41, 66, 68, 96, 69, 102, 48, 102, 64, 104, 105, 104, 183, 107, 48, 107, 64, 108, 48, 108, 64, 49, 48, 110, 48, 110, 64, 118, 48, 118, 108, 118, 64, 122, 59, 126, 5, 128, 152, 130, 126, 130, 84, 130, 144, 130, 5, 130, 157, 132, 127, 135, 134, 136, 126, 136, 84, 136, 144, 136, 5, 136, 157, 137, 126, 137, 84, 137, 144, 137, 5, 137, 157, 145, 146, 149, 126, 149, 84, 149, 144, 149, 5, 149, 157, 163, 126, 163, 84, 163, 144, 163, 2, 163, 5, 163, 157, 14, 126, 14, 84, 14, 144, 14, 5, 14, 157, 150, 126, 150, 84, 150, 144, 150, 5, 150, 157, 151, 154, 153, 156, 157, 155, 158, 126, 158, 84, 158, 144, 158, 5, 158, 157, 163, 33, 163, 206, 163, 207, 166, 203, 176, 177, 182, 105, 182, 183, 189, 59, 189, 64, 189, 65, 189, 123, 189, 41, 190, 126, 190, 84, 190, 144, 190, 5, 190, 157, 192, 126, 192, 84, 192, 144, 192, 5, 192, 157, 204, 15] );
undesirable = array2d(undesirables,1..2, [4, 1, 4, 4, 14, 1, 14, 4, 15, 3, 15, 6, 22, 1, 22, 4, 27, 1, 27, 4, 29, 3, 29, 6, 30, 2, 30, 5, 31, 3, 31, 6, 33, 2, 33, 5, 36, 3, 36, 6, 40, 1, 40, 4, 40, 2, 40, 5, 48, 3, 48, 6, 50, 3, 50, 6, 56, 2, 56, 5, 58, 2, 58, 5, 59, 2, 59, 5, 60, 3, 60, 6, 61, 3, 61, 6, 70, 3, 70, 6, 73, 3, 73, 6, 76, 2, 76, 5, 79, 3, 79, 6, 83, 3, 83, 6, 84, 3, 84, 6, 92, 3, 92, 6, 93, 1, 93, 4, 96, 1, 96, 4, 100, 2, 100, 5, 101, 1, 101, 4, 103, 3, 103, 6, 104, 3, 104, 6, 107, 3, 107, 6, 110, 1, 110, 4, 110, 3, 110, 6, 111, 1, 111, 4, 116, 2, 116, 5, 128, 1, 128, 4, 129, 1, 129, 4, 133, 2, 133, 5, 133, 3, 133, 6, 134, 2, 134, 5, 137, 3, 137, 6, 143, 2, 143, 5, 143, 3, 143, 6, 144, 1, 144, 4, 163, 3, 163, 6, 164, 1, 164, 4, 169, 3, 169, 6, 173, 1, 173, 4, 175, 2, 175, 5, 186, 2, 186, 5, 188, 3, 188, 6, 190, 1, 190, 4, 194, 3, 194, 6, 198, 3, 198, 6, 199, 2, 199, 5, 199, 3, 199, 6, 205, 3, 205, 6, 208, 1, 208, 4] );
precedes = array2d(1..n_precedences,1..2, [6, 33, 6, 206, 6, 207, 7, 33, 7, 206, 7, 207, 10, 11, 16, 17, 20, 33, 20, 206, 20, 207, 24, 33, 24, 206, 24, 207, 25, 33, 25, 206, 25, 207, 26, 33, 26, 206, 26, 207, 28, 33, 28, 206, 28, 207, 31, 149, 35, 48, 35, 64, 36, 48, 36, 64, 16, 48, 16, 64, 43, 48, 43, 64, 49, 59, 49, 64, 49, 65, 49, 123, 49, 41, 50, 59, 50, 64, 50, 65, 50, 123, 50, 41, 51, 59, 51, 64, 51, 65, 51, 123, 51, 41, 52, 59, 52, 64, 52, 108, 52, 65, 52, 123, 52, 41, 53, 58, 61, 59, 61, 63, 61, 64, 61, 65, 61, 123, 61, 41, 66, 68, 96, 69, 102, 48, 102, 64, 104, 105, 104, 183, 107, 48, 107, 64, 108, 48, 108, 64, 49, 48, 110, 48, 110, 64, 118, 48, 118, 108, 118, 64, 122, 59, 126, 5, 128, 152, 130, 126, 130, 84, 130, 144, 130, 5, 130, 157, 132, 127, 135, 134, 136, 126, 136, 84, 136, 144, 136, 5, 136, 157, 137, 126, 137, 84, 137, 144, 137, 5, 137, 157, 145, 146, 149, 126, 149, 84, 149, 144, 149, 5, 149, 157, 163, 126, 163, 84, 163, 144, 163, 2, 163, 5, 163, 157, 14, 126, 14, 84, 14, 144, 14, 5, 14, 157, 150, 126, 150, 84, 150, 144, 150, 5, 150, 157, 151, 154, 153, 156, 157, 155, 158, 126, 158, 84, 158, 144, 158, 5, 158, 157, 163, 33, 163, 206, 163, 207, 166, 203, 176, 177, 182, 105, 182, 183, 189, 59, 189, 64, 189, 65, 189, 123, 189, 41, 190, 126, 190, 84, 190, 144, 190, 5, 190, 157, 192, 126, 192, 84, 192, 144, 192, 5, 192, 157, 204, 15] );
undesirable = array2d(1..n_undesirables,1..2, [4, 1, 4, 4, 14, 1, 14, 4, 15, 3, 15, 6, 22, 1, 22, 4, 27, 1, 27, 4, 29, 3, 29, 6, 30, 2, 30, 5, 31, 3, 31, 6, 33, 2, 33, 5, 36, 3, 36, 6, 40, 1, 40, 4, 40, 2, 40, 5, 48, 3, 48, 6, 50, 3, 50, 6, 56, 2, 56, 5, 58, 2, 58, 5, 59, 2, 59, 5, 60, 3, 60, 6, 61, 3, 61, 6, 70, 3, 70, 6, 73, 3, 73, 6, 76, 2, 76, 5, 79, 3, 79, 6, 83, 3, 83, 6, 84, 3, 84, 6, 92, 3, 92, 6, 93, 1, 93, 4, 96, 1, 96, 4, 100, 2, 100, 5, 101, 1, 101, 4, 103, 3, 103, 6, 104, 3, 104, 6, 107, 3, 107, 6, 110, 1, 110, 4, 110, 3, 110, 6, 111, 1, 111, 4, 116, 2, 116, 5, 128, 1, 128, 4, 129, 1, 129, 4, 133, 2, 133, 5, 133, 3, 133, 6, 134, 2, 134, 5, 137, 3, 137, 6, 143, 2, 143, 5, 143, 3, 143, 6, 144, 1, 144, 4, 163, 3, 163, 6, 164, 1, 164, 4, 169, 3, 169, 6, 173, 1, 173, 4, 175, 2, 175, 5, 186, 2, 186, 5, 188, 3, 188, 6, 190, 1, 190, 4, 194, 3, 194, 6, 198, 3, 198, 6, 199, 2, 199, 5, 199, 3, 199, 6, 205, 3, 205, 6, 208, 1, 208, 4] );
% {'c824': 154, 'c543': 97, 'c825': 155, 'c433': 20, 'c417': 6, 'c527': 84, 'c546': 99, 'c415': 4, 'c993': 181, 'c501': 65, 'c1063': 198, 'c1002': 185, 'c478': 53, 'c833': 160, 'c794': 131, 'c456': 40, 'c1068': 201, 'c427': 14, 'c834': 161, 'c462': 45, 'c1057': 196, 'c454': 38, 'c512': 72, 'c820': 150, 'c1055': 195, 'c422': 10, 'c1046': 192, 'c441': 27, 'c1021': 190, 'c457': 41, 'c429': 16, 'c852': 169, 'c738': 123, 'c516': 76, 'c513': 73, 'c847': 167, 'c502': 66, 'c426': 13, 'c830': 158, 'c534': 89, 'c450': 35, 'c538': 93, 'c745': 124, 'c871': 175, 'c461': 44, 'c442': 28, 'c853': 170, 'c458': 42, 'c474': 49, 'c476': 51, 'c855': 171, 'c525': 82, 'c541': 96, 'c1047': 193, 'c793': 130, 'c411': 2, 'c465': 48, 'c533': 88, 'c599': 107, 'c475': 50, 'c484': 55, 'c437': 23, 'c1079': 205, 'c932': 178, 'c495': 61, 'c816': 149, 'c856': 172, 'c846': 166, 'c561': 103, 'c730': 121, 'c449': 34, 'c607': 111, 'c430': 17, 'c566': 105, 'c438': 24, 'c790': 128, 'c507': 69, 'c455': 39, 'c718': 117, 'c789': 127, 'c536': 91, 'c443': 29, 'c835': 162, 'c845': 165, 'c445': 31, 'c1001': 184, 'c747': 125, 'c724': 119, 'c600': 108, 'c869': 174, 'c598': 106, 'c826': 156, 'c489': 58, 'c812': 145, 'c412': 3, 'c670': 113, 'c796': 133, 'c866': 173, 'c540': 95, 'c463': 46, 'c814': 147, 'c440': 26, 'c409': 1, 'c464': 47, 'c800': 136, 'c423': 11, 'c850': 168, 'c806': 140, 'c804': 139, 'c997': 183, 'c840': 164, 'c996': 182, 'c431': 18, 'c1074': 204, 'c460': 43, 'c1067': 200, 'c531': 86, 'c797': 134, 'c606': 110, 'c788': 126, 'c421': 9, 'c487': 57, 'c498': 64, 'c564': 104, 'c922': 177, 'c444': 30, 'c416': 5, 'c1014': 189, 'c503': 67, 'c1094': 208, 'c801': 137, 'c535': 90, 'c808': 142, 'c676': 114, 'c725': 120, 'c1053': 194, 'c530': 85, 'c491': 59, 'c479': 54, 'c537': 92, 'c1003': 186, 'c1082': 207, 'c836': 163, 'c477': 52, 'c795': 132, 'c496': 62, 'c936': 180, 'c544': 98, 'c737': 122, 'c1071': 202, 'c828': 157, 'c494': 60, 'c716': 116, 'c506': 68, 'c446': 32, 'c511': 71, 'c1066': 199, 'c524': 81, 'c497': 63, 'c1005': 188, 'c532': 87, 'c523': 80, 'c791': 129, 'c831': 159, 'c419': 7, 'c554': 101, 'c425': 12, 'c807': 141, 'c435': 21, 'c436': 22, 'c447': 33, 'c1062': 197, 'c823': 153, 'c1022': 191, 'c602': 109, 'c678': 115, 'c822': 152, 'c798': 135, 'c1072': 203, 'c813': 146, 'c515': 75, 'c428': 15, 'c811': 144, 'c510': 70, 'c721': 118, 'c486': 56, 'c432': 19, 'c1081': 206, 'c539': 94, 'c452': 36, 'c520': 78, 'c439': 25, 'c933': 179, 'c1004': 187, 'c921': 176, 'c526': 83, 'c514': 74, 'c560': 102, 'c519': 77, 'c803': 138, 'c453': 37, 'c647': 112, 'c521': 79, 'c810': 143, 'c551': 100, 'c420': 8, 'c815': 148, 'c821': 151}

View File

@ -22,7 +22,8 @@
%
%------------------------------------------------------------------------------%
% Includes
include "globals.mzn";
include "global_cardinality_low_up_closed.mzn";
include "bin_packing_load.mzn";
%------------------------------------------------------------------------------%
% Parameters
@ -119,4 +120,4 @@ constraint objective = w1 * norm + w2 * undesirable_violation;
constraint trace("% init_area = \(ub(objective));\n", true);
output
["objective = ", show(objective)] ++[";\n"] ++
["period_of = ", show(period_of)] ++ [";\n"];
["period_of = ", show(period_of)] ++ [";\n"];

35
gbac/proto.mzn Normal file
View File

@ -0,0 +1,35 @@
include "gbac.mzn";
%-----------------------------------------------------------------------------%
% Objective
%-----------------------------------------------------------------------------%
function int: uniform_set(set of int: S) =
if card(S) == max(S) - min(S) + 1 then
uniform(min(S),max(S))
else
[ i | i in S ][uniform(1,card(S))]
endif;
predicate random_allocation() =
forall(i in courses) (
(uniform(1,100) < 80) -> (period_of[i] == sol(period_of[i]))
);
predicate free_period() =
let {
int: period = uniform_set(periods);
} in forall(i in courses) (
(sol(period_of[i]) != period) -> (period_of[i] == sol(period_of[i]))
);
predicate LNS(int: choice) ::export =
objective < sol(objective) /\
if choice == 0 then
free_period()
else
random_allocation()
endif;
constraint output_this([objective] ++ period_of);
solve :: int_search(period_of,first_fail,indomain_min,complete) satisfy;

1397
gbac/proto.uzn Normal file

File diff suppressed because it is too large Load Diff

View File

@ -19,6 +19,6 @@ w1 = 1;
w2 = 1;
course_load = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 12, 6, 6, 6, 6, 6, 6, 6, 6, 6, 12, 6, 6, 12, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6] ;
courses_of = [{1, 2, 3, 35, 8, 28, 29, 30}, {1, 3, 4, 5, 35, 28, 29, 30}, {1, 35, 6, 8, 28, 29, 30}, {1, 35, 4, 6, 7, 28, 29, 30}, {34, 9, 10, 11, 12, 13, 15, 17, 18}, {34, 9, 10, 11, 12, 13, 14, 15, 18}, {9, 10, 11, 12, 14, 15, 16, 17, 18}, {32, 33, 19, 20, 21, 22, 24, 27}, {32, 33, 19, 20, 21, 24, 27}, {32, 33, 4, 19, 20, 21, 24, 27}, {32, 33, 19, 20, 21, 24, 25, 27}, {32, 33, 13, 19, 20, 21, 23, 24, 27}, {25, 26, 19, 36, 31}, {25, 26, 19, 36, 31}, {4, 36, 19, 25, 26, 31}, {25, 26, 19, 36, 31}] ;
precedes = array2d(precedences,1..2, [2, 5, 2, 7, 2, 30, 9, 17, 9, 18, 10, 17, 10, 18, 23, 21, 23, 33, 31, 36, 32, 21, 32, 33] );
undesirable = array2d(undesirables,1..2, [1, 1, 1, 4, 2, 1, 2, 4, 3, 3, 3, 6, 4, 1, 4, 4, 5, 2, 5, 5, 5, 3, 5, 6, 6, 2, 6, 5, 7, 2, 7, 5, 8, 3, 8, 6, 9, 2, 9, 5, 10, 2, 10, 5, 11, 2, 11, 5, 11, 3, 11, 6, 12, 3, 12, 6, 13, 3, 13, 6, 14, 2, 14, 5, 15, 3, 15, 6, 16, 3, 16, 6, 17, 3, 17, 6, 18, 3, 18, 6, 19, 1, 19, 4, 20, 2, 20, 5, 21, 3, 21, 6, 22, 3, 22, 6, 23, 3, 23, 6, 23, 1, 23, 4, 24, 1, 24, 4, 25, 3, 25, 6, 25, 2, 25, 5, 26, 1, 26, 4, 27, 3, 27, 6, 28, 3, 28, 6, 29, 1, 29, 4, 30, 2, 30, 5, 31, 2, 31, 5, 32, 3, 32, 6, 33, 1, 33, 4, 34, 3, 34, 6, 35, 3, 35, 6, 36, 1, 36, 4] );
precedes = array2d(1..n_precedences,1..2, [2, 5, 2, 7, 2, 30, 9, 17, 9, 18, 10, 17, 10, 18, 23, 21, 23, 33, 31, 36, 32, 21, 32, 33] );
undesirable = array2d(1..n_undesirables,1..2, [1, 1, 1, 4, 2, 1, 2, 4, 3, 3, 3, 6, 4, 1, 4, 4, 5, 2, 5, 5, 5, 3, 5, 6, 6, 2, 6, 5, 7, 2, 7, 5, 8, 3, 8, 6, 9, 2, 9, 5, 10, 2, 10, 5, 11, 2, 11, 5, 11, 3, 11, 6, 12, 3, 12, 6, 13, 3, 13, 6, 14, 2, 14, 5, 15, 3, 15, 6, 16, 3, 16, 6, 17, 3, 17, 6, 18, 3, 18, 6, 19, 1, 19, 4, 20, 2, 20, 5, 21, 3, 21, 6, 22, 3, 22, 6, 23, 3, 23, 6, 23, 1, 23, 4, 24, 1, 24, 4, 25, 3, 25, 6, 25, 2, 25, 5, 26, 1, 26, 4, 27, 3, 27, 6, 28, 3, 28, 6, 29, 1, 29, 4, 30, 2, 30, 5, 31, 2, 31, 5, 32, 3, 32, 6, 33, 1, 33, 4, 34, 3, 34, 6, 35, 3, 35, 6, 36, 1, 36, 4] );
% {'c308': 7, 'c335': 15, 'c648': 31, 'c655': 34, 'c344': 18, 'c303': 6, 'c320': 10, 'c352': 21, 'c328': 13, 'c284': 1, 'c635': 30, 'c321': 11, 'c650': 32, 'c361': 23, 'c634': 29, 'c338': 16, 'c333': 14, 'c381': 25, 'c319': 9, 'c356': 22, 'c350': 20, 'c376': 24, 'c346': 19, 'c322': 12, 'c664': 36, 'c651': 33, 'c623': 27, 'c301': 5, 'c388': 26, 'c343': 17, 'c658': 35, 'c315': 8, 'c631': 28, 'c291': 3, 'c290': 2, 'c300': 4}

View File

@ -7,12 +7,15 @@ module load flex
mkdir -p software/{build,install}
# Build Chuffed
for dir in "chuffed" "gecode" "gecode_on_record" "gecode_on_replay" "minizinc"
# Build
for dir in "chuffed" "gecode" "gecode_base" "gecode_on_record" "gecode_on_replay" "minizinc"
do
cmake -S software/${dir} -B software/build/${dir} -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=`pwd`/software/install/${dir}
cmake -S software/${dir} -B software/build/${dir} -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=`pwd`/software/install/${dir} -DCMAKE_POSITION_INDEPENDENT_CODE=ON
cmake --build software/build/${dir} --config Release --target install -- -j4
done
cmake -S software/mza -B software/build/mza -DGECODE_ROOT=`pwd`/software/install/gecode_base/ -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=`pwd`/software/install/mza -DCMAKE_POSITION_INDEPENDENT_CODE=ON
cmake --build software/build/mza --config Release --target install -- -j4
ln -s `pwd`/software/install/gecode/share/minizinc/gecode/mznlib `pwd`/software/install/minizinc/share/minizinc/gecode
ln -s `pwd`/software/install/chuffed/share/minizinc/chuffed `pwd`/software/install/minizinc/share/minizinc/chuffed

16
output/gbac.csv Normal file
View File

@ -0,0 +1,16 @@
Configuration,Data,Compile Time (s),Solve Time (s)
Base,gbac/UD2-gbac.dzn,25.458818981423974,17.341287191957235
Base,gbac/UD4-gbac.dzn,25.138776898384094,14.327164655551314
Base,gbac/UD5-gbac.dzn,28.67881595157087,19.71248783171177
Base,gbac/UD8-gbac.dzn,27.21088409423828,25.1462098434567
Base,gbac/reduced_UD4-gbac.dzn,22.770592607557774,6.444738935679197
Incremental Rewriting,gbac/UD2-gbac.dzn,0.44289878150448203,16.619278862606734
Incremental Rewriting,gbac/UD4-gbac.dzn,0.2829281724989414,14.927907383069396
Incremental Rewriting,gbac/UD5-gbac.dzn,0.5103892032057047,18.957355537917465
Incremental Rewriting,gbac/UD8-gbac.dzn,0.39341115299612284,24.45117470016703
Incremental Rewriting,gbac/reduced_UD4-gbac.dzn,0.13793163280934095,7.798715312965214
Restart Based Search,gbac/UD2-gbac.dzn,0.24477300000000002,10.421576
Restart Based Search,gbac/UD4-gbac.dzn,0.1655035,5.5756935
Restart Based Search,gbac/UD5-gbac.dzn,0.35128000000000004,19.6692045
Restart Based Search,gbac/UD8-gbac.dzn,0.18578899999999998,22.257126
Restart Based Search,gbac/reduced_UD4-gbac.dzn,0.076363,5.0173045
1 Configuration Data Compile Time (s) Solve Time (s)
2 Base gbac/UD2-gbac.dzn 25.458818981423974 17.341287191957235
3 Base gbac/UD4-gbac.dzn 25.138776898384094 14.327164655551314
4 Base gbac/UD5-gbac.dzn 28.67881595157087 19.71248783171177
5 Base gbac/UD8-gbac.dzn 27.21088409423828 25.1462098434567
6 Base gbac/reduced_UD4-gbac.dzn 22.770592607557774 6.444738935679197
7 Incremental Rewriting gbac/UD2-gbac.dzn 0.44289878150448203 16.619278862606734
8 Incremental Rewriting gbac/UD4-gbac.dzn 0.2829281724989414 14.927907383069396
9 Incremental Rewriting gbac/UD5-gbac.dzn 0.5103892032057047 18.957355537917465
10 Incremental Rewriting gbac/UD8-gbac.dzn 0.39341115299612284 24.45117470016703
11 Incremental Rewriting gbac/reduced_UD4-gbac.dzn 0.13793163280934095 7.798715312965214
12 Restart Based Search gbac/UD2-gbac.dzn 0.24477300000000002 10.421576
13 Restart Based Search gbac/UD4-gbac.dzn 0.1655035 5.5756935
14 Restart Based Search gbac/UD5-gbac.dzn 0.35128000000000004 19.6692045
15 Restart Based Search gbac/UD8-gbac.dzn 0.18578899999999998 22.257126
16 Restart Based Search gbac/reduced_UD4-gbac.dzn 0.076363 5.0173045

28
output/radiation.csv Normal file
View File

@ -0,0 +1,28 @@
Configuration,Data,Compile Time (s),Solve Time (s)
Base,radiation/01.dzn,0.24510734984651208,0.023913082107901572
Base,radiation/02.dzn,0.30582690900191667,0.028090783022344114
Base,radiation/03.dzn,0.3193663267418742,0.031867857277393344
Base,radiation/04.dzn,0.39944209847599266,0.06285300282761455
Base,radiation/05.dzn,0.3814492827281356,0.07408921113237739
Base,radiation/06.dzn,0.42284395741298797,0.0830705595202744
Base,radiation/07.dzn,0.3188631976954639,0.03759916163980961
Base,radiation/08.dzn,0.41931043174117805,0.16300638895481825
Base,radiation/09.dzn,0.4676839098334312,0.2566952796652913
Incremental Rewriting,radiation/01.dzn,0.01925070183351636,0.01717325309291482
Incremental Rewriting,radiation/02.dzn,0.020097369328141212,0.014758218824863435
Incremental Rewriting,radiation/03.dzn,0.019597070664167403,0.03506866861134768
Incremental Rewriting,radiation/04.dzn,0.020147585589438678,0.046414986718446016
Incremental Rewriting,radiation/05.dzn,0.020718697272241116,0.07127303797751665
Incremental Rewriting,radiation/06.dzn,0.020426739938557148,0.0479787765070796
Incremental Rewriting,radiation/07.dzn,0.020852961204946042,0.031166965235024692
Incremental Rewriting,radiation/08.dzn,0.020653770212084054,0.240933208912611
Incremental Rewriting,radiation/09.dzn,0.020874314848333596,0.23791785333305598
Restart Based Search,radiation/01.dzn,0.0397587,0.0156963
Restart Based Search,radiation/02.dzn,0.03960400000000001,0.012639799999999998
Restart Based Search,radiation/03.dzn,0.039819400000000005,0.018935200000000003
Restart Based Search,radiation/04.dzn,0.044984100000000006,0.03167359999999999
Restart Based Search,radiation/05.dzn,0.045806799999999995, 0.068683
Restart Based Search,radiation/06.dzn,0.0460396,0.0317119
Restart Based Search,radiation/07.dzn,0.048206399999999996,0.016760999999999998
Restart Based Search,radiation/08.dzn,0.048394900000000005,0.1321796
Restart Based Search,radiation/09.dzn,0.048275,0.1422641
1 Configuration Data Compile Time (s) Solve Time (s)
2 Base radiation/01.dzn 0.24510734984651208 0.023913082107901572
3 Base radiation/02.dzn 0.30582690900191667 0.028090783022344114
4 Base radiation/03.dzn 0.3193663267418742 0.031867857277393344
5 Base radiation/04.dzn 0.39944209847599266 0.06285300282761455
6 Base radiation/05.dzn 0.3814492827281356 0.07408921113237739
7 Base radiation/06.dzn 0.42284395741298797 0.0830705595202744
8 Base radiation/07.dzn 0.3188631976954639 0.03759916163980961
9 Base radiation/08.dzn 0.41931043174117805 0.16300638895481825
10 Base radiation/09.dzn 0.4676839098334312 0.2566952796652913
11 Incremental Rewriting radiation/01.dzn 0.01925070183351636 0.01717325309291482
12 Incremental Rewriting radiation/02.dzn 0.020097369328141212 0.014758218824863435
13 Incremental Rewriting radiation/03.dzn 0.019597070664167403 0.03506866861134768
14 Incremental Rewriting radiation/04.dzn 0.020147585589438678 0.046414986718446016
15 Incremental Rewriting radiation/05.dzn 0.020718697272241116 0.07127303797751665
16 Incremental Rewriting radiation/06.dzn 0.020426739938557148 0.0479787765070796
17 Incremental Rewriting radiation/07.dzn 0.020852961204946042 0.031166965235024692
18 Incremental Rewriting radiation/08.dzn 0.020653770212084054 0.240933208912611
19 Incremental Rewriting radiation/09.dzn 0.020874314848333596 0.23791785333305598
20 Restart Based Search radiation/01.dzn 0.0397587 0.0156963
21 Restart Based Search radiation/02.dzn 0.03960400000000001 0.012639799999999998
22 Restart Based Search radiation/03.dzn 0.039819400000000005 0.018935200000000003
23 Restart Based Search radiation/04.dzn 0.044984100000000006 0.03167359999999999
24 Restart Based Search radiation/05.dzn 0.045806799999999995 0.068683
25 Restart Based Search radiation/06.dzn 0.0460396 0.0317119
26 Restart Based Search radiation/07.dzn 0.048206399999999996 0.016760999999999998
27 Restart Based Search radiation/08.dzn 0.048394900000000005 0.1321796
28 Restart Based Search radiation/09.dzn 0.048275 0.1422641

106
pyflow.lock Normal file
View File

@ -0,0 +1,106 @@
[[package]]
id = 12
name = "six"
version = "1.16.0"
source = "pypi+https://pypi.org/pypi/six/1.16.0/json"
dependencies = []
[[package]]
id = 17
name = "scipy"
version = "1.7.0"
source = "pypi+https://pypi.org/pypi/scipy/1.7.0/json"
dependencies = []
[[package]]
id = 13
name = "pandas"
version = "1.3.0"
source = "pypi+https://pypi.org/pypi/pandas/1.3.0/json"
dependencies = ["python-dateutil 2.8.1 pypi+https://pypi.org/pypi/python-dateutil/2.8.1/json", "pytz 2018.4 pypi+https://pypi.org/pypi/pytz/2018.4/json"]
[[package]]
id = 20
name = "numpy"
version = "1.21.0"
source = "pypi+https://pypi.org/pypi/numpy/1.21.0/json"
dependencies = []
[[package]]
id = 10
name = "kiwisolver"
version = "1.3.1"
source = "pypi+https://pypi.org/pypi/kiwisolver/1.3.1/json"
dependencies = []
[[package]]
id = 7
name = "pyparsing"
version = "3.0.0b2"
source = "pypi+https://pypi.org/pypi/pyparsing/3.0.0b2/json"
dependencies = []
[[package]]
id = 2
name = "pycparser"
version = "2.20"
source = "pypi+https://pypi.org/pypi/pycparser/2.20/json"
dependencies = []
[[package]]
id = 8
name = "Pillow"
version = "8.3.1"
source = "pypi+https://pypi.org/pypi/Pillow/8.3.1/json"
dependencies = []
[[package]]
id = 15
name = "python-dateutil"
version = "2.8.1"
source = "pypi+https://pypi.org/pypi/python-dateutil/2.8.1/json"
dependencies = []
[[package]]
id = 21
name = "matplotlib"
version = "3.4.2"
source = "pypi+https://pypi.org/pypi/matplotlib/3.4.2/json"
dependencies = ["Cycler 0.10.0 pypi+https://pypi.org/pypi/Cycler/0.10.0/json", "Pillow 8.3.1 pypi+https://pypi.org/pypi/Pillow/8.3.1/json", "kiwisolver 1.3.1 pypi+https://pypi.org/pypi/kiwisolver/1.3.1/json", "pyparsing 3.0.0b2 pypi+https://pypi.org/pypi/pyparsing/3.0.0b2/json"]
[[package]]
id = 3
name = "seaborn"
version = "0.11.1"
source = "pypi+https://pypi.org/pypi/seaborn/0.11.1/json"
dependencies = ["pandas 1.3.0 pypi+https://pypi.org/pypi/pandas/1.3.0/json", "scipy 1.7.0 pypi+https://pypi.org/pypi/scipy/1.7.0/json"]
[[package]]
id = 1
name = "cffi"
version = "1.14.6"
source = "pypi+https://pypi.org/pypi/cffi/1.14.6/json"
dependencies = ["pycparser 2.20 pypi+https://pypi.org/pypi/pycparser/2.20/json"]
[[package]]
id = 14
name = "pytz"
version = "2018.4"
source = "pypi+https://pypi.org/pypi/pytz/2018.4/json"
dependencies = []
[[package]]
id = 11
name = "Cycler"
version = "0.10.0"
source = "pypi+https://pypi.org/pypi/Cycler/0.10.0/json"
dependencies = ["six 1.16.0 pypi+https://pypi.org/pypi/six/1.16.0/json"]
[[package]]
id = 15
name = "minizinc"
version = "0.4.2"
source = "pypi+https://pypi.org/pypi/minizinc/0.4.2/json"
dependencies = []
[metadata]

200
radiation.py Executable file
View File

@ -0,0 +1,200 @@
#!/usr/bin/env python3
import os
import sys
import time
import csv
import logging
logging.basicConfig(filename="minizinc-python.log", level=logging.DEBUG)
MZNR_HOME = os.getcwd() + "/software/install/minizinc/bin"
os.environ["PATH"] = MZNR_HOME + ":" + os.environ["PATH"]
os.environ["MZN_SOLVER_PATH"] = (
os.getcwd() + "/software/install/gecode/share/minizinc/solvers"
)
import minizinc
MZA_HOME = os.getcwd() + "/software/mza"
sys.path.append(MZA_HOME)
mza_lib = os.getcwd() + "/software/install/mza/lib"
if sys.platform == "linux" or sys.platform == "linux2":
rerun = True
if not "LD_LIBRARY_PATH" in os.environ:
os.environ["LD_LIBRARY_PATH"] = mza_lib
elif not mza_lib in os.environ.get("LD_LIBRARY_PATH"):
os.environ["LD_LIBRARY_PATH"] += ":" + mza_lib
else:
rerun = False
if rerun:
os.execve(os.path.realpath(__file__), sys.argv, os.environ)
import mza
from mza import Instance
mza.DEBUG = False
SOLVER = "gecode_presolver"
PROTO_MODEL = "radiation/proto.uzn"
RESTART_MODEL = "radiation/on_restart.mzn"
DATA = [
"radiation/01.dzn",
"radiation/02.dzn",
"radiation/03.dzn",
"radiation/04.dzn",
"radiation/05.dzn",
"radiation/06.dzn",
"radiation/07.dzn",
"radiation/08.dzn",
"radiation/09.dzn",
]
FN_ID = "f_lex_obj_i"
N_OBJ = 2
RUNS = 10
def radiation_restart(data_file):
os.environ["MZN_STDLIB_DIR"] = (
os.getcwd() + "/software/install/minizinc/share/minizinc"
)
gecode = minizinc.Solver.lookup("gecode")
inst = minizinc.Instance(gecode, minizinc.Model(RESTART_MODEL))
inst.add_file(data_file)
args = {
"all_solutions": True,
"--restart": "constant",
"--restart-scale": 100000000,
}
res = inst.solve(**args)
# print(res.statistics)
return (
res.statistics["flatTime"].total_seconds(),
(res.statistics["initTime"] + res.statistics["solveTime"]).total_seconds(),
)
def radiation_incr(data_file):
os.environ["MZN_STDLIB_DIR"] = os.getcwd() + "/software/mza/share/minizinc"
compile_time = 0.0
solve_time = 0.0
# --- Initial compilation of instance ---
start = time.perf_counter()
inst = Instance(PROTO_MODEL, data_file, SOLVER)
inst.output_dict(False)
compile_time += time.perf_counter() - start
# --- Solve initial instance ---
start = time.perf_counter()
(status, sol) = inst.solve()
solve_time += time.perf_counter() - start
# print(status + ": " + str(sol))
# --- Further Lexicographic Search ---
stage = 1
while stage <= N_OBJ:
with inst.branch() as child:
# --- Compile instance ---
start = time.perf_counter()
inst.add_call(FN_ID, stage)
compile_time += time.perf_counter() - start
# inst.print()
# --- Solve instance ---
start = time.perf_counter()
(status, sol) = inst.solve()
solve_time += time.perf_counter() - start
if status == "UNSAT":
stage += 1
else:
assert status == "SAT" or status == "OPT"
# print(status + ": " + str(sol))
return compile_time, solve_time
def radiation_redo(data_file):
os.environ["MZN_STDLIB_DIR"] = os.getcwd() + "/software/mza/share/minizinc"
compile_time = 0.0
solve_time = 0.0
incumbent = None
stage = 1
status = None
inst = None
while stage <= N_OBJ:
# --- Compile instance ---
start = time.perf_counter()
inst = Instance(PROTO_MODEL, data_file, SOLVER)
inst.output_dict(True)
if incumbent is not None:
inst.set_incumbent(incumbent)
inst.add_call(FN_ID, stage)
compile_time += time.perf_counter() - start
# --- Solve instance ---
start = time.perf_counter()
(status, sol) = inst.solve()
solve_time += time.perf_counter() - start
if status == "UNSAT":
stage += 1
else:
assert status == "SAT" or status == "OPT"
incumbent = sol
# print(
# status + ": [" + ", ".join([str(v) for k, v in incumbent.items()]) + "]"
# )
return compile_time, solve_time
if __name__ == "__main__":
fieldnames = ["Configuration", "Data", "Compile Time (s)", "Solve Time (s)"]
writer = csv.writer(sys.stdout)
writer.writerow(fieldnames)
for d in DATA:
# --- Run Restart based strategy
t1, t2 = 0, 0
for i in range(RUNS):
ct, st = radiation_restart(d)
t1 += ct
t2 += st
writer.writerow(["RBS", d, t1 / RUNS, t2 / RUNS])
# --- Run incremental rewriting
t1, t2 = 0, 0
for i in range(RUNS):
ct, st = radiation_incr(d)
t1 += ct
t2 += st
writer.writerow(["Incr.", d, t1 / RUNS, t2 / RUNS])
# --- Run baseline
t1, t2 = 0, 0
for i in range(RUNS):
ct, st = radiation_redo(d)
t1 += ct
t2 += st
writer.writerow(["Base", d, t1 / RUNS, t2 / RUNS])
# df = pd.DataFrame(
# data={
# "Compile Time (s)": compile_time,
# "Solve Time (s)": solve_time,
# "Data": cumulative,
# "Strategy": tag,
# }
# )
# plot = sns.scatterplot(
# data=df,
# x="Compile Time (s)",
# y="Solve Time (s)",
# hue="Strategy",
# style="Strategy",
# )
# plot.figure.savefig("output.pdf")

13
radiation/01.dzn Normal file
View File

@ -0,0 +1,13 @@
m = 5; % rows
n = 5; % columns
% max intensity = 8
Intensity = [|
6, 7, 5, 6, 3 |
4, 2, 3, 1, 2 |
0, 1, 8, 0, 6 |
7, 5, 6, 4, 5 |
3, 4, 1, 3, 0
|];

13
radiation/02.dzn Normal file
View File

@ -0,0 +1,13 @@
m = 5; % rows
n = 5; % columns
% max intensity = 8
Intensity = [|
6, 4, 5, 3, 4 |
2, 3, 0, 1, 8 |
0, 7, 5, 6, 3 |
5, 2, 3, 1, 2 |
0, 1, 8, 0, 6
|];

13
radiation/03.dzn Normal file
View File

@ -0,0 +1,13 @@
m = 5; % rows
n = 5; % columns
% max intensity = 8
Intensity = [|
2, 0, 1, 8, 0 |
7, 8, 5, 6, 4 |
5, 3, 4, 2, 3 |
1, 2, 8, 0, 7 |
8, 6, 7, 5, 6
|];

14
radiation/04.dzn Normal file
View File

@ -0,0 +1,14 @@
m = 6; % rows
n = 6; % columns
% max intensity = 8
Intensity = [|
2, 0, 1, 8, 0, 7 |
8, 6, 7, 4, 5, 3 |
4, 2, 3, 1, 2, 0 |
1, 7, 5, 6, 4, 5 |
3, 4, 1, 3, 0, 1 |
8, 0, 7, 8, 6, 7
|];

14
radiation/05.dzn Normal file
View File

@ -0,0 +1,14 @@
m = 6; % rows
n = 6; % columns
% max intensity = 8
Intensity = [|
1, 8, 0, 7, 8, 6 |
7, 4, 6, 3, 4, 2 |
3, 1, 2, 0, 1, 7 |
0, 6, 4, 5, 3, 4 |
2, 3, 0, 1, 8, 0 |
7, 8, 6, 7, 5, 6
|];

14
radiation/06.dzn Normal file
View File

@ -0,0 +1,14 @@
m = 6; % rows
n = 6; % columns
% max intensity = 8
Intensity = [|
6, 4, 5, 3, 4, 1 |
2, 0, 1, 8, 0, 7 |
8, 6, 7, 4, 5, 3 |
4, 2, 3, 1, 2, 0 |
1, 7, 8, 6, 7, 5 |
6, 4, 5, 3, 4, 1
|];

14
radiation/07.dzn Normal file
View File

@ -0,0 +1,14 @@
m = 6; % rows
n = 6; % columns
% max intensity = 9
Intensity = [|
1, 8, 9, 7, 8, 5 |
7, 4, 5, 3, 4, 1 |
3, 0, 8, 9, 6, 7 |
5, 6, 4, 5, 2, 3 |
1, 2, 0, 1, 8, 9 |
7, 8, 5, 7, 4, 5
|];

14
radiation/08.dzn Normal file
View File

@ -0,0 +1,14 @@
m = 6; % rows
n = 6; % columns
% max intensity = 9
Intensity = [|
7, 5, 6, 3, 5, 2 |
3, 1, 2, 9, 1, 8 |
6, 7, 4, 5, 3, 4 |
2, 3, 0, 1, 9, 0 |
8, 9, 7, 5, 6, 4 |
5, 2, 3, 1, 2, 0
|];

14
radiation/09.dzn Normal file
View File

@ -0,0 +1,14 @@
m = 6; % rows
n = 6; % columns
% max intensity = 9
Intensity = [|
1, 9, 6, 7, 5, 6 |
3, 5, 2, 3, 1, 2 |
9, 1, 8, 9, 7, 8 |
5, 7, 4, 5, 3, 4 |
1, 3, 0, 1, 9, 0 |
7, 9, 6, 7, 5, 6
|];

32
radiation/on_restart.mzn Normal file
View File

@ -0,0 +1,32 @@
include "radiation.mzn";
include "restart.mzn";
%-----------------------------------------------------------------------------%
% Objective
%-----------------------------------------------------------------------------%
predicate complete();% = abort("'complete' should be used in reified context");
predicate complete_reif(var bool: marker);
predicate lex_minimize(array[int] of var int: o) =
let {
var min(index_set(o))..max(index_set(o))+1: stage;
} in if status() = START then
stage = min(index_set(o))
elseif status() = UNSAT then
stage = lastval(stage) + 1
else /* status() = SAT */
stage = lastval(stage)
/\ o[stage] < sol(o[stage])
endif
/\ forall(i in min(index_set(o))..stage-1) (
o[i] = sol(o[i])
)
/\ if stage > max(index_set(o)) then
complete()
endif;
% var STATUS: status ::add_to_output = status();
constraint lex_minimize([Beamtime, K]);
solve :: int_search([Beamtime] ++ N ++ [Q[i,j,b] | i in Rows, j in Columns, b in BTimes ], input_order, indomain_split, complete) satisfy;

17
radiation/proto.mzn Normal file
View File

@ -0,0 +1,17 @@
include "radiation.mzn";
include "lex_less.mzn";
%-----------------------------------------------------------------------------%
% Objective
%-----------------------------------------------------------------------------%
predicate lex_minimize(array[int] of var int: o, int: stage) =
forall(i in min(index_set(o))..stage-1) (
o[i] = sol(o[i])
)
/\ o[stage] < sol(o[stage]);
constraint output_this([Beamtime, K]);
predicate lex_obj(int: stage) ::export = lex_minimize([Beamtime, K], stage);
solve :: int_search([Beamtime] ++ N ++ [Q[i,j,b] | i in Rows, j in Columns, b in BTimes ], input_order, indomain_min, complete) satisfy;

1113
radiation/proto.uzn Normal file

File diff suppressed because it is too large Load Diff

77
radiation/radiation.mzn Normal file
View File

@ -0,0 +1,77 @@
%-----------------------------------------------------------------------------%
% Radiation problem, MiniZinc 2.0.4 version
%
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
% Parameters
%-----------------------------------------------------------------------------%
int: m; % Rows
int: n; % Columns
set of int: Rows = 1..m;
set of int: Columns = 1..n;
% Intensity matrix
array[Rows, Columns] of int: Intensity;
set of int: BTimes = 1..Bt_max;
int: Bt_max = max(i in Rows, j in Columns) (Intensity[i,j]);
int: Ints_sum = sum(i in Rows, j in Columns) (Intensity[i,j]);
%-----------------------------------------------------------------------------%
% Variables
%-----------------------------------------------------------------------------%
% Total beam-on time
var 0..Ints_sum: Beamtime;
% Number of shape matrices
var 0..m*n: K;
% N[b] is the number of shape matrices with associated beam-on time b
array[BTimes] of var 0..m*n: N;
% Q[i,j,b] is the number of shape matrices with associated beam-on time
% b that expose cell (i,j)
array[Rows, Columns, BTimes] of var 0..m*n: Q;
%-----------------------------------------------------------------------------%
% Constraints
%-----------------------------------------------------------------------------%
% For FD/LP hybrid solving, all these should go the LP solver
% (with a suitable linearisation of the 'max' expressions).
constraint
Beamtime = sum(b in BTimes) (b * N[b])
/\
K = sum(b in BTimes) (N[b])
/\
forall(i in Rows, j in Columns)
( Intensity[i,j] = sum([b * Q[i,j,b] | b in BTimes]) )
/\
forall(i in Rows, b in BTimes)
( upper_bound_on_increments(N[b], [Q[i,j,b] | j in Columns]) );
predicate upper_bound_on_increments(var int: N_b, array[int] of var int: L) =
N_b >= L[1] + sum([ max(L[j] - L[j-1], 0) | j in 2..n ]);
%
% Good linear version:
% let { array[min(index_set(L))..max(index_set(L))] of var int: S } in
% N_b >= L[1] + sum([ S[j] | j in 2..n ]) /\
% forall([ S[j] >= L[j] - L[j-1] /\ S[j] >= 0 | j in 2..n ]);
%-----------------------------------------------------------------------------%
output [
"Beamtime = \(Beamtime);\n",
"K = \(K);\n",
"N = \(N);\n",
"Q = array3d(\(Rows), \(Columns), \(BTimes), \(Q));\n"
];
%-----------------------------------------------------------------------------%

35
scatterplot.py Normal file
View File

@ -0,0 +1,35 @@
#!/usr/bin/env python3
import sys
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
import matplotlib as mpl
if __name__ == "__main__":
data = pd.read_csv(sys.argv[1])
sns.set(font_scale=1.24, style="whitegrid", font="IBM Plex Sans")
fig, ax = plt.subplots()
plot = sns.scatterplot(
data=data,
x="Compile Time (s)",
y="Solve Time (s)",
hue="Configuration",
style="Configuration",
legend="gbac" in sys.argv[1],
)
if "radiation" in sys.argv[1]:
ax.set_xlim(0, 0.5)
ax.set_ylim(0, 0.5)
elif "gbac" in sys.argv[1]:
handles, labels = ax.get_legend_handles_labels()
ax.legend(handles=handles, labels=labels)
plot.legend(bbox_to_anchor=(0.23, 0.95), loc="upper left", borderaxespad=0)
ax.set_xlim(0, 30)
ax.set_ylim(0, 30)
plot.figure.savefig("output.pdf", bbox_inches="tight")