Modelling with Binary Variables
What you will be able to do
Given a situation containing yes-or-no decisions and conditions relating them, the learner can define binary variables with stated meanings, write linear constraints expressing selection counts, implications and links between decisions and quantities, choose a defensible bound for a linking constraint, and verify that each constraint forbids what it is meant to forbid.
Orientation
A factory either opens a line or it does not. What should a decision variable mean when 0.4 factories is nonsense?
The vocabulary is small. Four or five patterns cover most of what arises, and they compose, so a complicated set of conditions is usually several simple constraints rather than one clever one.
What takes practice is not the patterns but the reading. Deciding that a sentence is an implication, noticing that a cost is only incurred when an activity runs, spotting that two conditions are the same condition stated twice, that is where the work is, and it is why this is a formulation competence rather than an algebraic one.
This unit assumes you know what integrality is and can formulate a linear program.
Intuition
Binary variables and the constraints that link them
The canonical text gives the switch reading and the linking pattern. Two things decide whether a binary model solves in reasonable time, and neither is about correctness.
The characteristic error is a missing link, not a wrong coefficient. A model that defines
Reading each constraint back as English, and asking which combinations it forbids, catches both.
Definition
The modelling vocabulary
A binary variable satisfies
Selection counts. For a set
Implication. "If
Setting
Linking a decision to a quantity. To permit a continuous
with
Fixed charges. A cost incurred only if an activity runs contributes
Choosing
Procedure
Turning conditions into constraints
Define a binary variable for each yes-or-no decision, and say which outcome is 1. Write the meaning down in words beside the symbol. Most later confusion traces to a variable whose direction was never fixed.
Go through the description one sentence at a time. Each sentence is either a condition to encode, a quantity to bound, or commentary. Classify it before writing algebra; sentences that turn out to be commentary are the ones that produce constraints forbidding nothing.
Name the pattern before writing the constraint. Is this a selection count, an implication, a link between a decision and a quantity, or a fixed charge? The pattern determines the form, and reaching for algebra before naming it is how implications end up written as equalities.
Respect the direction of an implication. "If
Bound every linking constraint as tightly as the situation allows. Derive
Test each constraint by naming something it forbids. Produce one assignment of the variables that the constraint rules out and that the model would otherwise have permitted. A constraint with no such assignment is doing nothing and should be removed or rewritten.
Check the objective for decisions that carry costs. A fixed charge belongs in the objective with its binary variable, and needs a linking constraint to make it payable. A charge without a link is never incurred.
Example
Five conditions, five constraints
A firm may open depots
"Open at most two depots."
"If
Forbidden:
"
"Nothing ships from a closed depot; each depot handles at most 500 tonnes."
Here
"An opened depot must ship at least 100 tonnes."
When
Check one combination.
Worked example
A fixed-charge model and its linking constraint
Problem. A workshop may commission a machine at a one-off cost of £8,000. If commissioned, it produces up to
Goal. A correct model, and a demonstration of why one constraint is load-bearing.
Relevant principle. A fixed charge needs its binary in the objective and a linking constraint, or the charge can be avoided while its benefit is enjoyed.
Step 1: variables.
Step 2: the objective. Revenue
Step 3: the capacity and the link. Production is capped at
With
Step 4: solve by cases. With
Answer. Commission the machine and produce
Step 5: now omit the link. Keep the objective and replace
What that answer says. Produce
A fixed charge is not modelled by putting a cost in the objective. It is modelled by the cost and the link. Without the link the charge is optional, and an optimiser will always decline it.
Check. With the link restored,
Non-example
Constraints that are true and useless
Not a constraint:
Not a constraint:
Not an implication:
Not a link: a fixed cost in the objective with no constraint tying it to the activity. The binary is then pure cost with no consequence, so a maximising model sets it to zero and enjoys the activity free.
Not a bound derived from the situation:
Not a binary decision: a count. "How many vans to hire" is a general integer variable. Writing it binary forbids hiring more than one.
Contrast
True is not the same as binding
A constraint's job is to forbid something. Whether the sentence it encodes is true of the situation is a separate question, and conflating the two produces models that look thorough and constrain nothing.
A modeller reads "each depot can handle at most 500 tonnes" and writes
Why it is hard to see. Every constraint in the model is a true statement. Reviewing the model by reading the constraints and checking they are true will pass this model, because the fault is not a false statement. It is a missing one.
The test that catches it. For each constraint, name an assignment it forbids that the rest of the model would otherwise permit. For
The general shape of the error. It is not confined to binaries. Any model can contain constraints that restate something already implied, while a condition the modeller believes is covered has no algebraic representative at all. Binaries make it more common because logical conditions feel like they have been handled once they have been written down in words.
The habit. Two passes. Once through the constraints, asking what each forbids. Once through the description, asking which constraint enforces each condition. The second pass is the one that finds what is missing, and it is the one most often skipped.
Exercise
1. Write constraints for: exactly one of four suppliers is chosen; supplier 2 may only be chosen if supplier 1 is; suppliers 3 and 4 cannot both be chosen.
2. A machine has a £5,000 setup cost and a capacity of
3. A modeller writes
4. For a quantity known never to exceed
5. Look at this constraint set:
What to carry forward
A binary variable records a yes-or-no decision, and which outcome is
The vocabulary is short. Selection counts are sums bounded by a number. "If
A fixed charge needs both its cost in the objective and a linking constraint. Without the link, the charge is optional and an optimiser declines it while keeping the benefit.
Choose
The recurring error is a constraint that is true and binding on nothing. Test every constraint by naming an assignment it forbids, then read the description again asking which constraint enforces each condition. The second pass is what finds the condition you believed you had written down and had not.