lanl-ansi / Alpine.jl

A Julia/JuMP-based Global Optimization Solver for Non-convex Programs
https://lanl-ansi.github.io/Alpine.jl/latest/
Other
244 stars 39 forks source link

Alpine+JuMP gives error for quadratic functions #177

Closed mzagorowska closed 2 years ago

mzagorowska commented 2 years ago

See: https://discourse.julialang.org/t/alpine-jump-gives-error-for-quadratic-functions/70321

In summary, if I change one nonlinear constraint slightly to have x[1]x[1] instead of x[1]x[6] I am getting an error on MOI.ScalarQuadraticFunction.

harshangrjn commented 2 years ago

@mzagorowska Interestingly, I just looked at this issue. This isn't an issue/bug in Alpine. Since you have created a quadratic monomial in x[1]*x[1], this automatically gets reformulated as x[1]^2 within Alpine. Once this is a quadratic function, you can use Gurobi as the underlying mip_solver and it runs without any issue. Although not the best, if you still prefer to use an open-source mip_solver, note that Cbc/HiGHS solver does not support quadratic functions. Instead, you will need to use Pavito.jl solver and then use Cbc/HiGHS and Ipopt as the underlying mip_solver and cont_solver, respectively. Similar to the way it is invoked here: https://github.com/lanl-ansi/Alpine.jl/blob/22c44020fe3c56c4e11bafaebf9c86b313da0714/test/runtests.jl#L35 I tested this and it works fine. Hence closing this issue. If you still have issues, please feel free to re-open this.