diff --git a/docs/Project.toml b/docs/Project.toml index 8a10b165..1d867d5d 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -9,6 +9,7 @@ Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306" MibS_jll = "118347d2-e127-56b9-9933-6abf9cc1adc1" QuadraticToBinary = "014a38d5-7acb-4e20-b6c0-4fe5c2344fd1" Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" +SCIP = "82193955-e24f-5292-bf16-6f2c5261a85f" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [compat] @@ -17,3 +18,4 @@ HiGHS = "=1.5.1" Ipopt = "=1.0.2" MibS_jll = "=1.1.3" QuadraticToBinary = "=0.4.0" +SCIP = "=0.11.12" diff --git a/docs/src/tutorials/conic_lower.md b/docs/src/tutorials/conic_lower.md index b68bdd38..b9e24d50 100644 --- a/docs/src/tutorials/conic_lower.md +++ b/docs/src/tutorials/conic_lower.md @@ -11,9 +11,9 @@ described in example 3.3 from ```math \begin{align} &\max_{x \in \mathbb{R}} \quad x + 3y_1 \\ - &\st \quad 2 \leq x \leq 6\\ - & \hspace{28pt} y(x) \in \argmin_{y\in {\mathbb{R}^3}} -y_1\\ - & \hspace{58pt} \st \quad x + y_1 \leq 8 \\ + &\textit{s.t.} \quad 2 \leq x \leq 6\\ + & \hspace{28pt} y(x) \in \arg\min_{y\in {\mathbb{R}^3}} -y_1\\ + & \hspace{58pt} \textit{s.t.} \quad x + y_1 \leq 8 \\ & \hspace{76pt} \quad x + 4y_1 \geq 8 \\ & \hspace{76pt} \quad x + 2y_1 \leq 12 \\ & \hspace{76pt} \quad y \in {SOC}_3 \label{eq-soc} diff --git a/docs/src/tutorials/lower_duals.jl b/docs/src/tutorials/lower_duals.jl index 79a42bd6..2dc67ff1 100644 --- a/docs/src/tutorials/lower_duals.jl +++ b/docs/src/tutorials/lower_duals.jl @@ -81,7 +81,7 @@ set_lower_bound(lambda, 0.0) set_upper_bound(lambda, 1000.0) # Then, as before, we set a solver -# (now SCIP with the `QuadraticToBinary.jl` wrapper) and a solution method +# (now HiGHS with the `QuadraticToBinary.jl` wrapper) and a solution method # (now Fortuny-Amat and McCarl): set_optimizer(model, @@ -107,4 +107,4 @@ for i in 1:3 var = @variable(Upper(model), variable_type = DualOf(reserves[i])) push!(my_duals, var) end -my_duals +my_duals # a vector of anonimous variables diff --git a/docs/src/tutorials/lower_duals.md b/docs/src/tutorials/lower_duals.md index 4c544e71..8cea985b 100644 --- a/docs/src/tutorials/lower_duals.md +++ b/docs/src/tutorials/lower_duals.md @@ -93,7 +93,7 @@ set_upper_bound(lambda, 1000.0) ``` Then, as before, we set a solver -(now SCIP with the `QuadraticToBinary.jl` wrapper) and a solution method +(now HiGHS with the `QuadraticToBinary.jl` wrapper) and a solution method (now Fortuny-Amat and McCarl): ```@example lower_duals @@ -126,7 +126,7 @@ for i in 1:3 var = @variable(Upper(model), variable_type = DualOf(reserves[i])) push!(my_duals, var) end -my_duals +my_duals # a vector of anonimous variables ``` !!! info diff --git a/docs/src/tutorials/modes.jl b/docs/src/tutorials/modes.jl index 7d512e01..8c5a053d 100644 --- a/docs/src/tutorials/modes.jl +++ b/docs/src/tutorials/modes.jl @@ -57,7 +57,7 @@ # We start loading all libraries needed for this example. -using BilevelJuMP, QuadraticToBinary, HiGHS, Ipopt +using BilevelJuMP, HiGHS, Ipopt, SCIP # Now we create a bilevel model with the `BilevelModel` constructor with no # solver nor mode specified. @@ -96,35 +96,33 @@ objective_value(model) # ## `SOS1Mode` and `SCIP.Optimizer` -# ```julia -# set_optimizer(model, SCIP.Optimizer) -# -# BilevelJuMP.set_mode(model, BilevelJuMP.SOS1Mode()) -# -# optimize!(model) -# -# objective_value(model) -# ``` +set_optimizer(model, SCIP.Optimizer) -# !!! info -# This code was not executed because SCIP might have a non-standard -# intallation procedure in windows. +BilevelJuMP.set_mode(model, BilevelJuMP.SOS1Mode()) + +optimize!(model) + +objective_value(model) + +# !!! warning +# SCIP requires a non-standard installation procedure in windows. +# See [SCIP.jl](https://github.com/scipopt/SCIP.jl#custom-installations) for +# more details. # ## `IndicatorMode` and `SCIP.Optimizer` -# ```julia -# set_optimizer(model, SCIP.Optimizer) -# -# BilevelJuMP.set_mode(model, BilevelJuMP.IndicatorMode()) -# -# optimize!(model) -# -# objective_value(model) -# ``` +set_optimizer(model, SCIP.Optimizer) + +BilevelJuMP.set_mode(model, BilevelJuMP.IndicatorMode()) + +optimize!(model) + +objective_value(model) -# !!! info -# This code was not executed because SCIP might have a non-standard -# intallation procedure in windows. +# !!! warning +# SCIP requires a non-standard installation procedure in windows. +# See [SCIP.jl](https://github.com/scipopt/SCIP.jl#custom-installations) for +# more details. # ## `ProductMode` and `Ipopt.Optimizer` @@ -152,20 +150,19 @@ objective_value(model) # ## `MixedMode` and `SCIP.Optimizer` -# ```julia -# set_optimizer(model, SCIP.Optimizer) -# -# BilevelJuMP.set_mode(model, BilevelJuMP.MixedMode(default = SOS1Mode())) -# -# BilevelJuMP.set_mode(c1, BilevelJuMP.IndicatorMode()) -# -# BilevelJuMP.set_mode(c3, BilevelJuMP.SOS1Mode()) -# -# optimize!(model) -# -# objective_value(model) -# ``` - -# !!! info -# This code was not executed because SCIP might have a non-standard -# intallation procedure in windows. +set_optimizer(model, SCIP.Optimizer) + +BilevelJuMP.set_mode(model, BilevelJuMP.MixedMode(default = BilevelJuMP.SOS1Mode())) + +BilevelJuMP.set_mode(c1, BilevelJuMP.IndicatorMode()) + +BilevelJuMP.set_mode(c3, BilevelJuMP.SOS1Mode()) + +optimize!(model) + +objective_value(model) + +# !!! warning +# SCIP requires a non-standard installation procedure in windows. +# See [SCIP.jl](https://github.com/scipopt/SCIP.jl#custom-installations) for +# more details. diff --git a/docs/src/tutorials/quad_to_bin.jl b/docs/src/tutorials/quad_to_bin.jl index 0ed272c2..ff1f7c3b 100644 --- a/docs/src/tutorials/quad_to_bin.jl +++ b/docs/src/tutorials/quad_to_bin.jl @@ -38,15 +38,21 @@ objective_value(model) # However, this might lead to some solver not supporting certain functionality like SCIP. # In this case we need to: -# ```julia -# SOLVER = SCIP.Optimizer() -# CACHED_SOLVER = MOI.Utilities.CachingOptimizer( -# MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}()), SOLVER) -# Q_SOLVER = QuadraticToBinary.Optimizer{Float64}(CACHED_SOLVER) -# BilevelModel(()->Q_SOLVER, mode = BilevelJuMP.ProductMode(1e-5)) -# ``` +using SCIP + +# !!! warning +# SCIP requires a non-standard installation procedure in windows. +# See [SCIP.jl](https://github.com/scipopt/SCIP.jl#custom-installations) for +# more details. + +SOLVER = SCIP.Optimizer() + +CACHED_SOLVER = MOI.Utilities.CachingOptimizer( + MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}()), SOLVER) + +Q_SOLVER = QuadraticToBinary.Optimizer{Float64}(CACHED_SOLVER) + +BilevelModel(()->Q_SOLVER, mode = BilevelJuMP.ProductMode(1e-5)) + # Note that we used `()->Q_SOLVER` instead of just `Q_SOLVER` because `BilevelModel` # requires as constructor and not an instance of an object. - -# !!! info -# This code was not executed to avoid excessive dependencies to build these docs. \ No newline at end of file diff --git a/src/moi.jl b/src/moi.jl index cdf2dd79..b5b491a7 100644 --- a/src/moi.jl +++ b/src/moi.jl @@ -168,24 +168,6 @@ function accept_vector_set( return nothing end -function reset!(::AbstractBilevelSolverMode) - return nothing -end - -ignore_dual_objective(::AbstractBilevelSolverMode{T}) where {T} = true - -function accept_vector_set( - mode::AbstractBilevelSolverMode{T}, - con::Complement, -) where {T} - if con.is_vec - error( - "Set $(typeof(con.set_w_zero)) is not accepted when solution method is $(typeof(mode))", - ) - end - return nothing -end - #= ComplementBoundCache used in Big-M =#