(Binary Variables, Penalties, and Objectives)

Goal of this chapter
- Understand the 3 ingredients of every QUBO
- Learn what penalties are and why they work
- Practice with simple, real-life examples
1. Binary Variables (Yes / No switches)
QUBO only uses binary variables:
0= NO / not chosen / not active1= YES / chosen / active
Think of them as on/off switches.
Example: 3 drinks
C = 1→ choose CokeM = 1→ choose Milk TeaO = 1→ choose Orange Juice
All variables must be:
C, M, O ∈ {0,1}
2. Objective Function (What you want to optimize)
QUBO always minimizes a formula.
- Smaller value = better
- Bigger value = worse
Example: Drink preference
- Coke is your favorite →
5 - Milk Tea you dislike →
+10 - Orange Juice is neutral →
0
Objective:
-5C + 10M + 0O
Lower score = better choice.
3. Constraints using Penalties (Rules)
Real problems have rules, such as:
- Choose exactly 1 item
- Do not choose A and B together
- Choose at most 2 items
QUBO enforces rules using penalties.
What is a Penalty?
A penalty is extra cost added when a rule is broken.
- Rule satisfied → penalty =
0 - Rule broken → penalty = positive number
Because QUBO minimizes, it naturally avoids penalties.
Why penalty = 0 or 1 in simple examples?
Many rules can be written so that:
- Valid solution → penalty =
0 - Invalid solution → penalty =
1
Later, we multiply by a penalty weight to make rules important.
How to choose penalty weight?
Simple rule:
Penalty weight should be larger than objective values
| Objective range | Safe penalty |
|---|---|
| 0 ~ 5 | 10 |
| 0 ~ 10 | 20 |
| 0 ~ 50 | 100 |
If penalty is too small → rules may break
If penalty is large → always safe
4. Super Simple Example: Choose 1 Drink (2 options)
Variables:
C ∈ {0,1}
P ∈ {0,1}
Constraint:
C + P = 1
QUBO penalty form:
(C + P - 1)²
Check it
| C | P | Result | Meaning |
|---|---|---|---|
| 1 | 0 | 0 | Valid |
| 0 | 1 | 0 | Valid |
| 0 | 0 | 1 | Invalid |
| 1 | 1 | 1 | Invalid |
Valid → penalty = 0
Invalid → penalty = 1
5. Assessment Problem (3 Drinks)
Problem
You have:
- Coke
- Milk Tea
- Orange Juice
Choose exactly 1.
Variables
C, M, O ∈ {0,1}
Constraint
C + M + O = 1
QUBO formula
(C + M + O - 1)²
Optional penalty weight P:
P(C + M + O - 1)²
6. Practice (Homework)
Try writing QUBO for:
- Choose at most 1 drink
- Choose at least 1 drink
- Choose exactly 2 drinks
- Add preferences:
- Coke = -5
- Milk Tea = +7
- Orange Juice = 0
Combine objective + constraint into one QUBO.



