The number of columns in A must be the same as the number of elements of f. i couldnt get this ,how can i solve it

59 views (last 30 days)
>> f=[65 73 63 57;67 70 65 58;68 72 69 55;67 75 70 59;71 69 75 57;69 71 66 59];
>> A=[1 1 1 1;1 1 1 1;1 1 1 1;1 1 1 1;1 1 1 1;1 1 1 1];
>> b=[1;1;1;1;1;1];
>> Aeq=[1 1 1 1 1 1 ;1 1 1 1 1 1 ;1 1 1 1 1 1 ;1 1 1 1 1 1];
>> beq=[1;1;1;1];
>> lb=[0;0;0;0;0;0];
>> ub=[1;1;1;1;1;1];
>> intcon=[1,2,3,4,5,6];
>> intlinprog(f,intcon,A,b,Aeq,beq,lb,ub)
Error using intlinprog (line 122)
The number of columns in A must be the same as the number of elements of f.

Answers (1)

Walter Roberson
Walter Roberson on 12 Feb 2016
"f can also be an array. Internally, intlinprog converts an array f to the vector f(:)"
So your 6 x 4 array for f, is treated as a 24 x 1 vector for f.
You A is also 6 x 4, but "A has size M-by-N, where M is the number of constraints and N = numel(f)". So your A would need to be something-by-24. You have 6 elements in b, so you have 6 constraints, so your A would have to be 6 x 24.
Likewise when Aeq is not empty, it has to be Meq x N where N is numel(f) and Meq is the number of equality constraints. Your beq is length 4 so you have 4 equality constraints, so your Aeq would need to be 4 x 24.

Categories

Find more on Linear Programming and Mixed-Integer Linear Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!