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..