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::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
 
size_t get_hash () 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

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::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.

Here is the call graph for this function:

Here is the caller graph for this function:

size_t get_hash ( ) const
inline

Here is the call graph for this function:

Here is the caller graph for this function:

Variable::Id get_id ( ) const

Here is the caller graph for this function:

string get_name ( ) const

Here is the caller graph for this function:

Variable::Type get_type ( ) const

Here is the caller graph for this function:

bool is_dummy ( ) const
inline

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

Here is the call graph for this function:

Here is the caller graph for this function:

bool less ( const Variable v) const
inline

Compares two variables based on their ID values.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the caller graph for this function:

Friends And Related Function Documentation

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

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