diff --git a/dev/background/index.html b/dev/background/index.html index 8a195ad..20237a8 100644 --- a/dev/background/index.html +++ b/dev/background/index.html @@ -1,5 +1,5 @@ -Background Information · BilevelJuMP.jl

Bilevel Optimization

Bilevel optimization is a vast discipline with a long (50+ years) history. We will not attempt to present a bilevel optimization introduction here. Instead, we point the reader to the excelent text:

A Gentle and Incomplete Introduction to Bilevel Optimization

by Yasmine Beck and Martin Schmidt.

The interested reader can find more information in books:

and in other reviews:

Bilevel Optimization in BilevelJuMP

In BileveJuMP focus on the following bilevel problem form:

\[\begin{aligned} +Background Information · BilevelJuMP.jl

Bilevel Optimization

Bilevel optimization is a vast discipline with a long (50+ years) history. We will not attempt to present a bilevel optimization introduction here. Instead, we point the reader to the excellent text:

A Gentle and Incomplete Introduction to Bilevel Optimization

by Yasmine Beck and Martin Schmidt.

The interested reader can find more information in books:

and in other reviews:

Bilevel Optimization in BilevelJuMP

In BileveJuMP focus on the following bilevel problem form:

\[\begin{aligned} &\min_{x, \textbf{y}, z} && f_0(x, \textbf{y}, z) \\ &\textit{s.t.} && f_i(x, \textbf{y}, z) \in \mathcal{S}_i, \quad i = 1 \ldots k, \\ &&& x(z), \textbf{y}(z) \in @@ -12,4 +12,4 @@ author={{Dias Garcia}, Joaquim and Bodin, Guilherme and Street, Alexandre}, journal={arXiv preprint arXiv:2205.02307}, year={2022} -}

Here is the pdf.

+}

Here is the pdf.

diff --git a/dev/examples/DTMP_example1/index.html b/dev/examples/DTMP_example1/index.html index 999851a..67b3b61 100644 --- a/dev/examples/DTMP_example1/index.html +++ b/dev/examples/DTMP_example1/index.html @@ -14,4 +14,4 @@ set_silent(model)

First we need to create all of the variables in the upper and lower problems:

Upper level variables

@variable(Upper(model), x, start = 1)

$ x $

Lower level variables

@variable(Lower(model), y, start = 6)

$ y $

Then we can add the objective and constraints of the upper problem:

Upper level objecive function

@objective(Upper(model), Min, 4y - x)

$ 4 y - x $

Upper level constraints

@constraint(Upper(model), y + 2x <= 8)

\[ 2 x + y \leq 8 \]

Followed by the objective and constraints of the lower problem:

Lower objective function

@objective(Lower(model), Min, - y -x )

$ -y - x $

Lower constraints

@constraint(Lower(model), - y <= 0)
 @constraint(Lower(model), y + x <= 7)
 @constraint(Lower(model), - x <= 0)
-@constraint(Lower(model), x <= 4)

\[ x \leq 4 \]

Now we can solve the problem and verify the solution again that reported by book

optimize!(model)

Results

value(x)
1.0000100892122645
value(y)
5.9999799010742905
Info

View this file on Github.


This page was generated using Literate.jl.

+@constraint(Lower(model), x <= 4)

\[ x \leq 4 \]

Now we can solve the problem and verify the solution again that reported by book

optimize!(model)

Results

value(x)
1.000010089212264
value(y)
5.999979901074291
Info

View this file on Github.


This page was generated using Literate.jl.

diff --git a/dev/examples/FOBP_example2/index.html b/dev/examples/FOBP_example2/index.html index b055627..e6d6def 100644 --- a/dev/examples/FOBP_example2/index.html +++ b/dev/examples/FOBP_example2/index.html @@ -73,35 +73,72 @@ 19 6.1333413e+00 1.32e-07 1.12e+05 -1.0 5.27e-02 - 1.00e+00 1.00e+00h 1 iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls 20 6.1333412e+00 1.28e-07 2.35e+06 -1.0 2.43e-03 - 1.00e+00 1.38e-01f 2 - 21 6.1333372e+00 2.05e-08 4.84e+05 -1.0 1.44e-02 - 1.00e+00 1.00e+00h 1 - 22 6.1333345e+00 0.00e+00 3.66e+05 -1.0 7.66e-03 - 1.00e+00 1.00e+00h 1 + 21 6.1333372e+00 2.05e-08 4.83e+05 -1.0 1.44e-02 - 1.00e+00 1.00e+00h 1 + 22 6.1333345e+00 1.11e-16 3.62e+05 -1.0 7.68e-03 - 1.00e+00 1.00e+00h 1 23 6.1333351e+00 0.00e+00 2.36e+06 -1.0 3.69e-03 - 1.00e+00 5.00e-01f 2 - 24 6.1333347e+00 2.22e-16 1.24e+03 -1.0 9.02e-05 - 1.00e+00 1.00e+00h 1 - 25 6.1333346e+00 1.11e-16 1.48e+04 -2.5 1.68e-04 - 1.00e+00 1.00e+00h 1 - 26 6.1333345e+00 1.11e-16 3.58e+01 -2.5 2.20e-05 1.8 1.00e+00 1.00e+00f 1 -Cannot call restoration phase at point that is almost feasible (violation 1.110223e-16). -Abort in line search due to no other fall back. + 24 6.1333350e+00 0.00e+00 1.17e+07 -1.0 1.87e-01 - 2.19e-02 4.38e-04f 8 + 25 6.1333350e+00 0.00e+00 9.28e+06 -1.0 8.16e-03 - 1.00e+00 1.01e-02f 5 + 26 6.1333350e+00 1.11e-16 4.10e+04 -1.0 2.53e-03 - 1.00e+00 1.00e+00h 1 + 27 6.1333346e+00 2.22e-16 5.34e+03 -1.0 1.71e-03 - 1.00e+00 1.00e+00h 1 + 28 6.1333347e+00 2.22e-16 2.49e+05 -2.5 3.67e-05 2.7 9.86e-01 1.00e+00f 1 + 29 6.1333346e+00 0.00e+00 1.59e+02 -2.5 1.35e-04 - 1.00e+00 1.00e+00f 1 +iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls + 30 6.1333360e+00 0.00e+00 1.34e+03 -2.5 1.28e-02 - 1.00e+00 1.00e+00H 1 + 31 6.1333359e+00 3.68e-08 1.37e+03 -2.5 1.65e+00 - 2.51e-05 2.51e-05s 7 + 32 6.1333380e+00 0.00e+00 7.38e+02 -2.5 1.59e-03 - 1.00e+00 1.00e+00s 7 + 33 6.1333388e+00 1.48e-07 2.57e-01 -2.5 2.12e-04 3.1 1.00e+00 1.00e+00s 7 + 34 6.1333337e+00 1.36e-07 2.67e+03 -5.7 1.70e+00 - 7.12e-02 7.65e-02H 1 + 35 6.1333334e+00 1.60e-08 4.54e+04 -5.7 5.63e-02 - 9.00e-01 8.02e-01h 1 + 36 6.1333334e+00 1.57e-08 1.65e+06 -5.7 7.65e-01 - 1.56e-02 6.35e-02h 1 + 37 6.1333333e+00 1.34e-08 1.93e+06 -5.7 3.73e-01 - 1.97e-01 1.24e-01f 1 + 38 6.1333333e+00 1.34e-08 1.93e+06 -5.7 5.18e+00 - 3.43e-03 2.47e-04f 2 + 39 6.1333333e+00 1.34e-08 3.23e+06 -5.7 4.94e+01 - 2.93e-03 1.19e-05f 2 +iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls + 40 6.1333333e+00 1.34e-08 2.66e+06 -5.7 5.76e-01 - 2.72e-02 5.07e-03h 1 + 41 6.1333334e+00 1.50e-08 2.68e+06 -5.7 4.64e-01 - 1.00e+00 7.56e-01f 1 + 42 6.1333334e+00 2.22e-16 1.61e+09 -5.7 5.29e-03 2.6 9.73e-04 1.00e+00f 1 + 43 6.1333334e+00 2.22e-16 1.17e+04 -5.7 1.57e-07 5.7 9.95e-01 1.00e+00h 1 + 44 6.1333334e+00 0.00e+00 2.78e+02 -5.7 8.91e-02 - 1.00e+00 1.00e+00f 1 + 45 6.1333333e+00 0.00e+00 8.16e-03 -5.7 4.43e-08 5.3 1.00e+00 1.00e+00f 1 + 46 6.1333333e+00 8.88e-16 5.94e+02 -5.7 1.08e+00 - 5.49e-01 1.00e+00f 1 + 47 6.1333333e+00 0.00e+00 6.93e+02 -5.7 2.07e+00 - 7.05e-01 1.00e+00h 1 + 48 6.1333333e+00 8.88e-16 2.32e-03 -5.7 3.78e-08 4.8 1.00e+00 1.00e+00h 1 + 49 6.1333333e+00 1.78e-15 1.04e+03 -5.7 3.38e+00 - 1.00e+00 1.00e+00f 1 +iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls + 50 6.1333333e+00 0.00e+00 2.91e+02 -5.7 7.44e+00 - 1.00e+00 9.91e-01h 1 + 51 6.1333333e+00 0.00e+00 2.07e+02 -5.7 3.86e+00 - 1.00e+00 1.00e+00f 1 + 52 6.1333333e+00 0.00e+00 4.07e+00 -5.7 3.37e-01 - 1.00e+00 1.00e+00h 1 + 53 6.1333333e+00 0.00e+00 2.54e-03 -5.7 5.88e-03 - 1.00e+00 1.00e+00h 1 + 54 6.1333333e+00 0.00e+00 3.20e-10 -5.7 1.78e-06 - 1.00e+00 1.00e+00h 1 + 55 6.1333333e+00 0.00e+00 2.37e+00 -8.6 3.39e-04 - 9.93e-01 1.00e+00h 1 +In iteration 55, 1 Slack too small, adjusting variable bound + 56 6.1333333e+00 0.00e+00 1.15e-01 -8.6 7.44e-01 - 9.51e-01 9.77e-01h 1 + 57 6.1333333e+00 0.00e+00 1.19e-01 -8.6 1.46e+00 - 1.00e+00 1.00e+00h 1 + 58 6.1333333e+00 0.00e+00 2.36e-02 -8.6 8.45e-01 - 1.00e+00 1.00e+00h 1 + 59 6.1333333e+00 0.00e+00 1.62e-04 -8.6 1.39e-01 - 1.00e+00 1.00e+00h 1 +iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls + 60 6.1333333e+00 0.00e+00 1.54e-09 -8.6 3.89e-04 - 1.00e+00 1.00e+00h 1 -Number of Iterations....: 26 +Number of Iterations....: 60 (scaled) (unscaled) -Objective...............: 6.1333345125452912e+00 6.1333345125452912e+00 -Dual infeasibility......: 3.5841188212015616e+01 3.5841188212015616e+01 -Constraint violation....: 1.1102230246251565e-16 1.1102230246251565e-16 -Variable bound violation: 4.3702289611215291e-09 4.3702289611215291e-09 -Complementarity.........: 2.9671402126700249e-03 2.9671402126700249e-03 -Overall NLP error.......: 3.7381382343713479e-02 3.5841188212015616e+01 +Objective...............: 6.1333332742376614e+00 6.1333332742376614e+00 +Dual infeasibility......: 1.5378925401466993e-09 1.5378925401466993e-09 +Constraint violation....: 0.0000000000000000e+00 0.0000000000000000e+00 +Variable bound violation: 4.3702290096584022e-09 4.3702290096584022e-09 +Complementarity.........: 2.5059035689599364e-09 2.5059035689599364e-09 +Overall NLP error.......: 2.5059035689599364e-09 2.5059035689599364e-09 -Number of objective function evaluations = 51 -Number of objective gradient evaluations = 28 -Number of equality constraint evaluations = 51 -Number of inequality constraint evaluations = 51 -Number of equality constraint Jacobian evaluations = 28 -Number of inequality constraint Jacobian evaluations = 28 -Number of Lagrangian Hessian evaluations = 27 -Total seconds in IPOPT = 0.047 +Number of objective function evaluations = 95 +Number of objective gradient evaluations = 61 +Number of equality constraint evaluations = 95 +Number of inequality constraint evaluations = 95 +Number of equality constraint Jacobian evaluations = 61 +Number of inequality constraint Jacobian evaluations = 61 +Number of Lagrangian Hessian evaluations = 60 +Total seconds in IPOPT = 0.024 -EXIT: Error in step computation!
objective_value(model)
6.133334512545291
objective_value(Lower(model))
-1.866667025303046
value(x)
1.866667025303046
value(y)
0.5333334366361542
value(u1)
1.866667025303046
value(l1)
2.4000004619392
dual(l1)
1-element Vector{Float64}:
- 4.017857069584776e-9
dual(l3)
1-element Vector{Float64}:
- 4.370228961121529e-9
Info

View this file on Github.


This page was generated using Literate.jl.

+EXIT: Optimal Solution Found.
objective_value(model)
6.133333274237661
objective_value(Lower(model))
-1.866666648886298
value(x)
1.866666648886298
value(y)
0.5333333275787672
value(u1)
1.866666648886298
value(l1)
2.399999976465065
dual(l1)
1-element Vector{Float64}:
+ 4.017857147042123e-9
dual(l3)
1-element Vector{Float64}:
+ 4.370229009658402e-9
Info

View this file on Github.


This page was generated using Literate.jl.

diff --git a/dev/examples/FOBP_example3/index.html b/dev/examples/FOBP_example3/index.html index 112569e..cf9aaf8 100644 --- a/dev/examples/FOBP_example3/index.html +++ b/dev/examples/FOBP_example3/index.html @@ -114,11 +114,11 @@ 12 1.3932121e-01 9.80e-07 1.25e+05 -1.0 7.48e-02 - 1.00e+00 1.47e-01f 3 13 3.0922874e-01 3.60e-07 6.62e+04 -1.0 1.06e-01 - 1.00e+00 7.60e-01h 1 14 2.9797374e-01 2.66e-07 5.55e+05 -1.0 3.64e-02 - 1.00e+00 1.48e-01f 3 - 15 1.6647533e-02 2.23e-08 1.70e+05 -1.0 1.54e-01 - 1.00e+00 8.49e-01h 1 - 16 1.9033881e-02 2.06e-08 3.39e+06 -1.0 6.15e-02 - 1.00e+00 1.75e-02f 6 - 17 1.0546868e-01 1.11e-08 6.84e+05 -1.0 4.30e-02 - 1.00e+00 8.78e-01h 1 - 18 1.2957235e-01 1.49e-13 4.55e+06 -1.0 3.44e-02 - 1.00e+00 3.38e-01f 2 - 19 1.1729935e-01 2.22e-16 6.80e+04 -1.0 1.79e-02 - 1.00e+00 1.00e+00h 1 + 15 1.6647530e-02 2.23e-08 1.70e+05 -1.0 1.54e-01 - 1.00e+00 8.49e-01h 1 + 16 1.9033879e-02 2.06e-08 3.39e+06 -1.0 6.15e-02 - 1.00e+00 1.75e-02f 6 + 17 1.0546869e-01 1.11e-08 6.84e+05 -1.0 4.30e-02 - 1.00e+00 8.78e-01h 1 + 18 1.2957235e-01 1.18e-13 4.55e+06 -1.0 3.44e-02 - 1.00e+00 3.38e-01f 2 + 19 1.1729935e-01 4.29e-13 6.80e+04 -1.0 1.79e-02 - 1.00e+00 1.00e+00h 1 iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls 20 2.0688419e-01 1.11e-16 3.19e+04 -1.0 4.11e-02 - 1.00e+00 1.00e+00f 1 21 -5.0650203e-01 2.22e-16 3.04e+06 -1.7 2.52e-01 - 7.50e-01 1.00e+00f 1 @@ -126,12 +126,12 @@ 23 -6.9110326e-01 2.22e-16 4.17e+04 -1.7 2.12e-02 - 1.00e+00 1.00e+00f 1 24 -6.9625189e-01 2.22e-16 2.86e+03 -1.7 4.13e-03 - 1.00e+00 1.00e+00f 1 25 -6.9564015e-01 2.22e-16 1.74e+01 -1.7 7.17e-04 - 1.00e+00 1.00e+00h 1 - 26 -9.7277264e-01 1.30e-14 1.52e+06 -3.8 8.89e-02 - 5.22e-01 9.68e-01f 1 - 27 -9.8930021e-01 2.22e-16 1.98e+06 -3.8 7.30e-03 - 2.50e-01 1.00e+00f 1 - 28 -9.9199990e-01 1.11e-16 2.08e+06 -3.8 2.47e-03 - 3.28e-01 1.00e+00f 1 + 26 -9.7277264e-01 5.88e-14 1.52e+06 -3.8 8.89e-02 - 5.22e-01 9.68e-01f 1 + 27 -9.8930021e-01 1.11e-16 1.98e+06 -3.8 7.30e-03 - 2.50e-01 1.00e+00f 1 + 28 -9.9199990e-01 2.22e-16 2.08e+06 -3.8 2.47e-03 - 3.28e-01 1.00e+00f 1 29 -9.9200876e-01 2.22e-16 1.24e+05 -3.8 4.91e-05 4.0 8.47e-01 1.00e+00f 1 iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls - 30 -9.9212721e-01 2.22e-16 3.24e-01 -3.8 3.94e-05 3.5 1.00e+00 1.00e+00f 1 + 30 -9.9212721e-01 1.11e-16 3.24e-01 -3.8 3.94e-05 3.5 1.00e+00 1.00e+00f 1 31 -9.9243733e-01 2.22e-16 9.31e-01 -3.8 1.16e-04 3.0 1.00e+00 1.00e+00f 1 32 -9.9528003e-01 2.22e-16 1.70e+02 -3.8 1.02e-02 - 2.88e-01 1.44e-01f 2 33 -9.9624613e-01 2.22e-16 1.65e+05 -3.8 8.40e-03 - 1.00e+00 7.62e-02f 2 @@ -139,61 +139,96 @@ 35 -9.9755343e-01 2.22e-16 1.78e+00 -3.8 1.80e-04 - 1.00e+00 1.00e+00f 1 36 -9.9756559e-01 2.22e-16 7.69e-02 -3.8 2.70e-05 - 1.00e+00 1.00e+00f 1 37 -9.9984090e-01 2.22e-16 1.21e+04 -5.7 7.73e-04 - 4.89e-01 9.34e-01f 1 - 38 -9.9993263e-01 3.60e-07 8.98e+02 -5.7 1.04e-01 - 9.26e-01 1.00e+00f 1 - 39 -9.9995500e-01 1.38e-07 1.72e+03 -5.7 4.67e-02 - 4.99e-01 7.53e-01h 1 + 38 -9.9989976e-01 3.62e-07 1.85e+04 -5.7 1.03e-01 - 4.15e-01 1.00e+00f 1 + 39 -9.9990102e-01 3.60e-07 1.79e+04 -5.7 1.67e-05 3.5 9.65e-01 3.71e-02h 1 iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls - 40 -9.9996178e-01 1.11e-16 6.76e+04 -5.7 2.66e-05 2.6 2.77e-02 1.00e+00f 1 - 41 -9.9996183e-01 2.22e-16 6.64e+04 -5.7 9.62e-05 2.1 3.22e-01 2.62e-02f 2 - 42 -9.9996572e-01 0.00e+00 5.67e+01 -5.7 8.96e-04 - 1.00e+00 1.00e+00f 1 - 43 -9.9996698e-01 9.16e-10 4.82e+01 -5.7 2.47e-01 - 2.34e-01 1.42e-01h 2 - 44 -9.9996733e-01 2.22e-16 1.20e-03 -5.7 2.93e-05 1.6 1.00e+00 1.00e+00h 1 - 45 -9.9997012e-01 4.86e-10 2.67e+01 -5.7 8.69e-02 - 1.00e+00 1.00e+00H 1 - 46 -9.9997052e-01 2.22e-16 3.85e-04 -5.7 2.80e-05 1.1 1.00e+00 1.00e+00h 1 - 47 -9.9997116e-01 2.82e-10 3.02e+01 -5.7 1.23e-01 - 1.00e+00 2.50e-01h 3 - 48 -9.9997186e-01 1.22e-09 4.03e+01 -5.7 1.46e-01 - 1.00e+00 2.50e-01h 3 - 49 -9.9997215e-01 2.22e-16 1.99e-04 -5.7 3.64e-05 0.7 1.00e+00 1.00e+00h 1 -Cannot call restoration phase at point that is almost feasible (violation 2.220446e-16). -Abort in line search due to no other fall back. + 40 -9.9994358e-01 2.38e-07 1.21e+04 -5.7 8.69e-05 3.0 1.00e+00 3.28e-01f 2 + 41 -9.9990347e-01 3.38e-06 5.95e+03 -5.7 5.56e-04 2.5 2.79e-02 1.00e+00h 1 + 42 -9.9992382e-01 2.33e-06 4.11e+03 -5.7 3.98e-04 2.0 1.00e+00 3.09e-01h 2 + 43 -9.9992007e-01 3.46e-07 1.02e+03 -5.7 6.53e-02 - 1.01e-01 1.00e+00h 1 + 44 -9.9994620e-01 3.37e-07 3.97e+02 -5.7 4.89e-05 1.6 1.00e+00 6.12e-01h 1 + 45 -9.9995539e-01 7.84e-08 4.23e+02 -5.7 4.82e-02 - 7.50e-03 3.99e-01f 2 + 46 -9.9996021e-01 7.95e-08 1.19e+02 -5.7 1.27e-04 1.1 1.00e+00 7.23e-01h 1 + 47 -9.9996331e-01 1.61e-08 1.08e+02 -5.7 3.39e-02 - 8.11e-02 2.83e-01f 2 + 48 -9.9996384e-01 2.53e-08 4.67e+01 -5.7 1.59e-04 0.6 1.00e+00 6.64e-01h 1 + 49 -9.9996585e-01 3.01e-09 9.39e+01 -5.7 1.54e-02 - 1.00e+00 3.13e-01f 2 +iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls + 50 -9.9997068e-01 2.22e-16 3.44e-01 -5.7 1.96e-03 - 1.00e+00 1.00e+00h 1 + 51 -9.9997083e-01 1.11e-16 2.83e-01 -5.7 2.12e-03 - 1.00e+00 1.00e+00h 1 + 52 -9.9997072e-01 2.22e-16 6.08e-03 -5.7 8.81e-04 - 1.00e+00 1.00e+00h 1 + 53 -9.9997061e-01 2.22e-16 7.91e-04 -5.7 1.14e-04 - 1.00e+00 1.00e+00h 1 + 54 -9.9997061e-01 2.22e-16 1.26e-07 -5.7 2.35e-06 - 1.00e+00 1.00e+00h 1 + 55 -1.0000000e+00 2.22e-16 1.67e+02 -8.6 1.83e-03 - 4.99e-01 9.98e-01f 1 + 56 -1.0000000e+00 1.55e-14 4.38e+01 -8.6 2.53e-01 - 5.00e-01 1.44e-02h 1 + 57 -1.0000000e+00 6.71e-11 6.23e+01 -8.6 7.30e-03 - 1.85e-01 1.00e+00f 1 + 58 -1.0000000e+00 2.22e-16 7.95e+00 -8.6 9.21e-03 - 7.79e-01 1.00e+00h 1 + 59 -1.0000000e+00 1.11e-16 4.63e+00 -8.6 1.47e+00 - 4.14e-01 1.00e+00h 1 +iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls + 60 -1.0000000e+00 2.22e-16 6.85e-01 -8.6 2.37e-01 - 8.82e-01 1.00e+00h 1 + 61 -1.0000000e+00 2.22e-16 4.09e-01 -8.6 7.35e+00 - 3.75e-01 1.00e+00h 1 + 62 -1.0000000e+00 2.22e-16 3.20e-01 -8.6 3.24e+00 - 9.93e-01 1.00e+00h 1 + 63 -1.0000000e+00 2.22e-16 3.89e-08 -8.6 2.87e-08 0.1 1.00e+00 1.00e+00h 1 + 64 -1.0000000e+00 4.44e-16 1.08e+00 -8.6 1.28e+01 - 7.64e-01 1.00e+00h 1 + 65 -1.0000000e+00 8.88e-16 1.29e+00 -8.6 5.33e+01 - 6.49e-02 9.45e-02h 2 + 66 -1.0000000e+00 5.43e-08 2.12e+00 -8.6 5.70e+01 - 3.16e-01 7.32e-01h 1 +In iteration 66, 1 Slack too small, adjusting variable bound + 67 -1.0000000e+00 5.23e-07 3.06e+00 -8.6 1.93e+02 - 5.83e-02 2.49e-01f 1 + 68 -1.0000000e+00 1.11e-16 5.52e-02 -8.6 2.26e-07 -0.3 9.18e-01 1.00e+00h 1 + 69 -1.0000000e+00 2.22e-16 3.75e+00 -8.6 1.15e+02 - 5.95e-01 1.00e+00f 1 +iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls + 70 -1.0000000e+00 1.11e-16 4.05e-08 -8.6 2.69e-07 -0.8 1.00e+00 1.00e+00h 1 + 71 -1.0000000e+00 1.42e-14 1.77e+00 -8.6 2.18e+02 - 9.64e-01 1.00e+00h 1 +In iteration 71, 1 Slack too small, adjusting variable bound + 72 -1.0000000e+00 2.43e-05 2.00e+01 -8.6 6.52e+03 - 7.82e-02 9.48e-01h 1 + 73 -1.0000000e+00 2.22e-16 1.11e-07 -8.6 2.21e-06 -1.3 1.00e+00 1.00e+00h 1 + 74 -1.0000000e+00 1.82e-12 1.75e+00 -8.6 6.45e+03 - 9.79e-01 1.00e+00h 1 + 75 -1.0000001e+00 8.53e-04 2.70e+01 -8.6 1.16e+05 - 5.29e-02 1.00e+00h 1 + 76 -1.0000000e+00 2.22e-16 4.61e-07 -8.6 2.76e-05 -1.8 1.00e+00 1.00e+00h 1 + 77 -1.0000000e+00 2.91e-11 7.21e-01 -8.6 4.86e+04 - 1.00e+00 1.00e+00h 1 + 78 -1.0000000e+00 2.91e-11 8.74e-03 -8.6 9.77e+04 - 1.00e+00 1.00e+00h 1 + 79 -1.0000000e+00 2.22e-16 9.88e-06 -8.6 2.06e+02 - 1.00e+00 1.00e+00h 1 +iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls + 80 -1.0000000e+00 2.22e-16 1.67e-11 -8.6 4.17e-01 - 1.00e+00 1.00e+00h 1 -Number of Iterations....: 49 +Number of Iterations....: 80 (scaled) (unscaled) -Objective...............: -9.9997214844108562e-01 -9.9997214844108562e-01 -Dual infeasibility......: 1.9936432244094249e-04 1.9936432244094249e-04 +Objective...............: -1.0000000311605097e+00 -1.0000000311605097e+00 +Dual infeasibility......: 1.6695200777405717e-11 1.6695200777405717e-11 Constraint violation....: 2.2204460492503131e-16 2.2204460492503131e-16 Variable bound violation: 0.0000000000000000e+00 0.0000000000000000e+00 -Complementarity.........: 1.8658407709437400e-06 1.8658407709437400e-06 -Overall NLP error.......: 1.9936432244094249e-04 1.9936432244094249e-04 +Complementarity.........: 2.5059035994014621e-09 2.5059035994014621e-09 +Overall NLP error.......: 2.5059035994014621e-09 2.5059035994014621e-09 -Number of objective function evaluations = 103 -Number of objective gradient evaluations = 51 -Number of equality constraint evaluations = 103 -Number of inequality constraint evaluations = 103 -Number of equality constraint Jacobian evaluations = 51 -Number of inequality constraint Jacobian evaluations = 51 -Number of Lagrangian Hessian evaluations = 50 -Total seconds in IPOPT = 0.060 +Number of objective function evaluations = 114 +Number of objective gradient evaluations = 81 +Number of equality constraint evaluations = 114 +Number of inequality constraint evaluations = 114 +Number of equality constraint Jacobian evaluations = 81 +Number of inequality constraint Jacobian evaluations = 81 +Number of Lagrangian Hessian evaluations = 80 +Total seconds in IPOPT = 0.072 -EXIT: Error in step computation!
primal_status(model)
UNKNOWN_RESULT_STATUS::ResultStatusCode = 8
termination_status(model)
NUMERICAL_ERROR::TerminationStatusCode = 20

Results

objective_value(model)
-0.9999721484410856
value.(x)
7-element Vector{Float64}:
- 5.0357292625440446e-6
- 2.8142410495600284e-8
- 3.3861353311607703e-6
- 5.020742807870395e-6
- 3.966504827341139e-6
- 4.043631654789277e-6
- 4.059292918624134e-6
value.(ya)
7-element Vector{Float64}:
- 0.9999949637481971
- 0.9999999704739196
- 0.9999966133461757
- 0.9999949787346272
- 0.9999960329744421
- 0.9999959558478139
- 0.9999959401865884
value.(yb)
7-element Vector{Float64}:
- 5.036251802956509e-6
- 2.9526080347917004e-8
- 3.386653824266946e-6
- 5.02126537276935e-6
- 3.9670255580268e-6
- 4.044152186150745e-6
- 4.05981341157427e-6
value(z)
0.9999976886202985
Info

View this file on Github.


This page was generated using Literate.jl.

+EXIT: Optimal Solution Found.
primal_status(model)
FEASIBLE_POINT::ResultStatusCode = 1
termination_status(model)
LOCALLY_SOLVED::TerminationStatusCode = 4

Results

objective_value(model)
-1.0000000311605097
value.(x)
7-element Vector{Float64}:
+ -2.9767438448894604e-9
+ -4.095847321577771e-9
+ -4.963502668013705e-9
+ -2.976743832423524e-9
+ -4.09584735304892e-9
+ -4.095847344657848e-9
+ -4.095847335609968e-9
value.(ya)
7-element Vector{Float64}:
+ 1.0000000043870785
+ 1.0000000057790928
+ 1.0000000068664787
+ 1.0000000043870787
+ 1.0000000057790928
+ 1.0000000057790928
+ 1.0000000057790928
value.(yb)
7-element Vector{Float64}:
+ -4.387078612662699e-9
+ -5.779092799400647e-9
+ -6.86647860749047e-9
+ -4.387078596982346e-9
+ -5.779092838463998e-9
+ -5.7790928280564376e-9
+ -5.779092816833792e-9
value(z)
1.00000000386013
Info

View this file on Github.


This page was generated using Literate.jl.

diff --git a/dev/examples/FOBP_example4/index.html b/dev/examples/FOBP_example4/index.html index 1fd2c38..dd23de2 100644 --- a/dev/examples/FOBP_example4/index.html +++ b/dev/examples/FOBP_example4/index.html @@ -75,8 +75,8 @@ Number of equality constraint Jacobian evaluations = 21 Number of inequality constraint Jacobian evaluations = 21 Number of Lagrangian Hessian evaluations = 20 -Total seconds in IPOPT = 0.009 +Total seconds in IPOPT = 0.007 EXIT: Optimal Solution Found.
primal_status(model)
FEASIBLE_POINT::ResultStatusCode = 1
termination_status(model)
LOCALLY_SOLVED::TerminationStatusCode = 4

Results

objective_value(model)
-1.7826027345370235e-8
value(x)
1.0331931011799034e-8
value(y)
 
-atol = 1e-3 # src
0.001
Info

View this file on Github.


This page was generated using Literate.jl.

+atol = 1e-3 # src
0.001
Info

View this file on Github.


This page was generated using Literate.jl.

diff --git a/dev/examples/FOBP_example5/index.html b/dev/examples/FOBP_example5/index.html index 56d0798..6f5058e 100644 --- a/dev/examples/FOBP_example5/index.html +++ b/dev/examples/FOBP_example5/index.html @@ -55,31 +55,33 @@ 14 0.0000000e+00 2.96e-04 6.01e+05 -1.0 1.11e-04 - 1.00e+00 6.70e-01h 1 15 0.0000000e+00 5.74e-05 6.07e+05 -1.0 3.68e-05 - 1.00e+00 8.06e-01h 1 16 0.0000000e+00 3.04e-05 1.70e+06 -1.0 7.14e-06 - 1.00e+00 4.71e-01f 2 - 17 0.0000000e+00 5.56e-07 4.14e+04 -1.0 3.78e-06 - 1.00e+00 9.82e-01h 1 + 17 0.0000000e+00 5.56e-07 4.14e+04 -1.0 3.77e-06 - 1.00e+00 9.82e-01h 1 18 0.0000000e+00 4.89e-07 9.77e+06 -1.0 2.78e-07 - 1.00e+00 1.22e-01f 2 - 19 0.0000000e+00 0.00e+00 6.07e-02 -1.0 8.14e-08 - 1.00e+00 1.00e+00h 1 + 19 0.0000000e+00 0.00e+00 6.07e-02 -1.0 6.83e-08 - 1.00e+00 1.00e+00h 1 iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls - 20 0.0000000e+00 0.00e+00 1.83e-03 -8.6 2.15e-11 - 1.00e+00 1.00e+00h 1 - 21 0.0000000e+00 0.00e+00 6.82e-10 -8.6 1.09e-09 - 1.00e+00 1.00e+00h 1 + 20 0.0000000e+00 0.00e+00 2.77e-01 -8.6 3.26e-09 - 1.00e+00 1.00e+00h 1 + 21 0.0000000e+00 1.11e-16 2.03e-08 -8.6 3.20e-08 - 1.00e+00 1.00e+00h 1 + 22 0.0000000e+00 0.00e+00 1.71e-08 -9.0 1.26e-08 - 1.00e+00 1.00e+00h 1 + 23 0.0000000e+00 0.00e+00 9.22e-15 -9.0 1.98e-08 - 1.00e+00 1.00e+00h 1 -Number of Iterations....: 21 +Number of Iterations....: 23 (scaled) (unscaled) Objective...............: 0.0000000000000000e+00 0.0000000000000000e+00 -Dual infeasibility......: 6.8225529429926481e-10 6.8225529429926481e-10 +Dual infeasibility......: 9.2176807238282207e-15 9.2176807238282207e-15 Constraint violation....: 0.0000000000000000e+00 0.0000000000000000e+00 -Variable bound violation: 3.7777407619505770e-09 3.7777407619505770e-09 -Complementarity.........: 2.5059184508964432e-09 2.5059184508964432e-09 -Overall NLP error.......: 2.5059184508964432e-09 2.5059184508964432e-09 +Variable bound violation: 3.7777777369972728e-09 3.7777777369972728e-09 +Complementarity.........: 9.0909091519652535e-10 9.0909091519652535e-10 +Overall NLP error.......: 9.0909091519652535e-10 9.0909091519652535e-10 -Number of objective function evaluations = 24 -Number of objective gradient evaluations = 22 -Number of equality constraint evaluations = 24 -Number of inequality constraint evaluations = 24 -Number of equality constraint Jacobian evaluations = 22 -Number of inequality constraint Jacobian evaluations = 22 -Number of Lagrangian Hessian evaluations = 21 -Total seconds in IPOPT = 0.008 +Number of objective function evaluations = 26 +Number of objective gradient evaluations = 24 +Number of equality constraint evaluations = 26 +Number of inequality constraint evaluations = 26 +Number of equality constraint Jacobian evaluations = 24 +Number of inequality constraint Jacobian evaluations = 24 +Number of Lagrangian Hessian evaluations = 23 +Total seconds in IPOPT = 0.009 -EXIT: Optimal Solution Found.
primal_status(model)
FEASIBLE_POINT::ResultStatusCode = 1
termination_status(model)
LOCALLY_SOLVED::TerminationStatusCode = 4
value(x)
-2.500000001499996
value(y)
1.225875404291898e-15
Info

View this file on Github.


This page was generated using Literate.jl.

+EXIT: Optimal Solution Found.
primal_status(model)
FEASIBLE_POINT::ResultStatusCode = 1
termination_status(model)
LOCALLY_SOLVED::TerminationStatusCode = 4
value(x)
-2.5000000015
value(y)
9.247588969944264e-17
Info

View this file on Github.


This page was generated using Literate.jl.

diff --git a/dev/examples/MibS_example1/index.html b/dev/examples/MibS_example1/index.html index 5f6aefd..86a8c10 100644 --- a/dev/examples/MibS_example1/index.html +++ b/dev/examples/MibS_example1/index.html @@ -34,4 +34,4 @@ @test solution.nonzero_upper == Dict(0 => 6.0) @test solution.nonzero_lower == Dict(0 => 5.0) @test solution.all_upper["x"] == 6.0 -@test solution.all_lower["y"] == 5.0
Test Passed
Info

View this file on Github.


This page was generated using Literate.jl.

+@test solution.all_lower["y"] == 5.0
Test Passed
Info

View this file on Github.


This page was generated using Literate.jl.

diff --git a/dev/examples/MibS_example2/index.html b/dev/examples/MibS_example2/index.html index 1070e05..98aa76a 100644 --- a/dev/examples/MibS_example2/index.html +++ b/dev/examples/MibS_example2/index.html @@ -36,4 +36,4 @@ @test solution.nonzero_lower == Dict(0 => 5.0) @test solution.all_upper["x"] == 6.0 @test solution.all_upper["z"] == 0 -@test solution.all_lower["y"] == 5.0
Test Passed
Info

View this file on Github.


This page was generated using Literate.jl.

+@test solution.all_lower["y"] == 5.0
Test Passed
Info

View this file on Github.


This page was generated using Literate.jl.

