Skip to content

Commit

Permalink
Merge pull request #83 from robotology/set_bounds
Browse files Browse the repository at this point in the history
Implement Data::setBounds() method
  • Loading branch information
GiulioRomualdi authored Mar 9, 2021
2 parents 64cfeb6 + 118a420 commit 9b00910
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
12 changes: 12 additions & 0 deletions include/OsqpEigen/Data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,18 @@ namespace OsqpEigen
*/
bool setUpperBound(Eigen::Ref<Eigen::Matrix<c_float, Eigen::Dynamic, 1>> upperBoundVector);

/**
* Set the array for upper and lower bounds (size m).
* @param lowerBound is the lower bound constraint.
* @param upperBound is the upper bound constraint.
* @note the elements of the upperBound and lowerBound are not copied inside the library.
* The user has to guarantee that the lifetime of the object passed is the same of the
* OsqpEigen object.
* @return true/false in case of success/failure.
*/
bool setBounds(Eigen::Ref<Eigen::Matrix<c_float, Eigen::Dynamic, 1>> lowerBound,
Eigen::Ref<Eigen::Matrix<c_float, Eigen::Dynamic, 1>> upperBound);

/**
* Get the OSQPData struct.
* @return a const point to the OSQPData struct.
Expand Down
11 changes: 11 additions & 0 deletions src/Data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,14 @@ bool OsqpEigen::Data::setUpperBound(Eigen::Ref<Eigen::Matrix<c_float, Eigen::Dyn
m_data->u = upperBound.data();
return true;
}

bool OsqpEigen::Data::setBounds(Eigen::Ref<Eigen::Matrix<c_float, Eigen::Dynamic, 1>> lowerBound,
Eigen::Ref<Eigen::Matrix<c_float, Eigen::Dynamic, 1>> upperBound)
{
bool ok = true;

ok = ok && this->setLowerBound(lowerBound);
ok = ok && this->setUpperBound(upperBound);

return ok;
}

0 comments on commit 9b00910

Please sign in to comment.