diff --git a/examples/low_dim_in_high_dim.jl b/examples/low_dim_in_high_dim.jl index 33a7a0402..1f9dd534f 100644 --- a/examples/low_dim_in_high_dim.jl +++ b/examples/low_dim_in_high_dim.jl @@ -9,6 +9,8 @@ using Distributions import MathOptInterface const MOI = MathOptInterface +include("cube_blmo.jl") + # The example from "Optimizing a low-dimensional convex function over a high-dimensional cube" # by Christoph Hunkenschröder, Sebastian Pokutta, Robert Weismantel # https://arxiv.org/abs/2204.05266. diff --git a/examples/nonlinear.jl b/examples/nonlinear.jl index e426b7a5b..4aa36a56c 100644 --- a/examples/nonlinear.jl +++ b/examples/nonlinear.jl @@ -1,4 +1,3 @@ -using SCIP using FrankWolfe using LinearAlgebra import MathOptInterface @@ -8,23 +7,41 @@ import Bonobo using Printf using Dates -const MOI = MathOptInterface +# using SCIP +# const MOI = MathOptInterface -n = 5 +include("cube_blmo.jl") + +n = 40 seed = 10 Random.seed!(seed) -o = SCIP.Optimizer() -MOI.set(o, MOI.Silent(), true) -MOI.empty!(o) -x = MOI.add_variables(o, n) -for xi in x - MOI.add_constraint(o, xi, MOI.ZeroOne()) - MOI.add_constraint(o, xi, MOI.GreaterThan(0.0)) - MOI.add_constraint(o, xi, MOI.LessThan(1.0)) +################################################################ +# alternative implementation of LMO using MOI and SCIP +################################################################ +# o = SCIP.Optimizer() +# MOI.set(o, MOI.Silent(), true) +# MOI.empty!(o) +# x = MOI.add_variables(o, n) +# for xi in x +# MOI.add_constraint(o, xi, MOI.ZeroOne()) +# MOI.add_constraint(o, xi, MOI.GreaterThan(0.0)) +# MOI.add_constraint(o, xi, MOI.LessThan(1.0)) +# end +# lmo = FrankWolfe.MathOptLMO(o) + + +################################################################ +# LMO via CubeBLMO +################################################################ +int_vars = collect(1:n) +bounds = Boscia.IntegerBounds() +for i in 1:n + push!(bounds, (i, 0.0), :greaterthan) + push!(bounds, (i, 1.0), :lessthan) end -lmo = FrankWolfe.MathOptLMO(o) +lmo = CubeBLMO(n, int_vars, bounds) const A = let A = randn(n, n) @@ -47,6 +64,6 @@ function grad!(storage, x) return mul!(storage, A, y, -2, 2) end -x, _, _ = Boscia.solve(f, grad!, lmo, verbose=true, print_iter=1) +x, _, _ = Boscia.solve(f, grad!, lmo, verbose=true, print_iter=500) @show x