Giter VIP home page Giter VIP logo

factoring's Introduction

Open in GitHub Codespaces Linux/Mac/Windows build status

Factoring

This code demonstrates the use of the D-Wave system to solve a factoring problem. This is done by turning the problem into a three-bit multiplier circuit.

Usage

A minimal working example using the main interface function can be seen by running:

python demo.py

The user is prompted to enter a six-bit integer: P, which represents a product to be factored.

Input product        ( 0 <= P <= 63):

The algorithm returns possible A and B values, which are the inputs the circuit multiplies to calculate the product, P.

Code Overview

Integer factoring is the decomposition of an integer into factors that, when multiplied together, give the original number. For example, the factors of 15 are 3 and 5.

D-Wave quantum computers allow us to factor numbers in an entirely new way, by turning a multiplication circuit into a constraint satisfaction problem that allows the quantum computer to compute inputs from a predefined output. Essentially, this means running the multiplication circuit in reverse!

A Boolean logic circuit is usually viewed as computing outputs from inputs based on the logic of the gates. However, the problem can also be thought of as seeking an assignment of values to the inputs and outputs consistent with the logic of all the gates in the circuit. This perspective of constraint satisfaction has no directionality. That is, input values do not need to flow through a series of gates to yield a result, as they do in a multiplication circuit.

License

Released under the Apache License 2.0. See LICENSE file.

factoring's People

Contributors

arcondello avatar bellert avatar fionahanington avatar hemantdwave avatar joelpasvolsky avatar m3ller avatar randomir avatar tleungdwave avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

factoring's Issues

How to config

Hi, sorry to ask a silly question. How to add user configuration. i dont have any idea.
Screenshot (70)

Factoring output

Factoring demo output is incredibly long. Perhaps do some clean up?

Enter a number to be factored:
Input product        ( 0 <= P <= 63): 24
Running on QPU
{'numberOfReads': 50,
 'results': [{'a': 7,
              'b': 4,
              'numOfOccurrences': 9,
              'percentageOfOccurrences': 18.0,
              'valid': False},
             {'a': 5,
              'b': 4,
              'numOfOccurrences': 2,
              'percentageOfOccurrences': 4.0,
              'valid': False},
             {'a': 4,
              'b': 5,
              'numOfOccurrences': 1,
              'percentageOfOccurrences': 2.0,
              'valid': False},
             {'a': 6,
              'b': 7,
              'numOfOccurrences': 6,
              'percentageOfOccurrences': 12.0,
              'valid': False},
             {'a': 7,
              'b': 6,
              'numOfOccurrences': 7,
              'percentageOfOccurrences': 14.0,
              'valid': False},
             {'a': 3,
              'b': 6,
              'numOfOccurrences': 1,
              'percentageOfOccurrences': 2.0,
              'valid': False},
             {'a': 6,
              'b': 3,
              'numOfOccurrences': 1,
              'percentageOfOccurrences': 2.0,
              'valid': False},
             {'a': 5,
              'b': 6,
              'numOfOccurrences': 4,
              'percentageOfOccurrences': 8.0,
              'valid': False},
             {'a': 6,
              'b': 5,
              'numOfOccurrences': 7,
              'percentageOfOccurrences': 14.0,
              'valid': False},
             {'a': 4,
              'b': 7,
              'numOfOccurrences': 3,
              'percentageOfOccurrences': 6.0,
              'valid': False},
             {'a': 3,
              'b': 4,
              'numOfOccurrences': 1,
              'percentageOfOccurrences': 2.0,
              'valid': False},
             {'a': 6,
              'b': 1,
              'numOfOccurrences': 1,
              'percentageOfOccurrences': 2.0,
              'valid': False},
             {'a': 2,
              'b': 5,
              'numOfOccurrences': 1,
              'percentageOfOccurrences': 2.0,
              'valid': False},
             {'a': 7,
              'b': 3,
              'numOfOccurrences': 1,
              'percentageOfOccurrences': 2.0,
              'valid': False},
             {'a': 7,
              'b': 2,
              'numOfOccurrences': 2,
              'percentageOfOccurrences': 4.0,
              'valid': False},
             {'a': 4,
              'b': 0,
              'numOfOccurrences': 1,
              'percentageOfOccurrences': 2.0,
              'valid': False},
             {'a': 4,
              'b': 6,
              'numOfOccurrences': 1,
              'percentageOfOccurrences': 2.0,
              'valid': True},
             {'a': 6,
              'b': 6,
              'numOfOccurrences': 1,
              'percentageOfOccurrences': 2.0,
              'valid': False}],
 'timing': {'actual': {'qpuProcessTime': 25160}}}

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.