Releases: dwavesystems/dimod
Releases · dwavesystems/dimod
0.10.7
New Features
- Add
ConstrainedQuadraticModel.is_equal()
andConstrainedQuadraticModel.is_almost_equal()
methods. See #1012
- Add
QuadraticModel.is_almost_equal()
method
- Support equality checks between quadratic models and binary quadratic models in
BinaryQuadraticModel.is_equal()
,BinaryQuadraticModel.is_almost_equal()
,QuadraticModel.is_equal()
, andQuadraticModel.is_almost_equal()
methods.
- Add
GraphLike
type hint todimod.typing
.
- Add
ConstrainedQuadraticModel.iter_constraint_data()
,ConstrainedQuadraticModel.iter_violations()
andConstrainedQuadraticModel.violations()
methods. See 971.
- Added
from_lp_file
classmethod toConstrainedQuadraticModel
that reads input LP file and converts it to CQM instance.
ConstrainedQuadraticModel.set_objective
now accepts an iterable.
- Add
ConstrainedQuadraticModel.check_feasible
method.
- Add
random_bin_packing
function with the same functionality as the (now deprecated)bin_packing
.
- Add
SampleSet.filter()
method that returns a sample set with data rows filtered by a given predicate.
- Add
.to_dict()
and.from_dict()
methods to the sample inverter returned by thecqm_to_bqm
function. The methods return a json serializable representation of the inversion for storage if needed. See 977.
- Add
random_multi_knapsack
function with the same functionality as the (now deprecated)multi_knapsack
.
- Add
random_knapsack
function with the same functionality as the (now deprecated)knapsack
.
- Allow the offset of a
BinaryQuadraticModel
to be specified as a keyword argument.
Upgrade Notes
- The
cls
keyword argument of thechimera_anticluster
function now does nothing.
Deprecation Notes
- Deprecate
cls
keyword argument of thechimera_anticluster
function.
- Deprecate
bin_packing
function in favour ofrandom_bin_packing
.
- Deprecate
multi_knapsack
function in favour ofrandom_multi_knapsack
.
- Deprecate
knapsack
function in favour ofrandom_knapsack
.
Bug Fixes
QuadraticModel
can now be multiplied by a number in place.
- Fix energy calculations for integer variables with large values. See #982.
- Make
dimod.BinaryQuadraticModel
a virtual subclass ofdimod.core.bqm.BQM
.
0.9.16
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.
0.10.5
New Features
- Add
QuadraticModel.set_upper_bound
andQuadraticModel.set_lower_bound
methods.
Upgrade Notes
- The
preprocessing
extra install argument has been removed.
- Remove
dimod.meta
namespace. Its functionality,SamplerABCMeta
andsamplemixinmethod
, has been migrated to thedimod.core.sampler
namespace.
Bug Fixes
- Fix
QuadraticModel.energies
when given samples with values greater than the maximum value representable by an 8 bit integer. Previously samples were incorrectly cast to 8 bit integers.
- When a
QuadraticModel
already has an integer variable, adding it withQuadraticModel.add_variable
with different lower or upper bounds now correctly raises an exception. Likewise, adding or multiplying the same variable symbolically with different bounds will also raise an exception.
- When a
ConstrainedQuadraticModel
already has an integer variable, adding it as part of a constraint or objective with different lower or upper bounds now correctly raises an exception.
- Make
dimod.INTEGER
correctly deepcopy-able.
- Fix (deprecated)
AdjVectorBQM.to_file
andAdjVectorBQM.from_file
. See #898.
- Fix
BinaryQuadraticModel.energies
for aBQM
withdtype=object
and a single variable with an integer bias. Previously it would raise anumpy.core._exceptions._UFuncOutputCastingError
.
- Fix energy calculation when the lower bound (lb) equals the upper bound (lb) in
DiscreteQuadraticModel.add_linear_inequality_constraint
andBinaryQuadraticModel.add_linear_inequality_constraint
.
- Promote dwave-preprocessing to a full dependency of dimod to avoid issues that occur when dimod is a required package but dwave-preprocessing is not.
0.10.4
Bug Fixes
- Fix
QuadraticModel.energies
when given samples with values greater than the maximum value representable by an 8 bit integer. Previously samples were incorrectly cast to 8 bit integers.
- Fix energy calculation when the lower bound (lb) equals the upper bound (lb) in
DiscreteQuadraticModel.add_linear_inequality_constraint
andBinaryQuadraticModel.add_linear_inequality_constraint
.
0.10.3
New Features
- Add
QuadraticModel.change_vartype()
method.
- Add C++
dimod::QuadraticModel::change_vartype()
method. Also add non-const versions ofdimod::QuadraticModel::vartype()
,dimod::QuadraticModel::lower_bound()
, anddimod::QuadraticModel::upper_bound()
.
Bug Fixes
- Fix
QuadraticModel.spin_to_binary
not correctly updating the variable type of the changed variables.
0.10.2
Bug Fixes
- Fix case where adding linear and quadratic biases whose class requires arguments on construction to a
BinaryQuadraticModel
withobject
dtype could fail.
0.10.1
New Features
- Add an optional
label
keyword argument toConstrainedQuadraticModel.add_discrete
. The method also now returns the assigned label, whether supplied or generated. This is consistent withConstrainedQuadraticModel.add_constraint
.
cyBQM
andcyQM
fused types can now be cimported from thedimod
namespace.
- Add
.data()
method tocyQM_template
andcyBQM_template
that returns a const pointer to the underlying C++QuadraticModel
andBinaryQuadraticModel
respectively.
Upgrade Notes
BinaryQuadraticModel.data.vartype()
is now accessed as a method rather than as an attribute. This is consistent withQuadraticModel.data.vartype()
.BinaryQuadraticModel.vartype
is still an attribute.
from dimod cimport cyBQM
now is a fused type containingcyBQM_float32
andcyBQM_float64
. You can use thecyBQM
containingcyAdjVectorBQM
withfrom dimod.bqm cimport cyBQM
.
Bug Fixes
- Fix wrong behaviour when the lower bound (lb) equals the upper bound (lb) in
add_linear_equality_constraint
. Correct behaviour is to add constraint as eqaulity when lb is equal ub.
0.10.0
Update version 0.10.0rc1 -> 0.10.0
0.10.0rc1
Release Notes
0.10.0rc1
New Features
- Add
num_quadratic_variables
to the header of the file created byConstrainedQuadraticModel.to_file
. This increments the version to 1.1.
- You can now install preprocessing as part of the dimod install with
pip install dimod[preprocessing]
Deprecation Notes
-
Some composites have been migrated to
dwave-preprocessing
. The affected composites:ClipComposite
ConnectedComponentsComposite
FixedVariableComposite
RoofDualityComposite
ScaleComposite
SpinReversalTransformComposite
you no longer can use the composites without having
dwave-preprocessing
installed. Using them with it installed results in a deprecation warning.