Drake
drake::solvers::internal Namespace Reference

Classes

class  SymbolicError
 

Functions

template<typename C , typename... Args>
Binding< C > CreateBinding (const std::shared_ptr< C > &c, Args &&... args)
 
template<typename To , typename From >
Binding< To > BindingDynamicCast (const Binding< From > &binding)
 
Binding< ConstraintParseConstraint (const Eigen::Ref< const VectorX< Expression >> &v, const Eigen::Ref< const Eigen::VectorXd > &lb, const Eigen::Ref< const Eigen::VectorXd > &ub)
 
Binding< ConstraintParseConstraint (const set< Formula > &formulas)
 
Binding< ConstraintParseConstraint (const Formula &f)
 
Binding< LinearEqualityConstraintParseLinearEqualityConstraint (const set< Formula > &formulas)
 
Binding< LinearEqualityConstraintParseLinearEqualityConstraint (const Formula &f)
 
Binding< LinearEqualityConstraintDoParseLinearEqualityConstraint (const Eigen::Ref< const VectorX< Expression >> &v, const Eigen::Ref< const Eigen::VectorXd > &b)
 
Binding< QuadraticConstraintParseQuadraticConstraint (const symbolic::Expression &e, double lower_bound, double upper_bound)
 Assists MathematicalProgram::AddConstraint(...) to create a quadratic constraint binding. More...
 
shared_ptr< ConstraintMakePolynomialConstraint (const VectorXPoly &polynomials, const vector< Polynomiald::VarType > &poly_vars, const Eigen::VectorXd &lb, const Eigen::VectorXd &ub)
 
Binding< LorentzConeConstraintParseLorentzConeConstraint (const Eigen::Ref< const VectorX< Expression >> &v)
 
Binding< LorentzConeConstraintParseLorentzConeConstraint (const Expression &linear_expr, const Expression &quadratic_expr, double tol)
 
Binding< RotatedLorentzConeConstraintParseRotatedLorentzConeConstraint (const Eigen::Ref< const VectorX< symbolic::Expression >> &v)
 
Binding< RotatedLorentzConeConstraintParseRotatedLorentzConeConstraint (const symbolic::Expression &linear_expr1, const symbolic::Expression &linear_expr2, const symbolic::Expression &quadratic_expr, double tol)
 
Binding< ConstraintParseConstraint (const Eigen::Ref< const VectorX< symbolic::Expression >> &v, const Eigen::Ref< const Eigen::VectorXd > &lb, const Eigen::Ref< const Eigen::VectorXd > &ub)
 The resulting constraint may be a BoundingBoxConstraint, LinearConstraint, LinearEqualityConstraint, or ExpressionConstraint, depending on the arguments. More...
 
Binding< ConstraintParseConstraint (const symbolic::Expression &e, const double lb, const double ub)
 
template<typename Derived >
std::enable_if< is_eigen_scalar_same< Derived, symbolic::Formula >::value, Binding< Constraint > >::type ParseConstraint (const Eigen::ArrayBase< Derived > &formulas)
 
Binding< LinearEqualityConstraintDoParseLinearEqualityConstraint (const Eigen::Ref< const VectorX< symbolic::Expression >> &v, const Eigen::Ref< const Eigen::VectorXd > &b)
 
Binding< LinearEqualityConstraintParseLinearEqualityConstraint (const symbolic::Expression &e, double b)
 
template<typename DerivedV , typename DerivedB >
std::enable_if< is_eigen_vector_expression_double_pair< DerivedV, DerivedB >::value, Binding< LinearEqualityConstraint > >::type ParseLinearEqualityConstraint (const Eigen::MatrixBase< DerivedV > &V, const Eigen::MatrixBase< DerivedB > &b)
 
template<typename DerivedV , typename DerivedB >
std::enable_if< is_eigen_nonvector_expression_double_pair< DerivedV, DerivedB >::value, Binding< LinearEqualityConstraint > >::type ParseLinearEqualityConstraint (const Eigen::MatrixBase< DerivedV > &V, const Eigen::MatrixBase< DerivedB > &B, bool lower_triangle=false)
 
