-
Notifications
You must be signed in to change notification settings - Fork 118
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
Restore compatibility with osqp version 0.6.0 #32
Conversation
@@ -32,7 +32,9 @@ bool OsqpEigen::Data::setHessianMatrix(const Eigen::SparseMatrix<T> &hessianMatr | |||
} | |||
|
|||
//set the hessian matrix | |||
if(!OsqpEigen::SparseMatrixHelper::createOsqpSparseMatrix(hessianMatrix, m_data->P)){ | |||
// osqp 0.6.0 required only the upper triangular part of the hessian matrix | |||
Eigen::SparseMatrix<T> hessianMatrixUpperTriangular = hessianMatrix.template triangularView<Eigen::Upper>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this method allocating memory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Could we move this to be a buffer in the class, or we can't because the method is templated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it allocates memory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to keep a copy of the hessian and iterate over the upper triangular non-zeros of the input hessian. In case an element is already present you can copy the value, otherwise you add it. The problem is if the saved hessian has more non-zeros than the input hessian.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is called only the first time.
Probably there is a way to avoid to allocate memory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In which sense "only the first time"? It is not called every time the hessian changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the function called every time the hessian changes is
osqp-eigen/include/OsqpEigen/Solver.tpp
Line 13 in bbd96ea
bool OsqpEigen::Solver::updateHessianMatrix(const Eigen::SparseCompressedBase<Derived> &hessianMatrix) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, sorry. Then it makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought as well it was called every time. So there are no problems I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, it is not easy to extract the upper triangular matrix from a CSC representation (representation used by osqp). Furthermore, the methods used to retrieve the outerIndexPtr
and the innerIndexPtr
are defined in Eigen::SparseCompressedBase
and the
Eigen::TriangularView
class does not inherit from Eigen::SparseCompressedBase
.
This is the reason why the following line is needed
Eigen::SparseMatrix<T> hessianMatrixUpperTriangular = hessianMatrix.template triangularView<Eigen::Upper>();
Some small suggestions (not directly related to this PR, to be honest):
|
cc @traversaro
Actually 0.3 is the current version of |
Upstream issue on this: osqp/osqp#195 .
Mhh, good to know. independentily on what 0.3 or 0.4 are compatible with, such as table would help. Anyhow, considering that |
I don't know if this is a good idea. Right now the On the other hand, when this PR will be merged the back-compatibility with a previous version of So to overcome possible issues, I would suggest to:
What do you think @traversaro @S-Dafarra? |
We can fix immediately the version of osqp-eigen in the superbuild, so that you are free to work as you prefer, and we update the osqp and osqp-eigen version when dust has setted . |
To be honest, I think that if the required version of osqp changes, it is better to at least bump the minor version. |
I'm updating the version from include(InstallBasicPackageFiles)
install_basic_package_files(${PROJECT_NAME}
VERSION ${${PROJECT_NAME}_VERSION}
- COMPATIBILITY AnyNewerVersion
+ COMPATIBILITY SameMinorVersion
VARS_PREFIX ${PROJECT_NAME}
NO_CHECK_REQUIRED_COMPONENTS_MACRO
CONFIG_TEMPLATE ${CMAKE_SOURCE_DIR}/cmake/OsqpEigenConfig.cmake.in) Unfortunately, this option is available only from |
You can just vendor |
Note that you will need to copy just the |
1688022
to
2369d49
Compare
- upload a custom version of BasicConfigVersion-SameMinorVersion.cmake.in and WriteBasicConfigVersionFile.cmake to guarantee compatibility with cmake < 3.11 - compatibility ensured only if the required version is 0.5.*
Done in ac2a551 |
This PR is currently blocked by robotology/robotology-superbuild#260 |
This PR restore the compatibility with
osqp
version 0.6.0.When this PR is merged, it will be not possible to use osqp 0.5.0 along with
osqp-eigen
. Indeed osqp/osqp@78d1135 changesosqp_setup()
interface. This problem should be taken into account since a custom version ofosqp
may be used by internal projects (e.g. https://github.com/robotology-dependencies/osqp/tree/fix-lf-problems)See #31