QAOA for maxcut cost function

用于 MaxCut 的 QAOA |PennyLane 演示
I have a problem that Why here is

neg_obj -= 0.5 * (1 - circuit(gammas, betas, edge=edge, n_layers=n_layers))

the cost function is C_{ij} = 1/2(1 − Z_j Z_k)
circuit()=Z_jZ_k?

    def objective(params):
        gammas = params[0]
        betas = params[1]
        neg_obj = 0
        for edge in graph:
            # objective for the MaxCut problem
            neg_obj -= 0.5 * (1 - circuit(gammas, betas, edge=edge, n_layers=n_layers))
        return neg_obj

Thank you for your reply!
Best wishes.

Hey @ming,

C_{ij} is (i, j) “element” of the cost function. The full cost function is C = \sum_{i, j} C_{ij}. Each edge in the graph represents one (i, j) pair, so that’s why we’re summing over the edges in the objective function above.

Hope this helps!