Skip to content

Commit 2cc1275

Browse files
committed
Added the max_iter=50 as a keyword in solve_QUBO for more customizability, also set print_res=False as default
1 parent f289829 commit 2cc1275

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/qrisp/qaoa/problems/QUBO.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def QUBO_problem(Q):
111111
return QAOAProblem(create_QUBO_cost_operator(Q), RX_mixer, create_QUBO_cl_cost_function(Q))
112112

113113

114-
def solve_QUBO(Q, depth, backend = None, n_solutions = 1, print_res = True):
114+
def solve_QUBO(Q, depth, max_iter = 50, backend = None, n_solutions = 1, print_res = False):
115115
"""
116116
Solves a Quadratic Unconstrained Binary Optimization (QUBO) problem using the Quantum Approximate Optimization Algorithm (QAOA).
117117
The function imports the default backend from the 'qrisp.default_backend' module.
@@ -126,6 +126,8 @@ def solve_QUBO(Q, depth, backend = None, n_solutions = 1, print_res = True):
126126
QUBO matrix to solve.
127127
depth : int
128128
The depth (amount of layers) of the QAOA circuit.
129+
max_iter : int
130+
The maximal amount of iterations of the COBYLA optimizer in the QAOA algorithm.
129131
backend : str
130132
The backend to be used for the quantum/annealing simulation.
131133
n_solutions : int
@@ -151,7 +153,7 @@ def solve_QUBO(Q, depth, backend = None, n_solutions = 1, print_res = True):
151153
backend = backend
152154

153155
# Run QAOA with given quantum arguments, depth, measurement keyword arguments and maximum iterations for optimization
154-
res = QUBO_instance.run(qarg, depth, mes_kwargs={"backend" : backend}, max_iter = 50) # runs the simulation
156+
res = QUBO_instance.run(qarg, depth, mes_kwargs={"backend" : backend}, max_iter = max_iter) # runs the simulation
155157
res = dict(list(res.items())[:n_solutions])
156158

157159
# Calculate the cost for each solution

0 commit comments

Comments
 (0)