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

Detailed Description

Each vertex in the graph has a corresponding ConvexSet, and a std::string name.

#include <drake/geometry/optimization/graph_of_convex_sets.h>

Public Member Functions

 ~Vertex ()
 
VertexId id () const
 Returns the unique identifier associated with this Vertex. More...
 
int ambient_dimension () const
 Returns the ambient dimension of the ConvexSet. More...
 
const std::string & name () const
 Returns the name of the vertex. More...
 
const VectorX< symbolic::Variable > & x () const
 Returns a decision variable corresponding to an element of the ConvexSet, which can be used for constructing symbolic::Expression costs and constraints. More...
 
const ConvexSetset () const
 Returns a const reference to the underlying ConvexSet. More...
 
solvers::Binding< solvers::CostAddCost (const symbolic::Expression &e, const std::unordered_set< Transcription > &use_in_transcription={ Transcription::kMIP, Transcription::kRelaxation, Transcription::kRestriction})
 Adds a cost to this vertex, described by a symbolic::Expression e containing only elements of x() as variables. More...
 
solvers::Binding< solvers::CostAddCost (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 vertex. More...
 
solvers::Binding< solvers::ConstraintAddConstraint (const symbolic::Formula &f, const std::unordered_set< Transcription > &use_in_transcription={ Transcription::kMIP, Transcription::kRelaxation, Transcription::kRestriction})
 Adds a constraint to this vertex. More...
 
solvers::Binding< solvers::ConstraintAddConstraint (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 vertex. 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 vertex. 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 vertex. More...
 
std::optional< doubleGetSolutionCost (const solvers::MathematicalProgramResult &result) const
 Returns the sum of the costs associated with this vertex in result, or std::nullopt if no solution for this vertex is available. More...
 
std::optional< doubleGetSolutionCost (const solvers::MathematicalProgramResult &result, const solvers::Binding< solvers::Cost > &cost) const
 Returns the cost associated with the cost binding on this vertex in result, or std::nullopt if no solution for this vertex is available. More...
 
std::optional< Eigen::VectorXd > GetSolution (const solvers::MathematicalProgramResult &result) const
 Returns the solution of x() in result, or std::nullopt if no solution for this vertex is available. More...
 
const std::vector< Edge * > & incoming_edges () const
 
const std::vector< Edge * > & outgoing_edges () const
 
Does not allow copy, move, or assignment
 Vertex (const Vertex &)=delete
 
Vertexoperator= (const Vertex &)=delete
 
 Vertex (Vertex &&)=delete
 
Vertexoperator= (Vertex &&)=delete
 

Friends

class GraphOfConvexSets
 

Constructor & Destructor Documentation

◆ Vertex() [1/2]

Vertex ( const Vertex )
delete

◆ Vertex() [2/2]

Vertex ( Vertex &&  )
delete

◆ ~Vertex()

~Vertex ( )

Member Function Documentation

◆ AddConstraint() [1/2]

solvers::Binding<solvers::Constraint> AddConstraint ( const symbolic::Formula f,
const std::unordered_set< Transcription > &  use_in_transcription = Transcription::kMIPTranscription::kRelaxationTranscription::kRestriction} 
)

Adds a constraint to this vertex.

Parameters
fmust contain only elements of x() as variables.
use_in_transcriptionspecifies the components of the problem to which the constraint should be added.
Exceptions
std::exceptionif f.GetFreeVariables() is not a subset of x().
std::exceptionif ambient_dimension() == 0.
std::exceptionif no transcription is specified.

◆ AddConstraint() [2/2]

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

Adds a constraint to this vertex.

Parameters
bindingsmust contain only elements of x() as variables.
use_in_transcriptionspecifies the components of the problem to which the constraint should be added.
Exceptions
std::exceptionif binding.variables() is not a subset of x().
std::exceptionif ambient_dimension() == 0.
std::exceptionif no transcription is specified.

◆ AddCost() [1/2]

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

Adds a cost to this vertex, described by a symbolic::Expression e containing only elements of x() as variables.

For technical reasons relating to being able to "turn-off" the cost on inactive vertices, all costs are eventually implemented with a slack variable and a constraint:

min g(x) ⇒ min ℓ, s.t. ℓ ≥ g(x).

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.

Parameters
use_in_transcriptionspecifies the components of the problem to which the constraint should be added.
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 added cost, g(x).
Exceptions
std::exceptionif e.GetVariables() is not a subset of x().
std::exceptionif no transcription is specified.

◆ AddCost() [2/2]

solvers::Binding<solvers::Cost> AddCost ( const solvers::Binding< solvers::Cost > &  binding,
const std::unordered_set< Transcription > &  use_in_transcription = Transcription::kMIPTranscription::kRelaxationTranscription::kRestriction} 
)

