SHOW ME WHAT YOU GOT (Part 7): Making It Pay (From Packing to ERP) (English)

On Monday morning, the regional manager sees that King Street turned away nine customers last week. Market Street did fewer treatments per technician. She's got one spare shift to put somewhere, and a branch lead vacancy to fill. Which salon needs help, and who could run it?

Open the bookings behind those figures. King Street had people waiting for a qualified technician. Market Street had technicians waiting for a station. Sending another person to Market Street would make the rota look better and leave them standing in the same queue. And if we use the treatments-per-technician column to pick a branch lead, we've just given somebody a head start for working in the better-equipped salon.

The original salon example began with a diary and a simple job: fit the appointments around the staff, stations and equipment. By Part 6 we could learn which of the feasible offers a customer might prefer. Now the regional manager can change the rota, move stock and give somebody responsibility for a branch. Can we use the appointment records to decide what to try, and come back later to see whether it worked?

Two offers, two calendars

The packing example gives us a way to find allocations that fit the salon's appointments, equipment and people. To see why the regional report needs the diary underneath it, take one booking at King Street. A customer can come at 11.00 or 11.20. Both fit, but they leave different gaps:

Offer Chance the customer accepts Contribution if booked What remains if she books
11.00 with another technician 80% £25 Short gaps at the step-free station
11.20 with Sarah 60% £25 An earlier window long enough for a removal and full set

The second allocation might leave the longer gap because Sarah can take the customer just after another treatment has cleared the station, while the 11.00 option splits an otherwise continuous window. The allocator works from the actual resource intervals. We can use its output directly here.

If the customer is our last enquiry, the expected contribution from the offers is £20 and £15 respectively. Offer 11.00 first. But suppose there's a 25% chance of a later enquiry for a removal and full set that needs that earlier window. If the salon can book it, the treatment contributes £40. Assume this customer always accepts when the window is available and has no other feasible slot.

Leaving the window open is worth 25% × £40, or £10 in expectation. If the customer takes 11.00 we give up that chance. If she declines, the window is still available. For simplicity, assume she responds immediately, we make one offer, and 11.20 leaves the other customer's allocation intact.

First offer Expected contribution from the customer Expected contribution from later enquiry Expected total
11.00 £20 20% × £10 = £2 £22
11.20 £15 £10 £25

The acceptance estimates stayed exactly the same. What changed the decision was the value of the calendar each booking would leave behind.

Start with the code we already have

The single-day sample already exposes AppointmentPlanner.FindOffers and TryBook. Here's the arithmetic between those calls. The two functions passed to this example are application code. One estimates acceptance and the other replays tomorrow's enquiries against a copy of the calendar.

var candidates = planner.FindOffers(request, limit: int.MaxValue).Offers;
var ranked = candidates
    .Select(offer => new
    {
        Offer = offer,
        Value = acceptanceProbability(offer) *
            (contributionIfBooked(offer) - futureContributionLost(offer))
    })
    .OrderByDescending(option => option.Value)
    .ToArray();

// Pass the accepted offer to TryBook after the customer responds.

The planner builds a demand for each resource interval. For example, the technician may need a different reset period from the station. Use the offer's actual demands when projecting the booking. The sample lives in AppointmentPlanner.cs.

A Friday when we get it wrong

Play the two policies through two possible Fridays. Assume the customer would accept either offer in these particular examples. A simulator can specify both responses to make the comparison. In a real booking we observe only her response to the offer shown.

What happens after the customer books Offer 11.00 first Offer 11.20 first
The removal enquiry arrives £25, with no suitable gap for the second treatment £65, with both treatments booked
Nobody else asks for the window £25 £25, with the earlier window empty

There's another Friday the first table already allows for. the customer would have accepted 11.00, she declines 11.20, and nobody else calls. Reserving the better window brings in £0 instead of £25. A policy can be better in expectation and still lose on a particular day. If the chance of the later enquiry falls below about 16%, the assumptions in this example favour 11.00 again. At that point the expected loss from consuming the window is less than the £5 advantage of the earlier offer.

This is an opportunity cost. It's a price we put on using capacity that could serve another request. As the morning goes on, the price can change. Someone might cancel and free a second window. The manager might have an enquiry pending that makes this one more valuable. A ranking cached for the customer can still describe her preferences correctly while the decision about what to offer has changed.

