Princeton Handbook of Test Problems: Test 9.3.2

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.

Model of the problem First level

\[\min (x-5)^2+(2y+1)^2,\\ \notag s.t.\\ x \geq 0,\\ y \geq 0,\\\]

Second level

\[\min (y-1)^2-1.5xy,\\ \notag s.t.\\ -3x+y \leq -3,\\ x-0.5y \leq 4,\\ x+y \leq 7,\\\]

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), x)

#Lower level variables
@variable(Lower(model), y)

$ y $

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

Upper level objecive function

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

$ x^2 + 4 y^2 - 10 x + 4 y + 26 $

Upper level constraints

@constraint(Upper(model), x >= 0)
@constraint(Upper(model), y >= 0)

\[ y \geq 0 \]

Followed by the objective and constraints of the lower problem:

Lower objective function

@objective(Lower(model), Min, (y - 1)^2 - 1.5 * x * y)

$ y^2 - 1.5 x\times y - 2 y + 1 $

Lower constraints

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

\[ x + y \leq 7 \]

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

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...:        5
Number of nonzeros in inequality constraint Jacobian.:       23
Number of nonzeros in Lagrangian Hessian.............:        8

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

iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
   0  2.6000000e+01 3.00e+00 2.03e+00  -1.0 0.00e+00    -  0.00e+00 0.00e+00   0
   1  2.5970934e+01 2.99e+00 1.92e+00  -1.0 2.17e+00    -  7.65e-03 1.41e-02h  1
   2  2.5353850e+01 2.17e+00 1.01e+01  -1.0 3.94e+00    -  1.33e-02 2.70e-01f  1
   3  2.5521131e+01 1.91e+00 8.94e+00  -1.0 2.39e+00    -  9.65e-02 1.16e-01f  1
   4  2.0612528e+01 1.01e+00 8.62e+00  -1.0 7.07e+00    -  4.96e-02 4.14e-01f  1
   5  1.8258605e+01 6.79e-01 1.33e+01  -1.0 9.79e+00    -  2.23e-02 8.45e-02f  1
   6  1.9557922e+01 6.77e-01 1.98e+01  -1.0 1.66e+00   0.0 9.21e-01 3.41e-01h  1
   7  1.6559716e+01 1.02e+00 3.49e+01  -1.0 3.48e+00    -  3.20e-02 7.11e-01f  1
   8  1.6371238e+01 1.27e+00 1.50e+02  -1.0 5.87e+00    -  1.00e+00 5.43e-02h  1
   9  1.7026711e+01 2.86e-01 9.93e+01  -1.0 6.03e-01    -  1.00e+00 7.12e-01h  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  10  1.7095238e+01 7.08e-02 3.69e+02  -1.0 1.70e-01    -  1.00e+00 5.64e-01h  1
  11  1.7104203e+01 9.74e-03 9.01e+02  -1.0 5.55e-02    -  1.00e+00 5.84e-01h  1
  12  1.7090622e+01 8.85e-03 2.15e+03  -1.0 6.28e-02    -  1.00e+00 5.87e-01h  1
  13  1.7090274e+01 1.69e-03 5.24e+03  -1.0 1.44e-02    -  1.00e+00 5.86e-01h  1
  14  1.7088167e+01 1.49e-03 1.26e+04  -1.0 1.07e-02    -  1.00e+00 5.86e-01h  1
  15  1.7088012e+01 2.87e-04 3.04e+04  -1.0 2.49e-03    -  1.00e+00 5.87e-01h  1
  16  1.7087724e+01 2.56e-04 7.29e+04  -1.0 1.83e-03    -  1.00e+00 5.88e-01h  1
  17  1.7087598e+01 4.63e-05 1.72e+05  -1.0 4.34e-04    -  1.00e+00 5.91e-01h  1
  18  1.7087578e+01 4.53e-05 6.86e+05  -1.0 3.14e-04    -  1.00e+00 2.99e-01f  2
  19  1.7087900e+01 1.33e-05 2.94e+05  -1.0 2.82e-04    -  1.00e+00 8.33e-01h  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  20  1.7087606e+01 6.65e-06 3.48e+06  -1.0 9.53e-04    -  1.00e+00 2.63e-01f  2
  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.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 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

Number of Iterations....: 33

                                   (scaled)                 (unscaled)
Objective...............:   1.6999999980907578e+01    1.6999999980907578e+01
Dual infeasibility......:   8.9958831495096092e-09    8.9958831495096092e-09
Constraint violation....:   2.2204460492503131e-16    2.2204460492503131e-16
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
Number of objective gradient evaluations             = 34
Number of equality constraint evaluations            = 38
Number of inequality constraint evaluations          = 38
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.015

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

This page was generated using Literate.jl.