Clear Filters
Clear Filters

The integer linear programming solver does not give me the expected results

2 views (last 30 days)
% A is a matrix N*N of ones and zeros
% B is a matrix N*1 of ones and zeros
N=14 ;
x = optimvar('x',N,1,"Type",'integer','LowerBound',0,'UpperBound',1);
opp = sum(x);
res1=x(7,1)==0;
res2=x(8,1)==0;
p = optimproblem("ObjectiveSense","minimize");
p.Objective = opp;
p.Constraints.Xk = A*x>=B;
p.Constraints.Xx = res1;
p.Constraints.Xc = res2;
Sol = solve(p,"Solver","intlinprog");
%i want to know if my syntax is wrong or what is the problem with the code,
%matrices A and B are saved in my workspace
  10 Comments
Torsten
Torsten on 27 Nov 2022
Edited: Torsten on 27 Nov 2022
According to IEEE articles, the values of the vector x that give a solution are: 2.6 and 9. But instead with my code I get 2, 10 and 13.
Then evaluate your cost function and your constraints at the IEEE solution and see if the cost function value is really smaller than the one you got from intlinprog and if the constraints are satisfied.
Mark Stone
Mark Stone on 27 Nov 2022
Following up on the comment by @Torsten , it is quite common that the optimal solution of a binary or integer Linear Programming problem is not unique. So as @Torsten wrote, you need to compare objective (cost function) values. If two different solutions both have the same objective value, but only one of them is deemed "acceptable", then the model is inadequate, and you need to chage the objective function and/ot the constraints. Many binary or integer Linear Programming problems have a hughe amount of symmetry, meaning any reshuffling among the symmetric entities, produces the same objective value. That might very well be the case here. intlibnprog especially, benfits in solution speed from symmetry breaking constraints - for instance, fi you have interchageable (identical) assets that can be placed in various locations, a symmetry breaing oonstraint could be that the lower the number asset, the "better" the location in terms of contribution to objective. That cuts off many optimal solutions, but does not degrade the optimal objective value. Some solvers, such as FIC Xpress "prefer" not to have symmetry brealking constraints, but intlinprog almost always does, and it could bethe difference between solivng in a minute or taking weeks, months or years. On the other hand, your problem is tiny, and you could brute force enumaerate and evaluate objective and constraint satisfaction for all 2^14 = 4096 points in short order. So no matter what you do on symmetry breaking, intlinprog shoudl sokve it very fast. If n is 30+, it might be a differrent story.

Sign in to comment.

Answers (0)

Categories

Find more on Linear Programming and Mixed-Integer Linear Programming in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!