jump-dev / Xpress.jl

A Julia interface to the FICO Xpress Optimization suite
https://www.fico.com/en/products/fico-xpress-optimization
65 stars 30 forks source link

Detection of non-linear/non-convex problem #274

Open trulsf opened 2 months ago

trulsf commented 2 months ago

The current implementation calls a different optimization routine depending on internal classification schemes

    if model.has_nlp_constraints
        @checked Lib.XPRSnlpoptimize(model.inner, model.solve_method)
    elseif is_mip(model)
        @checked Lib.XPRSmipoptimize(model.inner, model.solve_method)
    else
        @checked Lib.XPRSlpoptimize(model.inner, model.solve_method)
    end

This does not seem to work properly for non-convex quadratic problems which are not set as having nonlinear constraints and thus failing when calling XPRSlpoptimize. Here is a small example that fails:

using Xpress

m = Model(Xpress.Optimizer)
@variable(m, x >= 0)
@variable(m, y >= 0)
@constraint(m, x + y + x*y <= 5)
@objective(m, Max, x + y)
optimize!(m)

Instead of relying on an internal classification scheme would it not be better to let the choice of algorithm be left for Xpress using the more general XPRSoptimize function? The type of optimization used can then be queried afterwards using the XPRS_OPTIMIZETYPEUSED-attribute if this is needed before solution retrieval.

odow commented 2 months ago

Is this on the latest tagged version or the latest master?

odow commented 2 months ago

Ah it's https://github.com/jump-dev/Xpress.jl/blob/60ae1dd4971cd5cda76d214deaf93aa4c12c3d95/src/MOI/MOI_wrapper.jl#L2910-L2916

odow commented 2 months ago

I think the issue was that https://github.com/jump-dev/Xpress.jl/blob/60ae1dd4971cd5cda76d214deaf93aa4c12c3d95/src/Lib/xprs.jl#L479-L482 and some users of Xpress.jl are still stuck on quite outdated versions of Xpress.

trulsf commented 2 months ago

That is a pretty old version of Xpress to support. But is it not possible to have code that checks the version of Xpress available and adjusts accordingly? With the current implementation we do not get access to the capabilities of the global solver for nonconvex quadratic problems (nor MIQCQPs where the quadratic part defines a non-convex region). Alternatively, having some control mechanism to activate the global solver when calling optimize!.

odow commented 2 months ago

But is it not possible to have code that checks the version of Xpress available and adjusts accordingly?

Yeah, we can probably do that. Especially now that we have CI for old and new versions.

That is a pretty old version of Xpress to support

I won't name and shame the customer...