Release Notes#

0.6.0#

Prelude#

Qiskit Optimization has been migrated to the qiskit-community Github organization to further emphasize that it is a community-driven project. To reflect this change and because we are on-boarding additional code owners and maintainers, with this version (0.6) we have decided to remove all deprecated code, regardless of the time of its deprecation. This ensures that the new members of the development team do not have a large bulk of legacy code to maintain. This can mean one of two things for you as the end-user:

  1. Nothing, if you already migrated your code and no longer rely on any deprecated features.

  2. Otherwise, you need to migrate your code immediately. If you cannot do that, or want to continue using some of the features that were removed, you should pin your version of Qiskit Optimization to 0.5

You can check out the migration guides for details on how to update your code. For more context on the changes around Qiskit Optimization and the other application projects as well as the algorithms library in Qiskit, be sure to read this blog post.

Qiskit Optimization 0.6 switches from qiskit.algorithms of Qiskit to Qiskit Algorithms. Qiskit Optimization 0.6 drops supports of the former algorithms based on qiskit.algorithms, QuantumInstance, and Opflow of Qiskit.

New Features#

  • Added a new optimization algorithm, QuantumRandomAccessOptimizer. This approach incorporates Quantum Random Access Codes (QRACs) as a tool to encode multiple classical binary variables into a single qubit, thereby saving quantum resources and enabling exploration of larger problem instances on a quantum computer. The encodings produce a local quantum Hamiltonian whose ground state can be approximated with standard algorithms such as VQE, and then rounded to yield approximation solutions of the original problem.

    QuantumRandomAccessOptimizer has two methods for solving problems, solve() and solve_relaxed(). The solve method provides a seamless workflow by automatically managing the encoding and rounding procedures, as demonstrated in the example below. This allows for a simplified and streamlined user experience. On the other hand, the solve_relaxed method offers the flexibility to break the computation process into distinct steps. This feature can be advantageous when we need to compare solutions obtained from different rounding schemes applied to a potential ground state.

    For example:

    from qiskit_algorithms.optimizers import COBYLA
    from qiskit_algorithms import VQE
    from qiskit.circuit.library import RealAmplitudes
    from qiskit.primitives import Estimator
    
    from qiskit_optimization.algorithms.qrao import (
        QuantumRandomAccessOptimizer,
        QuantumRandomAccessEncoding,
        SemideterministicRounding,
    )
    from qiskit_optimization.problems import QuadraticProgram
    
    problem = QuadraticProgram()
    problem.binary_var("x")
    problem.binary_var("y")
    problem.binary_var("z")
    problem.minimize(linear={"x": 1, "y": 2, "z": 3})
    
    ansatz = RealAmplitudes(1)
    vqe = VQE(
        ansatz=ansatz,
        optimizer=COBYLA(),
        estimator=Estimator(),
    )
    # solve() automatically performs the encoding, optimization, and rounding
    qrao = QuantumRandomAccessOptimizer(min_eigen_solver=vqe)
    result = qrao.solve(problem)
    
    # solve_relaxed() only performs the optimization. The encoding and rounding must be done manually.
    # encoding
    encoding = QuantumRandomAccessEncoding(max_vars_per_qubit=3)
    encoding.encode(problem)
    # optimization
    qrao = QuantumRandomAccessOptimizer(min_eigen_solver=vqe)
    relaxed_results, rounding_context = qrao.solve_relaxed(encoding=encoding)
    # rounding
    rounding = SemideterministicRounding()
    result = rounding.round(rounding_context)
    

Upgrade Notes#

  • Added support for running with Python 3.11.

  • Support for running with Python 3.7 has been removed. To run Qiskit Optimization you need a minimum Python version of 3.8.

  • The support for QuantumInstance-based algorithms is removed. Qiskit optimization supports only Primitive-based algorithms.

  • The support for Opflow is removed to represent Ising Hamiltonians. Qiskit optimization supports only qiskit.quantum_info.SparsePauliOp, instead.

  • The classes VQEClient, QAOAClient, and VQERuntimeResult are removed. Instead, users should migrate their code to use the Qiskit Runtime Primitives with session.

  • Updated to_ising() to support returning qiskit.quantum_info.SparsePauliOp. The feature to return an Opflow operator is removed.

  • Updated from_ising() to support accepting qiskit.quantum_info.SparsePauliOp. The feature to accept an Opflow operator is removed.

  • The WarmStartQAOAOptimizer class takes the primitives-based QAOA (qiskit_algorithms.minimum_eigensolvers.QAOA) as qaoa argument. The support of the former QAOA algorithms based on qiskit.algorithms is removed.

  • The GroverOptimizer class drops the support of QuantumInstance and argument quantum_instance is removed. It supports only the Sampler primitive now.

