Variable functionality#

Add variable(s)#

add_variable(model, var_type, *[, lb, ub, name])

Create and add a single variable to the DOcplex model.

add_variables(model, indexset, var_type, *)

Create and add multiple variables (corresponding to an index-set) to the DOcplex model.

VarDict1D#

Custom subclass of dict to store DOcplex model variables with 1-dim scalar keys.

VarDict1D

This class is not meant to be instantiated; VarDict1D is built through the docplex_extensions.add_variables function.

Attributes#

VarDict1D.model

DOcplex model associated with the variables.

VarDict1D.vartype

DOcplex VarType corresponding to the variables.

VarDict1D.key_name

Name to refer to 1-dim scalar keys.

VarDict1D.value_name

Name to refer to Dict values.

Numerical operations#

VarDict1D.sum()

Sum all variables in a linear expression.

Mapping operations#

VarDict1D.get(key[, default])

Get the variable for the specified key, or the default if not found.

VarDict1D.lookup(key)

Get the variable for the specified key, or zero if it is not found.

Views#

  • VarDict1D.items()

  • VarDict1D.keys()

  • VarDict1D.values()

VarDictND#

Custom subclass of dict to store DOcplex model variables with N-dim tuple keys.

VarDictND

This class is not meant to be instantiated; VarDictND is built through the docplex_extensions.add_variables function.

Attributes#

VarDictND.model

DOcplex model associated with the variables.

VarDictND.vartype

DOcplex VarType corresponding to the variables.

VarDictND.key_names

Names to refer to each dimension of N-dim tuple keys.

VarDictND.value_name

Name to refer to Dict values.

Numerical operations#

VarDictND.sum(*pattern)

Sum all variables, or a subset based on wildcard pattern, in a linear expression.

Mapping operations#

VarDictND.get(key[, default])

Get the variable for the specified key, or the default if not found.

VarDictND.lookup(*key)

Get the variable for the specified key, or zero if it is not found.

Efficient subset selection#

VarDictND.subset_keys(*pattern)

Get a subset of the N-dim tuple keys of the Dict with a wildcard pattern.

VarDictND.subset_values(*pattern)

Get Dict values for all keys that match the wildcard pattern.

Views#

  • VarDictND.items()

  • VarDictND.keys()

  • VarDictND.values()