BreakpointSettler#

class pymc_marketing.mmm.price_schedule.BreakpointSettler(variables, objective_and_grad, constraints, solve, low, high, total_budget, ftol, rescale, max_passes=20, rtol=1e-09)[source]#

Solve again on each entry’s linear piece until no entry on a breakpoint would gain by leaving it.

A settler is configuration only; each settle() call keeps its own SettleRun.

Parameters:
  • variables (OptimizationVariables) – The decision variables; their price maps answer which piece an entry is on.

  • objective_and_grad (Callable[[ndarray], tuple[Any, Any]]) – The objective and its gradient at a flat plan, on whatever map the variables are conditioned on.

  • constraints (Sequence[dict]) – The compiled SciPy constraints, with "type", "fun" and "jac".

  • solve (Callable[[ndarray, list[tuple[float | None, float | None]], int], OptimizeResult]) – solve(start, bounds, index) runs one solve of the optimizer over bounds; index tags it in callback_info.

  • low (ndarray) – The caller’s bounds of every flat entry, -inf and inf where open.

  • high (ndarray) – The caller’s bounds of every flat entry, -inf and inf where open.

  • total_budget (float) – The size of a monetary entry, against which closeness to a bound is measured.

  • ftol (float) – The objective change below which letting entries go bought nothing, on the scale of objective_scale_from_gradient() when rescale and in objective units otherwise, as SLSQP reads it.

  • rescale (bool) – Whether the solves divide the objective by objective_scale_from_gradient().

  • max_passes (int) – Solves after the first, closing solves included; a run still closing on the last pass, after the progress rule fires or with new arrivals, may add one closing solve. Default 20.

  • rtol (float) – How close, relative, an entry is to the bound or breakpoint that holds it, and a constraint value to zero, when SLSQP leaves them; it leaves about 8e-10. Default 1e-9.

Attributes:
sizenp.ndarray

Each flat entry’s size, computed at construction: total_budget for money, and for a lever the largest absolute value among its finite bounds, at least 1.

Methods

BreakpointSettler.__init__(variables, ...[, ...])

BreakpointSettler.record_skipped_passes(...)

Return first recorded as "skipped", with a warning: the passes run under SLSQP only.

BreakpointSettler.settle(first)

Settle first, the solve with breakpoints blended, and return the plan with its status.

Attributes