Bug Fixes#

  • Fixed incorrect rho update when vary_rho is set to UPDATE_RHO_BY_RESIDUALS in ADMMOptimizer.

  • Fixed incorrect population of y_saved in ADMMState.

  • Fixed an issue of InequalityToEquality converter so that it adds all slack variables before adding the objective function and the constraints. The issue may have caused errors when interpreting solutions.

0.5.0#

Prelude#

Qiskit Optimization 0.5 supports the new algorithms introduced in Qiskit Terra 0.22 which in turn rely on the Qiskit Primitives. Qiskit Optimization 0.5 still supports the former algorithms based on qiskit.utils.QuantumInstance, but they will be deprecated and then removed, along with the support here, in future releases.

New Features#

  • The MinimumEigenOptimizer class takes the primitives-based algorithms (qiskit.algorithms.minimum_eigensolvers.SamplingMinimumEigensolver and qiskit.algorithms.minimum_eigensolvers.NumPyMinimumEigensolver) as min_eigen_solver argument. The former algorithm qiskit.algorithms.MinimumEigensolver is pending deprecation and will be deprecated and subsequently removed in future releases. Note that qiskit.algorithms.minimum_eigensolvers.SamplingVQE supersedes qiskit.algorithms.VQE for MinimumEigenOptimizer. qiskit.algorithms.minimum_eigensolvers.NumPyMinimumEigensolver also supersedes qiskit.algorithms.NumPyMinimumEigensolver.

  • The WarmStartQAOAOptimizer class takes the primitives-based QAOA (qiskit.algorithms.minimum_eigensolvers.QAOA) as qaoa argument. The former algorithm qiskit.algorithms.QAOA is pending deprecation and will be deprecated and subsequently removed in future releases.

  • The GroverOptimizer class has a new keyword argument, sampler which is used to run the algorithm using an instance of the qiskit.primitives.BaseSampler interface to calculate the results. This new argument supersedes the the quantum_instance argument and accordingly, quantum_instance is pending deprecation and will be deprecated and subsequently removed in future releases.

Upgrade Notes#

  • The previously deprecated VQEProgram and QAOAProgram classes have been removed. They were originally deprecated in the Qiskit Optimization 0.3.0 release.

Bug Fixes#

  • Fixed an issue that parse_tsplib_format() did not parse TSPLIB files correctly in all cases; in particular if extra whitespace existed around keywords or if an EOF keyword was present.

0.4.0#

New Features#

  • Adds a method prettyprint() to QuadraticProgram to generate a pretty-printed string of the object.

    Here is an example of pretty printing.

    from qiskit_optimization import QuadraticProgram
    
    qp = QuadraticProgram('problem 1')
    qp.integer_var(-1, 2, 'x')
    qp.integer_var(-1, 2, 'y')
    qp.continuous_var(-1, name='z')
    qp.binary_var('u')
    qp.binary_var('v')
    qp.binary_var_list(10)
    qp.integer_var_list(3)
    qp.continuous_var_list(3)
    qp.minimize(constant=3, linear={'x': 2, 'y': 3}, quadratic={('u', 'x'): -1})
    qp.linear_constraint({'x': 1, 'y': -2}, '>=', 2, name='lin_GE')
    qp.linear_constraint({'x': 2, 'y': -1}, '==', 1, name='lin_EQ')
    qp.quadratic_constraint({'x': 1, 'u': 1}, {(3, 4): 1, (5, 6): -1}, '<=', 1, name='quad_LE')
    qp.quadratic_constraint({'x': 2, 'y': -1}, {('z', 'z'): -1}, '<=', 1)
    
    print(qp.prettyprint())
    

    The output is as follows.

    Problem name: problem 1
    
    Minimize
      -x*u + 2*x + 3*y + 3
    
    Subject to
      Linear constraints (2)
        x - 2*y >= 2  'lin_GE'
        2*x - y == 1  'lin_EQ'
    
      Quadratic constraints (2)
        u*v - x5*x6 + u + x <= 1  'quad_LE'
        -z^2 + 2*x - y <= 1  'q1'
    
      Integer variables (5)
        -1 <= x <= 2
        -1 <= y <= 2
        0 <= x15
        0 <= x16
        0 <= x17
    
      Continuous variables (4)
        -1 <= z
        0 <= x18
        0 <= x19
        0 <= x20
    
      Binary variables (12)
        u v x5 x6 x7 x8 x9 x10 x11 x12 x13 x14
    

Upgrade Notes#

  • If users set an empty variable name "" with binary_var(), integer_var(), and continuous_var(), they set the default variable name (e.g., x0) while they used to set the empty name as variable name.

    from qiskit_optimization.problems import QuadraticProgram
    
    qp = QuadraticProgram()
    x = qp.binary_var(name="")
    y = qp.integer_var(name="")
    z = qp.continuous_var(name="")
    print(x.name)  # x0
    print(y.name)  # x1
    print(z.name)  # x2
    
  • Added support for running with Python 3.10. At the the time of the release, Cplex didn’t have a python 3.10 version and Docplex failed inside docplex.mp.model.Model.binary_var_list().

  • Updates the text format of str and repr of the following objects so that the output is one line.

    If users want to display a multi-line text of QuadraticProgram and OptimizationResult, please use QuadraticProgram’s prettyprint() and OptimizationResult’s prettyprint(), respectively.

    # An example of OptimizationResult
    from qiskit_optimization.problems import QuadraticProgram
    from qiskit_optimization.algorithms import OptimizationResult, OptimizationResultStatus
    
    qp = QuadraticProgram()
    x = qp.binary_var_list(3)
    result = OptimizationResult([1.0,2.0,3.0], 10.0, x, OptimizationResultStatus.SUCCESS)
    
    print(repr(result))
    # <OptimizationResult: fval=10.0, x0=1.0, x1=2.0, x2=3.0, status=SUCCESS>
    
    print(str(result))
    # fval=10.0, x0=1.0, x1=2.0, x2=3.0, status=SUCCESS
    
    print(result.prettyprint())
    # objective function value: 10.0
    # variable values: x0=1.0, x1=2.0, x2=3.0
    # status: SUCCESS
    
    from qiskit_optimization.problems import QuadraticProgram
    
    qp = QuadraticProgram('problem 1')
    qp.integer_var(-1, 2, 'x')
    qp.integer_var(-1, 2, 'y')
    qp.continuous_var(-1, name='z')
    qp.minimize(constant=3, linear={'x': 2, 'y': 3}, quadratic={('z', 'x'): -1})
    qp.linear_constraint({'x': 1, 'y': -2}, '>=', 2, name='lin_GE')
    qp.linear_constraint({'x': 2, 'y': -1}, '==', 1, name='lin_EQ')
    qp.quadratic_constraint({'x': 2, 'y': -1}, {('z', 'z'): -1}, '<=', 1)
    
    print(repr(qp))
    # <QuadraticProgram: minimize -x*z + 2*x + 3*y + 3, 3 variables, 3 constraints, 'problem 1'>
    
    print(str(qp))
    # minimize -x*z + 2*x + 3*y + 3 (3 variables, 3 constraints, 'problem 1')
    
    print(qp.prettyprint())
    # Problem name: problem 1
    #
    # Minimize
    #   -x*z + 2*x + 3*y + 3
    #
    # Subject to
    #   Linear constraints (2)
    #     x - 2*y >= 2  'lin_GE'
    #     2*x - y == 1  'lin_EQ'
    #
    #   Quadratic constraints (1)
    #     -z^2 + 2*x - y <= 1  'q0'
    #
    #   Integer variables (2)
    #     -1 <= x <= 2
    #     -1 <= y <= 2
    #
    #   Continuous variables (1)
    #     -1 <= z
    
  • The previously deprecated BaseBackend class has been removed. It was originally deprecated in the Qiskit Terra 0.18.0 release.

  • Enable installation of CPLEX for Python 3.10.

  • Support for running with Python 3.6 has been removed. To run Optimization you need a minimum Python version of 3.7.

Bug Fixes#

  • Fixed an issue that from_ising() raises an error when Pauli I is given.

  • Fixed an issue that to_ising() returns a wrong operator when there is no variable in an input problem.

Other Notes#

  • Shows a warning message if non-printable strings are set to QuadraticProgram as problem name, variable name, or constraint name.

  • Updated the documentation of SUCCESS of OptimizationResultStatus. SUCCESS means the obtained solution is feasible, but not always optimal because some algorithms do not guarantee the optimality.

  • Reword the documentation of all methods and the multi-line text format of OptimizationResult as follows because some algorithms do not guarantee the optimality.

    • “optimal function value” → “objective function value”

    • “optimal value” → “variable values”

0.3.0#