Binding< LorentzConeConstraintParseLorentzConeConstraint (const Eigen::Ref< const VectorX< symbolic::Expression >> &v)
 
template<typename Derived >
std::enable_if< is_eigen_vector_of< Derived, symbolic::Formula >::value, Binding< Constraint > >::type ParseConstraint (const Eigen::MatrixBase< Derived > &)
 
Binding< LinearCostParseLinearCost (const Expression &e)
 
Binding< QuadraticCostParseQuadraticCost (const Expression &e)
 
Binding< PolynomialCostParsePolynomialCost (const symbolic::Expression &e)
 
Binding< CostParseCost (const symbolic::Expression &e)
 
template<int Size>
NewVariableNames< Size >::type ::type CreateNewVariableNames (int)
 
template<int Size>
std::enable_if< Size==Eigen::Dynamic, typename NewVariableNames< Size >::type >::type CreateNewVariableNames (int size)
 Return un-initialized new variable names. More...
 
template<typename Derived >
void SetVariableNames (const std::string &name, int rows, int cols, Derived *names)
 Set the names of the newly added variables. More...
 
std::vector< Eigen::Vector3d > ComputeBoxEdgesAndSphereIntersection (const Eigen::Vector3d &bmin, const Eigen::Vector3d &bmax)
 Given an axis-aligned box in the first orthant, computes and returns all the intersecting points between the edges of the box and the unit sphere. More...
 
void ComputeTriangleOutwardNormal (const Eigen::Vector3d &pt0, const Eigen::Vector3d &pt1, const Eigen::Vector3d &pt2, Eigen::Vector3d *n, double *d)
 Compute the outward unit length normal of the triangle, with the three vertices being pt0, pt1 and pt2. More...
 
bool AreAllVerticesCoPlanar (const std::vector< Eigen::Vector3d > &pts, Eigen::Vector3d *n, double *d)
 For the vertices in pts, determine if these vertices are co-planar. More...
 
void ComputeHalfSpaceRelaxationForBoxSphereIntersection (const std::vector< Eigen::Vector3d > &pts, Eigen::Vector3d *n, double *d)
 
void ComputeInnerFacetsForBoxSphereIntersection (const std::vector< Eigen::Vector3d > &pts, Eigen::Matrix< double, Eigen::Dynamic, 3 > *A, Eigen::VectorXd *b)
 For the intersection region between the surface of the unit sphere, and the interior of a box aligned with the axes, relax this nonconvex intersection region to its convex hull. More...
 
void ExtractAndAppendVariablesFromExpression (const Expression &e, VectorXDecisionVariable *vars, unordered_map< Variable::Id, int > *map_var_to_index)
 
void DecomposeLinearExpression (const Eigen::Ref< const VectorX< Expression >> &v, Eigen::MatrixXd *A, Eigen::VectorXd *b, VectorXDecisionVariable *vars)
 
pair< VectorXDecisionVariable, unordered_map< Variable::Id, int > > ExtractVariablesFromExpression (const Expression &e)
 
void DecomposeQuadraticPolynomial (const symbolic::Polynomial &poly, const unordered_map< Variable::Id, int > &map_var_to_index, Eigen::MatrixXd *Q, Eigen::VectorXd *b, double *c)
 
template<typename Derived , typename = typename std::enable_if<Derived::ColsAtCompileTime == 1>::type>
void AppendToVector (const typename Derived::Scalar &s, Eigen::MatrixBase< Derived > *px)
 
void DecomposeLinearExpression (const Eigen::Ref< const VectorX< symbolic::Expression >> &v, Eigen::MatrixXd *A, Eigen::VectorXd *b, VectorXDecisionVariable *vars)
 
template<typename Derived >
std::enable_if< std::is_same< typename Derived::Scalar, double >::value, int >::type DecomposeLinearExpression (const symbolic::Expression &e, const std::unordered_map< symbolic::Variable::Id, int > &map_var_to_index, const Eigen::MatrixBase< Derived > &coeffs, double *constant_term)
 

Function Documentation

◆ AppendToVector()

