Worked Max-Cut and QUBO Examples

Trace small models from objective and Hamiltonian to candidate assignments and exact classical verification.

Documentation version: 2.0 · Compatible with: current AutomationGlance simulator · Last reviewed: 2026-10-05

A. Triangle Max-Cut

Take vertices {0,1,2} and edges {(0,1),(0,2),(1,2)}. Bit xᵢ indicates which side contains vertex i. Maximize C(x)=2x₀+2x₁+2x₂−2x₀x₁−2x₀x₂−2x₁x₂.

Substitute x=(I−Z)/2: H꜀=3I/2−(Z₀Z₁+Z₀Z₂+Z₁Z₂)/2. Equal-bit assignments 000 and 111 cut zero edges. Every other assignment cuts two; a triangle cannot have all three edges cross a binary partition. Enumeration of eight assignments proves optimum 2.

The actual p=1 circuit applies H on all three wires, then CX–RZ(−γ)–CX for each edge, then RX(2β) on all wires, then measurements 0,1,2. With the full 64-point default search it selects γ=β=π/8. Use the triangle preset or this request to POST /api/v1/quantum-model/maxcut (add your sessionId when required):

{
  "vertices": 3,
  "edges": [
    [
      0,
      1
    ],
    [
      1,
      2
    ],
    [
      0,
      2
    ]
  ],
  "targetVertices": 3,
  "targetEdges": 3,
  "qaoaDepth": 1,
  "shots": 1024,
  "seed": 42
}
Observed local reference run: 1024 shots, seed 42, .NET 10
AssignmentCutIdeal probabilityCount
00000.0198762225
00120.16004126184
01020.16004126146
01120.16004126161
10020.16004126164
10120.16004126155
11020.16004126171
11100.0198762218

Expected cut ≈1.92049513; optimal-assignment probability ≈0.96024756. The best sampled cut is 2 and the displayed approximation ratio is 2/2=1. The expected-cut/exact-optimum comparison is ≈0.96025, a different statistic. Counts are a reproducible reference for this runtime, not a guaranteed distribution for another seed or backend. Large target settings do not change this three-qubit execution.

B. Custom QUBO

Minimize E(x)=−3x₀−2x₁+4x₀x₁. This is an unconstrained supplied objective: the positive pair coefficient discourages selecting both, but no unspoken business rule is enforced.

Substitution gives −3(I−Z₀)/2−2(I−Z₁)/2+(I−Z₀−Z₁+Z₀Z₁), so H=−1.5I+0.5Z₀+0Z₁+1Z₀Z₁. The Ising constant is −1.5; linear Z coefficients are [0.5,0]; the ZZ coupling is 1. Energy scale is max(1,0.5,1)=1.

All assignments, with x0 leftmost
x0 x1z0 z1E(x)=H(z)
00+1 +10
01+1 −1−2
10−1 +1−3 (unique optimum)
11−1 −1−1

Set two variables, constant 0, linear array [-3,-2] and a single pair (0,1) with coefficient 4 in Custom QUBO. Equivalently send this to POST /api/v1/quantum-model/qubo:

{
  "variableCount": 2,
  "constant": 0,
  "linear": [
    -3,
    -2
  ],
  "quadratic": [
    {
      "i": 0,
      "j": 1,
      "coefficient": 4
    }
  ],
  "qaoaDepth": 1,
  "shots": 1024,
  "seed": 42
}

The circuit prepares |++⟩, applies RZ(γ) to q0 and CX(0,1)–RZ(2γ) on q1–CX(0,1), then RX(2β) on each wire and terminal measurement. Constant phase is omitted. Exact validation reports minimum −3 and ground state 10. The sampled candidate list is distinct from that reference; if 10 is observed its energy gap is zero, while a best sample of 01 has gap (−2)−(−3)=1.

Exported QUBO JSON retains the original coefficients; Ising fields report the derived expression. DSL and OpenQASM encode the selected-angle experiment, not a guarantee that every measurement is optimal. See methodology and penalties.