HomeArticle
Smart Rollout: How iFood uses Machine Learning to optimize coupon allocation
DADOS & IADATA & AI
06 mai.

Smart Rollout: How iFood uses Machine Learning to optimize coupon allocation

How iFood uses machine learning and operational research to optimize coupon distribution at massive scale


Providing discounts or coupons has become a natural marketing strategy for digital products to increase business metrics like purchases or user engagement. However, a follow-up question that these businesses need to answer is: what discount should be given, to whom, and when?

While this may seem simple, a single coupon allocation has huge impacts on business results and requires complex engineering solutions to be applied to millions of users at scale.

In this article, we describe how iFood uses machine learning and operational research to provide business teams with a platform that maximizes business metrics based on a target audience and business constraints. First, let’s define the problem we set out to solve.

The Problem: Coupon Allocation

What is iFood? In a nutshell, iFood is the largest delivery platform in Brazil operating in over 1,000 cities and connecting users with restaurants and grocery stores through its mobile and web apps. As of November 2025, it reached the landmark of 180M monthly orders. With such a high number of orders, any coupon distribution strategy plays a critical role in maintaining both user engagement and business profitability.

Defining a Coupon Distribution Strategy

At iFood, we define an allocation strategy using 4 pillars:

  • Audience: a target audience that will receive the coupons. These could be churn users, new users, or even subscribers.
  • Key Performance Indicator (KPI): which business metric we want to improve, such as maximize orders, maximize revenue or minimize costs.
  • Coupon portfolio: a set of different coupons that users within the audience can receive. We can have R$5.00 off on cart value, a 10% discount on specific items or free delivery and many other types of coupon mechanics.
  • Business constraints: specific rules that the allocation must follow, such as a maximum budget on incentives.

All these 4 components are defined by business teams based on their specific demands, which varies on specific areas of the product. For instance, teams that operate on groceries units will probably have different optimization settings from food delivery units.

Once an allocation strategy has been defined, it can be translated into an optimization problem. But before doing that, we need to take a quick trip to the economics realm.

Price Elasticity

Price elasticity measures how much a change in price affects a product’s demand. When an item is elastic, a change in price results in a significant change in sales. If a price change creates a small or no change in sales, then we say that the item is inelastic.

In the context of providing discounts to users, elasticity curves tell you how sensitive users are to incentives. Say we have the following incentive variants:

  • V1: $2 BRL discount
  • V2: $5 BRL discount
  • V3: $10 BRL discount

Most people would think that the higher the incentives, the higher the conversion rate. However, as we say in Brazil: life is not a strawberry! Not all users react the same way when given incentives. In fact, we can operate on 3 types of environments:

  • Elastic+: the higher the incentives, the higher the conversion rate
  • Inelastic: no response to incentives
  • Elastic-: the higher the incentives, the lower the conversion rate

With that being said, let’s move forward to our optimization problem.

Defining an Optimization Problem

Most optimization problems fall into the following framework:

Given a set of variables X, find the values of X that maximizes an objective function F restricted to a set of constraints C.

Or, in mathematical terms:

Let’s break it down to simpler problems and gradually make it more complex. Consider the previously defined set of coupon variants V (v1, v2 e v3) and a set of decision variables X(x1, x2 and x3) that decides the fraction of users that will receive each of these variants.

Problem 1: Maximize Orders

Since variable X represents a fraction, each of its values must sum up to 100%. Thus, it is translated as an allocation constraint Ca to our optimization problem:

Next, we need to define the Orders objective function in terms of our decision variables x1, x2 and x3.

To do so, we look at historical data and estimate how many orders of these coupon variants would generate if they operated separately. For instance, on a given audience we can infer from historical data that variant v1 would provide ô1 = 40 orders when x1 = 100%. Alternatively, we infer that ô2 = 70 orders and ô3 = 150 for v2 and v3, respectively. Basically, we are estimating the price-elasticity curves:

Based on these oi values, we can assume that if we allocated a xi fraction of users on variant vi, we would get xi oi orders, which leads to the missing objective function:

Finally, we have defined the complete optimization problem:

Problem 2: Maximize Orders, keeping at most an average R$4 discount per order

