Skip to content

Commit 48efeae

Browse files
committed
Several changes
1. Added bench_gurobi.sh script to coordinate benchmark computations comparing coek to gurobi 2. Reworked test scripts to work from the _build directory 3. Misc improvements to debugging I/O
1 parent c75fd1a commit 48efeae

File tree

4 files changed

+48
-12
lines changed

4 files changed

+48
-12
lines changed

Diff for: test/aml_comparisons/coek/solve0.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ int main(int argc, char* argv[])
6161
solver.set_option("TimeLimit", 0.0);
6262

6363
auto res = solver.solve(model);
64-
if (not check_optimal_termination(res)) {
64+
if (res->termination_condition != coek::TerminationCondition::time_limit) {
6565
std::cout << "ERROR - failed to execute solver '" << solver_name << "'" << std::endl;
6666
std::cout << "MESSAGE - " << res->error_message << std::endl;
6767
return 2;
@@ -76,7 +76,7 @@ int main(int argc, char* argv[])
7676
solver.set_option("print_level", 1);
7777

7878
auto res = solver.solve(Model);
79-
if (not check_optimal_termination(res)) {
79+
if (res->termination_condition != coek::TerminationCondition::time_limit) {
8080
std::cout << "ERROR - failed to execute solver '" << solver_name << "'" << std::endl;
8181
std::cout << "MESSAGE - " << res->error_message << std::endl;
8282
return 2;

Diff for: test/aml_comparisons/scripts/bench_gurobi.sh

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
#
3+
# Benchmark comparison
4+
#
5+
# This script should be run from the top-level _build directory
6+
#
7+
8+
if [[ -d /coek_performance_results ]]; then
9+
echo $CI_COMMIT_SHA
10+
echo $CI_COMMIT_TITLE
11+
fi
12+
13+
\rm -Rf results
14+
../test/aml_comparisons/scripts/run bench_coek 3
15+
../test/aml_comparisons/scripts/collect
16+
../test/aml_comparisons/scripts/dog solve0
17+
../test/aml_comparisons/scripts/dog writer
18+
19+
if [[ -d /coek_performance_results ]]; then
20+
CI_COMMIT_TITLE_MOD="${CI_COMMIT_TITLE// /_}"
21+
python ../test/aml_comparisons/scripts/to_csv.py --dirname /coek_performance_results/${BRANCH_NAME} --branch_name ${BRANCH_NAME} --ci_commit_sha ${CI_COMMIT_SHA} --ci_commit_title ${CI_COMMIT_TITLE_MOD}
22+
python ../test/aml_comparisons/scripts/compare.py --artifact_dir=/coek_performance_results --branch_name=${BRANCH_NAME}
23+
fi
24+

Diff for: test/aml_comparisons/scripts/dog

+3
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,9 @@ def collect_data(directory):
398398
collect_solve0_summary(directory)
399399

400400
if __name__ == "__main__":
401+
print("")
402+
print("DOG", " ".join(sys.argv))
403+
print("")
401404
directory = "results"
402405

403406
parser = argparse.ArgumentParser()

Diff for: test/aml_comparisons/scripts/run

+19-10
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def test_writer(
124124
if not os.path.exists("results/writer/" + subdir):
125125
os.mkdir("results/writer/" + subdir)
126126

127+
print("")
127128
print("")
128129
print("TESTING ARGUMENTS")
129130
print(" test_type: " + test_type)
@@ -133,7 +134,6 @@ def test_writer(
133134
print(" subdir: " + subdir)
134135
print(" timeout: " + str(timeout))
135136
print(" ntrials: " + str(ntrials))
136-
print("")
137137

138138
for model in models:
139139
config_name = None
@@ -208,8 +208,8 @@ def test_writer(
208208
)
209209
else:
210210
print(
211-
". ERROR {}: rc={} output='{}'".format(
212-
timefile, p.returncode, results
211+
". ERROR (test_writer) {}:\n\tcmd={} rc={} output='{}'".format(
212+
timefile, " ".join(run), p.returncode, results
213213
)
214214
)
215215
if os.path.exists(timefile):
@@ -218,7 +218,7 @@ def test_writer(
218218
except subprocess.TimeoutExpired:
219219
os.killpg(os.getpgid(p.pid), signal.SIGTERM)
220220
errors.append(timefile)
221-
print(". TIMEOUT {} cmd={}".format(timefile, " ".join(run)))
221+
print(". TIMEOUT (test_writer) {} cmd={}".format(timefile, " ".join(run)))
222222
with open(timefile, "w") as OUTPUT:
223223
OUTPUT.write("timeout {}".format(timeout))
224224

@@ -241,6 +241,7 @@ def test_solve0(
241241
if not os.path.exists("results/solve0/" + subdir):
242242
os.mkdir("results/solve0/" + subdir)
243243

244+
print("")
244245
print("")
245246
print("TESTING ARGUMENTS")
246247
print(" test_type: " + test_type)
@@ -250,7 +251,6 @@ def test_solve0(
250251
print(" subdir: " + subdir)
251252
print(" timeout: " + str(timeout))
252253
print(" ntrials: " + str(ntrials))
253-
print("")
254254

255255
for model in models:
256256
config_name = None
@@ -313,14 +313,14 @@ def test_solve0(
313313
if p.returncode == 0:
314314
print(". OK {}: rc={}".format(timefile, p.returncode))
315315
else:
316-
print(". ERROR {}: rc={}".format(timefile, p.returncode))
316+
print(". ERROR (test_solve0) {}:\n\tcmd={} rc={}".format(timefile, " ".join(run), p.returncode))
317317
if os.path.exists(timefile):
318318
os.remove(timefile)
319319
errors.append(timefile)
320320
except subprocess.TimeoutExpired:
321321
os.killpg(os.getpgid(p.pid), signal.SIGTERM)
322322
errors.append(timefile)
323-
print(". TIMEOUT {} cmd={}".format(timefile, " ".join(run)))
323+
print(". TIMEOUT (test_solve0) {} cmd={}".format(timefile, " ".join(run)))
324324
with open(timefile, "w") as OUTPUT:
325325
OUTPUT.write("timeout {}".format(timeout))
326326

@@ -341,14 +341,14 @@ if __name__ == "__main__":
341341
if os.path.exists("coek/coek_writer"):
342342
build_dir = "."
343343
elif os.path.exists(
344-
os.path.join(currdir, "../../../build/test/aml_comparisons/coek/coek_writer")
344+
os.path.join(currdir, "../../../_build/test/aml_comparisons/coek/coek_writer")
345345
):
346-
build_dir = os.path.join(currdir, "../../../build")
346+
build_dir = os.path.join(currdir, "../../../_build")
347347
if build_dir is None:
348348
print("Cannot find Coek build directory")
349349
print(
350350
os.path.join(
351-
currdir, "../../../build/test/aml_comparisons/coek/coek_writer"
351+
currdir, "../../../_build/test/aml_comparisons/coek/coek_writer"
352352
)
353353
)
354354
sys.exit(1)
@@ -366,6 +366,15 @@ if __name__ == "__main__":
366366
ntrials=ntrials,
367367
errors=errors,
368368
)
369+
test_solve0(
370+
test_type="small",
371+
models=all_gurobi_models,
372+
solvers=["gurobi"],
373+
executable=os.path.join(build_dir, "test/aml_comparisons/gurobi/gurobi_solve0"),
374+
subdir="gurobi",
375+
ntrials=ntrials,
376+
errors=errors,
377+
)
369378

370379
elif sys.argv[1] == "bench_coek":
371380
test_solve0(

0 commit comments

Comments
 (0)