sparse marix and linprog
4 ビュー (過去 30 日間)
古いコメントを表示
Hi I want to solve linear programming model in MATLAB with linprog function. I need to create eye matrix in 994840x994840. I want to create it with sparse(eye(994840)), but I got "out of memory" error. Is it any way to solve my problem?
Thank you.
0 件のコメント
回答 (1 件)
Matt J
2014 年 11 月 20 日
speye(994840)
5 件のコメント
John D'Errico
2014 年 11 月 20 日
ones(994840) will be a FULL matrix. There are no zeros at all. So use of a sparse form to store it will be less efficient. It will require more memory to store than a simple full matrix, since sparse is only efficient when the matrix is actually sparse.
Anyway, you don't want to create ones(994840), a matrix that would require
994840*994840*8 = 7917653004800
bytes to store, so roughly 8 terabytes of memory there!
Matt J
2014 年 11 月 20 日
編集済み: Matt J
2014 年 11 月 20 日
fatema,
As John says, trying to explicitly create a matrix as large and memory-consuming as ones(994840) is too brute force. You need to look to more indirect ways. If you show us the problem in more detail, we might be able to give better advice.
As an example, if you're doing this because some subset of your inequality constraints looks like
[ones(N), S]*x<=b
where S is an NxM sparse or small matrix and N=994840, then you could introduce an additional unknown variable q and impose the equality constraint,
q=[ones(1,N), zeros(1,M)]*x
Now the inequality constraints can be replaced by
[ones(N,1), sparse(N,N), S]*[q;x]<=b
But notice that modified constraint matrix
A=[ones(N,1), sparse(N,N), S]
is now much more sparse and manageable.
参考
カテゴリ
Help Center および File Exchange で Nonlinear Optimization についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!