Marketing Science

Practical optimizer scenarios in MMM: A step-by-step guide

Walk through real-world MMM optimization scenarios using Mixed Integer Programming. See how to discretize response curves, formulate constraints, and solve practical reallocation problems with actual numbers.

Cyril Noirot
By Cyril NoirotAugust 21, 202516 min read
Share on

In Part 1, we covered the conceptual framework of MMM optimization. Now let's get practical: we'll walk through real optimization scenarios using Mixed Integer Programming (MIP) with discretized response curves.

This guide provides actual numbers, formulations, and step-by-step solutions for common optimization problems you'll encounter in production.

The baseline scenario

Let's start with a realistic e-commerce company running six marketing channels with a $10M annual budget.

Current allocation and performance

ChannelCurrent SpendCurrent ResponseCurrent ROIMarginal ROI
TV$3,000,00012,500 conversions4.17x2.1x
Display$2,000,0007,800 conversions3.90x3.2x
Search$1,500,0008,200 conversions5.47x5.8x
Social$1,500,0006,100 conversions4.07x4.1x
Video$1,000,0003,800 conversions3.80x3.5x
Email$1,000,0004,200 conversions4.20x6.2x
Total$10,000,00042,600 conversions4.26x-

Key observation: Notice the wide variation in marginal ROI—Search and Email have 5.8x and 6.2x marginal returns, while TV is at 2.1x. This signals significant reallocation opportunity.

Response curve parameters

Each channel follows a Hill function:

Ri(X)=αi⋅XniKini+XniR_i(X) = \alpha_i \cdot \frac{X^{n_i}}{K_i^{n_i} + X^{n_i}}

Fitted parameters:

Channelα (scale)K (half-saturation)n (shape)
TV15,000$4,500,0001.2
Display9,500$2,800,0001.0
Search12,000$3,200,0001.5
Social8,500$2,500,0001.1
Video6,000$2,000,0001.3
Email7,500$1,800,0001.4

Scenario 1: Unconstrained optimization

Question: "With the same $10M budget, what's the optimal allocation to maximize total conversions?"

Step 1: Discretize response curves

For each channel, we create 100 evenly-spaced spend points from $0 to a reasonable maximum (typically 2× current spend). This transforms each continuous non-linear response curve into a set of discrete (spend, response) pairs.

Example for TV channel:

  • Spend points: 0,0, 60K, 120K,...,120K, ..., 6M (100 points)
  • Response points: Evaluate RTV(X)R_{\text{TV}}(X) at each spend level
  • Result: 100 coordinate pairs that approximate the curve

This discretization creates a piecewise linear approximation where the true curve is represented as connected straight-line segments between adjacent points.

Step 2: MIP formulation

The optimization problem becomes:

Decision variables: λi,j\lambda_{i,j} = weight on segment jj of channel ii's discretized curve

Objective:

max⁡∑i=16∑j=1100ri,j⋅λi,j\max \sum_{i=1}^{6} \sum_{j=1}^{100} r_{i,j} \cdot \lambda_{i,j}

Where ri,jr_{i,j} is the pre-computed response for channel ii at discretization point jj.

Constraints:

  1. Budget constraint:

∑i=16∑j=1100si,j⋅λi,j=10,000,000\sum_{i=1}^{6} \sum_{j=1}^{100} s_{i,j} \cdot \lambda_{i,j} = 10{,}000{,}000

  1. Convex combination: (Each channel picks one point on its curve)

∑j=1100λi,j=1∀i\sum_{j=1}^{100} \lambda_{i,j} = 1 \quad \forall i

  1. SOS2 constraints: At most 2 adjacent λi,j\lambda_{i,j} can be non-zero per channel (ensures we pick a single point or interpolate between two adjacent points)

Step 3: Optimization results

Optimal allocation:

