sparse marix and linprog

4 Ansichten (letzte 30 Tage)
fatema saba
fatema saba am 20 Nov. 2014
Bearbeitet: Matt J am 20 Nov. 2014
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.

Antworten (1)

Matt J
Matt J am 20 Nov. 2014
speye(994840)
  5 Kommentare
John D'Errico
John D'Errico am 20 Nov. 2014
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
Matt J am 20 Nov. 2014
Bearbeitet: Matt J am 20 Nov. 2014
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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Nonlinear Optimization 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!

Translated by