Closed GiulioRomualdi closed 3 years ago
Just to understand, what is the output if you add no constraints at all?
Just to understand, what is the output if you add no constraints at all?
[OsqpEigen::Solver::initSolver] Some data are not set.
Ok this sounds like a logical problem then. That should be easy to solve then. https://github.com/robotology/osqp-eigen/blob/9b0091038cf0fb9099a5d6c55820d6e5846034a7/src/Data.cpp#L88-L97
should become
return m_isNumberOfVariablesSet &&
m_isNumberOfConstraintsSet &&
m_isHessianMatrixSet &&
m_isGradientSet &&
(m_data->m ==0 || m_isLinearConstraintsMatrixSet ) &&
m_isLowerBoundSet &&
m_isUpperBoundSet;
right?
I don't know if it's so simple (We should investigate the side effects)
In any case, I think that it does not make sense to require the constraint matrix to be set if there are no constraints. If something else breaks, we shall fix it as well :grin:
Could you add the unconstrained problem as a test case?
I think that it does not make sense to require the constraint matrix to be set if there are no constraints
I agree
Related issue https://github.com/oxfordcontrol/osqp/issues/295
Related issue oxfordcontrol/osqp#295
Ah, nice! So if it is also a limitation of osqp
, the solution you proposed in the OP seems the way to go then.
This issue shows how to set
osqp-eigen
to solve an unconstrained optimization problemWe now want to solve the following optimization problem
The solution of the problem is
x = [0 0]
osqp-eigen
can be used to solve the problem as followsInitialize the variables. Please notice that the
constraintMatrix
size is0 x 2
(i.e. number of constraints x number of unknowns)Now you can initialize the problem as usual
You can finally solve the problem
Here the entire example
This is the
CMakeLists.txt
that you can use to run the exampleThe fact that the user should set the constraint matrix and the bounds even if the problem is unconstrained is counterintuitive.
cc @S-Dafarra @traversaro @lrapetti