mirror of
https://github.com/ANL-CEEESA/MIPLearn.jl.git
synced 2025-12-06 08:28:52 -06:00
Make package compatible with miplearn:dev
This commit is contained in:
@@ -17,6 +17,8 @@ global PyJuMPInstance = PyNULL()
|
|||||||
global StaticLazyConstraintsComponent = PyNULL()
|
global StaticLazyConstraintsComponent = PyNULL()
|
||||||
global traceback = PyNULL()
|
global traceback = PyNULL()
|
||||||
global UserCutsComponent = PyNULL()
|
global UserCutsComponent = PyNULL()
|
||||||
|
global MemorySample = PyNULL()
|
||||||
|
global Hdf5Sample = PyNULL()
|
||||||
|
|
||||||
include("utils/log.jl")
|
include("utils/log.jl")
|
||||||
include("utils/exceptions.jl")
|
include("utils/exceptions.jl")
|
||||||
@@ -37,6 +39,8 @@ function __init__()
|
|||||||
copy!(PrimalSolutionComponent, miplearn.PrimalSolutionComponent)
|
copy!(PrimalSolutionComponent, miplearn.PrimalSolutionComponent)
|
||||||
copy!(StaticLazyConstraintsComponent, miplearn.StaticLazyConstraintsComponent)
|
copy!(StaticLazyConstraintsComponent, miplearn.StaticLazyConstraintsComponent)
|
||||||
copy!(MinPrecisionThreshold, miplearn.MinPrecisionThreshold)
|
copy!(MinPrecisionThreshold, miplearn.MinPrecisionThreshold)
|
||||||
|
copy!(MemorySample, miplearn.features.sample.MemorySample)
|
||||||
|
copy!(Hdf5Sample, miplearn.features.sample.Hdf5Sample)
|
||||||
__init_PyFileInstance__()
|
__init_PyFileInstance__()
|
||||||
__init_PyJuMPInstance__()
|
__init_PyJuMPInstance__()
|
||||||
__init_JuMPSolver__()
|
__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_variable_categories(instance::FileInstance) = get_variable_categories(instance.loaded)
|
||||||
get_constraint_features(instance::FileInstance) = get_constraint_features(instance.loaded)
|
get_constraint_features(instance::FileInstance) = get_constraint_features(instance.loaded)
|
||||||
get_samples(instance::FileInstance) = get_samples(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)
|
function get_constraint_categories(instance::FileInstance)
|
||||||
return get_constraint_categories(instance.loaded)
|
return get_constraint_categories(instance.loaded)
|
||||||
@@ -56,7 +56,7 @@ function __init_PyFileInstance__()
|
|||||||
get_constraint_features(self) = get_constraint_features(self.jl)
|
get_constraint_features(self) = get_constraint_features(self.jl)
|
||||||
get_constraint_categories(self) = get_constraint_categories(self.jl)
|
get_constraint_categories(self) = get_constraint_categories(self.jl)
|
||||||
get_samples(self) = get_samples(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)
|
load(self) = load(self.jl)
|
||||||
free(self) = free(self.jl)
|
free(self) = free(self.jl)
|
||||||
flush(self) = flush(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_constraint_categories(instance::JuMPInstance) = instance.ext["constraint_categories"]
|
||||||
get_samples(instance::JuMPInstance) = instance.samples
|
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)
|
push!(instance.samples, sample)
|
||||||
|
return sample
|
||||||
end
|
end
|
||||||
|
|
||||||
function __init_PyJuMPInstance__()
|
function __init_PyJuMPInstance__()
|
||||||
@@ -61,7 +63,7 @@ function __init_PyJuMPInstance__()
|
|||||||
get_constraint_features(self,) = get_constraint_features(self.jl)
|
get_constraint_features(self,) = get_constraint_features(self.jl)
|
||||||
get_constraint_categories(self) = get_constraint_categories(self.jl)
|
get_constraint_categories(self) = get_constraint_categories(self.jl)
|
||||||
get_samples(self) = get_samples(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
|
end
|
||||||
copy!(PyJuMPInstance, Class)
|
copy!(PyJuMPInstance, Class)
|
||||||
end
|
end
|
||||||
@@ -106,7 +108,7 @@ function load_instance(filename::AbstractString)::JuMPInstance
|
|||||||
instance = JuMPInstance(file["mps"], file["ext"])
|
instance = JuMPInstance(file["mps"], file["ext"])
|
||||||
samples_filename = tempname()
|
samples_filename = tempname()
|
||||||
write(samples_filename, file["samples"])
|
write(samples_filename, file["samples"])
|
||||||
@time instance.samples = miplearn.read_pickle_gz(samples_filename)
|
instance.samples = miplearn.read_pickle_gz(samples_filename)
|
||||||
return instance
|
return instance
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -375,7 +375,7 @@ function get_variables(
|
|||||||
|
|
||||||
rc = isempty(data.reduced_costs) ? nothing : data.reduced_costs
|
rc = isempty(data.reduced_costs) ? nothing : data.reduced_costs
|
||||||
|
|
||||||
vf = miplearn.features.VariableFeatures(
|
vf = miplearn.solvers.internal.Variables(
|
||||||
names=names,
|
names=names,
|
||||||
lower_bounds=lb,
|
lower_bounds=lb,
|
||||||
upper_bounds=ub,
|
upper_bounds=ub,
|
||||||
@@ -463,7 +463,7 @@ function get_constraints(
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return miplearn.features.ConstraintFeatures(
|
return miplearn.solvers.internal.Constraints(
|
||||||
names=names,
|
names=names,
|
||||||
senses=senses,
|
senses=senses,
|
||||||
lhs=lhs,
|
lhs=lhs,
|
||||||
|
|||||||
Reference in New Issue
Block a user