Exemple #1
0
 def test_clique(self):
     """ Clique test """
     algo = NumPyMinimumEigensolver(self.qubit_op, aux_operators=[])
     result = algo.run()
     x = sample_most_likely(result.eigenstate)
     ising_sol = clique.get_graph_solution(x)
     np.testing.assert_array_equal(ising_sol, [1, 1, 1, 1, 1])
     oracle = self._brute_force()
     self.assertEqual(clique.satisfy_or_not(ising_sol, self.w, self.k),
                      oracle)
Exemple #2
0
 def test_clique_vqe(self):
     """ VQE Clique test """
     aqua_globals.random_seed = 10598
     result = VQE(self.qubit_op,
                  RealAmplitudes(reps=5, entanglement='linear'),
                  COBYLA(),
                  max_evals_grouped=2).run(
                      QuantumInstance(
                          BasicAer.get_backend('statevector_simulator'),
                          seed_simulator=aqua_globals.random_seed,
                          seed_transpiler=aqua_globals.random_seed))
     x = sample_most_likely(result.eigenstate)
     ising_sol = clique.get_graph_solution(x)
     np.testing.assert_array_equal(ising_sol, [1, 1, 1, 1, 1])
     oracle = self._brute_force()
     self.assertEqual(clique.satisfy_or_not(ising_sol, self.w, self.k),
                      oracle)