Incorrect objective function value reported

129 views
Skip to first unread message

Tony

unread,
Mar 18, 2015, 9:59:52 AM3/18/15
to am...@googlegroups.com
Dear AMPL google group,

I have an extremely simple model that I am solving using cplex. I am being informed that the objective is 2400, but when I display the objective function it is shown to be equal to 2500: 

CPLEX 12.6.1.0: optimal solution; objective 2400
0 dual simplex iterations (0 in phase I)
cost = 2500

I am not sure if this is an ampl or cplex issue. There is no constant term in my objective function. The correct value is 2500, the value reported by the display command. I can provide code if required.

Anthony

Robert Fourer

unread,
Mar 18, 2015, 10:30:15 AM3/18/15
to am...@googlegroups.com
We do not have any reports of an error like this using CPLEX 12.6.1, so please do send us the files that we would need to reproduce the problem. You can post them to this group, or if you do not want them to be public you can mail them to sup...@ampl.com.

Bob Fourer
am...@googlegroups.com

=======
Message has been deleted

Robert Fourer

unread,
May 18, 2015, 3:31:07 PM5/18/15
to am...@googlegroups.com, Tony
The cause of this discrepancy seems clear. Before the problem is sent to the solver, AMPL's presolve phase eliminates some variables:

Presolve eliminates 19 constraints and 48 variables.
Adjusted problem:
112 variables, all linear
52 constraints, all linear; 188 nonzeros
36 equality constraints
16 inequality constraints
1 linear objective; 12 nonzeros.

Certain variables are eliminated because presolve fixes them at nonzero values:

ampl: display {j in 1.._nvars: _var[j].astatus='pre'} (_varname[j],_var[j].lb,_var[j].ub);
: _varname[j] _var[j].lb _var[j].ub :=
...
73 "y['DR','B1',2,2]" 3919 3919
74 "y['DR','B1',2,3]" 7086 7086
79 "y['DR','B2',2,2]" 3410 3410
80 "y['DR','B2',2,3]" 1918 1918
85 "y['DR','B3',2,2]" 2986 2986
86 "y['DR','B3',2,3]" 2165 2165
...

This creates a nonzero constant term in the objective function that is being sent to the solver:

ampl: solexpand Cost;
minimize Cost:
32*v['Nuc',1,1] + 28.8*v['Nuc',2,2] + 3.2*v['Nuc',2,3] +
16*v['Coal',1,1] + 14.4*v['Coal',2,2] + 1.6*v['Coal',2,3] +
5*v['Gas',1,1] + 4.5*v['Gas',2,2] + 0.5*v['Gas',2,3] + 2*v['Oil',1,1]
+ 1.8*v['Oil',2,2] + 0.2*v['Oil',2,3] + 7524720;

The constant term equals the observed discrepancy in the objective (shown by default to 6 significant digits). Thus the reported optimal values of the variables are correct, being same regardless of the constant term, but the optimality message is failing to adjust the objective value to take the constant into effect. When you display Cost, AMPL plugs all of the variable values into the original objective function, so it shows the correct value.

This error seems to have been fixed in the latest build of CPLEX for AMPL:

ampl: shell "cplex -v";
AMPL/CPLEX 12.6.1.0 (Microsoft XP64, icl 10.1.029), driver(20150425), ASL(20150427)
Licensed to ...

ampl: model CapExMSMod.txt;
CPLEX 12.6.1.0: mipdisplay 2
CPLEX 12.6.1.0: optimal solution; objective 7524723.973
0 dual simplex iterations (0 in phase I)
ampl:

Bob Fourer
am...@googlegroups.com

=======

From: Tony [mailto:anthony.pa...@gmail.com]
Sent: Saturday, May 16, 2015 11:28 AM
To: am...@googlegroups.com
Cc: 4...@ampl.com
Subject: Re: [AMPL 10158] Incorrect objective function value reported

In the attached code, the objective function value reported by the solver is 0, whereas when I display the objective function through AMPL it turns out to be 7524720..

AMPLBug.png
CapExMSDat.txt
CapExMSMod.txt
Reply all
Reply to author
Forward
0 new messages