dwave-greedy


Namedwave-greedy JSON
Version 0.3.0 PyPI version JSON
download
home_pagehttps://github.com/dwavesystems/dwave-greedy
SummaryOcean-compatible collection of greedy/brute-force solvers/samplers
upload_time2022-11-25 23:48:54
maintainer
docs_urlNone
authorD-Wave Systems Inc.
requires_python>=3.7
licenseApache 2.0
keywords
VCS
bugtrack_url
requirements numpy numpy dimod cython importlib-metadata wheel setuptools
Travis-CI No Travis.
coveralls test coverage No coveralls.
            > :warning: **Note**: *dwave-greedy* is deprecated in favor of `dwave-samplers <https://github.com/dwavesystems/dwave-samplers>`_.

.. image:: https://circleci.com/gh/dwavesystems/dwave-greedy.svg?style=svg
    :target: https://circleci.com/gh/dwavesystems/dwave-greedy
    :alt: Linux/MacOS/Windows build status

.. image:: https://codecov.io/gh/dwavesystems/dwave-greedy/branch/master/graph/badge.svg?token=ZkZo09uAl7
    :target: https://codecov.io/gh/dwavesystems/dwave-greedy
    :alt: Code coverage

.. image:: https://readthedocs.com/projects/d-wave-systems-dwave-greedy/badge/?version=latest
    :target: https://docs.ocean.dwavesys.com/projects/greedy/en/latest/
    :alt: Documentation status

.. image:: https://badge.fury.io/py/dwave-greedy.svg
    :target: https://badge.fury.io/py/dwave-greedy
    :alt: Latest version on PyPI

.. image:: https://img.shields.io/pypi/pyversions/dwave-greedy.svg?style=flat
    :target: https://pypi.org/project/dwave-greedy/
    :alt: PyPI - Python Version


============
dwave-greedy
============

.. index-start-marker

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.

.. code-block:: python

    >>> 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]

.. index-end-marker


Installation
============

.. installation-start-marker

Install from a package on PyPI:

.. code-block:: bash

    pip install dwave-greedy

.. installation-end-marker


Examples
========

.. example-start-marker

Simple frustrated Ising triangle:

.. code-block:: python

    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):

.. code-block:: python

    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))

.. example-end-marker


License
=======

Released under the Apache License 2.0. See `<LICENSE>`_ file.


.. _NetworkX: https://networkx.github.io/
.. _RAN1: https://docs.ocean.dwavesys.com/en/stable/docs_dimod/reference/generated/dimod.generators.ran_r.html


Contributing
============

