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

Update of examples (wip) #157

Merged
merged 4 commits into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/low_dim_in_high_dim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
43 changes: 30 additions & 13 deletions examples/nonlinear.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using SCIP
using FrankWolfe
using LinearAlgebra
import MathOptInterface
Expand All @@ -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)
Expand All @@ -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
Loading