Drake
Variable Class Reference

Represents a symbolic variable. More...

#include <drake/common/symbolic_variable.h>

Public Types

enum  Type { CONTINUOUS, INTEGER, BINARY, BOOLEAN }
 Supported types of symbolic variables. More...
 
typedef size_t Id
 

Public Member Functions

 Variable ()
 Default constructor. 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...
 
bool is_dummy () const
 Checks if this is a dummy variable (ID = 0) which is 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)
 

Detailed Description

Represents a symbolic variable.

Member Typedef Documentation

typedef size_t Id

Member Enumeration Documentation

enum Type
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.

Constructor & Destructor Documentation

Variable ( const Variable )
default
Variable ( Variable &&  )
default
Variable ( )
inline

Default constructor.

Constructs a dummy variable of CONTINUOUS type. This is needed to have Eigen::Matrix<Variable>. The objects created by the default constructor share the same ID, zero. As a result, they all are identified as a single variable by equality operator (==). They all have the same hash value as well.

It is allowed to construct a dummy variable but it should not be used to construct a symbolic expression.

Variable ( std::nullptr_t  )
inlineexplicit

Constructs a default value.

This overload is used by Eigen when EIGEN_INITIALIZE_MATRICES_BY_ZERO is enabled.

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

Constructs a variable with a string.

If not specified, it has CONTINUOUS type by default.

Member Function Documentation

bool equal_to ( const Variable v) const
inline

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

Variable::Id get_id ( ) const
string get_name ( ) const
Variable::Type get_type ( ) const
bool is_dummy ( ) const
inline

Checks if this is a dummy variable (ID = 0) which is created by the default constructor.

bool less ( const Variable v) const
inline

Compares two variables based on their ID values.

Variable& operator= ( const Variable )
default
Variable& operator= ( Variable &&  )
default
string to_string ( ) const

Friends And Related Function Documentation

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

Implements the hash_append generic hashing concept.

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

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