Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MinimumEigenOptimizer fails with QAOAProgram #222

Closed
lasys opened this issue Aug 4, 2021 · 0 comments · Fixed by #223
Closed

MinimumEigenOptimizer fails with QAOAProgram #222

lasys opened this issue Aug 4, 2021 · 0 comments · Fixed by #223
Assignees

Comments

@lasys
Copy link
Contributor

lasys commented Aug 4, 2021

Information

  • Qiskit Optimization version: 0.2.1
  • Qiskit version: 0.29
  • Python version: 3.7.11
  • Operating system: Linux

What is the current behavior?

Program ends with error:

---------------------------------------------------------------------------
QiskitOptimizationError                   Traceback (most recent call last)
<ipython-input-11-bad44e8258c2> in <module>()
----> 1 algorithm = MinimumEigenOptimizer(runtime_qaoa)
      2 result = algorithm.solve(qubit_op)

/usr/local/lib/python3.7/dist-packages/qiskit_optimization/algorithms/minimum_eigen_optimizer.py in __init__(self, min_eigen_solver, penalty, converters)
    141         if not min_eigen_solver.supports_aux_operators():
    142             raise QiskitOptimizationError(
--> 143                 "Given MinimumEigensolver does not return the eigenstate "
    144                 + "and is not supported by the MinimumEigenOptimizer."
    145             )

QiskitOptimizationError: 'Given MinimumEigensolver does not return the eigenstate and is not supported by the MinimumEigenOptimizer.'

Steps to reproduce the problem

import networkx as nx
import numpy as np
from qiskit_optimization.runtime import QAOAProgram
from qiskit_optimization.converters import QuadraticProgramToQubo
from qiskit_optimization.applications.max_cut import Maxcut

# Generate a graph of 5 nodes
n = 5
graph = nx.Graph()
graph.add_nodes_from(np.arange(0, n, 1))
elist= [(0, 1, 3), (0, 2, 1), (1, 2, 1), (3, 2, 6), (3, 4, 1), (4, 2, 2)]
graph.add_weighted_edges_from(elist)

max_cut = Maxcut(graph)
qubit_op = max_cut.to_quadratic_program()

optimizer = {'name': 'SPSA', 'maxiter': 50}

backend = provider.get_backend('ibmq_qasm_simulator')

runtime_qaoa = QAOAProgram(
                         callback=None,
                         optimizer=optimizer,
                         initial_point=None,
                         provider=provider,
                         backend=backend,
                         shots=8192,
                         measurement_error_mitigation=True)

algorithm = MinimumEigenOptimizer(runtime_qaoa)
result = algorithm.solve(qubit_op)

What is the expected behavior?

Program should run without error.

Suggested solutions

Override classmethod supports_aux_operators in VQEProgram and return True.
I am already in the process of providing a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants