Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::math_opt::Variable Class Reference

#include <variable_and_expressions.h>

Public Types

using IdType = VariableId
 The typed integer used for ids.
 

Public Member Functions

 Variable (const ModelStorage *storage, VariableId id)
 
int64_t id () const
 
VariableId typed_id () const
 
const ModelStorage * storage () const
 
double lower_bound () const
 
double upper_bound () const
 
bool is_integer () const
 
absl::string_view name () const
 
LinearExpression operator- () const
 

Friends

template<typename H >
AbslHashValue (H h, const Variable &variable)
 
std::ostream & operator<< (std::ostream &ostr, const Variable &variable)
 

Detailed Description

A value type that references a variable from ModelStorage. Usually this type is passed by copy.

This type implements https://abseil.io/docs/cpp/guides/hash (see VariablesEquality for details about how operator== works).

Definition at line 124 of file variable_and_expressions.h.

Member Typedef Documentation

◆ IdType

The typed integer used for ids.

Definition at line 127 of file variable_and_expressions.h.

Constructor & Destructor Documentation

◆ Variable()

operations_research::math_opt::Variable::Variable ( const ModelStorage * storage,
VariableId id )
inline

Usually users will obtain variables using Model::AddVariable(). There should be little for users to build this object from an ModelStorage.

Inline function implementations ///////////////////////////////////////////// Variable

Definition at line 1277 of file variable_and_expressions.h.

Member Function Documentation

◆ id()

int64_t operations_research::math_opt::Variable::id ( ) const
inline

Each call to AddVariable will produce Variables id() increasing by one, starting at zero. Deleted ids are NOT reused. Thus, if no variables are deleted, the ids in the model will be consecutive.

Definition at line 1282 of file variable_and_expressions.h.

◆ is_integer()

bool operations_research::math_opt::Variable::is_integer ( ) const
inline

Definition at line 1296 of file variable_and_expressions.h.

◆ lower_bound()

double operations_research::math_opt::Variable::lower_bound ( ) const
inline

Definition at line 1288 of file variable_and_expressions.h.

◆ name()

absl::string_view operations_research::math_opt::Variable::name ( ) const
inline

Definition at line 1298 of file variable_and_expressions.h.

◆ operator-()

LinearExpression operations_research::math_opt::Variable::operator- ( ) const
inline

Definition at line 1321 of file variable_and_expressions.h.

◆ storage()

const ModelStorage * operations_research::math_opt::Variable::storage ( ) const
inline

Definition at line 1286 of file variable_and_expressions.h.

◆ typed_id()

VariableId operations_research::math_opt::Variable::typed_id ( ) const
inline

Definition at line 1284 of file variable_and_expressions.h.

◆ upper_bound()

double operations_research::math_opt::Variable::upper_bound ( ) const
inline

Definition at line 1292 of file variable_and_expressions.h.

Friends And Related Symbol Documentation

◆ AbslHashValue

template<typename H >
H AbslHashValue ( H h,
const Variable & variable )
friend

Definition at line 1306 of file variable_and_expressions.h.

◆ operator<<

std::ostream & operator<< ( std::ostream & ostr,
const Variable & variable )
friend
Todo
(b/170992529): handle quoting of invalid characters in the name.

Definition at line 1310 of file variable_and_expressions.h.


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