dimod
dimod is a shared API for samplers. It provides:
- classes for quadratic models---such as the binary quadratic model (BQM) class that contains Ising and QUBO models used by samplers such as the D-Wave system---and higher-order (non-quadratic) models.
- reference examples of samplers and composed samplers.
- abstract base classes for constructing new samplers and composed samplers.
(For explanations of the terminology, see the Ocean glossary.)
Example Usage
>>> import dimod
...
>>> # Construct a problem
>>> bqm = dimod.BinaryQuadraticModel({0: -1, 1: 1}, {(0, 1): 2}, 0.0, dimod.BINARY)
...
>>> # Use dimod's brute force solver to solve the problem
>>> sampleset = dimod.ExactSolver().sample(bqm)
>>> print(sampleset)
0 1 energy num_oc.
1 1 0 -1.0 1
0 0 0 0.0 1
3 0 1 1.0 1
2 1 1 2.0 1
['BINARY', 4 rows, 4 samples, 2 variables]
See the documentation for more examples.
Installation
Installation from PyPI:
pip install dimod
License
Released under the Apache License 2.0. See LICENSE file.
Contributing
Ocean's contributing guide has guidelines for contributing to Ocean packages.
dimod includes some formatting customization in the .clang-format and setup.cfg files.
Release Notes
dimod makes use of reno to manage its release notes.
When making a contribution to dimod that will affect users, create a new release note file by running
reno new your-short-descriptor-here
You can then edit the file created under releasenotes/notes/
.
Remove any sections not relevant to your changes.
Commit the file along with your changes.
See reno's user guide for details.