Skip to main content

variable_map

class IntegerBound

IntegerBound

Attributes

  • lower(int | float) : lower bound of integer decision variable
  • upper(int | float) : upper bound of integer decision variable

class VariableMap

VarialeMap

This class is used to manage the mapping between the label and the index of the decision variable.

Attributes

  • var_map(dict[str, dict[tuple[int, ...], int]]) : label, subscripts -> index (int)
  • var_num(int) : number of variables
  • integer_bound(dict[str, dict[tuple[int, ...], IntegerBound]]) : bounds of integer decision variables.

add_cont_variable (self, label, subscripts, lower, upper) -> -

Add an integer variable to the variable map.

add_int_variable (self, label, subscripts, lower, upper) -> -

Add an integer variable to the variable map.

add_variable (self, label, subscripts) -> int

Add a variable to the variable map.

Parameters

  • label(str) : label of the variable
  • subscripts(tuple[int, ...]) : subscripts of the variable

Returns

  • int : index of the variable in the variable map

from_serializable (data) -> -

to_serializable (self) -> dict

Convert to a serializable object.

Returns

  • dict : serializable object

Examples

varmap = VariableMap()
varmap.add_variable("x", (0, 0))
varmap.add_variable("x", (0, 1))
varmap.to_serializable()
# {
# "class": "VariableMap",
# "var_map": {
# "x": {
# "subscripts": [
# [0, 0],
# [0, 1]
# ],
# "index": [0, 1]
# }
# },
# "var_num": 2,
# "integer_bound": {}
# }