def setUp(self):
     super().setUp()
     pauli_dict = {
         'paulis': [{"coeff": {"imag": 0.0, "real": -1.052373245772859}, "label": "II"},
                    {"coeff": {"imag": 0.0, "real": 0.39793742484318045}, "label": "ZI"},
                    {"coeff": {"imag": 0.0, "real": -0.39793742484318045}, "label": "IZ"},
                    {"coeff": {"imag": 0.0, "real": -0.01128010425623538}, "label": "ZZ"},
                    {"coeff": {"imag": 0.0, "real": 0.18093119978423156}, "label": "XX"}
                    ]
     }
     self.qubit_op = WeightedPauliOperator.from_dict(pauli_dict).to_opflow()
示例#2
0
 def setUp(self):
     """ Set the problem. """
     super().setUp()
     aqua_globals.random_seed = 50
     pauli_dict = {
         'paulis': [{"coeff": {"imag": 0.0, "real": -1.052373245772859}, "label": "II"},
                    {"coeff": {"imag": 0.0, "real": 0.39793742484318045}, "label": "IZ"},
                    {"coeff": {"imag": 0.0, "real": -0.39793742484318045}, "label": "ZI"},
                    {"coeff": {"imag": 0.0, "real": -0.01128010425623538}, "label": "ZZ"},
                    {"coeff": {"imag": 0.0, "real": 0.18093119978423156}, "label": "XX"}
                    ]
     }
     self.qubit_op = WeightedPauliOperator.from_dict(pauli_dict)
示例#3
0
 def test_legacy_operator(self):
     """Test the VQE accepts and converts the legacy WeightedPauliOperator."""
     pauli_dict = {
         'paulis': [{
             "coeff": {
                 "imag": 0.0,
                 "real": -1.052373245772859
             },
             "label": "II"
         }, {
             "coeff": {
                 "imag": 0.0,
                 "real": 0.39793742484318045
             },
             "label": "IZ"
         }, {
             "coeff": {
                 "imag": 0.0,
                 "real": -0.39793742484318045
             },
             "label": "ZI"
         }, {
             "coeff": {
                 "imag": 0.0,
                 "real": -0.01128010425623538
             },
             "label": "ZZ"
         }, {
             "coeff": {
                 "imag": 0.0,
                 "real": 0.18093119978423156
             },
             "label": "XX"
         }]
     }
     h2_op = WeightedPauliOperator.from_dict(pauli_dict)
     vqe = VQE(h2_op)
     self.assertEqual(vqe.operator, self.h2_op)
    def setUp(self):
        super().setUp()
        pauli_dict = {
            'paulis': [{
                "coeff": {
                    "imag": 0.0,
                    "real": -1.052373245772859
                },
                "label": "II"
            }, {
                "coeff": {
                    "imag": 0.0,
                    "real": 0.39793742484318045
                },
                "label": "ZI"
            }, {
                "coeff": {
                    "imag": 0.0,
                    "real": -0.39793742484318045
                },
                "label": "IZ"
            }, {
                "coeff": {
                    "imag": 0.0,
                    "real": -0.01128010425623538
                },
                "label": "ZZ"
            }, {
                "coeff": {
                    "imag": 0.0,
                    "real": 0.18093119978423156
                },
                "label": "XX"
            }]
        }
        self.qubit_op = WeightedPauliOperator.from_dict(pauli_dict).to_opflow()

        aux_dict_1 = {
            'paulis': [{
                'coeff': {
                    'imag': 0.0,
                    'real': 2.0
                },
                'label': 'II'
            }]
        }
        aux_dict_2 = {
            'paulis': [{
                'coeff': {
                    'imag': 0.0,
                    'real': 0.5
                },
                'label': 'II'
            }, {
                'coeff': {
                    'imag': 0.0,
                    'real': 0.5
                },
                'label': 'ZZ'
            }, {
                'coeff': {
                    'imag': 0.0,
                    'real': 0.5
                },
                'label': 'YY'
            }, {
                'coeff': {
                    'imag': 0.0,
                    'real': -0.5
                },
                'label': 'XX'
            }]
        }
        self.aux_ops = [
            WeightedPauliOperator.from_dict(aux_dict_1).to_opflow(),
            WeightedPauliOperator.from_dict(aux_dict_2).to_opflow()
        ]