diff --git a/dev/examples/PHTP_example1/index.html b/dev/examples/PHTP_example1/index.html index 628dac1..49e9fa5 100644 --- a/dev/examples/PHTP_example1/index.html +++ b/dev/examples/PHTP_example1/index.html @@ -65,15 +65,15 @@ 21 1.7086922e+01 3.33e-08 8.74e+04 -1.0 5.85e-04 - 1.00e+00 9.88e-01h 1 22 1.7086849e+01 1.08e-07 6.99e+06 -1.0 1.11e-03 - 1.00e+00 5.49e-02f 2 23 1.7086696e+01 1.66e-09 3.81e+05 -1.0 1.36e-04 - 1.00e+00 9.47e-01h 1 - 24 1.7085702e+01 1.05e-09 2.11e+06 -1.0 2.26e-03 - 1.00e+00 3.69e-01f 2 - 25 1.7083926e+01 0.00e+00 3.59e+03 -1.0 1.50e-03 - 1.00e+00 1.00e+00h 1 - 26 1.7018660e+01 6.66e-16 3.12e+05 -2.5 6.08e-02 - 1.00e+00 1.00e+00f 1 - 27 1.7003709e+01 2.22e-16 1.30e+03 -2.5 1.60e-02 - 1.00e+00 1.00e+00f 1 - 28 1.7002810e+01 4.44e-16 7.98e-01 -2.5 9.96e-04 - 1.00e+00 1.00e+00f 1 - 29 1.7000041e+01 6.66e-16 4.53e+02 -5.7 3.09e-03 - 1.00e+00 1.00e+00f 1 + 24 1.7085701e+01 1.05e-09 2.10e+06 -1.0 2.26e-03 - 1.00e+00 3.70e-01f 2 + 25 1.7083927e+01 0.00e+00 3.59e+03 -1.0 1.49e-03 - 1.00e+00 1.00e+00h 1 + 26 1.7018660e+01 2.22e-16 3.12e+05 -2.5 6.08e-02 - 1.00e+00 1.00e+00f 1 + 27 1.7003709e+01 4.44e-16 1.30e+03 -2.5 1.60e-02 - 1.00e+00 1.00e+00f 1 + 28 1.7002810e+01 2.22e-16 7.95e-01 -2.5 9.96e-04 - 1.00e+00 1.00e+00f 1 + 29 1.7000041e+01 2.22e-16 4.53e+02 -5.7 3.09e-03 - 1.00e+00 1.00e+00f 1 iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls 30 1.7000002e+01 4.44e-16 5.14e-03 -5.7 4.42e-05 - 1.00e+00 1.00e+00f 1 - 31 1.7000002e+01 2.22e-16 7.67e-09 -5.7 8.06e-09 - 1.00e+00 1.00e+00h 1 + 31 1.7000002e+01 4.44e-16 7.67e-09 -5.7 8.06e-09 - 1.00e+00 1.00e+00h 1 32 1.7000000e+01 2.22e-16 3.22e+00 -8.6 2.07e-06 - 9.90e-01 1.00e+00f 1 33 1.7000000e+01 2.22e-16 9.00e-09 -8.6 5.65e-08 - 1.00e+00 1.00e+00h 1 @@ -81,11 +81,11 @@ (scaled) (unscaled) Objective...............: 1.6999999980907578e+01 1.6999999980907578e+01 -Dual infeasibility......: 8.9958795967959304e-09 8.9958795967959304e-09 +Dual infeasibility......: 8.9958831495096092e-09 8.9958831495096092e-09 Constraint violation....: 2.2204460492503131e-16 2.2204460492503131e-16 -Variable bound violation: 4.0833333485561426e-09 4.0833333485561426e-09 -Complementarity.........: 4.8883842466693959e-09 4.8883842466693959e-09 -Overall NLP error.......: 8.9958795967959304e-09 8.9958795967959304e-09 +Variable bound violation: 4.0833333485561435e-09 4.0833333485561435e-09 +Complementarity.........: 4.8883842466698459e-09 4.8883842466698459e-09 +Overall NLP error.......: 8.9958831495096092e-09 8.9958831495096092e-09 Number of objective function evaluations = 38 @@ -97,4 +97,4 @@ Number of Lagrangian Hessian evaluations = 33 Total seconds in IPOPT = 0.012 -EXIT: Optimal Solution Found.
primal_status(model)
FEASIBLE_POINT::ResultStatusCode = 1
termination_status(model)
LOCALLY_SOLVED::TerminationStatusCode = 4
value(x)
0.9999999983262665
value(y)
-8.120572244645419e-9
Info

View this file on Github.


This page was generated using Literate.jl.

+EXIT: Optimal Solution Found.
primal_status(model)
FEASIBLE_POINT::ResultStatusCode = 1
termination_status(model)
LOCALLY_SOLVED::TerminationStatusCode = 4
value(x)
0.9999999983262665
value(y)
-8.120572244645425e-9
Info

View this file on Github.


This page was generated using Literate.jl.

diff --git a/dev/examples/PHTP_example2/index.html b/dev/examples/PHTP_example2/index.html index c88ac84..7a35efa 100644 --- a/dev/examples/PHTP_example2/index.html +++ b/dev/examples/PHTP_example2/index.html @@ -75,25 +75,25 @@ 23 1.9573024e-01 1.02e-03 4.02e+06 -1.0 8.16e-04 - 1.00e+00 4.36e-02f 5 24 1.9569163e-01 1.11e-04 7.43e+05 -1.0 7.92e-04 - 1.00e+00 8.91e-01h 1 25 1.9645947e-01 8.32e-05 5.40e+06 -1.0 2.01e-03 - 1.00e+00 2.51e-01f 2 - 26 1.9874099e-01 1.42e-14 6.83e+02 -1.0 1.51e-03 - 1.00e+00 1.00e+00h 1 - 27 6.8772523e-03 1.42e-14 8.22e+04 -2.5 9.71e-02 - 1.00e+00 1.00e+00f 1 + 26 1.9874099e-01 7.11e-15 6.83e+02 -1.0 1.51e-03 - 1.00e+00 1.00e+00h 1 + 27 6.8772523e-03 0.00e+00 8.22e+04 -2.5 9.71e-02 - 1.00e+00 1.00e+00f 1 28 5.6568726e-03 7.11e-15 3.16e+00 -2.5 1.19e-03 - 1.00e+00 1.00e+00f 1 29 3.0104856e-04 1.42e-14 6.46e+01 -3.8 2.68e-03 - 1.00e+00 1.00e+00f 1 iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls 30 3.0100656e-04 0.00e+00 7.46e-07 -3.8 2.57e-07 - 1.00e+00 1.00e+00h 1 31 1.6349148e-07 1.42e-14 5.98e+00 -8.6 1.50e-04 - 1.00e+00 1.00e+00f 1 - 32 -3.6260538e-08 2.58e-14 5.60e-03 -8.6 2.01e-06 - 1.00e+00 9.89e-01h 1 - 33 -3.2290178e-08 1.42e-14 1.03e-12 -8.6 3.05e-08 - 1.00e+00 1.00e+00f 1 + 32 -3.6259763e-08 2.58e-14 5.60e-03 -8.6 2.01e-06 - 1.00e+00 9.89e-01h 1 + 33 -3.2290163e-08 1.42e-14 1.03e-12 -8.6 3.05e-08 - 1.00e+00 1.00e+00f 1 Number of Iterations....: 33 (scaled) (unscaled) -Objective...............: -3.2290177642835260e-08 -3.2290177642835260e-08 -Dual infeasibility......: 1.0289546992225951e-12 1.0289546992225951e-12 +Objective...............: -3.2290163431980545e-08 -3.2290163431980545e-08 +Dual infeasibility......: 1.0293987884324451e-12 1.0293987884324451e-12 Constraint violation....: 1.4210854715202004e-14 1.4210854715202004e-14 -Variable bound violation: 4.8166666662694811e-09 4.8166666662694811e-09 -Complementarity.........: 2.5157965850181528e-09 2.5157965850181528e-09 -Overall NLP error.......: 2.5157965850181528e-09 2.5157965850181528e-09 +Variable bound violation: 4.8166666662694820e-09 4.8166666662694820e-09 +Complementarity.........: 2.5157965850181507e-09 2.5157965850181507e-09 +Overall NLP error.......: 2.5157965850181507e-09 2.5157965850181507e-09 Number of objective function evaluations = 40 @@ -103,10 +103,10 @@ Number of equality constraint Jacobian evaluations = 34 Number of inequality constraint Jacobian evaluations = 34 Number of Lagrangian Hessian evaluations = 33 -Total seconds in IPOPT = 0.014 +Total seconds in IPOPT = 0.015 -EXIT: Optimal Solution Found.
primal_status(model)
FEASIBLE_POINT::ResultStatusCode = 1
termination_status(model)
LOCALLY_SOLVED::TerminationStatusCode = 4
objective_value(model)
-3.229017764283526e-8
value.(x)
2-element Vector{Float64}:
+EXIT: Optimal Solution Found.
primal_status(model)
FEASIBLE_POINT::ResultStatusCode = 1
termination_status(model)
LOCALLY_SOLVED::TerminationStatusCode = 4
objective_value(model)
-3.2290163431980545e-8
value.(x)
2-element Vector{Float64}:
  -8.747048220055642e-9
  -8.747048220161989e-9
value.(y)
2-element Vector{Float64}:
- -10.000000000634337
- -10.000000000265

Like any other optimization problem, there is a chance in bilevel

optimization to find multiple solutions with the same optimal value; based on the inherent stochasticity of the algorithm and random seed, we are expecting two optimal solutions for this problem.

Info

View this file on Github.


This page was generated using Literate.jl.

+ -10.000000000634342 + -10.000000000265

Like any other optimization problem, there is a chance in bilevel

optimization to find multiple solutions with the same optimal value; based on the inherent stochasticity of the algorithm and random seed, we are expecting two optimal solutions for this problem.

Info

View this file on Github.


This page was generated using Literate.jl.

diff --git a/dev/examples/SOCBLP_example1/index.html b/dev/examples/SOCBLP_example1/index.html index 8bff2b3..d90f232 100644 --- a/dev/examples/SOCBLP_example1/index.html +++ b/dev/examples/SOCBLP_example1/index.html @@ -51,5 +51,5 @@ objective_value(model) value.(y)
2-element Vector{Float64}:
- 2.0039420275412656
- 0.003942096460678376
Info

View this file on Github.


This page was generated using Literate.jl.

+ 2.003942027113088 + 0.003942096032501202
Info

View this file on Github.


This page was generated using Literate.jl.

diff --git a/dev/examples/mibs_output.txt b/dev/examples/mibs_output.txt index f332998..60eaf45 100644 --- a/dev/examples/mibs_output.txt +++ b/dev/examples/mibs_output.txt @@ -17,16 +17,16 @@ Build Date: Jun 18 2021 == Distributed under the Eclipse Public License 1.0 == Version: 1.5 == Build Date: Dec 4 2021 -Alps0030I Data file: /tmp/jl_B25NnK/model.mps +Alps0030I Data file: /tmp/jl_wC7P9P/model.mps Coin0001I At line 1 NAME Coin0001I At line 2 ROWS Coin0001I At line 10 COLUMNS -Coin0001I At line 27 RHS -Coin0001I At line 34 RANGES -Coin0001I At line 35 BOUNDS -Coin0001I At line 39 ENDATA +Coin0001I At line 28 RHS +Coin0001I At line 35 RANGES +Coin0001I At line 36 BOUNDS +Coin0001I At line 40 ENDATA Coin0002I Problem no_name has 6 rows, 3 columns and 12 elements -LL Data File: /tmp/jl_B25NnK/model.aux +LL Data File: /tmp/jl_wC7P9P/model.aux Number of LL Variables: 1 ======================================= @@ -72,11 +72,11 @@ Alps0267I Number of nodes branched: 17 Alps0268I Number of nodes pruned before processing: 0 Alps0270I Number of nodes left: 0 Alps0272I Tree depth: 9 -Alps0274I Search CPU time: 0.02 seconds +Alps0274I Search CPU time: 0.01 seconds Alps0278I Search wall-clock time: 0.01 seconds Blis0040I Checking feasibility took 0.0034 seconds -Blis0053I Called MIBS cut generator 42 times, generated 21 cuts, CPU time 0.0003 seconds, current strategy 3 -Blis0063I Called Rounding heuristic 84 times, found 0 solutions, CPU time 0.0004 seconds, current strategy 2 +Blis0053I Called MIBS cut generator 42 times, generated 21 cuts, CPU time 0.0000 seconds, current strategy 3 +Blis0063I Called Rounding heuristic 84 times, found 0 solutions, CPU time 0.0000 seconds, current strategy 2 Blis0058I Relative optimality gap is 0.00% ============================================ Optimal solution: @@ -85,6 +85,6 @@ x[0] = 6 y[0] = 5 Number of problems (VF) solved = 12 Number of problems (UB) solved = 0 -Time for solving problem (VF) = 0.00234032 +Time for solving problem (VF) = 0.00236678 Time for solving problem (UB) = 0 ============================================ diff --git a/dev/index.html b/dev/index.html index 68d0e03..74d0214 100644 --- a/dev/index.html +++ b/dev/index.html @@ -8,4 +8,4 @@ doi={https://doi.org/10.1287/ijoc.2022.0135}, pages={1-9}, year={2023} -}

Here is an earlier preprint.

+}

Here is an earlier preprint.

diff --git a/dev/manual/index.html b/dev/manual/index.html index 7c87548..4cc2e72 100644 --- a/dev/manual/index.html +++ b/dev/manual/index.html @@ -1,2 +1,2 @@ -Manual · BilevelJuMP.jl
+Manual · BilevelJuMP.jl
diff --git a/dev/reference/index.html b/dev/reference/index.html index 7090179..18ab10b 100644 --- a/dev/reference/index.html +++ b/dev/reference/index.html @@ -7,14 +7,14 @@ julia> BilevelJuMP.set_solver(model, HiGHS.Optimizer) -julia> BilevelJuMP.set_mode(model, BilevelJuMP.FortunyAmatMcCarlMode(primal_big_M = 1e6, dual_big_M = 1e6))source
BilevelJuMP.UpperFunction
Upper(model::BilevelModel)

Create a reference to the upper level of a bilevel model.

Example

julia> model = BilevelModel();
+julia> BilevelJuMP.set_mode(model, BilevelJuMP.FortunyAmatMcCarlMode(primal_big_M = 1e6, dual_big_M = 1e6))
source
BilevelJuMP.UpperFunction
Upper(model::BilevelModel)

Create a reference to the upper level of a bilevel model.

Example

julia> model = BilevelModel();
 
-julia> @variable(Upper(model), x >= 0)
source
BilevelJuMP.LowerFunction
Lower(model::BilevelModel)

Create a reference to the lower level of a bilevel model.

Example

julia> model = BilevelModel();
+julia> @variable(Upper(model), x >= 0)
source
BilevelJuMP.LowerFunction
Lower(model::BilevelModel)

Create a reference to the lower level of a bilevel model.

Example

julia> model = BilevelModel();
 
-julia> @variable(Lower(model), x >= 0)
source
BilevelJuMP.DualOfType
DualOf(constraint::ConstraintRef)

Get the dual variable associated with a constraint. This is only valid for constraints in the upper level of a bilevel model.

Examples

julia> m = BilevelModel();
+julia> @variable(Lower(model), x >= 0)
source
BilevelJuMP.DualOfType
DualOf(constraint::ConstraintRef)

Get the dual variable associated with a constraint. This is only valid for constraints in the upper level of a bilevel model.

Examples

julia> m = BilevelModel();
 
 julia> @variable(Lower(m), x >= 0);
 
 julia> @constraint(Lower(m), c, x <= 1);
 
-julia> @variable(Upper(m), y, DualOf(c));
source

Advanced constructors

BilevelJuMP.UpperOnlyFunction
UpperOnly(model::BilevelModel)

Create a special reference to the upper level of a bilevel model. Variables created with this reference will not be shared with the lower level.

source
BilevelJuMP.LowerOnlyFunction
LowerOnly(model::BilevelModel)

Create a special reference to the lower level of a bilevel model. Variables created with this reference will not be shared with the upper level.

source

Enums

BilevelJuMP.LevelType
Level

The level of a variable in a bilevel problem.

source
BilevelJuMP.LOWER_BOTHConstant

Indicates and object that is part of the lower level problem, but is shared with the upper level.

source
BilevelJuMP.UPPER_BOTHConstant

Indicates and object that is part of the upper level problem, but is shared with the lower level.

source
BilevelJuMP.LOWER_ONLYConstant

Indicates and object that is part of the lower level problem, but is not shared with the upper level.

source
BilevelJuMP.UPPER_ONLYConstant

Indicates and object that is part of the upper level problem, but is not shared with the lower level.

source
BilevelJuMP.DUAL_OF_LOWERConstant

Indicates and object that is part of the dual of the lower level problem, and is shared with the upper level.

source
BilevelJuMP.IndicatorSettingType
IndicatorSetting

The type of indicator function to use in the IndicatorMode mode.

source
BilevelJuMP.ZERO_ONEConstant

Activates the indicator constraint on the primal constraint if the auxiliaty binary is zero and activates the indicator constraint on the dual variable if the auxiliary binary is one.

source
BilevelJuMP.ZERO_ZEROConstant

Activates the indicator constraint on the primal constraint if the auxiliaty binary is zero and activates the indicator constraint on the dual variable if the auxiliary binary is zero.

source
BilevelJuMP.ONE_ONEConstant

Activates the indicator constraint on the primal constraint if the auxiliaty binary is one and activates the indicator constraint on the dual variable if the auxiliary binary is one.

source

Structs

BilevelJuMP.BilevelVariableRefType
BilevelVariableRef

Holds a reference to a variable in a bilevel model.

source
BilevelJuMP.BilevelAffExprType
BilevelVariableRef

Alias for GenericAffExpr{Float64,BilevelVariableRef}.

source
BilevelJuMP.BilevelQuadExprType
BilevelQuadExpr

Alias for GenericQuadExpr{Float64,BilevelVariableRef}.

source

Modes

BilevelJuMP.SOS1ModeType
SOS1Mode()

Used to solve a bilevel problem with the MPEC reformulation using SOS1 constraints to convert complementarity constraints into mixed-integer constraints.

source
BilevelJuMP.FortunyAmatMcCarlModeType
FortunyAmatMcCarlMode

See BigMMode for more details.

source
BilevelJuMP.IndicatorModeType
IndicatorMode(method::IndicatorSetting = BilevelJuMP.ONE_ONE)

Used to solve a bilevel problem with the MPEC reformulation using indicator constaints to convert complementarity constraints to a mixed integer formulation.

  • method indicates how the indicator constraints are activated for primal cosntraints and dual variables. See IndicatorSetting for more details.
source
BilevelJuMP.ProductModeType
ProductMode(epsilon = 0.0; with_slack = false, aggregation_group = nothing)

Used to solve a bilevel problem with the MPEC reformulation using products to convert complementarity constraints into non-convex quadratic constraints.

  • with_slack indicates whether to use slack variables to reformulate the complementarity constraints. Given a pair expr and var, the reformulation is expr == slack and var * slack == 0 instead of expr * slack == 0.

  • aggregation_group indicates whether to aggregate the products into a single quadratic constraint. If aggregation_group is nothing, then each product is converted into a quadratic constraint. If aggregation_group is a positive integer, then products with the same aggregation_group are aggregated into a single quadratic constraint.

source
BilevelJuMP.StrongDualityModeType
StrongDualityMode(eps = 0.0, inequality = true)

A mode that adds a strong duality constraint of the lower level problem instead of reformulating the complementarity constraints.

  • eps: The tolerance for the strong duality constraint. Defaults to 0.0.

  • inequality: If true the strong duality constraint is added as two inequality constraints. If false the strong duality constraint is added as an equality constraint. Defaults to true.

source
BilevelJuMP.ComplementModeType
ComplementMode(; with_slack = false)

Used to solve a bilevel problem with the MPEC reformulation using actual complementarity constraints. A limited number of solvers support this mode. One example is Knitro.

  • with_slack indicates whether to use slack variables to reformulate the complementarity constraints. Given a pair expr and var, the reformulation is expr == slack and var ⟂ slack instead of expr ⟂ slack.
source
BilevelJuMP.MixedModeType
MixedMode(; default = SOS1Mode())

A mode that allows to mix different modes for different constraints and variables.

  • default is the default mode to use for all constraints and variables that are not explicitly mapped to a mode.
source

Bound hints

BilevelJuMP.set_dual_upper_bound_hintFunction
set_dual_upper_bound_hint(cref, value)

Set a upper bound to the dual variable of the constraint cref to value. This bound will not be dualized. The dual upper bound hint is used to help the solution method.

Solution modes can be benefitted from this hint:

  • BigMMode will use this information to compute a tighter bound for the dual variable.

  • Other modes will be stabilized by the existence of the bounds on variables that would otherwise no be bounded.

  • Bounds that are not dualized are also useful for binary expansions of products of variables that can be done with QuadraticToBinary.jl.

source
BilevelJuMP.get_dual_upper_bound_hintFunction
get_dual_upper_bound_hint(cref)

Get the upper bound to the dual variable of the constraint cref that was set with set_dual_upper_bound_hint.

source
BilevelJuMP.set_dual_lower_bound_hintFunction
set_dual_lower_bound_hint(cref, value)

Set a lower bound to the dual variable of the constraint cref to value. This bound will not be dualized. The dual lower bound hint is used to help the solution method.

Solution modes can be benefitted from this hint:

  • BigMMode will use this information to compute a tighter bound for the dual variable.

  • Other modes will be stabilized by the existence of the bounds on variables that would otherwise no be bounded.

  • Bounds that are not dualized are also useful for binary expansions of products of variables that can be done with QuadraticToBinary.jl.

source
BilevelJuMP.get_dual_lower_bound_hintFunction
get_dual_lower_bound_hint(cref)

Get the lower bound to the dual variable of the constraint cref that was set with set_dual_lower_bound_hint.

source
BilevelJuMP.set_primal_upper_bound_hintFunction
set_primal_upper_bound_hint(vref, value)

Set a upper bound to the prima variable vref to value. This bound will not be dualized. The upper bound hint is used to help the solution method.

Solution modes can be benefitted from this hint:

  • BigMMode will use this information to compute a tighter bound for the primal constraint variable.

  • Other modes will be stabilized by the existence of the bounds on variables that would otherwise no be bounded.

  • Bounds that are not dualized are also useful for binary expansions of products of variables that can be done with QuadraticToBinary.jl.

source
BilevelJuMP.get_primal_upper_bound_hintFunction
get_primal_upper_bound_hint(cref)

Get the upper bound to the primal variable of the constraint cref that was set with set_primal_upper_bound_hint.

source
BilevelJuMP.set_primal_lower_bound_hintFunction
set_primal_lower_bound_hint(vref, value)

Set a lower bound to the prima variable vref to value. This bound will not be dualized. The lower bound hint is used to help the solution method.

Solution modes can be benefitted from this hint:

  • BigMMode will use this information to compute a tighter bound for the primal constraint variable.

  • Other modes will be stabilized by the existence of the bounds on variables that would otherwise no be bounded.

  • Bounds that are not dualized are also useful for binary expansions of products of variables that can be done with QuadraticToBinary.jl.

source
BilevelJuMP.get_primal_lower_bound_hintFunction
get_primal_lower_bound_hint(cref)

Get the lower bound to the primal variable of the constraint cref that was set with set_primal_lower_bound_hint.

source

Attributes getters and setters

BilevelJuMP.lower_objective_valueFunction
lower_objective_value(model::BilevelModel; result::Int = 1)

Return the value of the objective function of the lower level problem.

source
BilevelJuMP.build_timeFunction
build_time(model::BilevelModel)

Return the time it took to build the model.

source
BilevelJuMP.set_modeFunction
set_mode(bm::BilevelModel, mode::AbstractBilevelSolverMode)

Set the mode of a bilevel model.

source
set_mode(ci::BilevelVariableRef, mode::AbstractBilevelSolverMode)

Set the mode of a constraint. This is used in MixedMode reformulations.

source
set_mode(vi::BilevelVariableRef, mode::AbstractBilevelSolverMode)

Set the mode of the bounds of a variable. This is used in MixedMode reformulations.

source
BilevelJuMP.get_modeFunction
get_mode(ci::BilevelConstraintRef)

Get the mode of a constraint. This is used in MixedMode reformulations.

source
get_mode(vi::BilevelVariableRef)

Get the mode of the bounds of a variable. This is used in MixedMode reformulations.

source
BilevelJuMP.unset_modeFunction
unset_mode(ci::BilevelConstraintRef)

Unset the mode of a constraint. This will use the default mode for the constraint. This is used in MixedMode reformulations.

source
unset_mode(vi::BilevelVariableRef)

Unset the mode of the bounds of a variable. This will use the default mode for the bounds. This is used in MixedMode reformulations.

source
BilevelJuMP.set_copy_namesFunction
set_copy_names(model::BilevelModel)

Set the copy_names attribute of the solver to true.

source
BilevelJuMP.get_copy_namesFunction
get_copy_names(model::BilevelModel)

Return the value of the copy_names attribute of the solver.

source
BilevelJuMP.unset_copy_namesFunction
unset_copy_names(model::BilevelModel)

Set the copy_names attribute of the solver to false.

source
BilevelJuMP.set_pass_startFunction
set_pass_start(model::BilevelModel)

Activate passing start values (both primal and dual) to the solver.

source
BilevelJuMP.get_pass_startFunction
get_pass_start(model::BilevelModel)

Checks if passing start values (both primal and dual) to the solver is activated.

source
BilevelJuMP.unset_pass_startFunction
unset_pass_start(model::BilevelModel)

Deactivate passing start values (both primal and dual) to the solver.

source
+julia> @variable(Upper(m), y, DualOf(c));source

Advanced constructors

BilevelJuMP.UpperOnlyFunction
UpperOnly(model::BilevelModel)

Create a special reference to the upper level of a bilevel model. Variables created with this reference will not be shared with the lower level.

source
BilevelJuMP.LowerOnlyFunction
LowerOnly(model::BilevelModel)

Create a special reference to the lower level of a bilevel model. Variables created with this reference will not be shared with the upper level.

source

Enums

BilevelJuMP.LevelType
Level

The level of a variable in a bilevel problem.

source
BilevelJuMP.LOWER_BOTHConstant

Indicates and object that is part of the lower level problem, but is shared with the upper level.

source
BilevelJuMP.UPPER_BOTHConstant

Indicates and object that is part of the upper level problem, but is shared with the lower level.

source
BilevelJuMP.LOWER_ONLYConstant

Indicates and object that is part of the lower level problem, but is not shared with the upper level.

source
BilevelJuMP.UPPER_ONLYConstant

Indicates and object that is part of the upper level problem, but is not shared with the lower level.

source
BilevelJuMP.DUAL_OF_LOWERConstant

Indicates and object that is part of the dual of the lower level problem, and is shared with the upper level.

source
BilevelJuMP.IndicatorSettingType
IndicatorSetting

The type of indicator function to use in the IndicatorMode mode.

source
BilevelJuMP.ZERO_ONEConstant

Activates the indicator constraint on the primal constraint if the auxiliaty binary is zero and activates the indicator constraint on the dual variable if the auxiliary binary is one.

source
BilevelJuMP.ZERO_ZEROConstant

Activates the indicator constraint on the primal constraint if the auxiliaty binary is zero and activates the indicator constraint on the dual variable if the auxiliary binary is zero.

source
BilevelJuMP.ONE_ONEConstant

Activates the indicator constraint on the primal constraint if the auxiliaty binary is one and activates the indicator constraint on the dual variable if the auxiliary binary is one.

source

Structs

BilevelJuMP.BilevelVariableRefType
BilevelVariableRef

Holds a reference to a variable in a bilevel model.

source
BilevelJuMP.BilevelAffExprType
BilevelVariableRef

Alias for GenericAffExpr{Float64,BilevelVariableRef}.

source
BilevelJuMP.BilevelQuadExprType
BilevelQuadExpr

Alias for GenericQuadExpr{Float64,BilevelVariableRef}.

source

Modes

BilevelJuMP.SOS1ModeType
SOS1Mode()

Used to solve a bilevel problem with the MPEC reformulation using SOS1 constraints to convert complementarity constraints into mixed-integer constraints.

source
BilevelJuMP.FortunyAmatMcCarlModeType
FortunyAmatMcCarlMode

See BigMMode for more details.

source
BilevelJuMP.IndicatorModeType
IndicatorMode(method::IndicatorSetting = BilevelJuMP.ONE_ONE)

Used to solve a bilevel problem with the MPEC reformulation using indicator constaints to convert complementarity constraints to a mixed integer formulation.

  • method indicates how the indicator constraints are activated for primal cosntraints and dual variables. See IndicatorSetting for more details.
source
BilevelJuMP.ProductModeType
ProductMode(epsilon = 0.0; with_slack = false, aggregation_group = nothing)

Used to solve a bilevel problem with the MPEC reformulation using products to convert complementarity constraints into non-convex quadratic constraints.

  • with_slack indicates whether to use slack variables to reformulate the complementarity constraints. Given a pair expr and var, the reformulation is expr == slack and var * slack == 0 instead of expr * slack == 0.

  • aggregation_group indicates whether to aggregate the products into a single quadratic constraint. If aggregation_group is nothing, then each product is converted into a quadratic constraint. If aggregation_group is a positive integer, then products with the same aggregation_group are aggregated into a single quadratic constraint.

source
BilevelJuMP.StrongDualityModeType
StrongDualityMode(eps = 0.0, inequality = true)

A mode that adds a strong duality constraint of the lower level problem instead of reformulating the complementarity constraints.

  • eps: The tolerance for the strong duality constraint. Defaults to 0.0.

  • inequality: If true the strong duality constraint is added as two inequality constraints. If false the strong duality constraint is added as an equality constraint. Defaults to true.

source
BilevelJuMP.ComplementModeType
ComplementMode(; with_slack = false)

Used to solve a bilevel problem with the MPEC reformulation using actual complementarity constraints. A limited number of solvers support this mode. One example is Knitro.

  • with_slack indicates whether to use slack variables to reformulate the complementarity constraints. Given a pair expr and var, the reformulation is expr == slack and var ⟂ slack instead of expr ⟂ slack.
source
BilevelJuMP.MixedModeType
MixedMode(; default = SOS1Mode())

A mode that allows to mix different modes for different constraints and variables.

  • default is the default mode to use for all constraints and variables that are not explicitly mapped to a mode.
source

Bound hints

BilevelJuMP.set_dual_upper_bound_hintFunction
set_dual_upper_bound_hint(cref, value)

Set a upper bound to the dual variable of the constraint cref to value. This bound will not be dualized. The dual upper bound hint is used to help the solution method.

Solution modes can be benefitted from this hint:

  • BigMMode will use this information to compute a tighter bound for the dual variable.

  • Other modes will be stabilized by the existence of the bounds on variables that would otherwise no be bounded.

  • Bounds that are not dualized are also useful for binary expansions of products of variables that can be done with QuadraticToBinary.jl.

source
BilevelJuMP.get_dual_upper_bound_hintFunction
get_dual_upper_bound_hint(cref)

Get the upper bound to the dual variable of the constraint cref that was set with set_dual_upper_bound_hint.

source
BilevelJuMP.set_dual_lower_bound_hintFunction
set_dual_lower_bound_hint(cref, value)

Set a lower bound to the dual variable of the constraint cref to value. This bound will not be dualized. The dual lower bound hint is used to help the solution method.

Solution modes can be benefitted from this hint:

  • BigMMode will use this information to compute a tighter bound for the dual variable.

  • Other modes will be stabilized by the existence of the bounds on variables that would otherwise no be bounded.

  • Bounds that are not dualized are also useful for binary expansions of products of variables that can be done with QuadraticToBinary.jl.

source
BilevelJuMP.get_dual_lower_bound_hintFunction
get_dual_lower_bound_hint(cref)

Get the lower bound to the dual variable of the constraint cref that was set with set_dual_lower_bound_hint.

source
BilevelJuMP.set_primal_upper_bound_hintFunction
set_primal_upper_bound_hint(vref, value)

Set a upper bound to the prima variable vref to value. This bound will not be dualized. The upper bound hint is used to help the solution method.

Solution modes can be benefitted from this hint:

  • BigMMode will use this information to compute a tighter bound for the primal constraint variable.

  • Other modes will be stabilized by the existence of the bounds on variables that would otherwise no be bounded.

  • Bounds that are not dualized are also useful for binary expansions of products of variables that can be done with QuadraticToBinary.jl.

source
BilevelJuMP.get_primal_upper_bound_hintFunction
get_primal_upper_bound_hint(cref)

Get the upper bound to the primal variable of the constraint cref that was set with set_primal_upper_bound_hint.

source
BilevelJuMP.set_primal_lower_bound_hintFunction
set_primal_lower_bound_hint(vref, value)

Set a lower bound to the prima variable vref to value. This bound will not be dualized. The lower bound hint is used to help the solution method.

Solution modes can be benefitted from this hint:

  • BigMMode will use this information to compute a tighter bound for the primal constraint variable.

  • Other modes will be stabilized by the existence of the bounds on variables that would otherwise no be bounded.

  • Bounds that are not dualized are also useful for binary expansions of products of variables that can be done with QuadraticToBinary.jl.

source
BilevelJuMP.get_primal_lower_bound_hintFunction
get_primal_lower_bound_hint(cref)

Get the lower bound to the primal variable of the constraint cref that was set with set_primal_lower_bound_hint.

source

Attributes getters and setters

BilevelJuMP.lower_objective_valueFunction
lower_objective_value(model::BilevelModel; result::Int = 1)

Return the value of the objective function of the lower level problem.

source
BilevelJuMP.build_timeFunction
build_time(model::BilevelModel)

Return the time it took to build the model.

source
BilevelJuMP.set_modeFunction
set_mode(bm::BilevelModel, mode::AbstractBilevelSolverMode)

Set the mode of a bilevel model.

source
set_mode(ci::BilevelVariableRef, mode::AbstractBilevelSolverMode)

Set the mode of a constraint. This is used in MixedMode reformulations.

source
set_mode(vi::BilevelVariableRef, mode::AbstractBilevelSolverMode)

Set the mode of the bounds of a variable. This is used in MixedMode reformulations.

source
BilevelJuMP.get_modeFunction
get_mode(ci::BilevelConstraintRef)

Get the mode of a constraint. This is used in MixedMode reformulations.

source
get_mode(vi::BilevelVariableRef)

Get the mode of the bounds of a variable. This is used in MixedMode reformulations.

source
BilevelJuMP.unset_modeFunction
unset_mode(ci::BilevelConstraintRef)

Unset the mode of a constraint. This will use the default mode for the constraint. This is used in MixedMode reformulations.

source
unset_mode(vi::BilevelVariableRef)

Unset the mode of the bounds of a variable. This will use the default mode for the bounds. This is used in MixedMode reformulations.

source
BilevelJuMP.set_copy_namesFunction
set_copy_names(model::BilevelModel)

Set the copy_names attribute of the solver to true.

source
BilevelJuMP.get_copy_namesFunction
get_copy_names(model::BilevelModel)

Return the value of the copy_names attribute of the solver.

source
BilevelJuMP.unset_copy_namesFunction
unset_copy_names(model::BilevelModel)

Set the copy_names attribute of the solver to false.

source
BilevelJuMP.set_pass_startFunction
set_pass_start(model::BilevelModel)

Activate passing start values (both primal and dual) to the solver.

source
BilevelJuMP.get_pass_startFunction
get_pass_start(model::BilevelModel)

Checks if passing start values (both primal and dual) to the solver is activated.

source
BilevelJuMP.unset_pass_startFunction
unset_pass_start(model::BilevelModel)

Deactivate passing start values (both primal and dual) to the solver.

source
diff --git a/dev/search/index.html b/dev/search/index.html index d48521c..00dfd26 100644 --- a/dev/search/index.html +++ b/dev/search/index.html @@ -1,2 +1,2 @@ -Search · BilevelJuMP.jl

