dimod.QuadraticModel.add_linear_from#
- QuadraticModel.add_linear_from(linear: Mapping[Hashable, float | floating | integer] | Iterable[tuple[Hashable, float | floating | integer]], *, default_vartype=None, default_lower_bound=None, default_upper_bound=None)[source]#
Add variables and linear biases to a quadratic model.
- Parameters:
linear – Variables and their associated linear biases, as either a dict of form
{v: bias, ...}
or an iterable of(v, bias)
pairs, wherev
is a variable andbias
is its associated linear bias.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 –