Skip to content

Commit

Permalink
Bug Fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hendrych committed Nov 2, 2023
1 parent 5ba2369 commit cec1b41
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
5 changes: 3 additions & 2 deletions examples/approx_planted_point.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Boscia
using FrankWolfe
using Bonobo
using Test
using Random
using SCIP
Expand Down Expand Up @@ -49,7 +50,7 @@ diffi = Random.rand(Bool, n) * 0.6 .+ 0.3
push!(bounds, (i, 0.0), :greaterthan)
push!(bounds, (i, 1.0), :lessthan)
end
blmo = Boscia.CubeBLMO(n, int_vars, bounds)
blmo = CubeBLMO(n, int_vars, bounds)

x, _, result = Boscia.solve(f, grad!, blmo, verbose=true)

Expand Down Expand Up @@ -112,7 +113,7 @@ end
push!(bounds, (i, 0.0), :greaterthan)
push!(bounds, (i, 1.0), :lessthan)
end
blmo = Boscia.CubeBLMO(n, int_vars, bounds)
blmo = CubeBLMO(n, int_vars, bounds)

x, _, result = Boscia.solve(f, grad!, blmo, verbose=true)

Expand Down
13 changes: 8 additions & 5 deletions examples/cube_blmo.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
## How to implement the BLMO Interface using the cube as an example
using Boscia
using Bonobo
using Dates

"""
CubeBLMO
Expand All @@ -8,7 +11,7 @@ A Bounded Linear Minimization Oracle over a cube.
mutable struct CubeBLMO <: Boscia.BoundedLinearMinimizationOracle
n::Int
int_vars::Vector{Int}
bounds::IntegerBounds
bounds::Boscia.IntegerBounds
solving_time::Float64
end

Expand All @@ -30,7 +33,7 @@ end
##

function Boscia.build_global_bounds(blmo::CubeBLMO, integer_variables)
global_bounds = IntegerBounds()
global_bounds = Boscia.IntegerBounds()
for i in 1:blmo.n
if i in integer_variables
push!(global_bounds, (i, blmo.bounds[i, :lessthan]), :lessthan)
Expand Down Expand Up @@ -143,13 +146,13 @@ end
function Boscia.check_feasibility(blmo::CubeBLMO)
for i in 1:blmo.n
if !haskey(blmo.bounds, (i, :greaterthan)) || !haskey(blmo.bounds, (i, :lessthan))
return UNBOUNDED
return Boscia.UNBOUNDED
end
if blmo.bounds[i, :greaterthan] > blmo.bounds[i, :lessthan]
return INFEASIBLE
return Boscia.INFEASIBLE
end
end
return OPTIMAL
return Boscia.OPTIMAL
end

function Boscia.is_valid_split(tree::Bonobo.BnBTree, blmo::CubeBLMO, vidx::Int)
Expand Down

0 comments on commit cec1b41

Please sign in to comment.