Пример #1
0
    def test_mixer_layer_errors(self):
        """Tests that the mixer layer is throwing the correct errors"""

        hamiltonian = [[1, 1], [1, 1]]

        with pytest.raises(ValueError, match=r"hamiltonian must be of type pennylane.Hamiltonian"):
            qaoa.mixer_layer(0.1, hamiltonian)
Пример #2
0
    def test_mixer_layer_output(self, mixer, gates):
        """Tests that the gates of the mixer layer are correct"""

        alpha = 1

        with qml._queuing.OperationRecorder() as rec:
            qaoa.mixer_layer(alpha, mixer)

        for i, j in zip(rec.operations, gates):

            prep = [i.name, i.parameters, i.wires]
            target = [j.name, j.parameters, j.wires]

            assert prep == target
Пример #3
0
 def qaoa_layer(gamma, alpha):
     qaoa.cost_layer(gamma, cost_h)
     qaoa.mixer_layer(alpha, mixer_h)
Пример #4
0
 def qaoa_layer(gamma, alpha):
     qaoa.cost_layer(gamma, H_cost)
     qaoa.mixer_layer(alpha, H_mixer)
Пример #5
0
def qaoa_layer(gamma, beta):
    qaoa.cost_layer(gamma, cost_h)
    qaoa.mixer_layer(beta, mixer_h)