mirror of
https://github.com/ANL-CEEESA/MIPLearn.git
synced 2025-12-06 01:18:52 -06:00
Update benchmark scripts
This commit is contained in:
@@ -12,7 +12,7 @@ main: $(addsuffix /performance.png, $(CHALLENGES))
|
||||
%/train_instances.bin:
|
||||
python benchmark.py train $*
|
||||
|
||||
%/benchmark_baseline.csv: %/training_data.bin
|
||||
%/benchmark_baseline.csv: %/train_instances.bin
|
||||
python benchmark.py test-baseline $*
|
||||
|
||||
%/benchmark_ml.csv: %/benchmark_baseline.csv
|
||||
|
||||
@@ -16,11 +16,7 @@ Options:
|
||||
"""
|
||||
from docopt import docopt
|
||||
import importlib, pathlib
|
||||
from miplearn import (LearningSolver,
|
||||
BenchmarkRunner,
|
||||
WarmStartComponent,
|
||||
BranchPriorityComponent,
|
||||
)
|
||||
from miplearn import (LearningSolver, BenchmarkRunner)
|
||||
from numpy import median
|
||||
import pyomo.environ as pe
|
||||
import pickle
|
||||
@@ -29,7 +25,7 @@ import logging
|
||||
logging.getLogger('pyomo.core').setLevel(logging.ERROR)
|
||||
|
||||
n_jobs = 10
|
||||
time_limit = 300
|
||||
time_limit = 900
|
||||
internal_solver = "gurobi"
|
||||
|
||||
args = docopt(__doc__)
|
||||
@@ -65,32 +61,33 @@ def train():
|
||||
|
||||
|
||||
def test_baseline():
|
||||
test_instances = load("%s/test_instances.bin" % basepath)
|
||||
solvers = {
|
||||
"baseline": LearningSolver(
|
||||
time_limit=time_limit,
|
||||
components={},
|
||||
),
|
||||
}
|
||||
test_instances = load("%s/test_instances.bin" % basepath)
|
||||
benchmark = BenchmarkRunner(solvers)
|
||||
benchmark.parallel_solve(test_instances, n_jobs=n_jobs)
|
||||
benchmark.save_results("%s/benchmark_baseline.csv" % basepath)
|
||||
|
||||
|
||||
def test_ml():
|
||||
train_instances = load("%s/train_instances.bin" % basepath)
|
||||
test_instances = load("%s/test_instances.bin" % basepath)
|
||||
solvers = {
|
||||
"ml-exact": LearningSolver(
|
||||
time_limit=time_limit,
|
||||
time_limit=time_limit,
|
||||
),
|
||||
"ml-heuristic": LearningSolver(
|
||||
time_limit=time_limit,
|
||||
mode="heuristic",
|
||||
),
|
||||
}
|
||||
test_instances = load("%s/test_instances.bin" % basepath)
|
||||
benchmark = BenchmarkRunner(solvers)
|
||||
benchmark.load_state("%s/training_data.bin" % basepath)
|
||||
benchmark.load_results("%s/benchmark_baseline.csv" % basepath)
|
||||
benchmark.fit(train_instances)
|
||||
benchmark.parallel_solve(test_instances, n_jobs=n_jobs)
|
||||
benchmark.save_results("%s/benchmark_ml.csv" % basepath)
|
||||
|
||||
@@ -155,9 +152,9 @@ def charts():
|
||||
if __name__ == "__main__":
|
||||
if args["train"]:
|
||||
train()
|
||||
#if args["test-baseline"]:
|
||||
# test_baseline()
|
||||
#if args["test-ml"]:
|
||||
# test_ml()
|
||||
#if args["charts"]:
|
||||
# charts()
|
||||
if args["test-baseline"]:
|
||||
test_baseline()
|
||||
if args["test-ml"]:
|
||||
test_ml()
|
||||
if args["charts"]:
|
||||
charts()
|
||||
|
||||
Reference in New Issue
Block a user