From 0682b92ba6fad72af683b07d8d783eced366ca0d Mon Sep 17 00:00:00 2001 From: Clemens Possel <62604102+cpossel@users.noreply.github.com> Date: Thu, 8 May 2025 14:46:28 +0200 Subject: [PATCH 01/13] Add SBPLX to nloptimizer.py --- qiskit_algorithms/optimizers/nlopts/nloptimizer.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qiskit_algorithms/optimizers/nlopts/nloptimizer.py b/qiskit_algorithms/optimizers/nlopts/nloptimizer.py index 22bbf85f..d79a9284 100644 --- a/qiskit_algorithms/optimizers/nlopts/nloptimizer.py +++ b/qiskit_algorithms/optimizers/nlopts/nloptimizer.py @@ -1,6 +1,6 @@ # This code is part of a Qiskit project. # -# (C) Copyright IBM 2018, 2023. +# (C) Copyright IBM 2018, 2025. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory @@ -33,6 +33,7 @@ class NLoptOptimizerType(Enum): GN_DIRECT_L = 3 GN_ESCH = 4 GN_ISRES = 5 + LN_SBPLX = 6 @_optionals.HAS_NLOPT.require_in_instance From f5f19d618ee3a2a57c0bb482b21b3db0bda0e3f9 Mon Sep 17 00:00:00 2001 From: Clemens Possel <62604102+cpossel@users.noreply.github.com> Date: Thu, 8 May 2025 14:48:37 +0200 Subject: [PATCH 02/13] Add SBPLX to NLopt --- qiskit_algorithms/optimizers/nlopts/sbplx.py | 37 ++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 qiskit_algorithms/optimizers/nlopts/sbplx.py diff --git a/qiskit_algorithms/optimizers/nlopts/sbplx.py b/qiskit_algorithms/optimizers/nlopts/sbplx.py new file mode 100644 index 00000000..2a245984 --- /dev/null +++ b/qiskit_algorithms/optimizers/nlopts/sbplx.py @@ -0,0 +1,37 @@ +# This code is part of a Qiskit project. +# +# (C) Copyright IBM 2018, 2025. +# +# This code is licensed under the Apache License, Version 2.0. You may +# obtain a copy of this license in the LICENSE.txt file in the root directory +# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. +# +# Any modifications or derivative works of this code must retain this +# copyright notice, and modified files need to carry a notice indicating +# that they have been altered from the originals. + +"""Sbplx (Subplex) optimizer.""" + +from .nloptimizer import NLoptOptimizer, NLoptOptimizerType + + +class SBPLX(NLoptOptimizer): + """ + Subplex optimizer. + + "Subplex (a variant of Nelder-Mead that uses Nelder-Mead on a sequence of subspaces) + is claimed to be much more efficient and robust than the original Nelder-Mead, + while retaining the latter's facility with discontinuous objectives, + and in my experience these claims seem to be true in many cases. + (However, I'm not aware of any proof that Subplex is globally convergent, + and perhaps it may fail for some objectives like Nelder-Mead; YMMV.)" + Description by Steven G. Johnson, author of NLopt library. + + NLopt local optimizer, derivative-free. + For further detail, please refer to + https://nlopt.readthedocs.io/en/latest/NLopt_Algorithms/#sbplx-based-on-subplex + """ + + def get_nlopt_optimizer(self) -> NLoptOptimizerType: + """Return NLopt optimizer type.""" + return NLoptOptimizerType.LN_SBPLX From 648c857c331ee4556589536a138fc9631da3136e Mon Sep 17 00:00:00 2001 From: Clemens Possel <62604102+cpossel@users.noreply.github.com> Date: Fri, 9 May 2025 09:59:00 +0200 Subject: [PATCH 03/13] Update .pylintdict --- .pylintdict | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.pylintdict b/.pylintdict index 42f3bee1..2d012d3f 100644 --- a/.pylintdict +++ b/.pylintdict @@ -311,6 +311,7 @@ sanjiv sashank satisfiability satyen +sbplx schrödinger schroediger schroedinger @@ -342,6 +343,7 @@ subcircuits subclassed subclasses subcomponents +subplex subspaces suzuki swappable From b9eb614b649b97005c7bf7fa0e10cff74be7cf6d Mon Sep 17 00:00:00 2001 From: poc <62604102+cpossel@users.noreply.github.com> Date: Fri, 9 May 2025 11:29:38 +0200 Subject: [PATCH 04/13] Complete adding SBPLX --- qiskit_algorithms/optimizers/nlopts/nloptimizer.py | 3 ++- qiskit_algorithms/optimizers/nlopts/sbplx.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/qiskit_algorithms/optimizers/nlopts/nloptimizer.py b/qiskit_algorithms/optimizers/nlopts/nloptimizer.py index d79a9284..9dd62a0b 100644 --- a/qiskit_algorithms/optimizers/nlopts/nloptimizer.py +++ b/qiskit_algorithms/optimizers/nlopts/nloptimizer.py @@ -39,7 +39,7 @@ class NLoptOptimizerType(Enum): @_optionals.HAS_NLOPT.require_in_instance class NLoptOptimizer(Optimizer): """ - NLopt global optimizer base class + NLopt global and local optimizer base class """ _OPTIONS = ["max_evals"] @@ -65,6 +65,7 @@ def __init__(self, max_evals: int = 1000) -> None: # pylint: disable=unused-arg NLoptOptimizerType.GN_DIRECT_L: nlopt.GN_DIRECT_L, NLoptOptimizerType.GN_ESCH: nlopt.GN_ESCH, NLoptOptimizerType.GN_ISRES: nlopt.GN_ISRES, + NLoptOptimizerType.LN_SBPLX: nlopt.LN_SBPLX, } @abstractmethod diff --git a/qiskit_algorithms/optimizers/nlopts/sbplx.py b/qiskit_algorithms/optimizers/nlopts/sbplx.py index 2a245984..96b88e10 100644 --- a/qiskit_algorithms/optimizers/nlopts/sbplx.py +++ b/qiskit_algorithms/optimizers/nlopts/sbplx.py @@ -1,6 +1,6 @@ # This code is part of a Qiskit project. # -# (C) Copyright IBM 2018, 2025. +# (C) Copyright IBM 2025. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory From 9eb3453cbf4086a8439a3c759d9e81f1cc7bd97b Mon Sep 17 00:00:00 2001 From: poc <62604102+cpossel@users.noreply.github.com> Date: Fri, 9 May 2025 11:30:06 +0200 Subject: [PATCH 05/13] Add SBPLX test --- test/optimizers/test_optimizers.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/optimizers/test_optimizers.py b/test/optimizers/test_optimizers.py index c3b9e4cb..273ceb34 100644 --- a/test/optimizers/test_optimizers.py +++ b/test/optimizers/test_optimizers.py @@ -1,6 +1,6 @@ # This code is part of a Qiskit project. # -# (C) Copyright IBM 2018, 2024. +# (C) Copyright IBM 2018, 2025. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory @@ -42,6 +42,7 @@ Optimizer, P_BFGS, POWELL, + SBPLX, SLSQP, SPSA, QNSPSA, @@ -224,6 +225,7 @@ def test_scipy_optimizer_parse_bounds(self): (CRS, False), (DIRECT_L, False), (DIRECT_L_RAND, False), + (SBPLX, True), ) @unpack def test_nlopt(self, optimizer_cls, use_bound): From 2f7ca029453270567aaa765310adaaea003ec2af Mon Sep 17 00:00:00 2001 From: poc <62604102+cpossel@users.noreply.github.com> Date: Fri, 9 May 2025 11:30:26 +0200 Subject: [PATCH 06/13] Update documentation for SBPLX --- qiskit_algorithms/optimizers/__init__.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/qiskit_algorithms/optimizers/__init__.py b/qiskit_algorithms/optimizers/__init__.py index c196c85b..4cdc3dd3 100644 --- a/qiskit_algorithms/optimizers/__init__.py +++ b/qiskit_algorithms/optimizers/__init__.py @@ -1,6 +1,6 @@ # This code is part of a Qiskit project. # -# (C) Copyright IBM 2018, 2023. +# (C) Copyright IBM 2018, 2025. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory @@ -98,6 +98,16 @@ IMFIL SNOBFIT +Qiskit also provides local optimizers based on +`NLOpt `_. +See below section about global optimizers for installation instructions. + +.. autosummary:: + :toctree: ../stubs/ + :nosignatures: + + SBPLX + Global Optimizers ----------------- The global optimizers here all use `NLOpt `_ for their @@ -132,6 +142,7 @@ from .nlopts.direct_l_rand import DIRECT_L_RAND from .nlopts.esch import ESCH from .nlopts.isres import ISRES +from .nlopts.sbplx import SBPLX from .steppable_optimizer import SteppableOptimizer, AskData, TellData, OptimizerState from .optimizer import Minimizer, Optimizer, OptimizerResult, OptimizerSupportLevel from .p_bfgs import P_BFGS @@ -175,6 +186,7 @@ "DIRECT_L_RAND", "ESCH", "ISRES", + "SBPLX", "SNOBFIT", "BOBYQA", "IMFIL", From 9f122ca4e757a0b826927defdb07a363b7d39210 Mon Sep 17 00:00:00 2001 From: poc <62604102+cpossel@users.noreply.github.com> Date: Fri, 9 May 2025 11:30:49 +0200 Subject: [PATCH 07/13] Add release note for SBPLX --- releasenotes/notes/sbplx_optimizer-a27361fc4ac8de8c.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 releasenotes/notes/sbplx_optimizer-a27361fc4ac8de8c.yaml diff --git a/releasenotes/notes/sbplx_optimizer-a27361fc4ac8de8c.yaml b/releasenotes/notes/sbplx_optimizer-a27361fc4ac8de8c.yaml new file mode 100644 index 00000000..839d4f43 --- /dev/null +++ b/releasenotes/notes/sbplx_optimizer-a27361fc4ac8de8c.yaml @@ -0,0 +1,8 @@ +--- +features: + - | + Support for SBPLX optimizer from NLopt library has been added. + SBPLX is a local gradient-free optimizer based on Nelder-Mead and + is expected to show better convergence behaviour. + Further information about this and all other optimizers can be found + :ref:`here`. From 6f146524f5479fe4a0c2886d361a593b4b71b0dd Mon Sep 17 00:00:00 2001 From: Clemens Possel <62604102+cpossel@users.noreply.github.com> Date: Mon, 12 May 2025 14:13:13 +0200 Subject: [PATCH 08/13] Update releasenote (fix url) Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com> --- releasenotes/notes/sbplx_optimizer-a27361fc4ac8de8c.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/releasenotes/notes/sbplx_optimizer-a27361fc4ac8de8c.yaml b/releasenotes/notes/sbplx_optimizer-a27361fc4ac8de8c.yaml index 839d4f43..961e4aa5 100644 --- a/releasenotes/notes/sbplx_optimizer-a27361fc4ac8de8c.yaml +++ b/releasenotes/notes/sbplx_optimizer-a27361fc4ac8de8c.yaml @@ -5,4 +5,4 @@ features: SBPLX is a local gradient-free optimizer based on Nelder-Mead and is expected to show better convergence behaviour. Further information about this and all other optimizers can be found - :ref:`here`. + `in the API ref. here __`. From 925fea6a58f3f10507aea51742ffe716826fec5c Mon Sep 17 00:00:00 2001 From: Clemens Possel <62604102+cpossel@users.noreply.github.com> Date: Mon, 12 May 2025 14:13:48 +0200 Subject: [PATCH 09/13] Update qiskit_algorithms/optimizers/__init__.py Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com> --- qiskit_algorithms/optimizers/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qiskit_algorithms/optimizers/__init__.py b/qiskit_algorithms/optimizers/__init__.py index 4cdc3dd3..e6436189 100644 --- a/qiskit_algorithms/optimizers/__init__.py +++ b/qiskit_algorithms/optimizers/__init__.py @@ -100,7 +100,7 @@ Qiskit also provides local optimizers based on `NLOpt `_. -See below section about global optimizers for installation instructions. +See Global Optimizers section below for the optional NLOpt installation instructions. .. autosummary:: :toctree: ../stubs/ From d74148047fbc7146e94b1236b7499a5020eb486f Mon Sep 17 00:00:00 2001 From: Clemens Possel <62604102+cpossel@users.noreply.github.com> Date: Mon, 12 May 2025 14:16:11 +0200 Subject: [PATCH 10/13] Update .pylintdict --- .pylintdict | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.pylintdict b/.pylintdict index 2d012d3f..f8ac2c55 100644 --- a/.pylintdict +++ b/.pylintdict @@ -162,6 +162,7 @@ izaac izz jac jacobian +johnson jones july kandala @@ -338,6 +339,7 @@ stdout stefano steppable stepsize +steven str subcircuits subclassed From 2b8f45f063b501ed84461d573f10c469372733ed Mon Sep 17 00:00:00 2001 From: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com> Date: Mon, 12 May 2025 09:23:52 -0400 Subject: [PATCH 11/13] Update releasenotes/notes/sbplx_optimizer-a27361fc4ac8de8c.yaml --- releasenotes/notes/sbplx_optimizer-a27361fc4ac8de8c.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/releasenotes/notes/sbplx_optimizer-a27361fc4ac8de8c.yaml b/releasenotes/notes/sbplx_optimizer-a27361fc4ac8de8c.yaml index 961e4aa5..8942c5e9 100644 --- a/releasenotes/notes/sbplx_optimizer-a27361fc4ac8de8c.yaml +++ b/releasenotes/notes/sbplx_optimizer-a27361fc4ac8de8c.yaml @@ -3,6 +3,6 @@ features: - | Support for SBPLX optimizer from NLopt library has been added. SBPLX is a local gradient-free optimizer based on Nelder-Mead and - is expected to show better convergence behaviour. + is expected to show better convergence behavior. Further information about this and all other optimizers can be found `in the API ref. here __`. From fc40c374ddcf1a5445a01f98c1c09b15f0c507b2 Mon Sep 17 00:00:00 2001 From: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com> Date: Mon, 12 May 2025 10:03:55 -0400 Subject: [PATCH 12/13] Update releasenotes/notes/sbplx_optimizer-a27361fc4ac8de8c.yaml --- releasenotes/notes/sbplx_optimizer-a27361fc4ac8de8c.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/releasenotes/notes/sbplx_optimizer-a27361fc4ac8de8c.yaml b/releasenotes/notes/sbplx_optimizer-a27361fc4ac8de8c.yaml index 8942c5e9..2e7f83c0 100644 --- a/releasenotes/notes/sbplx_optimizer-a27361fc4ac8de8c.yaml +++ b/releasenotes/notes/sbplx_optimizer-a27361fc4ac8de8c.yaml @@ -5,4 +5,4 @@ features: SBPLX is a local gradient-free optimizer based on Nelder-Mead and is expected to show better convergence behavior. Further information about this and all other optimizers can be found - `in the API ref. here __`. + `in the API ref. here `__. From a43f557f030a800787bdbf1b36c422bc9b97b9f6 Mon Sep 17 00:00:00 2001 From: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com> Date: Mon, 12 May 2025 10:24:58 -0400 Subject: [PATCH 13/13] Update releasenotes/notes/sbplx_optimizer-a27361fc4ac8de8c.yaml --- releasenotes/notes/sbplx_optimizer-a27361fc4ac8de8c.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/releasenotes/notes/sbplx_optimizer-a27361fc4ac8de8c.yaml b/releasenotes/notes/sbplx_optimizer-a27361fc4ac8de8c.yaml index 2e7f83c0..e93f231c 100644 --- a/releasenotes/notes/sbplx_optimizer-a27361fc4ac8de8c.yaml +++ b/releasenotes/notes/sbplx_optimizer-a27361fc4ac8de8c.yaml @@ -1,8 +1,8 @@ --- features: - | - Support for SBPLX optimizer from NLopt library has been added. + Support for :class:`.SBPLX` optimizer from NLopt library has been added. SBPLX is a local gradient-free optimizer based on Nelder-Mead and is expected to show better convergence behavior. - Further information about this and all other optimizers can be found - `in the API ref. here `__. + Further information about this optimizer and the others can be found in + the API ref for the :mod:`~qiskit_algorithms.optimizers`.