dimod is a shared API for samplers. It provides:
- a binary quadratic model (BQM) class that contains Ising and quadratic unconstrained binary optimization (QUBO) models used by samplers such as the D-Wave system.
- a discrete quadratic model (DQM) class 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.)
>>> 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.
Compatible with Python 3.6+:
pip install dimod
To install from source (requires pip>=10.0.0
):
pip install -r requirements.txt
python setup.py install
When developing on dimod, it is often convenient to build the extensions in place:
pip install -r requirements.txt
python setup.py build_ext --inplace
Released under the Apache License 2.0. See LICENSE file.
Ocean's contributing guide has guidelines for contributing to Ocean packages.
dimod includes some formatting customization in the .clang-format and setup.cfg files.
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.