Problem Solving

Binary Variable

A comic close-up of a two-position toggle switch.

Binary Variable definition

A binary decision variable takes only the values 0 and 1.

In Spanish
variable binaria
Topic
Optimization and decision models

Binary Variable in a picture

Binary Variable diagramA switch with two allowed states can represent whether a decision is off or on.Use x = 0 for offThe option is not selectedUse x = 1 for onThe option is selectedCombine binary decisionsA sum counts selected options
A switch with two allowed states can represent whether a decision is off or on.

How it works

Use 1 to mark that an option is selected and 0 to mark that it is omitted. A constraint such as x + y ≤ 1 allows at most one of two options. Requiring x + y = 1 forces exactly one.

Worked examples

What does x + y = 1 allow for binary x and y?

It allows (1, 0) or (0, 1).

How do you require at most two out of three options?

Use x + y + z ≤ 2.

How can you require that choosing x also chooses y?

Use x ≤ y. If x is 1, y must be 1.

Common mistake

Specify x ∈ {0, 1}. The bounds 0 ≤ x ≤ 1 alone also permit fractions.

Quick check

What does x + y ≤ 1 mean for binary variables?

Can both options be omitted under x + y ≤ 1?

Show answer

Yes.

What does x + y count?

Show answer

The number of selected options.

Sources

Flashcard

Binary Variable

Reveal the definition

A binary decision variable takes only the values 0 and 1.

Effortless Math. “Binary Variable.” Math Dictionary.