void drake::solvers::internal::AppendToVector ( const typename Derived::Scalar &  s,
Eigen::MatrixBase< Derived > *  px 
)

◆ AreAllVerticesCoPlanar()

bool AreAllVerticesCoPlanar ( const std::vector< Eigen::Vector3d > &  pts,
Eigen::Vector3d *  n,
double d 
)

For the vertices in pts, determine if these vertices are co-planar.

If they are, then compute that plane nᵀ * x = d.

Parameters
ptsThe vertices to be checked.
nThe unit length normal vector of the plane, points outward from the origin. If the vertices are not co-planar, leave n to 0.
dThe intersecpt of the plane. If the vertices are not co-planar, set this to 0.
Returns
If the vertices are co-planar, set this to true. Otherwise set to false.

◆ BindingDynamicCast()

Binding<To> drake::solvers::internal::BindingDynamicCast ( const Binding< From > &  binding)

◆ ComputeBoxEdgesAndSphereIntersection()

std::vector< Eigen::Vector3d > ComputeBoxEdgesAndSphereIntersection ( const Eigen::Vector3d &  bmin,
const Eigen::Vector3d &  bmax 
)

Given an axis-aligned box in the first orthant, computes and returns all the intersecting points between the edges of the box and the unit sphere.

Parameters
bminThe vertex of the box closest to the origin.
bmaxThe vertex of the box farthest from the origin.

◆ ComputeHalfSpaceRelaxationForBoxSphereIntersection()

void ComputeHalfSpaceRelaxationForBoxSphereIntersection ( const std::vector< Eigen::Vector3d > &  pts,
Eigen::Vector3d *  n,
double d 
)

◆ ComputeInnerFacetsForBoxSphereIntersection()

void ComputeInnerFacetsForBoxSphereIntersection ( const std::vector< Eigen::Vector3d > &  pts,
Eigen::Matrix< double, Eigen::Dynamic, 3 > *  A,
Eigen::VectorXd *  b 
)

For the intersection region between the surface of the unit sphere, and the interior of a box aligned with the axes, relax this nonconvex intersection region to its convex hull.

This convex hull has some planar facets (formed by the triangles connecting the vertices of the intersection region). This function computes these planar facets. It is guaranteed that any point x on the intersection region, satisfies A * x <= b.

Parameters
[in]ptsThe vertices of the intersection region. Same as the pts in ComputeHalfSpaceRelaxationForBoxSphereIntersection()
[out]AThe rows of A are the normal vector of facets. Each row of A is a unit length vector.
bb(i) is the interscept of the i'th facet.
Precondition
pts[i] are all in the first orthant, namely (pts[i].array() >=0).all() should be true.

◆ ComputeTriangleOutwardNormal()

void drake::solvers::internal::ComputeTriangleOutwardNormal ( const Eigen::Vector3d &  pt0,
const Eigen::Vector3d &  pt1,
const Eigen::Vector3d &  pt2,
Eigen::Vector3d *  n,
double d 
)

Compute the outward unit length normal of the triangle, with the three vertices being pt0, pt1 and pt2.

Parameters
pt0A vertex of the triangle, in the first orthant (+++).
pt1A vertex of the triangle, in the first orthant (+++).
pt2A vertex of the triangle, in the first orthant (+++).
nThe unit length normal vector of the triangle, pointing outward from the origin.
dThe intersecpt of the plane. Namely nᵀ * x = d for any point x on the triangle.

◆ CreateBinding()

Binding<C> drake::solvers::internal::CreateBinding ( const std::shared_ptr< C > &  c,
Args &&...  args 
)

◆ CreateNewVariableNames() [1/2]

NewVariableNames<Size>::type ::type drake::solvers::internal::CreateNewVariableNames ( int  )

◆ CreateNewVariableNames() [2/2]

std::enable_if<Size == Eigen::Dynamic, typename NewVariableNames<Size>::type>::type drake::solvers::internal::CreateNewVariableNames ( int  size)

Return un-initialized new variable names.

◆ DecomposeLinearExpression() [1/3]

