Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Lab 12: Capital Budgeting and Facility Location

Open In Colab

Lab 12: Capital Budgeting and Facility Location

In this lab you build integer models in PuLP: a capital budget with logical rules, a set-covering model and a kiosk plan with fixed costs.

The questions. Qahwa House has a capital budget of 1,000 k SAR for this year’s projects, and wants to open drive-through kiosks in north Riyadh. Which projects should it fund, and which kiosks should it open?

How this lab works

  • Run the cells from top to bottom with Shift + Enter. Replace every ... with your code, then run the check cell under it.

  • Extended track: after Part D, try the ★ challenges.

  • Submit before the next lab session: File → Download → Download .ipynb.

You may use an AI assistant for code. If you do, add a short note at the end: what you asked, what you kept and what you changed.

File and columnMeaning
qahwa_projects.csvone row per project
project, name, areathe project
cost_ksarwhat it costs (k SAR)
npv_ksarits net present value over five years after paying for it (k SAR)
requiresa project that must also be funded for this one to work (empty if none)
excludesa project that cannot be funded together with this one (empty if none)
qahwa_sites.csvone row per (candidate kiosk site, district) pair
site, yearly_cost_ksar, capacity_cupsthe site, the yearly cost of a kiosk there (k SAR) and the most cups a day it can serve
district, district_cupsthe district and the cups a day its residents would buy at a kiosk within reach
minutesdriving time between the district and the site

The road and district names set the scene; the times, costs and demands are invented.

Part A: Capital budgeting

A1. More projects than money

Store the total cost of all ten projects in total_cost and their total NPV in total_npv (in k SAR). The Series cost and npv below are indexed by the project code.

A2. A first binary model

Complete the model: one binary variable per project (already created), the objective (maximise the total NPV) and the budget constraint (total cost at most 1,000). Ignore the requires and excludes columns for now. Store the optimal NPV in npv_no_rules and the list of funded projects in funded_no_rules.

A3. Add the logical rules

Complete the function capital_budget(budget, cat). It must add, for every row of projects:

  • if requires is not empty: fund this project only if the required one is funded, xB≤xAx_B \le x_A;

  • if excludes is not empty: not both, xA+xB≤1x_A + x_B \le 1.

Then store the best NPV for a budget of 1,000 in npv_rules and the funded projects in plan.

Part B: Rounding and the budget

B1. The LP relaxation

Solve the same model with continuous variables between 0 and 1 (cat="Continuous"). Store the NPV in lp_npv and the variables in lp_x. How many projects are funded only partly?

B2. Round it

Round down: fund only the projects the LP funds fully. Round up: fund every project the LP funds at all. Store the NPV of the rounded-down plan in npv_down and the cost of the rounded-up plan in cost_up.

B3. One riyal less

Solve the integer model with a budget of 999.999 k SAR (one riyal less). Store the funded projects in plan_less and the NPV in npv_less.

B4. In two sentences: why can one riyal change the whole plan, and what does that mean for a manager who asks “what if the budget were a little smaller?”

Your answer here (double-click to edit).

Part C: Set covering

The promise to customers: a Qahwa House kiosk within 10 minutes’ drive of every district.

C1. The coverage matrix

The first lines below build minutes, a site × district table of driving times, and site_cost, the yearly cost of each site. Store in covers a table of the same shape that is True when the site reaches the district within 10 minutes.

C2. The cheapest cover

Complete the set-covering model: minimise the yearly cost of the open sites, with one constraint per district saying that at least one open site reaches it. Store the yearly cost in cover_cost and the open sites in cover_sites.

C3. Start with the busiest site?

The planning team wants to open Abu Bakr Rd first: it reaches six districts, as many as any site, and is the cheapest of those. Use the must_open argument to find the cheapest cover that includes it, and store its yearly cost in forced_cost.

Part D: Fixed costs

Now the profit view. A kiosk earns about 6 SAR a cup, 360 days a year: each cup a day sold all year is worth MARGIN = 2.16 k SAR a year. An open kiosk costs its full yearly_cost_ksar (a fixed cost) and serves at most capacity_cups a day. Customers buy only at a kiosk within 10 minutes.

  • ys∈{0,1}y_s \in \{0, 1\}: open site ss;

  • xsd≥0x_{sd} \ge 0: cups a day that district dd buys at kiosk ss (only for pairs within 10 minutes);

  • maximise 2.16∑xsd−∑costs ys2.16 \sum x_{sd} - \sum \text{cost}_s \, y_s;

  • demand: ∑sxsd≤cupsd\sum_s x_{sd} \le \text{cups}_d; capacity and big-M link: ∑dxsd≤capacitys ys\sum_d x_{sd} \le \text{capacity}_s \, y_s.

D1. The most profitable kiosks

Complete the capacity-and-link constraint. Store the yearly profit in profit and the open sites in open_sites.

D2. The price of the promise

Solve the profit model again with the 10-minute promise (reach_all=True). Store the profit in profit_all and the drop in profit, the price of the promise, in price.

D3. Your recommendation

Write three sentences for the board: which projects to fund (and why the obvious rules of thumb or rounding would get it wrong), which kiosks to open under each goal, and what the 10-minute promise costs, with numbers from Parts A to D.

Write your recommendation here (double-click to edit).

★ Extended challenges

E1. A different promise. Solve the set-covering model for promises of 8, 9, 11, 12 and 15 minutes. Which promises can be kept at all, and how does the cheapest cost change? (Check the status the solver returns, res.status.name, for infeasible models: change cheapest_cover to return the status too.)

E2. Spreading the cash reserve. Qahwa House holds 2 million SAR in reserve. Using the estimates of the reading (four funds; mu, vol and corr), find with scipy.optimize.minimize (method "SLSQP") the mix with the lowest volatility whose expected return is at least 7.5%. Compare its volatility with that of the real-estate fund alone (7.5% expected, 14% volatility).

E3. The budget staircase. Plot the best NPV for every budget from 600 to 1,400 k SAR in steps of 10. Between 950 and 1,080 k SAR (where every budget has a single best plan), at how many steps does the best plan change, and at how many does it change completely (no project in common with the plan one step before)?

AI-use log (if you used an AI assistant)

What you asked, what you kept, what you changed.