- classmethod LinearExpression.from_tuples(*tuples, model=None, chunk=None)#
Create a linear expression by using tuples of coefficients and variables.
The function internally checks that all variables in the tuples belong to the same reference model.
variables)) – Each tuple represents one term in the resulting linear expression, which can possibly span over multiple dimensions:
The coefficient(s) in the term, if the coefficients array contains dimensions which do not appear in the variables, the variables are broadcasted.
The variable(s) going into the term. These may be referenced by name.
>>> from linopy import Model >>> import pandas as pd >>> m = Model() >>> x = m.add_variables(pd.Series([0, 0]), 1) >>> y = m.add_variables(4, pd.Series([8, 10])) >>> expr = LinearExpression.from_tuples((10, x), (1, y))
This is the same as calling
10*x + ybut a bit more performant.