Open Joviisaus opened 11 months ago
Hi @Joviisaus thanks for opening the issue. Do you have a minimum working example for us to reproduce the issue?
Thank you for your reply. This is what written in my code.
int Vertex_num = 3499;
int k = 5;
Eigen::VectorXd z_crowd(Vertex_num,1); //Value is given in another function.
Eigen::VectorXd b_crowd(k,1);//Value is given in another function.
Eigen::SparseMatrix<double> W_N; //This is a sparse matrix in the size of 3499*3499, whose value is given in another function.
OsqpEigen::Solver solver;
solver.data()->setNumberOfVariables(Vertex_num);
solver.data()->setNumberOfConstraints(k);
if (!solver.data()->setHessianMatrix(W_N))
{
std::cout<<"error in QPsolver"<<endl;
return vOmega;
}
if (!solver.data()->setGradient(z_crowd))
{
std::cout<<"error in QPsolver"<<endl;
return vOmega;
}
if (!solver.data()->setLinearConstraintsMatrix(a))
{
std::cout<<"error in QPsolver"<<endl;
return vOmega;
}
if (!solver.data()->setLowerBound(b_crowd))
{
std::cout<<"error in QPsolver"<<endl;
return vOmega;
}
if (!solver.data()->setUpperBound(b_crowd))
{
std::cout<<"error in QPsolver"<<endl;
return vOmega;
}
Eigen::VectorXd QPSolution = solver.getSolution();
The error was thrown while running solver.getSolution()
method as Thread 1: EXC_BAD_ACCESS (code=1, address=0xc8)
.Although I'm still not check your source code , I do have suffered this error before because the matrix W_N
is so huge that it can only stored by Eigen::SparseMatrix<double>
.It is because its zero element is over 99% .If your method need to compute the reverse matrix of W_N
,which is unlikely a sparse matrix ,the memory can easily overflow and causes this error.This is my consideration.
Thanks for the further info. Still, we would not be able to reproduce the problem with only the code you provided.
Memory-wise, a matrix of 4000x4000 should not be so problematic to store considering that it should be in the order of 128MB. Even its inversion should not explode in memory. At most, it could just take some time.
The error seems to indicate that some of the inputs are not properly allocated. I would suggest to double check that all the inputs are well formed.
Thank you for your suggestion.I would further check my input.
I'm trying to solve the problem that contains the huge matrix.the Hessian Matrix could be around 4000 *4000.The solver terminated because of EXC_BAD_ACCESS.I wonder if it is my coding error or the limitation of this lib.