Ocean-compatible collection of greedy/brute-force solvers/samplers
Project description
dwave-greedy
An implementation of a steepest descent solver for binary quadratic models.
Steepest descent is the discrete analogue of gradient descent, but the best move is computed using a local minimization rather rather than computing a gradient. At each step, we determine the dimension along which to descend based on the highest energy drop caused by a variable flip.
>>> import greedy
...
>>> solver = greedy.SteepestDescentSolver()
>>> sampleset = solver.sample_ising({0: 2, 1: 2}, {(0, 1): -1})
...
>>> print(sampleset)
0 1 energy num_oc.
0 -1 -1 -5.0 1
['SPIN', 1 rows, 1 samples, 2 variables]
Installation
Install from a package on PyPI:
pip install dwave-greedy
or install from source:
USE_CYTHON=1 pip install git+https://github.com/dwavesystems/dwave-greedy.git#egg=dwave-greeedy
Note: USE_CYTHON=1 forces Cythonization and proper build from source. When building from PyPI package source (which includes Cythonized files), this is not necessary.
To build from source:
pip install -r requirements.txt
python setup.py build_ext --inplace
python setup.py install
Examples
Simple frustrated Ising triangle:
import dimod
import greedy
# Construct a simple problem
bqm = dimod.BQM.from_qubo({'ab': 1, 'bc': 1, 'ca': 1})
# Instantiate the sampler
sampler = greedy.SteepestDescentSampler()
# Solve the problem
result = sampler.sample(bqm)
Large RAN1 sparse problem (requires NetworkX package):
import dimod
import greedy
import networkx
# Generate random Erdős-Rényi sparse graph with 10% density
graph = networkx.fast_gnp_random_graph(n=1000, p=0.1)
# Generate RAN1 problem on the sparse graph
bqm = dimod.generators.random.ran_r(r=1, graph=graph)
# Instantiate the sampler
sampler = greedy.SteepestDescentSampler()
# Run steepest descent for 100 times, each time from a random state
sampleset = sampler.sample(bqm, num_reads=100)
# Print the best energy
print(min(sampleset.record.energy))
License
Released under the Apache License 2.0. See LICENSE 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 dwave_greedy-0.1.2-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ad775cf35307c840514ec21d076332b9bb859fe22f716442cf9a927fe22617f |
|
MD5 | 13c9f27983070db8a2dfd5a408411ba0 |
|
BLAKE2b-256 | c8aad59b867261de1a9be7917a86f7e321f9675131f5a344dc3f02531a886f9e |
Hashes for dwave_greedy-0.1.2-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bfa4ebbc57d4a10090171f6f9ac31d2908803027ec297321cb66a0e2dbd154b5 |
|
MD5 | 2ededc0eced6e22589ca8c4950a5f078 |
|
BLAKE2b-256 | 37c46212e7b3dc462dc9f0157c8883d97468ae7be2072f0692d624b25c8050cc |
Hashes for dwave_greedy-0.1.2-cp39-cp39-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61b9164fb57fd0ee1f95e760a02b15dd1411af6b7d199c5d0ea15f85f51d0ba4 |
|
MD5 | 9b0c49ce886d1722ebdcb235ece25391 |
|
BLAKE2b-256 | 0436ff13db6d27f8495aa0d5f7f5ba42dbecd5218c1c157ee65c8d1b9797f4db |
Hashes for dwave_greedy-0.1.2-cp39-cp39-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39fd9d939f3e31c351bd68a8fe5972c1ea5d3249caf48d94d9e16be7ba870184 |
|
MD5 | c07da835e93ff9e8f83e59c0a034f262 |
|
BLAKE2b-256 | 136aa4dc000e9fed001434d53916b074d66c85af493cb8f2041256752f014d85 |
Hashes for dwave_greedy-0.1.2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | db1382cd6fb53231c27ba9e60dec616c0919ceb8833878559786bed1d5933be3 |
|
MD5 | 46562d3187ec3b07a21bd53a1cbd2c42 |
|
BLAKE2b-256 | d51b88b83ff4c83e00df606ee41d4198c3ef17c1f49e9a137ffc4cdf08697ae6 |
Hashes for dwave_greedy-0.1.2-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3220c54db1b75463a93210fe4293e1a32997007561a1bab69e7a8a649cdd78b8 |
|
MD5 | 1bcc174f4601b8cac9d92b77d2b71231 |
|
BLAKE2b-256 | ae674abab29175c21150daa75de950ca44f5b60b6f441a27d6686bfe7e34ece4 |
Hashes for dwave_greedy-0.1.2-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83821cece83675c205f6ea27137f409c859a20945670acfc5aa58dc97225b4fa |
|
MD5 | d71605f5b723a8396625da7421c70e9e |
|
BLAKE2b-256 | a8e027d092d88f16c73a8926f79855b01233327902b7205e81c25550866c4a6b |
Hashes for dwave_greedy-0.1.2-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88cdb3897159880d02b6e5880285b2b5a5295c3a725ce7c990ce4e72c21724ac |
|
MD5 | 85598671b1194ab11acf311c7b3fba40 |
|
BLAKE2b-256 | f58c4c7b0e2e1e642c9ef5e6f60d34491d3cf35b7c56845d52f09fda1c7d0acf |
Hashes for dwave_greedy-0.1.2-cp38-cp38-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5058abfe5057404d9b07f75bb408e28bd9640dd86f15473dfd208f2471877b2f |
|
MD5 | 761082aa2fe516a922796c0249da422b |
|
BLAKE2b-256 | 2814d23bf0a7e544920732b60b08d9a8a0bb8f2155cafa1a2ea1ef460b677411 |
Hashes for dwave_greedy-0.1.2-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a5a853c8ff4f85929c6348f2b67ddd5b2a656f9c46b852b53ec4256b0605b25b |
|
MD5 | d7c97db785936eba6c11cc14bb405227 |
|
BLAKE2b-256 | 073b216deb49b0c37472811f611f098632aab06d75d26e4a8226ad4396653b96 |
Hashes for dwave_greedy-0.1.2-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c12f3cc22a0e694c496dfb42f115ac0e9cec25909832bb48b2717e7e2f6da25 |
|
MD5 | e0cccf00fb12828e79298404505ba2e1 |
|
BLAKE2b-256 | 5ce5273eb600455ad0b628b8a34b902b274c05078e5f9d0ee696f6635f96b665 |
Hashes for dwave_greedy-0.1.2-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5369c3a345a2599fe71a27f45e8763e9444b4310aac479722671f964a2c4df9 |
|
MD5 | 485f07091c4cca4ef450d2df406cef11 |
|
BLAKE2b-256 | c66ee01444309927ff4ae8c9026f20c6fa3029ed909fffb19979b5875c8b81a6 |
Hashes for dwave_greedy-0.1.2-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c5da6414dd49ad2f5c712732b51794d0c478e5451300def65faa967256a92a79 |
|
MD5 | 91a3b2ac82cae66ace098df3bfd014b1 |
|
BLAKE2b-256 | 1bd833a03b1fe60483e0ec987767af54d2336076ff9e3b66c7cfe703639e7573 |
Hashes for dwave_greedy-0.1.2-cp37-cp37m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61a26cda60800735493eb36a2c08ba5288a0c819297370a649a134f4a57b3b8f |
|
MD5 | f0a82b4f631e19135a8c85720d1bb774 |
|
BLAKE2b-256 | 02492963c629bd4de2f9e5581ccf2cd72e363478d918d70788083a16219f3dbb |
Hashes for dwave_greedy-0.1.2-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba9cb3e4eb313f77fab9b02e7ebf5efd933bb18f524da003525f82d5510c1d4c |
|
MD5 | 2543870be51f712f579c3987aa953cd4 |
|
BLAKE2b-256 | ef877cd31faabf7e42bdf3fd98572403dcb0edae8c8d0ae6e5b61c1ee469ed9d |
Hashes for dwave_greedy-0.1.2-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc1986b3103c6cfe501e00610062ec6760160867ba929ab373fc2d1386cfdecc |
|
MD5 | 6a291c6b3f73fac859bf6ad024ccbca4 |
|
BLAKE2b-256 | a648bdbc98322de15a480e6fe000710acfd02e67657c9ddb13ecf8e0ea0e778c |
Hashes for dwave_greedy-0.1.2-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 713c9f8f799f28acc388e31558be6f3713f3b8ba5489bcd7aa2b233ffd58f807 |
|
MD5 | 1508467c07255c282e5194026a1a4d70 |
|
BLAKE2b-256 | c51005f51b00a04e489c3c417696d73c264ec640e2d9bf37b23ec595899da104 |
Hashes for dwave_greedy-0.1.2-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40bf4c2c758910eabcfc707d5f356264daef9ddec44d2fa7743cc74b27087201 |
|
MD5 | 5d644ad9830358955de6fd2f3a8aef74 |
|
BLAKE2b-256 | 8595f084dc4c172b8958059811d030fd1b64fd41ee61fc14e7bd2cddd02196e4 |
Hashes for dwave_greedy-0.1.2-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71c250c5b8c049c811cbf16df91215e7623c88e30df47ddabf21bda1c590cd52 |
|
MD5 | 9169fa7870a5569b15eea627ade223f4 |
|
BLAKE2b-256 | 040bbcf418ef69b3856a0b69e30167944c3eb40f89a8828dea789a98580ad1a0 |
Hashes for dwave_greedy-0.1.2-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e9d4dec4bd8127ac482db053c7590b13620e0dc6aef8cb8ec3f29d78a97f4af |
|
MD5 | 25dc8f3f03e9b09e5c5df584200cb01f |
|
BLAKE2b-256 | 4faed35c6ef9290911ea046c2a8c14b500d409d16f2c35823238885c2bd35d4e |
Hashes for dwave_greedy-0.1.2-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e23b88495302233e812de56098b21bc7fdfdd230599b3bcbc2da7681e5a7af13 |
|
MD5 | b0c5de606a74bbd6193c6956896434cb |
|
BLAKE2b-256 | 5d2f88ab09e774a294ac53556a28c37d7eb98091d85a23f4dbfa65fb0fb59b50 |
Hashes for dwave_greedy-0.1.2-cp35-cp35m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1666326f79e09033aa342453e3815b046246c365f61e09871c9a3ecfe8e6590b |
|
MD5 | 7e8316ea56cff87fcbe443ed4a4cb837 |
|
BLAKE2b-256 | 9c4ac6a45f1e2dec909b7957c8ea369b6b814a73a0c037c64769c1e7f6fbd5fd |
Hashes for dwave_greedy-0.1.2-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98cdeb3c06e53e5052df9e0defafdfd8f4a307607fac15e671e67b8a134a2272 |
|
MD5 | 98ba476f987c8232e03ac4398ecaa6cc |
|
BLAKE2b-256 | 598faae923ce25d7be5102be3bc8f1c6aee81a3f8d70fac344dc2a70905d5982 |
Hashes for dwave_greedy-0.1.2-cp35-cp35m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69852e5dbad783469b9a736e3a3168f011ec5c0113efdb1b4994d99302f4ba2d |
|
MD5 | ae75188c69818d1cae651e99be237cf4 |
|
BLAKE2b-256 | b600d5b9363a7b568197a07ea33a2f03f39884f99b1ad39174c7dc27af9b4656 |
Hashes for dwave_greedy-0.1.2-cp35-cp35m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0998bddf714ede48a8039b2ebeede49331d636baf6d4104c36ada21a71dfa5dd |
|
MD5 | ffc887942170e2f2b3821a9b6dc75009 |
|
BLAKE2b-256 | 845449917d346aa3b927162c9da6f41c324e679b4291e51ef13be91a1b2ec986 |