MATLAB: Solve(Opti​misationPr​oblem), intlinprog and cplex disagree

cplexintlinprogMATLABoptimizationsolve

I am trying to run a MILP. I made an OptimisationProblem which I can run with Solve(OptimisationProblem). Teh answer this gives me is correct. However when I run the same probelm in cplex (for calculation speed inprovements) or just intlinprog , I get a different (incorrect) answer.
%% using solve and timing
tic
[sol,fval,exitflag,output]=solve(scheduleprob);
toc
%% converting the problem
SP=prob2struct(scheduleprob);
%% using intlinprog and timing
tic
[sol2,fval2, exitflag2, output2] = intlinprog(SP.f,SP.intcon,SP.Aineq,SP.bineq,...
SP.Aeq,SP.beq,SP.lb,SP.ub,SP.x0,SP.options);
toc
%% creating the ctype array
ctype(1:numel(SP.f))='C';
ctype(SP.intcon)='I';
%$ using cplex and timing
tic
[sol3,fval3, exitflag3, output3] = cplexmilp(SP.f, SP.Aineq, SP.bineq, ...
SP.Aeq, SP.beq,[], [], [], SP.lb, SP.ub, ctype, [], SP.options);
toc
fval,fval2,fval3
when I run this I get the following output:
LP: Optimal objective value is -33898.197234.
Cut Generation: Applied 19 implication cuts, 5 mir cuts,
13 Gomory cuts, 4 cover cuts,
and 4 flow cover cuts.
Lower bound is -31811.836555.
Heuristics: Found 1 solution using diving.
Upper bound is -25000.000000.
Relative gap is 27.25%.



Cut Generation: Applied 5 Gomory cuts,
8 implication cuts, and 1 flow cover cut.
Lower bound is -31789.993780.
Relative gap is 27.16%.
Branch and Bound:
nodes total num int integer relative
explored time (s) solution fval gap (%)

161 9.87 2 -2.773075e+04 1.277874e+01
441 11.88 3 -2.849219e+04 6.454425e+00
651 13.01 4 -2.859219e+04 1.618574e+00
860 13.52 4 -2.859219e+04 0.000000e+00
Optimal solution found.
Intlinprog stopped because the objective value is within a gap tolerance of the
optimal value, options.AbsoluteGapTolerance = 0 (the default value). The intcon
variables are integer within tolerance, options.IntegerTolerance = 1e-05 (the
default value).
Elapsed time is 13.978858 seconds.
LP: Optimal objective value is -33898.197234.
Cut Generation: Applied 19 implication cuts, 5 mir cuts,
13 Gomory cuts, 4 cover cuts,
and 4 flow cover cuts.
Lower bound is -31811.836555.
Heuristics: Found 1 solution using diving.
Upper bound is -25000.000000.
Relative gap is 27.25%.
Cut Generation: Applied 5 Gomory cuts,
8 implication cuts, and 1 flow cover cut.
Lower bound is -31789.993780.
Relative gap is 27.16%.
Branch and Bound:
nodes total num int integer relative
explored time (s) solution fval gap (%)
161 9.45 2 -2.773075e+04 1.277874e+01
441 11.40 3 -2.849219e+04 6.454425e+00
651 12.51 4 -2.859219e+04 1.618574e+00
860 13.05 4 -2.859219e+04 0.000000e+00
Optimal solution found.
Intlinprog stopped because the objective value is within a gap tolerance of the
optimal value, options.AbsoluteGapTolerance = 0 (the default value). The intcon
variables are integer within tolerance, options.IntegerTolerance = 1e-05 (the
default value).
Elapsed time is 13.083694 seconds.
Elapsed time is 0.740988 seconds.
fval =
3.5922e+03
fval2 =
-2.8592e+04
fval3 =
-2.8592e+04
the optimal solution for the problem should be 3592.2 so only the "solve" command got the right answer. Remarkable is that during calculation the solve command does show the value reached by the other two commands. Is there a step I am missing?

Best Answer

If scheduleprob contains an additive offset value f0 in the objective function, then solve() will account for it, but intlinprog will not,
and cplex may not (though that is probably a question for the cplex developers). Were the optimized variables different among the solvers as well? I expect not.