Skip to content

Commit

Permalink
update qiskit version
Browse files Browse the repository at this point in the history
  • Loading branch information
DeborahVolpe committed May 30, 2024
1 parent c4fb2b1 commit 91f30b3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ Research = "https://www.cda.cit.tum.de/research/quantum/"
[tool.pytest.ini_options]
minversion = "7.2"
testpaths = ["tests"]
pythonpath = ["src"]
addopts = ["-ra", "--strict-markers", "--strict-config", "--showlocals"]
log_cli_level = "info"
xfail_strict = true
Expand Down
7 changes: 4 additions & 3 deletions src/mqt/qao/solvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from qiskit.circuit.library import TwoLocal
from qiskit.primitives import Sampler
from qiskit_algorithms import QAOA, SamplingVQE
from qiskit_algorithms.optimizers import COBYLA
from qiskit_optimization.algorithms import (
GroverOptimizer,
MinimumEigenOptimizer,
Expand Down Expand Up @@ -523,7 +524,7 @@ def solve_qaoa_qubo(
problem: Problem,
auto_setting: bool = False,
num_runs: int = 10,
optimizer: Optimizer = None,
optimizer: Optimizer = COBYLA(),
reps: int = 1,
initial_state: QuantumCircuit | None = None,
mixer: QuantumCircuit = None,
Expand Down Expand Up @@ -663,7 +664,7 @@ def solve_vqe_qubo(
problem: Problem,
auto_setting: bool = False,
num_runs: int = 10,
optimizer: Optimizer | None = None,
optimizer: Optimizer = COBYLA(),
ansatz: QuantumCircuit | None = None,
initial_point: np.ndarray[Any, Any] | None = None,
aggregation: float | Callable[[list[float]], float] | None = None,
Expand Down Expand Up @@ -710,7 +711,7 @@ def solve_vqe_qubo(
compilation_time = -1
logging.getLogger("qiskit").setLevel(logging.ERROR)
res = []
if auto_setting and ansatz is None:
if auto_setting or ansatz is None:
ansatz = TwoLocal(num_qubits=len(self.qubo.variables), rotation_blocks="ry", entanglement_blocks="cz")

vqe_mes = SamplingVQE(
Expand Down
5 changes: 5 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""MQT QAO.
This file is part of the MQT QAO library released under the MIT license.
See README.md or go to https://github.com/cda-tum/mqt-predictor for more information.
"""
1 change: 1 addition & 0 deletions tests/test_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1485,6 +1485,7 @@ def test_gas_solver_basic() -> None:
solution = solver.solve_grover_adaptive_search_qubo(problem, qubit_values=6, num_runs=10)
if isinstance(solution, Solution):
all_satisfy, _each_satisfy = solution.check_constraint_optimal_solution()
print(solution.best_solution)
assert solution.best_solution == {"a": 1.0, "b": 0.0, "c": 1.0}
print(solution.best_solution)
assert solution.best_energy < -5.9 # (the range if for having no issues with numerical errors)
Expand Down

0 comments on commit 91f30b3

Please sign in to comment.