Closed kyearb closed 3 years ago
Is a private member of
Eigen::Matrix<TScalar, Eigen::Dynamic, Eigen::Dynamic>;
really an issue? Could you please post more details. The solver itself does not allocate memory for the Hessian.
The issue is when the State
struct is instantiated in Function.Eval()
. Regardless of the solver used (or the order specified when calling Function.Eval()
), a hessian of size (dim,dim) is initialized.
Line 24-29 in function.h:
State(const int dim, const int order)
: dim(dim),
order(order),
x(vector_t::Zero(dim)),
gradient(vector_t::Zero(dim)),
hessian(matrix_t::Zero(dim, dim)) {}
Using methods that don't require a hessian (such as conjugate gradient descent) still tries to allocate memory for a hessian. This makes it impossible to use for solving problems with a large number of variables.
Since some of these methods are used specifically to require less memory, it would be nice if the hessians are not allocated by default.