Optimization

Weighted QAOA MaxCut

Difficulty: Medium ★★

Build a QAOA ansatz for any weighted graph and any depth p. Edges can carry negative weights and can be listed with either endpoint first.

Objective

build_qaoa_circuit(num_nodes, edges, gammas, betas) receives edges as (u, v, w) tuples and p = len(gammas) angle pairs. Start in |+>^n. For each layer apply exp(-i gamma * sum w Z_u Z_v), then exp(-i beta * sum X_i). Return the resulting state-preparation circuit.

Constraints

  • No PauliEvolutionGate / QAOAAnsatz shortcuts.

Entry Point

build_qaoa_circuit

Checks

  • Exports build_qaoa_circuit(num_nodes, edges, gammas, betas).
  • Matches reference states for weighted triangle, ring and p = 3 graphs.

Your Code

Outputpending

Execution results will appear here.