Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The possibility to handle huge matrix equation? #147

Open
Joviisaus opened this issue Sep 16, 2023 · 4 comments
Open

The possibility to handle huge matrix equation? #147

Joviisaus opened this issue Sep 16, 2023 · 4 comments

Comments

@Joviisaus
Copy link

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.

@S-Dafarra
Copy link
Collaborator

Hi @Joviisaus thanks for opening the issue. Do you have a minimum working example for us to reproduce the issue?

@Joviisaus
Copy link
Author

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.

@S-Dafarra
Copy link
Collaborator

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.

@Joviisaus
Copy link
Author

Thank you for your suggestion.I would further check my input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants