intlinprog is returning noninteger values

조회 수: 4 (최근 30일)
Standardtrickyness
Standardtrickyness 2015년 8월 31일
댓글: Brendan Hamm 2016년 7월 15일
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
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
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 CenterFile Exchange에서 Problem-Based Optimization Setup에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by