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...  
solvers::VectorXDecisionVariable  NewSlackVariables (int rows, const std::string &name) 
Creates continuous slack variables for this edge, appending them to an internal vector of existing slack variables. More...  
solvers::Binding< solvers::Cost >  AddCost (const symbolic::Expression &e, const std::unordered_set< Transcription > &use_in_transcription={ Transcription::kMIP, Transcription::kRelaxation, Transcription::kRestriction}) 
Adds a cost to this edge, described by a symbolic::Expression e containing only elements of xu() and xv() as variables. More...  
solvers::Binding< solvers::Cost >  AddCost (const solvers::Binding< solvers::Cost > &binding, const std::unordered_set< Transcription > &use_in_transcription={ Transcription::kMIP, Transcription::kRelaxation, Transcription::kRestriction}) 
Adds a cost to this edge. More...  
solvers::Binding< solvers::Constraint >  AddConstraint (const symbolic::Formula &f, const std::unordered_set< Transcription > &use_in_transcription={ Transcription::kMIP, Transcription::kRelaxation, Transcription::kRestriction}) 
Adds a constraint to this edge. More...  
solvers::Binding< solvers::Constraint >  AddConstraint (const solvers::Binding< solvers::Constraint > &binding, const std::unordered_set< Transcription > &use_in_transcription={ Transcription::kMIP, Transcription::kRelaxation, Transcription::kRestriction}) 
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...  
std::vector< solvers::Binding< solvers::Cost > >  GetCosts (const std::unordered_set< Transcription > &used_in_transcription={ Transcription::kMIP, Transcription::kRelaxation, Transcription::kRestriction}) const 
Returns costs on this edge. More...  
std::vector< solvers::Binding< solvers::Constraint > >  GetConstraints (const std::unordered_set< Transcription > &used_in_transcription={ Transcription::kMIP, Transcription::kRelaxation, Transcription::kRestriction}) const 
Returns constraints on this edge. More...  
std::optional< double >  GetSolutionCost (const solvers::MathematicalProgramResult &result) const 
Returns the sum of the costs associated with this edge in result , or std::nullopt if no solution for this edge is available. More...  
std::optional< double >  GetSolutionCost (const solvers::MathematicalProgramResult &result, const solvers::Binding< solvers::Cost > &cost) const 
Returns the cost associated with the cost binding on this edge in result , or std::nullopt if no solution for this edge is available. More...  
std::optional< Eigen::VectorXd >  GetSolutionPhiXu (const solvers::MathematicalProgramResult &result) const 
Returns the vector value of the slack variables associated with ϕxᵤ in result , or std::nullopt if no solution for this edge is available. More...  
std::optional< Eigen::VectorXd >  GetSolutionPhiXv (const solvers::MathematicalProgramResult &result) const 
Returns the vector value of the slack variables associated with ϕxᵥ in result , or std::nullopt if no solution for this edge is available. 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, 
const std::unordered_set< Transcription > &  use_in_transcription = { Transcription::kMIP, Transcription::kRelaxation, Transcription::kRestriction} 

) 
solvers::Binding<solvers::Constraint> AddConstraint  (  const solvers::Binding< solvers::Constraint > &  binding, 
const std::unordered_set< Transcription > &  use_in_transcription = { Transcription::kMIP, Transcription::kRelaxation, Transcription::kRestriction} 

) 
solvers::Binding<solvers::Cost> AddCost  (  const symbolic::Expression &  e, 
const std::unordered_set< Transcription > &  use_in_transcription = { Transcription::kMIP, Transcription::kRelaxation, Transcription::kRestriction} 

) 
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 "turnoff" 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)
You must use GetSolutionCost() to retrieve the cost of the solution, rather than evaluating the cost directly, in order to get consistent behavior when solving with the different GCS transcriptions.
use_in_transcription  specifies the components of the problem to which the constraint should be added. 
solvers::Binding<solvers::Cost> AddCost  (  const solvers::Binding< solvers::Cost > &  binding, 
const std::unordered_set< Transcription > &  use_in_transcription = { Transcription::kMIP, Transcription::kRelaxation, Transcription::kRestriction} 

) 
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 "turnoff" 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)
You must use GetSolutionCost() to retrieve the cost of the solution, rather than evaluating the cost directly, in order to get consistent behavior when solving with the different GCS transcriptions.
use_in_transcription  specifies the components of the problem to which the constraint should be added. 
void AddPhiConstraint  (  bool  phi_value  ) 
Adds a constraint on the binary variable associated with this edge.
void ClearPhiConstraints  (  ) 
Removes any constraints added with AddPhiConstraint.
std::vector<solvers::Binding<solvers::Constraint> > GetConstraints  (  const std::unordered_set< Transcription > &  used_in_transcription = { Transcription::kMIP, Transcription::kRelaxation, Transcription::kRestriction}  )  const 
Returns constraints on this edge.
used_in_transcription  specifies the components of the problem from which the constraint should be retrieved. 
std::exception  if no transcription is specified. 
std::vector<solvers::Binding<solvers::Cost> > GetCosts  (  const std::unordered_set< Transcription > &  used_in_transcription = { Transcription::kMIP, Transcription::kRelaxation, Transcription::kRestriction}  )  const 
Returns costs on this edge.
used_in_transcription  specifies the components of the problem from which the constraint should be retrieved. 
std::exception  if no transcription is specified. 
std::optional<double> GetSolutionCost  (  const solvers::MathematicalProgramResult &  result  )  const 
Returns the sum of the costs associated with this edge in result
, or std::nullopt if no solution for this edge is available.
std::optional<double> GetSolutionCost  (  const solvers::MathematicalProgramResult &  result, 
const solvers::Binding< solvers::Cost > &  cost  
)  const 
Returns the cost associated with the cost
binding on this edge in result
, or std::nullopt if no solution for this edge is available.
std::exception  if cost is not associated with this edge. 
std::optional<Eigen::VectorXd> GetSolutionPhiXu  (  const solvers::MathematicalProgramResult &  result  )  const 
Returns the vector value of the slack variables associated with ϕxᵤ in result
, or std::nullopt if no solution for this edge is available.
This can obtain a different value than the Vertex::GetSolution(), e.g. from edge>xu().GetSolution(result)
. First, a deactivated edge (defined by Phi ~= 0) will return the zero vector here, while Vertex::GetSolution() will return std::nullopt (rather than divide by zero to recover Xu). Second, in the case of a loose convex relaxation, the vertex version will return the averaged* value of the edge slacks for all nonzeroflow edges.
std::optional<Eigen::VectorXd> GetSolutionPhiXv  (  const solvers::MathematicalProgramResult &  result  )  const 
Returns the vector value of the slack variables associated with ϕxᵥ in result
, or std::nullopt if no solution for this edge is available.
See GetSolutionPhiXu() for more details.
const std::string& name  (  )  const 
Returns the string name associated with this edge.
solvers::VectorXDecisionVariable NewSlackVariables  (  int  rows, 
const std::string &  name  
) 
Creates continuous slack variables for this edge, appending them to an internal vector of existing slack variables.
These slack variables can be used in any cost or constraint on this edge only, and allows for modeling more complex costs and constraints.
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 