optimization_variables#
Optimization variables for budget optimization.
The decision vector handed to scipy.optimize.minimize is a flat 1-D array.
Everything the optimizer knows about what that vector means, which model
variable each segment substitutes, how a segment maps to model-space tensors
(the forward map), and how a solution maps back to labelled DataArray objects
(the inverse map), lives here, stated once per variable.
OptimizationVariableis the per-variable protocol: a named, contiguous segment of the flat vector with a forward map (to_model), an inverse (unpack) and its exact inverse (pack), plus defaults for the initial guess and bounds.MediaVariableimplements the media-budget path: mask scatter, channel scaling, temporal distribution, cost-per-unit conversion, and adstock carry-over padding.OptimizationVariablesowns the flat symbolic input and the variable layout, and produces the single substitution dict forpymc.do.
Module Attributes
|
Name of the flat decision vector's dimension, shared by every variable and by the container so a rename cannot desynchronise them. |
Functions
|
Reindex a labelled input onto the model's budget coordinates. |
Classes
|
A non-media decision variable: one |
|
The media-budget decision variable. |
One named, contiguous segment of the flat decision vector. |
|
|
The complete decision vector: an ordered list of variables. |