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, wherevis a variable andbiasis its associated linear bias.default_vartype – The vartype of any variables not already in the model. If
default_vartypeisNonethen missing variables raise aValueError.default_lower_bound – The lower bound of any variables not already in the model. Ignored if
default_vartypeisNoneor when the variable isBINARYorSPIN.default_upper_bound – The upper bound of any variables not already in the model. Ignored if
default_vartypeisNoneor when the variable isBINARYorSPIN.
- Raises:
ValueError – If the variable is not in the model and
default_vartype` is None –