mirror of
https://github.com/ANL-CEEESA/MIPLearn.jl.git
synced 2025-12-06 00:18:51 -06:00
Make compatible with write_mps; fix lazy_enforce
This commit is contained in:
@@ -372,6 +372,13 @@ function _set_warm_starts(model::JuMP.Model, var_names, var_values, stats)
|
||||
end
|
||||
|
||||
function _write(model::JuMP.Model, filename)
|
||||
ext = model.ext[:miplearn]
|
||||
if ext.lazy_separate !== nothing
|
||||
set_attribute(model, MOI.LazyConstraintCallback(), nothing)
|
||||
end
|
||||
if ext.cuts_separate !== nothing
|
||||
set_attribute(model, MOI.UserCutCallback(), nothing)
|
||||
end
|
||||
write_to_file(model, filename)
|
||||
end
|
||||
|
||||
@@ -439,6 +446,13 @@ function __init_solvers_jump__()
|
||||
function lazy_enforce(self, model, violations)
|
||||
self.inner.ext[:miplearn].lazy_enforce(violations)
|
||||
end
|
||||
|
||||
function _lazy_enforce_collected(self)
|
||||
ext = self.inner.ext[:miplearn]
|
||||
if ext.lazy_enforce !== nothing
|
||||
ext.lazy_enforce(ext.lazy)
|
||||
end
|
||||
end
|
||||
end
|
||||
copy!(JumpModel, Class)
|
||||
end
|
||||
|
||||
@@ -17,7 +17,7 @@ function gen_stab()
|
||||
)
|
||||
data = gen.generate(1)
|
||||
data_filenames = write_pkl_gz(data, "$BASEDIR/../fixtures", prefix="stab-n50-")
|
||||
collector = BasicCollector(write_mps=false)
|
||||
collector = BasicCollector()
|
||||
collector.collect(
|
||||
data_filenames,
|
||||
data -> build_stab_model_jump(data, optimizer=SCIP.Optimizer),
|
||||
|
||||
@@ -20,7 +20,7 @@ function gen_tsp()
|
||||
)
|
||||
data = gen.generate(1)
|
||||
data_filenames = write_pkl_gz(data, "$BASEDIR/../fixtures", prefix="tsp-n20-")
|
||||
collector = BasicCollector(write_mps=false)
|
||||
collector = BasicCollector()
|
||||
collector.collect(
|
||||
data_filenames,
|
||||
data -> build_tsp_model_jump(data, optimizer=GLPK.Optimizer),
|
||||
|
||||
@@ -28,7 +28,7 @@ function test_usage()
|
||||
)
|
||||
|
||||
@debug "Collecting training data..."
|
||||
bc = BasicCollector(write_mps=false)
|
||||
bc = BasicCollector()
|
||||
bc.collect(data_filenames, build_setcover_model_jump)
|
||||
|
||||
@debug "Training models..."
|
||||
|
||||
Reference in New Issue
Block a user