# \`HiGHS.jl\` gives strange results

**URL:** <https://discourse.julialang.org/t/highs-jl-gives-strange-results/112995>\
**Category:** Optimization (Mathematical)\
**Tags:** question, package, jump, optimization\
**Created:** [April 16, 2024, 7:33am UTC](https://discourse.julialang.org/t/highs-jl-gives-strange-results/112995 "2024-04-16T07:33:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![WuSiren](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wusiren/32/42529_2.png) [@WuSiren](https://discourse.julialang.org/u/WuSiren)\
**Post date:** [April 16, 2024, 7:33am UTC](https://discourse.julialang.org/t/highs-jl-gives-strange-results/112995/1 "2024-04-16T07:33:36Z")

</div>

```julia
using JuMP, HiGHS

## Case-1
M1 = Model(HiGHS.Optimizer)
@variable(M1, d[1:2])
g1 = @expression(M1, (1/100) * (d[1] - 1))
g2 = @expression(M1, (1/100) * (d[2] - 2))
@constraint(M1, 0 <= g1 <= 1)
@constraint(M1, 0 <= g2 <= 1)
@variable(M1, 0 <= x[1:2])
@objective(M1, Max, d' * x)
optimize!(M1)
value.(d), value.(x), objective_value(M1), termination_status(M1)
# RESULT:
# Running HiGHS 1.7.0 (git hash: 50670fd4c): Copyright (c) 2024 HiGHS under MIT licence terms
# Coefficient ranges:
# Matrix [1e-02, 1e-02]
# Cost [0e+00, 0e+00]
# Bound [0e+00, 0e+00]
# RHS [1e-02, 1e+00]
# Iteration, Runtime, ObjVal, NullspaceDim
# 0, 0.000000, 0.000000, 0
# lambda = -99999999999.998978
# Highs::returnFromRun: return_status = -1 != 0 = run_return_status For model_status_ = Not Set
# Model status : Not Set
# HiGHS run time : 0.01
# ([1.0, 2.0], [0.0, 2.0e7], 0.0, MathOptInterface.OTHER_ERROR)

## Case-2
M2 = Model(HiGHS.Optimizer)
@variable(M2, 0 <= d[1:2] <= 1)
@variable(M2, 0 <= x[1:2])
@objective(M2, Max, d' * x)
optimize!(M2)
value.(d), value.(x), objective_value(M2), termination_status(M2) 
# RESULT:
# Running HiGHS 1.7.0 (git hash: 50670fd4c): Copyright (c) 2024 HiGHS under MIT licence terms
# Coefficient ranges:
# Cost [0e+00, 0e+00]
# Bound [1e+00, 1e+00]
# Iteration, Runtime, ObjVal, NullspaceDim
# 0, 0.000999, 0.000000, 0
# 1, 0.001996, 0.000000, 0
# Model status : Optimal
# Objective value : 0.0000000000e+00
# HiGHS run time : 0.01
# ([0.0, 0.0], [0.0, 0.0], 0.0, MathOptInterface.OPTIMAL)

```

If `Case-1` reporting `OTHER_ERROR` is just because `M1` is an unbounded problem, `M2` is also unbounded in a similar fashion but the result of `Case-2` is misreported as `OPTIMAL`, although neither `value.(d)` nor `value.(x)` is an optimal solution as expected.

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [April 16, 2024, 8:48am UTC](https://discourse.julialang.org/t/highs-jl-gives-strange-results/112995/2 "2024-04-16T08:48:49Z")

</div>

> If `Case-1` reporting `OTHER_ERROR` is just because `M1` is an unbounded problem

Case 1 reports `OTHER_ERROR` because HiGHS cannot solve non-convex QPs.

You cannot use HiGHS to solve such problems. Try Gurobi instead.

> but the result of `Case-2` is misreported as `OPTIMAL` ,

Case 2 is a bug. HiGHS should report that it does not support solving non-convex QPs.

```julia
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.000216, 0.000000, 2
2, 0.000243, 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) : 2.83053e-04
  Simplex iterations : 0
  Barrier iterations : 0
  Node count : -1

```

I’ll open an issue: [kHighsModelStatusOptimal reported for non-convex QP · Issue #1727 · ERGO-Code/HiGHS · GitHub](https://github.com/ERGO-Code/HiGHS/issues/1727)

---

<div class="post-metadata">

**Author:** ![WuSiren](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wusiren/32/42529_2.png) [@WuSiren](https://discourse.julialang.org/u/WuSiren)\
**Post date:** [April 16, 2024, 2:04pm UTC](https://discourse.julialang.org/t/highs-jl-gives-strange-results/112995/3 "2024-04-16T14:04:24Z")

</div>

> [@odow](#):
>
> Case 1 reports `OTHER_ERROR` because HiGHS cannot solve non-convex QPs.
> 
> You cannot use HiGHS to solve such problems. Try Gurobi instead.

Is there any open-source solver that supports non-convex QPs?

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [April 16, 2024, 10:02pm UTC](https://discourse.julialang.org/t/highs-jl-gives-strange-results/112995/4 "2024-04-16T22:02:02Z")

</div>

- Ipopt.jl can find a local solution.
- You could try Alpine.jl
- You could try AmplNLWriter.jl with Couenne\_jll.jl

```Julia
using JuMP, AmplNLWriter, Couenne_jll
model = Model(() -> AmplNLWriter.Optimizer(Couenne_jll.amplexe))
@variable(model, 0 <= x <= 2)
@variable(model, 0 <= y <= 2)
@constraint(model, x + y <= 2)
@objective(model, Max, x * y)
optimize!(model)
solution_summary(model)

```
