ERGO-Code / HiGHS

Linear optimization software
MIT License
851 stars 164 forks source link

kHighsModelStatusOptimal reported for non-convex QP #1727

Open odow opened 2 months ago

odow commented 2 months ago

Solving Max x * y returns "Optimal" instead of declaring the QP to be non-convex. See the JuMP example:

julia> using JuMP, HiGHS

julia> model = Model(HiGHS.Optimizer)
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: EMPTY_OPTIMIZER
Solver name: HiGHS

julia> @variable(model, x)
x

julia> @variable(model, y)
y

julia> @objective(model, Max, x * y)
x*y

julia> optimize!(model)
Running HiGHS 1.7.0 (git hash: 50670fd4c): Copyright (c) 2024 HiGHS under MIT licence terms
Coefficient ranges:
  Cost   [0e+00, 0e+00]
  Bound  [0e+00, 0e+00]
Iteration, Runtime, ObjVal, NullspaceDim
0, 0.000214, 0.000000, 2
2, 0.000252, 0.000000, 2
Model   status      : Optimal
Objective value     :  0.0000000000e+00
HiGHS run time      :          0.00

julia> solution_summary(model)
* Solver : HiGHS

* Status
  Result count       : 1
  Termination status : OPTIMAL
  Message from the solver:
  "kHighsModelStatusOptimal"

* Candidate solution (result #1)
  Primal status      : FEASIBLE_POINT
  Dual status        : FEASIBLE_POINT
  Objective value    : 0.00000e+00
  Objective bound    : 0.00000e+00
  Relative gap       : Inf
  Dual objective value : 0.00000e+00

* Work counters
  Solve time (sec)   : 3.03478e-04
  Simplex iterations : 0
  Barrier iterations : 0
  Node count         : -1

As well as the C calls:

julia> using HiGHS

julia> model = Highs_create()
Ptr{Nothing} @0x00007fab448a6c00

julia> Highs_addCol(model, 0.0, -Inf, Inf, 0, C_NULL, C_NULL)
Running HiGHS 1.7.0 (git hash: 50670fd4c): Copyright (c) 2024 HiGHS under MIT licence terms
0

julia> Highs_addCol(model, 0.0, -Inf, Inf, 0, C_NULL, C_NULL)
0

julia> Highs_changeObjectiveSense(model, kHighsObjSenseMaximize)
0

julia> Highs_passHessian(
           model,
           2,
           1,
           kHighsHessianFormatTriangular,
           Cint[0, 1, 1],
           Cint[1],
           [1.0],
       )
0

julia> Highs_run(model)
Coefficient ranges:
  Cost   [0e+00, 0e+00]
  Bound  [0e+00, 0e+00]
Iteration, Runtime, ObjVal, NullspaceDim
0, 0.000229, 0.000000, 2
2, 0.000256, 0.000000, 2
Model   status      : Optimal
Objective value     :  0.0000000000e+00
HiGHS run time      :          0.00
0

julia> Highs_getModelStatus(model)
7

Originally reported in https://discourse.julialang.org/t/highs-jl-gives-strange-results/112995 x-ref https://github.com/jump-dev/HiGHS.jl/issues/210

feldmeier commented 2 months ago

This might be a side effect I didn't anticipate of a recent improvement I made for unconstrained QPs. I'll check