← Back to list

Chapter 2: QUBO Building Blocks

(Binary Variables, Penalties, and Objectives)

Anh · 2025-12-17 15:16 · 1 claps · 2.2 min read
#qubo #quantum-computing #quantum-annealing
Open on Medium ↗
Wiki topics: ⚛️ · Physics

Chapter 2: QUBO Building Blocks

(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

Full article for non-member here.

1. Binary Variables (Yes / No switches)

QUBO only uses binary variables:

  • 0 = NO / not chosen / not active
  • 1 = YES / chosen / active

Think of them as on/off switches.

Example: 3 drinks

  • C = 1 → choose Coke
  • M = 1 → choose Milk Tea
  • O = 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

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

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:

  1. Choose at most 1 drink
  2. Choose at least 1 drink
  3. Choose exactly 2 drinks
  4. Add preferences:
  • Coke = -5
  • Milk Tea = +7
  • Orange Juice = 0

Combine objective + constraint into one QUBO.


메타데이터
post_id
eb68686bb63a
slug
chapter-2-qubo-building-blocks-eb68686bb63a
url
https://medium.com/@nsna/chapter-2-qubo-building-blocks-eb68686bb63a
canonical_url
https://medium.com/@nsna/chapter-2-qubo-building-blocks-eb68686bb63a
author_url
https://medium.com/@nsna
status
ok
fetched_at
2026-07-14 03:37:49