Giter Site home page Giter Site logo

beartooth-demo's Introduction

Beartooth demo

The idea of this demo is to provide a visual to reinforce the 'sampling as water flowing to low points in a landsape' description of the D-Wave computer.

Details

The landscape is a discrete nxn grid of altitudes, f(x, y); we will construct a QUBO problem where samples that encode locations take on the energy equal to the altitude at that location. (and samples that do not represent valid locations have higher energy than...)

We chose a unary encoding for coordinates. Thus each coordinate will need n - 1 bits, x0, x1, ..., xn-2, and y0, y1, ..., yn-2. E.g. on a 4x4 grid:

  x   encoded
  0   000
  1   100
  2   110
  3   111

So the QUBO will have 2 * (n - 1) variables. To set the energy of the samples to be the altitudes, we make use of the unary encoding to telescope the energies:

for i in range(0, n-1):
    Q[xi, xi] = f(i + 1, 0) - f(i, 0)
    Q[yi, yi] = f(0, i + 1) - f(0, i)
for i in range(0, n-1):
    for j in range(0, n-1):
        Q[xi, yj] = f(i + 1, j + 1) - f(i, j + 1) - f(i, j + 1) + f(i, j)

And add the constant offset f(0, 0), which we basically ignore in this code. To bias the QUBO to return valid coordinates, we add the following:

for i in range(1, n-1):
    Q[xi-1,xi] = -ENCODING_BIAS
    Q[xi, xi] = ENCODING_BIAS

This will add at least ENCODING_BIAS to the energy for invalid samples.

beartooth-demo's People

Contributors

adam-douglass avatar jdklassen avatar

Watchers

 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.