Skip to main content

A shared API for binary quadratic model samplers.

Project description

https://img.shields.io/pypi/v/dimod.svg https://ci.appveyor.com/api/projects/status/2oc8vrxxh15ecgo1?svg=true https://codecov.io/gh/dwavesystems/dimod/branch/master/graph/badge.svg https://readthedocs.org/projects/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

License

Released under the Apache License 2.0. See LICENSE file.

Contribution

See CONTRIBUTING.rst file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
dimod-0.7.5-cp27-cp27m-macosx_10_13_x86_64.whl (208.0 kB) Copy SHA256 hash SHA256 Wheel cp27 Sep 18, 2018
dimod-0.7.5-cp27-cp27m-manylinux1_i686.whl (742.8 kB) Copy SHA256 hash SHA256 Wheel cp27 Sep 18, 2018
dimod-0.7.5-cp27-cp27m-manylinux1_x86_64.whl (766.6 kB) Copy SHA256 hash SHA256 Wheel cp27 Sep 18, 2018
dimod-0.7.5-cp27-cp27mu-manylinux1_i686.whl (742.9 kB) Copy SHA256 hash SHA256 Wheel cp27 Sep 18, 2018
dimod-0.7.5-cp27-cp27mu-manylinux1_x86_64.whl (766.5 kB) Copy SHA256 hash SHA256 Wheel cp27 Sep 18, 2018
dimod-0.7.5-cp27-cp27m-win32.whl (204.2 kB) Copy SHA256 hash SHA256 Wheel cp27 Sep 18, 2018
dimod-0.7.5-cp27-cp27m-win_amd64.whl (221.7 kB) Copy SHA256 hash SHA256 Wheel cp27 Sep 18, 2018
dimod-0.7.5-cp34-cp34m-macosx_10_13_x86_64.whl (208.1 kB) Copy SHA256 hash SHA256 Wheel cp34 Sep 18, 2018
dimod-0.7.5-cp34-cp34m-manylinux1_i686.whl (748.2 kB) Copy SHA256 hash SHA256 Wheel cp34 Sep 18, 2018
dimod-0.7.5-cp34-cp34m-manylinux1_x86_64.whl (776.3 kB) Copy SHA256 hash SHA256 Wheel cp34 Sep 18, 2018
dimod-0.7.5-cp34-cp34m-win32.whl (196.6 kB) Copy SHA256 hash SHA256 Wheel cp34 Sep 18, 2018
dimod-0.7.5-cp34-cp34m-win_amd64.whl (209.0 kB) Copy SHA256 hash SHA256 Wheel cp34 Sep 18, 2018
dimod-0.7.5-cp35-cp35m-macosx_10_13_x86_64.whl (208.1 kB) Copy SHA256 hash SHA256 Wheel cp35 Sep 18, 2018
dimod-0.7.5-cp35-cp35m-manylinux1_i686.whl (746.6 kB) Copy SHA256 hash SHA256 Wheel cp35 Sep 18, 2018
dimod-0.7.5-cp35-cp35m-manylinux1_x86_64.whl (774.1 kB) Copy SHA256 hash SHA256 Wheel cp35 Sep 18, 2018
dimod-0.7.5-cp35-cp35m-win32.whl (190.8 kB) Copy SHA256 hash SHA256 Wheel cp35 Sep 18, 2018
dimod-0.7.5-cp35-cp35m-win_amd64.whl (202.1 kB) Copy SHA256 hash SHA256 Wheel cp35 Sep 18, 2018
dimod-0.7.5-cp36-cp36m-macosx_10_13_x86_64.whl (208.3 kB) Copy SHA256 hash SHA256 Wheel cp36 Sep 18, 2018
dimod-0.7.5-cp36-cp36m-manylinux1_i686.whl (747.4 kB) Copy SHA256 hash SHA256 Wheel cp36 Sep 18, 2018
dimod-0.7.5-cp36-cp36m-manylinux1_x86_64.whl (775.2 kB) Copy SHA256 hash SHA256 Wheel cp36 Sep 18, 2018
dimod-0.7.5-cp36-cp36m-win32.whl (191.0 kB) Copy SHA256 hash SHA256 Wheel cp36 Sep 18, 2018
dimod-0.7.5-cp36-cp36m-win_amd64.whl (202.3 kB) Copy SHA256 hash SHA256 Wheel cp36 Sep 18, 2018
dimod-0.7.5-cp37-cp37m-macosx_10_13_x86_64.whl (207.9 kB) Copy SHA256 hash SHA256 Wheel cp37 Sep 18, 2018
dimod-0.7.5-cp37-cp37m-manylinux1_i686.whl (748.0 kB) Copy SHA256 hash SHA256 Wheel cp37 Sep 18, 2018
dimod-0.7.5-cp37-cp37m-manylinux1_x86_64.whl (775.4 kB) Copy SHA256 hash SHA256 Wheel cp37 Sep 18, 2018
dimod-0.7.5-cp37-cp37m-win32.whl (190.8 kB) Copy SHA256 hash SHA256 Wheel cp37 Sep 18, 2018
dimod-0.7.5-cp37-cp37m-win_amd64.whl (202.2 kB) Copy SHA256 hash SHA256 Wheel cp37 Sep 18, 2018
dimod-0.7.5.tar.gz (109.2 kB) Copy SHA256 hash SHA256 Source None Sep 18, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page