upperobjstop

26 views
Skip to first unread message

Fabrizio Marinelli

unread,
Aug 26, 2025, 6:39:29 AM (13 days ago) Aug 26
to AMPL Modeling Language
Dear AMPL Team,

I would like to set the CPLEX 22.1.2 parameter upperobjstop in order to stop the branch-and-bound process as soon as a feasible solution with an objective value greater than a given threshold is found (in a maximization problem).

However, AMPL does not seem to recognize this parameter. Is there a correct way to pass upperobjstop to CPLEX from AMPL?

If it turns out that AMPL cannot set this parameter directly, could you suggest any workaround or alternative method to achieve the same effect?

Thank you very much,

best regards.

Fabrizio

Gleb Belov

unread,
Aug 26, 2025, 10:06:39 PM (12 days ago) Aug 26
to AMPL Modeling Language
Hi Fabrizio,

since release 20240823 our default cplex driver is the MP-based one, see https://dev.ampl.com/solvers/cplex/changes.html#id11. It does not yet support all the options of the legacy ASL driver (but it offers an extended modeling support, see the Modeling Guide from the same page).

While we shall add these options and release an update, you can switch to the legacy driver via `ampl: option solver cplexasl;`, or in Python: `ampl.solver(solver='cplexasl')`. With the default driver, you can use similar options `mip:gap`, `mip:gapabs`. Finally, adding a constraint in the model might work.

Complete setup:
AMPL: `option solver cplexasl, cplex_options 'upperobj 20000';`
Python: `ampl.solve(solver="cplex", cplex_options="mip:gapabs=5000")`

Best regards,
Gleb

Message has been deleted

Fabrizio Marinelli

unread,
Aug 27, 2025, 7:38:01 AM (12 days ago) Aug 27
to AMPL Modeling Language
Hi Gleb,
nice to hear from you, and thank you very much for the support and advice.
Definitely, I will use cplexasl, as the other workarounds don’t seem suitable in my case.
I tried adding a constraint like obj.fun <= threshold, and indeed, the branch & bound process becomes faster. However, as a side effect, the constraint cuts out the first feasible solution found by cplex primal heuristics for the original problem that are actually very good and quite bigger than the threshold...

all my best,
fabrizio

Gleb Belov

unread,
Aug 27, 2025, 8:09:36 PM (11 days ago) Aug 27
to AMPL Modeling Language
Hi Fabrizio,

good to hear from you as well!

As an idea, the constraint can be softened:

var obj_target_gap >=0;
s.t. ObjTarget: obj_target_gap >= 20000 - obj.fun;
minimize ObjTargetGap: obj_target_gap;

This might be the solution for solvers such as COPT and Xpress which don't have this parameter (although it could be emulated by callbacks). BTW Gurobi and Highs do have similar options (bestobjstop, objectivetarget).

Best regards,
Gleb

Gleb Belov

unread,
Aug 27, 2025, 9:06:23 PM (11 days ago) Aug 27
to AMPL Modeling Language
... I have to correct myself.

CplexASL has the option `upperobj[lim]` which sets the solver's CPX_PARAM_OBJULIM which, according to CPLEX docs, only works for simplex algorithms. Neither of our drivers has the `upperobjstop` (CPXPARAM_MIP_Limits_UpperObjStop). We shall add this to the new driver and release in the next days.

In the meantime, the above idea or `mipgaps[abs]` could help.

Thank you for bringing this up.

Gleb Belov

unread,
Aug 28, 2025, 7:37:46 AM (11 days ago) Aug 28
to AMPL Modeling Language
Hi Fabrizio,

you can download the update from https://portal.ampl.com/user/ampl/download/cplex.

The default cplex has the new options lim:upperobj, lim:upperobjstop, lim:uppercutoff. For any uncovered options, use tech:optionnativeread/write to handle CPLEX native parameter files.

By the way, the ASL driver has had the native parameter capability (options paramfileprm, dparam, iparam, sparam).

Best regards,
Gleb

Fabrizio Marinelli

unread,
Aug 29, 2025, 3:36:55 AM (10 days ago) Aug 29
to AMPL Modeling Language
thank you Gleb, 
you’re right, I should’ve thought of that!
Fabrizio

Fabrizio Marinelli

unread,
Aug 29, 2025, 3:37:57 AM (10 days ago) Aug 29
to AMPL Modeling Language
Hi Gleb,
Thank you again for your support!
best regards,
fabrizio

Reply all
Reply to author
Forward
0 new messages