New Features#

  • Added the runtime client QAOAClient to execute the QAOA algorithm on Qiskit runtime. This runtime program leverages QAOA dedicated transpiler passes such as swap strategies and pulse-efficient transpiler passes for cross-resonance based hardware. Both these optimizations can significantly reduce circuit depth and improve execution time and results. Further, the QAOA runtime also allows using CVaR expectation values, which can improve the performance of ground state calculations in optimization settings.

    The client can for instance be used as

    from qiskit import IBMQ
    from qiskit.algorithms.optimizers import COBYLA
    from qiskit.opflow import I, Z
    from qiskit_optimization.runtime import QAOAClient
    
    # get the provider and backend we use to run the program
    IBMQ.load_account()
    provider = IBMQ.get_provider(hub="ibm-q", group="open", project="main")
    backend = provider.get_backend("ibmq_qasm_simulator")
    
    # define diagonal Hamiltonian whose minimum eigenvalue we want to find
    op =  (Z ^ Z ^ I ^ I ^ I) - (I ^ I ^ Z ^ Z ^ I) 
    
    # set up the client and solve the problem
    client = QAOAClient(
        reps=2,  # use p=2 repetitions in the QAOA ansatz
        optimizer=COBYLA(), 
        alpha=0.75,  # use CVaR expectation with 75% of the best readouts
        provider=provider, 
        backend=backend
    )
    result = client.compute_minimum_eigenvalue(op)
    

    See also the new QAOA Runtime tutorial in docs/tutorials/12_qaoa_runtime.ipynb for more details.

  • Introduced the Sherrington-Kirkpatrick (SK) model [1] qiskit_optimization.applications.SKModel. The model has all-to-all ferromagnetic and antiferromagnetic interactions given by a random disorder and represents a mean-field approximation of a spin glass.

    Let \(x\in\{\pm 1\}^n\) be a configuration of spins. The SK model Hamiltonian on \(n\) sites is

    \[\begin{array}{} H(x)=-1/\sqrt{n} \sum_{i<j} w_{i,j}x_ix_j,\text{ where } i,j\in [n], \end{array}\]

    \(w_{i,j}\in\{\pm 1\}\) are called disorder and are chosen independently and uniformly at random.

    The computational problem associated with this class is to find the ground state of the SK Hamiltonian instance and its energy.

    [1]: Dmitry Panchenko. “The Sherrington-Kirkpatrick model: an overview”, https://arxiv.org/abs/1211.1094

Upgrade Notes#

  • The deprecated methods QuadraticProgram.from_docplex and QuadraticProgram.to_docplex have been removed and no longer exist. These methods were deprecated as part of the 0.2.0 release. Instead you should use from_docplex_mp() and to_docplex_mp().

Deprecation Notes#

  • Rename the runtime “programs” to runtime “clients” to avoid name confusions and reflect the fact that they are an interface for code executed in the cloud. The classes VQEProgram, QAOAProgram and VQEProgramResult have been renamed to VQEClient, QAOAClient and VQERuntimeResult, respectively.

Bug Fixes#

  • Allow Qiskit’s Optimizer classes as input for the optimizer in the VQEProgram and QAOAProgram instead of only dictionaries.

0.2.0#

New Features#

  • Adds the support of indicator constraints (e.g. x=1 -> y+z=1) in from_docplex_mp() using the big-M formulation.

  • Adds translators between Ising Hamiltonian and qiskit_optimization.problems.QuadraticProgram, from_ising() and to_ising().

  • Introduced a new converter class qiskit_optimization.converters.LinearInequalityToPenalty. It converts the following inequality constraints to penalty terms where x, y, \(x_i\) are binary variables and P is a penalty factor.

    \[\begin{split}\begin{array}{} \text { Inequality constraint } & & \text { Penalty term } \\ x \leq y & \rightarrow & P(x-x y) \\ x \geq y & \rightarrow & P(y-x y) \\ \sum_{i=1}^n x_i \leq 1, n \geq 2 & \rightarrow & P \sum_{i, j : i < j} x_i x_j\\ \sum_{i=1}^n x_i \geq n-1, n \geq 2 & \rightarrow & P \sum_{i, j : i < j} (1 - x_i) (1 - x_j) \end{array}\end{split}\]
  • Allow leveraging Qiskit Runtime to execute VQE and QAOA in the cloud using the VQEProgram and QAOAProgram.

Upgrade Notes#

  • QuadraticProgram.pprint_as_string and QuadraticProgram.prettyprint have been removed, which were deprecated in Qiskit Aqua 0.8.0 release (October 2020).

Deprecation Notes#

Bug Fixes#

  • Sorts the order of result.get_counts(qc) by bitstring in qiskit_optimization.algorithms.GroverOptimizer when qasm_simulator is used so that the algorithm behaves deterministically. The previous version sorts the counts by probabilities, but some bitstrings may have the same probability and the algorithm could behave probabilistically.