Ask the allocator twice

We can start with a small addition to the booking policy. Take a snapshot of the calendar. For each feasible offer, tentatively apply its allocation to a copy. Generate plausible remaining enquiries and run the same sequence through the allocator against both calendars, one with the booking and one without. The average difference in future contribution estimates the cost of that booking.

Using the same enquiries in each comparison matters. If one calendar gets a stream of easy bookings and the other gets a run of awkward ones, we learn very little about the effect of the customer's slot. In the simple example, the future sequences have just two forms, either the removal enquiry arrives or it doesn't. With several requests, put them through in arrival order and let each booking consume capacity for the next. Giving the forecast calendar advance knowledge of all the requests would overstate what the live policy can achieve.

Spread the calculation across candidates and we get a form of stochastic optimisation. The allocator still checks that people, equipment and time line up. The policy compares what is feasible today using possible versions of what comes next. If we're accounting for uncertain treatment durations as well, we can replay those same calendars with sampled durations and charge for delays or overtime.

Relevance can help rank the candidates. The scheduling policy needs an estimate of acceptance to do the arithmetic, so if all we have is a relevance score, we need to estimate or calibrate that probability separately. The booking service still owns the reservation. Recheck the successful offer against the current calendar when the customer accepts, because other bookings may have arrived since we made the recommendation.

Add another salon

Now give The Nail Room a second branch. Both salons have their own stations and stock. Sarah can work at either location, but a transfer takes 25 minutes. The second branch has a spare bottle of a gel colour that the first branch is likely to run out of before Saturday's delivery.

The tempting implementation is to run the first salon's policy twice. That works for decisions whose resources really are independent. It breaks when both managers assume they can have Sarah on Friday afternoon, or when the second salon promises the same bottle to two branches.

We can reuse the allocation model by changing what it describes. A station belongs to a location. Technician availability belongs to a person, and moving between locations consumes time on that person's calendar. A bottle belongs to a stock location until a transfer leaves, and is usable at the destination only after it arrives. Two appointments on opposite sides of town can now conflict, while two treatments side by side can fit if they have separate people and equipment.

Suppose the first branch wants Sarah for an extra hour that could bring in £45. The second branch could use her for work worth £60. The group needs the incremental contribution from each plan. If another technician can cover £50 of the work at the second branch, the cost of sending Sarah away is £10. If the journey makes her late for an existing appointment, that plan needs a different allocation. The comparison only makes sense once we've checked the resources and the alternatives at both sites.

The stock decision has the same shape. Sending the spare bottle can prevent lost bookings at the first salon and create a shortage at the second. A transfer, a purchase and doing nothing each leave a different set of future options. Compare them using the same demand scenarios, including the lead time and the possibility that the donor branch needs the stock first.

How a booking system starts to look like ERP

Look at what the group now has to represent. An appointment commits a qualified person's time, a station and some consumables. A rota determines when that person can be assigned. A transfer moves available inventory from one branch to another, with a period when neither can use it. A purchase order creates an expected receipt that planning can use and that fulfilment can check when the delivery actually lands.

Put the appointment book, the rota and the stock ledger side by side. Each can tell us what's already spoken for and when it becomes available again.

Workflow Commitment the plan must account for What changes the next plan
Book an appointment Reserve staff and equipment for the treatment stages Cancellation, actual finish time, stock consumed
Assign a shift Make a qualified person available at one site during a period Absence, reassignment, travel time
Transfer stock Commit units at the source and expect them at the destination Dispatch, receipt, loss or delay
Replenish stock Commit spend and expect a delivery Supplier confirmation and quantities received

Say the Saturday delivery slips to Monday. The stock ledger tells us which colours are short. The appointment book tells us who is due to use them. Can we get the stock across town before the first appointment, and is there enough left at the other branch to cover its own bookings?

You can start with separate records for each workflow and project their commitments onto the same planning view. The projected view can compare hypothetical changes. The booking calendar, rota and inventory records still hold the actual commitments. That gives us the beginnings of the planning side of enterprise resource planning (ERP). The useful step is getting a booking, a shift and a transfer to tell the same story about what the business can promise tomorrow.

Can we compare Sarah across salons?

