Drake
Drake C++ Documentation
Variable Class Reference

Detailed Description

Represents a symbolic variable.

Note
Expression::Evaluate and Formula::Evaluate methods take a symbolic environment (Variable → double) and a random number generator. When an expression or a formula includes random variables, Evaluate methods use the random number generator to draw a number for a random variable from the given distribution. Then this numeric value is used to substitute all the occurrences of the corresponding random variable in an expression or a formula.

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

Public Types

enum  Type : uint8_t {
  CONTINUOUS, INTEGER, BINARY, BOOLEAN,
  RANDOM_UNIFORM, RANDOM_GAUSSIAN, RANDOM_EXPONENTIAL
}
 Supported types of symbolic variables. More...
 
typedef size_t Id
 

Public Member Functions

 Variable ()=default
 Constructs a default variable of type CONTINUOUS with an Id of zero. More...
 
 Variable (std::nullptr_t)
 Constructs a default value. More...
 
 Variable (std::string name, Type type=Type::CONTINUOUS)
 Constructs a variable with a string. More...
 
 ~Variable ()=default
 
bool is_dummy () const
 Checks if this is the variable created by the default constructor. More...
 
Id get_id () const
 
Type get_type () const
 
std::string get_name () const
 
std::string to_string () const
 
bool equal_to (const Variable &v) const
 Checks the equality of two variables based on their ID values. More...
 
bool less (const Variable &v) const
 Compares two variables based on their ID values. More...
 
Implements CopyConstructible, CopyAssignable, MoveConstructible, MoveAssignable
 Variable (const Variable &)=default
 
Variableoperator= (const Variable &)=default
 
 Variable (Variable &&)=default
 
Variableoperator= (Variable &&)=default
 

Friends

template<class HashAlgorithm >
void hash_append (HashAlgorithm &hasher, const Variable &item) noexcept
 Implements the hash_append generic hashing concept. More...
 
std::ostream & operator<< (std::ostream &os, const Variable &var)
 

Member Typedef Documentation

◆ Id

typedef size_t Id

Member Enumeration Documentation

◆ Type

enum Type : uint8_t
strong

Supported types of symbolic variables.

Enumerator
CONTINUOUS 

A CONTINUOUS variable takes a double value.

INTEGER 

An INTEGER variable takes an int value.

BINARY 

A BINARY variable takes an integer value from {0, 1}.

BOOLEAN 

A BOOLEAN variable takes a bool value.

RANDOM_UNIFORM 

A random variable whose value will be drawn from uniform real distributed ∈ [0,1).

RANDOM_GAUSSIAN 

A random variable whose value will be drawn from mean-zero, unit-variance normal.

RANDOM_EXPONENTIAL 

A random variable whose value will be drawn from exponential distribution with λ=1.

Constructor & Destructor Documentation

◆ Variable() [1/5]

Variable ( const Variable )
default

◆ Variable() [2/5]

Variable ( Variable &&  )
default

◆ Variable() [3/5]

Variable ( )
default

Constructs a default variable of type CONTINUOUS with an Id of zero.

All default-constructed variables are considered the same variable by the equality operator (==). Similarly, a moved-from variable is also identical to a default-constructed variable (in both its name and its Id).

◆ Variable() [4/5]

Variable ( std::nullptr_t  )
explicit

Constructs a default value.

This overload is used by Eigen when EIGEN_INITIALIZE_MATRICES_BY_ZERO is enabled.

◆ Variable() [5/5]

Variable ( std::string  name,
Type  type = Type::CONTINUOUS 
)
explicit

Constructs a variable with a string.

If not specified, it has CONTINUOUS type by default.

◆ ~Variable()

~Variable ( )
default

Member Function Documentation

◆ equal_to()

bool equal_to ( const Variable v) const

Checks the equality of two variables based on their ID values.

◆ get_id()

Id get_id ( ) const

◆ get_name()

std::string get_name ( ) const

◆ get_type()

Type get_type ( ) const

◆ is_dummy()

bool is_dummy ( ) const

Checks if this is the variable created by the default constructor.

◆ less()

bool less ( const Variable v) const

Compares two variables based on their ID values.

◆ operator=() [1/2]

Variable& operator= ( const Variable )
default

◆ operator=() [2/2]

Variable& operator= ( Variable &&  )
default

◆ to_string()

std::string to_string ( ) const

Friends And Related Function Documentation

◆ hash_append

void hash_append ( HashAlgorithm &  hasher,
const Variable item 
)
friend

Implements the hash_append generic hashing concept.

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const Variable var 
)
friend

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