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 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