intlinprog is returning noninteger values
2 次查看(过去 30 天)
显示 更早的评论
I have my code where DDD is a 35x60 matrix I'm trying to get integer values for w(26:60) but its giving me
w= -1.0000
0
-1.0000
1.0000
0
-0.6667
-0.2222
-1.0000
-0.6667
-1.0000
-0.5556
-1.0000
-0.6667
-1.0000
-1.0000
-0.3333
-1.0000
0.7778
0
-1.0000
-1.0000
-0.7778
-0.8890
-0.6667
-0.3333
-1.0000
-1.0000
-1.0000
-2.0000
-1.0000
-1.0000
0
-1.0000
-1.7778
-1.0000
-2.0000
-1.6667
0
1.0000
0
0
-1.0000
-1.0000
-2.0000
-2.0000
-2.0000
-2.0000
-1.0000
-2.0000
-3.0000
-1.6667
-2.0000
-2.0000
-1.2222
-2.0000
-2.0000
-3.0000
-2.0000
-2.3333
-15.0000
For my Code:
intcon= zeros(35,1);
for i= 1 : 35
intcon(i,1)=25+i;
end
D = [ DDD ; eye(25), zeros(25,35); -eye(25), zeros(25,35) ] ;
f= [zeros(25,1) ; g ; -1 ] ;
b=[zeros(34,1); [1-0.0001 ] ; ones(25,1); ones(25,1) ] ;
w = intlinprog(-f,intcon,D,b) ;
4 个评论
Taner Cokyasar
2016-7-14
Writing this just for future users: The intcon code you are using seems to be wrong. Intcon should be (1,35) for your problem. So all numbers should in the first row. The following code could solve this problem. As Matt mentioned, ub and lb are also necessary for particular bounds on variables.
intcon = 26:1:60;
Brendan Hamm
2016-7-15
@Taner For future users, it should be known that the intcon being a row or column vector does not matter. Internally, intlinprog uses:
intcon = intcon(:)
Maybe at some point in the past this was different, I am not sure, but this would mean future users using past versions :).
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear Programming and Mixed-Integer Linear Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!