mirror of
https://github.com/ANL-CEEESA/MIPLearn.jl.git
synced 2025-12-06 00:18:51 -06:00
Make package compatible with miplearn:dev
This commit is contained in:
@@ -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__()
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user