dimod.QuadraticModel.add_linear#
- QuadraticModel.add_linear(v: Hashable, bias: float | floating | integer, *, default_vartype=None, default_lower_bound=None, default_upper_bound=None)[source]#
Add a linear bias to an existing variable or a new variable with specified vartype.
- Parameters:
v – Variable label.
bias – Linear bias for the variable.
default_vartype – The vartype of any variables not already in the model. If
default_vartype
isNone
then missing variables raise aValueError
.default_lower_bound – The lower bound of any variables not already in the model. Ignored if
default_vartype
isNone
or when the variable isBINARY
orSPIN
.default_upper_bound – The upper bound of any variables not already in the model. Ignored if
default_vartype
isNone
or when the variable isBINARY
orSPIN
.
- Raises:
ValueError – If the variable is not in the model and
default_vartype` is None –