cplex and gurobi differ for LP

177 views
Skip to first unread message

John Mitchell

unread,
Oct 24, 2021, 8:58:34 PM10/24/21
to am...@googlegroups.com, John Mitchell
Hi,

I have an AMPL linear program where CPLEX and GUROBI give different optimal values. The model file is attached, the data file can be found at

http://homepages.rpi.edu/~mitchj/matp4700/wfp/wfp.dat

The problem seems to be with the constraint cons11. The constraint is active in the cplex solution, but satisfied with a positive slack in the gurobi solution. If I comment out cons11 then cplex returns the same solution as gurobi. I am confident the gurobi solution is correct: it agrees with that obtained by a different model file for the same problem.

This is a course assignment and the result first showed up in the version of AMPL you provided for the course. I also had the same discrepancy when I submitted the job to the NEOS server. Here are the outputs returned from the NEOS server with the 2 solvers, with no options specified:

=====================
You are using the solver gurobi_ampl.

%% COMMENTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Checking ampl.mod for gurobi_options...
Executing AMPL.
processing data.
processing commands.
Executing on prod-exec-7.neos-server.org

Presolve eliminates 266 constraints and 374 variables.
Adjusted problem:
2061 variables, all linear
1244 constraints, all linear; 6813 nonzeros
1102 equality constraints
142 inequality constraints
1 linear objective; 1 nonzero.

Gurobi 9.1.1: threads=4
Gurobi 9.1.1: optimal solution; objective 0.9547767264
760 simplex iterations
=====================

=====================
You are using the solver cplexamp.

%% COMMENTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Checking ampl.mod for cplex_options...
Executing AMPL.
processing data.
processing commands.
Executing on prod-exec-7.neos-server.org

Presolve eliminates 266 constraints and 374 variables.
Adjusted problem:
2061 variables, all linear
1244 constraints, all linear; 6813 nonzeros
1102 equality constraints
142 inequality constraints
1 linear objective; 1 nonzero.

CPLEX 20.1.0.0: threads=4
CPLEX 20.1.0.0: optimal solution; objective 0.9520810777
1219 dual simplex iterations (1 in phase I)
=====================

Thanks,

—John

----
John E. Mitchell
mit...@rpi.edu http://www.rpi.edu/~mitchj
ph:518-276-6915 fax:518-276-4824
Professor and Graduate Program Director
Department of Mathematical Sciences
Amos Eaton 325
Rensselaer (RPI)
110 Eighth St
Troy, NY 12180 USA

dtt_wfp.mod

AMPL Google Group

unread,
Oct 25, 2021, 6:15:59 PM10/25/21
to AMPL Modeling Language, mit...@rpi.edu
It appears that this is an issue with the optimality tolerance. Here is what I found:

In CPLEX, setting optimality=1e-6 (the default) gives optimal value 0.9520810777, but setting optimality=1e-7 (a tighter tolerance) gives 0.9547767264:

ampl: model dtt_wfp.mod;
ampl: data wfp.dat;
ampl: option solver cplex;
ampl: option cplex_options 'optimality 1e-6';
ampl: solve;
CPLEX 20.1.0.0: optimality 1e-6

CPLEX 20.1.0.0: optimal solution; objective 0.9520810777
1219 dual simplex iterations (1 in phase I)

ampl: reset;
ampl: model dtt_wfp.mod;
ampl: data wfp.dat;
ampl: option cplex_options 'optimality 1e-7';
ampl: solve;
CPLEX 20.1.0.0: optimality 1e-7
CPLEX 20.1.0.0: optimal solution; objective 0.9547767264
1246 dual simplex iterations (14 in phase I)

Returning to the default settings, solving with CPLEX and then with Gurobi (using CPLEX's optimal basis as a start) causes Gurobi to also declare 0.9520810777 to be optimal. But then setting opttol=1e-7 causes Gurobi to find a solution with optimal value 0.9547767264 instead:

ampl: model dtt_wfp.mod data wfp.dat
ampl: option solver cplex;
ampl: option cplex_options '';
ampl: solve;

CPLEX 20.1.0.0: optimal solution; objective 0.9520810777
1219 dual simplex iterations (1 in phase I)

ampl: option solver gurobi;
ampl: option gurobi_options '';
ampl: solve;
Gurobi 9.1.2: optimal solution; objective 0.9520810777

ampl: option gurobi_options 'opttol=1e-7';
ampl: solve;
Gurobi 9.1.2: opttol=1e-7
Gurobi 9.1.2: optimal solution; objective 0.9547767264
31 simplex iterations

Further investigation points to cons11 just as you suspected. when CPLEX finds the solution that has optimal value 0.9520810777, the slack on constraint cons11 is nonbasic with reduced cost 3.05486e-07, which would be favorable for a maximization problem but which is ignored because it's less than the default tolerance 1e-06. Gurobi would also find this basic solution to be optimal under the default tolerance, but Gurobi doesn't see this solution because it happens to take a different iteration path.


--
Robert Fourer
am...@googlegroups.com
{#HS:1674030274-106815#}

John Mitchell

unread,
Oct 25, 2021, 8:47:33 PM10/25/21
to AMPL Google Group, John Mitchell
Thanks for investigating this, your answer makes sense to me.

—John
Reply all
Reply to author
Forward
0 new messages