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

2 views (last 30 days)
sebastian marin quiceno on 26 Nov 2022
Commented: Mark Stone on 27 Nov 2022
% 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 CommentsShowHide 9 older comments
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.

### Categories

Find more on Choose a Solver in Help Center and File Exchange

R2022b

### Community Treasure Hunt

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

Start Hunting!