Before the first solve, define a parameter where you will store the objective values. For example,
param ObjVal {1..2};
Suppose that your objective function is named TotalCost, Then after the first solve, save the objective value with this command:
let ObjVal[1] := TotalCost;
After the second solve, save the value with this command:
let ObjVal[2] := TotalCost;
At any later point in your .run file, the difference between the two objective values is given by this AMPL expression:
abs(ObjVal[1] - ObjVal[2])
Of course, you should substitute the actual name of your objective function for "TotalCost" in this example. Also, you can use ObjVal[1] and ObjVal[2] in other expressions besides the one shown in the example above.
--
Robert Fourer
am...@googlegroups.com