0.10.6
New Features
- Add
Binaries,SpinsandIntegersfunctions. See #918.
- Add
DiscreteQuadraticModel.get_casesmethod to matchCaseLabelDQM.get_cases.
- Implement
QuadraticModel.remove_interactionmethod, previously it raised aNotImplementedErrorerror.
- Add
linearoption as a newslack_methodforDiscreteQuadraticModel.add_linear_inequality_constraintmethod. 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
quicksumfunction for faster summation ofQuadraticModelandBinaryQuadraticModel. Python's built-insumcontinues to work, butquicksumwill 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_modelwith an aliasConstrainedQuadraticModel.from_dqmConstrainedQuadraticModel.from_quadratic_modelwith two aliasesConstrainedQuadraticModel.from_qmandConstrainedQuadraticModel.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_bqmfunction.
- Add
ConstrainedQuadraticModel.substitute_self_loopsmethod that replaces integer self-loops by introducing a new variable and adding a constraint.
- Add
copy_alwaysparameter toInitialized.parse_initial_states.
-
Add new binary quadratic model generators for simple logic gates:
dimod.generators.and_gatedimod.generators.fulladder_gatedimod.generators.halfadder_gatedimod.generators.or_gatedimod.generators.xor_gate
See #951.
QuadraticModel.energies,QuadraticModel.energy,BinaryQuadraticModel.energies, andBinaryQuadraticModel.energynow 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.Integerare no longer required positional arguments. By default, unique labels are applied via the uuid module.
Upgrade Notes
ConstrainedQuadraticModel.objectiveis now always aQuadraticModel. Previously it could either be aBinaryQuadraticModelor aQuadraticModel.
ConstrainedQuadraticModel.objectivenow 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_boundsattributes.
- Deprecate
ConstrainedQuadraticModel.variables.vartype()method.
Bug Fixes
dimod::QuadraticModelBase.remove_interactionnow correctly returnstruewhen removing a self-loop.
- Return
boolrather thannumpy.bool_fromQuadraticModel.is_equalandBinaryQuadraticModel.is_equalwhen comparing empty models to numbers.
- Fix
as_samplesandInitialized.parse_initial_statesby ensuring that thecopyargument is not ignored inas_samplesandInitialized.parse_initial_statesdoes not modify any input data. See #861.
- Remove unused
ConstrainedQuadraticModel.labelsinstance variable.
- Fix adding constraints with integer variables via
ConstrainedQuadraticModel.add_constraint_from_iterablewhen those integer variables have pre-existing lower or upper bounds. See #943.
- Correctly account for the offset when multiplying binary quadratic models
BinaryQuadraticModel.energiesnow has consistent behaviour accross all data types when given samples containing a superset of the variables in the model. Previously binary quadratic models withobjectdata type would allow a superset of variables, whilefloat64andfloat32would not.