- Model.add_variables(lower=-inf, upper=inf, coords=None, name=None, mask=None, binary=False, integer=False, **kwargs)#
Assign a new, possibly multi-dimensional array of variables to the model.
Variables may be added with lower and/or upper bounds. Unless a coords argument is provided, the shape of the lower and upper bounds define the number of variables which will be added to the model under the name name.
float/array_like, optional) – Lower bound of the variable(s). Ignored if binary is True. The default is -inf.
TYPE, optional) – Upper bound of the variable(s). Ignored if binary is True. The default is inf.
list/xarray.Coordinates, optional) – The coords of the variable array. These are directly passed to the DataArray creation of lower and upper. For every single combination of coordinates a optimization variable is added to the model. The default is None.
str, optional) – Reference name of the added variables. The default None results in a name like “var1”, “var2” etc.
array_like, optional) – Boolean mask with False values for variables which are skipped. The shape of the mask has to match the shape the added variables. Default is None.
bool) – Whether the new variable is a binary variable which are used for Mixed-Integer problems.
bool) – Whether the new variable is a integer variable which are used for Mixed-Integer problems.
**kwargs – Additional keyword arguments are passed to the DataArray creation.
ValueError – If neither lower bound and upper bound have coordinates, nor coords are directly given.
linopy.Variable– Variable which was added to the model.
>>> from linopy import Model >>> import pandas as pd >>> m = Model() >>> time = pd.RangeIndex(10, name="Time") >>> m.add_variables(lower=0, coords=[time], name="x") Variable (Time: 10) ------------------- : x ∈ [0, inf] : x ∈ [0, inf] : x ∈ [0, inf] : x ∈ [0, inf] : x ∈ [0, inf] : x ∈ [0, inf] : x ∈ [0, inf] : x ∈ [0, inf] : x ∈ [0, inf] : x ∈ [0, inf]