Ocean's `contributing guide <https://docs.ocean.dwavesys.com/en/stable/contributing.html>`_
has guidelines for contributing to Ocean packages.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/dwavesystems/dwave-greedy",
    "name": "dwave-greedy",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "D-Wave Systems Inc.",
    "author_email": "tools@dwavesys.com",
    "download_url": "https://files.pythonhosted.org/packages/54/e4/e1c79ae2cb50275434d314906518f45e0c156377f74a7bf0e8928bf5ddfb/dwave-greedy-0.3.0.tar.gz",
    "platform": null,
    "description": "> :warning: **Note**: *dwave-greedy* is deprecated in favor of `dwave-samplers <https://github.com/dwavesystems/dwave-samplers>`_.\n\n.. image:: https://circleci.com/gh/dwavesystems/dwave-greedy.svg?style=svg\n    :target: https://circleci.com/gh/dwavesystems/dwave-greedy\n    :alt: Linux/MacOS/Windows build status\n\n.. image:: https://codecov.io/gh/dwavesystems/dwave-greedy/branch/master/graph/badge.svg?token=ZkZo09uAl7\n    :target: https://codecov.io/gh/dwavesystems/dwave-greedy\n    :alt: Code coverage\n\n.. image:: https://readthedocs.com/projects/d-wave-systems-dwave-greedy/badge/?version=latest\n    :target: https://docs.ocean.dwavesys.com/projects/greedy/en/latest/\n    :alt: Documentation status\n\n.. image:: https://badge.fury.io/py/dwave-greedy.svg\n    :target: https://badge.fury.io/py/dwave-greedy\n    :alt: Latest version on PyPI\n\n.. image:: https://img.shields.io/pypi/pyversions/dwave-greedy.svg?style=flat\n    :target: https://pypi.org/project/dwave-greedy/\n    :alt: PyPI - Python Version\n\n\n============\ndwave-greedy\n============\n\n.. index-start-marker\n\nAn implementation of a steepest descent solver for binary quadratic models.\n\nSteepest descent is the discrete analogue of gradient descent, but the best\nmove is computed using a local minimization rather rather than computing a\ngradient. At each step, we determine the dimension along which to descend based\non the highest energy drop caused by a variable flip.\n\n.. code-block:: python\n\n    >>> import greedy\n    ...\n    >>> solver = greedy.SteepestDescentSolver()\n    >>> sampleset = solver.sample_ising({0: 2, 1: 2}, {(0, 1): -1})\n    ...\n    >>> print(sampleset)\n        0  1 energy num_oc.\n    0 -1 -1   -5.0       1\n    ['SPIN', 1 rows, 1 samples, 2 variables]\n\n.. index-end-marker\n\n\nInstallation\n============\n\n.. installation-start-marker\n\nInstall from a package on PyPI:\n\n.. code-block:: bash\n\n    pip install dwave-greedy\n\n.. installation-end-marker\n\n\nExamples\n========\n\n.. example-start-marker\n\nSimple frustrated Ising triangle:\n\n.. code-block:: python\n\n    import dimod\n    import greedy\n\n    # Construct a simple problem\n    bqm = dimod.BQM.from_qubo({'ab': 1, 'bc': 1, 'ca': 1})\n\n    # Instantiate the sampler\n    sampler = greedy.SteepestDescentSampler()\n\n    # Solve the problem\n    result = sampler.sample(bqm)\n\nLarge RAN1_ sparse problem (requires NetworkX_ package):\n\n.. code-block:: python\n\n    import dimod\n    import greedy\n    import networkx\n\n    # Generate random Erd\u0151s-R\u00e9nyi sparse graph with 10% density\n    graph = networkx.fast_gnp_random_graph(n=1000, p=0.1)\n\n    # Generate RAN1 problem on the sparse graph\n    bqm = dimod.generators.random.ran_r(r=1, graph=graph)\n\n    # Instantiate the sampler\n    sampler = greedy.SteepestDescentSampler()\n\n    # Run steepest descent for 100 times, each time from a random state\n    sampleset = sampler.sample(bqm, num_reads=100)\n\n    # Print the best energy\n    print(min(sampleset.record.energy))\n\n.. example-end-marker\n\n\nLicense\n=======\n\nReleased under the Apache License 2.0. See `<LICENSE>`_ file.\n\n\n.. _NetworkX: https://networkx.github.io/\n.. _RAN1: https://docs.ocean.dwavesys.com/en/stable/docs_dimod/reference/generated/dimod.generators.ran_r.html\n\n\nContributing\n============\n\nOcean's `contributing guide <https://docs.ocean.dwavesys.com/en/stable/contributing.html>`_\nhas guidelines for contributing to Ocean packages.\n",
    "bugtrack_url": null,
    "license": "Apache 2.0",
    "summary": "Ocean-compatible collection of greedy/brute-force solvers/samplers",
    "version": "0.3.0",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "3206483b0c76d35b599edd1d7335b714",
                "sha256": "34c2d24bf6d4f4d3cee532dbc85c79b7faa4845a7bd51435fc4114d077095f6f"
            },
            "downloads": -1,
            "filename": "dwave_greedy-0.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3206483b0c76d35b599edd1d7335b714",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 10115,
            "upload_time": "2022-11-25T23:48:52",
            "upload_time_iso_8601": "2022-11-25T23:48:52.443023Z",
            "url": "https://files.pythonhosted.org/packages/02/91/bbc44323850dcf76f20721ab567a210680e8c16caa090e8831a386c86b34/dwave_greedy-0.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "356686ab74666b6a42b6e402bf199041",
                "sha256": "806c02d6c3f260ef5bf063d4932f43dfb52a0ea00f9db0b0d34d9b15691a011a"
            },
            "downloads": -1,
            "filename": "dwave-greedy-0.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "356686ab74666b6a42b6e402bf199041",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 7815,
            "upload_time": "2022-11-25T23:48:54",
            "upload_time_iso_8601": "2022-11-25T23:48:54.532871Z",
            "url": "https://files.pythonhosted.org/packages/54/e4/e1c79ae2cb50275434d314906518f45e0c156377f74a7bf0e8928bf5ddfb/dwave-greedy-0.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-11-25 23:48:54",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "dwavesystems",
    "github_project": "dwave-greedy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "circle": true,
    "requirements": [
        {
            "name": "numpy",
            "specs": [
                [
                    "==",
                    "1.19.5"
                ]
            ]
        },
        {
            "name": "numpy",
            "specs": [
                [
                    "==",
                    "1.21.4"
                ]
            ]
        },
        {
            "name": "dimod",
            "specs": [
                [
                    "==",
                    "0.10.10"
                ]
            ]
        },
        {
            "name": "cython",
            "specs": [
                [
                    "==",
                    "0.29.26"
                ]
            ]
        },
        {
            "name": "importlib-metadata",
            "specs": [
                [
                    ">=",
                    "1.0"
                ]
            ]
        },
        {
            "name": "wheel",
            "specs": [
                [
                    ">=",
                    "0.30.0"
                ]
            ]
        },
        {
            "name": "setuptools",
            "specs": [
                [
                    ">=",
                    "56.2.0"
                ]
            ]
        }
    ],
    "lcname": "dwave-greedy"
}
        
Elapsed time: 0.02240s