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

조회 수: 2(최근 30일)
sebastian marin quiceno 2022년 11월 26일
댓글: Mark Stone 2022년 11월 27일
% 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표시숨기기 이전 댓글 수: 9
Mark Stone 2022년 11월 27일
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.

댓글을 달려면 로그인하십시오.

### 범주

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!

Translated by