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
| Channel | Current Spend | Current Response | Current ROI | Marginal ROI |
|---|---|---|---|---|
| TV | $3,000,000 | 12,500 conversions | 4.17x | 2.1x |
| Display | $2,000,000 | 7,800 conversions | 3.90x | 3.2x |
| Search | $1,500,000 | 8,200 conversions | 5.47x | 5.8x |
| Social | $1,500,000 | 6,100 conversions | 4.07x | 4.1x |
| Video | $1,000,000 | 3,800 conversions | 3.80x | 3.5x |
| $1,000,000 | 4,200 conversions | 4.20x | 6.2x | |
| Total | $10,000,000 | 42,600 conversions | 4.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:
Fitted parameters:
| Channel | α (scale) | K (half-saturation) | n (shape) |
|---|---|---|---|
| TV | 15,000 | $4,500,000 | 1.2 |
| Display | 9,500 | $2,800,000 | 1.0 |
| Search | 12,000 | $3,200,000 | 1.5 |
| Social | 8,500 | $2,500,000 | 1.1 |
| Video | 6,000 | $2,000,000 | 1.3 |
| 7,500 | $1,800,000 | 1.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: 60K, 6M (100 points)
- Response points: Evaluate 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: = weight on segment of channel 's discretized curve
Objective:
Where is the pre-computed response for channel at discretization point .
Constraints:
- Budget constraint:
- Convex combination: (Each channel picks one point on its curve)
- SOS2 constraints: At most 2 adjacent can be non-zero per channel (ensures we pick a single point or interpolate between two adjacent points)
Step 3: Optimization results
Optimal allocation:
| Channel | Current | Optimized | Change | New Response | Marginal ROI |
|---|---|---|---|---|---|
| TV | $3,000,000 | $2,100,000 | -30% | 10,800 | 3.2x |
| Display | $2,000,000 | $1,800,000 | -10% | 7,200 | 3.3x |
| Search | $1,500,000 | $2,400,000 | +60% | 10,100 | 3.4x |
| Social | $1,500,000 | $1,600,000 | +7% | 6,500 | 3.3x |
| Video | $1,000,000 | $900,000 | -10% | 3,500 | 3.3x |
| $1,000,000 | $1,200,000 | +20% | 5,100 | 3.2x | |
| Total | $10,000,000 | $10,000,000 | 0% | 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
✅ 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:
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:
Similarly, we add $400K minimum spend for all other channels to ensure operational viability.
Constrained results
Optimal allocation with constraints:
| Channel | Unconstrained | Constrained | Difference |
|---|---|---|---|
| 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 |
| $1,200,000 | $1,200,000 | $0 | |
| Total | $10,000,000 | $10,000,000 | $0 |
| Response | 43,200 | 43,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 2.5M to $2.4M, we'd gain approximately 37.5 conversions.
Scenario 3: Budget increase optimization
Question: "We secured 20% more budget (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
Where is the baseline optimal allocation and is the incremental spend.
Constraint:
Incremental allocation results
Where the new budget goes:
| Channel | Baseline | Incremental | New Total | % of Increment |
|---|---|---|---|---|
| TV | $2,100,000 | $0 | $2,100,000 | 0% |
| Display | $1,800,000 | $200,000 | $2,000,000 | 10% |
| Search | $2,400,000 | $900,000 | $3,300,000 | 45% |
| Social | $1,600,000 | $400,000 | $2,000,000 | 20% |
| Video | $900,000 | $200,000 | $1,100,000 | 10% |
| $1,200,000 | $300,000 | $1,500,000 | 15% | |
| Total | $10,000,000 | $2,000,000 | $12,000,000 | 100% |
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 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:
- Total budget = $10M (hard constraint)
- Digital channels (Display, Search, Social) must be ≥ 50% of total
- Each channel must receive at least $400K (minimum viable spend)
- No channel can exceed $3M (capacity constraint)
- Search + Social combined ≥ $3M (performance marketing mandate)
- TV can't decrease by more than 20% from current (2.4M)
Mathematical formulation
The MIP incorporates all constraints simultaneously:
Constraint 2: Digital minimum
Constraint 3: Channel minimums
Constraint 4: Channel maximums
Constraint 5: Performance marketing mandate
Constraint 6: TV floor
Multi-constraint results
Optimal allocation under all constraints:
| Channel | Unconstrained | Multi-Constrained | Active Constraints |
|---|---|---|---|
| TV | $2,100,000 | $2,400,000 | TV minimum |
| Display | $1,800,000 | $1,600,000 | - |
| Search | $2,400,000 | $2,300,000 | - |
| Social | $1,600,000 | $1,700,000 | Search+Social min |
| Video | $900,000 | $800,000 | - |
| $1,200,000 | $1,200,000 | - | |
| Total | $10,000,000 | $10,000,000 | Budget constraint |
| Response | 43,200 | 42,950 | - |
Constraint analysis:
✅ Digital (Display + Search + Social): 400K → Satisfied
✅ All channels ≤ 4,000,000 → Satisfied
✅ TV: 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 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 (), it must receive minimum viable investment:
And cannot exceed capacity limits:
If not activated (), spend must be zero: .
Results: Should we launch new channels?
Optimal allocation with new channel option:
| Channel | Current | With New Channels | Change | Active? |
|---|---|---|---|---|
| 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 | - |
| $1,200,000 | $1,200,000 | $0 | - | |
| TikTok | $0 | $800,000 | +$800,000 | ✅ Yes () |
| Podcast | $0 | $0 | $0 | ❌ No () |
| 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: = spend on channel in quarter
Objective: Maximize total annual response
Smoothing constraints: Quarter-over-quarter change limited
Budget constraints per quarter:
Quarterly optimization results
Optimal allocation by quarter:
| Channel | Q1 | Q2 | Q3 | Q4 | Annual 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 |
| $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):
| Solver | Solve Time | License Cost |
|---|---|---|
| CBC | 2.5 seconds | Free |
| GLPK | 3.1 seconds | Free |
| Gurobi | 0.08 seconds | ~$3,000/year |
| CPLEX | 0.12 seconds | ~$4,000/year |
2. Discretization granularity
How many segments per channel?
| Segments | Approximation Error | Solve Time | Recommendation |
|---|---|---|---|
| 20 | ±5% | 0.05s | Too coarse |
| 50 | ±1.5% | 0.12s | Good for prototyping |
| 100 | ±0.3% | 0.35s | Production standard |
| 200 | ±0.08% | 1.2s | Overkill 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: 50K, 150K, ...
- Sparser points far from current spend: ..., 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:
- Sample 1,000 parameter sets from the Bayesian MMM posterior
- Optimize the MIP for each parameter sample
- Aggregate results to compute confidence intervals
Example output with uncertainty:
| Channel | Median Allocation | 95% Confidence Interval |
|---|---|---|
| TV | $2,100,000 | 2,500,000 |
| Search | $2,400,000 | 2,700,000 |
| $1,200,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:
| Aspect | MIP (Discretized) | Gradient-Based (SLSQP, L-BFGS) |
|---|---|---|
| Global optimum | Guaranteed | Local optimum only |
| Discrete constraints | Native support | Difficult/impossible |
| Binary decisions | Native support | Not supported |
| Speed (10 channels) | ~0.1s (Gurobi) | ~0.05s |
| Interpretability | High (piecewise linear) | Medium (black box) |
| Robustness | High (no gradient issues) | Sensitive to initialization |
| Implementation | Moderate complexity | Simple |
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:
- Unconstrained optimization → 1.4% efficiency gain, equalized marginal ROI
- Strategic constraints → Measured cost of business requirements
- Budget increase → Optimal incremental allocation (not proportional)
- Multi-constraint → Handling complex business rules simultaneously
- Binary decisions → New channel launch evaluation
- 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
Lead Data Scientist
Freelance data scientist. I design and ship decision systems — forecasting, pricing, marketing measurement, optimization.