Skip to content

Commit a577508

Browse files
committed
Merge branch 'main' into python39
2 parents 9492c35 + 999ad95 commit a577508

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+6285
-41
lines changed

.mergify.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
queue_rules:
22
- name: automerge
3-
conditions:
4-
- check-success=Deprecation_Messages_and_Coverage (3.8)
5-
6-
pull_request_rules:
7-
- name: automatic merge on CI success and review
8-
conditions:
3+
queue_conditions:
94
- check-success=Deprecation_Messages_and_Coverage (3.8)
105
- "#approved-reviews-by>=1"
116
- label=automerge
127
- label!=on hold
13-
actions:
14-
queue:
15-
name: automerge
16-
method: squash
8+
merge_conditions:
9+
- check-success=Deprecation_Messages_and_Coverage (3.8)
10+
merge_method: squash
11+
12+
pull_request_rules:
1713
- name: backport
1814
conditions:
1915
- label=stable backport potential
2016
actions:
2117
backport:
2218
branches:
2319
- stable/0.6
20+
- name: automatic merge on CI success and review
21+
conditions: []
22+
actions:
23+
queue:

.pylintdict

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ aer's
66
al
77
annealers
88
ansatz
9+
ansatzes
910
apidocs
11+
apl
1012
applegate
1113
args
1214
arxiv
@@ -15,14 +17,17 @@ autosummary
1517
backend
1618
backends
1719
barkoutsos
20+
batchsize
1821
benchmarking
22+
bfgs
1923
bitstring
2024
bitstrings
2125
bixby
2226
bool
2327
boolean
2428
boyd
2529
bravyi
30+
callables
2631
catol
2732
cartan
2833
chu
@@ -35,16 +40,20 @@ conv
3540
const
3641
cplex
3742
cplexoptimizer
43+
crs
3844
cts
3945
currentmodule
4046
cvar
47+
dataclass
4148
deterministically
4249
dic
4350
dicts
51+
dimensionality
4452
disp
4553
dmitry
4654
docplex
4755
docplex's
56+
docstring
4857
doi
4958
dok
5059
dtype
@@ -55,22 +64,31 @@ eigen
5564
eigensolver
5665
eigensolvers
5766
eigenstate
67+
eigenstates
5868
embeddings
5969
entangler
6070
enum
6171
eq
6272
et
73+
eval
74+
evals
6375
exponentiated
76+
failsafe
6477
farhi
6578
fmin
6679
formatter
80+
frac
6781
func
82+
functools
6883
fred
6984
fval
7085
fx
86+
f'spsa
7187
gambella
7288
geq
7389
getter
90+
getters
91+
globals
7492
glover
7593
goemans
7694
goldstone
@@ -81,11 +99,13 @@ gurobi
8199
gurobioptimizer
82100
gurobipy
83101
gutmann
102+
hadfield
84103
hamilton
85104
hamiltonian
86105
hamiltonians
87106
hastings
88107
hayashi
108+
hessians
89109
hoyer
90110
https
91111
ibm
@@ -99,7 +119,9 @@ iprint
99119
ising
100120
iter
101121
iteratively
122+
jac
102123
july
124+
kandala
103125
karimi
104126
kirkpatrick
105127
kwargs
@@ -108,22 +130,28 @@ len
108130
leq
109131
lhs
110132
lin
133+
linalg
111134
linearconstraint
112135
linexpr
136+
linter
113137
lowerbound
114138
lp
139+
lse
115140
lucas
116141
macos
117142
makefile
143+
marecek
118144
masahito
119145
matplotlib
120146
maxcut
147+
maxfev
121148
maxfun
122149
maxiter
123150
mdl
124151
milp
125152
minimizer
126153
minimumeigenoptimizer
154+
modelspace
127155
mmp
128156
mpm
129157
multiset
@@ -132,9 +160,13 @@ nannicini
132160
natively
133161
ndarray
134162
ndarrays
163+
nones
135164
noop
165+
nelder
136166
networkx
137167
neven
168+
nfev
169+
nft
138170
nosignatures
139171
np
140172
num
@@ -147,18 +179,23 @@ optimality
147179
optimizationresult
148180
optimizationresultstatus
149181
optimizers
182+
packagebut
150183
panchenko
151184
param
185+
parameterizations
152186
params
153187
parikh
188+
passmanager
154189
pauli
155190
paulis
156191
peleato
157192
pmm
193+
polyfit
158194
pooya
159195
pos
160196
ppp
161197
pre
198+
preconditioner
162199
preprint
163200
prepend
164201
presolver
@@ -187,6 +224,8 @@ qubo
187224
readme
188225
repr
189226
representable
227+
resamplings
228+
rescaling
190229
rhobeg
191230
rhoend
192231
rhs
@@ -196,22 +235,30 @@ robert
196235
ronagh
197236
rtype
198237
runtime
238+
rustworkx
199239
ry
200240
rz
201241
sahar
202242
scipy
203243
sdp
244+
serializable
204245
sherrington
205246
simonetto
206247
slsqp
207248
smode
208249
smoothen
250+
spall
251+
spedalieri
209252
spsa
210253
src
211254
statevector
212255
stdout
213256
stephen
257+
steppable
258+
stepsize
214259
str
260+
subclassed
261+
subclasses
215262
subcollection
216263
subgraph
217264
submodules
@@ -222,6 +269,7 @@ summands
222269
tavernelli
223270
terra
224271
th
272+
tnc
225273
toctree
226274
todok
227275
tol
@@ -241,13 +289,17 @@ variational
241289
vartype
242290
vqe
243291
vqeresult
292+
utils
244293
writelines
294+
xatol
245295
xixj
296+
xopt
246297
wavefunction
247298
wecker
248299
whitespace
249300
wiesner
250301
williamson
302+
woerner
251303
xs
252304
ys
253305
zemlin

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,12 @@ from docplex.mp.model import Model
7070

