From 837165575f0202a1723f51690a42b9bd3fc472e5 Mon Sep 17 00:00:00 2001 From: Alinson S Xavier Date: Wed, 28 Jul 2021 08:26:47 -0500 Subject: [PATCH] Make package compatible with miplearn:dev --- src/MIPLearn.jl | 4 ++++ src/instance/file.jl | 4 ++-- src/instance/jump.jl | 8 +++++--- src/solvers/jump.jl | 4 ++-- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/MIPLearn.jl b/src/MIPLearn.jl index 1fc4694..2d00658 100644 --- a/src/MIPLearn.jl +++ b/src/MIPLearn.jl @@ -17,6 +17,8 @@ global PyJuMPInstance = PyNULL() global StaticLazyConstraintsComponent = PyNULL() global traceback = PyNULL() global UserCutsComponent = PyNULL() +global MemorySample = PyNULL() +global Hdf5Sample = PyNULL() include("utils/log.jl") include("utils/exceptions.jl") @@ -37,6 +39,8 @@ function __init__() copy!(PrimalSolutionComponent, miplearn.PrimalSolutionComponent) copy!(StaticLazyConstraintsComponent, miplearn.StaticLazyConstraintsComponent) copy!(MinPrecisionThreshold, miplearn.MinPrecisionThreshold) + copy!(MemorySample, miplearn.features.sample.MemorySample) + copy!(Hdf5Sample, miplearn.features.sample.Hdf5Sample) __init_PyFileInstance__() __init_PyJuMPInstance__() __init_JuMPSolver__() diff --git a/src/instance/file.jl b/src/instance/file.jl index 0a1fb32..f608454 100644 --- a/src/instance/file.jl +++ b/src/instance/file.jl @@ -22,7 +22,7 @@ get_variable_features(instance::FileInstance) = get_variable_features(instance.l get_variable_categories(instance::FileInstance) = get_variable_categories(instance.loaded) get_constraint_features(instance::FileInstance) = get_constraint_features(instance.loaded) get_samples(instance::FileInstance) = get_samples(instance.loaded) -push_sample!(instance::FileInstance, sample::PyCall.PyObject) = push_sample!(instance.loaded, sample) +create_sample!(instance::FileInstance) = create_sample!(instance.loaded) function get_constraint_categories(instance::FileInstance) return get_constraint_categories(instance.loaded) @@ -56,7 +56,7 @@ function __init_PyFileInstance__() get_constraint_features(self) = get_constraint_features(self.jl) get_constraint_categories(self) = get_constraint_categories(self.jl) get_samples(self) = get_samples(self.jl) - push_sample(self, sample) = push_sample!(self.jl, sample) + create_sample(self) = create_sample!(self.jl) load(self) = load(self.jl) free(self) = free(self.jl) flush(self) = flush(self.jl) diff --git a/src/instance/jump.jl b/src/instance/jump.jl index 74d0ba5..0ecf055 100644 --- a/src/instance/jump.jl +++ b/src/instance/jump.jl @@ -45,8 +45,10 @@ get_constraint_features(instance::JuMPInstance) = instance.ext["constraint_featu get_constraint_categories(instance::JuMPInstance) = instance.ext["constraint_categories"] get_samples(instance::JuMPInstance) = instance.samples -function push_sample!(instance::JuMPInstance, sample::PyCall.PyObject) +function create_sample!(instance::JuMPInstance) + sample = MemorySample() push!(instance.samples, sample) + return sample end function __init_PyJuMPInstance__() @@ -61,7 +63,7 @@ function __init_PyJuMPInstance__() get_constraint_features(self,) = get_constraint_features(self.jl) get_constraint_categories(self) = get_constraint_categories(self.jl) get_samples(self) = get_samples(self.jl) - push_sample(self, sample) = push_sample!(self.jl, sample) + create_sample(self) = create_sample!(self.jl) end copy!(PyJuMPInstance, Class) end @@ -106,7 +108,7 @@ function load_instance(filename::AbstractString)::JuMPInstance instance = JuMPInstance(file["mps"], file["ext"]) samples_filename = tempname() write(samples_filename, file["samples"]) - @time instance.samples = miplearn.read_pickle_gz(samples_filename) + instance.samples = miplearn.read_pickle_gz(samples_filename) return instance end end diff --git a/src/solvers/jump.jl b/src/solvers/jump.jl index 83f1726..9fade0a 100644 --- a/src/solvers/jump.jl +++ b/src/solvers/jump.jl @@ -375,7 +375,7 @@ function get_variables( rc = isempty(data.reduced_costs) ? nothing : data.reduced_costs - vf = miplearn.features.VariableFeatures( + vf = miplearn.solvers.internal.Variables( names=names, lower_bounds=lb, upper_bounds=ub, @@ -463,7 +463,7 @@ function get_constraints( end end - return miplearn.features.ConstraintFeatures( + return miplearn.solvers.internal.Constraints( names=names, senses=senses, lhs=lhs,