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 quantum computer---and higher-order (non-quadratic) models.
- Reference examples of samplers and composed samplers.
- Abstract base classes for constructing new samplers and composed samplers.
>>> 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]
For explanations of the terminology, see the Ocean glossary.
See the documentation for more examples.
Installation
Installation from PyPI:
License
Released under the Apache License 2.0. See LICENSE file.
Contributing
Ocean's contributing section 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.