Worked Max-Cut and QUBO Examples
Trace small models from objective and Hamiltonian to candidate assignments and exact classical verification.
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
}
| Assignment | Cut | Ideal probability | Count |
|---|---|---|---|
| 000 | 0 | 0.01987622 | 25 |
| 001 | 2 | 0.16004126 | 184 |
| 010 | 2 | 0.16004126 | 146 |
| 011 | 2 | 0.16004126 | 161 |
| 100 | 2 | 0.16004126 | 164 |
| 101 | 2 | 0.16004126 | 155 |
| 110 | 2 | 0.16004126 | 171 |
| 111 | 0 | 0.01987622 | 18 |
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.
| x0 x1 | z0 z1 | E(x)=H(z) |
|---|---|---|
| 00 | +1 +1 | 0 |
| 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.