Epigraph
Convex Optimization in C++
Public Member Functions | Friends | List of all members
cvx::OptimizationProblem Class Reference

Public Member Functions

Scalar addVariable (const std::string &name)
 Creates and returns a variable. More...
 
VectorX addVariable (const std::string &name, size_t rows)
 Creates and returns a vector of variables. More...
 
MatrixX addVariable (const std::string &name, size_t rows, size_t cols)
 Creates and returns a matrix of variables. More...
 
void addConstraint (const Constraint &constraint)
 Add a single constraint to the problem. found. More...
 
void addConstraint (const std::vector< Constraint > &constraints)
 Add multiple constraints to the problem. More...
 
void addCostTerm (const Scalar &term)
 Add a cost term to the problem's cost function. This has to be a scalar. More...
 
void getVariableValue (const std::string &name, double &var)
 Get the value of a scalar variable. More...
 
void getVariableValue (const std::string &name, Eigen::VectorXd &var)
 Get the value of a vector variable. More...
 
void getVariableValue (const std::string &name, Eigen::MatrixXd &var)
 Get the value of a matrix variable. More...
 
void getVariable (const std::string &name, Scalar &var)
 Get a scalar variable that exists in the problem. More...
 
void getVariable (const std::string &name, VectorX &var)
 Get a vector variable that exists in the problem. More...
 
void getVariable (const std::string &name, MatrixX &var)
 Get a matrix variable that exists in the problem. More...
 
double getOptimalValue () const
 Returns the evaluated cost function. Only call this after the problem has been solved. More...
 
size_t getNumVariables () const
 Returns the number of used variables in the problem. More...
 

Friends

std::ostream & operator<< (std::ostream &os, const OptimizationProblem &socp)
 

Member Function Documentation

◆ addConstraint() [1/2]

void cvx::OptimizationProblem::addConstraint ( const Constraint constraint)

Add a single constraint to the problem. found.

Parameters
constraintThe constraint created by equalTo(), lessThan(), greaterThan() or box()

◆ addConstraint() [2/2]

void cvx::OptimizationProblem::addConstraint ( const std::vector< Constraint > &  constraints)

Add multiple constraints to the problem.

Parameters
constraintThe constraint created by equalTo(), lessThan(), greaterThan() or box()

◆ addCostTerm()

void cvx::OptimizationProblem::addCostTerm ( const Scalar term)

Add a cost term to the problem's cost function. This has to be a scalar.

Parameters
termA scalar cost term

◆ addVariable() [1/3]

Scalar cvx::OptimizationProblem::addVariable ( const std::string &  name)

Creates and returns a variable.

Parameters
nameThe name of the variable
Returns
Scalar The variable

◆ addVariable() [2/3]

VectorX cvx::OptimizationProblem::addVariable ( const std::string &  name,
size_t  rows 
)

Creates and returns a vector of variables.

Parameters
nameThe name of the variable
rowsThe number of elements in the vector
Returns
VectorX The vector of variables

◆ addVariable() [3/3]

MatrixX cvx::OptimizationProblem::addVariable ( const std::string &  name,
size_t  rows,
size_t  cols 
)

Creates and returns a matrix of variables.

Parameters
nameThe name of the variable
rowsThe number of rows of the matrix
colsThe number of columns in the matrix
Returns
MatrixX The matrix of variables

◆ getNumVariables()

size_t cvx::OptimizationProblem::getNumVariables ( ) const

Returns the number of used variables in the problem.

Returns
size_t The number of variables

◆ getOptimalValue()

double cvx::OptimizationProblem::getOptimalValue ( ) const

Returns the evaluated cost function. Only call this after the problem has been solved.

Note
This value may differ from the optimal value reported by the solver.
Returns
double

◆ getVariable() [1/3]

void cvx::OptimizationProblem::getVariable ( const std::string &  name,
MatrixX &  var 
)

Get a matrix variable that exists in the problem.

Parameters
nameThe name of the variable
varThe retured matrix variable

◆ getVariable() [2/3]

void cvx::OptimizationProblem::getVariable ( const std::string &  name,
Scalar var 
)

Get a scalar variable that exists in the problem.

Parameters
nameThe name of the variable
varThe retured scalar variable

◆ getVariable() [3/3]

void cvx::OptimizationProblem::getVariable ( const std::string &  name,
VectorX &  var 
)

Get a vector variable that exists in the problem.

Parameters
nameThe name of the variable
varThe retured vector variable

◆ getVariableValue() [1/3]

void cvx::OptimizationProblem::getVariableValue ( const std::string &  name,
double &  var 
)

Get the value of a scalar variable.

Parameters
nameThe name of the variable
varThe value stored in the variable

◆ getVariableValue() [2/3]

void cvx::OptimizationProblem::getVariableValue ( const std::string &  name,
Eigen::MatrixXd &  var 
)

Get the value of a matrix variable.

Parameters
nameThe name of the variable
varThe value stored in the variable

◆ getVariableValue() [3/3]

void cvx::OptimizationProblem::getVariableValue ( const std::string &  name,
Eigen::VectorXd &  var 
)

Get the value of a vector variable.

Parameters
nameThe name of the variable
varThe value stored in the variable

The documentation for this class was generated from the following file: