diff --git a/examples/approx_planted_point.jl b/examples/approx_planted_point.jl index 2ccbc824a..fb0ae08e9 100644 --- a/examples/approx_planted_point.jl +++ b/examples/approx_planted_point.jl @@ -60,7 +60,7 @@ diffi = Random.rand(Bool, n) * 0.6 .+ 0.3 lbs = zeros(n) ubs = ones(n) - sblmo = Boscia.CubeSimBLMO(lbs, ubs) + sblmo = Boscia.CubeSimpleBLMO(lbs, ubs) x, _, result = Boscia.solve(f, grad!, sblmo, lbs[int_vars], ubs[int_vars], int_vars, n, verbose =true) @@ -123,7 +123,7 @@ end lbs = zeros(n) ubs = ones(n) - sblmo = Boscia.CubeSimBLMO(lbs, ubs) + sblmo = Boscia.CubeSimpleBLMO(lbs, ubs) x, _, result = Boscia.solve(f, grad!, sblmo, lbs[int_vars], ubs[int_vars], int_vars, n, verbose =true) diff --git a/src/cube_blmo.jl b/src/cube_blmo.jl index 580169dc8..8ab14116c 100644 --- a/src/cube_blmo.jl +++ b/src/cube_blmo.jl @@ -164,14 +164,16 @@ end ######################################################################## """ - Cube SimpleBoundableLMO + CubeSimpleBLMO{T}(lower_bounds, upper_bounds) + +Hypercube with lower and upper bounds implementing the SimpleBoundableLMO interface """ -mutable struct CubeSimBLMO <: SimpleBoundableLMO - lower_bounds::Vector{Float64} - upper_bounds::Vector{Float64} +mutable struct CubeSimpleBLMO{T} <: SimpleBoundableLMO + lower_bounds::Vector{T} + upper_bounds::Vector{T} end -function bounded_compute_extreme_point(sblmo::CubeSimBLMO, d, lb, ub, int_vars; kwargs...) +function bounded_compute_extreme_point(sblmo::CubeSimpleBLMO, d, lb, ub, int_vars; kwargs...) v = zeros(length(d)) sblmo.lower_bounds[int_vars] = lb sblmo.upper_bounds[int_vars] = ub @@ -181,12 +183,12 @@ function bounded_compute_extreme_point(sblmo::CubeSimBLMO, d, lb, ub, int_vars; return v end -function update_integer_bounds!(sblmo::CubeSimBLMO, lb, ub, int_vars) +function update_integer_bounds!(sblmo::CubeSimpleBLMO, lb, ub, int_vars) sblmo.lower_bounds[int_vars] = lb sblmo.upper_bounds[int_vars] = ub end -function is_linear_feasible(sblmo::CubeSimBLMO, v) +function is_linear_feasible(sblmo::CubeSimpleBLMO, v) for i in eachindex(v) if !(sblmo.lower_bounds[i] ≤ v[i] + 1e-6 || !(v[i] - 1e-6 ≤ blmo.upper_bounds[i])) @debug("Vertex entry: $(v[i]) Lower bound: $(blmo.bounds[i, :greaterthan]) Upper bound: $(blmo.bounds[i, :lessthan]))")