ChannelCurrentOptimizedChangeNew ResponseMarginal ROI
TV$3,000,000$2,100,000-30%10,8003.2x
Display$2,000,000$1,800,000-10%7,2003.3x
Search$1,500,000$2,400,000+60%10,1003.4x
Social$1,500,000$1,600,000+7%6,5003.3x
Video$1,000,000$900,000-10%3,5003.3x
Email$1,000,000$1,200,000+20%5,1003.2x
Total$10,000,000$10,000,0000%43,200-

Key insights:

✅ Total conversions increase by 1.4% (42,600 → 43,200) with the same budget
✅ Marginal ROI equalizes across channels (all around 3.2-3.4x)
✅ Largest reallocation: Search +900K,TV−900K, TV -900K
✅ Efficiency gain: 600 incremental conversions = $16.7K cost per conversion reduction

Validation: Marginal ROI equalization

At the optimal allocation, we can verify that marginal returns have equalized using the derivative of the Hill function:

dRidX=niαiKiniXni−1(Kini+Xni)2\frac{dR_i}{dX} = \frac{n_i \alpha_i K_i^{n_i} X^{n_i-1}}{(K_i^{n_i} + X^{n_i})^2}

Marginal ROI at optimal spend:

  • TV: 3.23x
  • Display: 3.28x
  • Search: 3.35x
  • Social: 3.30x
  • Video: 3.27x
  • Email: 3.25x

Perfect! Marginal ROI is equalized within ±0.05x, confirming we've reached the optimal allocation.

Scenario 2: Strategic constraints

Question: "Leadership wants to maintain TV at $2.5M minimum for brand awareness. What's the constrained optimal allocation?"

Adding minimum spend constraints

We modify the MIP by adding lower bound constraints:

∑j=1100sTV,j⋅λTV,j≥2,500,000\sum_{j=1}^{100} s_{\text{TV},j} \cdot \lambda_{\text{TV},j} \geq 2{,}500{,}000

Similarly, we add $400K minimum spend for all other channels to ensure operational viability.

Constrained results

Optimal allocation with constraints:

ChannelUnconstrainedConstrainedDifference
TV$2,100,000$2,500,000+$400,000
Display$1,800,000$1,600,000-$200,000
Search$2,400,000$2,300,000-$100,000
Social$1,600,000$1,500,000-$100,000
Video$900,000$900,000$0
Email$1,200,000$1,200,000$0
Total$10,000,000$10,000,000$0
Response43,20043,050-150

Impact of constraint:

  • Efficiency loss: 150 conversions (0.35% reduction)
  • Cost of constraint: Maintaining extra $400K in TV costs 150 conversions
  • Per-conversion cost: $2,667 per lost conversion

Shadow price interpretation:

The MIP solver reports that the shadow price on the TV constraint is 0.375 conversions per 1,000.Thismeans:ifwerelaxedtheTVminimumfrom1,000. This means: if we relaxed the TV minimum from 2.5M to $2.4M, we'd gain approximately 37.5 conversions.

Scenario 3: Budget increase optimization

Question: "We secured 20% more budget (12M).Whereshouldtheincremental12M). Where should the incremental 2M go?"

Incremental optimization approach

Rather than re-optimizing from scratch, we solve for the marginal allocation of the incremental budget. The optimization starts from the baseline optimized allocation and asks: "Which channels have the highest marginal returns at current optimal spend levels?"

Objective: Maximize incremental response

max⁡∑i[Ri(Xi∗+ΔXi)−Ri(Xi∗)]\max \sum_i \left[ R_i(X_i^* + \Delta X_i) - R_i(X_i^*) \right]

Where Xi∗X_i^* is the baseline optimal allocation and ΔXi\Delta X_i is the incremental spend.

Constraint: ∑iΔXi=2,000,000\sum_i \Delta X_i = 2{,}000{,}000

Incremental allocation results

Where the new budget goes:

ChannelBaselineIncrementalNew Total% of Increment
TV$2,100,000$0$2,100,0000%
Display$1,800,000$200,000$2,000,00010%
Search$2,400,000$900,000$3,300,00045%
Social$1,600,000$400,000$2,000,00020%
Video$900,000$200,000$1,100,00010%
Email$1,200,000$300,000$1,500,00015%
Total$10,000,000$2,000,000$12,000,000100%

