Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
LebedevRI committed Jun 27, 2024
1 parent e7c72c4 commit ba1fb0b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
8 changes: 0 additions & 8 deletions examples/MINLPs/milp.jl

This file was deleted.

6 changes: 3 additions & 3 deletions src/MOI_wrapper/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ mutable struct Optimizer <: MOI.AbstractOptimizer
bound_sol_pool::Dict{Any,Any} # A pool of solutions from solving model_mip

# Linking constraints info for Multilinear terms
linking_constraints_info::Union{Nothing,Dict{Any,Any}} # Stored multilinear linking constraints info
linking_constraints_info::Union{Nothing,Dict{Any,Any}} # Stored multilinear linking constraints info

# Logging information and status
logs::Dict{Symbol,Any} # Logging information
Expand Down Expand Up @@ -449,7 +449,7 @@ function _get_bound_set(model::Alpine.Optimizer, vi::MOI.VariableIndex)
if !MOI.is_valid(model, vi)
throw(MOI.InvalidIndex(vi))
end
return _bound_set(model.l_var[vi.value], model.u_var[vi.value])
return _bound_set(model.l_var_orig[vi.value], model.u_var_orig[vi.value])
end

function MOI.is_valid(model::Alpine.Optimizer, ci::MOI.ConstraintIndex{MOI.VariableIndex,S}) where {S<:SCALAR_SET}
Expand All @@ -458,7 +458,7 @@ function MOI.is_valid(model::Alpine.Optimizer, ci::MOI.ConstraintIndex{MOI.Varia
end

function MOI.get(model::Alpine.Optimizer, ::MOI.ConstraintSet, ci::MOI.ConstraintIndex{MOI.VariableIndex,S}) where {S<:SCALAR_SET}
if !MOI.is_valid(o, ci)
if !MOI.is_valid(model, ci)
throw(MOI.InvalidIndex(ci))
end
return _get_bound_set(model, MOI.VariableIndex(ci.value))
Expand Down
26 changes: 24 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,33 @@ end
"mip_solver" => HIGHS,
"minlp_solver" => JUNIPER,
)
m = milp(solver = test_solver)

m = JuMP.Model(test_solver)

@variable(m, -10 <= objvar0 <= 20, Int)

#=
@variable(m, objvar1 >= -11, Int)
@constraint(m, objvar1 <= -21)
@variable(m, objvar2 <= 21, Int)
@constraint(m, objvar2 >= -12)
@variable(m, objvar3, Int)
@constraint(m, objvar3 >= -13)
@constraint(m, objvar3 <= -23)
@variable(m, objvar4, Int)
@constraint(m, objvar4 in MOI.Interval(-24, 14))
=#

@objective(m, Min, objvar0 + objvar1)

JuMP.optimize!(m)

@test termination_status(m) == MOI.OPTIMAL
@test isapprox(objective_value(m), 0; atol = 1e-4)
@test isapprox(objective_value(m), -10; atol = 1e-4)
@test isapprox(value(objvar0), -10, atol = 1E-6)
@test MOI.get(m, Alpine.NumberOfIterations()) == 0
end
# include(joinpath(@__DIR__, "test_solver.jl"))
Expand Down

0 comments on commit ba1fb0b

Please sign in to comment.