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.
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
An example of using one of the built-in test Samplers.
>>> 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) >>> response.samples_matrix matrix([[-1, -1], [ 1, -1], [ 1, 1], [-1, 1]])
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 Distribution
Hashes for dimod-0.6.7-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6433d5db2a8b00ba03d64b95298060bffb6b2520cadf44d297203451b561cf41 |
|
MD5 | 770329c89b43673b2974a5fa2a2f0561 |
|
BLAKE2b-256 | a26f9bfdabb2ffcd4fd1f8e32d22a2a05474800e48ef408f5cf41aae375ed5c3 |