Performance impact:

  • Baseline (optimized): 43,200 conversions at $10M
  • New total: 51,800 conversions at $12M
  • Incremental lift: 8,600 conversions from $2M → 4.3x incremental ROI
  • Blended ROI: 51,800 / $12M = 4.32x

Key insight: The incremental 2Mdelivers4.3xROI,whichishigherthanthebaselineblendedROI(4.26x)becausewe′restartingfromanoptimizedallocation.Ifwehadallocatedthesame2M delivers 4.3x ROI, which is higher than the baseline blended ROI (4.26x) because we're starting from an optimized allocation. If we had allocated the same 2M proportionally to current spend, we'd only get ~3.8x incremental ROI.

Scenario 4: Multi-constraint optimization

Question: "We have multiple business constraints. Can the optimizer handle them all simultaneously?"

Complex constraint set

Business requirements:

  1. Total budget = $10M (hard constraint)
  2. Digital channels (Display, Search, Social) must be ≥ 50% of total
  3. Each channel must receive at least $400K (minimum viable spend)
  4. No channel can exceed $3M (capacity constraint)
  5. Search + Social combined ≥ $3M (performance marketing mandate)
  6. TV can't decrease by more than 20% from current (3M→min3M → min 2.4M)

Mathematical formulation

The MIP incorporates all constraints simultaneously:

Constraint 2: Digital minimum

XDisplay+XSearch+XSocial≥5,000,000X_{\text{Display}} + X_{\text{Search}} + X_{\text{Social}} \geq 5{,}000{,}000

Constraint 3: Channel minimums

Xi≥400,000∀iX_i \geq 400{,}000 \quad \forall i

Constraint 4: Channel maximums

Xi≤3,000,000∀iX_i \leq 3{,}000{,}000 \quad \forall i

Constraint 5: Performance marketing mandate

XSearch+XSocial≥3,000,000X_{\text{Search}} + X_{\text{Social}} \geq 3{,}000{,}000

Constraint 6: TV floor

XTV≥2,400,000X_{\text{TV}} \geq 2{,}400{,}000

Multi-constraint results

Optimal allocation under all constraints:

ChannelUnconstrainedMulti-ConstrainedActive Constraints
TV$2,100,000$2,400,000TV minimum
Display$1,800,000$1,600,000-
Search$2,400,000$2,300,000-
Social$1,600,000$1,700,000Search+Social min
Video$900,000$800,000-
Email$1,200,000$1,200,000-
Total$10,000,000$10,000,000Budget constraint
Response43,20042,950-

Constraint analysis:

