Practice: Modelling with Binary Variables

Recognition · Interpretation

With binaries x and y , which constraint says "if x is chosen then y must be chosen"?

2 hints available, least help first.

Hint 1: Retrieval cue

Which single combination should the constraint forbid?

Hint 2: Concept cue

Test each option against x = 1 , y = 0 .

Comparison · Method selection

"We may run the second line only if the first is commissioned, and we need not run it even then." Which constraint set is correct?

2 hints available, least help first.

Hint 1: Retrieval cue

The second clause is telling you which constraint NOT to add.

Hint 2: Concept cue

Is the intended relation one-way or two-way?

Construction · Direct application · Explanation

A utility may build wind, solar or gas capacity. Building wind costs £3m fixed and yields up to 40 MW; solar costs £2m fixed and yields up to 25 MW; gas costs £5m fixed and yields up to 90 MW. It must build at least two of the three. Gas may only be built if wind is also built. Total capacity must reach at least 60 MW. Any built source must supply at least 10 MW.

Define the variables and write every constraint, saying for each what it forbids.

Write your answer, then compare it with the worked solution.

2 hints available, least help first.

Hint 1: Retrieval cue

Take the conditions one sentence at a time and name the pattern before writing algebra.

Hint 2: Strategy cue

Each source needs two linking constraints: one capping output, one imposing the minimum.

Compare with the worked solution

Comparing does not record a result. Judging your own written answer cannot show that you can do this without help.

Variables. w , s , g ∈ { 0 , 1 } , equal to 1 if wind, solar, gas respectively is built. q w , q s , q g ≥ 0 , the MW supplied by each.

At least two of the three.

w + s + g ≥ 2 .

Forbids: building none or exactly one.

Gas only if wind.

g ≤ w .

Forbids: g = 1 with w = 0 , and nothing else. Note it leaves wind-without-gas permitted, as the sentence intends.

Capacity links, upper.

q w ≤ 40 w , q s ≤ 25 s , q g ≤ 90 g .

Forbids: supplying from an unbuilt source, and exceeding a built source's rating. Each M comes from the stated rating, which is where a bound should come from.

Minimum output when built.

q w ≥ 10 w , q s ≥ 10 s , q g ≥ 10 g .

Forbids: building a source and running it below 10 MW. When the binary is 0 these read q ≥ 0 , already true, so they impose nothing on unbuilt sources.

Total capacity.

q w + q s + q g ≥ 60 .

Forbids: any plan supplying under 60 MW.

Objective, if minimising cost.

min 3 w + 2 s + 5 g (£m) .

The fixed charges sit with their binaries, and the capacity links make them payable, without q ≤ M w the model would supply wind power with w = 0 and never pay the £3m.

A check. w = 1 , s = 1 , g = 0 with q w = 40 , q s = 25 , q g = 0 : two sources built, gas implication holds vacuously, each quantity inside its sandwich, total 65 ≥ 60 . Feasible, cost £5m.

A complete answer does each of these:

  • defines variables
  • writes logical constraints
  • links decision to quantity
  • verifies constraint binds

Error diagnosis · Explanation · Evaluation

A modeller writes, for a depot with capacity 500 tonnes and a £2,000 opening cost:

Variables: y ∈ { 0 , 1 } for opening the depot, q ≥ 0 tonnes shipped.
Objective: minimise 2000 y + 6 q .
Constraints: q ≤ 500 (capacity), q ≥ 0 (nothing negative), y ≤ 1 (binary).
"Every constraint is a true statement about the depot, so the model is correct."

Identify what the model permits that it should not, and say what is wrong with the justification.

Write your answer, then compare it with the worked solution.

2 hints available, least help first.

Hint 1: Retrieval cue

Try setting y = 0 and q = 500 and check every constraint.

Hint 2: Concept cue

For each constraint, what assignment does it actually forbid?

Compare with the worked solution

Comparing does not record a result. Judging your own written answer cannot show that you can do this without help.

What the model permits. y = 0 with q = 500 . The depot is not opened, the £2,000 is never paid, and five hundred tonnes ship from it. Since the objective minimises cost, this is exactly what a solver will return: there is no reason to set y = 1 when doing so costs £2,000 and buys nothing.

The missing constraint. Nothing connects q to y . The condition "nothing ships from a closed depot" was never encoded. It needs a linking constraint:

q ≤ 500 y .

With y = 0 this forces q = 0 ; with y = 1 it is the capacity limit, so it also replaces the standalone q ≤ 500 .

