Drake
Drake C++ Documentation
GraphOfConvexSets::Edge Class Referencefinal

Detailed Description

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 Vertexu () const
 Returns a const reference to the "left" Vertex that this edge connects to. More...
 
Vertexu ()
 Returns a mutable reference to the "left" Vertex that this edge connects to. More...
 
const Vertexv () const
 Returns a const reference to the "right" Vertex that this edge connects to. More...
 
Vertexv ()
 Returns a mutable reference to the "right" Vertex that this edge connects to. More...
 
const symbolic::Variablephi () 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::ConstraintAddConstraint (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::ConstraintAddConstraint (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
 
Edgeoperator= (const Edge &)=delete
 
 Edge (Edge &&)=delete
 
Edgeoperator= (Edge &&)=delete
 

Friends

class GraphOfConvexSets
 

Constructor & Destructor Documentation

◆ Edge() [1/2]

Edge ( const Edge )
delete

◆ Edge() [2/2]

Edge ( Edge &&  )
delete

◆ ~Edge()

~Edge ( )

Member Function Documentation

◆ AddConstraint() [1/2]

Adds a constraint to this edge, described by a symbolic::Formula f containing only elements of xu() and xv() as variables.

Exceptions
std::exceptionif f.GetFreeVariables() is not a subset of xu()xv().
std::exceptionif xu()xv() is empty, i.e., when both vertices have an ambient dimension of zero.

◆ AddConstraint() [2/2]

Adds a constraint to this edge.

binding must contain only elements of xu() and xv() as variables.

Exceptions
std::exceptionif binding.variables() is not a subset of xu()xv().
std::exceptionif xu()xv() is empty, i.e., when both vertices have an ambient dimension of zero.

◆ AddCost() [1/2]

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)
Note
Linear costs lead to negative costs if decision variables are not properly constrained. Users may want to check that the solution does not contain negative costs.
Returns
the pair <ℓ, g(xu, xv)>.
Exceptions
std::exceptionif e.GetVariables() is not a subset of xu()xv().

◆ AddCost() [2/2]

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)
Note
Linear costs lead to negative costs if decision variables are not properly constrained. Users may want to check that the solution does not contain negative costs.
Returns
the pair <ℓ, g(xu, xv)>.
Exceptions
std::exceptionif binding.variables() is not a subset of xu()xv().

◆ AddPhiConstraint()

void AddPhiConstraint ( bool  phi_value)

Adds a constraint on the binary variable associated with this edge.

Note
We intentionally do not return a binding to the constraint created by this call, as that would allow the caller to make nonsensical modifications to its bounds (i.e. requiring phi == 0.5).

◆ ClearPhiConstraints()

void ClearPhiConstraints ( )

Removes any constraints added with AddPhiConstraint.

◆ GetConstraints()

const std::vector<solvers::Binding<solvers::Constraint> >& GetConstraints ( ) const

Returns all constraints on this edge.

◆ GetCosts()

const std::vector<solvers::Binding<solvers::Cost> >& GetCosts ( ) const

Returns all costs on this edge.

◆ GetSolutionCost()

double GetSolutionCost ( const solvers::MathematicalProgramResult result) const

Returns the sum of the costs associated with this edge in a solvers::MathematicalProgramResult.

◆ GetSolutionPhiXu()

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.

◆ GetSolutionPhiXv()

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().

◆ id()

EdgeId id ( ) const

Returns the unique identifier associated with this Edge.

◆ name()

const std::string& name ( ) const

Returns the string name associated with this edge.

◆ operator=() [1/2]

Edge& operator= ( Edge &&  )
delete

◆ operator=() [2/2]

Edge& operator= ( const Edge )
delete

◆ phi()

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.

◆ u() [1/2]

const Vertex& u ( ) const

Returns a const reference to the "left" Vertex that this edge connects to.

◆ u() [2/2]

Vertex& u ( )

Returns a mutable reference to the "left" Vertex that this edge connects to.

◆ v() [1/2]

const Vertex& v ( ) const

Returns a const reference to the "right" Vertex that this edge connects to.

◆ v() [2/2]

Vertex& v ( )

Returns a mutable reference to the "right" Vertex that this edge connects to.

◆ xu()

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.

◆ xv()

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.

Friends And Related Function Documentation

◆ GraphOfConvexSets

friend class GraphOfConvexSets
friend

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