Skip to content

Commit

Permalink
minor fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hendrych committed Oct 24, 2023
1 parent 4629716 commit 39d85d4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions examples/approx_planted_point.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ diffi = Random.rand(Bool, n) * 0.6 .+ 0.3
end

@testset "Using Cube LMO" begin
int_vars = []
bin_vars = collect(1:n)
int_vars = collect(1:n)
bin_vars = []

bounds = Boscia.IntegerBounds()
for i in 1:n
Expand Down
15 changes: 8 additions & 7 deletions src/MOI_bounded_oracle.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ function get_binary_variables(blmo::MathOptBLMO)
return MOI.get(blmo.o, MOI.ListOfConstraintIndices{MOI.VariableIndex,MOI.ZeroOne}())
end
function Boscia.get_integer_variables(blmo::MathOptBLMO)
return MOI.get(blmo.o, MOI.ListOfConstraintIndices{MOI.VariableIndex,MOI.Integer}())
bin_var = get_binary_variables(blmo)
return vcat(MOI.get(blmo.o, MOI.ListOfConstraintIndices{MOI.VariableIndex,MOI.Integer}()), bin_var)
end

"""
Expand Down Expand Up @@ -217,17 +218,17 @@ function explicit_bounds_binary_var(blmo::MathOptBLMO, global_bounds::Boscia.Int
# adding binary bounds explicitly
binary_variables = get_binary_variables(blmo)
for idx in binary_variables
cidx = MOI.ConstraintIndex{MOI.VariableIndex,MOI.LessThan{Float64}}(idx)
cidx = MOI.ConstraintIndex{MOI.VariableIndex,MOI.LessThan{Float64}}(idx.value)
if !MOI.is_valid(blmo.o, cidx)
MOI.add_constraint(blmo.o, MOI.VariableIndex(idx), MOI.LessThan(1.0))
MOI.add_constraint(blmo.o, MOI.VariableIndex(idx.value), MOI.LessThan(1.0))
end
@assert MOI.is_valid(blmo.o, cidx)
cidx = MOI.ConstraintIndex{MOI.VariableIndex,MOI.GreaterThan{Float64}}(idx)
cidx = MOI.ConstraintIndex{MOI.VariableIndex,MOI.GreaterThan{Float64}}(idx.value)
if !MOI.is_valid(blmo.o, cidx)
MOI.add_constraint(blmo.o, MOI.VariableIndex(idx), MOI.GreaterThan(0.0))
MOI.add_constraint(blmo.o, MOI.VariableIndex(idx.value), MOI.GreaterThan(0.0))
end
global_bounds[idx, :greaterthan] = 0.0
global_bounds[idx, :lessthan] = 1.0
global_bounds[idx.value, :greaterthan] = 0.0
global_bounds[idx.value, :lessthan] = 1.0
end
end

Expand Down

0 comments on commit 39d85d4

Please sign in to comment.