Skip to content

Commit 4665e07

Browse files
cposselwoodsp-ibm
andauthored
Adds supports for SBPLX optimizer from nlopt (#228)
Co-authored-by: Steve Wood <[email protected]>
1 parent ac7f29f commit 4665e07

File tree

6 files changed

+69
-4
lines changed

6 files changed

+69
-4
lines changed

.pylintdict

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ izaac
162162
izz
163163
jac
164164
jacobian
165+
johnson
165166
jones
166167
july
167168
kandala
@@ -311,6 +312,7 @@ sanjiv
311312
sashank
312313
satisfiability
313314
satyen
315+
sbplx
314316
schrödinger
315317
schroediger
316318
schroedinger
@@ -337,11 +339,13 @@ stdout
337339
stefano
338340
steppable
339341
stepsize
342+
steven
340343
str
341344
subcircuits
342345
subclassed
343346
subclasses
344347
subcomponents
348+
subplex
345349
subspaces
346350
suzuki
347351
swappable

qiskit_algorithms/optimizers/__init__.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This code is part of a Qiskit project.
22
#
3-
# (C) Copyright IBM 2018, 2023.
3+
# (C) Copyright IBM 2018, 2025.
44
#
55
# This code is licensed under the Apache License, Version 2.0. You may
66
# obtain a copy of this license in the LICENSE.txt file in the root directory
@@ -98,6 +98,16 @@
9898
IMFIL
9999
SNOBFIT
100100
101+
Qiskit also provides local optimizers based on
102+
`NLOpt <https://nlopt.readthedocs.io/en/latest/>`_.
103+
See Global Optimizers section below for the optional NLOpt installation instructions.
104+
105+
.. autosummary::
106+
:toctree: ../stubs/
107+
:nosignatures:
108+
109+
SBPLX
110+
101111
Global Optimizers
102112
-----------------
103113
The global optimizers here all use `NLOpt <https://nlopt.readthedocs.io/en/latest/>`_ for their
@@ -132,6 +142,7 @@
132142
from .nlopts.direct_l_rand import DIRECT_L_RAND
133143
from .nlopts.esch import ESCH
134144
from .nlopts.isres import ISRES
145+
from .nlopts.sbplx import SBPLX
135146
from .steppable_optimizer import SteppableOptimizer, AskData, TellData, OptimizerState
136147
from .optimizer import Minimizer, Optimizer, OptimizerResult, OptimizerSupportLevel
137148
from .p_bfgs import P_BFGS
@@ -175,6 +186,7 @@
175186
"DIRECT_L_RAND",
176187
"ESCH",
177188
"ISRES",
189+
"SBPLX",
178190
"SNOBFIT",
179191
"BOBYQA",
180192
"IMFIL",

qiskit_algorithms/optimizers/nlopts/nloptimizer.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This code is part of a Qiskit project.
22
#
3-
# (C) Copyright IBM 2018, 2023.
3+
# (C) Copyright IBM 2018, 2025.
44
#
55
# This code is licensed under the Apache License, Version 2.0. You may
66
# obtain a copy of this license in the LICENSE.txt file in the root directory
@@ -33,12 +33,13 @@ class NLoptOptimizerType(Enum):
3333
GN_DIRECT_L = 3
3434
GN_ESCH = 4
3535
GN_ISRES = 5
36+
LN_SBPLX = 6
3637

3738

3839
@_optionals.HAS_NLOPT.require_in_instance
3940
class NLoptOptimizer(Optimizer):
4041
"""
41-
NLopt global optimizer base class
42+
NLopt global and local optimizer base class
4243
"""
4344

4445
_OPTIONS = ["max_evals"]
@@ -64,6 +65,7 @@ def __init__(self, max_evals: int = 1000) -> None: # pylint: disable=unused-arg
6465
NLoptOptimizerType.GN_DIRECT_L: nlopt.GN_DIRECT_L,
6566
NLoptOptimizerType.GN_ESCH: nlopt.GN_ESCH,
6667
NLoptOptimizerType.GN_ISRES: nlopt.GN_ISRES,
68+
NLoptOptimizerType.LN_SBPLX: nlopt.LN_SBPLX,
6769
}
6870

6971
@abstractmethod
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# This code is part of a Qiskit project.
2+
#
3+
# (C) Copyright IBM 2025.
4+
#
5+
# This code is licensed under the Apache License, Version 2.0. You may
6+
# obtain a copy of this license in the LICENSE.txt file in the root directory
7+
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
8+
#
9+
# Any modifications or derivative works of this code must retain this
10+
# copyright notice, and modified files need to carry a notice indicating
11+
# that they have been altered from the originals.
12+
13+
"""Sbplx (Subplex) optimizer."""
14+
15+
from .nloptimizer import NLoptOptimizer, NLoptOptimizerType
16+
17+
18+
class SBPLX(NLoptOptimizer):
19+
"""
20+
Subplex optimizer.
21+
22+
"Subplex (a variant of Nelder-Mead that uses Nelder-Mead on a sequence of subspaces)
23+
is claimed to be much more efficient and robust than the original Nelder-Mead,
24+
while retaining the latter's facility with discontinuous objectives,
25+
and in my experience these claims seem to be true in many cases.
26+
(However, I'm not aware of any proof that Subplex is globally convergent,
27+
and perhaps it may fail for some objectives like Nelder-Mead; YMMV.)"
28+
Description by Steven G. Johnson, author of NLopt library.
29+
30+
NLopt local optimizer, derivative-free.
31+
For further detail, please refer to
32+
https://nlopt.readthedocs.io/en/latest/NLopt_Algorithms/#sbplx-based-on-subplex
33+
"""
34+
35+
def get_nlopt_optimizer(self) -> NLoptOptimizerType:
36+
"""Return NLopt optimizer type."""
37+
return NLoptOptimizerType.LN_SBPLX
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
features:
3+
- |
4+
Support for :class:`.SBPLX` optimizer from NLopt library has been added.
5+
SBPLX is a local gradient-free optimizer based on Nelder-Mead and
6+
is expected to show better convergence behavior.
7+
Further information about this optimizer and the others can be found in
8+
the API ref for the :mod:`~qiskit_algorithms.optimizers`.

test/optimizers/test_optimizers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This code is part of a Qiskit project.
22
#
3-
# (C) Copyright IBM 2018, 2024.
3+
# (C) Copyright IBM 2018, 2025.
44
#
55
# This code is licensed under the Apache License, Version 2.0. You may
66
# obtain a copy of this license in the LICENSE.txt file in the root directory
@@ -42,6 +42,7 @@
4242
Optimizer,
4343
P_BFGS,
4444
POWELL,
45+
SBPLX,
4546
SLSQP,
4647
SPSA,
4748
QNSPSA,
@@ -224,6 +225,7 @@ def test_scipy_optimizer_parse_bounds(self):
224225
(CRS, False),
225226
(DIRECT_L, False),
226227
(DIRECT_L_RAND, False),
228+
(SBPLX, True),
227229
)
228230
@unpack
229231
def test_nlopt(self, optimizer_cls, use_bound):

0 commit comments

Comments
 (0)