Comments (3)
@GiulioRomualdi That makes sense. I actually only had issues with the bound vectors; I somehow assumed that the same issue would exist with the matrices, so I made sure they would not go out of scope as well, but had not double checked. Thanks for clarifying! Also, thanks for writing this library, you probably saved me a couple of days of work.
from osqp-eigen.
Hi @joaospinto thanks for using osqp-eigen
When writing a class that encapsulates the use of this library in my codebase, I noticed that I had to store all matrices/vectors as private variables, otherwise some of the pointers would become stale (your library does not seem to be taking ownership of those matrices/vectors). Is this intended?
The library wants to be a simple wrapper to osqp
and so we try to reduce the memory allocation (matrices and vectors). However in the initialization phase (e.g. here) the Hessian matrix is saved inside the data
structure of osqp
.
osqp-eigen/include/OsqpEigen/Data.tpp
Line 35 in 7109a22
and here the memory is allocated and the Hessian matrix is copied
osqp-eigen/include/OsqpEigen/SparseMatrixHelper.tpp
Lines 34 to 53 in 7109a22
This is required by
osqp
itself. Indeed osqp
wants a pointer to a csc
struct when the first optimization problem is created.
On the other hand, when you set the gradient no memory allocation is performed and a pointer to the vector is passed to the osqp
library
osqp-eigen/include/OsqpEigen/Data.tpp
Lines 44 to 55 in 7109a22
So in simple terms:
- you do not need to save the matrices as private variables (dynamic memory allocation is performed by the
csc_spalloc
function) - you need to save the vectors as private variables because no memory allocation is performed.
On the light of this, it would be nice to have a simple example where I can try to replicate your problem.
from osqp-eigen.
from osqp-eigen.
Related Issues (20)
- ERROR in LDL_factor: Error in KKT matrix LDL factorization when computing the nonzero elements. The problem seems to be non-convex HOT 2
- problems compiling this library HOT 4
- Assert statement in SparseMatrixHelper.tpp HOT 2
- The createOsqpSparseMatrix does not correctly handle empty sparse matrix. HOT 5
- Compile error on Windows with vs2022 and vs2019 when compiling against osqp master branch (future osqp v1) HOT 8
- The possibility to handle huge matrix equation? HOT 4
- Using OSQP-Eigen with OSQP CUDA HOT 2
- have a solution for osqp 0.4.0? HOT 6
- error while loading shared libraries: libosqp.so HOT 3
- undefined reference to `OsqpEigen::Solver::Solver()',undefined reference to `OsqpEigen::Solver::settings() const' HOT 1
- I'm using osqp-eigen v0.7.0, wondering if Hessian Matrix is supporting only symmetric matrix, rather than upper triangular matrix. HOT 2
- Support for solution derivative functions HOT 1
- ..... HOT 1
- trouble building the library HOT 4
- different result in c++ and matlab HOT 3
- Get Unstable Answer When Solve a simple QP using Update Matrix Functions HOT 10
- When calling the setHessianMatrix and updateHessianMatrix functions, the compilation error HOT 4
- auxil.h no such file or directory HOT 4
- macos-latest CI float=ON failing since April 23
- Problems installing osqp-eigen HOT 29
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from osqp-eigen.