void drake::solvers::internal::DecomposeLinearExpression ( const Eigen::Ref< const VectorX< Expression >> &  v,
Eigen::MatrixXd *  A,
Eigen::VectorXd *  b,
VectorXDecisionVariable vars 
)

◆ DecomposeLinearExpression() [2/3]

void drake::solvers::internal::DecomposeLinearExpression ( const Eigen::Ref< const VectorX< symbolic::Expression >> &  v,
Eigen::MatrixXd *  A,
Eigen::VectorXd *  b,
VectorXDecisionVariable vars 
)

◆ DecomposeLinearExpression() [3/3]

std::enable_if<std::is_same<typename Derived::Scalar, double>::value, int>::type drake::solvers::internal::DecomposeLinearExpression ( const symbolic::Expression e,
const std::unordered_map< symbolic::Variable::Id, int > &  map_var_to_index,
const Eigen::MatrixBase< Derived > &  coeffs,
double constant_term 
)

◆ DecomposeQuadraticPolynomial()

void DecomposeQuadraticPolynomial ( const symbolic::Polynomial poly,
const unordered_map< Variable::Id, int > &  map_var_to_index,
Eigen::MatrixXd *  Q,
Eigen::VectorXd *  b,
double c 
)

◆ DoParseLinearEqualityConstraint() [1/2]

Binding<LinearEqualityConstraint> drake::solvers::internal::DoParseLinearEqualityConstraint ( const Eigen::Ref< const VectorX< symbolic::Expression >> &  v,
const Eigen::Ref< const Eigen::VectorXd > &  b 
)

◆ DoParseLinearEqualityConstraint() [2/2]

Binding<LinearEqualityConstraint> drake::solvers::internal::DoParseLinearEqualityConstraint ( const Eigen::Ref< const VectorX< Expression >> &  v,
const Eigen::Ref< const Eigen::VectorXd > &  b 
)

◆ ExtractAndAppendVariablesFromExpression()

void ExtractAndAppendVariablesFromExpression ( const Expression e,
VectorXDecisionVariable vars,
unordered_map< Variable::Id, int > *  map_var_to_index 
)

◆ ExtractVariablesFromExpression()

std::pair< VectorXDecisionVariable, std::unordered_map< symbolic::Variable::Id, int > > ExtractVariablesFromExpression ( const Expression e)

◆ MakePolynomialConstraint()

std::shared_ptr< Constraint > MakePolynomialConstraint ( const VectorXPoly polynomials,
const vector< Polynomiald::VarType > &  poly_vars,
const Eigen::VectorXd &  lb,
const Eigen::VectorXd &  ub 
)

◆ ParseConstraint() [1/7]

Binding<Constraint> drake::solvers::internal::ParseConstraint ( const Eigen::Ref< const VectorX< symbolic::Expression >> &  v,
const Eigen::Ref< const Eigen::VectorXd > &  lb,
const Eigen::Ref< const Eigen::VectorXd > &  ub 
)

The resulting constraint may be a BoundingBoxConstraint, LinearConstraint, LinearEqualityConstraint, or ExpressionConstraint, depending on the arguments.

Constraints of the form x == 1 (which could be created as a BoundingBoxConstraint or LinearEqualityConstraint) will be constructed as a LinearEqualityConstraint.

◆ ParseConstraint() [2/7]

Binding<Constraint> drake::solvers::internal::ParseConstraint ( const Eigen::Ref< const VectorX< Expression >> &  v,
const Eigen::Ref< const Eigen::VectorXd > &  lb,
const Eigen::Ref< const Eigen::VectorXd > &  ub 
)

◆ ParseConstraint() [3/7]

Binding<Constraint> drake::solvers::internal::ParseConstraint ( const symbolic::Expression e,
const double  lb,
const double  ub 
)
inline

◆ ParseConstraint() [4/7]

std::enable_if<is_eigen_scalar_same<Derived, symbolic::Formula>::value, Binding<Constraint> >::type drake::solvers::internal::ParseConstraint ( const Eigen::ArrayBase< Derived > &  formulas)

◆ ParseConstraint() [5/7]

Binding< Constraint > ParseConstraint ( const set< Formula > &  formulas)