Loading search...

    +Search · BilevelJuMP.jl

    Loading search...

      diff --git a/dev/search_index.js b/dev/search_index.js index 1050404..0f9ba0c 100644 --- a/dev/search_index.js +++ b/dev/search_index.js @@ -1,3 +1,3 @@ var documenterSearchIndex = {"docs": -[{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"EditURL = \"https://github.com/joaquimg/BilevelJuMP.jl/blob/master/docs/src/examples/DTMP_example1.jl\"","category":"page"},{"location":"examples/DTMP_example1/#Decomposition-Techniques-in-Mathematical-Programming:-Example-7.4","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"","category":"section"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"This example is from the book Decomposition Techniques in Mathematical Programming Chapter 7.2, page 281, url","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"Model of the problem First level","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"min -4y - x\nnotag st\ny + 2x leq 8","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"Second level","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"min - y - x\nnotag st\n- y leq 0\ny + x leq 7\n- x leq 0\nx leq 4","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"using BilevelJuMP\nusing Ipopt\n\nmodel = BilevelModel(Ipopt.Optimizer; mode = BilevelJuMP.ProductMode(1e-5))\n\nset_silent(model)","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"First we need to create all of the variables in the upper and lower problems:","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"Upper level variables","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"@variable(Upper(model), x, start = 1)","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"Lower level variables","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"@variable(Lower(model), y, start = 6)","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"Then we can add the objective and constraints of the upper problem:","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"Upper level objecive function","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"@objective(Upper(model), Min, 4y - x)","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"Upper level constraints","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"@constraint(Upper(model), y + 2x <= 8)","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"Followed by the objective and constraints of the lower problem:","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"Lower objective function","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"@objective(Lower(model), Min, - y -x )","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"Lower constraints","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"@constraint(Lower(model), - y <= 0)\n@constraint(Lower(model), y + x <= 7)\n@constraint(Lower(model), - x <= 0)\n@constraint(Lower(model), x <= 4)","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"Now we can solve the problem and verify the solution again that reported by book","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"optimize!(model)","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"Results","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"value(x)","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"value(y)","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"info: Info\nView this file on Github.","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"This page was generated using Literate.jl.","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"EditURL = \"https://github.com/joaquimg/BilevelJuMP.jl/blob/master/docs/src/examples/FOBP_example2.jl\"","category":"page"},{"location":"examples/FOBP_example2/#Foundations-of-Bilevel-Programming:-Chapter-3.2,-Page-25","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"","category":"section"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"This example is from the book Foundations of Bilevel Programming by Stephan Dempe, Chapter 3.2, Page 25 url.","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"Model of the problem First level","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"min 3x + y\nnotag st\nx leq 5\ny leq 8\ny geq 0","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"Second level","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"min -x\nnotag st\nx + y = 8\n4x + y = 8\n2x + y = 13\n2x - y = 0","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"using BilevelJuMP\nusing Ipopt\n\nmodel = BilevelModel(Ipopt.Optimizer; mode = BilevelJuMP.ProductMode(1e-9))","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"First we need to define all of the variables in the upper and lower problems:","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"@variable(Upper(model), y, start = 8 / 15)\n\n@variable(Lower(model), x, start = 3.5 * 8 / 15)","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"Then we can add the objective and constraints of the upper problem: Upper level objective function","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"@objective(Upper(model), Min, 3x + y)","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"Upper level constraints","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"@constraints(Upper(model), begin\n u1, x <= 5\n u2, y <= 8\n u3, y >= 0\nend)","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"Followed by the objective and constraints of the lower problem: Lower level objective function","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"@objective(Lower(model), Min, -x)","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"Lower level constraints","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"@constraint(Lower(model), l1, x + y <= 8)\n@constraint(Lower(model), l2, 4x + y >= 8)\n@constraint(Lower(model), l3, 2x + y <= 13)\n@constraint(Lower(model), l4, 2x - 7y <= 0)","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"tip: Tip\nYou can use the singular @constraint macro or the plural @constraints!","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"We can also set hints for the variables associated with the problems.","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"In this example, we know the duals on the lower constraints are in the set [-15, 15]:","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"for c in [l1, l2, l3, l4]\n BilevelJuMP.set_dual_upper_bound_hint(c, 15)\n BilevelJuMP.set_dual_lower_bound_hint(c, -15)\nend","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"While we think the primal variables are in [-10, 6] for x and [-1, 9] for y. These hints are optional. But supplying them (e.g., from domain knowledge) can be helpful for the solver.","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"BilevelJuMP.set_primal_lower_bound_hint(x, -10)\nBilevelJuMP.set_primal_upper_bound_hint(x, 6)\nBilevelJuMP.set_primal_lower_bound_hint(y, -1)\nBilevelJuMP.set_primal_upper_bound_hint(y, 9)","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"Now we can solve the problem and verify the solution again that reported by Dempe.","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"optimize!(model)","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"objective_value(model)","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"objective_value(Lower(model))","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"value(x)","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"value(y)","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"value(u1)","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"value(l1)","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"dual(l1)","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"dual(l3)","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"info: Info\nView this file on Github.","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"This page was generated using Literate.jl.","category":"page"},{"location":"tutorials/quad_to_bin/","page":"Using QuadraticToBinary","title":"Using QuadraticToBinary","text":"EditURL = \"https://github.com/joaquimg/BilevelJuMP.jl/blob/master/docs/src/tutorials/quad_to_bin.jl\"","category":"page"},{"location":"tutorials/quad_to_bin/#Using-QuadraticToBinary","page":"Using QuadraticToBinary","title":"Using QuadraticToBinary","text":"","category":"section"},{"location":"tutorials/quad_to_bin/","page":"Using QuadraticToBinary","title":"Using QuadraticToBinary","text":"QuadraticToBinary.jl is a package that converts quadratic terms in constraints and objective. To do so the pack acts like a solver on top of the real solver and most data is forwarded directly to the solver itself. For many solvers it is enough to use:","category":"page"},{"location":"tutorials/quad_to_bin/","page":"Using QuadraticToBinary","title":"Using QuadraticToBinary","text":"using BilevelJuMP, QuadraticToBinary, HiGHS\n\nSOLVER = HiGHS.Optimizer()\nQ_SOLVER = QuadraticToBinary.Optimizer{Float64}(SOLVER, lb = -10, ub = 10)\nmodel = BilevelModel(()->Q_SOLVER, mode = BilevelJuMP.ProductMode(1e-6))\n\n@variable(Lower(model), x)\n@variable(Upper(model), y)\n\n@objective(Upper(model), Min, 3x + y)\n@constraints(Upper(model), begin\n x <= 5\n y <= 8\n y >= 0\nend)\n\n@objective(Lower(model), Min, -x)\n@constraints(Lower(model), begin\n x + y <= 8\n 4x + y >= 8\n 2x + y <= 13\n 2x - 7y <= 0\nend)\n\noptimize!(model)\n\nobjective_value(model)\n@assert abs(objective_value(model) - (3 * (3.5 * 8/15) + 8/15)) < 1e-1 # src","category":"page"},{"location":"tutorials/quad_to_bin/","page":"Using QuadraticToBinary","title":"Using QuadraticToBinary","text":"However, this might lead to some solver not supporting certain functionality like SCIP. In this case we need to:","category":"page"},{"location":"tutorials/quad_to_bin/","page":"Using QuadraticToBinary","title":"Using QuadraticToBinary","text":"using SCIP","category":"page"},{"location":"tutorials/quad_to_bin/","page":"Using QuadraticToBinary","title":"Using QuadraticToBinary","text":"warning: Warning\nSCIP requires a non-standard installation procedure in windows. See SCIP.jl for more details.","category":"page"},{"location":"tutorials/quad_to_bin/","page":"Using QuadraticToBinary","title":"Using QuadraticToBinary","text":"SOLVER = SCIP.Optimizer()\n\nCACHED_SOLVER = MOI.Utilities.CachingOptimizer(\n MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}()), SOLVER)\n\nQ_SOLVER = QuadraticToBinary.Optimizer{Float64}(CACHED_SOLVER)\n\nBilevelModel(()->Q_SOLVER, mode = BilevelJuMP.ProductMode(1e-5))","category":"page"},{"location":"tutorials/quad_to_bin/","page":"Using QuadraticToBinary","title":"Using QuadraticToBinary","text":"Note that we used ()->Q_SOLVER instead of just Q_SOLVER because BilevelModel requires as constructor and not an instance of an object.","category":"page"},{"location":"tutorials/quad_to_bin/","page":"Using QuadraticToBinary","title":"Using QuadraticToBinary","text":"info: Info\nView this file on Github.","category":"page"},{"location":"tutorials/quad_to_bin/","page":"Using QuadraticToBinary","title":"Using QuadraticToBinary","text":"","category":"page"},{"location":"tutorials/quad_to_bin/","page":"Using QuadraticToBinary","title":"Using QuadraticToBinary","text":"This page was generated using Literate.jl.","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"EditURL = \"https://github.com/joaquimg/BilevelJuMP.jl/blob/master/docs/src/examples/FOBP_example5.jl\"","category":"page"},{"location":"examples/FOBP_example5/#Foundations-of-Bilevel-Programming:-Example-Chapter-8.1,-Page-255","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"","category":"section"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"This example is from the book Foundations of Bilevel Programming by Stephan Dempe, Chapter 8.1, Page 255. url","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"Here, only the second level is described","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"Model of the problem First level","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"min 0","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"Second level","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"min x\nnotag st\nx+y leq 2\nx-y leq 2\n-4x+5y leq 10\n-4x-5y leq 10","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"using BilevelJuMP\nusing Ipopt\n\nmodel = BilevelModel(Ipopt.Optimizer; mode = BilevelJuMP.ProductMode(1e-9))","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"First we need to create all of the variables in the upper and lower problems:","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"Upper level variables","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"@variable(Upper(model), y, start = 0)\n\n#Lower level variables\n@variable(Lower(model), x, start = 0)","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"Then we can add the objective and constraints of the upper problem:","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"Upper level objecive function","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"@objective(Upper(model), Min, 0 * y + 0)","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"Followed by the objective and constraints of the lower problem:","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"Lower objective function","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"@objective(Lower(model), Min, x)","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"Lower constraints","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"@constraint(Lower(model), x + y <= 2)\n@constraint(Lower(model), x - y <= 2)\n@constraint(Lower(model), -4x + 5y <= 10)\n@constraint(Lower(model), -4x - 5y <= 10)","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"Now we can solve the problem and verify the solution again that reported by Dempe.","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"optimize!(model)","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"primal_status(model)","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"termination_status(model)","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"value(x)","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"value(y)","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"info: Info\nView this file on Github.","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"This page was generated using Literate.jl.","category":"page"},{"location":"manual/#Manual","page":"Manual","title":"Manual","text":"","category":"section"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"EditURL = \"https://github.com/joaquimg/BilevelJuMP.jl/blob/master/docs/src/examples/PHTP_example2.jl\"","category":"page"},{"location":"examples/PHTP_example2/#Princeton-Handbook-of-Test-Problems:-Test-9.3.4","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"","category":"section"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"This example is from the book Princeton Handbook of Test Problems in Local and Global Optimization Dempe, Chapter 9.3.4 -parg 223 url","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"Here, only the second level is described","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"Model of the problem First level","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"min 2x_1+2x_2-3y_1-3y_2-60\nnotag st\nx_1 + x_2 + y_1 -2y_2 -40leq 0\n0 leq x_i leq 50 forall i in I\n-10 leq y_j leq 20 forall j in J","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"Second level","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"min (-x_1 + y_1 + 40)^2 + (-x_2 + y_2 + 20)^2\nnotag st\n- x_i + 2y_j = -10forall (ij) in (ij)iin I jin J i=j\n-10 leq y_j leq 20 forall j in J","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"using BilevelJuMP\nusing Ipopt\n\nmodel = BilevelModel(Ipopt.Optimizer; mode = BilevelJuMP.ProductMode(1e-9))","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"First we need to create all of the variables in the upper and lower problems:","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"Upper level variables","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"@variable(Upper(model), x[i = 1:2], start = 0)","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"Lower level variables","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"@variable(Lower(model), y[i = 1:2], start = -10)","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"Then we can add the objective and constraints of the upper problem:","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"Upper level objecive function","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"@objective(Upper(model), Min, 2x[1] + 2x[2] - 3y[1] - 3y[2] - 60)","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"Upper level constraints","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"@constraint(Upper(model), x[1] + x[2] + y[1] - 2y[2] - 40 <= 0)\n@constraint(Upper(model), [i = 1:2], x[i] >= 0)\n@constraint(Upper(model), [i = 1:2], x[i] <= 50)\n@constraint(Upper(model), [i = 1:2], y[i] >= -10)\n@constraint(Upper(model), [i = 1:2], y[i] <= 20)","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"Followed by the objective and constraints of the lower problem:","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"Lower objective function","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"@objective(Lower(model), Min, (-x[1] + y[1] + 40)^2 + (-x[2] + y[2] + 20)^2)","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"Lower constraints","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"@constraint(Lower(model), [i = 1:2], -x[i] + 2y[i] <= -10)\n@constraint(Lower(model), [i = 1:2], y[i] >= -10)\n@constraint(Lower(model), [i = 1:2], y[i] <= 20)","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"Now we can solve the problem and verify the solution again that reported by the book","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"optimize!(model)","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"primal_status(model)","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"termination_status(model)","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"objective_value(model)","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"value.(x)","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"value.(y)","category":"page"},{"location":"examples/PHTP_example2/#Like-any-other-optimization-problem,-there-is-a-chance-in-bilevel","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Like any other optimization problem, there is a chance in bilevel","text":"","category":"section"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"optimization to find multiple solutions with the same optimal value; based on the inherent stochasticity of the algorithm and random seed, we are expecting two optimal solutions for this problem.","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"info: Info\nView this file on Github.","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"This page was generated using Literate.jl.","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"EditURL = \"https://github.com/joaquimg/BilevelJuMP.jl/blob/master/docs/src/examples/SOCBLP_example1.jl\"","category":"page"},{"location":"examples/SOCBLP_example1/#SOCBLP-from-Chi-et-al.:-Example-3.1","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"","category":"section"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"This example is from The models of bilevel programming with lower level second-order cone programs (url or url) SOCBLP stands for bilevel programming problem with lower level second-order cone program Bold point(s): Using second-order cone in the lower level problem","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"Model of the problem First level","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"min x + 3(y_1-y_2)\nnotag st\n2 leq x leq 6","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"Second level","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"min - y_1 + y_2\nnotag st\nx + y_1 - y_2 leq 8\nx + 4(y_1 - y_2) geq 8\nx + 2(y_1 - y_2) leq 12\ny_1 geq 0\ny_2 geq 0\ny in K^2","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"Here, K^2 is second order cone and it represents:","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"y in y=(y_1y_2)in mathbbRtimes mathbbRy_1 geq y_2_2","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"using BilevelJuMP\nusing Ipopt\n\nmodel = BilevelModel(\n () -> MOI.Bridges.Constraint.SOCtoNonConvexQuad{Float64}(Ipopt.Optimizer());\n mode = BilevelJuMP.ProductMode(1e-9),\n)","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"First we need to create all of the variables in the upper and lower problems:","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"Upper level variables","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"@variable(Upper(model), x)\n\n#Lower level variables\n@variable(Lower(model), y[i = 1:2])","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"Then we can add the objective and constraints of the upper problem:","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"Upper level objecive function","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"@objective(Upper(model), Min, x + 3(y[1] - y[2]))","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"Upper level constraints","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"@constraint(Upper(model), x >= 2)\n@constraint(Upper(model), x <= 6)","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"Followed by the objective and constraints of the lower problem:","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"Lower objective function","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"@objective(Lower(model), Min, -(y[1] - y[2]))","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"Lower constraints","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"@constraint(Lower(model), lb_y_1, y[1] >= 0)\n@constraint(Lower(model), lb_y_2, y[2] >= 0)\n@constraint(Lower(model), con1, x + (y[1] - y[2]) <= 8)\n@constraint(Lower(model), con2, x + 4(y[1] - y[2]) >= 8)\n@constraint(Lower(model), con3, x + 2(y[1] - y[2]) <= 12)\n@constraint(Lower(model), soc_lw, y in SecondOrderCone())","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"Defining bounds","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"BilevelJuMP.set_dual_upper_bound_hint(soc_lw, +[5.0, 5.0])\nBilevelJuMP.set_dual_lower_bound_hint(soc_lw, -[5.0, 5.0])","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"require lower bounds","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"for con in [con1, con3]\n BilevelJuMP.set_dual_lower_bound_hint(con, -15)\nend","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"require upper bounds","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"for con in [lb_y_1, lb_y_2, con2]\n BilevelJuMP.set_dual_upper_bound_hint(con, +15)\nend","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"bounds defined in the upper level are not dualized","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"for i in 1:2\n @constraint(Upper(model), y[i] in MOI.LessThan(+5.0))\n @constraint(Upper(model), y[i] in MOI.GreaterThan(-5.0))\nend","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"Now we can solve the problem and verify the solution again that reported by","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"optimize!(model)\n\nprimal_status(model)\n\ntermination_status(model)\n\nobjective_value(model)\n\nvalue.(y)","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"info: Info\nView this file on Github.","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"This page was generated using Literate.jl.","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"EditURL = \"https://github.com/joaquimg/BilevelJuMP.jl/blob/master/docs/src/examples/MibS_example1.jl\"","category":"page"},{"location":"examples/MibS_example1/#MibS:-Example-1-(Experimental-feature)","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"","category":"section"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"Model of the problem First level","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"min_x -3x -7y\nnotag st\n-3x + 2y leq 12\nx + 2y leq 20\nx leq 10\nx in mathbbZ","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"Second level","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"min_y y\nnotag st\n2x - y = 7\n-2x + 4y = 16\ny = 5\ny in mathbbZ","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"using BilevelJuMP\nusing Test\nusing MibS_jll\n\nmodel = BilevelModel()","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"First we need to create all of the variables in the upper and lower problems:","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"Upper level variables","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"@variable(Upper(model), x, Int)\n\n#Lower level variables\n@variable(Lower(model), y, Int)","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"Then we can add the objective and constraints of the upper problem:","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"Upper level objecive function","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"@objective(Upper(model), Min, -3x - 7y)","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"Upper constraints","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"@constraints(Upper(model), begin\n u1, -3x + 2y <= 12\n u2, x + 2y <= 20\n u3, x <= 10\nend)","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"Followed by the objective and constraints of the lower problem:","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"Lower objective function","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"@objective(Lower(model), Min, y)","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"Lower constraints","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"@constraint(Lower(model), l1, 2x - y <= 7)\n@constraint(Lower(model), l2, -2x + 4y <= 16)\n@constraint(Lower(model), l3, y <= 5)","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"Using MibS Solver","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"solution = BilevelJuMP.solve_with_MibS(model, MibS_jll.mibs)","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"Auto testing","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"@test solution.status == true\n@test solution.objective ≈ -53\n@test solution.nonzero_upper == Dict(0 => 6.0)\n@test solution.nonzero_lower == Dict(0 => 5.0)\n@test solution.all_upper[\"x\"] == 6.0\n@test solution.all_lower[\"y\"] == 5.0","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"info: Info\nView this file on Github.","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"This page was generated using Literate.jl.","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"EditURL = \"https://github.com/joaquimg/BilevelJuMP.jl/blob/master/docs/src/tutorials/lower_duals.jl\"","category":"page"},{"location":"tutorials/lower_duals/#Dual-variables-of-the-lower-level","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"","category":"section"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"This is a quick introduction to modeling and solving bilevel optimization with BilevelJuMP.","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"This modeling feature enables the implementation of workflows where one (or more) of the upper-level variables is the dual of a lower-level constraint. In particular, in the energy sector, it is common to model the energy prices as the dual variable associated with the energy demand equilibrium constraint. One example of an application that uses this feature is Fanzeres et al. (2019), which focuses on strategic bidding in auction-based energy markets. A small and simplified example of the modeled problem would be the model:","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"beginalign\n max_lambda q_S quad lambda cdot g_S \n textitst quad 0 leq q_S leq 100\n hspace28pt (g_S lambda) in argmin_g_S g_1 g_2 g_D 50 g_R1 + 100 g_R2 + 1000 g_D\n hspace70pt textitst quad g_S leq q_S \n hspace88pt quad 0 leq g_S leq 100 \n hspace88ptquad 0 leq g_1 leq 40 \n hspace88ptquad 0 leq g_2 leq 40 \n hspace88ptquad 0 leq g_D leq 100 \n hspace88ptquad g_S + g_1 + g_2 + g_D = 100 quad quad lambda labeleq-dual-lambda\nendalign","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"Where lambda is the dual of the load balance constraint (last constraint in the lower part), g_S, g_1, g_2 represent the generation of the strategic bidder and from two other (non-strategic) plants. g_D represents the deficit in generation. Finally, q_S is the quantity bid optimized by the strategic generator.","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"load packages","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"using BilevelJuMP\nusing Ipopt\nusing QuadraticToBinary\nusing HiGHS","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"BilevelJuMP.jl allows users to implement similar models using the function DualOf that binds a new variable in the upper level to an existing constraint in the lower level. The model can be written as:","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"model = BilevelModel()\n@variable(Upper(model), 0 <= qS <= 100)\n@variable(Lower(model), 0 <= gS <= 100)\n@variable(Lower(model), 0 <= gR1 <= 40)\n@variable(Lower(model), 0 <= gR2 <= 40)\n@variable(Lower(model), 0 <= gD <= 100)\n@objective(Lower(model), Min, 50gR1 + 100gR2 + 1000gD)\n@constraint(Lower(model), gS <= qS)\n@constraint(Lower(model), demand_equilibrium, gS + gR1 + gR2 + gD == 100)\n@variable(Upper(model), lambda, DualOf(demand_equilibrium))\n@objective(Upper(model), Max, lambda*gS)","category":"page"},{"location":"tutorials/lower_duals/#NLP-solution","page":"Dual variables of the lower level","title":"NLP solution","text":"","category":"section"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"This model, can be solved by selecting a reformulation and a solver. Here we select Strong-Duality reformulation, the Ipopt solver and call optimizes to perform the reformulation and solve it.","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"BilevelJuMP.set_mode(model, BilevelJuMP.StrongDualityMode())\nset_optimizer(model, Ipopt.Optimizer)\noptimize!(model)","category":"page"},{"location":"tutorials/lower_duals/#MIP-solution","page":"Dual variables of the lower level","title":"MIP solution","text":"","category":"section"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"It is also possible to solve such problem by using a MIP formulation. The main issue is the product of variable in the upper level objective. However, this can be easily handled by using the package QuadraticToBinary.jl for automatic binary expansions. Because binary expansions require bounds on variables, we add the following lines:","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"set_lower_bound(lambda, 0.0)\nset_upper_bound(lambda, 1000.0)","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"Then, as before, we set a solver (now HiGHS with the QuadraticToBinary.jl wrapper) and a solution method (now Fortuny-Amat and McCarl):","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"set_optimizer(model,\n ()->QuadraticToBinary.Optimizer{Float64}(HiGHS.Optimizer()))\nBilevelJuMP.set_mode(model,\n BilevelJuMP.FortunyAmatMcCarlMode(dual_big_M = 100))\noptimize!(model)","category":"page"},{"location":"tutorials/lower_duals/#More-on-DualOf-usage","page":"Dual variables of the lower level","title":"More on DualOf usage","text":"","category":"section"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"You might have a problem where you want duals of a vector of constraints like:","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"@constraint(Lower(model), reserves[i=1:3], (40 - gR1) + (40 - gR2) == 10 * i)","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"then you can do","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"@variable(Upper(model), reserve_dual[i=1:3], DualOf(reserves[i]))","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"or use anonymous variables","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"my_duals = []\nfor i in 1:3\n var = @variable(Upper(model), variable_type = DualOf(reserves[i]))\n push!(my_duals, var)\nend\nmy_duals # a vector of anonimous variables","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"info: Info\nView this file on Github.","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"This page was generated using Literate.jl.","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"EditURL = \"https://github.com/joaquimg/BilevelJuMP.jl/blob/master/docs/src/examples/FOBP_example3.jl\"","category":"page"},{"location":"examples/FOBP_example3/#Foundations-of-Bilevel-Programming:-Chapter-3.7,-Page-59","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"","category":"section"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"This example is from the book Foundations of Bilevel Programming by Stephan Dempe, Chapter 3.7, Page 59. url","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"Model of the problem","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"First level","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"min sum_iin I x_i - z\nnotag st\ny^a_igeq 0 forall i in I\ny^a_ileq 1 forall i in I\ny^b_igeq 0 forall i in I\ny^b_ileq 1 forall i in I\ny^a_i + y^b_i = 1 forall i in I\nzgeq 0\nzleq 1\ny^a_1 + y^a_2 + y^a_3 geq z\n-y^b_1 - y^b_4 + y^a_3 geq z\ny^b_7 - y^b_6 + y^a_4 geq z\ny^a_5 + y^a_6 + y^a_7 geq z","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"Second level","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"min -sum_iin Ix_i\nnotag st\nsum x_i geq 0\nx_i leq y^a_i forall iin I\nx_i leq y^b_i forall iin I\nI = 17","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"using BilevelJuMP\nusing Ipopt\n\nmodel = BilevelModel(Ipopt.Optimizer; mode = BilevelJuMP.ProductMode(1e-9))","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"Global variables","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"I = 7 # maximum literals\nclauses = [[1, 2, 3], [-1, -4, 3], [7, -6, 4], [5, 6, 7]]","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"First we need to create all of the variables in the upper and lower problems:","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"Upper level variables","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"@variable(Upper(model), ya[i = 1:I])\n@variable(Upper(model), yb[i = 1:I])\n@variable(Upper(model), z)\n\n#Lower level variables\n@variable(Lower(model), x[i = 1:I])","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"Then we can add the objective and constraints of the upper problem:","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"Upper level objecive function","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"@objective(Upper(model), Min, sum(x[i] for i in 1:I) - z)","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"Upper level constraints","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"@constraint(Upper(model), ca, z <= 1)\n@constraint(Upper(model), cb, z >= 0)\n@constraint(Upper(model), c1[i = 1:I], ya[i] >= 0)\n@constraint(Upper(model), c2[i = 1:I], ya[i] <= 1)\n@constraint(Upper(model), c3[i = 1:I], yb[i] >= 0)\n@constraint(Upper(model), c4[i = 1:I], yb[i] <= 1)\n@constraint(Upper(model), c5[i = 1:I], ya[i] + yb[i] == 1)","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"for c in clauses","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"@constraint(\n Upper(model),\n cc[k in eachindex(clauses)],\n sum(i > 0 ? ya[i] : yb[-i] for i in clauses[k]) >= z\n)","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"Followed by the objective and constraints of the lower problem:","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"Lower objective function","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"@objective(Lower(model), Min, -sum(x[i] for i in 1:I))","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"Lower constraints","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"@constraint(Lower(model), b1[i = 1:I], x[i] >= 0)\n@constraint(Lower(model), b2[i = 1:I], x[i] <= ya[i])\n@constraint(Lower(model), b3[i = 1:I], x[i] <= yb[i])","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"Initial Starting conditions","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"JuMP.set_start_value.(x, 0)\nJuMP.set_start_value.(ya, 1)\nJuMP.set_start_value.(yb, 0)\nJuMP.set_start_value(z, 1)\nfor i in 1:I\n JuMP.set_dual_start_value.(b1, 0)\n JuMP.set_dual_start_value.(b2, 0)\n JuMP.set_dual_start_value.(b3, -1)\nend","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"Now we can solve the problem and verify the solution again that reported by Dempe.","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"optimize!(model)","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"primal_status(model)","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"termination_status(model)","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"Results","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"objective_value(model)","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"value.(x)","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"value.(ya)","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"value.(yb)","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"value(z)","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"info: Info\nView this file on Github.","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"This page was generated using Literate.jl.","category":"page"},{"location":"troubleshooting/#Troubleshooting","page":"Troubleshooting","title":"Troubleshooting","text":"","category":"section"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"Cbc has known bugs in its SOS1 constraints, so BilevelJuMP.SOS1Mode might","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"not work properly with Cbc.","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"For anonymous variables with DualOf use:","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"@variable(Upper(model, variable_type = DualOf(my_lower_constraint)))","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"Nonconvex/nonconcave/nonpsd objective/constraint error in a MIP solver.","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"If you are using Gurobi use:","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"model = BilevelModel(Gurobi.Optimizer, mode = BilevelJuMP.SOS1Mode()) #or other mode\nset_optimizer_attribute(model, \"NonConvex\", 2)","category":"page"},{"location":"reference/#API","page":"API Reference","title":"API","text":"","category":"section"},{"location":"reference/","page":"API Reference","title":"API Reference","text":"This section documents the BilevelJuMP API.","category":"page"},{"location":"reference/","page":"API Reference","title":"API Reference","text":"As a JuMP extension, most JuMP functions should just work. Some JuMP function will return error saying they are not implemented for BileveJuMP structures such as BilevelModel. If that happens and you consider that function should be implemented, please, open an issue.","category":"page"},{"location":"reference/#Constructors","page":"API Reference","title":"Constructors","text":"","category":"section"},{"location":"reference/","page":"API Reference","title":"API Reference","text":"BilevelModel\nUpper\nLower\nDualOf","category":"page"},{"location":"reference/#BilevelJuMP.BilevelModel","page":"API Reference","title":"BilevelJuMP.BilevelModel","text":"BilevelModel()\n\nCreate an empty BilevelModel with default settings, no solver and no solve mode.\n\nExample\n\njulia> model = BilevelModel()\n\nBilevelModel(solver::Function; mode = BilevelJuMP.SOS1Mode(), add_bridges::Bool = true)\n\nCreate a BilevelModel with the given solver and solve mode.\n\nsolver: is a functions that takes no arguments and returns a JuMP solver object.\nmode: is a solve mode object that defines how the model is solved.\nadd_bridges: if true (default) then bridges are added to the model. If false then bridges are not added and the model is not modified.\n\nExample\n\njulia> model = BilevelModel(\n HiGHS.Optimizer,\n mode = BilevelJuMP.FortunyAmatMcCarlMode(primal_big_M = 1e6, dual_big_M = 1e6))\n\nwhich is equivalent to\n\njulia> model = BilevelModel(\n ()->HiGHS.Optimizer(),\n mode = BilevelJuMP.FortunyAmatMcCarlMode(primal_big_M = 1e6, dual_big_M = 1e6))\n\nand equivalent to\n\njulia> model = BilevelModel()\n\njulia> BilevelJuMP.set_solver(model, HiGHS.Optimizer)\n\njulia> BilevelJuMP.set_mode(model, BilevelJuMP.FortunyAmatMcCarlMode(primal_big_M = 1e6, dual_big_M = 1e6))\n\n\n\n\n\n","category":"type"},{"location":"reference/#BilevelJuMP.Upper","page":"API Reference","title":"BilevelJuMP.Upper","text":"Upper(model::BilevelModel)\n\nCreate a reference to the upper level of a bilevel model.\n\nExample\n\njulia> model = BilevelModel();\n\njulia> @variable(Upper(model), x >= 0)\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.Lower","page":"API Reference","title":"BilevelJuMP.Lower","text":"Lower(model::BilevelModel)\n\nCreate a reference to the lower level of a bilevel model.\n\nExample\n\njulia> model = BilevelModel();\n\njulia> @variable(Lower(model), x >= 0)\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.DualOf","page":"API Reference","title":"BilevelJuMP.DualOf","text":"DualOf(constraint::ConstraintRef)\n\nGet the dual variable associated with a constraint. This is only valid for constraints in the upper level of a bilevel model.\n\nExamples\n\njulia> m = BilevelModel();\n\njulia> @variable(Lower(m), x >= 0);\n\njulia> @constraint(Lower(m), c, x <= 1);\n\njulia> @variable(Upper(m), y, DualOf(c));\n\n\n\n\n\n","category":"type"},{"location":"reference/#Advanced-constructors","page":"API Reference","title":"Advanced constructors","text":"","category":"section"},{"location":"reference/","page":"API Reference","title":"API Reference","text":"UpperOnly\nLowerOnly","category":"page"},{"location":"reference/#BilevelJuMP.UpperOnly","page":"API Reference","title":"BilevelJuMP.UpperOnly","text":"UpperOnly(model::BilevelModel)\n\nCreate a special reference to the upper level of a bilevel model. Variables created with this reference will not be shared with the lower level.\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.LowerOnly","page":"API Reference","title":"BilevelJuMP.LowerOnly","text":"LowerOnly(model::BilevelModel)\n\nCreate a special reference to the lower level of a bilevel model. Variables created with this reference will not be shared with the upper level.\n\n\n\n\n\n","category":"function"},{"location":"reference/#Enums","page":"API Reference","title":"Enums","text":"","category":"section"},{"location":"reference/","page":"API Reference","title":"API Reference","text":"BilevelJuMP.Level\nBilevelJuMP.LOWER_BOTH\nBilevelJuMP.UPPER_BOTH\nBilevelJuMP.LOWER_ONLY\nBilevelJuMP.UPPER_ONLY\nBilevelJuMP.DUAL_OF_LOWER","category":"page"},{"location":"reference/#BilevelJuMP.Level","page":"API Reference","title":"BilevelJuMP.Level","text":"Level\n\nThe level of a variable in a bilevel problem.\n\n\n\n\n\n","category":"type"},{"location":"reference/#BilevelJuMP.LOWER_BOTH","page":"API Reference","title":"BilevelJuMP.LOWER_BOTH","text":"Indicates and object that is part of the lower level problem, but is shared with the upper level.\n\n\n\n\n\n","category":"constant"},{"location":"reference/#BilevelJuMP.UPPER_BOTH","page":"API Reference","title":"BilevelJuMP.UPPER_BOTH","text":"Indicates and object that is part of the upper level problem, but is shared with the lower level.\n\n\n\n\n\n","category":"constant"},{"location":"reference/#BilevelJuMP.LOWER_ONLY","page":"API Reference","title":"BilevelJuMP.LOWER_ONLY","text":"Indicates and object that is part of the lower level problem, but is not shared with the upper level.\n\n\n\n\n\n","category":"constant"},{"location":"reference/#BilevelJuMP.UPPER_ONLY","page":"API Reference","title":"BilevelJuMP.UPPER_ONLY","text":"Indicates and object that is part of the upper level problem, but is not shared with the lower level.\n\n\n\n\n\n","category":"constant"},{"location":"reference/#BilevelJuMP.DUAL_OF_LOWER","page":"API Reference","title":"BilevelJuMP.DUAL_OF_LOWER","text":"Indicates and object that is part of the dual of the lower level problem, and is shared with the upper level.\n\n\n\n\n\n","category":"constant"},{"location":"reference/","page":"API Reference","title":"API Reference","text":"BilevelJuMP.IndicatorSetting\nBilevelJuMP.ZERO_ONE\nBilevelJuMP.ZERO_ZERO\nBilevelJuMP.ONE_ONE","category":"page"},{"location":"reference/#BilevelJuMP.IndicatorSetting","page":"API Reference","title":"BilevelJuMP.IndicatorSetting","text":"IndicatorSetting\n\nThe type of indicator function to use in the IndicatorMode mode.\n\n\n\n\n\n","category":"type"},{"location":"reference/#BilevelJuMP.ZERO_ONE","page":"API Reference","title":"BilevelJuMP.ZERO_ONE","text":"Activates the indicator constraint on the primal constraint if the auxiliaty binary is zero and activates the indicator constraint on the dual variable if the auxiliary binary is one.\n\n\n\n\n\n","category":"constant"},{"location":"reference/#BilevelJuMP.ZERO_ZERO","page":"API Reference","title":"BilevelJuMP.ZERO_ZERO","text":"Activates the indicator constraint on the primal constraint if the auxiliaty binary is zero and activates the indicator constraint on the dual variable if the auxiliary binary is zero.\n\n\n\n\n\n","category":"constant"},{"location":"reference/#BilevelJuMP.ONE_ONE","page":"API Reference","title":"BilevelJuMP.ONE_ONE","text":"Activates the indicator constraint on the primal constraint if the auxiliaty binary is one and activates the indicator constraint on the dual variable if the auxiliary binary is one.\n\n\n\n\n\n","category":"constant"},{"location":"reference/#Structs","page":"API Reference","title":"Structs","text":"","category":"section"},{"location":"reference/","page":"API Reference","title":"API Reference","text":"BilevelVariableRef\nBilevelAffExpr\nBilevelQuadExpr","category":"page"},{"location":"reference/#BilevelJuMP.BilevelVariableRef","page":"API Reference","title":"BilevelJuMP.BilevelVariableRef","text":"BilevelVariableRef\n\nHolds a reference to a variable in a bilevel model.\n\n\n\n\n\n","category":"type"},{"location":"reference/#BilevelJuMP.BilevelAffExpr","page":"API Reference","title":"BilevelJuMP.BilevelAffExpr","text":"BilevelVariableRef\n\nAlias for GenericAffExpr{Float64,BilevelVariableRef}.\n\n\n\n\n\n","category":"type"},{"location":"reference/#BilevelJuMP.BilevelQuadExpr","page":"API Reference","title":"BilevelJuMP.BilevelQuadExpr","text":"BilevelQuadExpr\n\nAlias for GenericQuadExpr{Float64,BilevelVariableRef}.\n\n\n\n\n\n","category":"type"},{"location":"reference/#Modes","page":"API Reference","title":"Modes","text":"","category":"section"},{"location":"reference/","page":"API Reference","title":"API Reference","text":"BilevelJuMP.SOS1Mode\nBilevelJuMP.FortunyAmatMcCarlMode\nBilevelJuMP.IndicatorMode\nBilevelJuMP.ProductMode\nBilevelJuMP.StrongDualityMode\nBilevelJuMP.ComplementMode\nBilevelJuMP.MixedMode","category":"page"},{"location":"reference/#BilevelJuMP.SOS1Mode","page":"API Reference","title":"BilevelJuMP.SOS1Mode","text":"SOS1Mode()\n\nUsed to solve a bilevel problem with the MPEC reformulation using SOS1 constraints to convert complementarity constraints into mixed-integer constraints.\n\n\n\n\n\n","category":"type"},{"location":"reference/#BilevelJuMP.FortunyAmatMcCarlMode","page":"API Reference","title":"BilevelJuMP.FortunyAmatMcCarlMode","text":"FortunyAmatMcCarlMode\n\nSee BigMMode for more details.\n\n\n\n\n\n","category":"type"},{"location":"reference/#BilevelJuMP.IndicatorMode","page":"API Reference","title":"BilevelJuMP.IndicatorMode","text":"IndicatorMode(method::IndicatorSetting = BilevelJuMP.ONE_ONE)\n\nUsed to solve a bilevel problem with the MPEC reformulation using indicator constaints to convert complementarity constraints to a mixed integer formulation.\n\nmethod indicates how the indicator constraints are activated for primal cosntraints and dual variables. See IndicatorSetting for more details.\n\n\n\n\n\n","category":"type"},{"location":"reference/#BilevelJuMP.ProductMode","page":"API Reference","title":"BilevelJuMP.ProductMode","text":"ProductMode(epsilon = 0.0; with_slack = false, aggregation_group = nothing)\n\nUsed to solve a bilevel problem with the MPEC reformulation using products to convert complementarity constraints into non-convex quadratic constraints.\n\nwith_slack indicates whether to use slack variables to reformulate the complementarity constraints. Given a pair expr and var, the reformulation is expr == slack and var * slack == 0 instead of expr * slack == 0.\naggregation_group indicates whether to aggregate the products into a single quadratic constraint. If aggregation_group is nothing, then each product is converted into a quadratic constraint. If aggregation_group is a positive integer, then products with the same aggregation_group are aggregated into a single quadratic constraint.\n\n\n\n\n\n","category":"type"},{"location":"reference/#BilevelJuMP.StrongDualityMode","page":"API Reference","title":"BilevelJuMP.StrongDualityMode","text":"StrongDualityMode(eps = 0.0, inequality = true)\n\nA mode that adds a strong duality constraint of the lower level problem instead of reformulating the complementarity constraints.\n\neps: The tolerance for the strong duality constraint. Defaults to 0.0.\ninequality: If true the strong duality constraint is added as two inequality constraints. If false the strong duality constraint is added as an equality constraint. Defaults to true.\n\n\n\n\n\n","category":"type"},{"location":"reference/#BilevelJuMP.ComplementMode","page":"API Reference","title":"BilevelJuMP.ComplementMode","text":"ComplementMode(; with_slack = false)\n\nUsed to solve a bilevel problem with the MPEC reformulation using actual complementarity constraints. A limited number of solvers support this mode. One example is Knitro.\n\nwith_slack indicates whether to use slack variables to reformulate the complementarity constraints. Given a pair expr and var, the reformulation is expr == slack and var ⟂ slack instead of expr ⟂ slack.\n\n\n\n\n\n","category":"type"},{"location":"reference/#BilevelJuMP.MixedMode","page":"API Reference","title":"BilevelJuMP.MixedMode","text":"MixedMode(; default = SOS1Mode())\n\nA mode that allows to mix different modes for different constraints and variables.\n\ndefault is the default mode to use for all constraints and variables that are not explicitly mapped to a mode.\n\n\n\n\n\n","category":"type"},{"location":"reference/#Bound-hints","page":"API Reference","title":"Bound hints","text":"","category":"section"},{"location":"reference/","page":"API Reference","title":"API Reference","text":"BilevelJuMP.set_dual_upper_bound_hint\nBilevelJuMP.get_dual_upper_bound_hint\nBilevelJuMP.set_dual_lower_bound_hint\nBilevelJuMP.get_dual_lower_bound_hint\nBilevelJuMP.set_primal_upper_bound_hint\nBilevelJuMP.get_primal_upper_bound_hint\nBilevelJuMP.set_primal_lower_bound_hint\nBilevelJuMP.get_primal_lower_bound_hint","category":"page"},{"location":"reference/#BilevelJuMP.set_dual_upper_bound_hint","page":"API Reference","title":"BilevelJuMP.set_dual_upper_bound_hint","text":"set_dual_upper_bound_hint(cref, value)\n\nSet a upper bound to the dual variable of the constraint cref to value. This bound will not be dualized. The dual upper bound hint is used to help the solution method.\n\nSolution modes can be benefitted from this hint:\n\nBigMMode will use this information to compute a tighter bound for the dual variable.\nOther modes will be stabilized by the existence of the bounds on variables that would otherwise no be bounded.\nBounds that are not dualized are also useful for binary expansions of products of variables that can be done with QuadraticToBinary.jl.\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.get_dual_upper_bound_hint","page":"API Reference","title":"BilevelJuMP.get_dual_upper_bound_hint","text":"get_dual_upper_bound_hint(cref)\n\nGet the upper bound to the dual variable of the constraint cref that was set with set_dual_upper_bound_hint.\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.set_dual_lower_bound_hint","page":"API Reference","title":"BilevelJuMP.set_dual_lower_bound_hint","text":"set_dual_lower_bound_hint(cref, value)\n\nSet a lower bound to the dual variable of the constraint cref to value. This bound will not be dualized. The dual lower bound hint is used to help the solution method.\n\nSolution modes can be benefitted from this hint:\n\nBigMMode will use this information to compute a tighter bound for the dual variable.\nOther modes will be stabilized by the existence of the bounds on variables that would otherwise no be bounded.\nBounds that are not dualized are also useful for binary expansions of products of variables that can be done with QuadraticToBinary.jl.\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.get_dual_lower_bound_hint","page":"API Reference","title":"BilevelJuMP.get_dual_lower_bound_hint","text":"get_dual_lower_bound_hint(cref)\n\nGet the lower bound to the dual variable of the constraint cref that was set with set_dual_lower_bound_hint.\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.set_primal_upper_bound_hint","page":"API Reference","title":"BilevelJuMP.set_primal_upper_bound_hint","text":"set_primal_upper_bound_hint(vref, value)\n\nSet a upper bound to the prima variable vref to value. This bound will not be dualized. The upper bound hint is used to help the solution method.\n\nSolution modes can be benefitted from this hint:\n\nBigMMode will use this information to compute a tighter bound for the primal constraint variable.\nOther modes will be stabilized by the existence of the bounds on variables that would otherwise no be bounded.\nBounds that are not dualized are also useful for binary expansions of products of variables that can be done with QuadraticToBinary.jl.\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.get_primal_upper_bound_hint","page":"API Reference","title":"BilevelJuMP.get_primal_upper_bound_hint","text":"get_primal_upper_bound_hint(cref)\n\nGet the upper bound to the primal variable of the constraint cref that was set with set_primal_upper_bound_hint.\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.set_primal_lower_bound_hint","page":"API Reference","title":"BilevelJuMP.set_primal_lower_bound_hint","text":"set_primal_lower_bound_hint(vref, value)\n\nSet a lower bound to the prima variable vref to value. This bound will not be dualized. The lower bound hint is used to help the solution method.\n\nSolution modes can be benefitted from this hint:\n\nBigMMode will use this information to compute a tighter bound for the primal constraint variable.\nOther modes will be stabilized by the existence of the bounds on variables that would otherwise no be bounded.\nBounds that are not dualized are also useful for binary expansions of products of variables that can be done with QuadraticToBinary.jl.\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.get_primal_lower_bound_hint","page":"API Reference","title":"BilevelJuMP.get_primal_lower_bound_hint","text":"get_primal_lower_bound_hint(cref)\n\nGet the lower bound to the primal variable of the constraint cref that was set with set_primal_lower_bound_hint.\n\n\n\n\n\n","category":"function"},{"location":"reference/#Attributes-getters-and-setters","page":"API Reference","title":"Attributes getters and setters","text":"","category":"section"},{"location":"reference/","page":"API Reference","title":"API Reference","text":"BilevelJuMP.lower_objective_value\nBilevelJuMP.build_time\nBilevelJuMP.set_mode\nBilevelJuMP.get_mode\nBilevelJuMP.unset_mode\nBilevelJuMP.set_copy_names\nBilevelJuMP.get_copy_names\nBilevelJuMP.unset_copy_names\nBilevelJuMP.set_pass_start\nBilevelJuMP.get_pass_start\nBilevelJuMP.unset_pass_start","category":"page"},{"location":"reference/#BilevelJuMP.lower_objective_value","page":"API Reference","title":"BilevelJuMP.lower_objective_value","text":"lower_objective_value(model::BilevelModel; result::Int = 1)\n\nReturn the value of the objective function of the lower level problem.\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.build_time","page":"API Reference","title":"BilevelJuMP.build_time","text":"build_time(model::BilevelModel)\n\nReturn the time it took to build the model.\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.set_mode","page":"API Reference","title":"BilevelJuMP.set_mode","text":"set_mode(bm::BilevelModel, mode::AbstractBilevelSolverMode)\n\nSet the mode of a bilevel model.\n\n\n\n\n\nset_mode(ci::BilevelVariableRef, mode::AbstractBilevelSolverMode)\n\nSet the mode of a constraint. This is used in MixedMode reformulations.\n\n\n\n\n\nset_mode(vi::BilevelVariableRef, mode::AbstractBilevelSolverMode)\n\nSet the mode of the bounds of a variable. This is used in MixedMode reformulations.\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.get_mode","page":"API Reference","title":"BilevelJuMP.get_mode","text":"get_mode(ci::BilevelConstraintRef)\n\nGet the mode of a constraint. This is used in MixedMode reformulations.\n\n\n\n\n\nget_mode(vi::BilevelVariableRef)\n\nGet the mode of the bounds of a variable. This is used in MixedMode reformulations.\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.unset_mode","page":"API Reference","title":"BilevelJuMP.unset_mode","text":"unset_mode(ci::BilevelConstraintRef)\n\nUnset the mode of a constraint. This will use the default mode for the constraint. This is used in MixedMode reformulations.\n\n\n\n\n\nunset_mode(vi::BilevelVariableRef)\n\nUnset the mode of the bounds of a variable. This will use the default mode for the bounds. This is used in MixedMode reformulations.\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.set_copy_names","page":"API Reference","title":"BilevelJuMP.set_copy_names","text":"set_copy_names(model::BilevelModel)\n\nSet the copy_names attribute of the solver to true.\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.get_copy_names","page":"API Reference","title":"BilevelJuMP.get_copy_names","text":"get_copy_names(model::BilevelModel)\n\nReturn the value of the copy_names attribute of the solver.\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.unset_copy_names","page":"API Reference","title":"BilevelJuMP.unset_copy_names","text":"unset_copy_names(model::BilevelModel)\n\nSet the copy_names attribute of the solver to false.\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.set_pass_start","page":"API Reference","title":"BilevelJuMP.set_pass_start","text":"set_pass_start(model::BilevelModel)\n\nActivate passing start values (both primal and dual) to the solver.\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.get_pass_start","page":"API Reference","title":"BilevelJuMP.get_pass_start","text":"get_pass_start(model::BilevelModel)\n\nChecks if passing start values (both primal and dual) to the solver is activated.\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.unset_pass_start","page":"API Reference","title":"BilevelJuMP.unset_pass_start","text":"unset_pass_start(model::BilevelModel)\n\nDeactivate passing start values (both primal and dual) to the solver.\n\n\n\n\n\n","category":"function"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"EditURL = \"https://github.com/joaquimg/BilevelJuMP.jl/blob/master/docs/src/tutorials/modes.jl\"","category":"page"},{"location":"tutorials/modes/#Modes-overview","page":"Modes overview","title":"Modes overview","text":"","category":"section"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"There are several ways to solve bilevel problems with BilevelJuMP. The main difference between them is the way the complementarity constraints are reformulated. The reformulation method is set with the mode option of the BilevelModel constructor.","category":"page"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"The modes available are:","category":"page"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"BilevelJuMP.SOS1Mode(): uses SOS1 constraints to model complementarity constraints and solve the problem with MIP solvers (Cbc, Xpress, Gurobi, CPLEX, SCIP).\nBilevelJuMP.IndicatorMode(): uses Indicator constraints to model complementarity constraints and solve the problem with MIP solvers (Cbc, Xpress, Gurobi, CPLEX, SCIP).\nBilevelJuMP.BigMMode(): uses the Fortuny-Amat and McCarl reformulation that requires a MIP solver with very basic functionality, i.e., just binary variables are needed. The main drawback of this method is that one must provide bounds for all primal and dual variables. However, if good bounds are provided, this method can be more efficient than the previous. Bound hints to compute the big-Ms can be passed with the methods: set_primal_(upper\\lower)_bound_hint(variable, bound), for primals; and set_dual_(upper\\lower)_bound_hint(constraint, bound) for duals. We can also call FortunyAmatMcCarlMode(primal_big_M = vp, dual_big_M = vd), where vp and vd are, respectively, the big M fallback values for primal and dual variables, these are used when some variables have no given bounds, otherwise the given bounds are used instead.\nBilevelJuMP.ProductMode(): reformulates the complementarity constraints as products so that the problem can be solved by NLP (Ipopt, KNITRO) solvers or even MIP solvers with the aid of binary expansions (see QuadraticToBinary.jl). Note that binary expansions require variables to have upper and lower bounds. Also, note that the Gurobi solver supports products, but requires setting the \"NonConvex\" options.\nBilevelJuMP.MixedMode(default = mode): where mode is one of the other modes described above. With this method it is possible to set complementarity reformulations per constraint with BilevelJuMP.set_mode(constraint, mode), where constraint is a constraint of the bilevel problem and mode is one of the modes described above. If no mode is set for a constraint, the default mode is used instead. To set a mode to reformulate variables bounds use: BilevelJuMP.set_mode(variable, mode).\nBilevelJuMP.StrongDualityMode: this mode is not a complementarity reformulation method, instead, all complementarity constraints are replaced by constraints enforcing the strong duality. This mode is especially amenable for NLP solvers (Ipopt, KNITRO). MIP solvers can also be used but they will have to deal with the products of variables crated or the will have to be used in conjunction with QuadraticToBinary.jl.","category":"page"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"The following example shows how to solve a classic bilevel problem.","category":"page"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"We start loading all libraries needed for this example.","category":"page"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"using BilevelJuMP, HiGHS, Ipopt, SCIP","category":"page"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"Now we create a bilevel model with the BilevelModel constructor with no solver nor mode specified.","category":"page"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"model = BilevelModel()\n\n@variable(Lower(model), x)\n@variable(Upper(model), y)\n\n@objective(Upper(model), Min, 3x + y)\n@constraints(Upper(model), begin\n x <= 5\n y <= 8\n y >= 0\nend)\n\n@objective(Lower(model), Min, -x)\n@constraints(Lower(model), begin\n c1, x + y <= 8\n c2, 4x + y >= 8\n c3, 2x + y <= 13\n c4, 2x - 7y <= 0\nend)","category":"page"},{"location":"tutorials/modes/#BigMMode-and-HiGHS.Optimizer","page":"Modes overview","title":"BigMMode and HiGHS.Optimizer","text":"","category":"section"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"set_optimizer(model, HiGHS.Optimizer)\n\nBilevelJuMP.set_mode(model,\n BilevelJuMP.BigMMode(primal_big_M = 100, dual_big_M = 100))\n\noptimize!(model)\n\nobjective_value(model)\n@assert abs(objective_value(model) - (3 * (7/2 * 8/15) + 8/15)) < 1e-1 # src","category":"page"},{"location":"tutorials/modes/#SOS1Mode-and-SCIP.Optimizer","page":"Modes overview","title":"SOS1Mode and SCIP.Optimizer","text":"","category":"section"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"set_optimizer(model, SCIP.Optimizer)\n\nBilevelJuMP.set_mode(model, BilevelJuMP.SOS1Mode())\n\noptimize!(model)\n\nobjective_value(model)\n\n@assert abs(objective_value(model) - (3 * (3.5 * 8/15) + 8/15)) < 1e-1 # src","category":"page"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"warning: Warning\nSCIP requires a non-standard installation procedure in windows. See SCIP.jl for more details.","category":"page"},{"location":"tutorials/modes/#IndicatorMode-and-SCIP.Optimizer","page":"Modes overview","title":"IndicatorMode and SCIP.Optimizer","text":"","category":"section"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"set_optimizer(model, SCIP.Optimizer)\n\nBilevelJuMP.set_mode(model, BilevelJuMP.IndicatorMode())\n\noptimize!(model)\n\nobjective_value(model)\n\n@assert abs(objective_value(model) - (3 * (3.5 * 8/15) + 8/15)) < 1e-1 # src","category":"page"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"warning: Warning\nSCIP requires a non-standard installation procedure in windows. See SCIP.jl for more details.","category":"page"},{"location":"tutorials/modes/#ProductMode-and-Ipopt.Optimizer","page":"Modes overview","title":"ProductMode and Ipopt.Optimizer","text":"","category":"section"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"set_optimizer(model, Ipopt.Optimizer)\n\nBilevelJuMP.set_mode(model, BilevelJuMP.ProductMode())\n\noptimize!(model)\n\nobjective_value(model)\n\n@assert abs(objective_value(model) - (3 * (7/2 * 8/15) + 8/15)) < 1e-1 # src","category":"page"},{"location":"tutorials/modes/#StrongDualityMode-and-Ipopt.Optimizer","page":"Modes overview","title":"StrongDualityMode and Ipopt.Optimizer","text":"","category":"section"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"set_optimizer(model, Ipopt.Optimizer)\n\nBilevelJuMP.set_mode(model, BilevelJuMP.StrongDualityMode())\n\noptimize!(model)\n\nobjective_value(model)\n\n@assert abs(objective_value(model) - (3 * (7/2 * 8/15) + 8/15)) < 1e-1 # src","category":"page"},{"location":"tutorials/modes/#MixedMode-and-SCIP.Optimizer","page":"Modes overview","title":"MixedMode and SCIP.Optimizer","text":"","category":"section"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"set_optimizer(model, SCIP.Optimizer)\n\nBilevelJuMP.set_mode(model, BilevelJuMP.MixedMode(default = BilevelJuMP.SOS1Mode()))\n\nBilevelJuMP.set_mode(c1, BilevelJuMP.IndicatorMode())\n\nBilevelJuMP.set_mode(c3, BilevelJuMP.SOS1Mode())\n\noptimize!(model)\n\nobjective_value(model)\n\n@assert abs(objective_value(model) - (3 * (3.5 * 8/15) + 8/15)) < 1e-1 # src","category":"page"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"warning: Warning\nSCIP requires a non-standard installation procedure in windows. See SCIP.jl for more details.","category":"page"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"info: Info\nView this file on Github.","category":"page"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"","category":"page"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"This page was generated using Literate.jl.","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"EditURL = \"https://github.com/joaquimg/BilevelJuMP.jl/blob/master/docs/src/tutorials/non_linear.jl\"","category":"page"},{"location":"tutorials/non_linear/#Non-Linear-models","page":"Non Linear models","title":"Non Linear models","text":"","category":"section"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"BilevelJuMP has limited support for non-linear models. The @NLconstraint and the @NLobjective macros are supported for the upper level, but not for the lower level. Moreover, these macros can only be used if the selected solver supports non-linear constraints and objectives.","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"The @constraint and @objective macros can be used for both levels to represent linear and quadratic constraints and objectives","category":"page"},{"location":"tutorials/non_linear/#Quadratic-constraints-and-objectives","page":"Non Linear models","title":"Quadratic constraints and objectives","text":"","category":"section"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"using BilevelJuMP, Ipopt\nmodel = BilevelModel(Ipopt.Optimizer, mode = BilevelJuMP.ProductMode(1e-5))\n\n@variable(Upper(model), x >= 2)\n@variable(Lower(model), 3 <= y <= 5)","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"We can add a non-linear objective to the upper level with @NLobjective","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"@NLobjective(Upper(model), Min, x^2 - y)","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"We can also add a non-linear constraint to the upper level with @NLconstraint","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"@NLconstraint(Upper(model), x^2 + y^2 <= 100)","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"@NLobjective is not supported in the lower level, but we can use @constraint to add a quadratic objective to the lower level.","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"@objective(Lower(model), Min, y^2)","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"optimize!(model)","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"All the quadratic objectives and constraints of the upper level can also be added with the @constraint and @objective macros. Hence, we can write the quivalent model:","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"using BilevelJuMP, Ipopt\nmodel = BilevelModel(Ipopt.Optimizer, mode = BilevelJuMP.ProductMode(1e-5))\n\n@variable(Upper(model), x >= 2)\n@variable(Lower(model), 3 <= y <= 5)","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"@objective(Upper(model), Min, x^2 - y)","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"@constraint(Upper(model), x^2 + y^2 <= 100)","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"@objective(Lower(model), Min, y^2)","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"optimize!(model)","category":"page"},{"location":"tutorials/non_linear/#General-non-linear-constraints-and-objectives","page":"Non Linear models","title":"General non-linear constraints and objectives","text":"","category":"section"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"General non quadratic objectives and general non-linear constraints can not be added to the lower level, but they can be added to the upper level.","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"using BilevelJuMP, Ipopt\nmodel = BilevelModel(Ipopt.Optimizer, mode = BilevelJuMP.ProductMode(1e-5))\n\n@variable(Upper(model), x >= 2)\n@variable(Lower(model), 3 <= y <= 5)","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"@NLobjective(Upper(model), Min, x^4 - sin(y))","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"@NLconstraint(Upper(model), x^3 + y^3 <= 1000)","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"@objective(Lower(model), Min, y^2)","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"optimize!(model)","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"info: Info\nConic constraints are supported in the lower level (see Conic Bilevel tutorial).","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"info: Info\nView this file on Github.","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"This page was generated using Literate.jl.","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"EditURL = \"https://github.com/joaquimg/BilevelJuMP.jl/blob/master/docs/src/examples/MibS_example2.jl\"","category":"page"},{"location":"examples/MibS_example2/#MibS:-Example-2-(Experimental-feature)","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"","category":"section"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"Model of the problem First level","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"min_x 2x -4y + 10z\nnotag st\n-3x + 2y + 2z leq 12\nx + 2y leq 20\nx leq 10\nx in mathbbZ z in mathbbB","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"Second level","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"min_y y\nnotag st\n2x - y + 3z= 7\n-2x + 4y = 16\ny = 5\ny in mathbbZ","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"using BilevelJuMP\nusing Test\nusing MibS_jll\n\nmodel = BilevelModel()","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"First we need to create all of the variables in the upper and lower problems:","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"Upper level variables","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"@variable(Upper(model), x, Int)\n@variable(Upper(model), z, Bin)\n\n#Lower level variables\n@variable(Lower(model), y, Int)","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"Then we can add the objective and constraints of the upper problem:","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"Upper level objecive function","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"@objective(Upper(model), Min, 2x - 4y + 10z)","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"Upper constraints","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"@constraints(Upper(model), begin\n u1, -3x + 2y + 5z <= 12\n u2, x + 2y <= 20\n u3, x <= 10\nend)","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"Followed by the objective and constraints of the lower problem:","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"Lower objective function","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"@objective(Lower(model), Min, y)","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"Lower constraints","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"@constraint(Lower(model), l1, 2x - y + 3z <= 7)\n@constraint(Lower(model), l2, -2x + 4y <= 16)\n@constraint(Lower(model), l3, y <= 5)","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"Using MibS Solver","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"solution = BilevelJuMP.solve_with_MibS(model, MibS_jll.mibs)","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"Auto testing","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"@test solution.status == true\n@test solution.objective ≈ -8.0\n@test solution.nonzero_upper == Dict(0 => 6.0)\n@test solution.nonzero_lower == Dict(0 => 5.0)\n@test solution.all_upper[\"x\"] == 6.0\n@test solution.all_upper[\"z\"] == 0\n@test solution.all_lower[\"y\"] == 5.0","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"info: Info\nView this file on Github.","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"This page was generated using Literate.jl.","category":"page"},{"location":"tutorials/conic_lower/","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"EditURL = \"https://github.com/joaquimg/BilevelJuMP.jl/blob/master/docs/src/tutorials/conic_lower.jl\"","category":"page"},{"location":"tutorials/conic_lower/#Conic-Bilevel-and-Mixed-Mode","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"","category":"section"},{"location":"tutorials/conic_lower/","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"Here we present a simple bilevel program with a conic lower level model described in example 3.3 from Chi, et al. 2014.","category":"page"},{"location":"tutorials/conic_lower/","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"beginalign\n max_x in mathbbR quad x + 3y_1 \n textitst quad 2 leq x leq 6\n hspace28pt y(x) in argmin_yin mathbbR^3 -y_1\n hspace58pt textitst quad x + y_1 leq 8 \n hspace76pt quad x + 4y_1 geq 8 \n hspace76pt quad x + 2y_1 leq 12 \n hspace76pt quad y in SOC_3 labeleq-soc\nendalign","category":"page"},{"location":"tutorials/conic_lower/","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"In this problem most of the constraints are regular linear constraints while the last one is a second order cone constraint. Such constraint ensures that the vector y belongs to a second order cone of dimension 3, that is: y_1 geq sqrty_2^2 + y_3^2.","category":"page"},{"location":"tutorials/conic_lower/","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"This problem can be encoded using regular JuMP syntax for conic programs:","category":"page"},{"location":"tutorials/conic_lower/","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"using BilevelJuMP\nmodel = BilevelModel()\n@variable(Upper(model), x)\n@variable(Lower(model), y[i=1:3])\n@objective(Upper(model), Min, x + 3y[1])\n@constraint(Upper(model), x >= 2)\n@constraint(Upper(model), x <= 6)\n@objective(Lower(model), Min, - y[1])\n@constraint(Lower(model), con1, x + y[1] <= 8)\n@constraint(Lower(model), con2, x + 4y[1] >= 8)\n@constraint(Lower(model), con3, x + 2y[1] <= 12)\n@constraint(Lower(model), con4, y in SecondOrderCone())","category":"page"},{"location":"tutorials/conic_lower/#NLP-solution-and-start-values","page":"Conic Bilevel and Mixed Mode","title":"NLP solution and start values","text":"","category":"section"},{"location":"tutorials/conic_lower/","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"We can set, for instance, the product reformulation and selected Ipopt as a solver. As Ipopt does not have native support for second order cones, we use the non-default MOI bridge SOCtoNonConvexQuad to convert second order cones into quadratic constraints.","category":"page"},{"location":"tutorials/conic_lower/","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"using Ipopt\nBilevelJuMP.set_mode(model, BilevelJuMP.ProductMode(1e-5))\nset_optimizer(model,\n ()->MOI.Bridges.Constraint.SOCtoNonConvexQuad{Float64}(Ipopt.Optimizer()))\noptimize!(model)","category":"page"},{"location":"tutorials/conic_lower/","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"The user could also use the alternative JuMP syntax:","category":"page"},{"location":"tutorials/conic_lower/","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"set_start_value(x, 6)\nset_dual_start_value(con2, 0)","category":"page"},{"location":"tutorials/conic_lower/#MIP-solution-and-mixed-mode","page":"Conic Bilevel and Mixed Mode","title":"MIP solution and mixed mode","text":"","category":"section"},{"location":"tutorials/conic_lower/","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"Alternatively, we could have used a Mixed Integer Second Order Cone Program (MISOCP) solver together with binary expansions. Complementarity of conic constraints is more difficult to handle because they require a sum of products that cannot be reformulated with other methods. Therefore, we rely on product reformulation for conic constraints. However, we can use other reformulations like indicator constraints for the non-conic constraints. Mixing the two of them can be done with Mixed Mode.","category":"page"},{"location":"tutorials/conic_lower/","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"The following code describes how to solve the problem with a MISOCP based solver.","category":"page"},{"location":"tutorials/conic_lower/","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"using Xpress\nusing QuadraticToBinary\nset_optimizer(model,\n ()->QuadraticToBinary.Optimizer{Float64}(Xpress.Optimizer(),lb=-10,ub=10))\nBilevelJuMP.set_mode(model,\n BilevelJuMP.MixedMode(default = BilevelJuMP.IndicatorMode()))\nBilevelJuMP.set_mode(con4, BilevelJuMP.ProductMode(1e-5))\noptimize!(model)","category":"page"},{"location":"tutorials/conic_lower/","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"info: Info\nThis code was not executed because Xpress requires a commercial license. Other solvers supporting MISOCP could be used such as Gurobi and CPLEX.","category":"page"},{"location":"tutorials/conic_lower/","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"We set the reformulation method as Mixed Mode and selected Indicator constraints to be the default for the case in which we do not explicitly specify the reformulation. Then we set product mode for the second order cone reformulation.","category":"page"},{"location":"tutorials/conic_lower/","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"Binary expansions require bounded variables, hence the QuadraticToBinary meta-solver accepts fallback to upper and lower bounds (\\texttt{ub} and \\texttt{lb}), used for variables with no explicit bounds.","category":"page"},{"location":"tutorials/conic_lower/","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"info: Info\nView this file on Github.","category":"page"},{"location":"tutorials/conic_lower/","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"","category":"page"},{"location":"tutorials/conic_lower/","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"This page was generated using Literate.jl.","category":"page"},{"location":"background/#Bilevel-Optimization","page":"Background Information","title":"Bilevel Optimization","text":"","category":"section"},{"location":"background/","page":"Background Information","title":"Background Information","text":"Bilevel optimization is a vast discipline with a long (50+ years) history. We will not attempt to present a bilevel optimization introduction here. Instead, we point the reader to the excelent text:","category":"page"},{"location":"background/","page":"Background Information","title":"Background Information","text":"A Gentle and Incomplete Introduction to Bilevel Optimization","category":"page"},{"location":"background/","page":"Background Information","title":"Background Information","text":"by Yasmine Beck and Martin Schmidt.","category":"page"},{"location":"background/","page":"Background Information","title":"Background Information","text":"The interested reader can find more information in books:","category":"page"},{"location":"background/","page":"Background Information","title":"Background Information","text":"Dempe 2002\nBard 2013\nDempe et al. 2015","category":"page"},{"location":"background/","page":"Background Information","title":"Background Information","text":"and in other reviews:","category":"page"},{"location":"background/","page":"Background Information","title":"Background Information","text":"Vicente and Calamai 1994\nColson et al. 2007\nKalashnikov et al. 2015\nDempe (2018)","category":"page"},{"location":"background/#Bilevel-Optimization-in-BilevelJuMP","page":"Background Information","title":"Bilevel Optimization in BilevelJuMP","text":"","category":"section"},{"location":"background/","page":"Background Information","title":"Background Information","text":"In BileveJuMP focus on the following bilevel problem form:","category":"page"},{"location":"background/","page":"Background Information","title":"Background Information","text":"beginaligned\n min_x textbfy z f_0(x textbfy z) \n textitst f_i(x textbfy z) in mathcalS_i quad i = 1 ldots k \n x(z) textbfy(z) in\n beginalignedt\n argmin_x textbfy frac12x z^top Q x z + a_0^top x+ d_0^top z + b_0\n textitst A_i x + D_i z + b_i in mathcalC_i quad y_i quad quad i = 1 ldots m\n endaligned\nendaligned","category":"page"},{"location":"background/","page":"Background Information","title":"Background Information","text":"where z in mathbbR^l and x in mathbbR^n are, respectively, from upper and lower-level primal decision variables. Vectors of lower level dual decision variables are represented individually, by y_1 in mathbbR^p_1 ldots y_m in mathbbR^p_m, or jointly, by the m-tuple textbfy = (y_1 ldots y_m). The square brackets cdot cdot represent the stacking of two vectors or scalars. Thus, xz is a (n+l)–vector with the elements of x and z stacked. The numbers of constraints in the upper and lower problems are given by k and m, respectively. Q, a_i, d_i, b_i, A_i, D_i are matrices (upper case) and vectors (lower case) of constants of the lower level problem and mathcalC_i subset mathbbR^p_i are convex conic sets. The functions f_i can be linear, quadratic, or non-linear. The sets mathcalS_iin mathbbR^q_i can be convex cones, as in the lower level, but can also represent other sets, such as the sets of integers or binary variables. We use the \"function-in-set\" notation following the MOI definition of mathematical optimization problems. As in traditional bilevel programming, z is decided in the upper level and passed to the lower level as a parameter and x might be seen as an upper-level variable constrained to be an optimal solution of the lower level. Also, we only consider optimistic bilevel problems. In short, the solution of the lower level will be the one that optimizes the upper level in case of degeneracy.","category":"page"},{"location":"background/","page":"Background Information","title":"Background Information","text":"For more information see our paper:","category":"page"},{"location":"background/","page":"Background Information","title":"Background Information","text":"@article{diasgarcia2022bileveljump,\n title={{BilevelJuMP. jl}: {M}odeling and solving bilevel optimization in {J}ulia},\n author={{Dias Garcia}, Joaquim and Bodin, Guilherme and Street, Alexandre},\n journal={arXiv preprint arXiv:2205.02307},\n year={2022}\n}","category":"page"},{"location":"background/","page":"Background Information","title":"Background Information","text":"Here is the pdf.","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"EditURL = \"https://github.com/joaquimg/BilevelJuMP.jl/blob/master/docs/src/examples/FOBP_example4.jl\"","category":"page"},{"location":"examples/FOBP_example4/#Foundations-of-Bilevel-Programming:-Example-Chapter-5.1,-Page-127","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"","category":"section"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"This example is from the book Foundations of Bilevel Programming by Stephan Dempe, Chapter 5.1, Page 127. url","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"Model of the problem","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"First level","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"min x^2 + y\nnotag st\n-x-yleq 0","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"Second level","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"min x\nnotag st\nx geq 0","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"using BilevelJuMP\nusing Ipopt\n\nmodel = BilevelModel(Ipopt.Optimizer; mode = BilevelJuMP.ProductMode(1e-9))","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"First we need to create all of the variables in the upper and lower problems:","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"Upper level variables","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"@variable(Upper(model), y, start = 0)\n\n#Lower level variables\n@variable(Lower(model), x, start = 0)","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"Then we can add the objective and constraints of the upper problem:","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"Upper level objecive function","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"@objective(Upper(model), Min, x^2 + y)","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"Upper level constraints","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"@constraint(Upper(model), u1, -x - y <= 0)","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"Followed by the objective and constraints of the lower problem:","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"Lower objective function","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"@objective(Lower(model), Min, x)","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"Lower constraints","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"@constraint(Lower(model), l1, x >= 0)","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"Now we can solve the problem and verify the solution again that reported by Dempe.","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"optimize!(model)","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"primal_status(model)","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"termination_status(model)","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"Results","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"objective_value(model)","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"value(x)","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"value(y)\n\natol = 1e-3 # src","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"info: Info\nView this file on Github.","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"This page was generated using Literate.jl.","category":"page"},{"location":"#BilevelJuMP.jl-Documentation","page":"Home","title":"BilevelJuMP.jl Documentation","text":"","category":"section"},{"location":"#Introduction","page":"Home","title":"Introduction","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"BilevelJuMP is a package for modeling and solving bilevel optimization problems in Julia.","category":"page"},{"location":"","page":"Home","title":"Home","text":"As an extension of the JuMP modeling language, BilevelJuMP allows users to employ the usual JuMP syntax with minor modifications to describe the problem and query solutions.","category":"page"},{"location":"","page":"Home","title":"Home","text":"Many modeling features are available in BilevelJuMP, some of which are unique while others are also not widely available. The main features supported are:","category":"page"},{"location":"","page":"Home","title":"Home","text":"Arbitrary JuMP models in the upper level (NLP, Conic, MIP)\nConic constraints and quadratic objectives in the lower-level\nDual variables of the lower level in the upper level\nMPEC reformulations with MIP or NLP solvers\nMixedMode MPEC reformulation: select the best reformulation for each","category":"page"},{"location":"","page":"Home","title":"Home","text":"constraint separately","category":"page"},{"location":"","page":"Home","title":"Home","text":"The currently available methods are based on re-writing the problem using the KKT conditions of the lower level. For that, we make strong use of Dualization.jl","category":"page"},{"location":"#Installation","page":"Home","title":"Installation","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Install BilevelJuMP as follows:","category":"page"},{"location":"","page":"Home","title":"Home","text":"julia> import Pkg\n\njulia> Pkg.add(\"BilevelJuMP\")","category":"page"},{"location":"#Getting-started","page":"Home","title":"Getting started","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Learn the basics of","category":"page"},{"location":"","page":"Home","title":"Home","text":"JuMP and Julia in the JuMP documentation","category":"page"},{"location":"","page":"Home","title":"Home","text":"Follow the tutorials in this manual","category":"page"},{"location":"","page":"Home","title":"Home","text":"If you need help, please open a GitHub issue.","category":"page"},{"location":"#License","page":"Home","title":"License","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"BilevelJuMP.jl is licensed under the MIT License.","category":"page"},{"location":"#Citing-BilevelJuMP.jl","page":"Home","title":"Citing BilevelJuMP.jl","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"If you use BilevelJuMP.jl, we ask that you please cite the following paper:","category":"page"},{"location":"","page":"Home","title":"Home","text":"@article{diasgarcia2023bileveljump,\n title={{BilevelJuMP.jl}: {M}odeling and {S}olving {B}ilevel {O}ptimization {P}roblems in {J}ulia},\n author={{Dias Garcia}, Joaquim and Bodin, Guilherme and Street, Alexandre},\n journal={INFORMS Journal on Computing},\n doi={https://doi.org/10.1287/ijoc.2022.0135},\n pages={1-9},\n year={2023}\n}","category":"page"},{"location":"","page":"Home","title":"Home","text":"Here is an earlier preprint.","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"EditURL = \"https://github.com/joaquimg/BilevelJuMP.jl/blob/master/docs/src/examples/PHTP_example1.jl\"","category":"page"},{"location":"examples/PHTP_example1/#Princeton-Handbook-of-Test-Problems:-Test-9.3.2","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"","category":"section"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"This example is from the book Princeton Handbook of Test Problems in Local and Global Optimization, Floudas et al., Chapter 9.3.2, Page 221, url.","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"Model of the problem First level","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"min (x-5)^2+(2y+1)^2\nnotag st\nx geq 0\ny geq 0","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"Second level","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"min (y-1)^2-15xy\nnotag st\n-3x+y leq -3\nx-05y leq 4\nx+y leq 7","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"using BilevelJuMP\nusing Ipopt\n\nmodel = BilevelModel(Ipopt.Optimizer; mode = BilevelJuMP.ProductMode(1e-9))","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"First we need to create all of the variables in the upper and lower problems:","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"Upper level variables","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"@variable(Upper(model), x)\n\n#Lower level variables\n@variable(Lower(model), y)","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"Then we can add the objective and constraints of the upper problem:","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"Upper level objecive function","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"@objective(Upper(model), Min, (x - 5)^2 + (2y + 1)^2)","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"Upper level constraints","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"@constraint(Upper(model), x >= 0)\n@constraint(Upper(model), y >= 0)","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"Followed by the objective and constraints of the lower problem:","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"Lower objective function","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"@objective(Lower(model), Min, (y - 1)^2 - 1.5 * x * y)","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"Lower constraints","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"@constraint(Lower(model), -3x + y <= -3)\n@constraint(Lower(model), x - 0.5y <= 4)\n@constraint(Lower(model), x + y <= 7)","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"Now we can solve the problem and verify the solution again that reported by the book.","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"optimize!(model)","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"primal_status(model)","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"termination_status(model)","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"value(x)","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"value(y)","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"info: Info\nView this file on Github.","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"This page was generated using Literate.jl.","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"EditURL = \"https://github.com/joaquimg/BilevelJuMP.jl/blob/master/docs/src/tutorials/getting_started.jl\"","category":"page"},{"location":"tutorials/getting_started/#Getting-started-with-BilevelJuMP","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"","category":"section"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"This is a quick introduction to modeling and solving bilevel optimization with BilevelJuMP.","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"If you are new to Julia, start with the Getting started with Julia from the JuMP documentation.","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"If you are new to JuMP, start with the Getting started with JuMP from the JuMP documentation.","category":"page"},{"location":"tutorials/getting_started/#Installation","page":"Getting started with BilevelJuMP","title":"Installation","text":"","category":"section"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"BilevelJuMP is a JuMP extension that be installed by using the built-in package manager.","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"import Pkg\nPkg.add(\"BilevelJuMP\")","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"That is all you need to model a bilevel optimization problem, but we want to also solve the problems. Therefore we need a solver, one such solver is HiGHS.Optimizer, which is provided by the HiGHS.jl package.","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"import Pkg\nPkg.add(\"HiGHS\")","category":"page"},{"location":"tutorials/getting_started/#A-first-example","page":"Getting started with BilevelJuMP","title":"A first example","text":"","category":"section"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"We will solve the following bilevel optimization problem using BilevelJuMP and HiGHS. First we take a look in the entire code then we go through it step-by-step.","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"Here is the example from Dempe (2002), Chapter 3.2, Page 25:","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"beginalign*\n min_x y 3x + y \n textitst x leq 5 \n y leq 8 \n y geq 0 \n x(y) in\n beginalignedt\n argmin_x -x\n textitst x + y leq 8\n 4x + y geq 8\n 2x + y leq 13\n 2x - 7y leq 0\n endaligned\nendalign*","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"Here is the complete code to model, solve and query results from the example:","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"using BilevelJuMP\nusing HiGHS\n\nmodel = BilevelModel(\n HiGHS.Optimizer,\n mode = BilevelJuMP.FortunyAmatMcCarlMode(primal_big_M = 100, dual_big_M = 100))\n\n@variable(Lower(model), x)\n\n@variable(Upper(model), y)\n\n@objective(Upper(model), Min, 3x + y)\n\n@constraint(Upper(model), u1, x <= 5)\n@constraint(Upper(model), u2, y <= 8)\n@constraint(Upper(model), u3, y >= 0)\n\n@objective(Lower(model), Min, -x)\n\n@constraint(Lower(model), l1, x + y <= 8)\n@constraint(Lower(model), l2, 4x + y >= 8)\n@constraint(Lower(model), l3, 2x + y <= 13)\n@constraint(Lower(model), l4, 2x - 7y <= 0)\n\nprint(model)\n\noptimize!(model)\n\ntermination_status(model)\n\nprimal_status(model)\n\ndual_status(Lower(model))\n\ndual_status(Upper(model))\n\nobjective_value(model)\n\nobjective_value(Lower(model))\n\nobjective_value(Upper(model))\n\nvalue(x)\n\nvalue(y)\n\ndual(l1)\n\ndual(l2)","category":"page"},{"location":"tutorials/getting_started/#Step-by-step","page":"Getting started with BilevelJuMP","title":"Step-by-step","text":"","category":"section"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"Once installed, BilevelJuMP can be loaded into julia:","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"using BilevelJuMP","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"Note that JuMP comes inside BilevelJuMP, and does not need to be installed separately. Once loaded, all JuMP functions are exported along with the BilevelJuMP additional functions.","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"We include a solver, in this case HiGHS:","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"using HiGHS","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"Just like regular JuMP has the Model function to initialize an optimization problem, BilevelJuMP has the BilevelModel function that takes a solver as a first positional argument, in this case HiGHS.Optimizer and a mode keyword argument that selects a bilevel solution method, in this case, BilevelJuMP.FortunyAmatMcCarlMode. Note that BilevelJuMP.FortunyAmatMcCarlMode takes two optional keyword arguments: primal_big_M and dual_big_M which have to be larger than the value of all primal and dual variavle sof the lower level respectively to guarantee that the solution is no eliminated.","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"model = BilevelModel(\n HiGHS.Optimizer,\n mode = BilevelJuMP.FortunyAmatMcCarlMode(primal_big_M = 100, dual_big_M = 100))","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"For more on modes and solutions methods, see XXX.","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"We can proceed, as usual in JuMP models and incrementally build our bilevel problem. We use the same macros as JuMP.","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"Variables are modeled using the @variable macro, but in bilevel problems we must define which level the variable is decided, then we use the Upper and Lower constructors to direct variable to the proper levels:","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"@variable(Lower(model), x)\n\n@variable(Upper(model), y)","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"The same goes for objective that are modeled with the @objective macro:","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"@objective(Upper(model), Min, 3x + y)","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"and constraints that are modeled with the @objective macro:","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"@constraint(Upper(model), u1, x <= 5)\n@constraint(Upper(model), u2, y <= 8)\n@constraint(Upper(model), u3, y >= 0)","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"repeat for the lower level:","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"@objective(Lower(model), Min, -x)\n\n@constraint(Lower(model), l1, x + y <= 8)\n@constraint(Lower(model), l2, 4x + y >= 8)\n@constraint(Lower(model), l3, 2x + y <= 13)\n@constraint(Lower(model), l4, 2x - 7y <= 0)","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"display the model","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"print(model)","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"solve the bilevel problem, which will combine a mode (in this case FortunyAmatMcCarlMode) and a solver (in this case HiGHS):","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"optimize!(model)","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"check the termination_status to understand why the solver stopped:","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"termination_status(model)","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"check the primal_status to check if there is a feasible solution available:","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"primal_status(model)","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"check the dual_status to check if there is a dual solution available for the lower level:","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"dual_status(Lower(model))","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"do the same for the upper level:","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"dual_status(Upper(model))","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"info: Info\nMost method will not support upper level duals.","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"info: Info\nJuMP's dual_status is not available to BilevelModel's although you can query dual_status of each level.","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"Query the objecive value of the bilevel model","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"objective_value(model)","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"Query the objective value of the lower level and the upper level","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"objective_value(Lower(model))\n\nobjective_value(Upper(model))","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"Obtain primal solutions:","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"value(x)\n\nvalue(y)","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"and dual solutions:","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"dual(l1)\n\ndual(l2)","category":"page"},{"location":"tutorials/getting_started/#Model-basics","page":"Getting started with BilevelJuMP","title":"Model basics","text":"","category":"section"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"We created a BilevelModel passing the optimizer and mode and initialization:","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"model = BilevelModel(\n HiGHS.Optimizer,\n mode = BilevelJuMP.FortunyAmatMcCarlMode(primal_big_M = 100, dual_big_M = 100))","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"We could do piece by piece","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"model = BilevelModel()\n\nset_optimizer(model, HiGHS.Optimizer)\n\nBilevelJuMP.set_mode(model,\n BilevelJuMP.FortunyAmatMcCarlMode(primal_big_M = 100, dual_big_M = 100))","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"warning: Warning\nBoth BilevelModel and set_optimizer take a optimizer constructor, in this case HiGHS.Optimizer. Note that HiGHS.Optimizer() returns an instance of the HiGHS.Optimizer. Hence, and alternative way to pass this solver would be: set_optimizer(model, () -> HiGHS.Optimizer()).() -> HiGHS.Optimizer() is a an anonymous function that returns an instance of the HiGHS.Optimizer.","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"info: Info\nThere is no equivalent of JuMP's direct_model in BilevelJuMP.","category":"page"},{"location":"tutorials/getting_started/#Solver-options","page":"Getting started with BilevelJuMP","title":"Solver options","text":"","category":"section"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"it is also possible to pass optimizers with attributes:","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"model = BilevelModel(\n optimizer_with_attributes(HiGHS.Optimizer, \"output_flag\" => false))","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"or set such attributes separately:","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"model = BilevelModel(HiGHS.Optimizer)\n\nset_attribute(model, \"output_flag\", false)\n\nget_attribute(model, \"output_flag\")","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"info: Info\nView this file on Github.","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"This page was generated using Literate.jl.","category":"page"}] +[{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"EditURL = \"https://github.com/joaquimg/BilevelJuMP.jl/blob/master/docs/src/examples/DTMP_example1.jl\"","category":"page"},{"location":"examples/DTMP_example1/#Decomposition-Techniques-in-Mathematical-Programming:-Example-7.4","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"","category":"section"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"This example is from the book Decomposition Techniques in Mathematical Programming Chapter 7.2, page 281, url","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"Model of the problem First level","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"min -4y - x\nnotag st\ny + 2x leq 8","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"Second level","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"min - y - x\nnotag st\n- y leq 0\ny + x leq 7\n- x leq 0\nx leq 4","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"using BilevelJuMP\nusing Ipopt\n\nmodel = BilevelModel(Ipopt.Optimizer; mode = BilevelJuMP.ProductMode(1e-5))\n\nset_silent(model)","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"First we need to create all of the variables in the upper and lower problems:","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"Upper level variables","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"@variable(Upper(model), x, start = 1)","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"Lower level variables","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"@variable(Lower(model), y, start = 6)","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"Then we can add the objective and constraints of the upper problem:","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"Upper level objecive function","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"@objective(Upper(model), Min, 4y - x)","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"Upper level constraints","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"@constraint(Upper(model), y + 2x <= 8)","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"Followed by the objective and constraints of the lower problem:","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"Lower objective function","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"@objective(Lower(model), Min, - y -x )","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"Lower constraints","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"@constraint(Lower(model), - y <= 0)\n@constraint(Lower(model), y + x <= 7)\n@constraint(Lower(model), - x <= 0)\n@constraint(Lower(model), x <= 4)","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"Now we can solve the problem and verify the solution again that reported by book","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"optimize!(model)","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"Results","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"value(x)","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"value(y)","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"info: Info\nView this file on Github.","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"","category":"page"},{"location":"examples/DTMP_example1/","page":"Decomposition Techniques in Mathematical Programming: Example 7.4","title":"Decomposition Techniques in Mathematical Programming: Example 7.4","text":"This page was generated using Literate.jl.","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"EditURL = \"https://github.com/joaquimg/BilevelJuMP.jl/blob/master/docs/src/examples/FOBP_example2.jl\"","category":"page"},{"location":"examples/FOBP_example2/#Foundations-of-Bilevel-Programming:-Chapter-3.2,-Page-25","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"","category":"section"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"This example is from the book Foundations of Bilevel Programming by Stephan Dempe, Chapter 3.2, Page 25 url.","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"Model of the problem First level","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"min 3x + y\nnotag st\nx leq 5\ny leq 8\ny geq 0","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"Second level","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"min -x\nnotag st\nx + y = 8\n4x + y = 8\n2x + y = 13\n2x - y = 0","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"using BilevelJuMP\nusing Ipopt\n\nmodel = BilevelModel(Ipopt.Optimizer; mode = BilevelJuMP.ProductMode(1e-9))","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"First we need to define all of the variables in the upper and lower problems:","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"@variable(Upper(model), y, start = 8 / 15)\n\n@variable(Lower(model), x, start = 3.5 * 8 / 15)","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"Then we can add the objective and constraints of the upper problem: Upper level objective function","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"@objective(Upper(model), Min, 3x + y)","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"Upper level constraints","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"@constraints(Upper(model), begin\n u1, x <= 5\n u2, y <= 8\n u3, y >= 0\nend)","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"Followed by the objective and constraints of the lower problem: Lower level objective function","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"@objective(Lower(model), Min, -x)","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"Lower level constraints","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"@constraint(Lower(model), l1, x + y <= 8)\n@constraint(Lower(model), l2, 4x + y >= 8)\n@constraint(Lower(model), l3, 2x + y <= 13)\n@constraint(Lower(model), l4, 2x - 7y <= 0)","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"tip: Tip\nYou can use the singular @constraint macro or the plural @constraints!","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"We can also set hints for the variables associated with the problems.","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"In this example, we know the duals on the lower constraints are in the set [-15, 15]:","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"for c in [l1, l2, l3, l4]\n BilevelJuMP.set_dual_upper_bound_hint(c, 15)\n BilevelJuMP.set_dual_lower_bound_hint(c, -15)\nend","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"While we think the primal variables are in [-10, 6] for x and [-1, 9] for y. These hints are optional. But supplying them (e.g., from domain knowledge) can be helpful for the solver.","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"BilevelJuMP.set_primal_lower_bound_hint(x, -10)\nBilevelJuMP.set_primal_upper_bound_hint(x, 6)\nBilevelJuMP.set_primal_lower_bound_hint(y, -1)\nBilevelJuMP.set_primal_upper_bound_hint(y, 9)","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"Now we can solve the problem and verify the solution again that reported by Dempe.","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"optimize!(model)","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"objective_value(model)","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"objective_value(Lower(model))","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"value(x)","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"value(y)","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"value(u1)","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"value(l1)","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"dual(l1)","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"dual(l3)","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"info: Info\nView this file on Github.","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"","category":"page"},{"location":"examples/FOBP_example2/","page":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","title":"Foundations of Bilevel Programming: Chapter 3.2, Page 25","text":"This page was generated using Literate.jl.","category":"page"},{"location":"tutorials/quad_to_bin/","page":"Using QuadraticToBinary","title":"Using QuadraticToBinary","text":"EditURL = \"https://github.com/joaquimg/BilevelJuMP.jl/blob/master/docs/src/tutorials/quad_to_bin.jl\"","category":"page"},{"location":"tutorials/quad_to_bin/#Using-QuadraticToBinary","page":"Using QuadraticToBinary","title":"Using QuadraticToBinary","text":"","category":"section"},{"location":"tutorials/quad_to_bin/","page":"Using QuadraticToBinary","title":"Using QuadraticToBinary","text":"QuadraticToBinary.jl is a package that converts quadratic terms in constraints and objective. To do so the pack acts like a solver on top of the real solver and most data is forwarded directly to the solver itself. For many solvers it is enough to use:","category":"page"},{"location":"tutorials/quad_to_bin/","page":"Using QuadraticToBinary","title":"Using QuadraticToBinary","text":"using BilevelJuMP, QuadraticToBinary, HiGHS\n\nSOLVER = HiGHS.Optimizer()\nQ_SOLVER = QuadraticToBinary.Optimizer{Float64}(SOLVER, lb = -10, ub = 10)\nmodel = BilevelModel(()->Q_SOLVER, mode = BilevelJuMP.ProductMode(1e-6))\n\n@variable(Lower(model), x)\n@variable(Upper(model), y)\n\n@objective(Upper(model), Min, 3x + y)\n@constraints(Upper(model), begin\n x <= 5\n y <= 8\n y >= 0\nend)\n\n@objective(Lower(model), Min, -x)\n@constraints(Lower(model), begin\n x + y <= 8\n 4x + y >= 8\n 2x + y <= 13\n 2x - 7y <= 0\nend)\n\noptimize!(model)\n\nobjective_value(model)\n@assert abs(objective_value(model) - (3 * (3.5 * 8/15) + 8/15)) < 1e-1 # src","category":"page"},{"location":"tutorials/quad_to_bin/","page":"Using QuadraticToBinary","title":"Using QuadraticToBinary","text":"However, this might lead to some solver not supporting certain functionality like SCIP. In this case we need to:","category":"page"},{"location":"tutorials/quad_to_bin/","page":"Using QuadraticToBinary","title":"Using QuadraticToBinary","text":"using SCIP","category":"page"},{"location":"tutorials/quad_to_bin/","page":"Using QuadraticToBinary","title":"Using QuadraticToBinary","text":"warning: Warning\nSCIP requires a non-standard installation procedure in windows. See SCIP.jl for more details.","category":"page"},{"location":"tutorials/quad_to_bin/","page":"Using QuadraticToBinary","title":"Using QuadraticToBinary","text":"SOLVER = SCIP.Optimizer()\n\nCACHED_SOLVER = MOI.Utilities.CachingOptimizer(\n MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}()), SOLVER)\n\nQ_SOLVER = QuadraticToBinary.Optimizer{Float64}(CACHED_SOLVER)\n\nBilevelModel(()->Q_SOLVER, mode = BilevelJuMP.ProductMode(1e-5))","category":"page"},{"location":"tutorials/quad_to_bin/","page":"Using QuadraticToBinary","title":"Using QuadraticToBinary","text":"Note that we used ()->Q_SOLVER instead of just Q_SOLVER because BilevelModel requires as constructor and not an instance of an object.","category":"page"},{"location":"tutorials/quad_to_bin/","page":"Using QuadraticToBinary","title":"Using QuadraticToBinary","text":"info: Info\nView this file on Github.","category":"page"},{"location":"tutorials/quad_to_bin/","page":"Using QuadraticToBinary","title":"Using QuadraticToBinary","text":"","category":"page"},{"location":"tutorials/quad_to_bin/","page":"Using QuadraticToBinary","title":"Using QuadraticToBinary","text":"This page was generated using Literate.jl.","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"EditURL = \"https://github.com/joaquimg/BilevelJuMP.jl/blob/master/docs/src/examples/FOBP_example5.jl\"","category":"page"},{"location":"examples/FOBP_example5/#Foundations-of-Bilevel-Programming:-Example-Chapter-8.1,-Page-255","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"","category":"section"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"This example is from the book Foundations of Bilevel Programming by Stephan Dempe, Chapter 8.1, Page 255. url","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"Here, only the second level is described","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"Model of the problem First level","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"min 0","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"Second level","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"min x\nnotag st\nx+y leq 2\nx-y leq 2\n-4x+5y leq 10\n-4x-5y leq 10","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"using BilevelJuMP\nusing Ipopt\n\nmodel = BilevelModel(Ipopt.Optimizer; mode = BilevelJuMP.ProductMode(1e-9))","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"First we need to create all of the variables in the upper and lower problems:","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"Upper level variables","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"@variable(Upper(model), y, start = 0)\n\n#Lower level variables\n@variable(Lower(model), x, start = 0)","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"Then we can add the objective and constraints of the upper problem:","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"Upper level objecive function","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"@objective(Upper(model), Min, 0 * y + 0)","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"Followed by the objective and constraints of the lower problem:","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"Lower objective function","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"@objective(Lower(model), Min, x)","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"Lower constraints","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"@constraint(Lower(model), x + y <= 2)\n@constraint(Lower(model), x - y <= 2)\n@constraint(Lower(model), -4x + 5y <= 10)\n@constraint(Lower(model), -4x - 5y <= 10)","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"Now we can solve the problem and verify the solution again that reported by Dempe.","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"optimize!(model)","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"primal_status(model)","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"termination_status(model)","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"value(x)","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"value(y)","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"info: Info\nView this file on Github.","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"","category":"page"},{"location":"examples/FOBP_example5/","page":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","title":"Foundations of Bilevel Programming: Example Chapter 8.1, Page 255","text":"This page was generated using Literate.jl.","category":"page"},{"location":"manual/#Manual","page":"Manual","title":"Manual","text":"","category":"section"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"EditURL = \"https://github.com/joaquimg/BilevelJuMP.jl/blob/master/docs/src/examples/PHTP_example2.jl\"","category":"page"},{"location":"examples/PHTP_example2/#Princeton-Handbook-of-Test-Problems:-Test-9.3.4","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"","category":"section"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"This example is from the book Princeton Handbook of Test Problems in Local and Global Optimization Dempe, Chapter 9.3.4 -parg 223 url","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"Here, only the second level is described","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"Model of the problem First level","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"min 2x_1+2x_2-3y_1-3y_2-60\nnotag st\nx_1 + x_2 + y_1 -2y_2 -40leq 0\n0 leq x_i leq 50 forall i in I\n-10 leq y_j leq 20 forall j in J","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"Second level","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"min (-x_1 + y_1 + 40)^2 + (-x_2 + y_2 + 20)^2\nnotag st\n- x_i + 2y_j = -10forall (ij) in (ij)iin I jin J i=j\n-10 leq y_j leq 20 forall j in J","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"using BilevelJuMP\nusing Ipopt\n\nmodel = BilevelModel(Ipopt.Optimizer; mode = BilevelJuMP.ProductMode(1e-9))","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"First we need to create all of the variables in the upper and lower problems:","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"Upper level variables","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"@variable(Upper(model), x[i = 1:2], start = 0)","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"Lower level variables","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"@variable(Lower(model), y[i = 1:2], start = -10)","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"Then we can add the objective and constraints of the upper problem:","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"Upper level objecive function","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"@objective(Upper(model), Min, 2x[1] + 2x[2] - 3y[1] - 3y[2] - 60)","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"Upper level constraints","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"@constraint(Upper(model), x[1] + x[2] + y[1] - 2y[2] - 40 <= 0)\n@constraint(Upper(model), [i = 1:2], x[i] >= 0)\n@constraint(Upper(model), [i = 1:2], x[i] <= 50)\n@constraint(Upper(model), [i = 1:2], y[i] >= -10)\n@constraint(Upper(model), [i = 1:2], y[i] <= 20)","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"Followed by the objective and constraints of the lower problem:","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"Lower objective function","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"@objective(Lower(model), Min, (-x[1] + y[1] + 40)^2 + (-x[2] + y[2] + 20)^2)","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"Lower constraints","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"@constraint(Lower(model), [i = 1:2], -x[i] + 2y[i] <= -10)\n@constraint(Lower(model), [i = 1:2], y[i] >= -10)\n@constraint(Lower(model), [i = 1:2], y[i] <= 20)","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"Now we can solve the problem and verify the solution again that reported by the book","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"optimize!(model)","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"primal_status(model)","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"termination_status(model)","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"objective_value(model)","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"value.(x)","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"value.(y)","category":"page"},{"location":"examples/PHTP_example2/#Like-any-other-optimization-problem,-there-is-a-chance-in-bilevel","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Like any other optimization problem, there is a chance in bilevel","text":"","category":"section"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"optimization to find multiple solutions with the same optimal value; based on the inherent stochasticity of the algorithm and random seed, we are expecting two optimal solutions for this problem.","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"info: Info\nView this file on Github.","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"","category":"page"},{"location":"examples/PHTP_example2/","page":"Princeton Handbook of Test Problems: Test 9.3.4","title":"Princeton Handbook of Test Problems: Test 9.3.4","text":"This page was generated using Literate.jl.","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"EditURL = \"https://github.com/joaquimg/BilevelJuMP.jl/blob/master/docs/src/examples/SOCBLP_example1.jl\"","category":"page"},{"location":"examples/SOCBLP_example1/#SOCBLP-from-Chi-et-al.:-Example-3.1","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"","category":"section"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"This example is from The models of bilevel programming with lower level second-order cone programs (url or url) SOCBLP stands for bilevel programming problem with lower level second-order cone program Bold point(s): Using second-order cone in the lower level problem","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"Model of the problem First level","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"min x + 3(y_1-y_2)\nnotag st\n2 leq x leq 6","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"Second level","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"min - y_1 + y_2\nnotag st\nx + y_1 - y_2 leq 8\nx + 4(y_1 - y_2) geq 8\nx + 2(y_1 - y_2) leq 12\ny_1 geq 0\ny_2 geq 0\ny in K^2","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"Here, K^2 is second order cone and it represents:","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"y in y=(y_1y_2)in mathbbRtimes mathbbRy_1 geq y_2_2","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"using BilevelJuMP\nusing Ipopt\n\nmodel = BilevelModel(\n () -> MOI.Bridges.Constraint.SOCtoNonConvexQuad{Float64}(Ipopt.Optimizer());\n mode = BilevelJuMP.ProductMode(1e-9),\n)","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"First we need to create all of the variables in the upper and lower problems:","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"Upper level variables","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"@variable(Upper(model), x)\n\n#Lower level variables\n@variable(Lower(model), y[i = 1:2])","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"Then we can add the objective and constraints of the upper problem:","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"Upper level objecive function","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"@objective(Upper(model), Min, x + 3(y[1] - y[2]))","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"Upper level constraints","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"@constraint(Upper(model), x >= 2)\n@constraint(Upper(model), x <= 6)","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"Followed by the objective and constraints of the lower problem:","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"Lower objective function","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"@objective(Lower(model), Min, -(y[1] - y[2]))","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"Lower constraints","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"@constraint(Lower(model), lb_y_1, y[1] >= 0)\n@constraint(Lower(model), lb_y_2, y[2] >= 0)\n@constraint(Lower(model), con1, x + (y[1] - y[2]) <= 8)\n@constraint(Lower(model), con2, x + 4(y[1] - y[2]) >= 8)\n@constraint(Lower(model), con3, x + 2(y[1] - y[2]) <= 12)\n@constraint(Lower(model), soc_lw, y in SecondOrderCone())","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"Defining bounds","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"BilevelJuMP.set_dual_upper_bound_hint(soc_lw, +[5.0, 5.0])\nBilevelJuMP.set_dual_lower_bound_hint(soc_lw, -[5.0, 5.0])","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"require lower bounds","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"for con in [con1, con3]\n BilevelJuMP.set_dual_lower_bound_hint(con, -15)\nend","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"require upper bounds","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"for con in [lb_y_1, lb_y_2, con2]\n BilevelJuMP.set_dual_upper_bound_hint(con, +15)\nend","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"bounds defined in the upper level are not dualized","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"for i in 1:2\n @constraint(Upper(model), y[i] in MOI.LessThan(+5.0))\n @constraint(Upper(model), y[i] in MOI.GreaterThan(-5.0))\nend","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"Now we can solve the problem and verify the solution again that reported by","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"optimize!(model)\n\nprimal_status(model)\n\ntermination_status(model)\n\nobjective_value(model)\n\nvalue.(y)","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"info: Info\nView this file on Github.","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"","category":"page"},{"location":"examples/SOCBLP_example1/","page":"SOCBLP from Chi et al.: Example 3.1","title":"SOCBLP from Chi et al.: Example 3.1","text":"This page was generated using Literate.jl.","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"EditURL = \"https://github.com/joaquimg/BilevelJuMP.jl/blob/master/docs/src/examples/MibS_example1.jl\"","category":"page"},{"location":"examples/MibS_example1/#MibS:-Example-1-(Experimental-feature)","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"","category":"section"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"Model of the problem First level","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"min_x -3x -7y\nnotag st\n-3x + 2y leq 12\nx + 2y leq 20\nx leq 10\nx in mathbbZ","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"Second level","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"min_y y\nnotag st\n2x - y = 7\n-2x + 4y = 16\ny = 5\ny in mathbbZ","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"using BilevelJuMP\nusing Test\nusing MibS_jll\n\nmodel = BilevelModel()","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"First we need to create all of the variables in the upper and lower problems:","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"Upper level variables","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"@variable(Upper(model), x, Int)\n\n#Lower level variables\n@variable(Lower(model), y, Int)","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"Then we can add the objective and constraints of the upper problem:","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"Upper level objecive function","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"@objective(Upper(model), Min, -3x - 7y)","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"Upper constraints","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"@constraints(Upper(model), begin\n u1, -3x + 2y <= 12\n u2, x + 2y <= 20\n u3, x <= 10\nend)","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"Followed by the objective and constraints of the lower problem:","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"Lower objective function","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"@objective(Lower(model), Min, y)","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"Lower constraints","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"@constraint(Lower(model), l1, 2x - y <= 7)\n@constraint(Lower(model), l2, -2x + 4y <= 16)\n@constraint(Lower(model), l3, y <= 5)","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"Using MibS Solver","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"solution = BilevelJuMP.solve_with_MibS(model, MibS_jll.mibs)","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"Auto testing","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"@test solution.status == true\n@test solution.objective ≈ -53\n@test solution.nonzero_upper == Dict(0 => 6.0)\n@test solution.nonzero_lower == Dict(0 => 5.0)\n@test solution.all_upper[\"x\"] == 6.0\n@test solution.all_lower[\"y\"] == 5.0","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"info: Info\nView this file on Github.","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"","category":"page"},{"location":"examples/MibS_example1/","page":"MibS: Example 1 (Experimental feature)","title":"MibS: Example 1 (Experimental feature)","text":"This page was generated using Literate.jl.","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"EditURL = \"https://github.com/joaquimg/BilevelJuMP.jl/blob/master/docs/src/tutorials/lower_duals.jl\"","category":"page"},{"location":"tutorials/lower_duals/#Dual-variables-of-the-lower-level","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"","category":"section"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"This is a quick introduction to modeling and solving bilevel optimization with BilevelJuMP.","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"This modeling feature enables the implementation of workflows where one (or more) of the upper-level variables is the dual of a lower-level constraint. In particular, in the energy sector, it is common to model the energy prices as the dual variable associated with the energy demand equilibrium constraint. One example of an application that uses this feature is Fanzeres et al. (2019), which focuses on strategic bidding in auction-based energy markets. A small and simplified example of the modeled problem would be the model:","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"beginalign\n max_lambda q_S quad lambda cdot g_S \n textitst quad 0 leq q_S leq 100\n hspace28pt (g_S lambda) in argmin_g_S g_1 g_2 g_D 50 g_R1 + 100 g_R2 + 1000 g_D\n hspace70pt textitst quad g_S leq q_S \n hspace88pt quad 0 leq g_S leq 100 \n hspace88ptquad 0 leq g_1 leq 40 \n hspace88ptquad 0 leq g_2 leq 40 \n hspace88ptquad 0 leq g_D leq 100 \n hspace88ptquad g_S + g_1 + g_2 + g_D = 100 quad quad lambda labeleq-dual-lambda\nendalign","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"Where lambda is the dual of the load balance constraint (last constraint in the lower part), g_S, g_1, g_2 represent the generation of the strategic bidder and from two other (non-strategic) plants. g_D represents the deficit in generation. Finally, q_S is the quantity bid optimized by the strategic generator.","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"load packages","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"using BilevelJuMP\nusing Ipopt\nusing QuadraticToBinary\nusing HiGHS","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"BilevelJuMP.jl allows users to implement similar models using the function DualOf that binds a new variable in the upper level to an existing constraint in the lower level. The model can be written as:","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"model = BilevelModel()\n@variable(Upper(model), 0 <= qS <= 100)\n@variable(Lower(model), 0 <= gS <= 100)\n@variable(Lower(model), 0 <= gR1 <= 40)\n@variable(Lower(model), 0 <= gR2 <= 40)\n@variable(Lower(model), 0 <= gD <= 100)\n@objective(Lower(model), Min, 50gR1 + 100gR2 + 1000gD)\n@constraint(Lower(model), gS <= qS)\n@constraint(Lower(model), demand_equilibrium, gS + gR1 + gR2 + gD == 100)\n@variable(Upper(model), lambda, DualOf(demand_equilibrium))\n@objective(Upper(model), Max, lambda*gS)","category":"page"},{"location":"tutorials/lower_duals/#NLP-solution","page":"Dual variables of the lower level","title":"NLP solution","text":"","category":"section"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"This model, can be solved by selecting a reformulation and a solver. Here we select Strong-Duality reformulation, the Ipopt solver and call optimizes to perform the reformulation and solve it.","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"BilevelJuMP.set_mode(model, BilevelJuMP.StrongDualityMode())\nset_optimizer(model, Ipopt.Optimizer)\noptimize!(model)","category":"page"},{"location":"tutorials/lower_duals/#MIP-solution","page":"Dual variables of the lower level","title":"MIP solution","text":"","category":"section"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"It is also possible to solve such problem by using a MIP formulation. The main issue is the product of variable in the upper level objective. However, this can be easily handled by using the package QuadraticToBinary.jl for automatic binary expansions. Because binary expansions require bounds on variables, we add the following lines:","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"set_lower_bound(lambda, 0.0)\nset_upper_bound(lambda, 1000.0)","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"Then, as before, we set a solver (now HiGHS with the QuadraticToBinary.jl wrapper) and a solution method (now Fortuny-Amat and McCarl):","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"set_optimizer(model,\n ()->QuadraticToBinary.Optimizer{Float64}(HiGHS.Optimizer()))\nBilevelJuMP.set_mode(model,\n BilevelJuMP.FortunyAmatMcCarlMode(dual_big_M = 100))\noptimize!(model)","category":"page"},{"location":"tutorials/lower_duals/#More-on-DualOf-usage","page":"Dual variables of the lower level","title":"More on DualOf usage","text":"","category":"section"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"You might have a problem where you want duals of a vector of constraints like:","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"@constraint(Lower(model), reserves[i=1:3], (40 - gR1) + (40 - gR2) == 10 * i)","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"then you can do","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"@variable(Upper(model), reserve_dual[i=1:3], DualOf(reserves[i]))","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"or use anonymous variables","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"my_duals = []\nfor i in 1:3\n var = @variable(Upper(model), variable_type = DualOf(reserves[i]))\n push!(my_duals, var)\nend\nmy_duals # a vector of anonimous variables","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"info: Info\nView this file on Github.","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"","category":"page"},{"location":"tutorials/lower_duals/","page":"Dual variables of the lower level","title":"Dual variables of the lower level","text":"This page was generated using Literate.jl.","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"EditURL = \"https://github.com/joaquimg/BilevelJuMP.jl/blob/master/docs/src/examples/FOBP_example3.jl\"","category":"page"},{"location":"examples/FOBP_example3/#Foundations-of-Bilevel-Programming:-Chapter-3.7,-Page-59","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"","category":"section"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"This example is from the book Foundations of Bilevel Programming by Stephan Dempe, Chapter 3.7, Page 59. url","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"Model of the problem","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"First level","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"min sum_iin I x_i - z\nnotag st\ny^a_igeq 0 forall i in I\ny^a_ileq 1 forall i in I\ny^b_igeq 0 forall i in I\ny^b_ileq 1 forall i in I\ny^a_i + y^b_i = 1 forall i in I\nzgeq 0\nzleq 1\ny^a_1 + y^a_2 + y^a_3 geq z\n-y^b_1 - y^b_4 + y^a_3 geq z\ny^b_7 - y^b_6 + y^a_4 geq z\ny^a_5 + y^a_6 + y^a_7 geq z","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"Second level","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"min -sum_iin Ix_i\nnotag st\nsum x_i geq 0\nx_i leq y^a_i forall iin I\nx_i leq y^b_i forall iin I\nI = 17","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"using BilevelJuMP\nusing Ipopt\n\nmodel = BilevelModel(Ipopt.Optimizer; mode = BilevelJuMP.ProductMode(1e-9))","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"Global variables","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"I = 7 # maximum literals\nclauses = [[1, 2, 3], [-1, -4, 3], [7, -6, 4], [5, 6, 7]]","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"First we need to create all of the variables in the upper and lower problems:","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"Upper level variables","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"@variable(Upper(model), ya[i = 1:I])\n@variable(Upper(model), yb[i = 1:I])\n@variable(Upper(model), z)\n\n#Lower level variables\n@variable(Lower(model), x[i = 1:I])","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"Then we can add the objective and constraints of the upper problem:","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"Upper level objecive function","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"@objective(Upper(model), Min, sum(x[i] for i in 1:I) - z)","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"Upper level constraints","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"@constraint(Upper(model), ca, z <= 1)\n@constraint(Upper(model), cb, z >= 0)\n@constraint(Upper(model), c1[i = 1:I], ya[i] >= 0)\n@constraint(Upper(model), c2[i = 1:I], ya[i] <= 1)\n@constraint(Upper(model), c3[i = 1:I], yb[i] >= 0)\n@constraint(Upper(model), c4[i = 1:I], yb[i] <= 1)\n@constraint(Upper(model), c5[i = 1:I], ya[i] + yb[i] == 1)","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"for c in clauses","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"@constraint(\n Upper(model),\n cc[k in eachindex(clauses)],\n sum(i > 0 ? ya[i] : yb[-i] for i in clauses[k]) >= z\n)","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"Followed by the objective and constraints of the lower problem:","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"Lower objective function","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"@objective(Lower(model), Min, -sum(x[i] for i in 1:I))","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"Lower constraints","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"@constraint(Lower(model), b1[i = 1:I], x[i] >= 0)\n@constraint(Lower(model), b2[i = 1:I], x[i] <= ya[i])\n@constraint(Lower(model), b3[i = 1:I], x[i] <= yb[i])","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"Initial Starting conditions","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"JuMP.set_start_value.(x, 0)\nJuMP.set_start_value.(ya, 1)\nJuMP.set_start_value.(yb, 0)\nJuMP.set_start_value(z, 1)\nfor i in 1:I\n JuMP.set_dual_start_value.(b1, 0)\n JuMP.set_dual_start_value.(b2, 0)\n JuMP.set_dual_start_value.(b3, -1)\nend","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"Now we can solve the problem and verify the solution again that reported by Dempe.","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"optimize!(model)","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"primal_status(model)","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"termination_status(model)","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"Results","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"objective_value(model)","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"value.(x)","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"value.(ya)","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"value.(yb)","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"value(z)","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"info: Info\nView this file on Github.","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"","category":"page"},{"location":"examples/FOBP_example3/","page":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","title":"Foundations of Bilevel Programming: Chapter 3.7, Page 59","text":"This page was generated using Literate.jl.","category":"page"},{"location":"troubleshooting/#Troubleshooting","page":"Troubleshooting","title":"Troubleshooting","text":"","category":"section"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"Cbc has known bugs in its SOS1 constraints, so BilevelJuMP.SOS1Mode might","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"not work properly with Cbc.","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"For anonymous variables with DualOf use:","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"@variable(Upper(model, variable_type = DualOf(my_lower_constraint)))","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"Nonconvex/nonconcave/nonpsd objective/constraint error in a MIP solver.","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"If you are using Gurobi use:","category":"page"},{"location":"troubleshooting/","page":"Troubleshooting","title":"Troubleshooting","text":"model = BilevelModel(Gurobi.Optimizer, mode = BilevelJuMP.SOS1Mode()) #or other mode\nset_optimizer_attribute(model, \"NonConvex\", 2)","category":"page"},{"location":"reference/#API","page":"API Reference","title":"API","text":"","category":"section"},{"location":"reference/","page":"API Reference","title":"API Reference","text":"This section documents the BilevelJuMP API.","category":"page"},{"location":"reference/","page":"API Reference","title":"API Reference","text":"As a JuMP extension, most JuMP functions should just work. Some JuMP function will return error saying they are not implemented for BileveJuMP structures such as BilevelModel. If that happens and you consider that function should be implemented, please, open an issue.","category":"page"},{"location":"reference/#Constructors","page":"API Reference","title":"Constructors","text":"","category":"section"},{"location":"reference/","page":"API Reference","title":"API Reference","text":"BilevelModel\nUpper\nLower\nDualOf","category":"page"},{"location":"reference/#BilevelJuMP.BilevelModel","page":"API Reference","title":"BilevelJuMP.BilevelModel","text":"BilevelModel()\n\nCreate an empty BilevelModel with default settings, no solver and no solve mode.\n\nExample\n\njulia> model = BilevelModel()\n\nBilevelModel(solver::Function; mode = BilevelJuMP.SOS1Mode(), add_bridges::Bool = true)\n\nCreate a BilevelModel with the given solver and solve mode.\n\nsolver: is a functions that takes no arguments and returns a JuMP solver object.\nmode: is a solve mode object that defines how the model is solved.\nadd_bridges: if true (default) then bridges are added to the model. If false then bridges are not added and the model is not modified.\n\nExample\n\njulia> model = BilevelModel(\n HiGHS.Optimizer,\n mode = BilevelJuMP.FortunyAmatMcCarlMode(primal_big_M = 1e6, dual_big_M = 1e6))\n\nwhich is equivalent to\n\njulia> model = BilevelModel(\n ()->HiGHS.Optimizer(),\n mode = BilevelJuMP.FortunyAmatMcCarlMode(primal_big_M = 1e6, dual_big_M = 1e6))\n\nand equivalent to\n\njulia> model = BilevelModel()\n\njulia> BilevelJuMP.set_solver(model, HiGHS.Optimizer)\n\njulia> BilevelJuMP.set_mode(model, BilevelJuMP.FortunyAmatMcCarlMode(primal_big_M = 1e6, dual_big_M = 1e6))\n\n\n\n\n\n","category":"type"},{"location":"reference/#BilevelJuMP.Upper","page":"API Reference","title":"BilevelJuMP.Upper","text":"Upper(model::BilevelModel)\n\nCreate a reference to the upper level of a bilevel model.\n\nExample\n\njulia> model = BilevelModel();\n\njulia> @variable(Upper(model), x >= 0)\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.Lower","page":"API Reference","title":"BilevelJuMP.Lower","text":"Lower(model::BilevelModel)\n\nCreate a reference to the lower level of a bilevel model.\n\nExample\n\njulia> model = BilevelModel();\n\njulia> @variable(Lower(model), x >= 0)\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.DualOf","page":"API Reference","title":"BilevelJuMP.DualOf","text":"DualOf(constraint::ConstraintRef)\n\nGet the dual variable associated with a constraint. This is only valid for constraints in the upper level of a bilevel model.\n\nExamples\n\njulia> m = BilevelModel();\n\njulia> @variable(Lower(m), x >= 0);\n\njulia> @constraint(Lower(m), c, x <= 1);\n\njulia> @variable(Upper(m), y, DualOf(c));\n\n\n\n\n\n","category":"type"},{"location":"reference/#Advanced-constructors","page":"API Reference","title":"Advanced constructors","text":"","category":"section"},{"location":"reference/","page":"API Reference","title":"API Reference","text":"UpperOnly\nLowerOnly","category":"page"},{"location":"reference/#BilevelJuMP.UpperOnly","page":"API Reference","title":"BilevelJuMP.UpperOnly","text":"UpperOnly(model::BilevelModel)\n\nCreate a special reference to the upper level of a bilevel model. Variables created with this reference will not be shared with the lower level.\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.LowerOnly","page":"API Reference","title":"BilevelJuMP.LowerOnly","text":"LowerOnly(model::BilevelModel)\n\nCreate a special reference to the lower level of a bilevel model. Variables created with this reference will not be shared with the upper level.\n\n\n\n\n\n","category":"function"},{"location":"reference/#Enums","page":"API Reference","title":"Enums","text":"","category":"section"},{"location":"reference/","page":"API Reference","title":"API Reference","text":"BilevelJuMP.Level\nBilevelJuMP.LOWER_BOTH\nBilevelJuMP.UPPER_BOTH\nBilevelJuMP.LOWER_ONLY\nBilevelJuMP.UPPER_ONLY\nBilevelJuMP.DUAL_OF_LOWER","category":"page"},{"location":"reference/#BilevelJuMP.Level","page":"API Reference","title":"BilevelJuMP.Level","text":"Level\n\nThe level of a variable in a bilevel problem.\n\n\n\n\n\n","category":"type"},{"location":"reference/#BilevelJuMP.LOWER_BOTH","page":"API Reference","title":"BilevelJuMP.LOWER_BOTH","text":"Indicates and object that is part of the lower level problem, but is shared with the upper level.\n\n\n\n\n\n","category":"constant"},{"location":"reference/#BilevelJuMP.UPPER_BOTH","page":"API Reference","title":"BilevelJuMP.UPPER_BOTH","text":"Indicates and object that is part of the upper level problem, but is shared with the lower level.\n\n\n\n\n\n","category":"constant"},{"location":"reference/#BilevelJuMP.LOWER_ONLY","page":"API Reference","title":"BilevelJuMP.LOWER_ONLY","text":"Indicates and object that is part of the lower level problem, but is not shared with the upper level.\n\n\n\n\n\n","category":"constant"},{"location":"reference/#BilevelJuMP.UPPER_ONLY","page":"API Reference","title":"BilevelJuMP.UPPER_ONLY","text":"Indicates and object that is part of the upper level problem, but is not shared with the lower level.\n\n\n\n\n\n","category":"constant"},{"location":"reference/#BilevelJuMP.DUAL_OF_LOWER","page":"API Reference","title":"BilevelJuMP.DUAL_OF_LOWER","text":"Indicates and object that is part of the dual of the lower level problem, and is shared with the upper level.\n\n\n\n\n\n","category":"constant"},{"location":"reference/","page":"API Reference","title":"API Reference","text":"BilevelJuMP.IndicatorSetting\nBilevelJuMP.ZERO_ONE\nBilevelJuMP.ZERO_ZERO\nBilevelJuMP.ONE_ONE","category":"page"},{"location":"reference/#BilevelJuMP.IndicatorSetting","page":"API Reference","title":"BilevelJuMP.IndicatorSetting","text":"IndicatorSetting\n\nThe type of indicator function to use in the IndicatorMode mode.\n\n\n\n\n\n","category":"type"},{"location":"reference/#BilevelJuMP.ZERO_ONE","page":"API Reference","title":"BilevelJuMP.ZERO_ONE","text":"Activates the indicator constraint on the primal constraint if the auxiliaty binary is zero and activates the indicator constraint on the dual variable if the auxiliary binary is one.\n\n\n\n\n\n","category":"constant"},{"location":"reference/#BilevelJuMP.ZERO_ZERO","page":"API Reference","title":"BilevelJuMP.ZERO_ZERO","text":"Activates the indicator constraint on the primal constraint if the auxiliaty binary is zero and activates the indicator constraint on the dual variable if the auxiliary binary is zero.\n\n\n\n\n\n","category":"constant"},{"location":"reference/#BilevelJuMP.ONE_ONE","page":"API Reference","title":"BilevelJuMP.ONE_ONE","text":"Activates the indicator constraint on the primal constraint if the auxiliaty binary is one and activates the indicator constraint on the dual variable if the auxiliary binary is one.\n\n\n\n\n\n","category":"constant"},{"location":"reference/#Structs","page":"API Reference","title":"Structs","text":"","category":"section"},{"location":"reference/","page":"API Reference","title":"API Reference","text":"BilevelVariableRef\nBilevelAffExpr\nBilevelQuadExpr","category":"page"},{"location":"reference/#BilevelJuMP.BilevelVariableRef","page":"API Reference","title":"BilevelJuMP.BilevelVariableRef","text":"BilevelVariableRef\n\nHolds a reference to a variable in a bilevel model.\n\n\n\n\n\n","category":"type"},{"location":"reference/#BilevelJuMP.BilevelAffExpr","page":"API Reference","title":"BilevelJuMP.BilevelAffExpr","text":"BilevelVariableRef\n\nAlias for GenericAffExpr{Float64,BilevelVariableRef}.\n\n\n\n\n\n","category":"type"},{"location":"reference/#BilevelJuMP.BilevelQuadExpr","page":"API Reference","title":"BilevelJuMP.BilevelQuadExpr","text":"BilevelQuadExpr\n\nAlias for GenericQuadExpr{Float64,BilevelVariableRef}.\n\n\n\n\n\n","category":"type"},{"location":"reference/#Modes","page":"API Reference","title":"Modes","text":"","category":"section"},{"location":"reference/","page":"API Reference","title":"API Reference","text":"BilevelJuMP.SOS1Mode\nBilevelJuMP.FortunyAmatMcCarlMode\nBilevelJuMP.IndicatorMode\nBilevelJuMP.ProductMode\nBilevelJuMP.StrongDualityMode\nBilevelJuMP.ComplementMode\nBilevelJuMP.MixedMode","category":"page"},{"location":"reference/#BilevelJuMP.SOS1Mode","page":"API Reference","title":"BilevelJuMP.SOS1Mode","text":"SOS1Mode()\n\nUsed to solve a bilevel problem with the MPEC reformulation using SOS1 constraints to convert complementarity constraints into mixed-integer constraints.\n\n\n\n\n\n","category":"type"},{"location":"reference/#BilevelJuMP.FortunyAmatMcCarlMode","page":"API Reference","title":"BilevelJuMP.FortunyAmatMcCarlMode","text":"FortunyAmatMcCarlMode\n\nSee BigMMode for more details.\n\n\n\n\n\n","category":"type"},{"location":"reference/#BilevelJuMP.IndicatorMode","page":"API Reference","title":"BilevelJuMP.IndicatorMode","text":"IndicatorMode(method::IndicatorSetting = BilevelJuMP.ONE_ONE)\n\nUsed to solve a bilevel problem with the MPEC reformulation using indicator constaints to convert complementarity constraints to a mixed integer formulation.\n\nmethod indicates how the indicator constraints are activated for primal cosntraints and dual variables. See IndicatorSetting for more details.\n\n\n\n\n\n","category":"type"},{"location":"reference/#BilevelJuMP.ProductMode","page":"API Reference","title":"BilevelJuMP.ProductMode","text":"ProductMode(epsilon = 0.0; with_slack = false, aggregation_group = nothing)\n\nUsed to solve a bilevel problem with the MPEC reformulation using products to convert complementarity constraints into non-convex quadratic constraints.\n\nwith_slack indicates whether to use slack variables to reformulate the complementarity constraints. Given a pair expr and var, the reformulation is expr == slack and var * slack == 0 instead of expr * slack == 0.\naggregation_group indicates whether to aggregate the products into a single quadratic constraint. If aggregation_group is nothing, then each product is converted into a quadratic constraint. If aggregation_group is a positive integer, then products with the same aggregation_group are aggregated into a single quadratic constraint.\n\n\n\n\n\n","category":"type"},{"location":"reference/#BilevelJuMP.StrongDualityMode","page":"API Reference","title":"BilevelJuMP.StrongDualityMode","text":"StrongDualityMode(eps = 0.0, inequality = true)\n\nA mode that adds a strong duality constraint of the lower level problem instead of reformulating the complementarity constraints.\n\neps: The tolerance for the strong duality constraint. Defaults to 0.0.\ninequality: If true the strong duality constraint is added as two inequality constraints. If false the strong duality constraint is added as an equality constraint. Defaults to true.\n\n\n\n\n\n","category":"type"},{"location":"reference/#BilevelJuMP.ComplementMode","page":"API Reference","title":"BilevelJuMP.ComplementMode","text":"ComplementMode(; with_slack = false)\n\nUsed to solve a bilevel problem with the MPEC reformulation using actual complementarity constraints. A limited number of solvers support this mode. One example is Knitro.\n\nwith_slack indicates whether to use slack variables to reformulate the complementarity constraints. Given a pair expr and var, the reformulation is expr == slack and var ⟂ slack instead of expr ⟂ slack.\n\n\n\n\n\n","category":"type"},{"location":"reference/#BilevelJuMP.MixedMode","page":"API Reference","title":"BilevelJuMP.MixedMode","text":"MixedMode(; default = SOS1Mode())\n\nA mode that allows to mix different modes for different constraints and variables.\n\ndefault is the default mode to use for all constraints and variables that are not explicitly mapped to a mode.\n\n\n\n\n\n","category":"type"},{"location":"reference/#Bound-hints","page":"API Reference","title":"Bound hints","text":"","category":"section"},{"location":"reference/","page":"API Reference","title":"API Reference","text":"BilevelJuMP.set_dual_upper_bound_hint\nBilevelJuMP.get_dual_upper_bound_hint\nBilevelJuMP.set_dual_lower_bound_hint\nBilevelJuMP.get_dual_lower_bound_hint\nBilevelJuMP.set_primal_upper_bound_hint\nBilevelJuMP.get_primal_upper_bound_hint\nBilevelJuMP.set_primal_lower_bound_hint\nBilevelJuMP.get_primal_lower_bound_hint","category":"page"},{"location":"reference/#BilevelJuMP.set_dual_upper_bound_hint","page":"API Reference","title":"BilevelJuMP.set_dual_upper_bound_hint","text":"set_dual_upper_bound_hint(cref, value)\n\nSet a upper bound to the dual variable of the constraint cref to value. This bound will not be dualized. The dual upper bound hint is used to help the solution method.\n\nSolution modes can be benefitted from this hint:\n\nBigMMode will use this information to compute a tighter bound for the dual variable.\nOther modes will be stabilized by the existence of the bounds on variables that would otherwise no be bounded.\nBounds that are not dualized are also useful for binary expansions of products of variables that can be done with QuadraticToBinary.jl.\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.get_dual_upper_bound_hint","page":"API Reference","title":"BilevelJuMP.get_dual_upper_bound_hint","text":"get_dual_upper_bound_hint(cref)\n\nGet the upper bound to the dual variable of the constraint cref that was set with set_dual_upper_bound_hint.\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.set_dual_lower_bound_hint","page":"API Reference","title":"BilevelJuMP.set_dual_lower_bound_hint","text":"set_dual_lower_bound_hint(cref, value)\n\nSet a lower bound to the dual variable of the constraint cref to value. This bound will not be dualized. The dual lower bound hint is used to help the solution method.\n\nSolution modes can be benefitted from this hint:\n\nBigMMode will use this information to compute a tighter bound for the dual variable.\nOther modes will be stabilized by the existence of the bounds on variables that would otherwise no be bounded.\nBounds that are not dualized are also useful for binary expansions of products of variables that can be done with QuadraticToBinary.jl.\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.get_dual_lower_bound_hint","page":"API Reference","title":"BilevelJuMP.get_dual_lower_bound_hint","text":"get_dual_lower_bound_hint(cref)\n\nGet the lower bound to the dual variable of the constraint cref that was set with set_dual_lower_bound_hint.\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.set_primal_upper_bound_hint","page":"API Reference","title":"BilevelJuMP.set_primal_upper_bound_hint","text":"set_primal_upper_bound_hint(vref, value)\n\nSet a upper bound to the prima variable vref to value. This bound will not be dualized. The upper bound hint is used to help the solution method.\n\nSolution modes can be benefitted from this hint:\n\nBigMMode will use this information to compute a tighter bound for the primal constraint variable.\nOther modes will be stabilized by the existence of the bounds on variables that would otherwise no be bounded.\nBounds that are not dualized are also useful for binary expansions of products of variables that can be done with QuadraticToBinary.jl.\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.get_primal_upper_bound_hint","page":"API Reference","title":"BilevelJuMP.get_primal_upper_bound_hint","text":"get_primal_upper_bound_hint(cref)\n\nGet the upper bound to the primal variable of the constraint cref that was set with set_primal_upper_bound_hint.\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.set_primal_lower_bound_hint","page":"API Reference","title":"BilevelJuMP.set_primal_lower_bound_hint","text":"set_primal_lower_bound_hint(vref, value)\n\nSet a lower bound to the prima variable vref to value. This bound will not be dualized. The lower bound hint is used to help the solution method.\n\nSolution modes can be benefitted from this hint:\n\nBigMMode will use this information to compute a tighter bound for the primal constraint variable.\nOther modes will be stabilized by the existence of the bounds on variables that would otherwise no be bounded.\nBounds that are not dualized are also useful for binary expansions of products of variables that can be done with QuadraticToBinary.jl.\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.get_primal_lower_bound_hint","page":"API Reference","title":"BilevelJuMP.get_primal_lower_bound_hint","text":"get_primal_lower_bound_hint(cref)\n\nGet the lower bound to the primal variable of the constraint cref that was set with set_primal_lower_bound_hint.\n\n\n\n\n\n","category":"function"},{"location":"reference/#Attributes-getters-and-setters","page":"API Reference","title":"Attributes getters and setters","text":"","category":"section"},{"location":"reference/","page":"API Reference","title":"API Reference","text":"BilevelJuMP.lower_objective_value\nBilevelJuMP.build_time\nBilevelJuMP.set_mode\nBilevelJuMP.get_mode\nBilevelJuMP.unset_mode\nBilevelJuMP.set_copy_names\nBilevelJuMP.get_copy_names\nBilevelJuMP.unset_copy_names\nBilevelJuMP.set_pass_start\nBilevelJuMP.get_pass_start\nBilevelJuMP.unset_pass_start","category":"page"},{"location":"reference/#BilevelJuMP.lower_objective_value","page":"API Reference","title":"BilevelJuMP.lower_objective_value","text":"lower_objective_value(model::BilevelModel; result::Int = 1)\n\nReturn the value of the objective function of the lower level problem.\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.build_time","page":"API Reference","title":"BilevelJuMP.build_time","text":"build_time(model::BilevelModel)\n\nReturn the time it took to build the model.\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.set_mode","page":"API Reference","title":"BilevelJuMP.set_mode","text":"set_mode(bm::BilevelModel, mode::AbstractBilevelSolverMode)\n\nSet the mode of a bilevel model.\n\n\n\n\n\nset_mode(ci::BilevelVariableRef, mode::AbstractBilevelSolverMode)\n\nSet the mode of a constraint. This is used in MixedMode reformulations.\n\n\n\n\n\nset_mode(vi::BilevelVariableRef, mode::AbstractBilevelSolverMode)\n\nSet the mode of the bounds of a variable. This is used in MixedMode reformulations.\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.get_mode","page":"API Reference","title":"BilevelJuMP.get_mode","text":"get_mode(ci::BilevelConstraintRef)\n\nGet the mode of a constraint. This is used in MixedMode reformulations.\n\n\n\n\n\nget_mode(vi::BilevelVariableRef)\n\nGet the mode of the bounds of a variable. This is used in MixedMode reformulations.\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.unset_mode","page":"API Reference","title":"BilevelJuMP.unset_mode","text":"unset_mode(ci::BilevelConstraintRef)\n\nUnset the mode of a constraint. This will use the default mode for the constraint. This is used in MixedMode reformulations.\n\n\n\n\n\nunset_mode(vi::BilevelVariableRef)\n\nUnset the mode of the bounds of a variable. This will use the default mode for the bounds. This is used in MixedMode reformulations.\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.set_copy_names","page":"API Reference","title":"BilevelJuMP.set_copy_names","text":"set_copy_names(model::BilevelModel)\n\nSet the copy_names attribute of the solver to true.\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.get_copy_names","page":"API Reference","title":"BilevelJuMP.get_copy_names","text":"get_copy_names(model::BilevelModel)\n\nReturn the value of the copy_names attribute of the solver.\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.unset_copy_names","page":"API Reference","title":"BilevelJuMP.unset_copy_names","text":"unset_copy_names(model::BilevelModel)\n\nSet the copy_names attribute of the solver to false.\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.set_pass_start","page":"API Reference","title":"BilevelJuMP.set_pass_start","text":"set_pass_start(model::BilevelModel)\n\nActivate passing start values (both primal and dual) to the solver.\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.get_pass_start","page":"API Reference","title":"BilevelJuMP.get_pass_start","text":"get_pass_start(model::BilevelModel)\n\nChecks if passing start values (both primal and dual) to the solver is activated.\n\n\n\n\n\n","category":"function"},{"location":"reference/#BilevelJuMP.unset_pass_start","page":"API Reference","title":"BilevelJuMP.unset_pass_start","text":"unset_pass_start(model::BilevelModel)\n\nDeactivate passing start values (both primal and dual) to the solver.\n\n\n\n\n\n","category":"function"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"EditURL = \"https://github.com/joaquimg/BilevelJuMP.jl/blob/master/docs/src/tutorials/modes.jl\"","category":"page"},{"location":"tutorials/modes/#Modes-overview","page":"Modes overview","title":"Modes overview","text":"","category":"section"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"There are several ways to solve bilevel problems with BilevelJuMP. The main difference between them is the way the complementarity constraints are reformulated. The reformulation method is set with the mode option of the BilevelModel constructor.","category":"page"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"The modes available are:","category":"page"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"BilevelJuMP.SOS1Mode(): uses SOS1 constraints to model complementarity constraints and solve the problem with MIP solvers (Cbc, Xpress, Gurobi, CPLEX, SCIP).\nBilevelJuMP.IndicatorMode(): uses Indicator constraints to model complementarity constraints and solve the problem with MIP solvers (Cbc, Xpress, Gurobi, CPLEX, SCIP).\nBilevelJuMP.BigMMode(): uses the Fortuny-Amat and McCarl reformulation that requires a MIP solver with very basic functionality, i.e., just binary variables are needed. The main drawback of this method is that one must provide bounds for all primal and dual variables. However, if good bounds are provided, this method can be more efficient than the previous. Bound hints to compute the big-Ms can be passed with the methods: set_primal_(upper\\lower)_bound_hint(variable, bound), for primals; and set_dual_(upper\\lower)_bound_hint(constraint, bound) for duals. We can also call FortunyAmatMcCarlMode(primal_big_M = vp, dual_big_M = vd), where vp and vd are, respectively, the big M fallback values for primal and dual variables, these are used when some variables have no given bounds, otherwise the given bounds are used instead.\nBilevelJuMP.ProductMode(): reformulates the complementarity constraints as products so that the problem can be solved by NLP (Ipopt, KNITRO) solvers or even MIP solvers with the aid of binary expansions (see QuadraticToBinary.jl). Note that binary expansions require variables to have upper and lower bounds. Also, note that the Gurobi solver supports products, but requires setting the \"NonConvex\" options.\nBilevelJuMP.MixedMode(default = mode): where mode is one of the other modes described above. With this method it is possible to set complementarity reformulations per constraint with BilevelJuMP.set_mode(constraint, mode), where constraint is a constraint of the bilevel problem and mode is one of the modes described above. If no mode is set for a constraint, the default mode is used instead. To set a mode to reformulate variables bounds use: BilevelJuMP.set_mode(variable, mode).\nBilevelJuMP.StrongDualityMode: this mode is not a complementarity reformulation method, instead, all complementarity constraints are replaced by constraints enforcing the strong duality. This mode is especially amenable for NLP solvers (Ipopt, KNITRO). MIP solvers can also be used but they will have to deal with the products of variables crated or the will have to be used in conjunction with QuadraticToBinary.jl.","category":"page"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"The following example shows how to solve a classic bilevel problem.","category":"page"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"We start loading all libraries needed for this example.","category":"page"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"using BilevelJuMP, HiGHS, Ipopt, SCIP","category":"page"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"Now we create a bilevel model with the BilevelModel constructor with no solver nor mode specified.","category":"page"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"model = BilevelModel()\n\n@variable(Lower(model), x)\n@variable(Upper(model), y)\n\n@objective(Upper(model), Min, 3x + y)\n@constraints(Upper(model), begin\n x <= 5\n y <= 8\n y >= 0\nend)\n\n@objective(Lower(model), Min, -x)\n@constraints(Lower(model), begin\n c1, x + y <= 8\n c2, 4x + y >= 8\n c3, 2x + y <= 13\n c4, 2x - 7y <= 0\nend)","category":"page"},{"location":"tutorials/modes/#BigMMode-and-HiGHS.Optimizer","page":"Modes overview","title":"BigMMode and HiGHS.Optimizer","text":"","category":"section"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"set_optimizer(model, HiGHS.Optimizer)\n\nBilevelJuMP.set_mode(model,\n BilevelJuMP.BigMMode(primal_big_M = 100, dual_big_M = 100))\n\noptimize!(model)\n\nobjective_value(model)\n@assert abs(objective_value(model) - (3 * (7/2 * 8/15) + 8/15)) < 1e-1 # src","category":"page"},{"location":"tutorials/modes/#SOS1Mode-and-SCIP.Optimizer","page":"Modes overview","title":"SOS1Mode and SCIP.Optimizer","text":"","category":"section"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"set_optimizer(model, SCIP.Optimizer)\n\nBilevelJuMP.set_mode(model, BilevelJuMP.SOS1Mode())\n\noptimize!(model)\n\nobjective_value(model)\n\n@assert abs(objective_value(model) - (3 * (3.5 * 8/15) + 8/15)) < 1e-1 # src","category":"page"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"warning: Warning\nSCIP requires a non-standard installation procedure in windows. See SCIP.jl for more details.","category":"page"},{"location":"tutorials/modes/#IndicatorMode-and-SCIP.Optimizer","page":"Modes overview","title":"IndicatorMode and SCIP.Optimizer","text":"","category":"section"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"set_optimizer(model, SCIP.Optimizer)\n\nBilevelJuMP.set_mode(model, BilevelJuMP.IndicatorMode())\n\noptimize!(model)\n\nobjective_value(model)\n\n@assert abs(objective_value(model) - (3 * (3.5 * 8/15) + 8/15)) < 1e-1 # src","category":"page"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"warning: Warning\nSCIP requires a non-standard installation procedure in windows. See SCIP.jl for more details.","category":"page"},{"location":"tutorials/modes/#ProductMode-and-Ipopt.Optimizer","page":"Modes overview","title":"ProductMode and Ipopt.Optimizer","text":"","category":"section"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"set_optimizer(model, Ipopt.Optimizer)\n\nBilevelJuMP.set_mode(model, BilevelJuMP.ProductMode())\n\noptimize!(model)\n\nobjective_value(model)\n\n@assert abs(objective_value(model) - (3 * (7/2 * 8/15) + 8/15)) < 1e-1 # src","category":"page"},{"location":"tutorials/modes/#StrongDualityMode-and-Ipopt.Optimizer","page":"Modes overview","title":"StrongDualityMode and Ipopt.Optimizer","text":"","category":"section"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"set_optimizer(model, Ipopt.Optimizer)\n\nBilevelJuMP.set_mode(model, BilevelJuMP.StrongDualityMode())\n\noptimize!(model)\n\nobjective_value(model)\n\n@assert abs(objective_value(model) - (3 * (7/2 * 8/15) + 8/15)) < 1e-1 # src","category":"page"},{"location":"tutorials/modes/#MixedMode-and-SCIP.Optimizer","page":"Modes overview","title":"MixedMode and SCIP.Optimizer","text":"","category":"section"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"set_optimizer(model, SCIP.Optimizer)\n\nBilevelJuMP.set_mode(model, BilevelJuMP.MixedMode(default = BilevelJuMP.SOS1Mode()))\n\nBilevelJuMP.set_mode(c1, BilevelJuMP.IndicatorMode())\n\nBilevelJuMP.set_mode(c3, BilevelJuMP.SOS1Mode())\n\noptimize!(model)\n\nobjective_value(model)\n\n@assert abs(objective_value(model) - (3 * (3.5 * 8/15) + 8/15)) < 1e-1 # src","category":"page"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"warning: Warning\nSCIP requires a non-standard installation procedure in windows. See SCIP.jl for more details.","category":"page"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"info: Info\nView this file on Github.","category":"page"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"","category":"page"},{"location":"tutorials/modes/","page":"Modes overview","title":"Modes overview","text":"This page was generated using Literate.jl.","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"EditURL = \"https://github.com/joaquimg/BilevelJuMP.jl/blob/master/docs/src/tutorials/non_linear.jl\"","category":"page"},{"location":"tutorials/non_linear/#Non-Linear-models","page":"Non Linear models","title":"Non Linear models","text":"","category":"section"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"BilevelJuMP has limited support for non-linear models. The @NLconstraint and the @NLobjective macros are supported for the upper level, but not for the lower level. Moreover, these macros can only be used if the selected solver supports non-linear constraints and objectives.","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"The @constraint and @objective macros can be used for both levels to represent linear and quadratic constraints and objectives","category":"page"},{"location":"tutorials/non_linear/#Quadratic-constraints-and-objectives","page":"Non Linear models","title":"Quadratic constraints and objectives","text":"","category":"section"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"using BilevelJuMP, Ipopt\nmodel = BilevelModel(Ipopt.Optimizer, mode = BilevelJuMP.ProductMode(1e-5))\n\n@variable(Upper(model), x >= 2)\n@variable(Lower(model), 3 <= y <= 5)","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"We can add a non-linear objective to the upper level with @NLobjective","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"@NLobjective(Upper(model), Min, x^2 - y)","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"We can also add a non-linear constraint to the upper level with @NLconstraint","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"@NLconstraint(Upper(model), x^2 + y^2 <= 100)","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"@NLobjective is not supported in the lower level, but we can use @constraint to add a quadratic objective to the lower level.","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"@objective(Lower(model), Min, y^2)","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"optimize!(model)","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"All the quadratic objectives and constraints of the upper level can also be added with the @constraint and @objective macros. Hence, we can write the quivalent model:","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"using BilevelJuMP, Ipopt\nmodel = BilevelModel(Ipopt.Optimizer, mode = BilevelJuMP.ProductMode(1e-5))\n\n@variable(Upper(model), x >= 2)\n@variable(Lower(model), 3 <= y <= 5)","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"@objective(Upper(model), Min, x^2 - y)","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"@constraint(Upper(model), x^2 + y^2 <= 100)","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"@objective(Lower(model), Min, y^2)","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"optimize!(model)","category":"page"},{"location":"tutorials/non_linear/#General-non-linear-constraints-and-objectives","page":"Non Linear models","title":"General non-linear constraints and objectives","text":"","category":"section"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"General non quadratic objectives and general non-linear constraints can not be added to the lower level, but they can be added to the upper level.","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"using BilevelJuMP, Ipopt\nmodel = BilevelModel(Ipopt.Optimizer, mode = BilevelJuMP.ProductMode(1e-5))\n\n@variable(Upper(model), x >= 2)\n@variable(Lower(model), 3 <= y <= 5)","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"@NLobjective(Upper(model), Min, x^4 - sin(y))","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"@NLconstraint(Upper(model), x^3 + y^3 <= 1000)","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"@objective(Lower(model), Min, y^2)","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"optimize!(model)","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"info: Info\nConic constraints are supported in the lower level (see Conic Bilevel tutorial).","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"info: Info\nView this file on Github.","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"","category":"page"},{"location":"tutorials/non_linear/","page":"Non Linear models","title":"Non Linear models","text":"This page was generated using Literate.jl.","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"EditURL = \"https://github.com/joaquimg/BilevelJuMP.jl/blob/master/docs/src/examples/MibS_example2.jl\"","category":"page"},{"location":"examples/MibS_example2/#MibS:-Example-2-(Experimental-feature)","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"","category":"section"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"Model of the problem First level","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"min_x 2x -4y + 10z\nnotag st\n-3x + 2y + 2z leq 12\nx + 2y leq 20\nx leq 10\nx in mathbbZ z in mathbbB","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"Second level","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"min_y y\nnotag st\n2x - y + 3z= 7\n-2x + 4y = 16\ny = 5\ny in mathbbZ","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"using BilevelJuMP\nusing Test\nusing MibS_jll\n\nmodel = BilevelModel()","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"First we need to create all of the variables in the upper and lower problems:","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"Upper level variables","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"@variable(Upper(model), x, Int)\n@variable(Upper(model), z, Bin)\n\n#Lower level variables\n@variable(Lower(model), y, Int)","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"Then we can add the objective and constraints of the upper problem:","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"Upper level objecive function","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"@objective(Upper(model), Min, 2x - 4y + 10z)","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"Upper constraints","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"@constraints(Upper(model), begin\n u1, -3x + 2y + 5z <= 12\n u2, x + 2y <= 20\n u3, x <= 10\nend)","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"Followed by the objective and constraints of the lower problem:","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"Lower objective function","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"@objective(Lower(model), Min, y)","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"Lower constraints","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"@constraint(Lower(model), l1, 2x - y + 3z <= 7)\n@constraint(Lower(model), l2, -2x + 4y <= 16)\n@constraint(Lower(model), l3, y <= 5)","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"Using MibS Solver","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"solution = BilevelJuMP.solve_with_MibS(model, MibS_jll.mibs)","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"Auto testing","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"@test solution.status == true\n@test solution.objective ≈ -8.0\n@test solution.nonzero_upper == Dict(0 => 6.0)\n@test solution.nonzero_lower == Dict(0 => 5.0)\n@test solution.all_upper[\"x\"] == 6.0\n@test solution.all_upper[\"z\"] == 0\n@test solution.all_lower[\"y\"] == 5.0","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"info: Info\nView this file on Github.","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"","category":"page"},{"location":"examples/MibS_example2/","page":"MibS: Example 2 (Experimental feature)","title":"MibS: Example 2 (Experimental feature)","text":"This page was generated using Literate.jl.","category":"page"},{"location":"tutorials/conic_lower/","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"EditURL = \"https://github.com/joaquimg/BilevelJuMP.jl/blob/master/docs/src/tutorials/conic_lower.jl\"","category":"page"},{"location":"tutorials/conic_lower/#Conic-Bilevel-and-Mixed-Mode","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"","category":"section"},{"location":"tutorials/conic_lower/","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"Here we present a simple bilevel program with a conic lower level model described in example 3.3 from Chi, et al. 2014.","category":"page"},{"location":"tutorials/conic_lower/","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"beginalign\n max_x in mathbbR quad x + 3y_1 \n textitst quad 2 leq x leq 6\n hspace28pt y(x) in argmin_yin mathbbR^3 -y_1\n hspace58pt textitst quad x + y_1 leq 8 \n hspace76pt quad x + 4y_1 geq 8 \n hspace76pt quad x + 2y_1 leq 12 \n hspace76pt quad y in SOC_3 labeleq-soc\nendalign","category":"page"},{"location":"tutorials/conic_lower/","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"In this problem most of the constraints are regular linear constraints while the last one is a second order cone constraint. Such constraint ensures that the vector y belongs to a second order cone of dimension 3, that is: y_1 geq sqrty_2^2 + y_3^2.","category":"page"},{"location":"tutorials/conic_lower/","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"This problem can be encoded using regular JuMP syntax for conic programs:","category":"page"},{"location":"tutorials/conic_lower/","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"using BilevelJuMP\nmodel = BilevelModel()\n@variable(Upper(model), x)\n@variable(Lower(model), y[i=1:3])\n@objective(Upper(model), Min, x + 3y[1])\n@constraint(Upper(model), x >= 2)\n@constraint(Upper(model), x <= 6)\n@objective(Lower(model), Min, - y[1])\n@constraint(Lower(model), con1, x + y[1] <= 8)\n@constraint(Lower(model), con2, x + 4y[1] >= 8)\n@constraint(Lower(model), con3, x + 2y[1] <= 12)\n@constraint(Lower(model), con4, y in SecondOrderCone())","category":"page"},{"location":"tutorials/conic_lower/#NLP-solution-and-start-values","page":"Conic Bilevel and Mixed Mode","title":"NLP solution and start values","text":"","category":"section"},{"location":"tutorials/conic_lower/","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"We can set, for instance, the product reformulation and selected Ipopt as a solver. As Ipopt does not have native support for second order cones, we use the non-default MOI bridge SOCtoNonConvexQuad to convert second order cones into quadratic constraints.","category":"page"},{"location":"tutorials/conic_lower/","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"using Ipopt\nBilevelJuMP.set_mode(model, BilevelJuMP.ProductMode(1e-5))\nset_optimizer(model,\n ()->MOI.Bridges.Constraint.SOCtoNonConvexQuad{Float64}(Ipopt.Optimizer()))\noptimize!(model)","category":"page"},{"location":"tutorials/conic_lower/","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"The user could also use the alternative JuMP syntax:","category":"page"},{"location":"tutorials/conic_lower/","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"set_start_value(x, 6)\nset_dual_start_value(con2, 0)","category":"page"},{"location":"tutorials/conic_lower/#MIP-solution-and-mixed-mode","page":"Conic Bilevel and Mixed Mode","title":"MIP solution and mixed mode","text":"","category":"section"},{"location":"tutorials/conic_lower/","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"Alternatively, we could have used a Mixed Integer Second Order Cone Program (MISOCP) solver together with binary expansions. Complementarity of conic constraints is more difficult to handle because they require a sum of products that cannot be reformulated with other methods. Therefore, we rely on product reformulation for conic constraints. However, we can use other reformulations like indicator constraints for the non-conic constraints. Mixing the two of them can be done with Mixed Mode.","category":"page"},{"location":"tutorials/conic_lower/","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"The following code describes how to solve the problem with a MISOCP based solver.","category":"page"},{"location":"tutorials/conic_lower/","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"using Xpress\nusing QuadraticToBinary\nset_optimizer(model,\n ()->QuadraticToBinary.Optimizer{Float64}(Xpress.Optimizer(),lb=-10,ub=10))\nBilevelJuMP.set_mode(model,\n BilevelJuMP.MixedMode(default = BilevelJuMP.IndicatorMode()))\nBilevelJuMP.set_mode(con4, BilevelJuMP.ProductMode(1e-5))\noptimize!(model)","category":"page"},{"location":"tutorials/conic_lower/","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"info: Info\nThis code was not executed because Xpress requires a commercial license. Other solvers supporting MISOCP could be used such as Gurobi and CPLEX.","category":"page"},{"location":"tutorials/conic_lower/","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"We set the reformulation method as Mixed Mode and selected Indicator constraints to be the default for the case in which we do not explicitly specify the reformulation. Then we set product mode for the second order cone reformulation.","category":"page"},{"location":"tutorials/conic_lower/","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"Binary expansions require bounded variables, hence the QuadraticToBinary meta-solver accepts fallback to upper and lower bounds (\\texttt{ub} and \\texttt{lb}), used for variables with no explicit bounds.","category":"page"},{"location":"tutorials/conic_lower/","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"info: Info\nView this file on Github.","category":"page"},{"location":"tutorials/conic_lower/","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"","category":"page"},{"location":"tutorials/conic_lower/","page":"Conic Bilevel and Mixed Mode","title":"Conic Bilevel and Mixed Mode","text":"This page was generated using Literate.jl.","category":"page"},{"location":"background/#Bilevel-Optimization","page":"Background Information","title":"Bilevel Optimization","text":"","category":"section"},{"location":"background/","page":"Background Information","title":"Background Information","text":"Bilevel optimization is a vast discipline with a long (50+ years) history. We will not attempt to present a bilevel optimization introduction here. Instead, we point the reader to the excellent text:","category":"page"},{"location":"background/","page":"Background Information","title":"Background Information","text":"A Gentle and Incomplete Introduction to Bilevel Optimization","category":"page"},{"location":"background/","page":"Background Information","title":"Background Information","text":"by Yasmine Beck and Martin Schmidt.","category":"page"},{"location":"background/","page":"Background Information","title":"Background Information","text":"The interested reader can find more information in books:","category":"page"},{"location":"background/","page":"Background Information","title":"Background Information","text":"Dempe 2002\nBard 2013\nDempe et al. 2015","category":"page"},{"location":"background/","page":"Background Information","title":"Background Information","text":"and in other reviews:","category":"page"},{"location":"background/","page":"Background Information","title":"Background Information","text":"Vicente and Calamai 1994\nColson et al. 2007\nKalashnikov et al. 2015\nDempe (2018)","category":"page"},{"location":"background/#Bilevel-Optimization-in-BilevelJuMP","page":"Background Information","title":"Bilevel Optimization in BilevelJuMP","text":"","category":"section"},{"location":"background/","page":"Background Information","title":"Background Information","text":"In BileveJuMP focus on the following bilevel problem form:","category":"page"},{"location":"background/","page":"Background Information","title":"Background Information","text":"beginaligned\n min_x textbfy z f_0(x textbfy z) \n textitst f_i(x textbfy z) in mathcalS_i quad i = 1 ldots k \n x(z) textbfy(z) in\n beginalignedt\n argmin_x textbfy frac12x z^top Q x z + a_0^top x+ d_0^top z + b_0\n textitst A_i x + D_i z + b_i in mathcalC_i quad y_i quad quad i = 1 ldots m\n endaligned\nendaligned","category":"page"},{"location":"background/","page":"Background Information","title":"Background Information","text":"where z in mathbbR^l and x in mathbbR^n are, respectively, from upper and lower-level primal decision variables. Vectors of lower level dual decision variables are represented individually, by y_1 in mathbbR^p_1 ldots y_m in mathbbR^p_m, or jointly, by the m-tuple textbfy = (y_1 ldots y_m). The square brackets cdot cdot represent the stacking of two vectors or scalars. Thus, xz is a (n+l)–vector with the elements of x and z stacked. The numbers of constraints in the upper and lower problems are given by k and m, respectively. Q, a_i, d_i, b_i, A_i, D_i are matrices (upper case) and vectors (lower case) of constants of the lower level problem and mathcalC_i subset mathbbR^p_i are convex conic sets. The functions f_i can be linear, quadratic, or non-linear. The sets mathcalS_iin mathbbR^q_i can be convex cones, as in the lower level, but can also represent other sets, such as the sets of integers or binary variables. We use the \"function-in-set\" notation following the MOI definition of mathematical optimization problems. As in traditional bilevel programming, z is decided in the upper level and passed to the lower level as a parameter and x might be seen as an upper-level variable constrained to be an optimal solution of the lower level. Also, we only consider optimistic bilevel problems. In short, the solution of the lower level will be the one that optimizes the upper level in case of degeneracy.","category":"page"},{"location":"background/","page":"Background Information","title":"Background Information","text":"For more information see our paper:","category":"page"},{"location":"background/","page":"Background Information","title":"Background Information","text":"@article{diasgarcia2022bileveljump,\n title={{BilevelJuMP. jl}: {M}odeling and solving bilevel optimization in {J}ulia},\n author={{Dias Garcia}, Joaquim and Bodin, Guilherme and Street, Alexandre},\n journal={arXiv preprint arXiv:2205.02307},\n year={2022}\n}","category":"page"},{"location":"background/","page":"Background Information","title":"Background Information","text":"Here is the pdf.","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"EditURL = \"https://github.com/joaquimg/BilevelJuMP.jl/blob/master/docs/src/examples/FOBP_example4.jl\"","category":"page"},{"location":"examples/FOBP_example4/#Foundations-of-Bilevel-Programming:-Example-Chapter-5.1,-Page-127","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"","category":"section"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"This example is from the book Foundations of Bilevel Programming by Stephan Dempe, Chapter 5.1, Page 127. url","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"Model of the problem","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"First level","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"min x^2 + y\nnotag st\n-x-yleq 0","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"Second level","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"min x\nnotag st\nx geq 0","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"using BilevelJuMP\nusing Ipopt\n\nmodel = BilevelModel(Ipopt.Optimizer; mode = BilevelJuMP.ProductMode(1e-9))","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"First we need to create all of the variables in the upper and lower problems:","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"Upper level variables","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"@variable(Upper(model), y, start = 0)\n\n#Lower level variables\n@variable(Lower(model), x, start = 0)","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"Then we can add the objective and constraints of the upper problem:","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"Upper level objecive function","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"@objective(Upper(model), Min, x^2 + y)","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"Upper level constraints","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"@constraint(Upper(model), u1, -x - y <= 0)","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"Followed by the objective and constraints of the lower problem:","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"Lower objective function","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"@objective(Lower(model), Min, x)","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"Lower constraints","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"@constraint(Lower(model), l1, x >= 0)","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"Now we can solve the problem and verify the solution again that reported by Dempe.","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"optimize!(model)","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"primal_status(model)","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"termination_status(model)","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"Results","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"objective_value(model)","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"value(x)","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"value(y)\n\natol = 1e-3 # src","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"info: Info\nView this file on Github.","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"","category":"page"},{"location":"examples/FOBP_example4/","page":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","title":"Foundations of Bilevel Programming: Example Chapter 5.1, Page 127","text":"This page was generated using Literate.jl.","category":"page"},{"location":"#BilevelJuMP.jl-Documentation","page":"Home","title":"BilevelJuMP.jl Documentation","text":"","category":"section"},{"location":"#Introduction","page":"Home","title":"Introduction","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"BilevelJuMP is a package for modeling and solving bilevel optimization problems in Julia.","category":"page"},{"location":"","page":"Home","title":"Home","text":"As an extension of the JuMP modeling language, BilevelJuMP allows users to employ the usual JuMP syntax with minor modifications to describe the problem and query solutions.","category":"page"},{"location":"","page":"Home","title":"Home","text":"Many modeling features are available in BilevelJuMP, some of which are unique while others are also not widely available. The main features supported are:","category":"page"},{"location":"","page":"Home","title":"Home","text":"Arbitrary JuMP models in the upper level (NLP, Conic, MIP)\nConic constraints and quadratic objectives in the lower-level\nDual variables of the lower level in the upper level\nMPEC reformulations with MIP or NLP solvers\nMixedMode MPEC reformulation: select the best reformulation for each","category":"page"},{"location":"","page":"Home","title":"Home","text":"constraint separately","category":"page"},{"location":"","page":"Home","title":"Home","text":"The currently available methods are based on re-writing the problem using the KKT conditions of the lower level. For that, we make strong use of Dualization.jl","category":"page"},{"location":"#Installation","page":"Home","title":"Installation","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Install BilevelJuMP as follows:","category":"page"},{"location":"","page":"Home","title":"Home","text":"julia> import Pkg\n\njulia> Pkg.add(\"BilevelJuMP\")","category":"page"},{"location":"#Getting-started","page":"Home","title":"Getting started","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Learn the basics of","category":"page"},{"location":"","page":"Home","title":"Home","text":"JuMP and Julia in the JuMP documentation","category":"page"},{"location":"","page":"Home","title":"Home","text":"Follow the tutorials in this manual","category":"page"},{"location":"","page":"Home","title":"Home","text":"If you need help, please open a GitHub issue.","category":"page"},{"location":"#License","page":"Home","title":"License","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"BilevelJuMP.jl is licensed under the MIT License.","category":"page"},{"location":"#Citing-BilevelJuMP.jl","page":"Home","title":"Citing BilevelJuMP.jl","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"If you use BilevelJuMP.jl, we ask that you please cite the following paper:","category":"page"},{"location":"","page":"Home","title":"Home","text":"@article{diasgarcia2023bileveljump,\n title={{BilevelJuMP.jl}: {M}odeling and {S}olving {B}ilevel {O}ptimization {P}roblems in {J}ulia},\n author={{Dias Garcia}, Joaquim and Bodin, Guilherme and Street, Alexandre},\n journal={INFORMS Journal on Computing},\n doi={https://doi.org/10.1287/ijoc.2022.0135},\n pages={1-9},\n year={2023}\n}","category":"page"},{"location":"","page":"Home","title":"Home","text":"Here is an earlier preprint.","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"EditURL = \"https://github.com/joaquimg/BilevelJuMP.jl/blob/master/docs/src/examples/PHTP_example1.jl\"","category":"page"},{"location":"examples/PHTP_example1/#Princeton-Handbook-of-Test-Problems:-Test-9.3.2","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"","category":"section"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"This example is from the book Princeton Handbook of Test Problems in Local and Global Optimization, Floudas et al., Chapter 9.3.2, Page 221, url.","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"Model of the problem First level","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"min (x-5)^2+(2y+1)^2\nnotag st\nx geq 0\ny geq 0","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"Second level","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"min (y-1)^2-15xy\nnotag st\n-3x+y leq -3\nx-05y leq 4\nx+y leq 7","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"using BilevelJuMP\nusing Ipopt\n\nmodel = BilevelModel(Ipopt.Optimizer; mode = BilevelJuMP.ProductMode(1e-9))","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"First we need to create all of the variables in the upper and lower problems:","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"Upper level variables","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"@variable(Upper(model), x)\n\n#Lower level variables\n@variable(Lower(model), y)","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"Then we can add the objective and constraints of the upper problem:","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"Upper level objecive function","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"@objective(Upper(model), Min, (x - 5)^2 + (2y + 1)^2)","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"Upper level constraints","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"@constraint(Upper(model), x >= 0)\n@constraint(Upper(model), y >= 0)","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"Followed by the objective and constraints of the lower problem:","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"Lower objective function","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"@objective(Lower(model), Min, (y - 1)^2 - 1.5 * x * y)","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"Lower constraints","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"@constraint(Lower(model), -3x + y <= -3)\n@constraint(Lower(model), x - 0.5y <= 4)\n@constraint(Lower(model), x + y <= 7)","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"Now we can solve the problem and verify the solution again that reported by the book.","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"optimize!(model)","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"primal_status(model)","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"termination_status(model)","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"value(x)","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"value(y)","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"info: Info\nView this file on Github.","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"","category":"page"},{"location":"examples/PHTP_example1/","page":"Princeton Handbook of Test Problems: Test 9.3.2","title":"Princeton Handbook of Test Problems: Test 9.3.2","text":"This page was generated using Literate.jl.","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"EditURL = \"https://github.com/joaquimg/BilevelJuMP.jl/blob/master/docs/src/tutorials/getting_started.jl\"","category":"page"},{"location":"tutorials/getting_started/#Getting-started-with-BilevelJuMP","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"","category":"section"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"This is a quick introduction to modeling and solving bilevel optimization with BilevelJuMP.","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"If you are new to Julia, start with the Getting started with Julia from the JuMP documentation.","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"If you are new to JuMP, start with the Getting started with JuMP from the JuMP documentation.","category":"page"},{"location":"tutorials/getting_started/#Installation","page":"Getting started with BilevelJuMP","title":"Installation","text":"","category":"section"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"BilevelJuMP is a JuMP extension that be installed by using the built-in package manager.","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"import Pkg\nPkg.add(\"BilevelJuMP\")","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"That is all you need to model a bilevel optimization problem, but we want to also solve the problems. Therefore we need a solver, one such solver is HiGHS.Optimizer, which is provided by the HiGHS.jl package.","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"import Pkg\nPkg.add(\"HiGHS\")","category":"page"},{"location":"tutorials/getting_started/#A-first-example","page":"Getting started with BilevelJuMP","title":"A first example","text":"","category":"section"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"We will solve the following bilevel optimization problem using BilevelJuMP and HiGHS. First we take a look in the entire code then we go through it step-by-step.","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"Here is the example from Dempe (2002), Chapter 3.2, Page 25:","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"beginalign*\n min_x y 3x + y \n textitst x leq 5 \n y leq 8 \n y geq 0 \n x(y) in\n beginalignedt\n argmin_x -x\n textitst x + y leq 8\n 4x + y geq 8\n 2x + y leq 13\n 2x - 7y leq 0\n endaligned\nendalign*","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"Here is the complete code to model, solve and query results from the example:","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"using BilevelJuMP\nusing HiGHS\n\nmodel = BilevelModel(\n HiGHS.Optimizer,\n mode = BilevelJuMP.FortunyAmatMcCarlMode(primal_big_M = 100, dual_big_M = 100))\n\n@variable(Lower(model), x)\n\n@variable(Upper(model), y)\n\n@objective(Upper(model), Min, 3x + y)\n\n@constraint(Upper(model), u1, x <= 5)\n@constraint(Upper(model), u2, y <= 8)\n@constraint(Upper(model), u3, y >= 0)\n\n@objective(Lower(model), Min, -x)\n\n@constraint(Lower(model), l1, x + y <= 8)\n@constraint(Lower(model), l2, 4x + y >= 8)\n@constraint(Lower(model), l3, 2x + y <= 13)\n@constraint(Lower(model), l4, 2x - 7y <= 0)\n\nprint(model)\n\noptimize!(model)\n\ntermination_status(model)\n\nprimal_status(model)\n\ndual_status(Lower(model))\n\ndual_status(Upper(model))\n\nobjective_value(model)\n\nobjective_value(Lower(model))\n\nobjective_value(Upper(model))\n\nvalue(x)\n\nvalue(y)\n\ndual(l1)\n\ndual(l2)","category":"page"},{"location":"tutorials/getting_started/#Step-by-step","page":"Getting started with BilevelJuMP","title":"Step-by-step","text":"","category":"section"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"Once installed, BilevelJuMP can be loaded into julia:","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"using BilevelJuMP","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"Note that JuMP comes inside BilevelJuMP, and does not need to be installed separately. Once loaded, all JuMP functions are exported along with the BilevelJuMP additional functions.","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"We include a solver, in this case HiGHS:","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"using HiGHS","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"Just like regular JuMP has the Model function to initialize an optimization problem, BilevelJuMP has the BilevelModel function that takes a solver as a first positional argument, in this case HiGHS.Optimizer and a mode keyword argument that selects a bilevel solution method, in this case, BilevelJuMP.FortunyAmatMcCarlMode. Note that BilevelJuMP.FortunyAmatMcCarlMode takes two optional keyword arguments: primal_big_M and dual_big_M which have to be larger than the value of all primal and dual variavle sof the lower level respectively to guarantee that the solution is no eliminated.","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"model = BilevelModel(\n HiGHS.Optimizer,\n mode = BilevelJuMP.FortunyAmatMcCarlMode(primal_big_M = 100, dual_big_M = 100))","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"For more on modes and solutions methods, see XXX.","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"We can proceed, as usual in JuMP models and incrementally build our bilevel problem. We use the same macros as JuMP.","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"Variables are modeled using the @variable macro, but in bilevel problems we must define which level the variable is decided, then we use the Upper and Lower constructors to direct variable to the proper levels:","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"@variable(Lower(model), x)\n\n@variable(Upper(model), y)","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"The same goes for objective that are modeled with the @objective macro:","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"@objective(Upper(model), Min, 3x + y)","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"and constraints that are modeled with the @objective macro:","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"@constraint(Upper(model), u1, x <= 5)\n@constraint(Upper(model), u2, y <= 8)\n@constraint(Upper(model), u3, y >= 0)","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"repeat for the lower level:","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"@objective(Lower(model), Min, -x)\n\n@constraint(Lower(model), l1, x + y <= 8)\n@constraint(Lower(model), l2, 4x + y >= 8)\n@constraint(Lower(model), l3, 2x + y <= 13)\n@constraint(Lower(model), l4, 2x - 7y <= 0)","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"display the model","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"print(model)","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"solve the bilevel problem, which will combine a mode (in this case FortunyAmatMcCarlMode) and a solver (in this case HiGHS):","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"optimize!(model)","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"check the termination_status to understand why the solver stopped:","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"termination_status(model)","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"check the primal_status to check if there is a feasible solution available:","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"primal_status(model)","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"check the dual_status to check if there is a dual solution available for the lower level:","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"dual_status(Lower(model))","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"do the same for the upper level:","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"dual_status(Upper(model))","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"info: Info\nMost method will not support upper level duals.","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"info: Info\nJuMP's dual_status is not available to BilevelModel's although you can query dual_status of each level.","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"Query the objecive value of the bilevel model","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"objective_value(model)","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"Query the objective value of the lower level and the upper level","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"objective_value(Lower(model))\n\nobjective_value(Upper(model))","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"Obtain primal solutions:","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"value(x)\n\nvalue(y)","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"and dual solutions:","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"dual(l1)\n\ndual(l2)","category":"page"},{"location":"tutorials/getting_started/#Model-basics","page":"Getting started with BilevelJuMP","title":"Model basics","text":"","category":"section"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"We created a BilevelModel passing the optimizer and mode and initialization:","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"model = BilevelModel(\n HiGHS.Optimizer,\n mode = BilevelJuMP.FortunyAmatMcCarlMode(primal_big_M = 100, dual_big_M = 100))","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"We could do piece by piece","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"model = BilevelModel()\n\nset_optimizer(model, HiGHS.Optimizer)\n\nBilevelJuMP.set_mode(model,\n BilevelJuMP.FortunyAmatMcCarlMode(primal_big_M = 100, dual_big_M = 100))","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"warning: Warning\nBoth BilevelModel and set_optimizer take a optimizer constructor, in this case HiGHS.Optimizer. Note that HiGHS.Optimizer() returns an instance of the HiGHS.Optimizer. Hence, and alternative way to pass this solver would be: set_optimizer(model, () -> HiGHS.Optimizer()).() -> HiGHS.Optimizer() is a an anonymous function that returns an instance of the HiGHS.Optimizer.","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"info: Info\nThere is no equivalent of JuMP's direct_model in BilevelJuMP.","category":"page"},{"location":"tutorials/getting_started/#Solver-options","page":"Getting started with BilevelJuMP","title":"Solver options","text":"","category":"section"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"it is also possible to pass optimizers with attributes:","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"model = BilevelModel(\n optimizer_with_attributes(HiGHS.Optimizer, \"output_flag\" => false))","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"or set such attributes separately:","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"model = BilevelModel(HiGHS.Optimizer)\n\nset_attribute(model, \"output_flag\", false)\n\nget_attribute(model, \"output_flag\")","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"info: Info\nView this file on Github.","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"","category":"page"},{"location":"tutorials/getting_started/","page":"Getting started with BilevelJuMP","title":"Getting started with BilevelJuMP","text":"This page was generated using Literate.jl.","category":"page"}] } diff --git a/dev/troubleshooting/index.html b/dev/troubleshooting/index.html index 85da38c..41cd656 100644 --- a/dev/troubleshooting/index.html +++ b/dev/troubleshooting/index.html @@ -1,3 +1,3 @@ Troubleshooting · BilevelJuMP.jl

      Troubleshooting

      • Cbc has known bugs in its SOS1 constraints, so BilevelJuMP.SOS1Mode might

      not work properly with Cbc.

      • For anonymous variables with DualOf use:
      @variable(Upper(model, variable_type = DualOf(my_lower_constraint)))
      • Nonconvex/nonconcave/nonpsd objective/constraint error in a MIP solver.

      If you are using Gurobi use:

      model = BilevelModel(Gurobi.Optimizer, mode = BilevelJuMP.SOS1Mode()) #or other mode
      -set_optimizer_attribute(model, "NonConvex", 2)
      +set_optimizer_attribute(model, "NonConvex", 2) diff --git a/dev/tutorials/conic_lower/index.html b/dev/tutorials/conic_lower/index.html index 1d05a85..eb1895a 100644 --- a/dev/tutorials/conic_lower/index.html +++ b/dev/tutorials/conic_lower/index.html @@ -108,11 +108,11 @@ (scaled) (unscaled) Objective...............: 1.1999969855039765e+01 1.1999969855039765e+01 -Dual infeasibility......: 2.6066157088495915e-10 2.6066157088495915e-10 +Dual infeasibility......: 2.6065981070644904e-10 2.6065981070644904e-10 Constraint violation....: 0.0000000000000000e+00 0.0000000000000000e+00 Variable bound violation: 0.0000000000000000e+00 0.0000000000000000e+00 -Complementarity.........: 2.5705110524827392e-09 2.5705110524827392e-09 -Overall NLP error.......: 2.5705110524827392e-09 2.5705110524827392e-09 +Complementarity.........: 2.5705110524790607e-09 2.5705110524790607e-09 +Overall NLP error.......: 2.5705110524790607e-09 2.5705110524790607e-09 Number of objective function evaluations = 77 @@ -122,7 +122,7 @@ Number of equality constraint Jacobian evaluations = 62 Number of inequality constraint Jacobian evaluations = 62 Number of Lagrangian Hessian evaluations = 58 -Total seconds in IPOPT = 0.031 +Total seconds in IPOPT = 0.032 EXIT: Optimal Solution Found.

      The user could also use the alternative JuMP syntax:

      set_start_value(x, 6)
       set_dual_start_value(con2, 0)
      0

      MIP solution and mixed mode

      Alternatively, we could have used a Mixed Integer Second Order Cone Program (MISOCP) solver together with binary expansions. Complementarity of conic constraints is more difficult to handle because they require a sum of products that cannot be reformulated with other methods. Therefore, we rely on product reformulation for conic constraints. However, we can use other reformulations like indicator constraints for the non-conic constraints. Mixing the two of them can be done with Mixed Mode.

      The following code describes how to solve the problem with a MISOCP based solver.

      using Xpress
      @@ -132,4 +132,4 @@
       BilevelJuMP.set_mode(model,
           BilevelJuMP.MixedMode(default = BilevelJuMP.IndicatorMode()))
       BilevelJuMP.set_mode(con4, BilevelJuMP.ProductMode(1e-5))
      -optimize!(model)
      Info

      This code was not executed because Xpress requires a commercial license. Other solvers supporting MISOCP could be used such as Gurobi and CPLEX.

      We set the reformulation method as Mixed Mode and selected Indicator constraints to be the default for the case in which we do not explicitly specify the reformulation. Then we set product mode for the second order cone reformulation.

      Binary expansions require bounded variables, hence the QuadraticToBinary meta-solver accepts fallback to upper and lower bounds (\texttt{ub} and \texttt{lb}), used for variables with no explicit bounds.

      Info

      View this file on Github.


      This page was generated using Literate.jl.

      +optimize!(model)
      Info

      This code was not executed because Xpress requires a commercial license. Other solvers supporting MISOCP could be used such as Gurobi and CPLEX.

      We set the reformulation method as Mixed Mode and selected Indicator constraints to be the default for the case in which we do not explicitly specify the reformulation. Then we set product mode for the second order cone reformulation.

      Binary expansions require bounded variables, hence the QuadraticToBinary meta-solver accepts fallback to upper and lower bounds (\texttt{ub} and \texttt{lb}), used for variables with no explicit bounds.

      Info

      View this file on Github.


      This page was generated using Literate.jl.

      diff --git a/dev/tutorials/getting_started/index.html b/dev/tutorials/getting_started/index.html index ddcc04d..936a474 100644 --- a/dev/tutorials/getting_started/index.html +++ b/dev/tutorials/getting_started/index.html @@ -121,7 +121,7 @@ 0 (bound viol.) 0 (int. viol.) 0 (row viol.) - Timing 0.03 (total) + Timing 0.08 (total) 0.00 (presolve) 0.00 (postsolve) Nodes 1 @@ -341,4 +341,4 @@ julia> set_attribute(model, "output_flag", false) julia> get_attribute(model, "output_flag") -false
      Info

      View this file on Github.


      This page was generated using Literate.jl.

      +false
      Info

      View this file on Github.


      This page was generated using Literate.jl.

      diff --git a/dev/tutorials/lower_duals/index.html b/dev/tutorials/lower_duals/index.html index a3cfb18..8e7d91f 100644 --- a/dev/tutorials/lower_duals/index.html +++ b/dev/tutorials/lower_duals/index.html @@ -90,37 +90,58 @@ 42 1.9999819e+04 1.43e-01 7.31e+05 -1.0 1.22e-03 - 1.00e+00 7.51e-02f 4 43 1.9999806e+04 2.90e-02 2.92e+05 -1.0 1.08e-03 - 1.00e+00 7.98e-01h 1 44 1.9999805e+04 2.55e-02 3.26e+06 -1.0 1.66e-04 - 1.00e+00 1.21e-01f 3 - 45 1.9999800e+04 6.63e-03 1.82e+06 -1.0 1.64e-04 - 1.00e+00 7.39e-01h 1 - 46 1.9999800e+04 6.08e-03 1.31e+07 -1.0 5.25e-05 - 1.00e+00 8.04e-02f 4 - 47 1.9999800e+04 9.62e-04 3.47e+06 -1.0 4.59e-05 - 1.00e+00 8.59e-01h 1 - 48 1.9999800e+04 8.45e-04 2.80e+07 -1.0 9.75e-06 - 1.00e+00 3.04e-01f 2 - 49 1.9999799e+04 4.67e-04 4.13e+07 -1.0 1.23e-05 - 1.00e+00 1.25e-01h 4 + 45 1.9999800e+04 6.64e-03 1.82e+06 -1.0 1.64e-04 - 1.00e+00 7.39e-01h 1 + 46 1.9999800e+04 6.11e-03 1.31e+07 -1.0 5.25e-05 - 1.00e+00 8.04e-02f 4 + 47 1.9999800e+04 9.57e-04 3.47e+06 -1.0 4.59e-05 - 1.00e+00 8.59e-01h 1 + 48 1.9999800e+04 6.28e-04 2.79e+07 -1.0 9.71e-06 - 1.00e+00 3.06e-01f 2 + 49 1.9999799e+04 8.69e-05 3.54e+07 -1.0 1.15e-05 - 1.00e+00 2.50e-01h 3 iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls - 50 1.9999800e+04 4.20e-05 9.16e-03 -1.0 1.72e-05 - 1.00e+00 1.00e+00h 1 - 51 1.9999997e+04 5.29e-07 2.40e+07 -8.6 4.91e-03 - 7.50e-01 1.00e+00f 1 - 52 2.0000000e+04 4.62e-10 4.12e+04 -8.6 6.23e-05 - 9.98e-01 9.95e-01f 1 - 53 2.0000000e+04 1.14e-13 5.85e-08 -8.6 5.53e-08 - 1.00e+00 1.00e+00h 1 - 54 2.0000000e+04 4.93e-15 1.79e-13 -8.6 1.71e-10 - 1.00e+00 1.00e+00h 1 + 50 1.9999800e+04 4.22e-06 4.18e+07 -1.0 1.12e-05 - 1.00e+00 3.12e-02h 6 + 51 1.9999800e+04 5.78e-07 4.41e+07 -1.0 1.30e-05 - 1.00e+00 1.95e-03h 10 + 52 1.9999800e+04 5.78e-07 4.47e+07 -1.0 1.29e-05 - 1.00e+00 1.22e-04h 14 + 53 1.9999808e+04 7.72e-03 8.23e-03 -1.0 1.40e-05 - 1.00e+00 1.00e+00s 22 + 54 1.9999997e+04 4.41e-07 4.92e+00 -5.7 4.93e-03 - 1.00e+00 1.00e+00f 1 + 55 1.9999999e+04 1.48e-10 1.25e+03 -5.7 4.82e-05 - 9.51e-01 9.97e-01f 1 + 56 2.0000000e+04 7.82e-13 6.55e+00 -5.7 4.65e-06 - 1.00e+00 9.95e-01f 1 + 57 2.0000000e+04 9.99e-14 4.70e-10 -5.7 5.51e-08 - 1.00e+00 1.00e+00f 1 + 58 2.0000000e+04 1.14e-13 7.81e+01 -8.6 9.21e-08 - 9.58e-01 1.00e+00f 1 + 59 6.1246727e+04 3.72e+04 2.78e+13 -8.6 1.21e+78 - 5.73e-30 2.12e-18F 1 +iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls + 60 6.1246728e+04 3.72e+04 2.78e+13 -8.6 4.52e+04 - 8.31e-03 2.19e-10h 1 + 61 6.1144734e+04 3.71e+04 2.55e+13 -8.6 3.92e+03 - 5.75e-02 8.18e-02h 1 + 62r 6.1144734e+04 3.71e+04 1.00e+03 3.6 0.00e+00 - 0.00e+00 4.41e-11R 2 + 63r 6.2346762e+04 3.83e+04 2.03e+03 3.6 2.30e+12 - 9.22e-10 4.86e-11f 6 + 64r 6.0677876e+04 3.62e+04 2.03e+03 1.5 2.55e+06 - 6.82e-04 6.06e-04f 1 + 65r 5.9593573e+04 3.42e+04 2.03e+03 1.5 8.11e+05 - 6.73e-06 1.29e-03f 1 + 66r 3.3177905e+04 9.07e+03 2.03e+03 1.5 1.34e+06 - 1.42e-05 1.87e-03f 1 + 67 3.3166193e+04 9.06e+03 9.99e+02 -8.6 9.04e+02 - 6.37e-01 8.98e-04h 1 + 68 2.4771237e+04 3.28e+03 3.62e+02 -8.6 9.03e+02 - 6.52e-01 6.37e-01h 1 + 69 2.2863803e+04 1.97e+03 2.33e+02 -8.6 3.28e+02 - 9.40e-01 4.00e-01h 1 +iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls + 70 2.0069449e+04 4.78e+01 5.64e+00 -8.6 1.97e+02 - 9.71e-01 9.76e-01h 1 + 71 2.0000010e+04 6.84e-03 8.52e-04 -8.6 4.78e+00 - 1.00e+00 1.00e+00h 1 + 72 2.0000000e+04 1.35e-13 6.10e-10 -8.6 6.95e-04 - 1.00e+00 1.00e+00h 1 + 73 2.0000000e+04 1.42e-14 6.61e-14 -8.6 2.77e-11 - 1.00e+00 1.00e+00h 1 -Number of Iterations....: 54 +Number of Iterations....: 73 (scaled) (unscaled) -Objective...............: -2.0000000046430941e+04 2.0000000046430941e+04 -Dual infeasibility......: 1.7944263049376870e-13 1.7944263049376870e-13 -Constraint violation....: 4.9276714876508972e-15 4.9276714876508972e-15 -Variable bound violation: 3.9995489231614556e-07 3.9995489231614556e-07 -Complementarity.........: 2.6685309806246466e-09 2.6685309806246466e-09 -Overall NLP error.......: 2.3559954670452298e-09 2.6685309806246466e-09 +Objective...............: -2.0000000046430814e+04 2.0000000046430814e+04 +Dual infeasibility......: 6.6055616324458369e-14 6.6055616324458369e-14 +Constraint violation....: 1.4210854715202004e-14 1.4210854715202004e-14 +Variable bound violation: 3.9995490652700028e-07 3.9995490652700028e-07 +Complementarity.........: 2.5441766264890888e-09 2.5441766264890888e-09 +Overall NLP error.......: 2.2463137571874334e-09 2.5441766264890888e-09 -Number of objective function evaluations = 70 -Number of objective gradient evaluations = 55 -Number of equality constraint evaluations = 70 -Number of inequality constraint evaluations = 70 -Number of equality constraint Jacobian evaluations = 55 -Number of inequality constraint Jacobian evaluations = 55 -Number of Lagrangian Hessian evaluations = 54 -Total seconds in IPOPT = 0.019 +Number of objective function evaluations = 149 +Number of objective gradient evaluations = 71 +Number of equality constraint evaluations = 149 +Number of inequality constraint evaluations = 149 +Number of equality constraint Jacobian evaluations = 75 +Number of inequality constraint Jacobian evaluations = 75 +Number of Lagrangian Hessian evaluations = 73 +Total seconds in IPOPT = 0.029 EXIT: Optimal Solution Found.

      MIP solution

      It is also possible to solve such problem by using a MIP formulation. The main issue is the product of variable in the upper level objective. However, this can be easily handled by using the package QuadraticToBinary.jl for automatic binary expansions. Because binary expansions require bounds on variables, we add the following lines:

      set_lower_bound(lambda, 0.0)
       set_upper_bound(lambda, 1000.0)

      Then, as before, we set a solver (now HiGHS with the QuadraticToBinary.jl wrapper) and a solution method (now Fortuny-Amat and McCarl):

      set_optimizer(model,
      @@ -161,4 +182,4 @@
       my_duals # a vector of anonimous variables
      3-element Vector{Any}:
        anon
        anon
      - anon
      Info

      View this file on Github.


      This page was generated using Literate.jl.

      + anon
      Info

      View this file on Github.


      This page was generated using Literate.jl.

      diff --git a/dev/tutorials/modes/index.html b/dev/tutorials/modes/index.html index ee5bf05..7fee8f4 100644 --- a/dev/tutorials/modes/index.html +++ b/dev/tutorials/modes/index.html @@ -83,11 +83,10 @@ @assert abs(objective_value(model) - (3 * (3.5 * 8/15) + 8/15)) < 1e-1 # src
      presolving:
       (round 1, fast)       0 del vars, 3 del conss, 0 add conss, 3 chg bounds, 0 chg sides, 0 chg coeffs, 0 upgd conss, 0 impls, 0 clqs
      -(round 2, fast)       0 del vars, 3 del conss, 0 add conss, 5 chg bounds, 0 chg sides, 0 chg coeffs, 0 upgd conss, 0 impls, 0 clqs
      -(round 3, fast)       0 del vars, 3 del conss, 0 add conss, 8 chg bounds, 0 chg sides, 0 chg coeffs, 0 upgd conss, 0 impls, 0 clqs
      -(round 4, exhaustive) 0 del vars, 6 del conss, 0 add conss, 8 chg bounds, 3 chg sides, 0 chg coeffs, 0 upgd conss, 0 impls, 0 clqs
      +(round 2, fast)       0 del vars, 3 del conss, 0 add conss, 8 chg bounds, 0 chg sides, 0 chg coeffs, 0 upgd conss, 0 impls, 0 clqs
      +(round 3, exhaustive) 0 del vars, 6 del conss, 0 add conss, 8 chg bounds, 3 chg sides, 0 chg coeffs, 0 upgd conss, 0 impls, 0 clqs
          (0.0s) symmetry computation skipped: there exist constraints that cannot be handled by symmetry methods.
      -presolving (5 rounds: 5 fast, 2 medium, 2 exhaustive):
      +presolving (4 rounds: 4 fast, 2 medium, 2 exhaustive):
        0 deleted vars, 6 deleted constraints, 0 added constraints, 8 tightened bounds, 0 added holes, 3 changed sides, 0 changed coefficients
        0 implications, 0 cliques
       presolved problem has 10 variables (0 bin, 0 int, 0 impl, 10 cont) and 10 constraints
      @@ -98,7 +97,8 @@
        time | node  | left  |LP iter|LP it/n|mem/heur|mdpt |vars |cons |rows |cuts |sepa|confs|strbr|  dualbound   | primalbound  |  gap   | compl.
         0.0s|     1 |     0 |     5 |     - |   639k |   0 |  10 |  10 |   6 |   0 |  0 |   0 |   0 | 6.133333e+00 |      --      |    Inf | unknown
         0.0s|     1 |     0 |     6 |     - |   639k |   0 |  10 |  10 |   7 |   1 |  2 |   0 |   0 | 6.133333e+00 |      --      |    Inf | unknown
      -* 0.0s|     1 |     0 |     6 |     - |    LP  |   0 |  10 |  10 |   7 |   1 |  4 |   0 |   0 | 6.133333e+00 | 6.133333e+00 |   0.00%| unknown
      +  0.0s|     1 |     0 |     7 |     - |   639k |   0 |  10 |  10 |   8 |   2 |  4 |   0 |   0 | 6.133333e+00 |      --      |    Inf | unknown
      +* 0.0s|     1 |     0 |     7 |     - |    LP  |   0 |  10 |  10 |   8 |   2 |  6 |   0 |   0 | 6.133333e+00 | 6.133333e+00 |   0.00%| unknown
       
       SCIP Status        : problem is solved [optimal solution found]
       Solving Time (sec) : 0.00
      @@ -130,17 +130,14 @@
       Presolving Time: 0.00
       
        time | node  | left  |LP iter|LP it/n|mem/heur|mdpt |vars |cons |rows |cuts |sepa|confs|strbr|  dualbound   | primalbound  |  gap   | compl.
      -  0.0s|     1 |     0 |    18 |     - |   754k |   0 |  14 |  17 |   9 |   0 |  0 |   0 |   0 | 6.133333e+00 |      --      |    Inf | unknown
      -  0.0s|     1 |     0 |    20 |     - |   761k |   0 |  14 |  17 |  11 |   2 |  1 |   0 |   0 | 6.133333e+00 |      --      |    Inf | unknown
      -  0.0s|     1 |     0 |    21 |     - |   765k |   0 |  14 |  17 |  12 |   3 |  2 |   0 |   0 | 6.133333e+00 |      --      |    Inf | unknown
      -  0.0s|     1 |     0 |    22 |     - |   766k |   0 |  14 |  17 |  13 |   4 |  4 |   0 |   0 | 6.133333e+00 |      --      |    Inf | unknown
      -r 0.0s|     1 |     0 |    22 |     - |randroun|   0 |  14 |  17 |  13 |   0 |  4 |   0 |   0 | 6.133333e+00 | 6.133333e+00 |   0.00%| unknown
      -  0.0s|     1 |     0 |    22 |     - |   766k |   0 |  14 |  17 |  13 |   4 |  4 |   0 |   0 | 6.133333e+00 | 6.133333e+00 |   0.00%| unknown
      +p 0.0s|     1 |     0 |     5 |     - |  clique|   0 |  14 |  17 |   9 |   0 |  0 |   0 |   0 | 0.000000e+00 | 1.800000e+01 |    Inf | unknown
      +p 0.0s|     1 |     0 |    11 |     - |   locks|   0 |  14 |  17 |   9 |   0 |  0 |   0 |   0 | 0.000000e+00 | 6.133333e+00 |    Inf | unknown
      +  0.0s|     1 |     0 |    17 |     - |   754k |   0 |  14 |  15 |   9 |   0 |  0 |   0 |   0 | 6.133333e+00 | 6.133333e+00 |   0.00%| unknown
       
       SCIP Status        : problem is solved [optimal solution found]
       Solving Time (sec) : 0.00
       Solving Nodes      : 1
      -Primal Bound       : +6.13333333333333e+00 (1 solutions)
      +Primal Bound       : +6.13333333333333e+00 (2 solutions)
       Dual Bound         : +6.13333333333333e+00
       Gap                : 0.00 %
      Warning

      SCIP requires a non-standard installation procedure in windows. See SCIP.jl for more details.

      ProductMode and Ipopt.Optimizer

      set_optimizer(model, Ipopt.Optimizer)
       
      @@ -198,32 +195,54 @@
         26  6.1333604e+00 5.74e-08 3.18e+05  -1.0 4.19e-03    -  1.00e+00 3.61e-01f  2
         27  6.1333559e+00 3.78e-08 2.30e+05  -1.0 6.97e-04    -  1.00e+00 8.11e-01h  1
         28  6.1333447e+00 3.25e-09 1.96e+06  -1.0 2.95e-03    -  1.00e+00 4.96e-01f  2
      -  29  6.1333430e+00 0.00e+00 2.44e+03  -1.0 2.20e-04    -  1.00e+00 1.00e+00h  1
      +  29  6.1333430e+00 2.22e-16 2.44e+03  -1.0 2.20e-04    -  1.00e+00 1.00e+00h  1
       iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
         30  6.1333427e+00 0.00e+00 3.07e+03  -2.5 3.24e-05    -  1.00e+00 1.00e+00f  1
         31  6.1333393e+00 0.00e+00 2.13e+01  -2.5 3.73e-05   4.0 1.00e+00 1.00e+00f  1
      -Cannot call restoration phase at point that is almost feasible (violation 0.000000e+00).
      +  32  6.1333392e+00 0.00e+00 3.41e+00  -3.8 1.25e-06   3.5 1.00e+00 1.00e+00h  1
      +  33  6.1333388e+00 1.82e-13 3.70e-03  -3.8 3.43e-06   3.0 1.00e+00 1.00e+00f  1
      +  34  6.1333372e+00 9.10e-14 5.45e+03  -5.7 6.82e-04    -  7.04e-01 5.00e-01h  2
      +  35  6.1333370e+00 1.11e-16 3.31e+03  -5.7 4.65e-06   2.6 7.90e-01 1.00e+00h  1
      +  36  6.1333368e+00 0.00e+00 3.00e+03  -5.7 5.96e-04    -  1.00e+00 1.56e-01h  3
      +  37  6.1333351e+00 1.11e-16 1.95e+03  -5.7 3.97e-03    -  5.87e-01 3.50e-01h  2
      +  38  6.1333348e+00 0.00e+00 3.89e-02  -5.7 2.90e-06   2.1 1.00e+00 1.00e+00h  1
      +  39  6.1333340e+00 0.00e+00 5.31e-01  -5.7 2.19e-03    -  1.00e+00 1.00e+00h  1
      +iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
      +  40  6.1333335e+00 2.22e-16 6.63e-02  -5.7 8.65e-03    -  1.00e+00 1.00e+00h  1
      +  41  6.1333338e+00 1.11e-16 3.91e-05  -5.7 9.78e-07   1.6 1.00e+00 1.00e+00h  1
      +  42  6.1333335e+00 0.00e+00 1.90e+00  -5.7 1.20e-02    -  1.00e+00 1.00e+00H  1
      +  43  6.1333336e+00 0.00e+00 2.27e-04  -5.7 1.60e-06   1.1 1.00e+00 1.00e+00h  1
      +  44  6.1333335e+00 8.88e-16 3.54e+00  -5.7 3.68e-02    -  7.32e-01 2.15e-01h  3
      +  45  6.1333335e+00 8.88e-16 1.37e+04  -5.7 5.91e-01    -  9.38e-01 1.28e-04h  8
      +  46  6.1333335e+00 0.00e+00 2.37e+00  -5.7 8.37e-03    -  1.00e+00 1.00e+00h  1
      +  47  6.1333335e+00 1.11e-16 9.88e-04  -5.7 3.46e-06   0.6 1.00e+00 1.00e+00h  1
      +  48  6.1333334e+00 0.00e+00 1.97e+01  -5.7 9.34e-02    -  4.64e-01 1.42e-01f  3
      +  49  6.1333335e+00 1.11e-16 3.62e+00  -5.7 5.42e-02    -  1.00e+00 1.00e+00s 22
      +iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
      +  50  6.1333333e+00 1.11e-16 3.00e+00  -5.7 6.88e-02    -  1.58e-01 1.58e-01s 22
      +  51  6.1333338e+00 1.11e-16 3.74e-03  -5.7 3.09e-05   0.2 1.00e+00 1.00e+00s 22
      +Cannot call restoration phase at point that is almost feasible (violation 1.110223e-16).
       Abort in line search due to no other fall back.
       
      -Number of Iterations....: 31
      +Number of Iterations....: 51
       
                                          (scaled)                 (unscaled)
      -Objective...............:   6.1333392656866677e+00    6.1333392656866677e+00
      -Dual infeasibility......:   2.1310536983443171e+01    2.1310536983443171e+01
      -Constraint violation....:   0.0000000000000000e+00    0.0000000000000000e+00
      -Variable bound violation:   4.4274786760585229e-09    4.4274786760585229e-09
      -Complementarity.........:   3.1439668442150119e-03    3.1439668442150119e-03
      -Overall NLP error.......:   1.6855608441038162e-02    2.1310536983443171e+01
      -
      -
      -Number of objective function evaluations             = 65
      -Number of objective gradient evaluations             = 33
      -Number of equality constraint evaluations            = 65
      -Number of inequality constraint evaluations          = 65
      -Number of equality constraint Jacobian evaluations   = 33
      -Number of inequality constraint Jacobian evaluations = 33
      -Number of Lagrangian Hessian evaluations             = 32
      -Total seconds in IPOPT                               = 0.014
      +Objective...............:   6.1333337784306430e+00    6.1333337784306430e+00
      +Dual infeasibility......:   3.7397819529587650e-03    3.7397819529587650e-03
      +Constraint violation....:   1.1102230246251565e-16    1.1102230246251565e-16
      +Variable bound violation:   4.4274805315123328e-09    4.4274805315123328e-09
      +Complementarity.........:   1.8492384206734471e-06    1.8492384206734471e-06
      +Overall NLP error.......:   3.7397819529587650e-03    3.7397819529587650e-03
      +
      +
      +Number of objective function evaluations             = 114
      +Number of objective gradient evaluations             = 53
      +Number of equality constraint evaluations            = 114
      +Number of inequality constraint evaluations          = 114
      +Number of equality constraint Jacobian evaluations   = 53
      +Number of inequality constraint Jacobian evaluations = 53
      +Number of Lagrangian Hessian evaluations             = 52
      +Total seconds in IPOPT                               = 0.024
       
       EXIT: Error in step computation!

      StrongDualityMode and Ipopt.Optimizer

      set_optimizer(model, Ipopt.Optimizer)
       
      @@ -263,92 +282,113 @@
       iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
         10  6.1317629e+00 9.14e-03 2.51e+02  -1.7 1.45e+01    -  6.09e-01 3.74e-01h  1
         11  6.1326207e+00 8.08e-03 3.75e+02  -1.7 7.78e+01    -  5.24e-01 3.34e-01f  1
      -  12  6.1330471e+00 4.49e-03 5.42e+02  -1.7 5.06e+01    -  5.84e-01 4.01e-01H  1
      -  13  6.1330042e+00 4.19e-03 2.38e+02  -1.7 2.41e+02    -  3.12e-01 4.80e-01F  1
      -  14  6.1332031e+00 4.03e-03 2.43e+02  -1.7 3.17e+02    -  3.74e-01 3.74e-01H  1
      -  15  6.1332221e+00 6.18e-04 7.32e+02  -1.7 5.37e+02    -  5.47e-01 4.62e-01H  1
      -  16  6.1332962e+00 6.48e-04 5.28e+02  -1.7 9.70e+02    -  4.48e-01 4.99e-01H  1
      -  17  6.1333059e+00 6.51e-03 1.37e+04  -1.7 1.92e+03    -  7.43e-01 3.38e-01f  2
      -  18  6.1333095e+00 6.49e-03 3.75e+04  -1.7 3.05e+03    -  6.23e-01 1.25e-01h  4
      -  19  6.1333111e+00 6.32e-03 7.22e+04  -1.7 4.20e+03    -  7.09e-01 6.25e-02h  5
      +  12  6.1330486e+00 4.42e-03 5.23e+02  -1.7 5.06e+01    -  5.84e-01 4.03e-01H  1
      +  13  6.1330047e+00 4.21e-03 1.85e+02  -1.7 2.42e+02    -  3.11e-01 4.80e-01F  1
      +  14  6.1332027e+00 4.23e-03 2.44e+02  -1.7 3.18e+02    -  3.71e-01 3.72e-01H  1
      +  15  6.1332221e+00 2.82e-04 2.11e+02  -1.7 5.36e+02    -  5.48e-01 4.64e-01F  1
      +  16  6.1332964e+00 2.43e-03 2.64e+02  -1.7 9.71e+02    -  4.43e-01 5.04e-01F  1
      +  17  6.1333045e+00 5.56e-03 1.26e+03  -1.7 1.88e+03    -  4.96e-01 5.04e-01F  1
      +  18r 6.1333045e+00 5.56e-03 1.00e+03  -1.7 0.00e+00    -  0.00e+00 4.87e-18R  2
      +  19r 6.1333058e+00 5.17e-05 8.43e+02  -1.7 4.00e+02    -  1.58e-01 3.57e-03f  1
       iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
      -  20  6.1333127e+00 6.18e-03 1.06e+05  -1.7 4.53e+03    -  6.98e-01 6.25e-02h  5
      -  21  6.1333141e+00 6.05e-03 1.40e+05  -1.7 4.98e+03    -  7.11e-01 6.25e-02h  5
      -  22  6.1333155e+00 5.93e-03 1.73e+05  -1.7 5.43e+03    -  7.12e-01 6.25e-02h  5
      -  23  6.1333167e+00 5.81e-03 2.06e+05  -1.7 5.95e+03    -  7.18e-01 6.25e-02h  5
      -  24  6.1333179e+00 5.70e-03 2.39e+05  -1.7 6.52e+03    -  7.21e-01 6.25e-02h  5
      -  25  6.1333190e+00 5.60e-03 2.71e+05  -1.7 7.14e+03    -  7.25e-01 6.25e-02h  5
      -  26  6.1333200e+00 5.50e-03 3.03e+05  -1.7 7.81e+03    -  7.28e-01 6.25e-02h  5
      -  27  6.1333348e+00 6.40e-02 2.04e+04  -1.7 8.54e+03    -  7.31e-01 1.00e+00w  1
      -  28  6.1333342e+00 1.11e-02 1.79e+05  -1.7 4.04e+03    -  1.00e+00 8.78e-01w  1
      -  29  6.1333333e+00 8.74e-03 1.16e+05  -1.7 6.41e+03    -  1.00e+00 5.31e-01w  1
      +  20  6.1333111e+00 5.17e-05 5.58e+03  -1.7 6.87e-02    -  9.90e-01 3.65e-04f  2
      +  21  6.1333111e+00 5.17e-05 5.64e+15  -1.7 5.24e+68  -1.6 3.27e-62 6.71e-75h  1
      +  22  6.1333140e+00 5.05e-05 6.51e+13  -1.7 6.27e+00    -  9.88e-01 1.60e-02f  2
      +  23  6.1333152e+00 2.37e-05 1.10e+13  -1.7 7.29e+02    -  8.31e-01 5.98e-02h  5
      +  24  6.1333152e+00 2.37e-05 1.10e+11  -1.7 2.78e+03    -  9.90e-01 1.87e-05h 16
      +  25r 6.1333152e+00 2.37e-05 1.00e+03  -1.7 0.00e+00    -  0.00e+00 1.21e-10R  2
      +  26r 6.1333389e+00 3.11e-04 9.18e+02  -1.7 4.06e+02    -  1.00e+00 1.00e+00f  1
      +  27r 6.1333582e+00 8.62e-03 2.17e+02  -1.7 2.61e+02    -  1.00e+00 1.00e+00f  1
      +  28r 6.1333543e+00 1.06e-04 4.00e+00  -1.7 1.38e+01    -  1.00e+00 1.00e+00h  1
      +  29r 6.1333547e+00 6.51e-05 1.33e-02  -1.7 2.00e+00    -  1.00e+00 1.00e+00h  1
       iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
      -  30  6.1333204e+00 5.39e-03 3.47e+05  -1.7 3.50e+03    -  7.31e-01 3.12e-02h  5
      -  31  6.1333209e+00 5.28e-03 3.91e+05  -1.7 9.06e+03    -  7.54e-01 3.12e-02h  6
      -  32  6.1333211e+00 5.22e-03 4.39e+05  -1.7 9.36e+03    -  7.46e-01 1.56e-02h  7
      -  33  6.1333213e+00 5.15e-03 4.87e+05  -1.7 9.68e+03    -  7.64e-01 1.56e-02h  7
      -  34  6.1333214e+00 5.13e-03 5.38e+05  -1.7 9.81e+03    -  7.57e-01 3.91e-03h  9
      -  35  6.1333222e+00 5.08e-03 5.53e+05  -1.7 9.95e+03    -  7.71e-01 6.25e-02h  5
      -  36  6.1333230e+00 5.01e-03 5.65e+05  -1.7 1.05e+04    -  7.30e-01 6.25e-02h  5
      -  37  6.1333237e+00 4.95e-03 5.79e+05  -1.7 1.17e+04    -  7.55e-01 6.25e-02h  5
      -  38  6.1333244e+00 4.88e-03 5.92e+05  -1.7 1.27e+04    -  7.45e-01 6.25e-02h  5
      -  39  6.1333250e+00 4.81e-03 6.05e+05  -1.7 1.39e+04    -  7.55e-01 6.25e-02h  5
      +  30r 6.1333361e+00 2.04e-02 1.10e+02  -3.8 5.43e+02    -  1.00e+00 8.72e-01f  1
      +  31r 6.1333334e+00 4.45e-07 8.52e-05  -3.8 2.45e-03  -4.0 1.00e+00 1.00e+00h  1
      +  32  6.1333333e+00 4.84e-07 9.51e+04  -1.7 5.23e-02    -  9.90e-01 8.70e-02f  2
      +  33  6.1333333e+00 7.99e-07 8.86e+02  -1.7 1.36e-03  -2.1 9.91e-01 1.00e+00f  1
      +  34  6.1333334e+00 1.53e-05 4.34e+04  -1.7 5.15e+02    -  8.97e-01 1.46e-01f  3
      +  35  6.1333334e+00 1.15e-06 2.97e-03  -1.7 5.06e-03  -2.5 1.00e+00 1.00e+00f  1
      +  36  6.1333334e+00 1.64e-06 4.40e+02  -5.7 9.89e+01    -  1.00e+00 7.38e-03h  8
      +  37  6.1333334e+00 1.79e-06 3.09e+02  -5.7 4.72e+01    -  9.88e-01 2.50e-01h  3
      +  38  6.1333334e+00 7.44e-07 8.45e+02  -5.7 8.61e+01    -  1.00e+00 1.25e-01h  4
      +  39  6.1333334e+00 6.50e-07 1.08e+03  -5.7 6.60e+01    -  1.00e+00 1.25e-01h  4
       iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
      -  40  6.1333340e+00 6.12e-02 1.79e+04  -1.7 1.51e+04    -  7.55e-01 1.00e+00w  1
      -  41  6.1333339e+00 1.21e-02 1.51e+05  -1.7 1.00e+04    -  1.00e+00 8.38e-01w  1
      -  42  6.1333333e+00 1.17e-02 4.61e+05  -1.7 1.60e+04    -  1.00e+00 7.32e-01w  1
      -  43  6.1333335e+00 2.88e-03 1.85e+05  -1.7 6.33e+03    -  1.00e+00 8.91e-01h  1
      -  44  6.1333334e+00 2.97e-07 3.08e-02  -1.7 1.80e-03  -2.5 1.00e+00 1.00e+00f  1
      -  45  6.1333333e+00 5.94e-08 1.57e+00  -8.6 2.63e-01    -  1.00e+00 1.00e+00h  1
      -  46  6.1333333e+00 0.00e+00 4.62e+02  -8.6 3.21e+00    -  9.95e-01 1.00e+00h  1
      -In iteration 46, 1 Slack too small, adjusting variable bound
      -  47  6.1333333e+00 3.64e-12 2.79e-01  -8.6 5.59e-08  -3.0 1.00e+00 9.99e-01h  1
      -  48  6.1333333e+00 6.89e-04 3.75e+00  -8.6 2.25e+04    -  4.67e-01 1.00e+00h  1
      -  49  6.1333333e+00 0.00e+00 1.19e-08  -8.6 3.22e-05  -3.4 1.00e+00 1.00e+00h  1
      +  40  6.1333333e+00 1.40e-06 1.41e+03  -5.7 1.26e+02    -  1.00e+00 1.25e-01h  4
      +  41  6.1333333e+00 1.39e-06 1.83e+03  -5.7 1.28e+02    -  1.00e+00 1.56e-02h  7
      +  42  6.1333333e+00 1.40e-06 2.21e+03  -5.7 1.89e+02    -  1.00e+00 1.56e-02h  7
      +  43  6.1333333e+00 1.40e-06 2.43e+03  -5.7 1.94e+02    -  1.00e+00 1.56e-02h  7
      +  44  6.1333333e+00 1.40e-06 2.64e+03  -5.7 2.29e+02    -  1.00e+00 1.56e-02h  7
      +  45  6.1333333e+00 1.41e-06 2.76e+03  -5.7 2.31e+02    -  1.00e+00 1.56e-02h  7
      +  46  6.1333333e+00 1.20e-04 9.22e+02  -5.7 2.53e+02    -  1.00e+00 1.00e+00w  1
      +  47  6.1333333e+00 1.19e-05 8.46e+04  -5.7 2.41e+03    -  5.69e-01 1.00e+00w  1
      +  48  6.1333333e+00 9.53e-06 7.01e+04  -5.7 2.40e+02    -  1.00e+00 1.71e-01w  1
      +  49  6.1333333e+00 8.78e-07 4.02e+02  -5.7 9.32e+01    -  9.10e-01 1.00e+00h  1
       iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
      -  50  6.1333333e+00 3.08e-04 4.13e-02  -9.0 1.78e+04    -  8.51e-01 1.00e+00h  1
      -  51  6.1333333e+00 2.52e-04 6.84e-01  -9.0 6.87e+04    -  6.60e-01 1.00e+00h  1
      -  52  6.1333333e+00 2.29e-04 4.52e-01  -9.0 9.58e+04    -  8.64e-01 2.72e-01h  2
      -  53  6.1333333e+00 1.05e-03 4.74e-01  -9.0 2.54e+06    -  4.38e-02 3.12e-02h  6
      -  54  6.1333333e+00 6.98e-04 3.14e-01  -9.0 5.97e-04  -3.9 1.00e+00 3.37e-01h  2
      -  55  6.1333333e+00 5.39e-04 2.25e-01  -9.0 7.13e+04    -  1.00e+00 2.43e-01h  2
      -  56  6.1333333e+00 2.30e-05 4.05e-02  -9.0 1.95e+04    -  1.00e+00 1.00e+00h  1
      -  57  6.1333333e+00 3.20e-06 2.46e-04  -9.0 5.39e+03    -  1.00e+00 1.00e+00h  1
      -  58  6.1333333e+00 1.20e-08 4.72e-06  -9.0 7.70e+02    -  1.00e+00 1.00e+00h  1
      -  59  6.1333333e+00 0.00e+00 1.29e-06  -9.0 5.09e+02    -  1.00e+00 1.00e+00h  1
      +  50  6.1333333e+00 8.68e-07 3.97e+02  -5.7 1.10e+03    -  5.03e-01 1.30e-02h  1
      +  51  6.1333333e+00 8.77e-07 3.97e+02  -5.7 1.54e+05    -  6.93e-03 1.22e-04f 14
      +  52  6.1333333e+00 8.67e-07 3.92e+02  -5.7 5.28e-06  -3.0 1.00e+00 1.21e-02f  2
      +  53  6.1333333e+00 1.98e-06 1.79e+02  -5.7 1.03e+03    -  5.64e-01 2.50e-01h  3
      +  54  6.1333333e+00 1.99e-06 1.78e+02  -5.7 6.66e+03    -  4.60e-01 7.81e-03h  8
      +  55  6.1333333e+00 1.99e-06 1.78e+02  -5.7 6.41e+03    -  1.63e-01 1.92e-06f  2
      +  56  6.1333333e+00 1.99e-06 1.78e+02  -5.7 1.50e+04    -  1.45e-01 1.95e-03h 10
      +  57  6.1333333e+00 1.99e-06 1.78e+02  -5.7 1.64e+04    -  8.26e-02 3.98e-07h  3
      +  58  6.1333333e+00 1.08e-07 4.02e+02  -5.7 2.74e+04    -  6.44e-02 6.25e-02h  5
      +  59  6.1333333e+00 1.08e-07 4.02e+02  -5.7 2.84e+04    -  1.58e-01 8.48e-06h  1
       iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
      -  60  6.1333333e+00 1.16e-10 5.39e-06  -9.0 1.04e+03    -  1.00e+00 1.00e+00h  1
      -  61  6.1333333e+00 0.00e+00 4.44e-07  -9.0 2.98e+02    -  1.00e+00 1.00e+00h  1
      -  62  6.1333333e+00 0.00e+00 1.10e-07  -9.0 1.48e+02    -  1.00e+00 1.00e+00h  1
      -  63  6.1333333e+00 0.00e+00 1.04e-06  -9.0 8.86e+02    -  1.00e+00 5.00e-01h  2
      -  64  6.1333333e+00 2.33e-10 1.55e-06  -9.0 5.56e+02    -  1.00e+00 1.00e+00h  1
      -  65  6.1333333e+00 1.16e-10 4.47e-06  -9.0 9.43e+02    -  1.00e+00 1.00e+00h  1
      -  66  6.1333333e+00 1.16e-10 2.33e-06  -9.0 6.81e+02    -  1.00e+00 1.00e+00h  1
      -  67  6.1333333e+00 0.00e+00 1.37e-06  -9.0 4.06e+02    -  1.00e+00 5.00e-01h  2
      -  68  6.1333333e+00 0.00e+00 6.94e-07  -9.0 3.72e+02    -  1.00e+00 1.00e+00h  1
      -  69  6.1333333e+00 1.16e-10 1.40e-09  -9.0 1.67e+01    -  1.00e+00 1.00e+00h  1
      -
      -Number of Iterations....: 69
      +  60  6.1333333e+00 3.42e-08 4.02e+02  -5.7 8.06e+04    -  9.56e-02 1.95e-03f 10
      +  61  6.1333333e+00 3.42e-08 4.02e+02  -5.7 6.51e+04    -  6.90e-02 3.01e-07f  2
      +  62  6.1333333e+00 1.74e-08 1.35e+02  -5.7 2.16e-05   0.6 1.00e+00 6.64e-01h  1
      +  63  6.1333333e+00 1.50e-06 1.22e+02  -5.7 1.93e+03    -  1.00e+00 1.25e-01f  4
      +  64  6.1333333e+00 1.22e-06 8.58e+02  -5.7 3.34e+03    -  1.00e+00 1.00e+00H  1
      +  65  6.1333333e+00 1.66e-06 8.16e+02  -5.7 9.59e+03    -  9.88e-01 1.00e+00H  1
      +  66  6.1333333e+00 1.75e-06 8.05e+02  -5.7 1.21e+05    -  2.66e-01 1.56e-02h  7
      +  67  6.1333333e+00 1.74e-06 8.04e+02  -5.7 1.74e+05    -  1.72e-01 5.77e-04h  2
      +  68  6.1333333e+00 4.13e-03 1.54e+04  -5.7 2.35e+05    -  1.44e-01 1.00e+00h  1
      +  69  6.1333333e+00 5.82e-11 3.47e-03  -5.7 4.52e-05   1.9 1.00e+00 1.00e+00h  1
      +iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
      +  70  6.1333333e+00 6.36e-05 1.01e+02  -5.7 1.97e+04    -  1.00e+00 1.00e+00h  1
      +  71  6.1333333e+00 4.31e-05 8.96e+00  -5.7 9.76e+03    -  1.00e+00 1.00e+00h  1
      +  72  6.1333333e+00 4.71e-07 3.75e-02  -5.7 7.14e+02    -  1.00e+00 1.00e+00h  1
      +  73  6.1333333e+00 0.00e+00 2.91e-03  -5.7 4.59e+02    -  1.00e+00 1.00e+00h  1
      +  74  6.1333333e+00 0.00e+00 6.83e-03  -5.7 6.64e+02    -  1.00e+00 1.00e+00h  1
      +  75  6.1333333e+00 0.00e+00 2.15e-02  -5.7 1.18e+03    -  1.00e+00 1.00e+00h  1
      +  76  6.1333333e+00 0.00e+00 1.24e-02  -5.7 6.48e+02    -  1.00e+00 5.00e-01h  2
      +  77  6.1333333e+00 0.00e+00 3.77e-02  -5.7 1.55e+03    -  1.00e+00 1.00e+00h  1
      +  78  6.1333333e+00 1.16e-10 1.99e-02  -5.7 1.13e+03    -  1.00e+00 1.00e+00h  1
      +  79  6.1333333e+00 1.16e-10 5.54e-03  -5.7 5.99e+02    -  1.00e+00 1.00e+00h  1
      +iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
      +  80  6.1333333e+00 0.00e+00 2.95e-03  -5.7 4.37e+02    -  1.00e+00 1.00e+00H  1
      +  81  6.1333333e+00 0.00e+00 3.48e-04  -5.7 1.50e+02    -  1.00e+00 1.00e+00H  1
      +  82  6.1333333e+00 0.00e+00 8.72e-03  -5.7 7.51e+02    -  1.00e+00 1.00e+00h  1
      +  83  6.1333333e+00 0.00e+00 5.40e-03  -5.7 5.19e+02    -  1.00e+00 5.00e-01h  2
      +  84  6.1333333e+00 0.00e+00 5.04e-03  -5.7 7.78e+02    -  1.00e+00 5.00e-01h  2
      +  85  6.1333333e+00 0.00e+00 1.87e-05  -5.7 3.53e+01    -  1.00e+00 1.00e+00h  1
      +  86  6.1333333e+00 0.00e+00 1.13e-04  -5.7 8.54e+01    -  1.00e+00 1.00e+00h  1
      +  87  6.1333333e+00 0.00e+00 6.32e-04  -5.7 3.85e+02    -  1.00e+00 5.00e-01h  2
      +Cannot call restoration phase at point that is almost feasible (violation 0.000000e+00).
      +Abort in line search due to no other fall back.
      +
      +Number of Iterations....: 87
       
                                          (scaled)                 (unscaled)
      -Objective...............:   6.1333332729116652e+00    6.1333332729116652e+00
      -Dual infeasibility......:   1.3969838619232178e-09    1.3969838619232178e-09
      -Constraint violation....:   1.1641532182693481e-10    1.1641532182693481e-10
      +Objective...............:   6.1333332911037246e+00    6.1333332911037246e+00
      +Dual infeasibility......:   6.3216686248779297e-04    6.3216686248779297e-04
      +Constraint violation....:   0.0000000000000000e+00    0.0000000000000000e+00
       Variable bound violation:   0.0000000000000000e+00    0.0000000000000000e+00
      -Complementarity.........:   9.0909101251615372e-10    9.0909101251615372e-10
      -Overall NLP error.......:   1.3969838619232178e-09    1.3969838619232178e-09
      +Complementarity.........:   1.8449145045134108e-06    1.8449145045134108e-06
      +Overall NLP error.......:   6.3216686248779297e-04    6.3216686248779297e-04
       
       
      -Number of objective function evaluations             = 212
      -Number of objective gradient evaluations             = 70
      -Number of equality constraint evaluations            = 212
      -Number of inequality constraint evaluations          = 212
      -Number of equality constraint Jacobian evaluations   = 70
      -Number of inequality constraint Jacobian evaluations = 70
      -Number of Lagrangian Hessian evaluations             = 69
      -Total seconds in IPOPT                               = 0.029
      +Number of objective function evaluations             = 328
      +Number of objective gradient evaluations             = 84
      +Number of equality constraint evaluations            = 328
      +Number of inequality constraint evaluations          = 328
      +Number of equality constraint Jacobian evaluations   = 91
      +Number of inequality constraint Jacobian evaluations = 91
      +Number of Lagrangian Hessian evaluations             = 88
      +Total seconds in IPOPT                               = 0.047
       
      -EXIT: Optimal Solution Found.

      MixedMode and SCIP.Optimizer

      set_optimizer(model, SCIP.Optimizer)
      +EXIT: Error in step computation!

      MixedMode and SCIP.Optimizer

      set_optimizer(model, SCIP.Optimizer)
       
       BilevelJuMP.set_mode(model, BilevelJuMP.MixedMode(default = BilevelJuMP.SOS1Mode()))
       
      @@ -362,12 +402,11 @@
       
       @assert abs(objective_value(model) - (3 * (3.5 * 8/15) + 8/15)) < 1e-1 # src
      presolving:
       (round 1, fast)       2 del vars, 5 del conss, 0 add conss, 5 chg bounds, 0 chg sides, 0 chg coeffs, 0 upgd conss, 0 impls, 0 clqs
      -(round 2, fast)       2 del vars, 5 del conss, 0 add conss, 8 chg bounds, 0 chg sides, 0 chg coeffs, 0 upgd conss, 0 impls, 0 clqs
      -(round 3, fast)       2 del vars, 5 del conss, 0 add conss, 10 chg bounds, 0 chg sides, 0 chg coeffs, 0 upgd conss, 0 impls, 0 clqs
      -(round 4, exhaustive) 2 del vars, 7 del conss, 0 add conss, 10 chg bounds, 2 chg sides, 0 chg coeffs, 0 upgd conss, 0 impls, 0 clqs
      +(round 2, fast)       2 del vars, 5 del conss, 0 add conss, 10 chg bounds, 0 chg sides, 0 chg coeffs, 0 upgd conss, 0 impls, 0 clqs
      +(round 3, exhaustive) 2 del vars, 7 del conss, 0 add conss, 10 chg bounds, 2 chg sides, 0 chg coeffs, 0 upgd conss, 0 impls, 0 clqs
          (0.0s) probing cycle finished: starting next cycle
          (0.0s) symmetry computation skipped: there exist constraints that cannot be handled by symmetry methods.
      -presolving (5 rounds: 5 fast, 2 medium, 2 exhaustive):
      +presolving (4 rounds: 4 fast, 2 medium, 2 exhaustive):
        2 deleted vars, 7 deleted constraints, 0 added constraints, 10 tightened bounds, 0 added holes, 2 changed sides, 0 changed coefficients
        7 implications, 0 cliques
       presolved problem has 11 variables (1 bin, 0 int, 0 impl, 10 cont) and 12 constraints
      @@ -376,12 +415,15 @@
       Presolving Time: 0.00
       
        time | node  | left  |LP iter|LP it/n|mem/heur|mdpt |vars |cons |rows |cuts |sepa|confs|strbr|  dualbound   | primalbound  |  gap   | compl.
      -p 0.0s|     1 |     0 |     5 |     - |   locks|   0 |  11 |  12 |   7 |   0 |  0 |   0 |   0 | 0.000000e+00 | 6.133333e+00 |    Inf | unknown
      -  0.0s|     1 |     0 |    10 |     - |   641k |   0 |  11 |  11 |   7 |   0 |  0 |   0 |   0 | 6.133333e+00 | 6.133333e+00 |   0.00%| unknown
      +  0.0s|     1 |     0 |    10 |     - |   643k |   0 |  11 |  12 |   7 |   0 |  0 |   0 |   0 | 6.133333e+00 |      --      |    Inf | unknown
      +  0.0s|     1 |     0 |    11 |     - |   646k |   0 |  11 |  12 |   8 |   1 |  1 |   0 |   0 | 6.133333e+00 |      --      |    Inf | unknown
      +  0.0s|     1 |     0 |    12 |     - |   656k |   0 |  11 |  12 |   9 |   2 |  2 |   0 |   0 | 6.133333e+00 |      --      |    Inf | unknown
      +  0.0s|     1 |     0 |    13 |     - |   656k |   0 |  11 |  12 |  10 |   3 |  4 |   0 |   0 | 6.133333e+00 |      --      |    Inf | unknown
      +* 0.0s|     1 |     0 |    13 |     - |    LP  |   0 |  11 |  12 |  10 |   3 |  6 |   0 |   0 | 6.133333e+00 | 6.133333e+00 |   0.00%| unknown
       
       SCIP Status        : problem is solved [optimal solution found]
       Solving Time (sec) : 0.00
       Solving Nodes      : 1
       Primal Bound       : +6.13333333333333e+00 (1 solutions)
       Dual Bound         : +6.13333333333333e+00
      -Gap                : 0.00 %
      Warning

      SCIP requires a non-standard installation procedure in windows. See SCIP.jl for more details.

      Info

      View this file on Github.


      This page was generated using Literate.jl.

      +Gap : 0.00 %
      Warning

      SCIP requires a non-standard installation procedure in windows. See SCIP.jl for more details.


      This page was generated using Literate.jl.

      diff --git a/dev/tutorials/non_linear/index.html b/dev/tutorials/non_linear/index.html index 2519876..05aec57 100644 --- a/dev/tutorials/non_linear/index.html +++ b/dev/tutorials/non_linear/index.html @@ -186,4 +186,4 @@ Number of Lagrangian Hessian evaluations = 17 Total seconds in IPOPT = 0.005 -EXIT: Optimal Solution Found.
      Info

      Conic constraints are supported in the lower level (see Conic Bilevel tutorial).


      This page was generated using Literate.jl.

      +EXIT: Optimal Solution Found.
      Info

      Conic constraints are supported in the lower level (see Conic Bilevel tutorial).


      This page was generated using Literate.jl.

      diff --git a/dev/tutorials/quad_to_bin/index.html b/dev/tutorials/quad_to_bin/index.html index f5e753c..8c50639 100644 --- a/dev/tutorials/quad_to_bin/index.html +++ b/dev/tutorials/quad_to_bin/index.html @@ -29,42 +29,39 @@ @assert abs(objective_value(model) - (3 * (3.5 * 8/15) + 8/15)) < 1e-1 # src
      Running HiGHS 1.5.1 [date: 1970-01-01, git hash: 93f1876e4]
       Copyright (c) 2023 HiGHS under MIT licence terms
       Presolving model
      -383 rows, 224 cols, 1095 nonzeros
      -359 rows, 151 cols, 975 nonzeros
      -359 rows, 151 cols, 975 nonzeros
      +503 rows, 224 cols, 1453 nonzeros
      +408 rows, 193 cols, 1235 nonzeros
       
       Solving MIP model with:
      -   359 rows
      -   151 cols (27 binary, 0 integer, 0 implied int., 124 continuous)
      -   975 nonzeros
      +   408 rows
      +   193 cols (56 binary, 0 integer, 0 implied int., 137 continuous)
      +   1235 nonzeros
       
               Nodes      |    B&B Tree     |            Objective Bounds              |  Dynamic Constraints |       Work
            Proc. InQueue |  Leaves   Expl. | BestBound       BestSol              Gap |   Cuts   InLp Confl. | LpIters     Time
       
                0       0         0   0.00%   0               inf                  inf        0      0      0         0     0.0s
      -         0       0         0   0.00%   6.133333333     inf                  inf        0      0      2         9     0.0s
      - R       0       0         0   0.00%   6.133333333     6.160714286        0.44%       51     11      4        58     0.0s
      -
      -25.9% inactive integer columns, restarting
      +         0       0         0   0.00%   6.133333333     inf                  inf        0      0      4        87     0.0s
      + L       0       0         0   0.00%   6.133333333     6.133333333        0.00%      432     90     38       366     0.2s
       
       Solving report
         Status            Optimal
      -  Primal bound      6.16071428571
      -  Dual bound        6.16071428571
      +  Primal bound      6.13333333338
      +  Dual bound        6.13333333333
         Gap               0% (tolerance: 0.01%)
         Solution status   feasible
      -                    6.16071428571 (objective)
      +                    6.13333333338 (objective)
                           0 (bound viol.)
                           0 (int. viol.)
                           0 (row viol.)
      -  Timing            0.03 (total)
      +  Timing            0.20 (total)
                           0.00 (presolve)
                           0.00 (postsolve)
      -  Nodes             0
      -  LP iterations     406 (total)
      +  Nodes             1
      +  LP iterations     823 (total)
                           0 (strong br.)
      -                    59 (separation)
      -                    328 (heuristics)

      However, this might lead to some solver not supporting certain functionality like SCIP. In this case we need to:

      using SCIP
      Warning

      SCIP requires a non-standard installation procedure in windows. See SCIP.jl for more details.

      SOLVER = SCIP.Optimizer()
      +                    279 (separation)
      +                    457 (heuristics)

      However, this might lead to some solver not supporting certain functionality like SCIP. In this case we need to:

      using SCIP
      Warning

      SCIP requires a non-standard installation procedure in windows. See SCIP.jl for more details.

      SOLVER = SCIP.Optimizer()
       
       CACHED_SOLVER = MOI.Utilities.CachingOptimizer(
           MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}()), SOLVER)
      @@ -78,4 +75,4 @@
       Lower Constraints: 0
       Bilevel Model
       Solution method: BilevelJuMP.ProductMode{Float64}(1.0e-5, false, 0, nothing)
      -Solver name: QuadraticToBinary [SCIP]

      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 page was generated using Literate.jl.

      +Solver name: QuadraticToBinary [SCIP]

      Note that we used ()->Q_SOLVER instead of just Q_SOLVER because BilevelModel requires as constructor and not an instance of an object.


      This page was generated using Literate.jl.