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 ownSettleRun.- 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 overbounds;indextags it incallback_info.low (
ndarray) – The caller’s bounds of every flat entry,-infandinfwhere open.high (
ndarray) – The caller’s bounds of every flat entry,-infandinfwhere 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 ofobjective_scale_from_gradient()whenrescaleand in objective units otherwise, as SLSQP reads it.rescale (
bool) – Whether the solves divide the objective byobjective_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 about8e-10. Default1e-9.
- Attributes:
- size
np.ndarray Each flat entry’s size, computed at construction:
total_budgetfor money, and for a lever the largest absolute value among its finite bounds, at least 1.
- size
Methods
BreakpointSettler.__init__(variables, ...[, ...])Return
firstrecorded 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