Skip to content
Claudio Cabrera
Chapter 1 · Component 3 · 32:00src/policies/base.py

The DLA Pricing Policy

Monte Carlo rollout over multi-step horizons — evaluating candidate actions and selecting the optimal one

In This Component

The pricing policy is a Direct Lookahead Approximation (DLA) — Powell’s most sophisticated policy class. It doesn’t just react to the current order. It simulates what the world will look like after accepting or rejecting, across stochastic futures, and selects the action that maximizes expected cumulative reward over a horizon .

The DLAPolicyEngine

For each incoming B2B order, the engine executes:

1. Candidate Generation Three price tiers × three schedule options = up to 9 candidate B2BAction objects. Schedule options are min(request_day, SLA) - 4, - 2, and 0.

2. Feasibility Filter Each candidate must pass MarginObjectiveFunction.is_valid_action(): sellable inventory must cover quantity, schedule must not exceed delivery offset, and immediate margin must be positive.

3. Seeded Monte Carlo Rollouts Per feasible action, simulation paths are run. Seeds are deterministically derived from the order UUID using NumPy’s SeedSequence — the same order always produces the same rollout, making decisions fully auditable:

event_seed_words = [(event_id.int >> shift) & 0xFFFFFFFF for shift in (0, 32, 64, 96)]
seeds = tuple(
    SeedSequence([self.simulation_seed, *event_seed_words, i]).generate_state(1)[0]
    for i in range(self.num_simulations)
)

4. Path Scoring

Invalid future actions make the entire path worth .

5. Stable Argmax + Business Guard The action with the highest expected value is selected. A final safety guard converts an invalid accepted action to a reject, preventing a pathological edge case from reaching the customer.