An edge in the graph connects between vertex u
and vertex v
.
The edge also holds a list of cost and constraints associated with the continuous variables.
#include <drake/geometry/optimization/graph_of_convex_sets.h>
Public Member Functions | |
~Edge () | |
EdgeId | id () const |
Returns the unique identifier associated with this Edge. More... | |
const std::string & | name () const |
Returns the string name associated with this edge. More... | |
const Vertex & | u () const |
Returns a const reference to the "left" Vertex that this edge connects to. More... | |
Vertex & | u () |
Returns a mutable reference to the "left" Vertex that this edge connects to. More... | |
const Vertex & | v () const |
Returns a const reference to the "right" Vertex that this edge connects to. More... | |
Vertex & | v () |
Returns a mutable reference to the "right" Vertex that this edge connects to. More... | |
const symbolic::Variable & | phi () const |
Returns the binary variable associated with this edge. More... | |
const VectorX< symbolic::Variable > & | xu () const |
Returns the continuous decision variables associated with vertex u . More... | |
const VectorX< symbolic::Variable > & | xv () const |
Returns the continuous decision variables associated with vertex v . More... | |
std::pair< symbolic::Variable, solvers::Binding< solvers::Cost > > | AddCost (const symbolic::Expression &e) |
Adds a cost to this edge, described by a symbolic::Expression e containing only elements of xu() and xv() as variables. More... | |
std::pair< symbolic::Variable, solvers::Binding< solvers::Cost > > | AddCost (const solvers::Binding< solvers::Cost > &binding) |
Adds a cost to this edge. More... | |
solvers::Binding< solvers::Constraint > | AddConstraint (const symbolic::Formula &f) |
Adds a constraint to this edge, described by a symbolic::Formula f containing only elements of xu() and xv() as variables. More... | |
solvers::Binding< solvers::Constraint > | AddConstraint (const solvers::Binding< solvers::Constraint > &binding) |
Adds a constraint to this edge. More... | |
void | AddPhiConstraint (bool phi_value) |
Adds a constraint on the binary variable associated with this edge. More... | |
void | ClearPhiConstraints () |
Removes any constraints added with AddPhiConstraint. More... | |
const std::vector< solvers::Binding< solvers::Cost > > & | GetCosts () const |
Returns all costs on this edge. More... | |
const std::vector< solvers::Binding< solvers::Constraint > > & | GetConstraints () const |
Returns all constraints on this edge. More... | |
double | GetSolutionCost (const solvers::MathematicalProgramResult &result) const |
Returns the sum of the costs associated with this edge in a solvers::MathematicalProgramResult. More... | |
Eigen::VectorXd | GetSolutionPhiXu (const solvers::MathematicalProgramResult &result) const |
Returns the vector value of the slack variables associated with ϕxᵤ in a solvers::MathematicalProgramResult. More... | |
Eigen::VectorXd | GetSolutionPhiXv (const solvers::MathematicalProgramResult &result) const |
Returns the vector value of the slack variables associated with ϕxᵥ in a solvers::MathematicalProgramResult. More... | |
Does not allow copy, move, or assignment | |
Edge (const Edge &)=delete | |
Edge & | operator= (const Edge &)=delete |
Edge (Edge &&)=delete | |
Edge & | operator= (Edge &&)=delete |
Friends | |
class | GraphOfConvexSets |
~Edge | ( | ) |
solvers::Binding<solvers::Constraint> AddConstraint | ( | const symbolic::Formula & | f | ) |
Adds a constraint to this edge, described by a symbolic::Formula f
containing only elements of xu() and xv() as variables.
solvers::Binding<solvers::Constraint> AddConstraint | ( | const solvers::Binding< solvers::Constraint > & | binding | ) |
std::pair<symbolic::Variable, solvers::Binding<solvers::Cost> > AddCost | ( | const symbolic::Expression & | e | ) |
Adds a cost to this edge, described by a symbolic::Expression e
containing only elements of xu() and xv() as variables.
For technical reasons relating to being able to "turn-off" the cost on inactive edges, all costs are eventually implemented with a slack variable and a constraint:
min g(xu, xv) ⇒ min ℓ, s.t. ℓ ≥ g(xu,xv)
std::pair<symbolic::Variable, solvers::Binding<solvers::Cost> > AddCost | ( | const solvers::Binding< solvers::Cost > & | binding | ) |
Adds a cost to this edge.
binding
must contain only elements of xu() and xv() as variables. For technical reasons relating to being able to "turn-off" the cost on inactive edges, all costs are eventually implemented with a slack variable and a constraint:
min g(xu, xv) ⇒ min ℓ, s.t. ℓ ≥ g(xu,xv)
void AddPhiConstraint | ( | bool | phi_value | ) |
Adds a constraint on the binary variable associated with this edge.
void ClearPhiConstraints | ( | ) |
Removes any constraints added with AddPhiConstraint.
const std::vector<solvers::Binding<solvers::Constraint> >& GetConstraints | ( | ) | const |
Returns all constraints on this edge.
const std::vector<solvers::Binding<solvers::Cost> >& GetCosts | ( | ) | const |
Returns all costs on this edge.
double GetSolutionCost | ( | const solvers::MathematicalProgramResult & | result | ) | const |
Returns the sum of the costs associated with this edge in a solvers::MathematicalProgramResult.
Eigen::VectorXd GetSolutionPhiXu | ( | const solvers::MathematicalProgramResult & | result | ) | const |
Returns the vector value of the slack variables associated with ϕxᵤ in a solvers::MathematicalProgramResult.
This can obtain a different value than result.GetSolution(edge->xu())
, which is equivalent to result.GetSolution(edge->u()->x())
; in the case of a loose convex relaxation result.GetSolution(edge->xu())
will be the averaged value of the edge slacks for all non-zero-flow edges.
Eigen::VectorXd GetSolutionPhiXv | ( | const solvers::MathematicalProgramResult & | result | ) | const |
Returns the vector value of the slack variables associated with ϕxᵥ in a solvers::MathematicalProgramResult.
See GetSolutionPhiXu().
const std::string& name | ( | ) | const |
Returns the string name associated with this edge.
const symbolic::Variable& phi | ( | ) | const |
Returns the binary variable associated with this edge.
It can be used to determine whether this edge was active in the solution to an optimization problem, by calling GetSolution(phi()) on a returned MathematicalProgramResult.
const Vertex& u | ( | ) | const |
Returns a const reference to the "left" Vertex that this edge connects to.
const Vertex& v | ( | ) | const |
Returns a const reference to the "right" Vertex that this edge connects to.
const VectorX<symbolic::Variable>& xu | ( | ) | const |
Returns the continuous decision variables associated with vertex u
.
This can be used for constructing symbolic::Expression costs and constraints.
See also GetSolutionPhiXu(); using result.GetSolution(xu())
may not be what you want.
const VectorX<symbolic::Variable>& xv | ( | ) | const |
Returns the continuous decision variables associated with vertex v
.
This can be used for constructing symbolic::Expression costs and constraints.
See also GetSolutionPhiXv(); using result.GetSolution(xv())
may not be what you want.
|
friend |