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

Wrapper for the Mixed Integer Linear Minimization Oracle #135

Merged
merged 86 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from 71 commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
7a4bf49
Supertype for the Mixed Integer Linear Oracles.
Jul 25, 2023
19dde3e
BLMO wrapper and functions that have to be implemented.
Oct 13, 2023
b00426d
BLMO implemented for solvers supporting MathOptInterface.
Oct 13, 2023
5f09349
Rework build_LMO for the BLMO wrapper.
Oct 13, 2023
59bb4c9
Add the new files.
Oct 13, 2023
6f2dbd7
Started on adapting function for BLMO.
Oct 13, 2023
ccea3d9
Bounded Linear Minimzation Oracle as subtype of Linear Minimization O…
Oct 16, 2023
8191716
Adapted build_LMO for BLMO.
Oct 16, 2023
cbc8166
BLMO for all solvers supporting MOI.
Oct 16, 2023
fa434fc
Add BLMO wrapper and MOI BLMO to source.
Oct 16, 2023
ed5aa04
Adapting file ultilities.jl.
Oct 16, 2023
8174e2d
Boscia.compute_extreme_point is the same function as FrankWolfe.compu…
Oct 16, 2023
cea0ff9
Adapt time_tracking_lmo.jl.
Oct 16, 2023
c553a74
Adapt problem.jl.
Oct 16, 2023
c5df452
Adapt problem.jl II.
Oct 16, 2023
a619cd2
Adapt node.jl
Oct 16, 2023
7b757bb
Is not needed any longer.
Oct 16, 2023
ba01559
Convert between FW.MathOptLMO and MathOptBLMO.
Oct 16, 2023
e47d6d3
Convert MathOptBLMO into MathOptLMO.
Oct 16, 2023
a85593e
Get list of all variables, binaries and integers respectivily.
Oct 16, 2023
bae27ad
Deleted infeasible_pairwise.jl.
Oct 16, 2023
4c2482e
Adapt heuristics.jl.
Oct 16, 2023
dd90fbd
Adapt callback.jl
Oct 16, 2023
75d6bb5
Adapt strong branching.
Oct 16, 2023
a1b04d8
Adapt interface.jl.
Oct 16, 2023
f6295df
Rename files for more clearity.
Oct 16, 2023
f3918d8
Separate file for the build_LMO function.
Oct 16, 2023
a93213c
Fix syntax issues.
Oct 16, 2023
c5c03dc
Rather write Base.convert.
Oct 16, 2023
5441367
Have a solve function for MathOptLMO. Converts internally and calls o…
Oct 16, 2023
32e2f45
Minor change.
Oct 16, 2023
b2c0d4a
Better explanation of blmo
dhendryc Oct 16, 2023
0d8d0bc
Fix incremental compilation warning.
Oct 17, 2023
223794e
Signuature fix.
Oct 17, 2023
edf9b1c
minor change.
Oct 17, 2023
1733515
Redirect to FrankWolfe.compute_extreme_point for MathOptLMO.
Oct 17, 2023
4130c16
Syntax fix.
Oct 17, 2023
0c6413d
Merge changes
Oct 17, 2023
7090af6
Mix up between lower and upper bounds.
Oct 17, 2023
db6e3c3
Syntax fix.
Oct 17, 2023
c567780
Syntax fix.
Oct 17, 2023
f2a386e
Export Base.copy.
Oct 17, 2023
9d7c507
Syntax fix.
Oct 17, 2023
064d74c
Update src/MOI_bounded_oracle.jl
matbesancon Oct 17, 2023
9064c2c
No extra copy function needed.
Oct 17, 2023
d7fbc36
Merge changes
Oct 17, 2023
60d1b44
Changes to the Strong Branching struct.
Oct 17, 2023
701140a
Syntax fix.
Oct 17, 2023
2682cd8
Change to MathOptBLMO.
Oct 17, 2023
1b07904
Syntax change.
Oct 17, 2023
b56ae3c
Signature change.
Oct 17, 2023
edda014
Delete unnecessary code.
Oct 18, 2023
0deade1
Clean up.
Oct 18, 2023
5748d5e
Some rewriting.
Oct 18, 2023
f514281
Explicitly hand down all the arguments.
Oct 18, 2023
cda0fc3
Syntax fix.
Oct 18, 2023
23f760c
Update src/lmo_wrapper.jl
matbesancon Oct 18, 2023
3bf1ad4
Update src/lmo_wrapper.jl
matbesancon Oct 18, 2023
e310223
LMO over the cube.
Oct 18, 2023
297178b
Approx planted point with LMO over cube.
Oct 18, 2023
70674ee
Split up get_bound.
Oct 18, 2023
2f58f3c
Minor change.
Oct 18, 2023
098e7a7
Fomratting change.
Oct 18, 2023
f6fe5f9
Minor fix.
Oct 18, 2023
13d8e93
minor fix.
Oct 18, 2023
89fa456
Merge changes
Oct 18, 2023
e32de1b
Minor fix.
Oct 19, 2023
b79f45a
Move the cube LMO into the source files.
Oct 19, 2023
9057ee7
Cube BLMO now part of source, sees all dependencies.
Oct 19, 2023
005db86
Minor change.
Oct 19, 2023
512d5cb
Merge changes.
Oct 19, 2023
5e293ce
Account for numerical inaccuracies.
Oct 19, 2023
f6f1fc2
Renaming.2
Oct 19, 2023
7321fde
Renaming of fields.
Oct 19, 2023
b6d9fa5
Beware of numerical rounding issues.
Oct 19, 2023
32bd9f1
Both nodes can be pruned if one of them actually reaches the incumben…
Oct 19, 2023
b039daf
Update src/MOI_bounded_oracle.jl
matbesancon Oct 19, 2023
b91d306
Update src/cube_blmo.jl
matbesancon Oct 19, 2023
1a5ead0
Update src/MOI_bounded_oracle.jl
matbesancon Oct 19, 2023
231319e
Update src/cube_blmo.jl
matbesancon Oct 19, 2023
670bce8
cleanup
matbesancon Oct 19, 2023
854dc7b
readd file
matbesancon Oct 19, 2023
15c96b1
Merge changes.
Oct 19, 2023
6e0f597
Fix merge conflicts.
Oct 19, 2023
ca50fc3
Minor change.
Oct 19, 2023
1a9ef28
Hand down kwargs...
Oct 19, 2023
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
52 changes: 37 additions & 15 deletions examples/approx_planted_point.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,10 @@ using Distributions
import MathOptInterface
const MOI = MathOptInterface