Reviewing the constraints that are present.

  • q ≤ 500 : true, and forbids q = 600 . Genuine work, though subsumed once the link is added.
  • q ≥ 0 : forbids nothing. The variable was already declared nonnegative.
  • y ≤ 1 : forbids nothing. The variable was already declared binary.

Two of the three constraints are true statements that restrict nothing the model could otherwise have done.

What is wrong with the justification. "Every constraint is true" cannot detect this fault, because the fault is not a false statement. It is a missing one. A review that reads each constraint and confirms it is true will pass this model every time.

The review that works. Two passes. First, for each constraint, name an assignment it forbids that the rest of the model would permit; a constraint with no such assignment is doing nothing. Second, for each condition in the description, name the constraint that enforces it. "Nothing ships from a closed depot" has no answer in this model, and that second pass is what exposes it.

Why fixed charges are where this bites hardest. A cost in the objective with no linking constraint is always declined by an optimiser. The binary becomes pure cost with no consequence, so the charge is never incurred and the activity runs free.

A complete answer does each of these:

  • defines variables
  • writes logical constraints
  • links decision to quantity
  • verifies constraint binds

Transfer · Construction · Evaluation

A research council must choose among six proposals. Each has a cost c j and a score v j , and the total budget is B . At most one of proposals 3 and 4 may be funded, since they duplicate each other. Proposal 6 requires proposal 2 as a precursor.

Formulate the selection as a binary program. Then say what changes structurally if the council may instead fund any fraction of each proposal, and why that version is far easier to solve.

Write your answer, then compare it with the worked solution.

2 hints available, least help first.

Hint 1: Retrieval cue

Each condition matches one of the patterns: a count, an implication, a resource limit.

Hint 2: Strategy cue

For the second part, ask what the feasible set becomes when the variables are allowed to be fractional.

Compare with the worked solution

Comparing does not record a result. Judging your own written answer cannot show that you can do this without help.

Variables. x j ∈ { 0 , 1 } for j = 1 , … , 6 , equal to 1 if proposal j is funded.

Objective.

max ∑ j = 1 6 v j x j .

Budget.

∑ j = 1 6 c j x j ≤ B .

Forbids: any selection costing more than the budget.

Duplication.

x 3 + x 4 ≤ 1 .

Forbids: funding both, while permitting either alone or neither.

Precursor.

x 6 ≤ x 2 .

Forbids: funding proposal 6 without proposal 2. It leaves 2 fundable alone, which is correct. A precursor need not lead anywhere.

What this is. A knapsack problem with two side conditions: maximise value subject to a single capacity constraint, with items indivisible.

The fractional version. Replace x j ∈ { 0 , 1 } with 0 ≤ x j ≤ 1 . The problem becomes a linear program, and it is solved by a simple rule: order the proposals by value-per-pound v j / c j and fund them in that order until the budget runs out, with at most one proposal funded partially at the end. The side constraints complicate this slightly but the problem remains a linear program.

Why the fractional version is far easier. Its feasible set is a polyhedron, so the optimum sits at a vertex and the geometry does the work. Restoring integrality removes that: the feasible set becomes the 2 6 corner points of the unit cube that satisfy the constraints, with no direction to move in and no vertex guarantee.

The consequence. The greedy value-per-pound rule is optimal for the fractional problem and can be arbitrarily bad for the integer one. A proposal with the best ratio may consume so much budget that two lesser proposals would have scored higher together, and no amount of care in applying the ratio rule finds that, because it requires declining the item the rule ranks first.

Why this is the transfer. The patterns here are the ones already met, a selection count, an implication, a budget, arriving in a named problem family under different vocabulary, with the integrality question carrying real consequence.

A complete answer does each of these:

  • defines variables
  • writes logical constraints
  • links decision to quantity
  • verifies constraint binds
Practice data

Your practice record is stored in this browser only. Clearing it removes every answer and every scheduled review, and cannot be undone.

Results update as you type. Use the up and down arrow keys to move between results, Enter to open one, and Escape to close.

Type to search.

Settings

Appearance

Interface density

Your record

Your progress is stored in this browser and nowhere else: an identifier, the answers you have given, the mastery states and review schedule derived from them, and the lesson you last opened. Clearing it makes you a new learner on this device. It cannot be undone, and it will not affect your appearance or density settings.

Focus timer

Focus--minutes remaining

Phase

Kept in this browser only, and used to label the session in your own history.

Today

Nothing recorded yet. Finish a focus session and it will appear here.

Settings

Focus sessions between long breaks.

Sessions you are aiming for in a day.

Notifications

Your history

Sessions are stored in this browser and nowhere else. They are not evidence and never reach your mastery record.