Home » News » Case Study: Developing a digital twin of a retail loyalty scheme

Case Study: Developing a digital twin of a retail loyalty scheme

Developing a proof-of-concept digital twin of a retail loyalty scheme to simulate customer behaviour change in response to incentives. 

Project overview 

Increases in the cost of goods caused by disruptions to the global supply chain have led to an ongoing cost-of-living crisis and there are growing calls on businesses such as retailers to do more to support consumers who may be vulnerable to price increases (Which?, 2022).

Customer loyalty schemes offer benefits to both customers and businesses including the ability to nudge purchasing behaviours towards more sustainable, affordable, or healthier goals. In addition, modern data infrastructure and technology offers the ability to make data-driven business decisions relating to loyalty schemes.

In collaboration with a large retailer, this work develops a proof-of-concept (PoC) digital twin of a customer loyalty scheme consisting of an agent-based model (ABM) to generate synthetic purchasing scenarios from consumer agents. The model is integrated with a cloud-based Digital Twin platform which enables the analysis of simulation outputs by multiple users through graph-based queries.

The goal of the project was to create a PoC system capable of exploring ‘what-if’ scenarios relating to the retailer’s loyalty scheme to assess the impact of including certain products within the scheme. 

Data and methods  

We collaborated with our retail partner’s Decision Science & Analytics team to develop the PoC. They use Microsoft Azure for operational data stores and other services, hence to support model initialisation and integration with existing business practices (e.g. reporting pipelines), the simulation system utilises the Azure Digital Twins (ADT) service. The ABM back-end uses the open-source Mesa agent-based modelling framework and feeds into the digital twin via the Python Software Development Kit (SDK). The digital twin uses a graph database to capture the current state of a running simulation. The ABM consists of distinct customer agents together with a purchasing model that depends on attributes of each customer agent and a sample product database.  

On model initialization, customer agents are instantiated from customer segments, defining store visit frequency and receptiveness to promotions. On each time step, customers decide whether to visit the store, based on a probability distribution informed by customer segments. The set of available products is matched via product attributes to customers’ preferences, and these are combined to form a contextual purchase intention for each product (Doniec et al., 2020). This is then used to construct a basket for each customer per visit. Important model factors that lead to emergent dynamics within the simulation include product affinities, which influence the attractiveness of products based on items already within a basket and, importantly for our research question, the influence of promotions delivered via the loyalty scheme. Combining product affinities with the impact of promotions supports ‘what-if’ scenarios where a promotion of Product A via the loyalty scheme leads to an uplift or drop in sales for Product B, depending on the associated affinity between the two products. 

Key findings  

The primary outcome of the project is the PoC system comprising of an ABM integrated with Azure Digital Twins, capable of exploring what-if scenarios in relation to the loyalty scheme. We have demonstrated the PoC system exhibits representative customer behaviour in response to the promotion of products within a sample catalogue. The following describes an example. 

A sample product catalogue, shown in Figure 1, was set up in ADT’s graph database. The sample catalogue contains five products: fajita seasoning, wraps, black beans, garden peas, and shampoo. The sale of wraps is associated with an uplift in the sales of fajita seasoning and black beans. This is captured by product-product relationships shown in Figure 1 (dashed lines). 

Figure 1: Example product catalogue graph set up in Azure Digital Twins 

Simulated sales were generated via agent purchases from the sample catalogue. From day 30 to 60 of the simulation, wraps were placed on promotion as shown by the grey region within Figure 2. The model captures an increase in wrap sales (red) driven by the customer agent segments most receptive to promotions. This sales increase is also apparent for the associated products, black beans, and fajita seasoning (blue and yellow), as they are commonly bought together. As the model runs, simulated transactions made by customer agents are written to ADT.

Figure 2: Output simulated sales quantities (seven-day rolling average) for 200 customer agents over 90 days for the example product catalogue 

The resultant transaction graph for a single customer agent is displayed in Figure 3. The agent (blue) has made five transactions (pink) over the simulation period. Each transaction possesses relationships to the products purchased (orange). Multiple users can simultaneously analyse the resultant customer-transaction graph through graph-based queries.   

Figure 3: Output ADT graph for a single customer agent over a 90-day simulation period for the example product catalogue 

Documentation for the system was prepared covering its ABM, integration with Azure Digital Twins, and a walkthrough of conducting simulations using the PoC. This was shared with our retail partner, alongside the codebase, to support their continuation of the project. 

Value of the research  

The integration of ABM with an enterprise graph database capturing product affinities offers significant potential for the answering of deeper, more complex ‘what-if’ questions in relation to customer loyalty schemes. This supports the optimisation of loyalty schemes towards desired outcomes, such as healthier or more sustainable consumer purchasing. 

The PoC digital twin contains a framework for simulating purchasing behaviour under the influence of a loyalty scheme; a foundation from which the system can be developed, and further value realised. Integration with our partner’s existing customer segmentation database would enable timely updates to the model as customer segments evolve. Integration with customer and product feature stores would enable the creation of more realistic, nuanced agents improving the simulation further. Multi-order product affinity relationships, where purchasing Product A influences the purchase of product B which in turn influences product C, could be captured and utilised in the system. This would likely lead to further emergent behaviour generating valuable insights into the knock-on effects of promotion decisions.  


  • Bridging the gap between agent-based modelling and digital twins 
  • Integrating agent-based modelling with enterprise data infrastructure  
  • Exploring ‘what-if’ scenarios relating to customer loyalty schemes 


James Battye – Data Scientist, Leeds Institute for Data Analytics, University of Leeds 

Dr Peter Baudains – Research Data Scientist, Consumer Data Research Centre, University of Leeds 

Dr Jonathan Ward – Lecturer, School of Mathematics, University of Leeds 


NDA applies 


Consumer Data Research Centre 


Which? 2022. Affordable food for all: how supermarkets can help in the cost of food crisis. Site. [Online]. [Accessed 3 April 2023]. Available from: https://www.which.co.uk/policy/policy/consumers/9142/affordable-food-for-all-how-supermarkets-can-help-in-the-cost-of-food-crisis. 

Doniec, A., Lecoeuche, S., Mandiau, R. and Sylvain, A. 2020. Purchase intention-based agent for customer behaviours. Information Sciences. 521, pp.380–397.