0.10.6
New Features
- Add
Binaries
,Spins
andIntegers
functions. See #918.
- Add
DiscreteQuadraticModel.get_cases
method to matchCaseLabelDQM.get_cases
.
- Implement
QuadraticModel.remove_interaction
method, previously it raised aNotImplementedError
error.
- Add
linear
option as a newslack_method
forDiscreteQuadraticModel.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 ofQuadraticModel
andBinaryQuadraticModel
. Python's built-insum
continues to work, butquicksum
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 aliasConstrainedQuadraticModel.from_dqm
ConstrainedQuadraticModel.from_quadratic_model
with two aliasesConstrainedQuadraticModel.from_qm
andConstrainedQuadraticModel.from_bqm
See #866.
- Add
QuadraticModel.add_quadratic_from()
method.
- Add
QuadraticModel.add_linear_from()
method.
- Add
ConstrainedQuadraticModel.lower_bound()
andConstrainedQuadraticModel.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 toInitialized.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
, andBinaryQuadraticModel.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
, anddimod.Integer
are no longer required positional arguments. By default, unique labels are applied via the uuid module.
Upgrade Notes
ConstrainedQuadraticModel.objective
is now always aQuadraticModel
. Previously it could either be aBinaryQuadraticModel
or aQuadraticModel
.
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
, andConstrainedQuadraticModel.variables.upper_bounds
attributes.
- Deprecate
ConstrainedQuadraticModel.variables.vartype()
method.
Bug Fixes
dimod::QuadraticModelBase.remove_interaction
now correctly returnstrue
when removing a self-loop.
- Return
bool
rather thannumpy.bool_
fromQuadraticModel.is_equal
andBinaryQuadraticModel.is_equal
when comparing empty models to numbers.
- Fix
as_samples
andInitialized.parse_initial_states
by ensuring that thecopy
argument is not ignored inas_samples
andInitialized.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 withobject
data type would allow a superset of variables, whilefloat64
andfloat32
would not.