dimod.QuadraticModel.add_linear_from

QuadraticModel.add_linear_from(linear: Union[Mapping[Hashable, Union[float, numpy.floating, numpy.integer]], Iterable[Tuple[Hashable, Union[float, numpy.floating, numpy.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, where v is a variable and bias is its associated linear bias.

  • default_vartype – The vartype of any variables not already in the model. If default_vartype is None then missing variables raise a ValueError.

  • default_lower_bound – The lower bound of any variables not already in the model. Ignored if default_vartype is None or when the variable is BINARY or SPIN.

  • default_upper_bound – The upper bound of any variables not already in the model. Ignored if default_vartype is None or when the variable is BINARY or SPIN.

Raises
  • ValueError – If the variable is not in the model and

  • default_vartype` is None