7171
from qiskit_optimization.algorithms import MinimumEigenOptimizer
7272
from qiskit_optimization.translators import from_docplex_mp
73+
from qiskit_optimization.utils import algorithm_globals
74+
from qiskit_optimization.minimum_eigensolvers import QAOA
75+
from qiskit_optimization.optimizers import SPSA
7376

7477
from qiskit.primitives import Sampler
7578

76-
from qiskit_algorithms.utils import algorithm_globals
77-
from qiskit_algorithms import QAOA
78-
from qiskit_algorithms.optimizers import SPSA
79-
8079
# Generate a graph of 4 nodes
8180
n = 4
8281
edges = [(0, 1, 1.0), (0, 2, 1.0), (0, 3, 1.0), (1, 2, 1.0), (2, 3, 1.0)] # (node_i, node_j, weight)

docs/tutorials/06_examples_max_cut_and_tsp.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,11 +527,11 @@
527527
"source": [
528528
"## Traveling Salesman Problem\n",
529529
"\n",
530-
"In addition to being a notorious NP-complete problem that has drawn the attention of computer scientists and mathematicians for over two centuries, the Traveling Salesman Problem (TSP) has important bearings on finance and marketing, as its name suggests. Colloquially speaking, the traveling salesman is a person that goes from city to city to sell merchandise. The objective in this case is to find the shortest path that would enable the salesman to visit all the cities and return to its hometown, i.e. the city where he started traveling. By doing this, the salesman gets to maximize potential sales in the least amount of time. \n",
530+
"In addition to being a notorious NP-complete problem that has drawn the attention of computer scientists and mathematicians for over two centuries, the Traveling Salesman Problem (TSP) has important bearings on finance and marketing, as its name suggests. Colloquially speaking, the traveling salesman is a person that goes from city to city to sell merchandise. The objective in this case is to find the shortest path that would enable the salesman to visit all the cities and return to his hometown, i.e. the city where he started traveling. By doing this, the salesman gets to maximize potential sales in the least amount of time. \n",
531531
"\n",
532532
"The problem derives its importance from its \"hardness\" and ubiquitous equivalence to other relevant combinatorial optimization problems that arise in practice.\n",
533533
" \n",
534-
"The mathematical formulation with some early analysis was proposed by W.R. Hamilton in the early 19th century. Mathematically the problem is, as in the case of Max-Cut, best abstracted in terms of graphs. The TSP on the nodes of a graph asks for the shortest *Hamiltonian cycle* that can be taken through each of the nodes. A Hamilton cycle is a closed path that uses every vertex of a graph once. The general solution is unknown and an algorithm that finds it efficiently (e.g., in polynomial time) is not expected to exist.\n",
534+
"The mathematical formulation with some early analysis was proposed by W.R. Hamilton in the early 19th century. Mathematically the problem is, as in the case of Max-Cut, best abstracted in terms of graphs. The TSP on the nodes of a graph asks for the shortest *Hamiltonian cycle* that can be taken through each of the nodes. A Hamiltonian cycle is a closed path that uses every vertex of a graph once. The general solution is unknown and an algorithm that finds it efficiently (e.g., in polynomial time) is not expected to exist.\n",
535535
"\n",
536536
"Find the shortest Hamiltonian cycle in a graph $G=(V,E)$ with $n=|V|$ nodes and distances, $w_{ij}$ (distance from vertex $i$ to vertex $j$). A Hamiltonian cycle is described by $N^2$ variables $x_{i,p}$, where $i$ represents the node and $p$ represents its order in a prospective cycle. The decision variable takes the value 1 if the solution occurs at node $i$ at time order $p$. We require that every node can only appear once in the cycle, and for each time a node has to occur. This amounts to the two constraints (here and in the following, whenever not specified, the summands run over 0,1,...N-1)\n",
537537
"\n",

qiskit_optimization/__init__.py

Lines changed: 9 additions & 3 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 2019, 2024.
3+
# (C) Copyright IBM 2019, 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
@@ -85,9 +85,15 @@
8585
8686
"""
8787

88-
from .exceptions import QiskitOptimizationError
88+
from .exceptions import QiskitOptimizationError, AlgorithmError
8989
from .infinity import INFINITY # must be at the top of the file
9090
from .problems.quadratic_program import QuadraticProgram
9191
from .version import __version__
9292

93-
__all__ = ["__version__", "QuadraticProgram", "QiskitOptimizationError", "INFINITY"]
93+
__all__ = [
94+
"__version__",
95+
"QuadraticProgram",
96+
"QiskitOptimizationError",
97+
"AlgorithmError",
98+
"INFINITY",
99+
]

qiskit_optimization/algorithm_job.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# This code is part of a Qiskit project.
2+
#
3+
# (C) Copyright IBM 2022, 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+
"""
14+
AlgorithmJob class
15+
"""
16+
from qiskit.primitives.primitive_job import PrimitiveJob
17+
18+
19+
class AlgorithmJob(PrimitiveJob):
20+
"""
21+
This class is introduced for typing purposes and provides no
22+
additional function beyond that inherited from its parents.
23+
24+
Update: :meth:`AlgorithmJob.submit()` method added. See its
25+
documentation for more info.
26+
"""
27+
28+
def submit(self) -> None:
29+
"""
30+
Submit the job for execution.
31+
32+
For V1 primitives, Qiskit ``PrimitiveJob`` subclassed JobV1 and defined ``submit()``.
33+
``PrimitiveJob`` was updated for V2 primitives, no longer subclasses ``JobV1``, and
34+
now has a private ``_submit()`` method, with ``submit()`` being deprecated as of
35+
Qiskit version 0.46. This maintains the ``submit()`` for ``AlgorithmJob`` here as
36+
it's called in many places for such a job. An alternative could be to make
37+
0.46 the required minimum version and alter all algorithm's call sites to use
38+
``_submit()`` and make this an empty class again as it once was. For now this
39+
way maintains compatibility with the current min version of 0.44.
40+
"""
41+
# TODO: Considering changing this in the future - see above docstring.
42+
try:
43+
super()._submit()
44+
except AttributeError:
45+
super().submit() # pylint: disable=no-member

0 commit comments

Comments
 (0)