Fmincon requires way more memory than input variables
Mostrar comentarios más antiguos
I'm using fmincon to solve a very large problem (up to 20000 variables). My problem is, that Matlab runs out of memory after a certain number of iterations. My objective function is sum((x - d).^2), where d is a constant. I use linear equality and inequality constraints as sparse matrices/vectors. My input variables x0, A, b, Aeq, beq require 0.5 MB up to 1 MB, although A for example is of the size 52560x17520. The maximum number of iterations is set to 525600. The error message is
First-order Norm of
Iter F-count f(x) Feasibility optimality step
0 17521 0.000000e+00 2.188e+03 2.235e-07
1 35043 5.897884e+00 2.027e+03 1.207e-01 2.429e+00
2 52564 6.143605e+01 1.689e+03 3.174e-01 5.598e+00
Error using ldl
Requested 122641x122641 (18.3GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and
cause MATLAB to become unresponsive. See array size limit or preference panel for more information.
This brings me to a number of questions:
- Why does fmincon need such huge arrays when the inputs are way smaller? And why do they require so much memory? Can't fmincon handle sparse matrices?
- Why does this error occur after more than 50000 function calls and not at the beginning of the algorithm? Does this function add results to some intermediate variable, which grows with function calls? I also realized that every iteration step takes more time than the previous one, which suprises me.
- Why does Matlab call my function 17521 times per iteration? I use exactly 17521 variables, but the cost function is made to handle vectors. Why doesn't Matlab compute the cost function with the complete x vector as a whole?
I was using lsqlin up to that point, which worked perfectly (no problems with the memory, extremely fast computation). Now I need nonlinear constraints, this is why I want to try to use fmincon.
Thank you very much for your help!
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Solver Outputs and Iterative Display en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!