n = 20
diffi = Random.rand(Bool, n) * 0.6 .+ 0.3

@testset "Approximate planted point" begin
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.GreaterThan(0.0))
MOI.add_constraint(o, xi, MOI.LessThan(1.0))
MOI.add_constraint(o, xi, MOI.ZeroOne()) # or MOI.Integer()
end
lmo = FrankWolfe.MathOptLMO(o)
@testset "Approximate planted point - Integer" begin

function f(x)
return 0.5 * sum((x[i] - diffi[i])^2 for i in eachindex(x))
Expand All @@ -32,8 +21,41 @@ diffi = Random.rand(Bool, n) * 0.6 .+ 0.3
@. storage = x - diffi
end

x, _, result = Boscia.solve(f, grad!, lmo, verbose=true)
@testset "Using SCIP" begin
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.GreaterThan(0.0))
MOI.add_constraint(o, xi, MOI.LessThan(1.0))
MOI.add_constraint(o, xi, MOI.ZeroOne()) # or MOI.Integer()
end
lmo = FrankWolfe.MathOptLMO(o)

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

@test x == round.(diffi)
@test isapprox(f(x), f(result[:raw_solution]), atol=1e-6, rtol=1e-3)

x_scip = x
dhendryc marked this conversation as resolved.
Show resolved Hide resolved
end

@testset "Using Cube LMO" begin
int_vars = []
bin_vars = collect(1:n)

bounds = Boscia.IntegerBounds()
for i in 1:n
push!(bounds, (i, MOI.GreaterThan(0.0)))
push!(bounds, (i, MOI.LessThan(1.0)))
end
blmo = Boscia.CubeBLMO(n, int_vars, bin_vars, bounds)

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

@test x == round.(diffi)
@test isapprox(f(x), f(result[:raw_solution]), atol=1e-6, rtol=1e-3)
@test x == round.(diffi)
@test isapprox(f(x), f(result[:raw_solution]), atol=1e-6, rtol=1e-3)
end
end

5 changes: 3 additions & 2 deletions examples/birkhoff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ x, _, _ = Boscia.solve(f, grad!, lmo, verbose=true)
x, _, result_baseline = Boscia.solve(f, grad!, lmo, verbose=true)
@test f(x) <= f(result_baseline[:raw_solution]) + 1e-6
lmo = build_birkhoff_lmo()
branching_strategy = Boscia.PartialStrongBranching(20, 1e-4, HiGHS.Optimizer())
MOI.set(branching_strategy.optimizer, MOI.Silent(), true)
blmo = Boscia.MathOptBLMO(HiGHS.Optimizer())
branching_strategy = Boscia.PartialStrongBranching(10, 1e-3, blmo)
MOI.set(branching_strategy.bounded_lmo.o, MOI.Silent(), true)
x_strong, _, result_strong =
Boscia.solve(f, grad!, lmo, verbose=true, branching_strategy=branching_strategy)
@test f(x) ≈ f(x_strong)
Expand Down
5 changes: 3 additions & 2 deletions examples/strong_branching_portfolio.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ end
@test dot(ai, x) <= bi + 1e-6
@test f(x) <= f(result_baseline[:raw_solution]) + 1e-6

branching_strategy = Boscia.PartialStrongBranching(10, 1e-3, HiGHS.Optimizer())
MOI.set(branching_strategy.optimizer, MOI.Silent(), true)
blmo = Boscia.MathOptBLMO(HiGHS.Optimizer())
branching_strategy = Boscia.PartialStrongBranching(10, 1e-3, blmo)
MOI.set(branching_strategy.bounded_lmo.o, MOI.Silent(), true)

lmo = prepare_portfolio_lmo()
x, _, result_strong_branching =
Expand Down
9 changes: 7 additions & 2 deletions src/Boscia.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module Boscia

using FrankWolfe
import FrankWolfe: compute_extreme_point
export compute_extreme_point
using Random
using SCIP
import MathOptInterface
Expand All @@ -12,17 +14,20 @@ const MOIU = MOI.Utilities

import MathOptSetDistances as MOD

include("integer_bounds.jl")
include("lmo_wrapper.jl")
include("time_tracking_lmo.jl")
include("bounds.jl")
include("build_lmo.jl")
include("frank_wolfe_variants.jl")
include("node.jl")
include("custom_bonobo.jl")
include("callbacks.jl")
include("problem.jl")
include("infeasible_pairwise.jl")
include("heuristics.jl")
include("strong_branching.jl")
include("utilities.jl")
include("interface.jl")
include("MOI_bounded_oracle.jl")
include("cube_blmo.jl")

end # module
Loading
Loading