Giter Club home page Giter Club logo

dwave_sapi_dimod's Introduction

D-Wave SAPI dimod

A dimod wrapper for SAPI.

Installation

For python 2

python setup.py install

Examples

Loading the module

>>> import dwave_sapi_dimod as sapi

Initializing a remote solver

>>> url = "http://myURL"
>>> token = "myToken001"
>>> solver_name = "solver_name"
>>> solver = sapi.SAPISampler(solver_name, url, token)

Initializing a local solver.

>>> solver_name = 'c4-sw_optimize'
>>> solver = sapi.SAPILocalSampler(solver_name)

sample_qubo and sample_ising work only for problems that fit directly onto the solver's structure

>>> h = {0: -.1, 4: .1}
>>> J = {(0, 4): -1}
>>> response = solver.sample_ising(h, J)
>>> list(response.samples())
[{0: -1, 4: -1}, {0: 1, 4: 1}, {0: 1, 4: -1}, {0: -1, 4: 1}]
>>> list(response.energies())
[-1.0, -1.0, 0.8, 1.2]

For solving arbitrary problems, you need to apply the EmbeddingComposite layer.

>>> solver = sapi.EmbeddingComposite(sapi.SAPILocalSampler(solver_name))
>>> h = {0: -.1, 1: .1}
>>> J = {(0, 1): -1}
>>> response = solver.sample_ising(h, J)
>>> list(response.samples())
[{0: -1, 1: -1}, {0: 1, 1: 1}, {0: 1, 1: -1}, {0: -1, 1: 1}]
>>> list(response.energies())
[-1.0, -1.0, 0.8, 1.2]

See dimod documentation for full description of the response object.

License

See LICENSE.txt

dwave_sapi_dimod's People

Contributors

arcondello avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.