I'm doing some linear optimization on a matrix that takes up 16GB of memory using the spicy.optimize.linprog method. However, my computer only has 8GB of RAM. I already consider the option of simply getting more RAM but besides that what other thing could I do to allow the program to still run.
Asked
Active
Viewed 110 times
0
-
Swap is a possibility (albeit it is slow) - what OS are you running? – jrd1 Mar 21 '22 at 02:17
-
I have access to both a Mac and a Windows computer @jrd1, also what is "Swap"? – Minh Pham Mar 21 '22 at 02:18
-
Try this one for Windows: https://superuser.com/questions/793304/how-to-increase-swap-memory-in-windows . The Mac should do swap automatically. It is possible to modify it, though as indicated here: https://discussions.apple.com/thread/252429784 – jrd1 Mar 21 '22 at 02:22
-
One last option could be creating a sparse matrix from your original matrix, and then using a different library for linear programming: https://stackoverflow.com/questions/34821894/scipy-linear-programming-with-sparse-matrices – jrd1 Mar 21 '22 at 02:25
-
1Thanks! @jrd1, I'll check them out – Minh Pham Mar 21 '22 at 02:29
-
1Also worth noting: An EC2 instance with 32G of RAM costs less than $0.40 an hour. – Nick Bailey Mar 21 '22 at 02:40
-
This is actually a really intriguing options @NickBailey – Minh Pham Mar 21 '22 at 03:02
1 Answers
1
Make sure to use scipy.sparse
to store the matrix. Almost all LP matrices are very sparse.

Erwin Kalvelagen
- 15,677
- 2
- 14
- 39