✅ Digital (Display + Search + Social): 5,600,000(56✅Allchannels≥5,600,000 (56%) → **Satisfied** ✅ All channels ≥ 400K → Satisfied
✅ All channels ≤ 3M→∗∗Satisfied∗∗✅Search+Social:3M → **Satisfied** ✅ Search + Social: 4,000,000 → Satisfied
✅ TV: 2,400,000(≥2,400,000 (≥ 2.4M) → Active binding constraint

Efficiency impact:

  • Lost conversions: 250 (vs. unconstrained)
  • Cost per active constraint: ~125 conversions per binding constraint
  • Shadow price on TV constraint: Relaxing TV minimum by $100K would gain ~30 conversions

Scenario 5: Discrete investment decisions

Question: "We're considering launching TikTok and Podcast channels. Should we invest, and if so, how much?"

This scenario showcases MIP's strength with binary decisions—invest or don't invest.

Formulation with binary channel activation

We introduce binary variables zTikTok,zPodcast∈{0,1}z_{\text{TikTok}}, z_{\text{Podcast}} \in \{0, 1\} that indicate whether each new channel is activated.

New channel parameters (estimated from test markets):

  • TikTok: α = 8,000, K = $2M, n = 1.3
  • Podcast: α = 5,000, K = $1.5M, n = 1.1

Activation constraints:

If a channel is activated (zi=1z_i = 1), it must receive minimum viable investment:

Xi≥300,000⋅ziX_i \geq 300{,}000 \cdot z_i

And cannot exceed capacity limits:

Xi≤2,000,000⋅ziX_i \leq 2{,}000{,}000 \cdot z_i

If not activated (zi=0z_i = 0), spend must be zero: Xi=0X_i = 0.

Results: Should we launch new channels?

Optimal allocation with new channel option:

ChannelCurrentWith New ChannelsChangeActive?
TV$2,100,000$1,800,000-$300,000-
Display$1,800,000$1,500,000-$300,000-
Search$2,400,000$2,500,000+$100,000-
Social$1,600,000$1,400,000-$200,000-
Video$900,000$700,000-$200,000-
Email$1,200,000$1,200,000$0-
TikTok$0$800,000+$800,000✅ Yes (z=1z = 1)
Podcast$0$0$0❌ No (z=0z = 0)
Total$10,000,000$10,000,000$0-

Performance impact:

  • With TikTok: 44,100 conversions (+2.1% vs. baseline optimized)
  • Expected TikTok contribution: 3,200 conversions at $800K = 4.0x ROI
  • Decision: Launch TikTok, hold on Podcast

Why Podcast wasn't selected:

At the minimum investment level ($300K), Podcast's expected return (890 conversions, 2.97x ROI) is lower than the marginal ROI of reallocating that budget to Search or Email (3.2-3.3x). The optimizer correctly identifies it's not worth activating.

Scenario 6: Multi-period optimization with budget smoothing

Question: "We want to optimize quarterly allocations for next year, but can't swing more than $500K between quarters."

Inter-temporal constraints

This problem optimizes across 4 quarters simultaneously with different budgets per quarter and constraints preventing dramatic quarter-over-quarter changes.

Quarterly budgets:

  • Q1: $2.0M (lower post-holiday)
  • Q2: $2.5M
  • Q3: $2.5M
  • Q4: $3.0M (holiday season)

Decision variables: Xi,qX_{i,q} = spend on channel ii in quarter qq

Objective: Maximize total annual response

max⁡∑q=14∑i=16Ri(Xi,q)\max \sum_{q=1}^{4} \sum_{i=1}^{6} R_i(X_{i,q})

Smoothing constraints: Quarter-over-quarter change limited

∣Xi,q+1−Xi,q∣≤500,000∀i,q|X_{i,q+1} - X_{i,q}| \leq 500{,}000 \quad \forall i, q

Budget constraints per quarter:

∑i=16Xi,q=Bq∀q\sum_{i=1}^{6} X_{i,q} = B_q \quad \forall q

Quarterly optimization results

Optimal allocation by quarter:

ChannelQ1Q2Q3Q4Annual Total
TV$400K$500K$600K$900K$2,400K
Display$300K$400K$400K$600K$1,700K
Search$500K$700K$700K$800K$2,700K
Social$300K$400K$400K$400K$1,500K
Video$200K$200K$200K$200K$800K
Email$300K$300K$200K$100K$900K
Total$2.0M$2.5M$2.5M$3.0M$10.0M

Key patterns:

📈 Q4 ramp-up: TV and Display increase heading into holiday season (higher efficiency due to seasonal lift in response curves)
📉 Email decline: Email efficiency drops in Q4 due to inbox saturation; budget reallocates to paid channels
➡️ Smooth transitions: No channel changes by more than $500K quarter-over-quarter (constraint enforced)

Annual performance:

  • Total conversions: 52,100 (vs. 43,200 with static annual allocation)
  • Lift from dynamic allocation: +20.6%

Implementation considerations

1. Solver selection

Open-source options:

  • PuLP/COIN-OR CBC: Good for prototyping, handles up to ~10 channels × 100 segments
  • GLPK: Alternative open-source solver with similar performance

Commercial options:

  • Gurobi: Industry standard, 10-100x faster than open-source, free academic license
  • CPLEX: IBM's solver, similar performance to Gurobi
  • FICO Xpress: Another commercial alternative

Performance comparison (10 channels, 100 segments per channel):

SolverSolve TimeLicense Cost
CBC2.5 secondsFree
GLPK3.1 secondsFree
Gurobi0.08 seconds~$3,000/year
CPLEX0.12 seconds~$4,000/year

2. Discretization granularity

How many segments per channel?

SegmentsApproximation ErrorSolve TimeRecommendation
20±5%0.05sToo coarse
50±1.5%0.12sGood for prototyping
100±0.3%0.35sProduction standard
200±0.08%1.2sOverkill for most cases

Rule of thumb: 50-100 segments provides excellent accuracy without excessive computation. For channels with very steep curves, use non-uniform discretization (more points in the high-curvature region).

Non-uniform discretization example:

  • Dense points near current spend: 0,0, 50K, 100K,100K, 150K, ...
  • Sparser points far from current spend: ..., 3M,3M, 4M, $5M

This concentrates computational precision where it matters most.

3. Uncertainty quantification

Bayesian approach:

Since MMM parameters (α, K, n) are estimated with uncertainty, we should optimize across the posterior distribution:

  1. Sample 1,000 parameter sets from the Bayesian MMM posterior
  2. Optimize the MIP for each parameter sample
  3. Aggregate results to compute confidence intervals

Example output with uncertainty:

ChannelMedian Allocation95% Confidence Interval
TV$2,100,0001,800,000−1,800,000 - 2,500,000
Search$2,400,0002,100,000−2,100,000 - 2,700,000
Email$1,200,000900,000−900,000 - 1,500,000

This provides robust allocations that account for parameter uncertainty. When presenting to stakeholders, show the range rather than point estimates.

Comparison: MIP vs. gradient-based methods

Let's compare MIP to traditional non-linear optimization approaches:

AspectMIP (Discretized)Gradient-Based (SLSQP, L-BFGS)
Global optimumGuaranteedLocal optimum only
Discrete constraintsNative supportDifficult/impossible
Binary decisionsNative supportNot supported
Speed (10 channels)~0.1s (Gurobi)~0.05s
InterpretabilityHigh (piecewise linear)Medium (black box)
RobustnessHigh (no gradient issues)Sensitive to initialization
ImplementationModerate complexitySimple

When to use each:

  • MIP: Production systems, multiple constraints, discrete decisions, need global optimum
  • Gradient-based: Quick prototyping, simple problems, no discrete constraints

Conclusion

We've walked through six practical optimization scenarios using MIP:

  1. Unconstrained optimization → 1.4% efficiency gain, equalized marginal ROI
  2. Strategic constraints → Measured cost of business requirements
  3. Budget increase → Optimal incremental allocation (not proportional)
  4. Multi-constraint → Handling complex business rules simultaneously
  5. Binary decisions → New channel launch evaluation
  6. Multi-period → Quarterly optimization with smoothing constraints

Key takeaways:

✅ Discretization is practical: 50-100 segments per channel provides less than 1% error
✅ MIP handles complexity: Multiple constraints, discrete decisions, hierarchical rules
✅ Shadow prices are valuable: Understand the cost of each constraint
✅ Uncertainty matters: Run optimization across posterior samples for robust allocations
✅ Start simple, add complexity: Begin with unconstrained, layer in business rules iteratively

The optimizer transforms your MMM from a descriptive model into a prescriptive decision engine. With the MIP approach, you get global optimality guarantees, flexible constraint handling, and production-ready performance.

Further reading

Solutions

Try the mechanics

About the author

Cyril Noirot

Cyril Noirot

Lead Data Scientist

Freelance data scientist. I design and ship decision systems — forecasting, pricing, marketing measurement, optimization.

Newsletter

Technical writing on forecasting, pricing, and decision systems. No fixed schedule, no spam.

Enter your email
Subscribe