Skip to content

0.10.6

Compare
Choose a tag to compare
@arcondello arcondello released this 25 Aug 14:21
· 1158 commits to main since this release
74ac365

New Features

  • Add Binaries, Spins and Integers functions. See #918.
  • Add DiscreteQuadraticModel.get_cases method to match CaseLabelDQM.get_cases.
  • Implement QuadraticModel.remove_interaction method, previously it raised a NotImplementedError error.
  • Add linear option as a new slack_method for DiscreteQuadraticModel.add_linear_inequality_constraint method. This will add only one discrete variable to an inequality constraint with linear number of cases, according to right hand side value of the constraint.
  • Add quicksum function for faster summation of QuadraticModel and BinaryQuadraticModel. Python's built-in sum continues to work, but quicksum will generally be faster when adding many objects.
  • Add a generator, dimod.generators.binary_encoding, to create a binary quadratic model that encodes an integer.
  • Add methods to construct a constrained quadratic model from other model types:

    • ConstrainedQuadraticModel.from_discrete_quadratic_model with an alias ConstrainedQuadraticModel.from_dqm
    • ConstrainedQuadraticModel.from_quadratic_model with two aliases ConstrainedQuadraticModel.from_qm and ConstrainedQuadraticModel.from_bqm

    See #866.

  • Add QuadraticModel.add_quadratic_from() method.
  • Add QuadraticModel.add_linear_from() method.
  • Add ConstrainedQuadraticModel.lower_bound() and ConstrainedQuadraticModel.upper_bound() methods.
  • Add cqm_to_bqm function.
  • Add ConstrainedQuadraticModel.substitute_self_loops method that replaces integer self-loops by introducing a new variable and adding a constraint.
  • Add copy_always parameter to Initialized.parse_initial_states.
  • Add new binary quadratic model generators for simple logic gates:

    • dimod.generators.and_gate
    • dimod.generators.fulladder_gate
    • dimod.generators.halfadder_gate
    • dimod.generators.or_gate
    • dimod.generators.xor_gate

    See #951.

  • QuadraticModel.energies, QuadraticModel.energy, BinaryQuadraticModel.energies, and BinaryQuadraticModel.energy now all support samples containing a superset of the variables in the model. Any variables not in the model are ignored when calculating the energy.
  • Labels for dimod.Spin, dimod.Binary, and dimod.Integer are no longer required positional arguments. By default, unique labels are applied via the uuid module.

Upgrade Notes

  • ConstrainedQuadraticModel.objective is now always a QuadraticModel. Previously it could either be a BinaryQuadraticModel or a QuadraticModel.
  • ConstrainedQuadraticModel.objective now contains all variables in the constrained quadratic model. Previously it could contain a subset of the variables.

Deprecation Notes

  • Deprecate ConstrainedQuadraticModel.variables.vartypes, ConstrainedQuadraticModel.variables.lower_bounds, and ConstrainedQuadraticModel.variables.upper_bounds attributes.
  • Deprecate ConstrainedQuadraticModel.variables.vartype() method.

Bug Fixes

  • dimod::QuadraticModelBase.remove_interaction now correctly returns true when removing a self-loop.
  • Return bool rather than numpy.bool_ from QuadraticModel.is_equal and BinaryQuadraticModel.is_equal when comparing empty models to numbers.
  • Fix as_samples and Initialized.parse_initial_states by ensuring that the copy argument is not ignored in as_samples and Initialized.parse_initial_states does not modify any input data. See #861.
  • Remove unused ConstrainedQuadraticModel.labels instance variable.
  • Fix adding constraints with integer variables via ConstrainedQuadraticModel.add_constraint_from_iterable when those integer variables have pre-existing lower or upper bounds. See #943.
  • Correctly account for the offset when multiplying binary quadratic models
  • BinaryQuadraticModel.energies now has consistent behaviour accross all data types when given samples containing a superset of the variables in the model. Previously binary quadratic models with object data type would allow a superset of variables, while float64 and float32 would not.