Adds a cost to this vertex.

binding must contain only elements of x() as variables. For technical reasons relating to being able to "turn-off" the cost on inactive vertices, all costs are eventually implemented with a slack variable and a constraint:

min g(x) ⇒ min ℓ, s.t. ℓ ≥ g(x).

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.

Parameters
use_in_transcriptionspecifies the components of the problem to which the constraint should be added.
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 added cost, g(x).
Exceptions
std::exceptionif binding.variables() is not a subset of x().
std::exceptionif no transcription is specified.

◆ ambient_dimension()

int ambient_dimension ( ) const

Returns the ambient dimension of the ConvexSet.

◆ GetConstraints()

std::vector<solvers::Binding<solvers::Constraint> > GetConstraints ( const std::unordered_set< Transcription > &  used_in_transcription = Transcription::kMIPTranscription::kRelaxationTranscription::kRestriction}) const

Returns constraints on this vertex.

Parameters
used_in_transcriptionspecifies the components of the problem from which the constraint should be retrieved.
Exceptions
std::exceptionif no transcription is specified.

◆ GetCosts()

std::vector<solvers::Binding<solvers::Cost> > GetCosts ( const std::unordered_set< Transcription > &  used_in_transcription = Transcription::kMIPTranscription::kRelaxationTranscription::kRestriction}) const

Returns costs on this vertex.

Parameters
used_in_transcriptionspecifies the components of the problem from which the constraint should be retrieved.
Exceptions
std::exceptionif no transcription is specified.

◆ GetSolution()

std::optional<Eigen::VectorXd> GetSolution ( const solvers::MathematicalProgramResult result) const

Returns the solution of x() in result, or std::nullopt if no solution for this vertex is available.

std::nullopt can happen if the vertex is deactivated (e.g. not in the shorest path) in the solution.

◆ GetSolutionCost() [1/2]

std::optional<double> GetSolutionCost ( const solvers::MathematicalProgramResult result) const

Returns the sum of the costs associated with this vertex in result, or std::nullopt if no solution for this vertex is available.

◆ GetSolutionCost() [2/2]

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 vertex in result, or std::nullopt if no solution for this vertex is available.

Exceptions
std::exceptionif cost is not associated with this vertex.

◆ id()

VertexId id ( ) const

Returns the unique identifier associated with this Vertex.

◆ incoming_edges()

const std::vector<Edge*>& incoming_edges ( ) const

◆ name()

const std::string& name ( ) const

Returns the name of the vertex.

◆ operator=() [1/2]

Vertex& operator= ( Vertex &&  )
delete

◆ operator=() [2/2]

Vertex& operator= ( const Vertex )
delete

◆ outgoing_edges()

const std::vector<Edge*>& outgoing_edges ( ) const

◆ set()

const ConvexSet& set ( ) const

Returns a const reference to the underlying ConvexSet.

◆ x()

const VectorX<symbolic::Variable>& x ( ) const

Returns a decision variable corresponding to an element of the ConvexSet, which can be used for constructing symbolic::Expression costs and constraints.

Friends And Related Function Documentation

◆ GraphOfConvexSets

friend class GraphOfConvexSets
friend

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