9999b6e4d5022ef678087b221273378330a229bd,qiskit/optimization/algorithms/minimum_eigen_optimizer.py,MinimumEigenOptimizer,solve,#MinimumEigenOptimizer#Any#,128

Before Change


        self._verify_compatibility(problem)

        // convert problem to QUBO
        qubo_converter = QuadraticProgramToQubo()
        problem_ = qubo_converter.encode(problem)

        // construct operator and offset
        operator_converter = QuadraticProgramToIsing()

After Change


        self._verify_compatibility(problem)

        // convert problem to QUBO
        problem_ = self._qubo_converter.convert(problem)

        // construct operator and offset
        operator, offset = problem_.to_ising()

        // only try to solve non-empty Ising Hamiltonians
        x = None  // type: Optional[Any]
        if operator.num_qubits > 0:

            // approximate ground state of operator using min eigen solver
            eigen_results = self._min_eigen_solver.compute_minimum_eigenvalue(operator)

            // analyze results
            // backend = getattr(self._min_eigen_solver, "quantum_instance", None)
            samples = _eigenvector_to_solutions(eigen_results.eigenstate, problem_)
            // print(offset, samples)
            // samples = [(res[0], problem_.objective.sense.value * (res[1] + offset), res[2])
            //    for res in samples]
            samples.sort(key=lambda x: problem_.objective.sense.value * x[1])
            x = samples[0][0]
            fval = samples[0][1]

        // if Hamiltonian is empty, then the objective function is constant to the offset
        else:
            x = [0]*problem_.get_num_binary_vars()
            fval = offset
            x_str = "0"*problem_.get_num_binary_vars()
            samples = [(x_str, offset, 1.0)]

        // translate result back to integers
        opt_res = MinimumEigenOptimizerResult(x=x, fval=fval, samples=samples,
                                              results={"qubo_converter": copy.deepcopy(
                                                  self._qubo_converter)},
                                              variables=problem.variables)
        opt_res = cast(MinimumEigenOptimizerResult, self._qubo_converter.interpret(opt_res))

        // translate results back to original problem
        return opt_res
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 6

Instances


Project Name: Qiskit/qiskit-aqua
Commit Name: 9999b6e4d5022ef678087b221273378330a229bd
Time: 2020-08-03
Author: 47442626+a-matsuo@users.noreply.github.com
File Name: qiskit/optimization/algorithms/minimum_eigen_optimizer.py
Class Name: MinimumEigenOptimizer
Method Name: solve


Project Name: Qiskit/qiskit-aqua
Commit Name: 9999b6e4d5022ef678087b221273378330a229bd
Time: 2020-08-03
Author: 47442626+a-matsuo@users.noreply.github.com
File Name: qiskit/optimization/algorithms/grover_optimizer.py
Class Name: GroverOptimizer
Method Name: solve


Project Name: Qiskit/qiskit-aqua
Commit Name: 9999b6e4d5022ef678087b221273378330a229bd
Time: 2020-08-03
Author: 47442626+a-matsuo@users.noreply.github.com
File Name: qiskit/optimization/algorithms/minimum_eigen_optimizer.py
Class Name: MinimumEigenOptimizer
Method Name: solve


Project Name: Qiskit/qiskit-aqua
Commit Name: 9999b6e4d5022ef678087b221273378330a229bd
Time: 2020-08-03
Author: 47442626+a-matsuo@users.noreply.github.com
File Name: qiskit/optimization/algorithms/recursive_minimum_eigen_optimizer.py
Class Name: RecursiveMinimumEigenOptimizer
Method Name: solve