◆ ParseConstraint() [6/7]

std::enable_if<is_eigen_vector_of<Derived, symbolic::Formula>::value, Binding<Constraint> >::type drake::solvers::internal::ParseConstraint ( const Eigen::MatrixBase< Derived > &  )

◆ ParseConstraint() [7/7]

Binding< Constraint > ParseConstraint ( const Formula f)

◆ ParseCost()

Binding< Cost > ParseCost ( const symbolic::Expression e)

◆ ParseLinearCost()

Binding< LinearCost > ParseLinearCost ( const Expression e)

◆ ParseLinearEqualityConstraint() [1/5]

Binding<LinearEqualityConstraint> drake::solvers::internal::ParseLinearEqualityConstraint ( const symbolic::Expression e,
double  b 
)
inline

◆ ParseLinearEqualityConstraint() [2/5]

std::enable_if< is_eigen_vector_expression_double_pair<DerivedV, DerivedB>::value, Binding<LinearEqualityConstraint> >::type drake::solvers::internal::ParseLinearEqualityConstraint ( const Eigen::MatrixBase< DerivedV > &  V,
const Eigen::MatrixBase< DerivedB > &  b 
)

◆ ParseLinearEqualityConstraint() [3/5]

std::enable_if< is_eigen_nonvector_expression_double_pair<DerivedV, DerivedB>::value, Binding<LinearEqualityConstraint> >::type drake::solvers::internal::ParseLinearEqualityConstraint ( const Eigen::MatrixBase< DerivedV > &  V,
const Eigen::MatrixBase< DerivedB > &  B,
bool  lower_triangle = false 
)

◆ ParseLinearEqualityConstraint() [4/5]

Binding< LinearEqualityConstraint > ParseLinearEqualityConstraint ( const set< Formula > &  formulas)

◆ ParseLinearEqualityConstraint() [5/5]

Binding< LinearEqualityConstraint > ParseLinearEqualityConstraint ( const Formula f)

◆ ParseLorentzConeConstraint() [1/3]

Binding<LorentzConeConstraint> drake::solvers::internal::ParseLorentzConeConstraint ( const Eigen::Ref< const VectorX< symbolic::Expression >> &  v)

◆ ParseLorentzConeConstraint() [2/3]

Binding<LorentzConeConstraint> drake::solvers::internal::ParseLorentzConeConstraint ( const Eigen::Ref< const VectorX< Expression >> &  v)

◆ ParseLorentzConeConstraint() [3/3]

Binding< LorentzConeConstraint > ParseLorentzConeConstraint ( const Expression linear_expr,
const Expression quadratic_expr,
double  tol 
)

◆ ParsePolynomialCost()

Binding< PolynomialCost > ParsePolynomialCost ( const symbolic::Expression e)

◆ ParseQuadraticConstraint()

Binding< QuadraticConstraint > ParseQuadraticConstraint ( const symbolic::Expression e,
double  lower_bound,
double  upper_bound 
)

Assists MathematicalProgram::AddConstraint(...) to create a quadratic constraint binding.

◆ ParseQuadraticCost()

Binding< QuadraticCost > ParseQuadraticCost ( const Expression e)

◆ ParseRotatedLorentzConeConstraint() [1/2]

Binding< RotatedLorentzConeConstraint > ParseRotatedLorentzConeConstraint ( const Eigen::Ref< const VectorX< symbolic::Expression >> &  v)

◆ ParseRotatedLorentzConeConstraint() [2/2]

Binding< RotatedLorentzConeConstraint > ParseRotatedLorentzConeConstraint ( const symbolic::Expression linear_expr1,
const symbolic::Expression linear_expr2,
const symbolic::Expression quadratic_expr,
double  tol 
)

◆ SetVariableNames()

void drake::solvers::internal::SetVariableNames ( const std::string &  name,
int  rows,
int  cols,
Derived *  names 
)

Set the names of the newly added variables.

Parameters
nameThe common name of all new variables.
rowsThe number of rows in the new variables.
colsThe number of columns in the new variables.
Precondition
The size of names is rows * cols.