Skip to content
A shared API for QUBO/Ising samplers.
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci Use 3.7 for doctests in circleci to match rtd Mar 13, 2019
.github/ISSUE_TEMPLATE Update issue templates Aug 13, 2018
benchmarks Fix benchmark for as_samples Jan 8, 2019
dimod Raise the correct exception in child_structure_dfs Jun 17, 2019
docs Merge pull request #488 from arcondello/feature/dfs-on-child-samplers Jun 5, 2019
tests Raise the correct exception in child_structure_dfs Jun 17, 2019
.appveyor.yml Only build wheel on tag Dec 27, 2018
.coveragerc Document and unittest new methods in BinaryQuadraticModel Jan 15, 2018
.gitignore Add benchmarks using asv Jan 4, 2019
CONTRIBUTING.rst Use intersphinx instead of explicit links Sep 14, 2018
LICENSE Conform to boilerplate from template Feb 27, 2018
MANIFEST.in Refactor JSON-serialization Feb 26, 2019
README.rst Fixed Broken Link Dec 14, 2018
requirements.txt Support simplejson encoding Mar 4, 2019
setup.cfg
setup.py Make views a subpackage Mar 18, 2019

README.rst

https://ci.appveyor.com/api/projects/status/2oc8vrxxh15ecgo1/branch/master?svg=true https://readthedocs.com/projects/d-wave-systems-dimod/badge/?version=latest https://circleci.com/gh/dwavesystems/dimod.svg?style=svg

dimod

dimod is a shared API for binary quadratic 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. It also provides utilities for constructing new samplers and composed samplers and for minor-embedding. Its reference examples include several samplers and composed samplers.

Learn more about dimod on Read the Docs.

Example Usage

This example constructs a simple QUBO and converts it to Ising format.

>>> import dimod
>>> bqm = dimod.BinaryQuadraticModel({0: -1, 1: -1}, {(0, 1): 2}, 0.0, dimod.BINARY)  # QUBO
>>> bqm_ising = bqm.change_vartype(dimod.SPIN, inplace=False)  # Ising

This example uses one of dimod's test samplers, ExactSampler, a solver that calculates the energies of all possible samples.

>>> import dimod
>>> h = {0: 0.0, 1: 0.0}
>>> J = {(0, 1): -1.0}
>>> bqm = dimod.BinaryQuadraticModel.from_ising(h, J)
>>> response = dimod.ExactSolver().sample(bqm)
>>> for sample, energy in response.data(['sample', 'energy']): print(sample, energy)
{0: -1, 1: -1} -1.0
{0: 1, 1: 1} -1.0
{0: 1, 1: -1} 1.0
{0: -1, 1: 1} 1.0

See the documentation for more examples.

Installation

Compatible with Python 2 and 3:

pip install dimod

To install with optional components:

pip install dimod[all]

To install from source:

pip install -r requirements.txt
python setup.py install

Note that for an installation from source some functionality requires that your system have Boost C++ libraries installed.

License

Released under the Apache License 2.0. See LICENSE file.

Contribution

See CONTRIBUTING.rst file.

You can’t perform that action at this time.