OsqpEigen::Solver class

Solver class is a wrapper of the OSQP OSQPWorkspace struct.

Constructors, destructors, conversion operators

Solver()
Constructor.

Public functions

auto initSolver() -> bool
Initialize the solver with the actual initial data and settings.
auto isInitialized() -> bool
Check if the solver is initialized.
void clearSolver()
Deallocate memory.
auto clearSolverVariables() -> bool
Set to zero all the solver variables.
auto solve() -> bool
Solve the QP optimization problem.
auto solveProblem() -> OsqpEigen::ErrorExitFlag
Solve the QP optimization problem.
auto getStatus() const -> OsqpEigen::Status
Get the status of the solver.
auto getObjValue() const -> const c_float
Get the primal objective value.
auto getSolution() -> const Eigen::Matrix<c_float, -1, 1>&
Get the optimization problem solution.
auto getDualSolution() -> const Eigen::Matrix<c_float, -1, 1>&
Get the dual optimization problem solution.
auto updateGradient(const Eigen::Ref<const Eigen::Matrix<c_float, Eigen::Dynamic, 1>>& gradient) -> bool
Update the linear part of the cost function (Gradient).
auto updateLowerBound(const Eigen::Ref<const Eigen::Matrix<c_float, Eigen::Dynamic, 1>>& lowerBound) -> bool
Update the lower bounds limit (size m).
auto updateUpperBound(const Eigen::Ref<const Eigen::Matrix<c_float, Eigen::Dynamic, 1>>& upperBound) -> bool
Update the upper bounds limit (size m).
auto updateBounds(const Eigen::Ref<const Eigen::Matrix<c_float, Eigen::Dynamic, 1>>& lowerBound, const Eigen::Ref<const Eigen::Matrix<c_float, Eigen::Dynamic, 1>>& upperBound) -> bool
Update both upper and lower bounds (size m).
template<typename Derived>
auto updateHessianMatrix(const Eigen::SparseCompressedBase<Derived>& hessianMatrix) -> bool
Update the quadratic part of the cost function (Hessian).
template<typename Derived>
auto updateLinearConstraintsMatrix(const Eigen::SparseCompressedBase<Derived>& linearConstraintsMatrix) -> bool
Update the linear constraints matrix (A)
template<typename T, int n, int m>
auto setWarmStart(const Eigen::Matrix<T, n, 1>& primalVariable, const Eigen::Matrix<T, m, 1>& dualVariable) -> bool
Set the entire.
template<typename T, int n>
auto setPrimalVariable(const Eigen::Matrix<T, n, 1>& primalVariable) -> bool
template<typename T, int m>
auto setDualVariable(const Eigen::Matrix<T, m, 1>& dualVariable) -> bool
template<typename T, int n>
auto getPrimalVariable(Eigen::Matrix<T, n, 1>& primalVariable) -> bool
template<typename T, int m>
auto getDualVariable(Eigen::Matrix<T, m, 1>& dualVariable) -> bool
auto settings() const -> const std::unique_ptr<OsqpEigen::Settings>&
Get the solver settings pointer.
auto data() const -> const std::unique_ptr<OsqpEigen::Data>&
Get the pointer to the solver initial data.
auto workspace() const -> const std::unique_ptr<OSQPWorkspace, std::function<void(OSQPWorkspace*)>>&
Get the pointer to the OSQP workspace.

Function documentation

bool OsqpEigen::Solver::initSolver()

Initialize the solver with the actual initial data and settings.

Returns true/false in case of success/failure.

bool OsqpEigen::Solver::isInitialized()

Check if the solver is initialized.

Returns true if the solver is initialized.

bool OsqpEigen::Solver::clearSolverVariables()

Set to zero all the solver variables.

Returns true/false in case of success/failure.

bool OsqpEigen::Solver::solve()

Solve the QP optimization problem.

Returns true/false in case of success/failure.

OsqpEigen::ErrorExitFlag OsqpEigen::Solver::solveProblem()

Solve the QP optimization problem.

Returns the error exit flag

OsqpEigen::Status OsqpEigen::Solver::getStatus() const

Get the status of the solver.

Returns The inner solver status

const c_float OsqpEigen::Solver::getObjValue() const

Get the primal objective value.

Returns The primal objective value

const Eigen::Matrix<c_float, -1, 1>& OsqpEigen::Solver::getSolution()

Get the optimization problem solution.

Returns an Eigen::Vector containing the optimization result.

const Eigen::Matrix<c_float, -1, 1>& OsqpEigen::Solver::getDualSolution()

Get the dual optimization problem solution.

Returns an Eigen::Vector containing the optimization result.

bool OsqpEigen::Solver::updateGradient(const Eigen::Ref<const Eigen::Matrix<c_float, Eigen::Dynamic, 1>>& gradient)

Update the linear part of the cost function (Gradient).

Parameters
gradient is the Gradient vector.
Returns true/false in case of success/failure.

bool OsqpEigen::Solver::updateLowerBound(const Eigen::Ref<const Eigen::Matrix<c_float, Eigen::Dynamic, 1>>& lowerBound)

Update the lower bounds limit (size m).

Parameters
lowerBound is the lower bound constraint vector.
Returns true/false in case of success/failure.

bool OsqpEigen::Solver::updateUpperBound(const Eigen::Ref<const Eigen::Matrix<c_float, Eigen::Dynamic, 1>>& upperBound)

Update the upper bounds limit (size m).

Parameters
upperBound is the upper bound constraint vector.
Returns true/false in case of success/failure.

bool OsqpEigen::Solver::updateBounds(const Eigen::Ref<const Eigen::Matrix<c_float, Eigen::Dynamic, 1>>& lowerBound, const Eigen::Ref<const Eigen::Matrix<c_float, Eigen::Dynamic, 1>>& upperBound)

Update both upper and lower bounds (size m).

Parameters
lowerBound is the lower bound constraint vector;
upperBound is the upper bound constraint vector.
Returns true/false in case of success/failure.

template<typename Derived>
bool OsqpEigen::Solver::updateHessianMatrix(const Eigen::SparseCompressedBase<Derived>& hessianMatrix)

Update the quadratic part of the cost function (Hessian).

Returns true/false in case of success/failure.

It is assumed to be a symmetric matrix.

template<typename Derived>
bool OsqpEigen::Solver::updateLinearConstraintsMatrix(const Eigen::SparseCompressedBase<Derived>& linearConstraintsMatrix)

Update the linear constraints matrix (A)

Parameters
linearConstraintsMatrix is the linear constraint matrix A
Returns true/false in case of success/failure.

template<typename T, int n, int m>
bool OsqpEigen::Solver::setWarmStart(const Eigen::Matrix<T, n, 1>& primalVariable, const Eigen::Matrix<T, m, 1>& dualVariable)

Set the entire.

Returns true/false in case of success/failure.

const std::unique_ptr<OsqpEigen::Settings>& OsqpEigen::Solver::settings() const

Get the solver settings pointer.

Returns the pointer to Settings object.

const std::unique_ptr<OsqpEigen::Data>& OsqpEigen::Solver::data() const

Get the pointer to the solver initial data.

Returns the pointer to Data object.

const std::unique_ptr<OSQPWorkspace, std::function<void(OSQPWorkspace*)>>& OsqpEigen::Solver::workspace() const

Get the pointer to the OSQP workspace.

Returns the pointer to Workspace object.