intlinprog is returning noninteger values
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Taner Cokyasar
am 14 Jul. 2016
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
am 15 Jul. 2016
@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 :).
Antworten (0)
Siehe auch
Kategorien
Mehr zu Linear Programming and Mixed-Integer Linear Programming finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!