A binary optimization model can reward a forbidden decision unless its penalties represent the constraint strongly enough. A QUBO is unconstrained: it asks for a low-value assignment to binary variables. Real decisions, by contrast, often come with rules. If those rules are expressed as penalties inside the objective, how large should the penalty be?

Too small, and the solver may prefer an invalid answer. Excessively large, and the original objective can become hard to distinguish numerically or to optimize effectively. The right balance depends on the model, the range of objective values and the algorithm. A short example makes the tradeoff visible.

Two choices, one seat

Suppose two optional activities are competing for a single available room. Running activity A has a benefit of 5 units; B has a benefit of 4 units. We may choose A, B or neither, but not both. Let binary variables a and b equal 1 when their activities run.

To turn the benefits into a minimization objective, begin with −5a − 4b. Without a constraint, the minimum is obtained by setting both variables to 1, yielding −9. That is invalid because the room can host at most one activity.

We can penalize the forbidden joint selection by adding Pab, where P is a positive penalty weight. The unconstrained model becomes:

E(a, b) = −5a − 4b + Pab.
If all minimizers must be feasible, a tie is not sufficient.

This is a QUBO because every variable is binary and the objective consists of linear and quadratic terms. It does not require quantum hardware; a classical program can evaluate it just as well.

See how the penalty changes the answer

abInterpretationQUBO energy
00Neither activity0
10A only, valid−5
01B only, valid−4
11Both, invalid−9 + P

If P = 2, the invalid assignment has energy −7, lower than the best valid energy of −5. The penalty has not done its job. If P = 5, the invalid assignment has energy −4, while choosing A alone has energy −5; the lowest-energy answer is valid. The strict threshold in this example is P > 4, because the additional benefit from illegally selecting B alongside A is 4. At the boundary P = 4, the invalid assignment ties the valid best solution. If all minimizers must be feasible, a tie is not sufficient.

The same effect can be checked without a QUBO library:

It does not guarantee that a heuristic solver will actually find that optimum within its budget.
from itertools import product

def energy(a, b, penalty):
    return -5*a - 4*b + penalty*a*b

for penalty in (2, 4, 5):
    scored = [
        ((a, b), energy(a, b, penalty))
        for a, b in product((0, 1), repeat=2)
    ]
    minimum = min(score for _, score in scored)
    winners = [choice for choice, score in scored if score == minimum]
    print(f"P={penalty}: {winners}, energy={minimum}")

The example illustrates a penalty large enough to make the global QUBO optimum feasible. It does not guarantee that a heuristic solver will actually find that optimum within its budget. Modeling feasibility and solving reliability are separate questions.

What changes with real constraints

Not every rule can be encoded by multiplying two variables. Equality requirements, capacity limits and logical relationships often require squared penalties and sometimes auxiliary binary variables. Squaring a linear expression of binary variables produces at most quadratic terms, which is why expressions such as P(Σxᵢ − k)² are common when exactly k selections are required. But there are modeling subtleties: if a squared penalty is zero only for valid choices, it correctly identifies feasibility, yet choosing a sufficiently strong coefficient still requires analysis of the original objective.

Penalty weights can interact. Satisfying one constraint may violate another, and the largest conceivable violation does not always determine the minimum penalty needed to preserve the best valid solution. It is useful to derive a defensible bound when possible, enumerate tiny models, and check returned solutions against the original constraints rather than trusting the QUBO energy alone. Repeated rescaling may also change the effective precision of the coefficients on a particular solver.

A practical workflow is therefore to formulate the original constrained model first, record which assignments are valid, construct the QUBO, and test on small instances where the answer can be independently checked. Then examine the effect of penalty choices on both feasibility and solution quality under realistic solver budgets. A small amount of careful modeling can save a great deal of misleading experimentation.