jump-dev / HiGHS.jl

A Julia interface to the HiGHS solver
https://highs.dev
MIT License
103 stars 14 forks source link

Handle INFEASIBLE_POINT statuses #97

Closed jd-lara closed 2 years ago

jd-lara commented 2 years ago

For the attached MOF file HiGH prints the following log to the REPL:

julia> optimize!(m)
0, 150795.719209, 41, 0.015529, 0.000609, 388, 0.000000, 0.000000
1000, 144677.302916, 65, 0.110455, 0.000520, 285, 0.000000, 0.002797
1370, 144677.302624, 65, 0.155823, 0.000320, 254, 0.000000, 0.002797
ERROR:   QP solver claims optimality, but with num/sum/max primal(3/0.000319877/0.000142008) and dual(3/3319.88/3316.94) infeasibilities
Model   status      : Optimal
Simplex   iterations: 488
QP ASM    iterations: 1370
Objective value     :  1.4467730262e+05
HiGHS run time      :          0.16

However, the return status from JuMP is NO_SOLUTION.

The same problem in IPOPT has the following output:

his is Ipopt version 3.14.4, running with linear solver MUMPS 5.4.1.

Number of nonzeros in equality constraint Jacobian...:     2496
Number of nonzeros in inequality constraint Jacobian.:     3024
Number of nonzeros in Lagrangian Hessian.............:      120

Total number of variables............................:      984
                     variables with only lower bounds:        0
                variables with lower and upper bounds:      216
                     variables with only upper bounds:        0
Total number of equality constraints.................:      840
Total number of inequality constraints...............:     2160
        inequality constraints with only lower bounds:     1080
   inequality constraints with lower and upper bounds:        0
        inequality constraints with only upper bounds:     1080

iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
   0  3.8477488e+03 9.32e-01 5.87e+00  -1.0 0.00e+00    -  0.00e+00 0.00e+00   0
   1  1.7083487e+05 6.66e-16 5.63e+01  -1.0 6.63e-01    -  1.73e-02 1.00e+00h  1
   2  1.4738956e+05 9.99e-16 2.52e+01  -1.0 1.49e+00    -  2.92e-01 5.52e-01f  1
   3  1.4488590e+05 8.88e-16 1.88e+01  -1.0 7.12e-01    -  9.50e-01 2.56e-01f  1
   4  1.4244691e+05 2.66e-15 6.57e+00  -1.0 3.79e+00    -  9.72e-01 6.53e-01f  1
   5  1.4230740e+05 3.55e-15 1.00e-06  -1.0 3.70e+00    -  1.00e+00 1.00e+00f  1
   6  1.4165823e+05 5.33e-15 4.30e-03  -2.5 2.45e+00    -  8.81e-01 8.87e-01f  1
   7  1.4157997e+05 3.55e-15 1.87e-01  -2.5 2.52e-01    -  1.00e+00 6.13e-01f  1
   8  1.4153211e+05 5.33e-15 2.83e-08  -2.5 3.79e-02    -  1.00e+00 1.00e+00f  1
   9  1.4151379e+05 7.11e-15 2.48e-04  -3.8 4.05e-02    -  1.00e+00 9.96e-01f  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  10  1.4151276e+05 5.33e-15 1.84e-11  -5.7 4.86e-04    -  1.00e+00 1.00e+00f  1
  11  1.4151274e+05 3.55e-15 2.66e-14  -8.6 2.28e-05    -  1.00e+00 1.00e+00f  1

Number of Iterations....: 11

                                   (scaled)                 (unscaled)
Objective...............:   3.5378185780472641e+03    1.4151274312189055e+05
Dual infeasibility......:   2.6645352591003757e-14    1.0658141036401503e-12
Constraint violation....:   3.5527136788005009e-15    3.5527136788005009e-15
Variable bound violation:   9.7471085828473771e-09    9.7471085828473771e-09
Complementarity.........:   2.6310850719202676e-09    1.0524340287681070e-07
Overall NLP error.......:   2.6310850719202676e-09    1.0524340287681070e-07

Number of objective function evaluations             = 12
Number of objective gradient evaluations             = 12
Number of equality constraint evaluations            = 12
Number of inequality constraint evaluations          = 12
Number of equality constraint Jacobian evaluations   = 1
Number of inequality constraint Jacobian evaluations = 1
Number of Lagrangian Hessian evaluations             = 1
Total seconds in IPOPT                               = 0.330

