A production line can incur costs whenever the required paint color changes between successive jobs. In a simplified benchmark, the sequence of bodies is fixed and each body appears twice, with its two appearances requiring opposite colors. The decision is which appearance receives which color.

One variable per body is enough to express a sequence-wide objective. It also shows how repeated occurrences of a decision can create interactions between variables far apart in a physical sequence.

One variable for each body

Let xi be the color assigned to the first appearance of body i, encoded as zero or one. Its second appearance must use 1 − xi. At each position t, the color ct is thus either xi or 1 − xi for the body occupying that position.

The number of switches between adjacent positions is ∑t(ct + ct+1 − 2ctct+1). Substituting the expressions for the colors produces a quadratic polynomial in the body variables. There is no need to encode the opposite-color rule with a penalty because it is already built into the representation.

Consecutive occurrences of the same body always contribute one switch, a constant. Repeated terms between distinct bodies can reinforce or cancel after expansion.

Illustration: standalone Python calculation.

from itertools import product
sequence='ABACBC'
def colors(x):
    seen=set(); out=[]
    for c in sequence:
        i='ABC'.index(c)
        out.append(1-x[i] if c in seen else x[i])
        seen.add(c)
    return out
def switches(x):
    a=colors(x)
    return sum(i!=j for i,j in zip(a,a[1:]))
best=min(product((0,1),repeat=3),key=switches)
assert switches(best)==2

For this example the sequence is fixed and there are three decisions. The enumerated minimum is two switches. One optimal color sequence is 001110. In a longer sequence, several consecutive appearances can generate repeated quadratic terms between the same pair of body variables; their coefficients should be combined.

The mathematical representation is useful in two ways

A classical binary optimizer searches directly for the assignment that reduces switches. A quantum optimization experiment can turn the quadratic polynomial into a cost Hamiltonian and use an ansatz such as QAOA. Its circuit complexity depends on the number of distinct nonzero interactions after combining coefficients, and on how those interactions fit the hardware.

For an evaluation, generate the same sequences for both methods and compare with enumeration on small instances and a documented heuristic on larger ones. Independently reconstruct the color sequence and count every change. Compile the corresponding quantum circuits for a fixed target and record their hardware-specific cost. The objective remains identical throughout.

The simplified benchmark isolates a particular sequencing decision. An industrial paint shop may have more colors, batches, buffer constraints and production rules. Those requirements call for a more detailed model. The binary example shows how the mathematical structure can be understood first, before choosing the algorithms to investigate.

Study the sequencing model with the 4colors Optimizer for QUBO and evaluate a corresponding circuit with the 4colors Quantum Compiler.