Objectives, Decision Variables, Constraints, and Feasibility › Example: Allocating Two Products Across Two Resources
Machine Learning from ScratchAll chapters Objectives, Decision Variables, Constraints, and Feasibility › Example: Allocating Two Products Across Two ResourcesSection view · Sections in this chapter6 / 10 ↓
Reading tools Definitions, links & notes
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
We now solve the packaging problem completely by hand, then repeat the exercise with whole pallets, and finally measure the gap between the two. Hand-solving is not busywork: it gives us a reference value against which every solver call in the next section can be audited.
The first step is to find the feasible set, because without it we have no candidates to score. Each resource inequality becomes an equality on its boundary line. The machine constraint has boundary , which meets the -axis at and the -axis at . The labour constraint has boundary , meeting the axes at and . The non-negativity domains cut everything to the first quadrant, so the feasible region is the quadrilateral with corners
The corner comes from the first line at ; the corner comes from the second line at ; the corner implied by the second line is cut off by the first line and is therefore not feasible. To find the intersection we solve the two equalities. Doubling the first gives . Subtracting the second, , yields , so , and substituting back gives . Both are positive, so this point is in the feasible set.
Evaluating the objective at each corner:
| Corner | Machine slack | Labour slack | Profit | ||
|---|---|---|---|---|---|
| A | 0 | 0 | 8 | 8 | 0 |
| B | 4 | 0 | 0 | 4 | 160 |
| C | 8/3 | 8/3 | 0 | 0 | 560/3 ≈ 186.67 |
| D | 0 | 4 | 4 | 0 | 120 |
The largest value is at corner C, where both resources are exactly exhausted. Checking the algebra: and , and the sum is . Because the objective is linear and the feasible set is a polygon, the maximum must occur at a corner, so we have solved the continuous problem exactly without any software. The slack columns are worth reading alongside the profit: at C both are zero, which is the geometric signature of a vertex formed by two binding constraints.
Now suppose pallets cannot be split. We enumerate every lattice point with and and keep those satisfying both inequalities and . The feasible lattice points are exactly those whose coordinates satisfy both resource limits, because nonnegativity and the resource limits rule out any coordinate above 4, independently of the objective. The top candidates, ranked by profit , are:
| Machine slack | Labour slack | Profit | ||
|---|---|---|---|---|
| 3 | 2 | 0 | 1 | 180 |
| 2 | 3 | 1 | 0 | 170 |
| 4 | 0 | 0 | 4 | 160 |
| 3 | 1 | 1 | 3 | 150 |
| 2 | 2 | 2 | 2 | 140 |
The best integer plan is , with profit , leaving one labour-hour idle () and no machine-hours idle (). Note how close the top candidates are: earns 170 and earns 180, a ten-unit difference produced by swapping which resource is left slack. Rounding the continuous optimum to would have been a mistake, since violates the machine constraint; rounding down to loses 40 units of profit. Rounding is a heuristic with no general feasibility or optimality guarantee; this example shows infeasibility when rounding up and lost profit when rounding down.
Finally we quantify how much the integer restriction costs. In minimization form the integer optimum is and the LP relaxation bound is ; using profit values directly gives the same relative gap,
The gap relative to the integer profit is . This quantifies the initial LP bound's looseness. Enumeration has already established that 180 is the exact integer optimum for this tiny model. A MILP solver that certifies that optimum can tighten its search bound to 180 and report a zero final gap.
Comments
Add to the conversation
A question, a correction, or an example from your own work.
No comments yet. Be the first to share your thoughts!