Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Predefined blmo #155

Merged
merged 15 commits into from
Nov 3, 2023
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
dhendryc marked this conversation as resolved.
Show resolved Hide resolved
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
Loading