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

9 vues (au cours des 30 derniers jours)
Pepijn Baart
Pepijn Baart le 24 Juil 2019
Commenté : Pepijn Baart le 24 Juil 2019
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?
  4 commentaires
Pepijn Baart
Pepijn Baart le 24 Juil 2019
Yes it does. I have the same problem when I use other optimisation problems. It is an maximisation problem is there maybe something in the prob2struct command that does something weird for that? making the optimisation function (SP.f) negative does not fix this.
Pepijn Baart
Pepijn Baart le 24 Juil 2019
switching the problem to a minimisation problem (and inverting the objective) gives the negative version of the answer for the solve function (-3.5922e+03), as expected, but the same answer as before for the other two options (-2.8592e+04) which is wierd.

Connectez-vous pour commenter.

Réponse acceptée

Matt J
Matt J le 24 Juil 2019
Modifié(e) : Matt J le 24 Juil 2019
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.
  8 commentaires
Matt J
Matt J le 24 Juil 2019
Modifié(e) : Matt J le 24 Juil 2019
I think it would be worth posting a new question, because it looks like a worthwhile topic for wider discussion. It is strange to me that a command for this doesn't already exist.
Pepijn Baart
Pepijn Baart le 24 Juil 2019
Thank you for your help. I have created a New question.

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by