Skip to content
Tutorials Center
My learning

Topics

Lesson 5 of 38 ยท Modelling

Product Mix and Resource Allocation

Learn the product mix model: define variables, build a resource matrix, add demand limits and minimum orders, and solve with linprog while reading the results.

The most classic LP is the product mix problem: a company can make several products, each product consumes shared resources (machine hours, labor, material), and the goal is to choose how much of each to make to maximize profit. Almost every other model in this course is a variation on it, so it is worth learning the modelling routine carefully.

A four-step modelling routine

  1. Decision variables. What can you choose? Say exactly what each variable means and its unit: "x_j = units of product j made per week".
  2. Objective. What single number do you maximize or minimize? Write it as a sum over the variables.
  3. Constraints. For every scarce resource: (use per unit) times (units made), summed, is at most the supply. Add demand ceilings, minimum commitments and logical limits.
  4. Check. Test the model on a plan you can verify by hand, and ask whether the answer makes sense.

The workshop example

A workshop builds three products: desks, chairs and shelves. Per unit:

Desk Chair Shelf Weekly supply
Profit (dollars) 90 55 40
Wood (board feet) 20 8 10 1200
Labor (hours) 6 3 2 340
Finishing (hours) 4 1 1 200

Market limits: at most 40 desks per week can be sold, and a long-term customer requires at least 30 chairs.

With d, c, s for the numbers of desks, chairs and shelves:

TEXT
maximize    90d + 55c + 40s
subject to  20d + 8c + 10s <= 1200     wood
             6d + 3c +  2s <=  340     labor
             4d +  c +   s <=  200     finishing
             d <= 40                    demand
             c >= 30                    commitment
             d, c, s >= 0
Python Solve the workshop product mix

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Notice how the demand limit and the commitment became bounds, not rows. The printed usage table is a habit worth keeping: it shows which resources are fully used (the bottlenecks) at a glance.

Interpreting results as a manager would

The raw numbers are rarely the end. Ask:

  • Which constraints bind? Those resources limit profit. Slack on a resource means you are paying for capacity you do not use.
  • Are any products not made? A product at 0 is not profitable at the current prices given its resource use. The reduced cost says how much its profit would have to rise before it entered the plan.
  • Are the numbers fractional? Making 12.5 desks may be impossible; the later chapter on integer programming (see the track page) shows how to force whole numbers.
Python Binding constraints and reduced costs

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

If a resource has a positive shadow price, buying more of it raises profit by that amount per unit (for a limited range; see sensitivity analysis). A shadow price of zero on a slack resource confirms that extra capacity is worthless.

Building models from data

Hand-typing matrices does not scale. A reusable function takes tables and builds the LP, so that adding a product means adding a row of data, not rewriting the model.

Python A reusable product-mix function

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Re-solving with changed data is the simplest form of what-if analysis, and it is a good way to cross-check shadow prices.

Common modelling pitfalls

  • Mixing units. Do not combine minutes in one row and hours in another without conversion.
  • Forgetting a constraint. An unbounded result almost always means a missing limit (for example, no sales cap).
  • Over-constraining. An infeasible result usually means two requirements clash; relax one and see.
  • Confusing coefficients. Row i, column j means "resource i used per unit of product j". Keep a table like the one above next to the code.
  • Hiding assumptions. Constant profit per unit and constant resource use are assumptions; state them.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. In the resource matrix 'use', what does use[1][2] mean?

    Row index is the resource, column index is the product, so use[1][2] is labor per shelf.
  2. 2. A resource has slack 35 at the optimum. What is its shadow price?

    If capacity is left over, extra capacity cannot help, so the marginal value is zero (complementary slackness).
  3. 3. How is the customer commitment 'at least 30 chairs' best entered in linprog?

    A lower bound is a simple bound; it is handled efficiently without adding a constraint row.
  4. 4. Your product-mix LP returns 'unbounded'. The most likely cause is

    Unbounded means profit can grow forever, so some real-world limit was left out of the model.

Summary

  • Follow the routine: variables, objective, constraints, check.
  • Product mix: maximize profit with one row per scarce resource; bounds for demand caps and commitments.
  • Print resource usage, slack and shadow prices to find bottlenecks.
  • Build models from data tables so what-if changes are easy.
  • Unbounded means a missing constraint; infeasible means a clash.

Next: Diet and Blending Problems