Sarah does six treatments on a Friday at the first salon and four at the second. Has she slowed down? Open the appointments. The second salon does more removals and full sets, and Sarah spends less of her shift at a station. I'd want to see those numbers before touching the rota.

Start with comparable work. Show counts and treatment duration by service and complexity, alongside available station time, booking load and the number of observations. Include quality measures such as rework and customer waits. Compare Sarah with her own results on similar treatments at both branches, then with technicians who did similar work under similar conditions. Where the work barely overlaps, show that gap. A technician who has only worked at one branch leaves us little direct evidence about how they would do at the other.

For the rota decision we need a more specific comparison. What would each branch be able to do under each feasible assignment? Sarah's faster removals might matter a lot where removal demand exceeds capacity. At the other branch, a shortage of stations may mean the same improvement buys us very little. The report can describe the work Sarah has done. The planner can use those observations, with uncertainty, to estimate what her reassignment would allow.

Can a context span entities?

Yes. The shift decision has a technician, a sending branch, a receiving branch and a set of appointments that might be affected. They keep their own IDs. The application reads their current state at a specific revision and supplies a view of that state to the decision.

The runnable RegionalSalon sample starts with a request that names the region, Sarah, both branches and the shifts she wants to change.

var request = new ShiftRequest(region, "Sarah", king, market,
    ["friday-1", "friday-2", "friday-3"]);
var previews = planner.Preview(request, [busy, quiet]);

The planner checks the request against the rota and confirmed appointments. Each feasible move carries the request, the affected appointment IDs, the rota revision and the projected change in completed visits at both branches. Those figures come from replaying the same busy and quiet scenarios under the original and revised plans.

Relevance takes one subject ID per ranking call. In this example the subject is the region, because we're learning which proposals a regional manager tends to find useful. The candidates describe a decision that crosses entities. Their first two coordinates come from the two branch replays. The third marks that the request came from the technician. The fixture seeds a previous decision in a SQLite-backed space and ranks the supplied options with the actual API:

var pool = previews.Select(move => new RelevanceItem(move.Id,
    [(float)(move.SourceDelta / 4), (float)(move.DestinationDelta / 4), 1f]))
    .ToArray();
var suggestions = await engine.RankCandidatesAsync(region, "next", pool,
    count: pool.Length);

The rank gives a manager an order in which to look at plans. The replay gives them the estimated consequences in completed visits. Sarah and each branch retain their own IDs and records. If we later want to retrieve comparable treatments or shifts, those can have their own Relevance space with its own coordinates. The join that makes a regional staffing decision belongs to the application. There's no need to merge people's histories or add a multi-subject API to the library.

Who should run a branch?

A branch lead spends part of the day doing work the treatment report barely notices. When the diary goes sideways, can they reshuffle appointments without breaking a promise? Do they help a new technician get through a difficult treatment? Do they catch a stock problem while there's still time to fix it?

If Sarah wants the role, give her a chance to cover it on several shifts and agree what she'll be responsible for. Read the handover, ask how she handled specific incidents and compare the shifts with others of similar demand and staffing. The report can point to examples the manager should ask about. The promotion is a judgement about the lead role, informed by that evidence and the same criteria for every candidate.

Move three shifts, then see what happened

Suppose Sarah asks to move her next three Friday afternoon shifts from the first salon to the second. Let her make one request that names all three shifts. It should include the destination and any flexibility about dates. The manager needs to see the whole proposed rota before approving it. One Friday has a colleague on leave, another has a removal course that ties up a station, and the third already has two bookings that request Sarah specifically. A preview that multiplies the impact of an average Friday by three will miss all of that.

Generate the current plan and feasible alternatives, including moving all three shifts, moving two, or exchanging a shift with another technician who agrees. Check qualifications, hours, breaks, travel, staff availability and existing booking commitments. If part of Sarah's request cannot fit, offer her the feasible subset as a revised proposal. Once both sides agree to the same set of changes, recheck it against the latest rota and bookings and apply the agreed change together.

In one simulated Friday, moving Sarah frees up room for three extra treatments at the receiving branch but costs the sending branch one treatment. That is a projected gain of two for the group. Across plausible Fridays the gain may disappear, or the sending branch may struggle to cover step-free appointments even when the group shows a gain. Put the per-branch effects beside the group total. A manager needs to see who absorbs the extra waiting and which appointments become harder to serve.

