BudgetOptimizer.allocate_budget#

BudgetOptimizer.allocate_budget(total_budget, budget_bounds=None, custom_constraints=None, minimize_kwargs=None)[source]#

Allocate the budget based on the total budget, budget bounds, and custom constraints.

The default budget bounds are (0, total_budget) for each channel.

The default constraint is the sum of all budgets should be equal to the total budget.

The optimization is done using the Sequential Least Squares Quadratic Programming (SLSQP) method and it’s constrained such that: 1. The sum of budgets across all channels equals the total available budget. 2. The budget allocated to each individual channel lies within its specified range.

The purpose is to maximize the total expected objective based on the inequality and equality constraints.

Parameters:
total_budgetfloat

The total budget.

budget_boundsdict[str, tuple[float, float]], optional

The budget bounds for each channel. Default is None.

custom_constraintsdict, optional

Custom constraints for the optimization. Default is None.

minimize_kwargsdict, optional

Additional keyword arguments for the scipy.optimize.minimize function. If None, default values are used. Method is set to “SLSQP”, ftol is set to 1e-9, and maxiter is set to 1_000.

Returns:
tuple[dict[str, float], float]

The optimal budgets for each channel and the negative total response value.

Raises:
Exception

If the optimization fails, an exception is raised with the reason for the failure.