https://github.com/dwavesystems/dwave-optimization
Enables the formulation of nonlinear models for industrial optimization problems.
https://github.com/dwavesystems/dwave-optimization
Last synced: 4 months ago
JSON representation
Enables the formulation of nonlinear models for industrial optimization problems.
- Host: GitHub
- URL: https://github.com/dwavesystems/dwave-optimization
- Owner: dwavesystems
- License: apache-2.0
- Created: 2024-06-10T15:02:26.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2026-01-15T21:31:00.000Z (5 months ago)
- Last Synced: 2026-01-16T00:44:39.957Z (5 months ago)
- Language: C++
- Homepage: https://docs.ocean.dwavesys.com/en/stable/docs_optimization/index.html#index-optimization
- Size: 2.59 MB
- Stars: 26
- Watchers: 5
- Forks: 30
- Open Issues: 42
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
.. image:: https://img.shields.io/pypi/v/dwave-optimization.svg
:target: https://pypi.org/project/dwave-optimization
.. image:: https://img.shields.io/pypi/pyversions/dwave-optimization.svg
:target: https://pypi.python.org/pypi/dwave-optimization
.. image:: https://circleci.com/gh/dwavesystems/dwave-optimization.svg?style=svg
:target: https://circleci.com/gh/dwavesystems/dwave-optimization
==================
dwave-optimization
==================
.. start_optimization_about
`dwave-optimization` enables the formulation of nonlinear models for industrial
optimization problems. The package includes:
* A class for nonlinear models used by the
`Leap `_ service's quantum-classical
hybrid nonlinear-program solver.
* Model generators for common optimization problems.
.. end_optimization_about
Example Usage
-------------
.. start_optimization_examples
The
`flow-shop scheduling `_
problem is a variant of the renowned
`job-shop scheduling `_
optimization problem. Given ``n`` jobs to schedule on ``m`` machines, with
specified processing times for each job per machine, minimize the makespan
(the total length of the schedule for processing all the jobs). For every
job, the ``i``-th operation is executed on the ``i``-th machine. No machine
can perform more than one operation simultaneously.
This small example builds a model for optimizing the schedule for processing
two jobs on three machines.
.. code-block:: python
from dwave.optimization.generators import flow_shop_scheduling
processing_times = [[10, 5, 7], [20, 10, 15]]
model = flow_shop_scheduling(processing_times=processing_times)
.. end_optimization_examples
For explanations of the terminology, see the
`Ocean glossary `_.
See the `documentation `_
for more examples.
Installation
============
Installation from `PyPI `_:
.. code-block:: bash
pip install dwave-optimization
During package development, it is often convenient to use an editable install.
See `meson-python's editable installs
`_
for more details.
.. code-block:: bash
pip install --group dev --group blas
pip install --editable . \
--no-build-isolation \
--config-settings=editable-verbose=true \
--config-settings=setup-args="-Dblas=enabled"
Testing
=======
All code should be thoroughly tested and all pull requests should include tests.
To run the Python tests, first install the package using an editable install
as described above. The tests can then be run with
`unittest `_.
.. code-block:: bash
python -m unittest
To run the C++ tests, first install the project dependencies, then setup a
``meson`` build directory. You must configure the build as a debug build for
the tests to run.
.. code-block:: bash
pip install --group dev --group blas
meson setup build -Dbuildtype=debug -Dblas=enabled
You can then run the tests using
`meson's test framework `_.
.. code-block:: bash
meson test -Cbuild
To run the doctests, install the docs requirements:
.. code-block:: bash
pip install --group docs
You can then run them using the `docs/Makefile`.
.. code-block:: bash
make -C docs doctest
License
=======
Released under the Apache License 2.0. See LICENSE file.
Contributing
============
Ocean's `contributing guide `_
has guidelines for contributing to Ocean packages.
``dwave-optimization`` includes some formatting customization in the
`.clang-format <.clang-format>`_ and `setup.cfg `_ files.
Release Notes
-------------
``dwave-optimization`` makes use of `reno `_
to manage its release notes.
When making a contribution to ``dwave-optimization`` that will affect users,
create a new release note file by running
.. code-block:: bash
reno new your-short-descriptor-here
You can then edit the file created under ``releasenotes/notes/``.
Remove any sections not relevant to your changes.
Commit the file along with your changes.
See reno's `user guide `_
for details.