Save the baseline, the alternatives, the forecast and the agreed change together. When the Fridays have passed, put actual treatment counts, waiting, overtime, cancellations and rework alongside the forecast. This is an operational review. It tells us whether the plan happened and where our assumptions were wrong. An unexpectedly quiet Friday or a colleague calling in sick changes the outcome even if the transfer decision was sound.

To estimate impact, we need some evidence about what would have happened under the original rota. For a one-off request, comparable Fridays can provide a rough reference if we account for demand, treatment mix and other staffing changes. For a recurring, discretionary transfer policy, we could alternate policies across comparable weeks or randomise where staff have already agreed to either plan. Measure the paired branches together because moving Sarah changes both. With three Fridays, the report should show the observed outcomes and uncertainty. It can inform the next decision without settling the causal question.

I'd want to click on the shortfall in the Friday report and try moving Sarah's shifts right there. When I open the report again a month later, I should be able to see which rota we agreed, which bookings we thought it would save and what actually happened. Otherwise next month's manager has to work out why Sarah was across town from a spreadsheet and a string of WhatsApp messages.

The code behind Preview, Approve and Review

The existing calendar sample can check a set of resource demands with CapacityCalendar.CanReserve. The group adapter needs dated intervals and resource keys. A technician gets the same key at both salons. Stations use branch-qualified keys. A transfer of a technician must leave room for travel, and units of stock become supply at the receiving branch on receipt. A preview uses a copy of the current commitments so a proposed move cannot spend live capacity.

In the fixture, Friday 3 contains a confirmed appointment that requires Sarah. Moving all three shifts breaks that promise. The planner can offer Friday 1, Friday 2, or both together. The sample manager chooses both after reviewing the impact. Here's the approval and replay code:

var selected = previews.Single(move => move.ShiftIds.Length == 2);
var approved = planner.Approve("manager-approval-1", selected);
var before = baseline.RunApprovedPlan(busy);
var actual = planner.RunApprovedPlan(busy);

Approve checks the preview revision and runs the commitment check again before changing the rota. A retry with the same command ID returns the recorded result. The console sample keeps this state in memory. A shared application would put the revision check, the rota write and the approval record in one transaction.

The two-shift proposal forecasts two fewer visits at King Street and three more at Market Street. In the busy scenario, Market Street gains four. Here's the actual console output from the replay:

Approved: friday-1,friday-2. Fixture actuals under the busy scenario:
  King Street: baseline 4, approved 2, scenario delta -2, forecast delta -2.0
  Market Street: baseline 0, approved 4, scenario delta 4, forecast delta 3.0

The forecast averages the busy and quiet cases. The review shows one of those cases playing out. Those are simulator outcomes. On a real Monday we'd join the approved move to recorded outcomes, compare them with its forecast and keep any controlled impact estimate alongside that review. RegionalReport also demonstrates grouping technician observations by branch and treatment, with sample counts and rework, and recording lead-cover handovers for the promotion discussion.

dotnet run --project samples/RegionalSalon -c Release

Measure the decisions the forecast changes

A forecast can be wrong in ways that never alter the plan. It can also be slightly wrong about the last usable window at a branch and reverse the recommendation. We can hold the allocator fixed, run policies on the same test scenarios, and compare completed treatments, waiting, overtime, stockouts and contribution. Validate scenario assumptions against operating data before relying on the results. With shared technicians or stock, include the branches that can affect one another in the comparison.

That is the connection to decision-focused learning. Once we can measure the schedules a predictor produces, we can ask whether training against the quality of those decisions improves on training against forecast error alone. A 2026 preprint studies this for sequential contextual linear optimisation with partial feedback. Our first experiment can be simpler. Check which errors actually change a booking, a shift or a transfer before changing the training objective. Benslimane et al., Decision-Focused On-Policy Learning for Contextual Linear Optimization with Partial Feedback

The next Monday I'd want to open those same nine lost bookings and see why we turned them away. Then I want to see what we changed at King Street, whether more customers got served, and what Market Street gave up to make it happen. If the manager can follow that trail from the report to the rota and back again, the diary has started earning its keep.

Finding related posts...
logo

© 2026 Scott Galloway — Unlicense — All content and source code on this site is free to use, copy, modify, and sell.