Now, besides the allocation constraint, the business team requested that iFood gives, on average, a R$4 discount at most.

Given that variants v1, v2 and v3 represent R$2, R$5 and R$10 discounts, respectively, we can translate this request into an additional budget constraint Cb:

Once we have the optimization problem set, we need to implement an algorithm that solves it based on historical data.

The Solution: Predict & Optimize

The optimization problem is an abstraction of the Predict + Optimize framework, which involves two main steps:

  • 1. Predict: Make predictions on the necessary metrics (e.g., predicted orders for each coupon variant).
    • 2. Optimize: Make allocation decisions based on the inferred metrics to maximize the objective function while meeting constraints.

    Based on the presented optimization problem, we need to make predictions on the orders considering each coupon variant.

    Let’s say we are making decisions on a daily basis, that is, everyday we change the coupon distribution. Then, predictions can be done by fetching a historical time series for each of the variants and estimating each metric for the next day.

    Time series forecasting is a challenge in itself and many algorithms have been developed in this field. Most algorithms rely solely on past data, in which case the prediction function would be something like:

    where N is the number of past data points to consider and “o_t” is the metric value on day t. One of the simplest algorithms one could use is the Exponential Weight Moving Average, which makes predictions by averaging past data on a given time window and weighting data according to their recency.

    Once the inference models are trained and predictions are computed, one can use several optimization algorithms like linear and mixed linear programming, which are available in python libraries such as PuLP or SciPy.

    More recently, we used iFoods Large Commerce Models as the main engine to make those inferences which greatly improved our inference capacity by leveraging the contextual knowledge of LLMs to overcome cold-start problems, that is, when we do not have enough information to create empirical time series.

    The Platform: Scaling to Multiple Businesses

    As you can see, many different settings might be configured for a single coupon allocation strategy: the audience to be impacted, the coupon portfolio to be offered, the business constraints to be set and so many other parameters. All of these can vary depending on the business unit, and so we need to provide different operations teams with a robust and scalable solution architecture.

    To this end, we built the Smart Rollout Models, a framework capable of abstracting all these configurations and concise solutions into a single python library.

    By setting execution metadata for both inference and optimization modules, the library orchestrates the workflow and outputs the allocation results, which are then fed to external engineering services responsible for serving the coupons at scale.

    As of early January 2026, the framework processes:

    • +60 strategies with varying business units (food delivery, groceries, pharmacy) and user lifecycles (early churn, late churn, new users, prospects)
    • +300 coupon variants with varying coupon mechanics (% off, discounts, free delivery)
    • +16000 time series forecasts with varying metrics (orders, subsidy, gross merchandise value)

    Conclusion

    In this article, we presented iFood’s “Smart Rollout”, a platform designed to optimize coupon allocation at massive scale. We demonstrated how machine learning and operational research are combined to solve the complex challenge of determining what discount to give, to whom, and when, while maximizing key business metrics and adhering to strict business constraints.

    By defining an allocation strategy based on four key pillars (Audience, KPI, Coupon Portfolio, and Business Constraints), we translate business needs into a clear optimization problem. The core of the solution lies in the Predict + Optimize framework, where time series forecasting models predict the expected performance of various coupon variants (Predict), and an optimization algorithm then determines the optimal user allocation to maximize the objective function (Optimize).

    Finally, the Smart Rollout Models framework abstracts this complex workflow into a scalable Python library, currently managing numerous distinct strategies, many coupon variants, and thousands of time series forecasts across various business units. This system ensures that iFood’s incentive strategy is data-driven, efficient, and highly effective in driving engagement and profitability.

    Share:
    Joao Felipe Guedes

    Joao Felipe Guedes

    Data Scientist

    Engenheiro de Machine Learning no iFood desde 2024. É formado em Engenharia Eletrônica e de Computação pela Universidade Federal do Rio de Janeiro e possui mestrado em Inteligência Computacional pela Coppe/UFRJ.

    Build the future at iFood

    We are always looking for passionate developers, designers and data scientists to help us revolutionize the food delivery experience. Join iFood Tech and be part of building the future of food technology.

    Discover our CareersArrow Right