Foundations of Bilevel Programming: Example Chapter 5.1, Page 127

This example is from the book Foundations of Bilevel Programming by Stephan Dempe, Chapter 5.1, Page 127. url

Model of the problem

First level

\[\min x^2 + y,\\ \notag s.t.\\ -x-y\leq 0,\\\]

Second level

\[\min x,\\ \notag s.t.\\ x \geq 0,\\\]

using BilevelJuMP
using Ipopt

model = BilevelModel(Ipopt.Optimizer; mode = BilevelJuMP.ProductMode(1e-9))
An Abstract JuMP Model
Feasibility problem with:
Variables: 0
Upper Constraints: 0
Lower Constraints: 0
Bilevel Model
Solution method: BilevelJuMP.ProductMode{Float64}(1.0e-9, false, 0, nothing)
Solver name: Ipopt

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

Upper level variables

@variable(Upper(model), y, start = 0)

#Lower level variables
@variable(Lower(model), x, start = 0)

$ x $

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

Upper level objecive function

@objective(Upper(model), Min, x^2 + y)

$ x^2 + y $

Upper level constraints

@constraint(Upper(model), u1, -x - y <= 0)

\[ -y - x \leq 0 \]

Followed by the objective and constraints of the lower problem:

Lower objective function

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

$ x $

Lower constraints

@constraint(Lower(model), l1, x >= 0)

\[ x \geq 0 \]

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

optimize!(model)
┌ Warning: primal_var_dual_quad_slack field is deprecated, use primal_var_in_quad_obj_to_dual_slack_var instead
└ @ Dualization ~/.julia/packages/Dualization/ihzlf/src/structures.jl:268
┌ Warning: primal_parameter field is deprecated, use primal_parameter_to_dual_parameter instead
└ @ Dualization ~/.julia/packages/Dualization/ihzlf/src/structures.jl:265
This is Ipopt version 3.14.4, running with linear solver MUMPS 5.4.1.

Number of nonzeros in equality constraint Jacobian...:        1
Number of nonzeros in inequality constraint Jacobian.:        5
Number of nonzeros in Lagrangian Hessian.............:        2

Total number of variables............................:        3
                     variables with only lower bounds:        1
                variables with lower and upper bounds:        0
                     variables with only upper bounds:        0
Total number of equality constraints.................:        1
Total number of inequality constraints...............:        3
        inequality constraints with only lower bounds:        1
   inequality constraints with lower and upper bounds:        0
        inequality constraints with only upper bounds:        2

iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
   0  0.0000000e+00 9.90e-01 7.96e-01  -1.0 0.00e+00    -  0.00e+00 0.00e+00   0
   1 -8.0026319e-03 3.76e-02 9.32e+01  -1.7 9.90e-01    -  1.01e-02 9.62e-01f  1
   2  1.9551208e-02 1.63e-02 4.04e+01  -1.7 5.00e-02    -  1.00e+00 5.67e-01h  1
   3  1.5311322e-02 6.75e-03 1.67e+01  -1.7 1.86e-02    -  1.00e+00 5.86e-01h  1
   4  1.9929116e-02 2.42e-03 6.02e+00  -1.7 7.23e-03    -  1.00e+00 6.41e-01h  1
   5  1.9255373e-02 1.08e-03 1.27e+01  -1.7 2.92e-03    -  1.00e+00 5.53e-01h  1
   6  1.9988285e-02 4.33e-04 2.61e+01  -1.7 1.22e-03    -  1.00e+00 6.01e-01h  1
   7  1.9875360e-02 1.82e-04 6.76e+01  -1.7 4.98e-04    -  1.00e+00 5.79e-01h  1
   8  1.9998012e-02 7.49e-05 1.58e+02  -1.7 2.08e-04    -  1.00e+00 5.88e-01h  1
   9  1.9978696e-02 3.11e-05 3.87e+02  -1.7 8.55e-05    -  1.00e+00 5.85e-01h  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  10  1.9989176e-02 2.20e-05 1.59e+03  -1.7 3.57e-05    -  1.00e+00 2.93e-01f  2
  11  1.9999846e-02 4.33e-06 8.31e+02  -1.7 2.20e-05    -  1.00e+00 8.03e-01h  1
  12  1.9999125e-02 3.31e-06 1.07e+04  -1.7 6.09e-06    -  1.00e+00 2.36e-01f  2
  13  1.9999606e-02 5.48e-07 4.62e+03  -1.7 3.31e-06    -  1.00e+00 8.34e-01h  1
  14  1.9999797e-02 4.29e-07 8.05e+04  -1.7 8.82e-07    -  1.00e+00 2.17e-01f  2
  15  1.9999994e-02 4.50e-08 2.08e+04  -1.7 4.29e-07    -  1.00e+00 8.95e-01h  1
  16  1.9999976e-02 3.42e-08 5.22e+05  -1.7 1.03e-07    -  1.00e+00 2.40e-01f  2
  17  1.9999984e-02 0.00e+00 3.38e-02  -1.7 3.42e-08    -  1.00e+00 1.00e+00h  1
  18 -5.5153716e-09 0.00e+00 8.30e-07  -8.6 2.00e-02    -  1.00e+00 1.00e+00f  1
  19 -9.6089960e-09 0.00e+00 1.86e-01  -8.6 4.09e-09    -  9.96e-01 1.00e+00h  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  20 -1.7826027e-08 0.00e+00 3.23e-09  -8.6 8.22e-09    -  1.00e+00 1.00e+00f  1

Number of Iterations....: 20

                                   (scaled)                 (unscaled)
Objective...............:  -1.7826027345370235e-08   -1.7826027345370235e-08
Dual infeasibility......:   3.2303548462337760e-09    3.2303548462337760e-09
Constraint violation....:   0.0000000000000000e+00    0.0000000000000000e+00
Variable bound violation:   0.0000000000000000e+00    0.0000000000000000e+00
Complementarity.........:   4.2055517639287297e-09    4.2055517639287297e-09
Overall NLP error.......:   4.2055517639287297e-09    4.2055517639287297e-09


Number of objective function evaluations             = 25
Number of objective gradient evaluations             = 21
Number of equality constraint evaluations            = 25
Number of inequality constraint evaluations          = 25
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.008

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

This page was generated using Literate.jl.