A shared API for binary quadratic model samplers.
Project description
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for dimod-0.7.6-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec13967a87e694ac553f8659e197ba1a408263208954fed21785ad9bf63f6214 |
|
MD5 | 80f3ddc9a2d3577428e13fabf4443299 |
|
BLAKE2b-256 | d204bd339c34a995a74c8ecc3c7a96040ca59e8c0b72dbeab54d7fc73a46df7d |
Hashes for dimod-0.7.6-cp37-cp37m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1771228a9d32f0b9968e0679c254fb6f9cbd2904f45b37b51aab889f04f4c4c2 |
|
MD5 | ee052c67ba423a58ee2ffb20c4550d3c |
|
BLAKE2b-256 | c220d6948420a23ac8723a6a5d125386797454d8247aaaeb393d9f28442830ff |
Hashes for dimod-0.7.6-cp37-cp37m-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1611a4ef62daf6272bd5ea381492d4f7f1e23677dc98edbc06d6282d64e8ea6 |
|
MD5 | 12bbcef058f52a4f1060fee431541f1c |
|
BLAKE2b-256 | c9f4bf0ca8734e8efb9e279d34dd153725ca626b9caae0ba76964bafcebb9751 |
Hashes for dimod-0.7.6-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8bd4969db7bc569faa9a617395b8cf4d5f43a8a64f5ce97b05d3143a4817ef2 |
|
MD5 | 9de6bc7527e11b0133dc80a5f094dad0 |
|
BLAKE2b-256 | e25a8715b143cc4adbead8555eea39c17bad9f03f72ead7ea1c06f318c39a660 |
Hashes for dimod-0.7.6-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c21cdbed08af15694db47eb5a28047af824cb656dfe5a69f84ea1a0ca26d6d2 |
|
MD5 | b792a82590955e4511c5b601085d93eb |
|
BLAKE2b-256 | 25e9e88e2c76914ec5fc49d2b507e3264bfa170cfaae50f5a463d5e75d49331c |
Hashes for dimod-0.7.6-cp36-cp36m-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 221e8fc885f1a8031aed788d3bff380792440451f0a822e3d01fee06df17560f |
|
MD5 | 90478f4abddaff16a2c8141239c3c3f4 |
|
BLAKE2b-256 | 9d479dae50a01c5338ec1cadd59846a4bdc0d8d3378805d5d2b9b79156184318 |
Hashes for dimod-0.7.6-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7eee5323f2e44400b6b4546c7e5499fe0145266d7cce2c795d5d4bc2519ed46 |
|
MD5 | 187d3e29d046a8ee11ed038f7366964c |
|
BLAKE2b-256 | f7c5a645b9d492bc11cfda0501d1c2a47f8e77ab1dfc62ff90d755220ead8b02 |
Hashes for dimod-0.7.6-cp35-cp35m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6546dbbfa89f20fc7f6eb1ce3b9dbed3d5620bf7f3b063f877cdd8c725da7950 |
|
MD5 | 4845941376f883a3d093dde95d16a6b9 |
|
BLAKE2b-256 | 23a23595ad22ae6ded0519ae6ddf7c1729c75b4b4054ef1c2606303029217e1c |
Hashes for dimod-0.7.6-cp35-cp35m-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3fc7043eb9d125a8fcdca5864c86c2d5144381b17e36143c6484058d36b161e8 |
|
MD5 | bea63bcdc9617f2cd2b91bf6a98936e3 |
|
BLAKE2b-256 | 828ceccf26225ba5c8faf52af81241ef91a9d9889f13549a0a9ce1f93850841b |
Hashes for dimod-0.7.6-cp34-cp34m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ea91124498f032383059ec7fe08f5c05b716c91d503fb123d69ccc3e108ce88 |
|
MD5 | 6ab487f8f17b623f2ba0a081b1cef131 |
|
BLAKE2b-256 | 58102f9788f017f43ffab32ffc133e6bd450ebb98de83d089aefab05330dda13 |
Hashes for dimod-0.7.6-cp34-cp34m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 386b1e1dc0338a905d98092c69efbc2dfe6ffe704f72d88485cd6f354405d244 |
|
MD5 | 620b3ed62cb7536d0e2479bbd1056086 |
|
BLAKE2b-256 | e38dc8e798d6c9d04cc254f09cdd6b82a50bb7b2114e44130432356b888253ad |
Hashes for dimod-0.7.6-cp34-cp34m-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f98a5f9453a1b5aa16d27ae86e8ef66119f4e72683885d6446f430008759547a |
|
MD5 | b38e17a334f4547ec0c8405bd838bd72 |
|
BLAKE2b-256 | 13442894a3bcb5b744380acb041ef36fcb04e21af7c159a315559485a894b4b1 |
Hashes for dimod-0.7.6-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cad6ef89696e091908c5bec623629fc3d77ac9d25dd86d6d144103f4d4cececc |
|
MD5 | 32b609cb9e6bdf4e4fa1be38e738af51 |
|
BLAKE2b-256 | 759f3bcaec3e26a097f7559fa95d96d1721c3dfcb32a33a88fdddf69d03a9789 |
Hashes for dimod-0.7.6-cp27-cp27mu-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08c9f73f66cdacd441f78dc44a808c2d9afd2717adb4932b86b228fa15ce0187 |
|
MD5 | eba885f840709f51e29948ed7eb66e46 |
|
BLAKE2b-256 | f66f4f120ff9876fbf8b34c3d39f88b04c2563c5d3f59b9d21e51a3096a9359f |
Hashes for dimod-0.7.6-cp27-cp27m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8cd77036077a3a813ff6e8df2aba9801419907ba9b5f682bccc22be0ca0bf0c9 |
|
MD5 | 27786c3cd866d0769f27a61c19dfec46 |
|
BLAKE2b-256 | cc582ea1cfab1b55e512931ce4238bf98b7ee4cf7566ba6187b6b149d8bf8031 |
Hashes for dimod-0.7.6-cp27-cp27m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21794dd90225361a3c0fbb1763c0bc55c85db1dcf0885d41d2d925f7e772670b |
|
MD5 | 5e5a825557ce2df180009e830a27d0dd |
|
BLAKE2b-256 | 6efee940a45030b6dbd802c371432f1d510464bae35d8564797db9303689fa12 |
Hashes for dimod-0.7.6-cp27-cp27m-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1320a2f6cdb7320e068e1fff665eceb1cfba5f42f1d114ae6368f6e17d93564 |
|
MD5 | 8408bafe7942e81b0a39167fadbc6f26 |
|
BLAKE2b-256 | 4d310f11f5f0532304ef439041350cd5eeed21d47ff08c1cf0a1af13c5d4713b |