class
#include <ScsEigen/MathematicalProgram.h>
MathematicalProgram Contents
MathematicalProgram is a class that describes an optimization problem. Please use if when you want to define an optimization problem.
This simple example shows you how to use the MathematicalProgram class
#include <ScsEigen/MathematicalProgram.h> ... // Initialize the mathematical programming problem ScsEigen::MathematicalProgram mp; // Add a quadratic cost mp.addQuadraticCost( std::make_shared<ScsEigen::QuadraticCost>(H, "quadratic cost")); // Add linear constraint mp.addLinearConstraint( std::make_shared<ScsEigen::LinearConstraint>(A, lowerBound, upperBound), "linear constraint"));
Public types
-
template<class T>using dictionary = std::unordered_map<std::string_view, std::shared_ptr<T>>
- dictionary used to store cost and constraints.
Constructors, destructors, conversion operators
- MathematicalProgram()
- Constructor.
- ~MathematicalProgram()
- Destructor.
Public functions
- void setNumberOfVariables(unsigned int variables)
- Set the number of variables.
- auto numberOfVariables() const -> unsigned int
- Get the number of variables.
- auto addLinearCost(std::shared_ptr<LinearCost> cost, std::string_view name) -> bool
- Set the linear cost.
- auto getLinearCost(std::string_view name) const -> std::weak_ptr<LinearCost>
- Get the linear cost.
- auto getLinearCosts() const -> const dictionary<LinearCost>&
- Get all the linear costs stored the in the MathematicalProgram class.
- auto addQuadraticCost(std::shared_ptr<QuadraticCost> cost, std::string_view name) -> bool
- Set the quadratic cost.
- auto getQuadraticCost(std::string_view name) const -> std::weak_ptr<QuadraticCost>
- Get the quadratic cost.
- auto getQuadraticCosts() const -> const dictionary<QuadraticCost>&
- Get all the quadratic costs stored the in the MathematicalProgram class.
- auto addLinearConstraint(std::shared_ptr<LinearConstraint> constraint, std::string_view name) -> bool
- Set the linear constraint.
- auto getLinearConstraint(std::string_view name) const -> std::weak_ptr<LinearConstraint>
- Get the linear constraint.
- auto getLinearConstraints() const -> const dictionary<LinearConstraint>&
- Get all the linear constraints stored the in the MathematicalProgram class.
- auto addQuadraticConstraint(std::shared_ptr<QuadraticConstraint> constraint, std::string_view name) -> bool
- Set the quadratic constraint.
- auto getQuadraticConstraint(std::string_view name) const -> std::weak_ptr<QuadraticConstraint>
- Get the quadratic constraint.
- auto getQuadraticConstraints() const -> const dictionary<QuadraticConstraint>&
- Get all the quadratic constraints stored the in the MathematicalProgram class.
Function documentation
bool ScsEigen:: MathematicalProgram:: addLinearCost(std::shared_ptr<LinearCost> cost,
std::string_view name)
Set the linear cost.
Parameters | |
---|---|
cost | a shared pointer to the cost. |
name | the name of the cost. |
std::weak_ptr<LinearCost> ScsEigen:: MathematicalProgram:: getLinearCost(std::string_view name) const
Get the linear cost.
Parameters | |
---|---|
name | name of the cost. |
Returns | a weak_ptr to the cost. |
bool ScsEigen:: MathematicalProgram:: addQuadraticCost(std::shared_ptr<QuadraticCost> cost,
std::string_view name)
Set the quadratic cost.
Parameters | |
---|---|
cost | a shared pointer to the cost. |
name | the name of the cost. |
std::weak_ptr<QuadraticCost> ScsEigen:: MathematicalProgram:: getQuadraticCost(std::string_view name) const
Get the quadratic cost.
Parameters | |
---|---|
name | name of the cost. |
Returns | a weak_ptr to the cost. |
bool ScsEigen:: MathematicalProgram:: addLinearConstraint(std::shared_ptr<LinearConstraint> constraint,
std::string_view name)
Set the linear constraint.
Parameters | |
---|---|
constraint | a shared pointer to the constraint. |
name | the name of the constraint. |
std::weak_ptr<LinearConstraint> ScsEigen:: MathematicalProgram:: getLinearConstraint(std::string_view name) const
Get the linear constraint.
Parameters | |
---|---|
name | name of the constraint. |
Returns | a weak_ptr to the constraint. |
bool ScsEigen:: MathematicalProgram:: addQuadraticConstraint(std::shared_ptr<QuadraticConstraint> constraint,
std::string_view name)
Set the quadratic constraint.
Parameters | |
---|---|
constraint | a shared pointer to the constraint. |
name | the name of the constraint. |
std::weak_ptr<QuadraticConstraint> ScsEigen:: MathematicalProgram:: getQuadraticConstraint(std::string_view name) const
Get the quadratic constraint.
Parameters | |
---|---|
name | name of the constraint. |
Returns | a weak_ptr to the constraint. |