ndarray of shape (n_paid_channels,) containing
aggregated historical spend allocation for spend for all media and RF
channels.
use_kpi
Whether using generic KPI or revenue.
use_posterior
Whether posterior distributions were used, or prior.
use_optimal_frequency
Whether optimal frequency was used.
max_frequency
The maximum frequency for reach and frequency channels.
start_date
The start date of the optimization period.
end_date
The end date of the optimization period.
gtol
Float indicating the acceptable relative error for the budget used in
the grid setup. The budget is rounded by 10*n, where n is the smallest
integer such that (budget - rounded_budget) is less than or equal to
(budget * gtol).
round_factor
The round factor used for the optimization grid.
optimal_frequency
Optional ndarray of shape (n_paid_channels,),
containing the optimal frequency per channel. Value is None if the model
does not contain reach and frequency data, or if the model does contain
reach and frequency data, but historical frequency is used for the
optimization scenario.
selected_geos
The geo coordinates from the model used in this grid.
selected_times
The time coordinates from the model used in this grid. If
new data with modified time coordinates is used for optimization, this is
a list of booleans indicating which time coordinates are selected.
Otherwise, this is a list of strings indicating the time coordinates used
in this grid.
channels
The spend channels in the grid.
grid_dataset
Dataset holding the grid information used for optimization.
The dataset contains the following:
Coordinates: grid_spend_index, channel
Data variables: spend_grid, incremental_outcome_grid
Finds the optimal budget allocation that maximizes outcome.
Args
scenario
The optimization scenario with corresponding parameters.
pct_of_spend
Numeric list of size channels containing the percentage
allocation for spend for all channels. The values must be between 0-1,
summing to 1. By default, the historical allocation is used. Budget and
allocation are used in conjunction to determine the non-optimized
media-level spend, which is used to calculate the non-optimized
performance metrics (for example, ROI) and construct the feasible range
of media-level spend with the spend constraints.
spend_constraint_lower
Numeric list of size channels or float (same
constraint for all channels) indicating the lower bound of media-level
spend. If given as a channel-indexed array, the order must match
channels. The lower bound of media-level spend is (1 -
spend_constraint_lower) * budget * allocation). The value must be
between 0-1. Defaults to 0.3 for fixed budget and 1 for flexible.
spend_constraint_upper
Numeric list of size channels or float (same
constraint for all channels) indicating the upper bound of media-level
spend. If given as a channel-indexed array, the order must match
channels. The upper bound of media-level spend is (1 +
spend_constraint_upper) * budget * allocation). Defaults to 0.3 for
fixed budget and 1 for flexible.
Returns
An xarray Dataset with channel as the coordinate and the following data
variables
* optimized: media spend that maximizes incremental outcome based
on spend constraints for all media and RF channels.
* non_optimized: rounded channel-level spend.
Raises
A warning if the budget's rounding should be different from the grid's
round factor.'.
ValueError
If spend allocation is not within the grid coverage.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-06-17 UTC."],[],[]]