Drake
Drake C++ Documentation
Loading...
Searching...
No Matches
FormulaPositiveSemidefinite Class Reference

Detailed Description

Symbolic formula representing positive-semidefinite (PSD) constraint.

#include <drake/common/symbolic/expression/formula_cell.h>

Public Member Functions

 FormulaPositiveSemidefinite (const Eigen::Ref< const MatrixX< Expression > > &m)
 Constructs a positive-semidefinite formula from a symmetric matrix m.
template<typename Derived>
 FormulaPositiveSemidefinite (const Eigen::TriangularView< Derived, Eigen::Lower > &l)
 Constructs a symbolic positive-semidefinite formula from a lower triangular-view l.
template<typename Derived>
 FormulaPositiveSemidefinite (const Eigen::TriangularView< Derived, Eigen::Upper > &u)
 Constructs a symbolic positive-semidefinite formula from an upper triangular-view u.
 ~FormulaPositiveSemidefinite () override
void HashAppendDetail (DelegatingHasher *) const override
 Sends all hash-relevant bytes for this FormulaCell type into the given hasher, per the hash_append generic hashing concept – except for get_kind(), because Formula already sends that.
Variables GetFreeVariables () const override
 Returns set of free variables in formula.
bool EqualTo (const FormulaCell &f) const override
 Checks structural equality.
bool Less (const FormulaCell &f) const override
 Checks ordering between this PSD formula and f.
bool Evaluate (const Environment &env) const override
 Evaluates under a given environment.
Formula Substitute (const Substitution &s) const override
 Returns a Formula obtained by replacing all occurrences of the variables in s in the current formula cell with the corresponding expressions in s.
std::ostream & Display (std::ostream &os) const override
 Outputs string representation of formula into output stream os.
const MatrixX< symbolic::Expression > & get_matrix () const
 Returns the corresponding matrix in this PSD formula.
Public Member Functions inherited from FormulaCell
FormulaKind get_kind () const
 Returns kind of formula.
 FormulaCell ()=delete
 Default constructor (deleted).
FormulaCelloperator= (FormulaCell &&f)=delete
 Move-assign (deleted).
FormulaCelloperator= (const FormulaCell &f)=delete
 Copy-assign (deleted).

Additional Inherited Members

Protected Member Functions inherited from FormulaCell
 FormulaCell (FormulaCell &&f)=default
 Move-construct a formula from an rvalue.
 FormulaCell (const FormulaCell &f)=default
 Copy-construct a formula from an lvalue.
 FormulaCell (FormulaKind k)
 Construct FormulaCell of kind k.
virtual ~FormulaCell ()
 Default destructor.

Constructor & Destructor Documentation

◆ FormulaPositiveSemidefinite() [1/3]

FormulaPositiveSemidefinite ( const Eigen::Ref< const MatrixX< Expression > > & m)
explicit

Constructs a positive-semidefinite formula from a symmetric matrix m.

Exceptions
std::exceptionif m is not symmetric.
Note
This constructor checks if m is symmetric, which can be costly.

◆ FormulaPositiveSemidefinite() [2/3]

template<typename Derived>
FormulaPositiveSemidefinite ( const Eigen::TriangularView< Derived, Eigen::Lower > & l)
explicit

Constructs a symbolic positive-semidefinite formula from a lower triangular-view l.

◆ FormulaPositiveSemidefinite() [3/3]

template<typename Derived>
FormulaPositiveSemidefinite ( const Eigen::TriangularView< Derived, Eigen::Upper > & u)
explicit

Constructs a symbolic positive-semidefinite formula from an upper triangular-view u.

◆ ~FormulaPositiveSemidefinite()

Member Function Documentation

◆ Display()

std::ostream & Display ( std::ostream & os) const
overridevirtual

Outputs string representation of formula into output stream os.

Implements FormulaCell.

◆ EqualTo()

bool EqualTo ( const FormulaCell & c) const
nodiscardoverridevirtual

Checks structural equality.

Implements FormulaCell.

◆ Evaluate()

bool Evaluate ( const Environment & env) const
nodiscardoverridevirtual

Evaluates under a given environment.

Implements FormulaCell.

◆ get_matrix()

const MatrixX< symbolic::Expression > & get_matrix ( ) const
nodiscard

Returns the corresponding matrix in this PSD formula.

◆ GetFreeVariables()

Variables GetFreeVariables ( ) const
nodiscardoverridevirtual

Returns set of free variables in formula.

Implements FormulaCell.

◆ HashAppendDetail()

void HashAppendDetail ( DelegatingHasher * ) const
overridevirtual

Sends all hash-relevant bytes for this FormulaCell type into the given hasher, per the hash_append generic hashing concept – except for get_kind(), because Formula already sends that.

Implements FormulaCell.

◆ Less()

bool Less ( const FormulaCell & f) const
nodiscardoverridevirtual

Checks ordering between this PSD formula and f.

The ordering between two PSD formulas psd1 and psd2 are determined by the ordering between the two matrices m1 in psd1 and m2 in psd2.

First, we compare the size of m1 and m2:

  • If m1 is smaller than m2, psd1.Less(psd2) is true.
  • If m2 is smaller than m1, psd1.Less(psd2) is false.

If m1 and m2 are of the same size, we perform element-wise comparison by following column-major order. See the following example:

m1 << x + y, -3.14,
-3.14, y;
m2 << x + y, 3.14,
3.14, y;
EXPECT_TRUE(psd1.Less(psd2));
Represents a symbolic form of a first-order logic formula.
Definition formula.h:114
bool Less(const Formula &f) const
Checks lexicographical ordering between this and e.
x
Definition light_parameter.h:147
Formula positive_semidefinite(const Eigen::Ref< const MatrixX< Expression > > &m)
Returns a symbolic formula constraining m to be a positive-semidefinite matrix.
Note
In the code above, psd1.Less(psd2) holds because we have
  • m1 in column-major ordering : (x + y) -3.14 -3.14 y_
  • m2 in column-major ordering : (x + y) 3.14 3.14 y_.

Implements FormulaCell.

◆ Substitute()

Formula Substitute ( const Substitution & s) const
nodiscardoverridevirtual

Returns a Formula obtained by replacing all occurrences of the variables in s in the current formula cell with the corresponding expressions in s.

Implements FormulaCell.


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