#include <variable.h>
|
Id | id_ |
| Unique identifier for the variable. The high-order byte stores the Type.
|
|
std::shared_ptr< const std::string > | name_ |
| Name of the variable.
|
|
Represents a symbolic variable.
A symbolic variable is a named entity that can take a value from a specific domain.
- Warning
- Do not use the
operator==
to verify equality between to Variable, as it creates a Formula. Use the equal_to() method instead.
◆ Type
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.
|
◆ Variable() [1/2]
smats::Variable::Variable |
( |
| ) |
|
|
inline |
Construct a dummy variable.
All default-constructed variables are considered the same variable by the equal_to method. A moved-from variable becomes a dummy variable.
◆ Variable() [2/2]
Constructs a variable with a string.
- Parameters
-
name | name of the variable. |
type | type of the variable. |
◆ equal_to()
bool smats::Variable::equal_to |
( |
const Variable & | o | ) |
const |
|
inlinenodiscardnoexcept |
Compare two variables to determine if they are equal. Two variables are equal if they have the same id_ .
- Parameters
-
o | other object to compare against |
- Returns
- true the two object are equal
-
false if the two objects are different
◆ get_next_id()
Get the next unique identifier for a variable.
The unique identifier is a 64-bit value that is composed of two parts:
- The first high-order byte stores the Type of the variable
- The remaining low-order bytes store a counter that is incremented each time a new variable is created.
- Note
- Id 0 is reserved for anonymous variable which is created by the default constructor, Variable(). As a result, the invariant
get_next_id() > 0
is guaranteed.
- Parameters
-
- Returns
- next unique identifier for a variable
◆ hash()
void smats::Variable::hash |
( |
InvocableHashAlgorithm auto & | hasher | ) |
const |
|
inlinenoexcept |
Compute the hash of this variable using the given hasher
- Template Parameters
-
- Parameters
-
hasher | hash algorithm to use |
◆ id()
Id smats::Variable::id |
( |
| ) |
const |
|
inlinenodiscard |
Get read-only access to the unique identifier of the variable.
- Returns
- unique identifier of the variable
◆ is_dummy()
bool smats::Variable::is_dummy |
( |
| ) |
const |
|
inlinenodiscard |
Check whether the variable is a dummy variable.
A dummy variable is a variable with an ID of zero and represents an anonymous variable. It should not be used in any context other than as a placeholder.
- Returns
- true if the variable is a dummy variable
-
false if the variable is not a dummy variable
◆ less()
bool smats::Variable::less |
( |
const Variable & | o | ) |
const |
|
inlinenodiscardnoexcept |
Compare two variables to determine the order between them. The ordering is based on the id_ values of the two variables.
- Parameters
-
o | other object to compare against |
- Returns
- true if this object is less than the other object
-
false if this object is not less than the other object
◆ name()
const std::string & smats::Variable::name |
( |
| ) |
const |
|
nodiscard |
Get read-only access to the name of the variable.
- Returns
- name of the variable
◆ type()
Type smats::Variable::type |
( |
| ) |
const |
|
inlinenodiscard |
Get read-only access to the type of the variable. The type is stored in the upper byte of id_ .
- Returns
- type of the variable
- See also
- get_next_id()
◆ id_
Unique identifier for the variable. The high-order byte stores the Type.
- See also
- get_next_id()
The documentation for this class was generated from the following files:
- smats/symbolic/variable.h
- smats/symbolic/variable.cpp