EXIT: Optimal Solution Found.

and JuMP return the status that the primal status is FEASIBLE_POINT

odow commented 2 years ago

Ah very interesting:

julia> using JuMP, HiGHS

julia> model = read_from_file("/Users/Oscar/Downloads/failed_model.mof.json")
A JuMP Model
Minimization problem with:
Variables: 984
Objective function type: QuadExpr
`AffExpr`-in-`MathOptInterface.EqualTo{Float64}`: 840 constraints
`AffExpr`-in-`MathOptInterface.GreaterThan{Float64}`: 984 constraints
`AffExpr`-in-`MathOptInterface.LessThan{Float64}`: 984 constraints
`AffExpr`-in-`MathOptInterface.Interval{Float64}`: 96 constraints
`VariableRef`-in-`MathOptInterface.GreaterThan{Float64}`: 216 constraints
`VariableRef`-in-`MathOptInterface.LessThan{Float64}`: 216 constraints
Model mode: AUTOMATIC
CachingOptimizer state: NO_OPTIMIZER
Solver name: No optimizer attached.

julia> set_optimizer(model, HiGHS.Optimizer)

julia> optimize!(model)
0, 150795.719209, 41, 0.018099, 0.000609, 388, 0.000000, 0.000000
1000, 144677.302916, 65, 0.095258, 0.000520, 285, 0.000000, 0.002797
1370, 144677.302624, 65, 0.129061, 0.000320, 254, 0.000000, 0.002797
ERROR:   QP solver claims optimality, but with num/sum/max primal(3/0.000319877/0.000142008) and dual(3/3319.88/3316.94) infeasibilities
Model   status      : Optimal
Simplex   iterations: 488
QP ASM    iterations: 1370
Objective value     :  1.4467730262e+05
HiGHS run time      :          0.13

julia> solution_summary(model)
* Solver : HiGHS

* Status
  Termination status : OPTIMAL
  Primal status      : NO_SOLUTION
  Dual status        : NO_SOLUTION
  Message from the solver:
  "7"

* Candidate solution
  Objective bound      : 0.0

* Work counters
  Solve time (sec)   : 0.12938
  Simplex iterations : 488
  Barrier iterations : 0
odow commented 2 years ago

So HiGHS reports OPTIMAL, but the solution is an INFEASIBLE_POINT.

Here's the MPS file: fail.mps.txt

I'll report upstream.

julia> p = Highs_create()
Ptr{Nothing} @0x00007ffbe3931200

julia> Highs_readModel(p, "fail.mps")
0

julia> Highs_run(p)
0, 149528.772276, 32, 0.014367, 0.000267, 385, 0.000000, 0.000000
1000, 142765.317106, 56, 0.082363, 0.000178, 281, 0.000000, 0.006892
1366, 142765.317106, 56, 0.116675, 0.000178, 237, 0.000000, 0.006892
ERROR:   QP solver claims optimality, but with num/sum/max primal(2/0.000177869/8.89344e-05) and dual(2/3317.82/3316.94) infeasibilities
Model   status      : Optimal
Simplex   iterations: 504
QP ASM    iterations: 1366
Objective value     :  1.4276531711e+05
HiGHS run time      :          0.12
0

julia> Highs_getModelStatus(p)
7

julia> statusP = Ref{Cint}();

julia> Highs_getIntInfoValue(p, "primal_solution_status", statusP)
0

julia> statusP[]
1

julia> Highs_getIntInfoValue(p, "dual_solution_status", statusP)
0

julia> statusP[]
1

julia> Highs_destroy(p)
jd-lara commented 2 years ago

@odow what isn't clear to me is why the model in HiGHS is reported as infeasible when ipopt can solve it properly

odow commented 2 years ago

what isn't clear to me is why the model in HiGHS is reported as infeasible

A bug in the solver.

odow commented 2 years ago

I changed the title because we should handle the case here when the return is 1 (kHighsSolutionStatusInfeasible):

https://github.com/jump-dev/HiGHS.jl/blob/efddaca5768ca16adfa42f2ed0d692b75afbb8dd/src/MOI_wrapper.jl#L1580-L1583