why am I getting this linprog error ?

19 ビュー (過去 30 日間)
Aidy
Aidy 2013 年 11 月 8 日
回答済み: Jonathan LeSage 2013 年 11 月 8 日
Hi ,
I get the following error using linprog :
The number of columns in Aeq must be the same as the length of f.
anyway to overcome it?

回答 (1 件)

Jonathan LeSage
Jonathan LeSage 2013 年 11 月 8 日
You should check the dimensions of both your 'f' vector and your 'Aeq' matrix. Both of these values are multiplied with the vector to optimize, 'x', and accordingly, the dimensions must allow proper matrix multiplication.
First, check the length of 'f'
length(f)
As you know, the length of 'f' dictates the number of variables to optimize in vector 'x'. As a result, we need to make sure that the dimensions of 'Aeq' make sense too:
[m,n] = size(Aeq)
The value of 'm' gives use the number of rows in 'Aeq' which tells us how many equality constraint equations that we are enforcing on this linear program. Conversely, 'n' tells use the number of columns in 'Aeq' which indicates the size of 'x'. As a result, the number of columns of 'Aeq' and the length of 'f' must be equivalent (which is the error message that you're receiving).
Two potential corrections:
  • If 'm' equals the length of 'f', you may have transposed your 'Aeq' matrix. You could fix this by transposing your Aeq matrix (Aeq = Aeq').
  • Your equations might not be consistent, and you should write them out to ensure your equations make sense.
Hope this helps!

カテゴリ

Help Center および File ExchangeSolver Outputs and Iterative Display についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by