scieee AI-readable full text Open interactive document viewer

Optimization of marketing strategies in dynamic environments: an epidemiological approach to the spread of advertising campaigns

Mota, Vasco Peres Filipe Pimentel da

Abstract

This dissertation explores how principles from Mathematical Epidemiology, particularly the SIR Model, and Optimal Control The ory can be applied to Viral Marketing. The main objective is to investigate the dynamics of four different viral marketing campaigns using these mathematical tools to improve the strategies behind spreading information through social networks. By leveraging concep ts traditionally used to understand the spread of infectious diseases, we can gain deeper insights into how marketing messages propagate among digital world. The application of Optimal Control Theory in this context allows us to develop strategies that optimize the reach and impact of these campaigns, while efficiently managing costs and resources. This interdisciplinary approach not only enhances our understan ding of how viral marketing works but also provides a framework for designing more effective marketing interventions. Ultimately, the goal of this research is to bridge the gap between epidemiological modeling and marketing, offering a new perspective on h ow to create and control successful viral marketing campaigns.

Full text

Setembro de 2024 Universidade do Minho Escola de Engenharia Vasco Peres Filipe Pimentel da Mota Optimization of marketing strategies in dynamic environments: an epidemiological approach to the spread of advertising campaigns Setembro de 2024 Universidade do Minho Escola de Engenharia Vasco Peres Filipe Pimentel da Mota Optimization of marketing strategies in dynamic environments: an epidemiological approach to the spread of advertising campaigns Dissertação de Mestrado Mestrado Integrado em Engenharia e Gestão Industrial Trabalho efetuado sob a orientação de Professora Doutora Maria Teresa Torres Monteiro Professor Doutor João Nuno Costa Gonçalves ii ii D IREITOS DE A UTOR E C ONDIÇÕES DE U TILIZAÇÃO DO T RABALHO POR T ERCEIROS Este é um trabalho académico que pode ser utilizado por terceiros desde que respeitadas as regras e boas práticas internacionalmente aceites, no que concerne aos direitos de autor e direitos conexos. Assim, o presente trabalho pode ser utilizado nos termos previstos na licença abaixo indicada. Caso o utilizador necessite de permissão para poder fazer um uso do trabalho em condições não previstas no licenciamento indicado, deverá contactar o autor, através do RepositóriUM da Universidade do Minho. Licença concedida aos utilizadores deste trabalho Atribuição CC BY https://creativecommons.org/licenses/by/4.0/ iii iii Acknowledgments My deepest gratitude goes to my mother and my maternal grandmother. Without their incredibly strong and exceptional support from day one until the very last day, this milestone would not have been possible. My next thank you goes to Dr. Teresa Monteiro and Dr. João Gonçalves for their support during the development of this dissertation. Their constant, close, and unwavering support allowed me to complete this final phase of my course with ease, tranquility, and a joy for learning. iv iv DECLARAÇÃO DE INTEGRIDADE Declaro ter atuado com integridade na elaboração do presente trabalho académico e confirmo que não recorri à prática de plágio nem a qualquer forma de utilização indevida ou falsificação de informações ou resultados em nenhuma das etapas conducente à sua elaboração. Mais declaro que conheço e que respeitei o Código de Conduta Ética da Universidade do Minho. v Optimization of marketing strategies in dynamic environments: an epidemiological approach to the spread of advertising campaigns A BSTRACT This dissertation explores how principles from Mathematical Epidemiology, particularly the SIR Model, and Optimal Control Theory can be applied to Viral Marketing. The main objective is to investigate the dynamics of four different viral marketing campaigns using these mathematical tools to improve the strategies behind spreading information through social networks. By leveraging concepts traditionally used to understand the spread of infectious diseases, we can gain deeper insights into how marketing messages propagate among digital world. The application of Optimal Control Theory in this context allows us to develop strategies that optimize the reach and impact of these campaigns, while efficiently managing costs and resources. This interdisciplinary approach not only enhances our understanding of how viral marketing works but also provides a framework for designing more effective marketing interventions. Ultimately, the goal of this research is to bridge the gap between epidemiological modeling and marketing, offering a new perspective on how to create and control successful viral marketing campaigns. K EYWORDS Mathematical Epidemiology, SIR Epidemiological Model, Viral Marketing, Advertisement Campaigns, Optimal Control vi Otimização de estratégias de marketing em ambientes dinâmicos: uma abordagem epidemiológica para a difusão de campanhas publicitárias R ESUMO Esta dissertação explora como os princípios da Matemática Epidemiológica, em particular o Modelo SIR, e a Teoria do Controlo Ótimo podem ser aplicados ao Marketing Viral. O principal objetivo passa por estudar a dinâmica de quatro campanhas de marketing, utilizando estas ferramentas matemáticas numa tentativa de encontrar as estratégias de disseminação mais alinhadas com o propósito de atingir o ponto mais alto do marketing, ou seja, o marketing viral. Ao tirar vantagem de conceitos tradicionalmente usados para compreender a propagação de doenças infeciosas, podemos obter resultados mais detalhados em relação à propagação das mensagens de marketing viral no mundo digital. A aplicação da Teoria do Controlo Ótimo, neste contexto, permite desenvolver estratégias que maximizam o alcance e o impacto destas campanhas, gerindo de forma eficiente os custos e os recursos associados às mesmas. Esta abordagem interdisciplinar não só aprofunda a compreensão sobre como funciona o marketing viral, como também fornece um quadro para a conceção de intervenções de marketing mais eficazes. Em última análise, o objetivo desta investigação é criar uma ponte entre a modelação epidemiológica e o marketing, oferecendo uma nova perspetiva sobre como criar e controlar campanhas de marketing viral bem sucedidas. P ALAVRAS -C HAVE Matemática Epidemiológica, Modelo Epidemiológico SIR, Marketing Viral, Campanhas Publicitárias, Controlo ótimo vii I NDEX Acknowledgments .................................................................................................................................. iii Abstract ................................................................................................................................................ v Resumo ............................................................................................................................................... vi Index ................................................................................................................................................... vii List of Figures .......................................................................................................................................... xi List of Tables .......................................................................................................................................... xii List of Listings ........................................................................................................................................ xiii List of Acronyms ..................................................................................................................................... xiv Introduction ............................................................................................................................................. 1 Objectives ............................................................................................................................................... 2 PART 1: State of the Art ……………………………………………………………………………………………………………………………...3 1 Epidemiological Models .................................................................................................................................................. 4 1.1 Introductory Remarks .................................................................................................................. 4 1.2 The SIS Model .......................................................................................................................... 4 1.2.1 Exploring infectious disease dynamics with the SIS Model ................................................................. 5 1.2.2 Modeling infectious disease dynamics: The SIS equation system ......................................................... 5 1.2.3 The SIS epidemiological model ................................................................................................ 6 1.2.4 The SIS temporal evolution .................................................................................................... 7 1.3 The SIR Model .......................................................................................................................... 7 1.3.1 Exploring infectious disease dynamics with the SIR Model ................................................................. 8 1.3.2 Modeling infectious disease dynamics: The SIR equation system ......................................................... 8 1.3.3 The SIR epidemiological model ................................................................................................ 9 1.3.4 The SIR temporal evolution .................................................................................................... 9 1.4 The SIRS Model ...................................................................................................................... 11 1.4.1 Exploring infectious disease dynamics with the SIRS Model ............................................................. 11 1.4.2 Modeling infectious disease dynamics: The SIRS equation system ..................................................... 11 1.4.3 The SIRS epidemiological model ............................................................................................ 12 1.4.4 The SIRS temporal evolution ................................................................................................. 12 1.5 Other epidemiological models ...................................................................................................... 13 2 Optimal Control Theory ................................................................................................................... 14 2.1 Introductory Remarks ................................................................................................................ 14 2.2 Formulation of the Optimal Control Problem ..................................................................................... 14 2.3 Types of Optimal Control Problems ................................................................................................ 15 2.3.1 Linear Quadratic Regulator (LQR) Problem ................................................................................ 15 2.3.2 Linear Programming (LP) in Control ........................................................................................ 15 2.3.3 Nonlinear Optimal Control ................................................................................................... 16 viii 2.3.4 Stochastic Optimal Control ................................................................................................... 16 2.3.5 Constrained Optimal Control ................................................................................................. 16 2.4 Methods for Solving Optimal Control Problems ................................................................................... 17 2.4.1 Dynamic Programming (DP) ................................................................................................. 17 2.4.2 Linear Quadratic Regulator (LQR) ........................................................................................... 17 2.4.3 Pontryagin's Maximum Principle (PMP) .................................................................................... 17 2.4.4 Kalman Filter and LQG Control .............................................................................................. 17 2.4.5 Numerical Optimization Methods ........................................................................................... 17 2.4.6 Model Predictive Control (MPC) ............................................................................................. 18 2.4.7 Model Predictive Control (MPC) ............................................................................................. 18 2.4.8 Indirect Methods .............................................................................................................. 18 2.4.9 Direct Methods ................................................................................................................ 18 2.5 Optimal Control in Engineering Applications ...................................................................................... 18 2.6 Optimal Control in Biomedical Systems ........................................................................................... 19 2.7 Optimal Control in Environmental Systems ....................................................................................... 20 2.8 Optimal Control in Marketing ....................................................................................................... 21 PART 2: Core of Dissertation…………………………………………………………………………………………….… 22 3 Viral Marketing .............................................................................................................................. 24 3.1 Introductory Remarks ................................................................................................................ 24 3.2 Types of viral marketing .............................................................................................................. 25 3.3 Advantages of viral marketing ..................................................................................................... 25 3.4 Viral marketing principles ............................................................................................................ 25 3.5 Optimal Control Problem: The specific application to viral marketing .......................................................... 27 3.5.1 Contextualization .............................................................................................................. 27 3.5.2 Objective Function ............................................................................................................ 27 3.5.3 Initial Conditions and Control Constraints .................................................................................. 28 3.5.4 Justification for Maximizing the Number of Recovered in the Marketing Context ...................................... 28 3.5.5 Justification for Maximizing the Number of Infected in the Marketing Context ......................................... 29 3.5.6 Conclusion ..................................................................................................................... 29 3.6 The Backward-Forward Sweep Algorithm .......................................................................................... 30 3.7 The fourth-order Runge-Kutta Method (RK4) ...................................................................................... 30 3.8 The research methods ............................................................................................................... 31 xv List of Acronyms OC - Optimal Control ODE - Ordinary Differential Equation PMP - Pontryagin’s Maximum Principle SIS - Susceptible-Infected-Susceptible SIR - Susceptible-Infected-Recovered SIRS - Susceptible-Infected-Recovered-Susceptible VM - Viral Marketing 1 I NTRODUCTION Traditionally, epidemiological models have been widely used to understand the dynamics of various infectious diseases [15]. However, since the spread of infections can evolve unpredictably, research has applied Optimal Control Theory in Epidemiology [15]. This approach aims to provide effective and cost-efficient strategies to detect and control the spread of viral infections within a given population [15]. At this stage, the connection between Epidemiology and Optimal Control Theory has shown to be strongly linked [1]. In his notable 2000 article, "The Mathematics of Infectious Diseases" [2], H.W. Hethcote points out that the steady rise of infectious diseases has sparked increased interest within the scientific community to study them [15]. In this context, employing mathematical models to describe and manage the spread of viral infections is crucial, despite the inherent complexity involved in creating accurate models that accurately represent the reality of the disease [15]. Focusing on control measures, it's essential to recognize that devising strategies to enhance our understanding of viral outbreaks can make a crucial difference in saving lives [15]. This is particularly important and motivating, as the urgency to both contain virus outbreaks and prevent future reinfections drives research in applying Optimal Control Theory to Epidemiology [15]. Although, the connection between these two fields has been examined beyond its traditional applications, it has been explored in various other areas as well. In the area of Viral Marketing (see, e.g., [3, 4, 5]), this connection has been increasingly explored with the aim of maximizing the spread of viral messages within a population [15]. The objective of this dissertation was to study the relationship between Optimal Control Theory and Viral Marketing, aiming to develop a comprehensive framework for applying this theory to viral marketing strategies. Practically, this work aims to identify and implement the most effective methods for maximizing the reach and impact of marketing campaigns through viral mechanisms, while also considering cost efficiency. By analyzing epidemiological models and optimal control problems, this dissertation seeks to provide concrete actions that marketing professionals can use to optimize viral marketing campaigns in real-world scenarios. This dissertation is organized as follows. Chapter 1 presents mathematical models, specifically the classical epidemiological models, namely the SIS, SIR, and SIRS models. In Chapter 2, the theory of optimal control is discussed, detailing the various problems within the domain of optimal control. Chapter 3 delves into viral marketing: the optimal control problem is formulated, the analytical methods and tools used to assess the effectiveness of the viral marketing campaigns under study are presented, along with the results, including the computational experiments obtained and the real-world actions to be applied to marketing campaigns depending on the available investment level. 2 O BJECTIVES The objectives of this dissertation are outlined as follows: • Study of epidemiological models for the modeling of viral marketing campaigns; • Collection and processing of real advertising campaign data; • Survey and discussion of control policies aiming to maximize the diffusion of viral marketing messages; • Application of control policies in formulating and solving optimal control problems using specific optimization techniques; • Analysis and comparison of the defined control policies in light of the formulated functional objectives; • Discussion and recommendation of efficient control policies. To gather and analyze data comprehensively, the investigation will utilize ViewStats, YouTube and MATLAB. This research aims to elucidate the complex dynamics of viral marketing using the specific framework of the SIR epidemiological model. Rooted in both theoretical exploration and practical application, the study seeks to enhance our comprehension of the mechanisms that govern the dissemination of marketing messages. In addition, this study endeavors to provide actionable insights for marketers seeking to leverage viral marketing strategies in an ever-evolving digital landscape. 3 Part I State of the Art 4 1 | E PIDEMIOLOGICAL M ODELS This chapter aims to provide an introduction and mathematical explanation of standard epidemiological models. These models categorize the population into distinct compartments, such as SIS (Susceptible-Infected-Susceptible), SIR (Susceptible-Infected- Recovered), and SIRS (Susceptible-Infected-Recovered-Susceptible). It assumes that there are no births, deaths, or migration phenomena occurring during the observation period, meaning the population remains constant. 1.1 Introductory Remarks In this dissertation, epidemiological models are to be viewed as dynamic systems represented by ordinary differential equations (ODEs) that depict and simulate the progression of an epidemic within a given population. According to K. Dietz [10], epidemiology can be defined in two ways: as the study of the dynamics of infectious diseases within a population or as the study of variables influencing the incidence of infectious diseases. Focusing on the first definition, infectious diseases are clinically identifiable illnesses caused by pathogenic microorganisms that can spread within a population through direct or indirect transmission [11]. Historically, despite Daniel Bernoulli's 1760 smallpox model [12], the foundational theory of Mathematical Epidemiology was primarily developed between 1900 and 1935. A significant contribution came from Kermack and McKendrick's 1927 paper, "A contribution to the mathematical theory of epidemics" [13], which introduced a deterministic model classifying individuals as susceptible, infected, or recovered. Since then, numerous models have been developed to understand infectious disease dynamics and devise control strategies, solidifying the importance of Mathematical Epidemiology. The primary challenge in this field is to create simple yet effective models to address complex research questions [14] . Continuing the line of reasoning, Mathematical Epidemiology has expanded significantly, incorporating various types of models to address different aspects of disease dynamics [6]. Stochastic models have been developed to account for the randomness inherent in disease transmission, providing a more nuanced understanding of epidemic behavior [6] . In addition to deterministic and stochastic models, agent-based models have emerged as a powerful tool in mathematical epidemiology [7]. According to [7], agent-based models offer a flexible approach to simulating complex scenarios and can provide insights into epidemic dynamics across various scales, from individual interactions to large populations. This advancement is particularly useful in contexts where social interactions and individual behavior play critical roles in disease transmission [7] . Moreover, the integration of real-time data and machine learning techniques has transformed the application of epidemiological models [8]. The use of empirical data to calibrate and adjust models enhances the accuracy of predictions and the effectiveness of control strategies [8]. Machine learning techniques, such as neural networks and optimization 5 algorithms, are employed to uncover hidden patterns and forecast epidemic trends with greater precision [8]. According to [8], combining mathematical modeling with big data analytics has improved the ability of models to predict outbreaks and assess intervention strategies more effectively. 1.2 The SIS Model The presentation of the SIS model is structured as follows: Section 1.2.1 provides a brief theoretical framework. In Section 1.2.2, the mathematical modeling underlying this epidemiological model is presented. Section 1.2.3 includes a diagram that illustrates the progression of individuals through each compartment. Finally, Section 1.2.4 provides a dynamic visualization of how the susceptible and infectious populations change over time. It is important to highlight that the explanation provided regarding the mathematical modeling presented in Section 1.2.2 follows the work of [15]. The SIS epidemiological model and the SIS temporal evolution figures were retrieved from the official website of the Institute for Disease Modeling [16]. 1.2.1 Exploring infectious disease dynamics with the SIS Model The SIS model is widely recognized as one of the most commonly employed mathematical epidemiological models for simulating epidemics [17,18,19]. In the SIS model, each individual belongs to either the susceptible set (S) or the infected set (I), as described by [20]. Some infections, as noted by [20], do not confer immunity. These infections lack a recovery state, and individuals become susceptible again after infection. The SIS model can explain this type of disease, as it reflects the cyclical dynamics of susceptible-infected-susceptible [20]. Many infectious diseases, ranging from bacterial infections like meningitis to sexually transmitted diseases such as gonorrhea and protozoan diseases like malaria and sleeping sickness, exhibit a unique characteristic: they do not provide long-lasting immunity [21]. In these cases, individuals can contract the disease multiple times throughout their lives without developing immunity [21]. This phenomenon is well explained within the framework of SIS model, where individuals transition between susceptible and infected states without a distinct recovery phase [21]. 1.2.2 Modeling infectious disease dynamics: The SIS equation system The dynamics of the SIS epidemiological model can be described by a system of Ordinary Differential Equations (ODEs). The system involves two variables: the number of susceptible individuals ( 𝑆 ) and the number of infected individuals ( 𝐼 ) at time 𝑡 . The SIS model can be mathematically represented as follows: { 𝑑𝑆(𝑡) 𝑑𝑡 = −𝛽𝑆(𝑡)𝐼(𝑡) 𝑁+ 𝛾𝐼(𝑡) 𝑑𝐼(𝑡) 𝑑𝑡 = 𝛽𝑆(𝑡)𝐼(𝑡) 𝑁− 𝛾𝐼(𝑡), 6 subject to initial conditions 𝑆(0)>0 and 𝐼(0)>0 . The parameter 𝛽 is the transmission rate, representing the rate at which susceptible individuals become infected, while the parameter 𝛾 is the recovery rate, indicating the rate at which infected individuals recover and become susceptible again. The concept of standard incidence, denoted by 𝛽𝑆(𝑡)𝐼(𝑡) 𝑁 , stems from the probability that a susceptible individual comes into contact with an infected individual, 𝐼(𝑡) 𝑁 , multiplied by the rate at which infected individuals spread the infection, 𝛽𝑆(𝑡) , per unit time 𝑡 . The term 𝛾𝐼(𝑡) represents the rate at which infected individuals recover over time 𝑡 . The total population size ( 𝑁 ) is defined by the sum of susceptible ( 𝑆 ) with infected ( 𝐼 ) individuals, given by 𝑁 = 𝑆(𝑡) + 𝐼(𝑡). 1.2.3 The SIS epidemiological model The diagram provided below illustrates the progression of individuals through each compartment in the SIS model. Figure 1 - The SIS epidemiological model. Source: https://docs.idmod.org/projects/emod-generic/en/2.20_a/model-si.html In the epidemiological model, arrows depict the flow of individuals between compartments. Susceptible individuals can transition to the infectious compartment upon contact with infectious individuals. Over time, infected individuals may recover from the disease and return to the susceptible compartment, as individuals in the SIS model do not gain permanent immunity upon recovery. 1.2.4 The SIS temporal evolution The SIS temporal evolution provides a dynamic visualization of how the susceptible and infectious populations change over time within the framework of the Susceptible-Infectious-Susceptible (SIS) model, as demonstrated by the simulation below. The X-axis represents time, and the Y-axis represents the fraction of the population in each class, indicating the proportion of individuals in different compartments of the model such as susceptible or infected. 7 Figure 2 - The SIS temporal evolution. Source: https://docs.idmod.org/projects/emod-generic/en/2.20_a/model-si.html The graph vividly illustrates the initial scenario where the susceptible population begins at a high level, gradually diminishing over time. This decline occurs as more individuals become infected, depleting the pool of susceptible individuals available for further transmission. Therefore, the rate of infection slows down, leading to a reduction in the susceptible population. Conversely, the infectious population starts from a relatively low level but steadily increases as the disease spreads within the community. Infected individuals transmit the disease to susceptible individuals, causing a surge in the number of infectious cases. All these conclusions are drawn from observing the simulation. 1.3 The SIR Model The presentation of the SIR model is organized as follows: Section 1.3.1 offers a concise theoretical overview. Section 1.3.2 delves into the mathematical framework that supports this epidemiological model. In Section 1.3.3, a diagram is provided to depict the flow of individuals through each compartment. Finally, Section 1.3.4 features a dynamic visualization illustrating the changes in the susceptible, infectious, and recovered populations over time. It's important to note that the explanation of the mathematical modeling in Section 1.3.2 is based on reference [15]. Both the SIR epidemiological model and the figures showing its temporal evolution were obtained from the official website of the Institute for Disease Modeling [16]. 1.3.1 Exploring infectious disease dynamics with the SIR Model In the SIR model analyzed by [22], the total population is partitioned into three distinct classes: susceptible, infective (or infected), and removed (or recovered). Individuals within the susceptible class have the potential to transition to the infective class through infection [22]. Similarly, individuals in the infective class have the possibility to move to the removed class either through recovery or quarantine [22]. The SIR model describes the dynamics of acute infections that provide lifelong immunity upon recovery [21]. This model is applicable to diseases where individuals gain permanent immunity, such as measles, smallpox, chickenpox, mumps, 8 typhoid fever, and diphtheria [21]. 1.3.2 Modeling infectious disease dynamics: The SIR equation system The behavior of the SIR epidemiological model can be represented by a system of Ordinary Differential Equations (ODEs). The system involves three variables: the number of susceptible individuals ( 𝑆 ) , the number of infected individuals ( 𝐼 ) and the number of recovered individuals ( 𝑅 ) at time 𝑡. The SIR model can be mathematically represented as follows: { 𝑑𝑆(𝑡) 𝑑𝑡 =−𝛽𝑆(𝑡)𝐼(𝑡) 𝑁 𝑑𝐼(𝑡) 𝑑𝑡 = 𝛽𝑆(𝑡)𝐼(𝑡) 𝑁− 𝛾𝐼(𝑡) 𝑑𝑅(𝑡) 𝑑𝑡 = 𝛾𝐼(𝑡), subject to initial conditions 𝑆(0)>0 and 𝐼(0)>0 and 𝑅(0)=0 . In the SIR model, the parameter 𝛽 represents the transmission rate, indicating the rate at which susceptible individuals become infected upon contact with infectious individuals. Meanwhile, the parameter 𝛾 signifies the recovery rate, indicating the rate at which infected individuals recover and move to the recovered class, becoming immune to further infection. In contrast to the SIS model, in the SIR model, infected individuals transition to the recovered class 𝑅 at a rate 𝛾𝐼 proportional to the number of infected individuals per unit time 𝑡 . They are unable to return to the susceptible class 𝑆 , and the total population size ( 𝑁 ) is defined by the sum of susceptible ( 𝑆 ) , infected ( 𝐼 ) , and recovered ( 𝑅 ) individuals, given by 𝑁 = 𝑆(𝑡)+ 𝐼(𝑡)+ 𝑅(𝑡) . 1.3.3 The SIR epidemiological model The diagram provided below illustrates the progression of individuals through each compartment in the SIR model. Figure 3 - The SIR epidemiological model. Source: https://docs.idmod.org/projects/emod-hiv/en/latest/model-sir.html In the epidemiological model, arrows depict the flow of individuals between compartments. Susceptible individuals can transition to the infectious compartment upon contact with infectious individuals. Infected individuals, over time, recover from 9 the disease and move to the recovered compartment. However, individuals in the recovered compartment do not return to the susceptible compartment, as they are assumed to have lifelong immunity. 1.3.4 The SIR temporal evolution The temporal evolution of the SIR model provides a dynamic visualization of how the susceptible, infected, and recovered populations change over time within the framework of the Susceptible-Infectious-Recovered (SIR) model. This simulation demonstrates the progression of the epidemic. The X-axis represents time, while the Y-axis represents the fraction of the population in each class, indicating the proportion of individuals in different compartments of the model, such as susceptible, infected or recovered. Figure 4 - The SIR temporal evolution. Source: https://docs.idmod.org/projects/emod-hiv/en/latest/model-sir.html The graph clearly depicts the initial conditions of the SIR model. It shows that the number of susceptible individuals begins high but steadily decreases over time. This decline happens as more people contract the disease, reducing the number of susceptible individuals who can potentially be infected. As a result, the infection rate diminishes, leading to a further drop in the susceptible population. In contrast, the infectious population starts off relatively small but grows as the disease spreads through the community. Infected individuals pass the disease on to those who are still susceptible, causing a rise in the number of active cases. This increase continues until the peak of the infectious population is reached. After this peak, the number of infectious cases begins to fall as individuals recover and transition into the recovered category. These observations are derived from analyzing the simulation results. 16 Linear programming problems in control involve optimizing a linear objective function subject to linear constraints [33,34]. This type of problem is used in various applications where the system's constraints and objectives are linear [33,34]. The mathematical formulation [33,34]: • Objective Function : Minimize 𝑐𝑇𝑥 • Subject to : 𝐴𝑥≤𝑏 • Decision Variables : 𝑥, which includes control variable 𝑢 as part of the vector 𝑥. 2.3.3 Nonlinear Optimal Control Nonlinear optimal control deals with systems described by nonlinear differential equations and involves optimizing a possibly nonlinear cost function [28, 35]. This type is more complex due to the nonlinearity in the system dynamics and/or cost function [28,35]. The mathematical formulation [28,35]: • System Dynamics : 𝑥󰇗(𝑡)=𝑓(𝑥(𝑡),𝑢(𝑡)) • Cost Function : 𝐽= ∫𝐿(𝑥(𝑡),𝑢(𝑡))𝑑𝑡+𝜙(𝑥(𝑇)) 𝑇 0 • Objective : Minimize 𝐽 over 𝑢(𝑡) and 𝑥(𝑡) , subject to the nonlinear dynamics. 2.3.4 Stochastic Optimal Control This type involves systems with uncertainties modeled by stochastic processes and the goal is to optimize the expected value of a cost function over a probabilistic model [36,37]. The mathematical formulation [36,37]: • System Dynamics : 𝑑𝑥(𝑡)=𝑓(𝑥(𝑡),𝑢(𝑡))𝑑𝑡+ σ (𝑥(𝑡),𝑢(𝑡))𝑑𝑊(𝑡) • Cost Function : 𝐽=𝔼 [∫𝐿(𝑥(𝑡),𝑢(𝑡))𝑑𝑡+ 𝜙(𝑥 ( 𝑇 ) )] 𝑇 0 • Objective : Minimize the expected cost 𝐽 over controls 𝑢(𝑡) . 2.3.5 Constrained Optimal Control This problem involves optimizing a cost function subject to constraints on both the states and control inputs, which can be equality or inequality constraints [28,30]. The mathematical formulation [28,30]: • System Dynamics : 𝑥󰇗(𝑡)=𝑓(𝑥(𝑡),𝑢(𝑡)) 17 • Cost Function : 𝐽= ∫𝐿(𝑥(𝑡),𝑢(𝑡))𝑑𝑡 𝑇 0 • Constraints : ℎ(𝑥(𝑡),𝑢(𝑡))=0 (𝑒𝑞𝑢𝑎𝑙𝑖𝑡𝑦) 𝑎𝑛𝑑/𝑜𝑟 𝑔(𝑥(𝑡),𝑢(𝑡))≤0 (𝑖𝑛𝑒𝑞𝑢𝑎𝑙𝑖𝑡𝑦) 2.4 Methods for Solving Optimal Control Problems In this section, based on current scientific literature, some methods for solving optimal control problems will be presented. 2.4.1 Dynamic Programming (DP) Dynamic Programming breaks down the problem into smaller, simpler subproblems and solves each one to build up the solution to the overall problem [38]. It uses the principle of optimality, which states that an optimal policy has the property that, regardless of the initial state and decisions, the remaining decisions must form an optimal policy for the remaining time [38]. 2.4.2 Linear Quadratic Regulator (LQR) LQR is used for systems with linear dynamics and quadratic cost functions [39]. It provides a solution by deriving an optimal control law that minimizes the cost over time [39]. It is highly effective for problems with linear system dynamics and quadratic costs [39]. 2.4.3 Pontryagin's Maximum Principle (PMP) Pontryagin's Maximum Principle is a method for finding the optimal control by setting up a Hamiltonian function and solving a set of optimality conditions [40]. This approach involves calculating the optimal control policy by maximizing the Hamiltonian function, which combines the system dynamics and the cost function [40]. The principle provides necessary conditions for optimality, which can be solved to determine the optimal control policy [40]. It is particularly useful for problems where the system dynamics and cost functions are nonlinear [40]. This method was crucial for the development of this master's thesis. The application of this method allowed for solving the control problem associated with viral marketing, a problem that will be discussed in the next chapter. 2.4.4 Kalman Filter and LQG Control This method combines the Linear Quadratic Regulator (LQR) with the Kalman Filter to handle systems with noise [41]. The Kalman Filter provides state estimates in the presence of noise, and LQG control uses these estimates to compute the optimal control policy [41]. 2.4.5 Numerical Optimization Methods 18 These methods involve algorithms like gradient descent, Newton's method, or other optimization techniques to iteratively find the control policy that minimizes the cost function [42]. They are useful for problems where analytical solutions are difficult to obtain, especially in nonlinear systems [42]. In addition to 2.4.3, for solving the optimal control problem presented in this master's thesis, a numerical optimization method was also applied, that is, the Runge-Kutta Method. This method will be discussed in more detail in the next chapter. 2.4.6 Model Predictive Control (MPC) MPC solves an optimization problem at each control step, using a model of the system to predict future behavior and compute the optimal control actions over a finite time horizon [43]. It adjusts the control policy at each step based on new measurements and predictions [43]. 2.4.7 Adaptive Control Adaptive Control adjusts the control parameters in real-time based on changes in the system dynamics or the environment [44]. It continuously updates the control policy to adapt to uncertainties or changes, making it suitable for systems with varying dynamics [44]. 2.4.8 Indirect Numerical Methods Indirect methods utilize Pontryagin's Maximum Principle (PMP) to address optimal control problems by determining the firstorder optimality conditions [15]. These conditions lead to the derivation of optimal trajectories by solving a multi-point boundary-value problem [15]. An example of an indirect numerical method is the Forward-Backward Sweep Method (FBS) [15]. This method is applicable to problems formulated using PMP (2.4.3) [15]. Therefore, this method was also applied to solve the optimal control problem associated with this master's thesis and will be discussed in more detail in the following chapter. 2.4.9 Direct Numerical Methods Direct methods solve optimal control problems by discretizing them with respect to time, allowing for the direct optimization of the objective functional [15]. These methods treat an optimal control problem as a nonlinear constrained optimization problem [15]. It is common to utilize nonlinear optimization software packages, often through platforms like the NEOS server, to solve these types of problems [15]. 2.5 Optimal Control in Engineering Applications In the field of aerospace engineering, the article [45] explores optimal control strategies for spacecraft rendezvous missions, 19 considering objectives such as minimizing fuel consumption or achieving the rendezvous in minimum time. It discusses mathematical formulations and algorithms used to compute optimal trajectories for spacecraft. In the field of electronic engineering, the article [46] focuses on applying linear feedback and feedforward control strategies to optimize the motion of mobile robots. It examines how these control techniques can improve the precision and efficiency of robot movements in different environments and tasks. In the field of mechanical engineering, based on the work of [47], various strategies for energy management in hybrid electric vehicles (HEVs) are explored, aiming to achieve near-optimal performance while maintaining methodological simplicity. Pontryagin's Minimum Principle (PMP) is highlighted as a viable real-time strategy, ensuring near-global optimality under reasonable assumptions. This principle facilitates instantaneous optimal control, particularly in managing battery usage through an equivalent parameter, which is shown to be globally optimal assuming specific battery characteristics. 2.6 Optimal Control in Biomedical Systems Optimal control in biomedical systems has found significant applications in various fields of medicine, including drug delivery systems, disease treatment methods, and rehabilitation technology. Controlled drug delivery systems are essential for achieving precise and effective release of active pharmaceutical ingredients to optimize therapeutic outcomes [48]. Traditional delivery methods, such as tablets and capsules, often suffer from limitations like poor bioavailability and inconsistent drug levels in plasma, which undermine treatment efficacy [48]. However, controlled drug delivery systems address these issues by regulating drug release rates and targeting specific sites, utilizing advancements that range from macro to nano-scale technologies, along with intelligent delivery systems [48]. In the realm of disease treatment, optimal control strategies have been applied to manage infectious diseases, focusing on minimizing the number of infected individuals and optimizing vaccination rates [49]. Research utilizing Pontryagin's maximum principle within the SIR compartmental model framework has developed an optimal control law that significantly reduces infection rates, by up to 50% in numerical simulations compared to constant vaccination strategies [49]. This approach is adaptable to model-free scenarios, meaning that knowledge of specific population parameters is not required, thus providing valuable insights for effective disease eradication strategies [49]. The findings highlight the crucial role of optimal control in proactive and efficient disease management, potentially informing future global vaccination efforts against diseases like COVID-19 [49]. In rehabilitation technology, optimal control and inverse optimal control are being utilized to enhance human movement analysis, therapy, and device improvement [50]. A key challenge in this area is the development of subject-specific models for both healthy and impaired individuals, which integrate skeletal multibody dynamics, neuromuscular components, and technical models [50]. Hybrid multi-phase optimal control problems in rehabilitation involve complex elements such as dynamic motion stability, and solving these efficiently requires addressing specific challenges inherent to this problem class [50]. 20 2.7 Optimal Control in Environmental Systems Optimal control plays a crucial role in environmental systems, with practical applications in areas such as air pollution management, waste management, and ecosystem management. In air pollution management, an innovative resource allocation model has been developed to maximize environmental and public health benefits in major Metropolitan Statistical Areas (MSAs) like New York, Los Angeles, Chicago, Dallas-Fort Worth, and Philadelphia [51]. By focusing on controlling emissions of sulfur dioxide (SO2) and primary carbon (PC), this model suggests that approximately 30,800 air pollution-related deaths could be avoided during a two-week summer period across these cities [51]. This highlights the importance of optimal control strategies in resource allocation for mitigating air pollution and achieving significant health improvements in urban centres [51]. In the field of waste management, an updated bioeconomic model has been used to analyze investment in waste-to-energy technology and waste treatment valorization, particularly as society transitions from fossil fuels to renewable energy sources [52]. The model incorporates technological constraints to optimize energy production processes and create sustainable business models [52]. By applying Pontryagin’s Maximum Principle and dynamic modeling, optimal control strategies are identified to maximize both economic returns and environmental benefits over a finite time period, making it a key tool for advancing sustainable waste management practices [52]. Ecosystem management is another area where optimal control theory has been applied to integrate sustainability into management practices, a challenging task due to the complexity and ambiguity of objectives in natural systems [53]. Using Fisher information as a measure, sustainability hypotheses are developed for dynamical systems, which facilitate externally enforced control schemes to meet sustainable development goals [53]. Research contrasting top-down and bottom-up control strategies in aquatic food chain models reveals that while top-down control is more aggressive, bottom-up control provides more stable and improved dynamic responses [53]. This demonstrates the critical role of optimal control in managing ecosystems effectively, balancing the need for environmental sustainability with ecosystem stability and productivity [53]. 2.8 Optimal Control in Marketing Optimal control theory has found significant applications in marketing, particularly in the areas of marketing campaigns and the spread of fake news. In the context of marketing campaigns, optimal control theory has been applied to model viral marketing using concepts from mathematical epidemiology, specifically the Susceptible-Infected-Recovered (SIR) model [9]. This approach investigates how optimal control strategies can enhance the spread of a viral advertisement while minimizing costs within a specific time frame [9]. By comparing two different optimal control strategies, the research reveals that substantial investments in publicity efforts do not always lead to higher levels of information diffusion [9]. Using real numerical data, this study contributes to the literature on viral marketing, emphasizing the importance of optimal control in maximizing both the effectiveness and efficiency of marketing campaigns [9]. 21 In terms of combating the spread of fake news, a separate study introduces an optimal control strategy to analyze the propagation of "Scam Rumors" on social networking platform [54]. These false rumors exploit users' trust and emotions for fraudulent purposes, posing risks to both individuals and organizations [54]. The model integrates the role of network informants and evaluates the costeffectiveness of various strategies aimed at stopping the dissemination of scam rumors through optimal control theory [54]. Numerical simulations are used to assess the proposed interventions, demonstrating their potential to enhance the accuracy of online content while reducing the harmful effects of misinformation [54]. This research highlights the vital role of optimal control in mitigating the spread of fake news, offering insights into effective measures for maintaining trust and security within online communities [54]. 22 Part II Core of Dissertation 23 3 | V IRAL M ARKETING In the realm of marketing, delivering a message to a specific audience can be unpredictable. This chapter delves into the concept and mechanics of Viral Marketing. It defines Viral Marketing and explores its process. Additionally, it examines the behavior of viral messages within populations using the SIR model, applied to real-world Viral Marketing campaigns. The chapter also discusses how Optimal Control Theory is integrated into mathematical models to maximize the impact of marketing messages economically across various marketing strategies. 3.1 Introductory Remarks Marketing is an essential tool for guiding and boosting an organization's performance [69], so companies frequently use marketing strategies to enhance and strengthen their brand. However, as technology has advanced, traditional marketing strategies have increasingly shown themselves to be inadequate in meeting the evolving demands of consumers [70]. Therefore, since the success of a marketing campaign largely hinges on motivating individuals to feel challenged and inspired to share the marketing message within their social networks [71], marketing professionals have been focusing on creating engaging and viral campaigns. These campaigns are designed to address the limitations of traditional marketing strategies. One such strategy is called Viral Marketing (VM), which leverages word-of-mouth to disseminate and amplify a marketing message across a wide audience [72]. As a result, VM emerges as one of the most effective strategies to address the unpredictable nature associated with typical viral marketing campaigns [73]. In contrast to many other marketing methods, VM offers a highly effective means to reach a large audience at a relatively low cost [74]. While traditional marketing heavily focuses on communicating with individual customers, VM establishes mechanisms to minimize the involvement of the original source by fostering increased information exchange among customers and consumers [75]. Furthermore, VM generates a snowball effect by spreading the message among the susceptible population, thereby increasing the number of individuals who are influenced or "infected" by it [76]. In order to address the growing competition among marketing firms, researchers and professionals in the field have been endeavoring to develop marketing campaigns that are resilient and less susceptible to imitation by competitors [77]. In this context, as the dynamics of an epidemic closely resemble those of VM, the connection between Epidemiology and Marketing has garnered growing attention from researchers, despite being a relatively recent development [78]. As a final note, it is important to highlight that the content and structure of this introductory discussion are largely informed by the work of [9,15]. 24 3.2 Types of Viral Marketing According to [64], there are essentially two different types of viral marketing: passive and active. Passive viral marketing involves promoting the brand through some form of media without making it the main focus of the content. This can be likened to adding a watermark to a viral video. Many Facebook pages use this method, leading to a large audience seeing the watermark even though the primary interest is the video's content. Active viral marketing, on the other hand, requires a call to action and participation from the audience. A prime example of this would be a social media contest where participants must like, share, or comment on a page to enter, causing it to spread rapidly. In this study, the four marketing campaigns examined fall into this category, meaning they are examples of active viral marketing campaigns. 3.3 Advantages of Viral Marketing According to [64], one of the greatest advantages of viral marketing is its cost-effectiveness compared to traditional media advertising such as television or print ads. There is no need to spend substantial amounts on airtime, printing, or distribution. The inherent design of viral marketing enables this efficiency, making it more effective than conventional advertising methods. Research indicates that millennials, who are the most active on social media, also have the least trust in traditional advertising. They are more influenced by advertisements from internet personalities they follow rather than those directly from companies. This is because millennials tend to trust their favorite online personalities more and are more willing to watch ads that support these content creators. Given that many influencers frequently have viral videos, this type of marketing is particularly pertinent to this study. Also according to [64], another potent method of leveraging virality in advertising is stealth marketing. Stealth marketing involves influencers promoting a product without disclosing that it is a paid advertisement. This can be more effective than traditional influencer marketing as it suggests the influencer genuinely likes the product, even if their promotion is financially motivated. Although this practice is often seen as unethical, it is not uncommon. Nevertheless, it is increasingly common for influencers and companies to be transparent about their promotional activities. YouTube now provides an option for influencers to include an annotation in their videos indicating "Includes paid promotion". 3.4 Viral Marketing Principles Based on [64], when engaging in different kinds of viral marketing strategies there are six essential principles that should be taken into account to achieve maximum success and effectiveness: 1. Give-aways of products or services 25 In viral marketing, one of the most powerful incentives for sharing is the promise of free products or services. When people are offered something for 'free' in exchange for simply sharing information with others, they are often quick to participate. In fact, the allure of receiving something for 'free' generates much more interest than offering a discount in a similar exchange. There doesn't even need to be a guarantee of receiving a free product; just the chance to win something for free can have a comparable effect. This type of marketing fosters a viral spread, leading to a larger audience of potential customers who will see future marketing efforts and ultimately drive sales for the company. 2. Effortless transfer to others Viral marketing campaigns succeed only when they are easy to share, similar to how a virus spreads from person to person through sneezes, coughs, and runny noses. If sharing content with one’s social network is cumbersome, it is unlikely to spread. This ease of sharing is why viral marketing thrives on the internet, where distributing content to friends and followers is just a click away. Most social media platforms feature built-in share buttons, making the process almost effortless. Given that social media users are constantly bombarded with information, resulting in short attention spans, concise and straightforward messages are the most effective. These messages are not only easy to share but also easy to consume. 3. Easy scaling from small to very large For a viral marketing campaign to be successful, the company must be prepared to handle the resulting consequences. For example, if a campaign significantly increases website traffic by 4000%, the company's servers must be capable of managing this sudden surge. A virus is ineffective if the host does not survive long enough for it to spread. Therefore, planning ahead is crucial. 4. Exploitation of common motivations and behaviour For a viral marketing campaign to reach its full potential it needs to incorporate appeal to common motivating factors such as greed, the need to be popular, loved and understood. All of these may contribute to communication between people. A company that designs their message with regard to these factors are sure to see success. 5. Utilization of existing communication networks People are inherently social, with a natural inclination to communicate and connect with others. Most individuals have a social network consisting of friends and family, which can range from a few people to hundreds, depending on their social status. The advent of social media platforms has significantly expanded the ability to maintain contact 32 3.9.1.1 Sample The data was obtained using the website ViewStats, resulting in a sample of 25 data points, each corresponding to a week of Youtube views between May 1, 2023, and October 22, 2023 (table 1). A (weekly data) 1/7 (May 2023) 8/14 (May 2023) 15/21 (May 2023) 22/28 (May 2023) 29 May / 4 June (2023) 5/11 (June 2023) 12/18 (June 2023) B (views in millions) 0 12.37 0.82 0.63 0.48 0.37 0.31 C (cumulative views in millions) 5.45 17.82 18.64 19.27 19.75 20.12 20.43 A (weekly data) 19/25 (June 2023) 26 June / 2 July (2023) 3/9 (July 2023) 10/16 (July 2023) 17/23 (July 2023) 24/30 (July 2023) 31 July / 6 August (2023) B (views in millions) 0.29 0.31 0.40 0.27 2.73 2.85 6.25 C (cumulative views in millions) 20.72 21.03 21.43 21.70 24.43 27.28 33.53 A (weekly data) 7/13 (August 2023) 14/20 (August 2023) 21/27 (August 2023) 28 August / 3 September (2023) 4/10 (September 2023) 11/17 (September 2023) B (views in millions) 2.82 0.91 1.02 0.50 0.43 0.28 C (cumulative views in million) 36.35 37.26 38.28 38.78 39.21 39.49 33 Table 1 - Weekly observations of the movie marketing campaign. 3.9.1.2 Temporal Evolution of Weekly Views The figure 7 visually illustrates the fluctuations in views over the course of the marketing campaign. The x-axis represents the weeks, while the y-axis represents the number of views, measured in millions. Figure 7 - Weekly views of the movie marketing campaign. 3.9.1.3 Sample Treatment Table 1 provides weekly observations of views (denoted as B) and cumulative views (denoted as C) for the promotional trailer from May 1, 2023, to October 22, 2023. Each row corresponds to a specific week, with "A" representing the week's date range. The "views" row (B) indicates the increase or decrease in views for each respective week, while the "cumulative views" row (C) shows the total cumulative views up to that week. To calculate these views (denoted as B), we subtracted the cumulative views at the beginning of the week (denoted as C) from the cumulative views at the end of the week. This difference gives us the number of additional views gained during that specific week, providing insights into the weekly fluctuations in viewer engagement with the promotional trailer of the movie. These observations allow us A (weekly data) 18/24 (September 2023) 25 September / 1 October (2023) 2/8 (October 2023) 9/15 (October 2023) 16/22 (October 2023) B (views in millions) 0.26 0.19 0.14 0.10 0.10 C (cumulative views in millions) 39.75 39.94 40.08 40.18 40.28 34 to track the growth in views over time and identify any significant spikes or trends in viewer engagement with the trailer. The value of cumulative views in the first week starts with half of the number of subscribers of the YouTube channel at the time of the launch of the advertising campaign. It is important to note that the viewstats website only provides cumulative views. Therefore, it was important to make this decision as this value acted as a trigger to enable an analysis of the gain and loss of the number of views over the weeks under study (in this case, data collection is carried out on a weekly basis). Analyzing the data, it was found that it presents two peaks. The first and largest peak occurred between May 1, 2023, and Jun e 1, 2023, which includes the day the trailer of the movie premiered on the official Warner Bros. YouTube channel (May 8, 2023). The second peak occurred between July 16, 2023, and September 3, 2023, with this period containing the day the movie was officially released in the market (August 4, 2023). 3.9.1.4 Meaning of being Infected In the context of the viral marketing campaign for "Meg 2: The Trench – Official Trailer", being "infected" refers to the rapid and extensive dissemination of the trailer and its associated content across various online platforms, particularly YouTube. When the trailer "infects" the internet, it means that it attracts significant attention and is widely shared by users, achieving viral status. This concept draws a parallel to how viruses spread from person to person, emphasizing the exponential growth in reach and engagement. A successful campaign for the "Meg 2: The Trench" trailer results in high visibility and interaction, with the trailer receiving numerous likes, comments, and shares, indicating strong viewer interest and engagement. The dissemination extends beyond YouTube to other platforms such as X, Facebook, Instagram, and TikTok, where users continue to share and discuss the trailer. This leads to the emergence of memes, reaction videos, and fan-created content, further expanding the trailer's reach. The widespread sharing and engagement with the trailer lead to increased brand awareness for the movie, making it a trending topic and creating anticipation and excitement for its release. To ensure the "Meg 2: The Trench" trailer becomes "infected," the marketing team can employ various strategies, such as releasing teaser clips and countdowns to build anticipation, partnering with influencers and YouTube personalities to promote the trailer, and creating visually captivating content filled with thrilling moments to entice viewers to share. Additionally, hashtag campaigns and interactive challenges can facilitate user participation and content creation. Interactive elements like polls, quizzes, or augmented reality experiences can engage users and encourage sharing. Targeted ads on social media platforms can reach the intended audience, while retargeting strategies can remind users who have shown interest in similar content. By effectively executing these strategies, the marketing team can maximize the chances of the trailer becoming viral, achieving widespread visibility, significant engagement, and ultimately, a successful promotional campaign for the movie. 3.9.1.5 Total Population Covered For the execution of the project, it was necessary to estimate the parameter 𝑁 , which corresponds to the total population that may 35 eventually view, within YouTube, the movie trailer (after its release). Given that we are dealing with a mass industry, the value of 𝑁 would have to be in the order of millions. Since the views are only achieved via YouTube, only in the YouTube environment, the value of 𝑁 was estimated at 100 million (individuals). This value of 𝑁 was decided upon given that, being a sensitive parameter, its value cannot be exaggerated. It must have a value that is coherent and effectively able to determine with greater precision the maximum audience that can be reached. After several attempts to determine the value of 𝑁 , this was the value that allowed for the best modeling between the SIR model and the real campaign data, enabling the creation of a sinusoidal curve. In relation to the population of infected individuals at the beginning of the campaign, the value of 5.45 million (individuals) was assigned. This value corresponds to half the number of subscribers to the Warner Bros. YouTube channel at the time of the trailer launch 3 . It was decided to attribute half the value of the subscribers to ensure greater coherence in the analysis. At the time of the trailer launch, it is not guaranteed that all subscribers will immediately view it. Therefore, half the subscriber count is a much more likely value to be reached. In this case, the subscribers represent individuals who are more likely to engage with the trailer quickly. Therefore, the concept of "infected" was attributed to the subscribers. Thus, the value of the susceptible population would be the difference between 𝑁 and 𝐼 , that is, 𝑆=𝑁−𝐼 (in millions). 3.9.1.6 Initial Conditions The first code to be implemented, developed in MATLAB environment, aims to obtain the optimal parameters for gamma and beta. The beta parameter relates to the transmission rate, and the gamma parameter relates to the recovery rate. This code enabled the obtaining of the results presented in section 3.9.1.8 and can be consulted in the appendix 1. A succinct overview of the general structure of the code: • Initialization and data configuration : The code begins by defining the data format as well as the arrays containing the temporal observation period in weeks (tdata) and the observed data, in millions of views, corresponding to this temporal observation period (qdata); • Definition of the SIR Model Equations : The differential equations of the model are defined in the function model_1. It describes changes in susceptible individuals, y(1), and infected individuals, y(2), over time. The variable 𝑅(𝑡) (representing the recovered individuals) was omitted at this stage since 𝑁 is constant. • Error determination : The moder function calculates the error related with the observed data by solving the differential equations (ode23s); • Optimization Process : The main function (MovieMarketingCampaign) starts by defining the initial values, configured by the user, of the gamma, or a, and beta, or b, parameters and calculates the error with these initial parameters. Then, it uses the fminsearch function to optimize the a and b parameters, minimizing the error calculated by the 3 https://www.viewstats.com/@warnerbrospictures/channelytics 36 moder function. The optimized (final) parameters and the minimized error will be displayed; • Graphical display : The code generates plots to visualize the fit of the SIR model to the data, using the initial parameters and the optimal parameters. The initial conditions for the population of susceptible and infected individuals are defined in the ode23s resolution function. The initial conditions are [(100 – 0.27), 0.27], implying that at the beginning there were 0.27 (millions) individuals infected. For the analysis of this campaign, the second peak was selected, with 0.27 corresponding to the first value of the sample associated with the second peak. The MATLAB code mandates an initial value, which can never be zero. Through an iterative process, the code adjusts the a and b parameters of the SIR model in order to find the best parameters that describe the spread of the views, similar to the flu, over time. 3.9.1.7 Meaning of Optimal Control In the context of marketing, "optimal control" refers to the strategic management and coordination of marketing activities to achieve the most favorable outcomes, such as maximizing brand awareness, increasing sales, and enhancing customer engagement. It involves carefully analyzing market data, consumer behavior, and competitive landscape to develop tailored marketing strategies that efficiently allocate resources and deliver the greatest return on investment. Specifically for a marketing campaign, such as launching a trailer on YouTube to promote a movie, optimal control entails meticulous planning and execution to ensure the trailer reaches the widest and most receptive audience possible. This includes selecting the optimal timing and platform for the trailer release, crafting compelling content that captivates viewers and generates excitement, leveraging targeted advertising and promotional tactics to amplify reach and engagement, and continuously monitoring and adjusting the campaign based on performance metrics to optimize results. In the context of optimal control in marketing, the variable 𝑢 represents the control inputs or actions taken by marketers to influence the outcomes of their campaigns. These control inputs could include decisions related to budget allocation, advertising channels, messaging strategies, timing of promotions, and other marketing tactics. For example, in the context of launching a trailer on YouTube to promote a movie, the variable 𝑢 could represent decisions such as the amount of budget allocated to YouTube advertising, the timing and frequency of ad placements, the targeting criteria used to reach specific audience segments, and the creative elements of the trailer itself. By carefully adjusting and optimizing these control inputs, marketers aim to maximize the effectiveness and efficiency of their campaigns, ultimately driving greater engagement, visibility, and ultimately, ticket sales for the film. The optimal control approach involves continuously evaluating and refining these inputs based on real-time data and performance metrics to ensure that resources are allocated in a way that maximizes the return on investment and achieves the desired marketing objectives. 37 3.9.1.8 Computational Tests - Parameters of the SIR Model To identify the optimal parameters, gamma and beta, of the SIR model, the MATLAB code described in section 3.9.1.6 was applied. This marketing campaign had two peaks, with the first peak reaching the highest number of views. However, as already mentioned, the second peak was chosen for the investigation of this campaign. This choice was made because the second peak had the highest number of observations, allowing for the collection of a more compact sample. As a result, the SIR model can be more reliable. In Figure 8, we can observe eight weekly observations obtained during the monitoring of the advertising campaign by Warner Bros. Pictures, corresponding to the second peak recorded. Figure 8 - Weekly views corresponding to the second peak of the movie marketing campaign. The output of the code provides information about the optimization of the SIR model parameters and the quality of the fit to the observed data. Let's analyze the results: • Initial parameter values (k) : The initial parameter values were set as a = 10 and b = 0.1. • Value of the objective function with initial parameters (aux) : The objective function, which is the sum of squared errors (SSE) between the observed data and the model predictions using the initial parameters, resulted in approximately 61.114995905805507. • Final parameter values after optimization : After optimization, the final parameter values were adjusted to a = 3.482369778802087 and b = 0.050434425558240. • Value of the objective function after optimization (fval) : After optimization, the objective function (SSE) decreased to approximately 4.722297256959857. 38 • Improvement in the objective function : The improvement in the objective function is calculated by subtracting the objective function value with the optimized parameters (fval) from the objective function value with the initial parameters (aux). In this case, the improvement was 56.392698648845652. In summary, the model parameters were optimized to better fit the observed data, resulting in a significant reduction in the objective function (SSE) and a substantial improvement in the model's fit to the data. The optimal parameters obtained were a = 3.482370 (gamma - recovery rate) and b = 0.050434 (beta - transmission rate). Figure 9 displays the fitting of the SIR model to this data. Figure 9 - Fitting the model to the data of the Warner Bros. Pictures marketing campaign. 3.9.1.9 Computational Tests - u Control Once the optimal parameters for the SIR model were obtained, three experiments were executed. To apply optimal control to the viral marketing campaign under study, different values of 𝑏 were tested, where the variable 𝑏 represents the weight associated with control. It is worth mentioning that the values of 𝑏 are arbitrary and have no practical significance. In other words, they were set solely to test the model's behavior with different values of 𝑏 . The code, developed in MATLAB environment that made this analysis possible, can be consulted in the appendix 2. Hence, three weights ( 𝑏 = 0.1, 10, 100) associated with the control parameter 𝑏 were evaluated to assess the impact of propagation cost on the marketing campaign. Figures 10, 11, and 12 demonstrate the implementation of the control and illustrate how the model evolves for these values of 𝑏 . On the left side, the SIR model is displayed. On the right side, the optimal control function 𝑢(𝑡) is presented. 39 Figure 10 - With control for b = 0.1 (Movie Campaign). Figure 11 - With control for b = 10 (Movie Campaign). Figure 12 - With control for b = 100 (Movie Campaign). In the context of a marketing campaign, the parameter 𝑏 dictates the level of investment and intensity of control efforts over time. The following explanation can be given: • Figure 10 | Low Cost Scenario : This scenario represents a situation with a low cost associated with the YouTube marketing campaign. With 𝑏 set at 0.1, the campaign can afford continuous and intense investment in control efforts throughout the entire campaign period of eight weeks. This sustained investment ensures high visibility and engagement with the target audience. Consequently, this scenario yields the highest number of "infected" 40 individuals, referring to the extent of the campaign's reach and influence. This can be verified using the SIR (Susceptible-Infected-Recovered) model, which demonstrates how the low cost facilitates ongoing efforts to spread the campaign message effectively and widely; • Figure 11 | Moderate Cost Scenario : Here, 𝑏 is set to 10, representing a moderate cost for the YouTube marketing campaign. The investment level in this scenario is lower than in the 𝑏 = 0.1 scenario. Initially, the campaign maintains a moderate level of control efforts, balancing investment and visibility. However, as the campaign progresses, there is a noticeable decrease in control efforts starting from the sixth week. This decline reflects budget constraints, where the initial moderate investment is not sustainable over the entire period. The result is a reduction in the intensity and effectiveness of the campaign towards the later stages, impacting the overall reach and engagement; • Figure 12 | High Cost Scenario : In this scenario, 𝑏 is set to 100, indicating a high cost associated with the YouTube marketing campaign. The significant investment required limits the overall budget, leading to a conservative and adaptive approach over time. Control efforts start at a low level and sharply decrease after the sixth week due to stringent budget allocations. This reduction in control efforts results in a more cautious campaign, unable to maintain high visibility and engagement throughout the period. Consequently, this scenario presents the lowest number of "infected" individuals, as confirmed by the SIR model. The high cost restricts the campaign's ability to sustain widespread influence, limiting its reach and impact. Given the existing budget constraints, the marketing team must take a set of concrete actions to sell the company's product and strive for their marketing campaign to achieve the widest possible reach. Therefore, the question that arises is, "What should the response be?" A set of actions will be presented for each of the scenarios as an attempt to address the challenges posed by each. In relation to 𝑏 = 0.1, over eight weeks, concrete actions in this scenario include: • Daily Ad Placements : Implementing daily advertisements across YouTube and other relevant platforms (Instagram and TikTok) to maintain continuous visibility. These ads could include pre-roll placements on popular videos and strategically placed banners; • Daily Engagement Campaigns : Launching interactive content daily, such as behind-the- scenes videos, interviews with the cast and crew, and polls to engage viewers actively. Encouraging audience participation through likes, comments, and shares boosts engagement metrics; • Influencer Collaborations : Engaging with influencers on a regular basis for sustained promotion. This involves influencers creating content like vlogs, challenge videos related to the movie, or live streams discussing various aspects of the film; 41 • Frequent Teasers and Clips : Releasing new teasers, trailers, and exclusive clips on a regular basis to maintain audience interest and anticipation. These snippets could highlight key scenes, introduce characters, or showcase special effects; • Fan Interaction Initiatives : Initiating fan-driven activities such as contests for fan art, fan-made trailers, or themed challenges related to the movie. Highlighting and featuring the best entries on official channels encourages community engagement and content sharing. In relation to 𝑏 = 10, over six weeks, concrete actions in this scenario include: • Peak Time Ad Placements : Running ads during peak times, such as evenings and weekends, and around major events or holidays to maximize impact while controlling costs; • Targeted Campaigns : Focusing on specific audience segments with personalized content. For example, creating different ads for different demographics, such as action fans, family audiences, or fans of the actors; • Timed Content Releases : Scheduling content releases to coincide with major movie-related events, like comic conventions, film festivals, or actor interviews; • Influencer Collaborations : Engaging influencers for short, impactful bursts rather than continuous promotions. Influencers could create review videos, reaction videos to trailers, or themed challenges; • Themed Weeks : Organizing themed weeks where specific aspects of the movie are highlighted. For example, one week could focus on the special effects with behind-the-scenes looks, and another on the storyline with deep dives into the plot and characters. In relation to 𝑏 = 100, over six weeks, concrete actions in this scenario include: • Selective Ad Placements : Running highly targeted ads in specific niches, such as movie review channels, channels of similar genres, and channels with a high engagement rate among the target audience; • Content Optimization : Investing in high-quality, shareable content that can generate organic reach without continuous spending. This includes well-produced trailers, exclusive sneak peeks, and high-impact visuals; • Key Influencer Partnerships : Partnering with top influencers for high-impact moments rather than ongoing promotions. These influencers could create high-quality content such as in-depth reviews, behind-the-scenes looks, or exclusive interviews with the cast and crew; • Budget Reallocation : Adjusting the budget dynamically based on performance metrics to optimize spending. For instance, increasing spend on ads that show higher engagement rates and reducing spend on less effective ads; • Major Event Releases : Timing major content releases with high-visibility events like the premiere, cast interviews, or participation in online film festivals, to maximize reach without sustained high spending. 48 • Improvement in the objective function : The improvement in the objective function is calculated by subtracting the objective function value with the optimized parameters (fval) from the objective function value with the initial parameters (aux). In this case, the improvement was 6.771714630234474. In summary, the model parameters were optimized to better fit the observed data, resulting in a significant reduction in the objective function (SSE) and a substantial improvement in the model's fit to the data. The optimal parameters obtained were a = 6.315770 (gamma - recovery rate) and b = 0.077759 (beta - transmission rate). Figure 15 displays the fitting of the SIR model to this data. Figure 15 - Fitting the model to the data of the Calvin Klein marketing campaign. 3.9.2.9 Computational Tests - u Control After determining the optimal parameters for the SIR model, three experiments were conducted. To apply optimal control to the viral marketing campaign under investigation, different values of the variable 𝑏 were tested. The variable 𝑏 represents the weight associated with the control, and it is important to clarify that these values are arbitrary and have no practical significance. They were chosen solely to observe how the model behaves under varying 𝑏 values. The MATLAB code used for this analysis is provided in Appendix 4. In these experiments, three different weights ( 𝑏 = 0.1, 10, 100) were assessed to understand how the propagation cost affects the marketing campaign. Figures 16, 17, and 18 show the results of applying control to the model. On the left side of each figure, the evolution of the SIR model is depicted, while on the right side, the corresponding optimal control function 𝑢(𝑡) is presented. 49 Figure 16 - With control for b = 0.1 (Fashion Campaign). Figure 17 - With control for b = 10 (Fashion Campaign). Figure 18 - With control for b = 100 (Fashion Campaign). In the context of a marketing campaign, the parameter 𝑏 dictates the level of investment and intensity of control efforts over time. The following explanation can be given: • Figure 16 | Low Cost Scenario : This scenario depicts a YouTube marketing campaign with low associated costs, allowing for sustained and intensive investment in control efforts throughout an eight-week period. This continuous investment ensures high visibility and engagement with the target audience, leading to the maximum number of "infected" individuals according to the SIR model; 50 • Figure 17 | Moderate Cost Scenario : Here, 𝑏 is set at 10, indicating a moderate cost for the YouTube marketing campaign. Initially, there is a balanced level of investment in control efforts, maintaining reasonable visibility and engagement. However, as the campaign progresses, budget constraints become evident, resulting in a gradual decrease in investment starting from the sixth week. This reduction compromises the campaign's effectiveness and diminishes its reach, impacting the number of "infected" individuals compared to the low-cost scenario; • Figure 18 | High Cost Scenario : In this scenario, 𝑏 is set to 100, signifying a high cost associated with the YouTube marketing campaign. The substantial investment required imposes strict budget limitations, leading to conservative control efforts. Starting at a low level, these efforts decrease sharply after the sixth week due to budget constraints, resulting in reduced visibility and engagement. Consequently, this scenario records the lowest number of "infected" individuals according to the SIR model, highlighting the campaign's limited reach and impact under stringent financial constraints. Given the current budget limitations, the marketing team needs to strategize concrete actions to effectively promote the company's product and maximize the campaign's reach. The question at hand is: "What actions should be taken?" Here are proposed actions tailored to each scenario to tackle the respective challenges. For 𝑏 = 0.1, over eight weeks, the following actions may be applied: • Daily Ad Campaigns: Implement daily ad placements across YouTube and relevant platform (Instagram and TikTok) to maintain continuous visibility. • Interactive Content Strategy: Launch daily engaging content such as behind-the-scenes videos, cast interviews, and interactive polls to foster viewer participation. • Influencer Engagement: Collaborate consistently with influencers for ongoing promotion, encouraging them to create content like vlogs and challenge videos. • Regular Teasers and Exclusives: Release frequent teasers, trailers, and exclusive clips to sustain audience interest and anticipation. • Fan Community Initiatives: Initiate fan-driven activities like contests and challenges related to the product, highlighting user-generated content on official channels. For 𝑏 = 10 , over six weeks, the following actions may be applied: • Optimized Ad Timing: Place ads during peak viewing times and around key events to maximize impact while controlling costs. 51 • Targeted Audience Campaigns: Develop personalized campaigns for specific demographics such as genre enthusiasts or product aficionados. • Scheduled Content Releases: Time content launches to coincide with industry events, movie premieres, or relevant holidays. • Strategic Influencer Partnerships: Collaborate with influencers for focused promotional periods, leveraging their reach through reviews and themed content. • Thematic Marketing Weeks: Organize themed promotional weeks highlighting different aspects of the product, enhancing engagement through varied content approaches. For 𝑏 = 100 , over six weeks, the following actions may be applied: • Precise Ad Placement Strategy: Focus ads on niche platforms and high-engagement channels within the target market. • Premium Content Production: Invest in high-quality content such as polished trailers, exclusive previews, and visually impactful campaigns. • Top-tier Influencer Collaborations: Partner with top influencers for impactful content releases, leveraging their credibility and reach for maximum impact. • Dynamic Budget Allocation: Adjust spending dynamically based on campaign performance metrics to optimize effectiveness. • Strategic Event Integration: Align major content releases with prestigious events, leveraging their visibility and audience engagement opportunities. 3.9.3 Case Study 3: Introducing Apple Vision Pro Apple Vision Pro is a mixed-reality headset developed by Apple [58]. It was announced on June 5, 2023, at Apple's Worldwide Developers Conference, and pre-orders began on January 19, 2024 [58]. It became available for purchase on February 2, 2024, in the United States [58]. A worldwide launch has yet to be scheduled [58]. Apple Vision Pro is Apple's first new major product category since the release of the Apple Watch in 2015 [58]. Apple markets Apple Vision Pro as a "spatial computer" where digital media is integrated with the real world [58]. Physical inputs—such as motion gestures, eye tracking, and speech recognition—can be used to interact with the system [58]. With the objective of implementing the SIR model, the view data from YouTube concerning the promotional campaign of the electronic 52 device "Introducing Apple Vision Pro" was chosen for analysis. This campaign was launched on the official Apple YouTube channel 7 . The release of the trailer on YouTube aimed to capture a broad audience, ignite anticipation, and draw attention to the device. Premiering on 5/06/2023, the trailer served as a pivotal marketing tool to bolster pre-orders and generate hype surrounding the device's release. The target audience specifically within YouTube for the promotional campaign of "Introducing Apple Vision Pro" would comprise users who actively engage with technology-related content on the platform. This may include individuals interested in innovative electronic devices, enthusiasts of Apple products, subscribers of the Apple YouTube channel, and viewers who regularly watch trailers and promotional material for new tech gadgets. As of May 11, 2024, the promotional campaign for this eletronic device had accumulated a total of 62.8 million views, along with 487K likes. On average, it was receiving around 7.68K views per hour 8 . 3.9.3.1 Sample The data was obtained using the website ViewStats, resulting in a sample of 20 data points, each corresponding to a week of Youtube views between May 29, 2023, and October 15, 2023 (table 3). 7 https://www.youtube.com/watch?v=TX9qSaGXFyg9 8 https://www.viewstats.com/@apple/videos/TX9qSaGXFyg A (weekly data) 29 May / 4 June (2023) 5/11 (June 2023) 12/18 (June 2023) 19/25 (June 2023) 26 June (2023) / 2 July (2023) 3/9 (July 2023) 10/16 (July 2023) B (views in millions) 0 24.76 9.04 0.78 0.62 0.74 0.34 C (cumulative views in millions) 8.60 33.36 42.40 43.18 43.80 44.54 44.88 A (weekly data) 17/23 (July 2023) 24/30 (July 2023) 31 July (2023) / 6 August (2023) 7/13 (August 2023) 14/20 (August 2023) 21/27 (August 2023) 28 August (2023) / 3 September (2023) B (views in millions) 0.32 0.22 0.18 0.13 0.14 0.14 0.13 C (cumulative views in millions) 45.20 45.42 45.60 45.73 45.87 46.01 46.14 53 Table 3 - Weekly observations of the electronic device marketing campaign. 3.9.3.2 Temporal Evolution of Weekly Views The figure 19 illustrates the fluctuations in views over the course of the marketing campaign. The x-axis represents the weeks, while the y-axis represents the number of views, measured in millions. Figure 19 - Weekly views of the electronic device marketing campaign. 3.9.3.3 Sample Treatment Table 3 provides weekly observations of views (denoted as B) and cumulative views (denoted as C) for the promotional campaign from May 29, 2023, to October 15, 2023. The reasoning used in the previous sections, in 3.9.1.3 and 3.9.2.3, regarding the calculation of views, has been applied here as well. Additionally, all the considerations discussed in 3.9.1.3 and 3.9.2.3 are equally relevant and have been taken into account in this topic. The value of cumulative views in the first week starts with half of the number of subscribers of the YouTube channel at the time of the launch of the advertising campaign. Upon analyzing the data, it was identified that a singular peak in viewership occurred between May 29, 2023, and July 23, 2023, spanning 8 weeks. The highest number of views was recorded during week 2, specifically between June 5 and June 11, 2023. This week 2 precisely includes the day the promotional campaign for the "Apple Vision Pro" premiered on the official Apple YouTube channel (June 5, 2023). A (weekly data) 4/10 (September 2023) 11/17 (September 2023) 18/24 (September 2023) 25 September (2023) / 1 October (2023) 2/8 (October 2023) 9/15 (October 2023) B (views in millions ) 0.14 0.42 0.19 0.16 0.12 0.10 C (cumul ative views in millions ) 46.28 46.70 46.89 47.05 47.17 47.27 54 3.9.3.4 Meaning of being Infected In the context of YouTube promotional campaigns, particularly for Apple's Vision Pro product, being "infected" refers to the level of engagement and interest that users demonstrate towards the campaign content. When a user is labeled as "infected," it signifies that they have interacted meaningfully with the promotional material and have been influenced or impacted by it in some way. This engagement can take various forms. Firstly, "infected" users are those who have actively watched the promotional video, indicating a genuine interest in the product being showcased. Beyond passive viewing, these users may also share the video within their social networks, amplifying its reach and potentially influencing others' perceptions. Moreover, leaving comments on the video— whether positive or negative—represents another level of engagement. Comments not only provide direct feedback to Apple but also foster community interaction among viewers, enhancing the campaign's visibility and impact. Additionally, "infected" users may take actionable steps such as clicking on links provided in the video description for more information, visiting the product's website, or even proceeding to pre-order the product. These actions demonstrate a deeper level of interest and intention to engage further with the product beyond just watching the promotional video. The concept of being "infected" also implies a lasting impact on users' perception or behavior. It suggests that the campaign has successfully resonated with viewers, potentially influencing their future decisions or continuing interest in updates related to the product. Overall, being "infected" serves as a measure of the campaign's effectiveness in engaging its audience on YouTube. It not only reflects the reach of the promotional content but also its ability to generate meaningful interactions, influence viewer behavior, and ultimately contribute to Apple's marketing goals for the Vision Pro product. 3.9.3.5 Total Population Covered For this study, estimating parameter 𝑁 was crucial, representing the potential total viewership on YouTube for the device trailer postrelease. Given the industry's scale, 𝑁 was estimated at 172 million (individuals), considering views are exclusively garnered on YouTube. This value is carefully chosen to accurately determine the maximum potential audience without overestimation. After several attempts to determine the value of 𝑁 , this was the value that allowed for the best modeling between the SIR model and the real campaign data, enabling the creation of a sinusoidal curve. Regarding the initial "infected" population at the campaign's start, it was set at 8.6 million (individuals). This figure equals half the number of subscribers to the Apple YouTube channel when the trailer launched. This choice ensures analytical coherence since not all subscribers immediately view the trailer upon release. These subscribers are considered likely to engage promptly, hence classified as "infected." Consequently, the susceptible population is calculated as the difference between 𝑁 and 𝐼 , specifically 𝑆=𝑁−𝐼 (in millions). This approach delineates the population not initially engaged but potentially open to the trailer's influence over time, facilitating a 55 comprehensive analysis of audience reach and engagement dynamics. 3.9.3.6 Initial Conditions The first code to be implemented, developed in MATLAB environment, aims to obtain the optimal parameters for gamma and beta. The beta parameter relates to the transmission rate, and the gamma parameter relates to the recovery rate. This code enabled the obtaining of the results presented in section 3.6.3.8 and can be consulted in the appendix 5. A succinct overview of the general structure of the code: • Initialization and data configuration : The code begins by defining the data format as well as the arrays containing the temporal observation period in weeks (tdata) and the observed data, in millions of views, corresponding to this temporal observation period (qdata); • Definition of the SIR Model Equations : The differential equations of the model are defined in the function model_1. It describes changes in susceptible individuals, y(1), and infected individuals, y(2), over time. The variable 𝑅(𝑡) (representing the recovered individuals) was omitted at this stage since 𝑁 is constant. • Error determination : The moder function calculates the error related with the observed data by solving the differential equations (ode23s); • Optimization Process : The main function (ElectronicDeviceMarketingCampaign) starts by defining the initial values, configured by the user, of the gamma, or a, and beta, or b, parameters and calculates the error with these initial parameters. Then, it uses the fminsearch function to optimize the a and b parameters, minimizing the error calculated by the moder function. The optimized (final) parameters and the minimized error will be displayed; • Graphical display : The code generates plots to visualize the fit of the SIR model to the data, using the initial parameters and the optimal parameters. The initial conditions for the population of susceptible and infected individuals are defined in the ode23s resolution function. The initial conditions are [(172 – 8.60), 8.60], implying that at the beginning there were 8.60 (millions) individuals infected (this value equals half the number of subscribers to the Apple YouTube channel when the trailer launched). The MATLAB code mandates an initial value, which can never be zero. Through an iterative process, the code adjusts the a and b parameters of the SIR model in order to find the best parameters that describe the spread of the views, similar to the flu, over time. 3.9.3.7 Meaning of Optimal Control In the context of launching a promotional campaign on YouTube, specifically through Apple's channel, to promote the Apple Vision Pro product, "optimal control" refers to the marketing team's ability to effectively manage and influence the flow of views, engagement, 56 and interest generated around the content. This entails employing carefully planned strategies to maximize the impact of the promotional video, including scheduling releases at strategic times, targeting specific audience demographics, optimizing keywords and tags for improved video discovery, and actively engaging with viewers and the tech community. The variable 𝑢 in this scenario could represent a dynamic factor in optimal control, such as the frequency of video releases, the intensity of the promotional efforts, or the allocation of marketing resources across different platforms and outreach strategies. Consequently, the practical significance of the variable 𝑢 lies in its direct influence on the success of the product's marketing campaign. It allows the marketing team to adapt and optimize their strategies to achieve the best possible outcomes in terms of views, engagement, and audience interest, thereby maximizing the promotion of the Apple Vision Pro product on YouTube. 3.9.3.8 Computational Tests - Parameters of the SIR Model To identify the optimal parameters gamma and beta of the SIR model, the MATLAB code described in Section 3.9.3.6 was utilized. This marketing campaign exhibited only one peak, and thus this singular peak was selected for the study. The study was conducted based on eight temporal observations (weekly). In Figure 20, we can observe eight weekly observations obtained during the monitoring of the advertising campaign by Apple, corresponding to the only peak recorded. Figure 20 - Weekly views corresponding to the only peak of the electronic device marketing campaign. 57 The output of the code provides information about the optimization of the SIR model parameters and the quality of the fit to the observed data. Let's analyze the results: • Initial parameter values (k) : The initial parameter values were set as a = 10 and b = 0.1. • Value of the objective function with initial parameters (aux) : The objective function, which is the sum of squared errors (SSE) between the observed data and the model predictions using the initial parameters, resulted in approximately 6.268381307608187e+02. • Final parameter values after optimization : After optimization, the final parameter values were adjusted to a = 3.137420297332799 and b = 0.032803651520307. • Value of the objective function after optimization (fval) : After optimization, the objective function (SSE) decreased to approximately 1.706700300014939. • Improvement in the objective function : The improvement in the objective function is calculated by subtracting the objective function value with the optimized parameters (fval) from the objective function value with the initial parameters (aux). In this case, the improvement was 6.251314304608037e+02. In summary, the model parameters were optimized to better fit the observed data, resulting in a significant reduction in the objective function (SSE) and a substantial improvement in the model's fit to the data. The optimal parameters obtained were a = 3.137420 (gamma - recovery rate) and b = 0.032804 (beta - transmission rate). Figure 21 displays the fitting of the SIR model to this data. Figure 21 - Fitting the model to the data of the Apple marketing campaign. 64 would have to be in the order of millions. Since the views are only achieved via YouTube, only in the YouTube environment, the value of 𝑁 was estimated at 172 million (individuals). This value of 𝑁 was decided upon given that, being a sensitive parameter, its value cannot be exaggerated. It must have a value that is coherent and effectively able to determine with greater precision the maximum audience that can be reached. After several attempts to determine the value of 𝑁 , this was the value that allowed for the best modeling between the SIR model and the real campaign data, enabling the creation of a sinusoidal curve. In relation to the population of infected individuals at the beginning of the campaign, the value of 1.49 million (individuals) was assigned. This value corresponds to half the number of subscribers to the DIOR YouTube channel at the time of the trailer launch 11 . It was decided to attribute half the value of the subscribers to ensure greater coherence in the analysis. At the time of the trailer launch, it is not guaranteed that all subscribers will immediately view it. Therefore, half the subscriber count is a much more likely value to be reached. In this case, the subscribers represent individuals who are more likely to engage with the trailer quickly. Therefore, the concept of "infected" was attributed to the subscribers. Thus, the value of the susceptible population would be the difference between 𝑁 and 𝐼 , that is, 𝑆=𝑁−𝐼 (in millions). 3.9.4.6 Initial Conditions The first code to be implemented, developed in MATLAB environment, aims to obtain the optimal parameters for gamma and beta. The beta parameter relates to the transmission rate, and the gamma parameter relates to the recovery rate. This code enabled the obtaining of the results presented in section 3.6.4.8 and can be consulted in the appendix 7. A succinct overview of the general structure of the code: • Initialization and data configuration : The code begins by defining the data format as well as the arrays containing the temporal observation period in weeks (tdata) and the observed data, in millions of views, corresponding to this temporal observation period (qdata); • Definition of the SIR Model Equations : The differential equations of the model are defined in the function model_1. It describes changes in susceptible individuals, y(1), and infected individuals, y(2), over time. The variable 𝑅(𝑡) (representing the recovered individuals) was omitted at this stage since N is constant; • Error determination : The moder function calculates the error related with the observed data by solving the differential equations (ode23s); • Optimization Process : The main function (PerfumeMarketingCampaign) starts by defining the initial values, configured by the user, of the gamma, or a, and beta, or b, parameters and calculates the error with these initial parameters. Then, it 11 https://www.viewstats.com/@dior/channelytics 65 uses the fminsearch function to optimize the a and b parameters, minimizing the error calculated by the moder function. The optimized (final) parameters and the minimized error will be displayed; • Graphical display : The code generates plots to visualize the fit of the SIR model to the data, using the initial parameters and the optimal parameters. The initial conditions for the population of susceptible and infected individuals are defined in the ode23s resolution function. The initial conditions are [(172 – 0.54), 0.54], implying that at the beginning there were 0.54 (millions) individuals infected. For the analysis of this campaign, the second peak was selected, with 0.54 corresponding to the first value of the sample associated with the second peak. Through an iterative process, the code adjusts the a and b parameters of the SIR model in order to find the best parameters that describe the spread of the views, similar to the flu, over time. 3.9.4.7 Meaning of Optimal Control Based on the provided text, the concept of "optimal control" in the context of launching a promotional campaign on YouTube for Dior's L'Or perfume refers to the marketing team's ability to efficiently manage and influence various aspects of the campaign to maximize its effectiveness. This includes strategies to control and enhance factors such as viewership, engagement, and interest in th e promotional content. The variable 𝑢 in this scenario could represent dynamic factors in optimal control, such as the timing of video releases, the intensity of promotional efforts, or the allocation of marketing resources across different channels and strategies. These factors are carefully adjusted and optimized by the marketing team to achieve the best possible outcomes in terms of views, engagement, and audience interest. Therefore, the practical significance of "optimal control" lies in its direct impact on the success of the promotional campaign for the L'Or perfume on YouTube. It enables the marketing team to adapt and refine their strategies in real-time, ensuring that the campaign reaches its target audience effectively and maximizes the promotion of the product. 3.9.4.8 Computational Tests - Parameters of the SIR Model To identify the optimal parameters gamma and beta of the SIR model, the MATLAB code described in Section 3.6.4.6 was utilized. This marketing campaign exhibited only one peak, and thus this singular peak was selected for the study. The study was conducted based on eight temporal observations (biweekly). In Figure 26, we can observe six biweekly observations obtained during the monitoring of the "L'or De J’Adore, The new perfume" advertising campaign by DIOR, corresponding to the second peak recorded. The first peak was slightly more impactful. However, it was not chosen because a larger and well-behaved sample makes the model more reliable. The second peak has the highest number 66 of observations (the first and third peaks have fewer observations). Therefore, following this reasoning, the second peak was chosen. Figure 26 - Biweekly views corresponding to the second peak of the DIOR marketing campaign. The output of the code provides information about the optimization of the SIR model parameters and the quality of the fit to the observed data. Let's analyze the results: • Initial parameter values (k) : The initial parameter values were set as a = 10 and b = 0.1. • Value of the objective function with initial parameters (aux) : The objective function, which is the sum of squared errors (SSE) between the observed data and the model predictions using the initial parameters, resulted in approximately 2.091661848348500e+02. • Final parameter values after optimization : After optimization, the final parameter values were adjusted to a = 3.826522835439373 and b = 0.032384000580986. • Value of the objective function after optimization (fval) : After optimization, the objective function (SSE) decreased to approximately 0.959264390517707. • Improvement in the objective function : The improvement in the objective function is calculated by subtracting the objective function value with the optimized parameters (fval) from the objective function value with the initial parameters (aux). In this case, the improvement was 2.082069204443323e+02. In summary, the model parameters were optimized to better fit the observed data, resulting in a significant reduction in the objective function (SSE) and a substantial improvement in the model's fit to the data. The optimal parameters obtained were a = 3.826523 (gamma - recovery rate) and b = 0.032384 (beta - transmission rate). Figure 27 displays the fitting of the SIR model to this data. 67 Figure 27 - Fitting the model to the data of the DIOR marketing campaign. 3.9.4.9 Computational Tests - u Control To apply optimal control to the viral marketing campaign under study, different values of b were tested, where the variable 𝑏 represents the weight associated with control. It is essential to recognize that the values of 𝑏 are arbitrary and lack practical importance. They were chosen only to analyze how the model behaves with different values of 𝑏 . The code, developed in MATLAB environment that made this analysis possible, can be consulted in the appendix 8. Next, three weights ( 𝑏 = 0.1, 10, 100) associated with the control parameter 𝑏 were evaluated to assess the impact of propagation cost on the marketing campaign. Figures 28, 29, and 30 demonstrate the implementation of the control and illustrate how the model evolves for these values of 𝑏 . On the left side, the SIR model is displayed. On the right side, the optimal control function 𝑢(𝑡) is presented. Figure 28 - With control for b = 0.1 (Perfume Campaign). 68 Figure 29 - With control for b = 10 (Perfume Campaign). Figure 30 - With control for b = 100 (Perfume Campaign). In the context of a marketing campaign, the parameter 𝑏 dictates the level of investment and intensity of control efforts over time. The following explanation can be given: • Figure 28 | Low Cost Scenario : This scenario depicts a low-cost YouTube marketing campaign. This low cost allows for continuous and intensive investment in control efforts throughout the eight-week campaign period, ensuring consistent visibility and engagement with the target audience. Consequently, this scenario results in the highest number of "infected" individuals, as demonstrated by the SIR model. • Figure 29 | Moderate Cost Scenario : This scenario illustrates a moderate-cost YouTube marketing campaign. The investment level is lower than in the 𝑏 = 0.1 scenario. Initially, the campaign can sustain a moderate level of control efforts. However, there is a notable decrease in control efforts starting from the sixth week, indicating a significant reduction due to budget constraints. • Figure 30 |High Cost Scenario : This scenario represents a high-cost YouTube marketing campaign. The substantial cost limits the overall investment, leading to a more conservative and adaptive approach over time. Control efforts begin at low 69 level and sharply decline after the sixth week due to strict budget limitations. As a result, this scenario produces the lowest number of "infected" individuals, as confirmed by the SIR model. Given the current budget constraints, the marketing team must develop specific strategies to effectively promote Dior's L'Or fragrance on YouTube and maximize the campaign's reach. The key question is: "What actions should be taken?" Here are proposed strategies tailored to each scenario to address their respective challenges. For 𝑏 = 0.1, over eight weeks, the following actions may be applied: • Daily Advertising Campaigns: Implement daily ad placements across YouTube and other relevant platforms (Instagram and TikTok) to ensure continuous visibility. • Engaging Content Strategy: Launch daily engaging content such as behind-the-scenes videos, interviews with the Dior team, and interactive polls to encourage viewer participation. • Influencer Collaborations: Consistently work with influencers for ongoing promotion, encouraging them to create content like vlogs and challenge videos featuring Dior's L'Or. • Regular Teasers and Exclusives: Frequently release teasers, trailers, and exclusive clips to maintain audience interest and anticipation. • Community Engagement Initiatives: Organize fan-driven activities such as contests and challenges related to Dior's L'Or, showcasing user-generated content on official channels. For 𝑏 = 10, over six weeks, the following actions may be applied: • Optimized Ad Scheduling: Schedule ads during peak viewing times and around key events to maximize impact while managing costs. • Targeted Audience Campaigns: Create personalized campaigns for specific demographics, such as luxury fragrance enthusiasts or Dior fans. • Timed Content Releases: Coordinate content launches with industry events, product unveilings, or relevant holidays to enhance visibility. • Focused Influencer Partnerships: Partner with influencers for short, impactful promotional periods, utilizing their reach through reviews and themed content. • Themed Marketing Weeks: Organize themed promotional weeks highlighting different aspects of Dior's L'Or, increasing engagement through varied content. 70 For 𝑏 = 100, over six weeks, the following actions may be applied: • Strategic Ad Placements: Target ads on niche platforms and high-engagement channels within the luxury and fragrance market. • High-Quality Content Production: Invest in premium content such as polished trailers, exclusive previews, and visually striking campaigns. • High-Impact Influencer Collaborations: Work with top influencers for impactful content releases, leveraging their credibility and reach. • Dynamic Budget Management: Adjust spending dynamically based on campaign performance metrics to optimize effectiveness. • Major Event Coordination: Align significant content releases with high-profile events, leveraging their visibility and audience engagement opportunities. 3.10 Comparative Analysis To enrich the conducted research, it was decided to study the impact of increased investment, specifically applying a significantly reduced value of 𝑏 ( 𝑏 = 0.01), to observe and compare the behavior of the four viral marketing campaigns under analysis. We can observe in Figures 31, 32, 33, and 34 the response of the four marketing campaigns to a strong investment effort in marketing. Figure 31 – Response of the Movie Campaign (b = 0.01). Figure 32 – Response of the Fashion Campaign (b = 0.01). 71 Figure 33 – Response of the Device Campaign (b = 0.01). Figure 34 – Response of the Perfume Campaign (b = 0.01). By the results, we can conclude that the Calvin Klein campaign (fashion campaign) had the least impact with the increase in investment effort, while the Apple campaign (device campaign) experienced the greatest impact. Based on a study conducted by [63], Apple is considered one of the greatest marketers of all time. Indeed, upon carefully analyzing the videos on YouTube corresponding to each of the marketing campaigns under study, we can verify that Apple's stands out the most (achieved the highest number of views). The Apple Vision Pro campaign stands out due to its well-structured video and the creation of an experience ecosystem, which is one of the key factors sustaining Apple's marketing excellence according to [63]. Let's analyze how this is manifested throughout the video: 1. Introduction (00:00) • The introduction immediately captures the viewer's attention, establishing the importance and innovation of the product. This initial presentation contextualizes the Apple Vision Pro within Apple's ecosystem, suggesting how it integrates with other products and services. 2. Photos and Videos (01:35) • The Apple Vision Pro's ability to capture and display high-quality photos and videos demonstrates seamless integration with Apple's media services, such as iCloud. This reinforces the continuity of the user experience across different devices. 3. Entertainment (02:41) 72 • Emphasizing entertainment showcases how the product can transform media consumption, linking to other Apple services like Apple TV+ and Apple Music, expanding Apple's content ecosystem. 4. Work (03:38) • The work functionalities highlight productivity, integrating with applications and services like Apple Notes, Pages, Keynote, and the iWork suite, demonstrating how the Apple Vision Pro can enhance work efficiency. 5. FaceTime (04:19) • Integration with FaceTime underscores connectivity and communication, essential elements of Apple's ecosystem, allowing for a seamless user experience across devices for calls and video conferences. 6. Design (05:26) • Focusing on design highlights attention to detail and minimalist aesthetics, which are Apple trademarks. This not only enhances the user experience but also strengthens brand identity. 7. Technology (06:57) • The technology section emphasizes the cutting-edge innovation and engineering of the Apple Vision Pro, maintaining Apple's commitment to simplicity and usability, as described in the reason "Unpack Simplicity." 8. Ending (08:32) • The conclusion ties together all the features highlighted earlier, reinforcing how the Apple Vision Pro fits into Apple's ecosystem and providing a unified and superior user experience. Thus, the Apple Vision Pro campaign stands out by emphasizing the product's integration within Apple's ecosystem. This is achieved through a video structure that highlights different uses and functionalities, connecting the product to other Apple services and devices, and creating a narrative that emphasizes simplicity, innovation, and a cohesive user experience, which are central to Apple's ongoing marketing success. 73 3.11 Concluding Remarks & Critical Analysis Based on the above, we can conclude that television is the best medium for launching an advertising campaign. However, this medium is very expensive and therefore only accessible to a few. Television falls under the category of traditional marketing. In the category of viral marketing, which is the focus of this research, social media platforms such as YouTube, X, Instagram, Facebook, and TikTok are included. For this study, YouTube was chosen because, in my opinion, it is currently the most powerful viral marketing medium. In my opinion, platforms like YouTube, X, Instagram, Facebook, and TikTok are essential tools for viral marketing due to their vast user bases and the ease with which content can be shared. Each platform caters to different demographics and allows for diverse forms of content, such as videos, images, and text. YouTube, for instance, is particularly effective for long-form content and storytelling, engaging viewers in a way that encourages sharing. TikTok, on the other hand, thrives on short, catchy videos that can go viral in a matter of hours, making it perfect for quick engagement. Similarly, Instagram and Facebook excel at visual storytelling and community building, allowing brands to connect with their audiences more personally. X serves as a real-time platform for updates and discussions, facilitating immediate engagement with trending topics. Together, these platforms create a dynamic ecosystem where brands can reach millions of potential customers quickly, making them invaluable for any viral marketing strategy. To conclude, based on what was mentioned in section 3.9, the investigation procedure was the same for all four viral marketing campaigns, meaning the same approach was applied to each of the four case studies. The reasoning used was practically identical across all four advertising campaigns. Therefore, the written text and, consequently, the explanations provided are very similar. However, each case is unique, and for this reason, the four marketing campaigns were studied independently, each with the same level of importance. Although the text may seem repetitive, I believe it is essential to explain everything in great detail, along with the reasoning process that justifies each step taken for each of the campaigns studied. As I have already mentioned, each campaign was handled independently, with no connection between them (except for the investigation procedure). Therefore, my critical analysis follows this line of thought. 80 [38] Bellman, R. (1957). Dynamic programming . Princeton University Press. [39] Anderson, B. D. O., & Moore, J. B. (1990). Optimal control: Linear quadratic methods . Prentice Hall. [40] Pontryagin, L. S., Boltyanskii, V. G., Gamkrelidze, R. V., & Mishchenko, E. F. (1962). The mathematical theory of optimal processes . Interscience Publishers. [41] Kalman, R. E., & Bucy, R. S. (1961). New results in linear filtering and prediction theory . Journal of Fluids Engineering, Transactions of the ASME, 83(1), 95–108. https://doi.org/10.1115/1.3658902 [42] Nocedal, J., & Wright, S. J. (2006). Numerical optimization . Springer. [43] Maciejowski, J. M. (2002). Model predictive control: Theory and practice . Addison-Wesley. [44] Astrom, K. J., & Wittenmark, B. (2013). Adaptive control . Dover Publications. [45] Miele, A., Weeks, M. W., & Ciarcià, M. (2007). Optimal trajectories for spacecraft rendezvous . Journalof Optimization Theory and Applications, 132(3), 353–376. https://doi.org/10.1007/s10957-007-9166-4 [46] Zhang, S., Xie, Y., Wang, S., & Li, H. (2024). LQR optimal composite control for mobile robot trajectory tracking system based on LPV model . In J. Tan, Y. Liu, H. Z. Huang, J. Yu, & Z. Wang (Eds.), Advances in mechanical design: ICMD 2023 (Vol. 155, pp. 2135–2151). Springer. https://doi.org/10.1007/978-981-97-0922-9_135 [47] Kim, N., Jeong, J., & Zheng, C. (2019). Adaptive energy management strategy for plug-in hybrid electric vehicles with Pontryagin’s minimum principle based on daily driving patterns . International Journal of Precision Engineering and Manufacturing–Green Technology, 6, 539–548. https://doi.org/10.1007/s40684-019-00046-z [48] Adepu, S., & Ramakrishna, S. (2021 ). Controlled drug delivery systems: Current status and future directions . Molecules, 26(19), 5905. https://doi.org/10.3390/molecules26195905 [49] Nepomuceno, E. G., Peixoto, M. L. C., Lacerda, M. J., Campanharo, A. S. L. O., Takahashi, R. H. C., & Aguirre, L. A. (2021). Application of Optimal Control of Infectious Diseases in a Model-Free Scenario . SN Computer Science, 2(5). https://doi.org/10.1007/s42979-021-00794-3 [50] Mombaur, K. (2016). Optimal Control for Applications in Medical and Rehabilitation Technology: Challenges and Solutions. In: Hiriart-Urruty, JB., Korytowski, A., Maurer, H., Szymkat, M. (eds) Advances in Mathematical Modeling, 81 Optimization and Optimal Control. Springer Optimization and Its Applications, vol 109. Springer, Cham. https://doi.org/10.1007/978-3-319-30785-5_5 [51] Liao, K. J., Hou, X., & Strickland, M. J. (2016). Resource allocation for mitigating regional air pollution–related mortality: A summertime case study for five cities in the United States . Journal of the Air and Waste Management Association, 66(8), 748–757. https://doi.org/10.1080/10962247.2016.1176085 [52] Cherkaoui-Dekkaki, O., Djema, W., Raissi, N., et al. (2024). Optimal control of waste recovery process . Authorea. https://doi.org/10.22541/au.171475802.23126177/v1 [53] Shastri, Y., & Diwekar, U. (2005). Application of optimal control theory for sustainable ecosystem management . In AIChE Annual Meeting, Conference Proceedings (pp. 7255–7272). [54] Belhdid, S., Balatif, O., & Khajji, B. (2024). Optimal control and cost-effectiveness analysis of scam rumor propagation over social networks . Results in Control and Optimization, 16, 100441. https://doi.org/10.1016/j.rico.2024.100441 [55] McAsey, M., Mou, L., & Han, W. (2012, September). Convergence of the forward-backward sweep method in optimal control . Computational Optimization and Applications. https://doi.org/10.1007/s10589-011-9454-7 [56] Wikipedia contributors. (2024, July 20). Meg 2: The Trench . Wikipedia, The Free Encyclopedia. https://en.wikipedia.org/wiki/Meg_2:_The_Trench [57] PVH Corp. (2024, July 17). Calvin Klein Spring 2024: Jeremy Allen White. PVH. https://pvh.com/news/calvin-klein- spring-2024-jeremy-allen-white [58] Wikipedia contributors. (2024, July 15). Apple Vision Pro . Wikipedia, The Free Encyclopedia. https://en.wikipedia.org/wiki/Apple_Vision_Pro [59] Wikipedia contributors. (2024, July 19). Dior . Wikipedia, The Free Encyclopedia. https://en.wikipedia.org/wiki/Dior [60] Wikipedia contributors. (2024, July 18). J'adore (fragrance) . Wikipedia, The Free Encyclopedia. https://en.wikipedia.org/wiki/J%27adore_(fragrance) [61] M. Martcheva. An Introduction to Mathematical Epidemiology . Springer, New York Heidelberg Dordrecht London, 2015. [62] Lenhart, S., & Workman, J. T. (2007). Optimal control applied to biological models . Chapman & Hall. 82 [63] Moorman, C. (2018, January 12). Why Apple is still a great marketer and what you can learn . Forbes. https://www.forbes.com/sites/christinemoorman/2018/01/12/why-apple-is-still-a-great-marketer-and-what-you-can- learn/ [64] Pal, R. (2018). Successful methods of viral marketing: How to achieve virality (Bachelor's thesis). Jönköping University. [65] Q. Liu, D. Jiang, N. Shi, T. Hayat and B. Ahmad. Stationary distribution and extinction of a stochastic SEIR epidemic model with standard incidence . Physica A: Statistical Mechanics and its Applications, 476:58–69, 2017. [66] Q. Liu, D. Jiang, N. Shi, T. Hayat and A. Alsaedi. Asymptotic behavior of a stochastic delayed SEIR epidemic model with nonlinear incidence . Physica A: Statistical Mechanics and its Applications, 462:870–882, 2016. [67] J. Mateus and C. Silva. HIV–TB co-infection treatment: Existence of periodic solutions of a periodic SEIRS model with general incidence . Nonlinear Analysis: Real World Applications, 34:379–402, 2017. [68] L. Qi and J. Cui. The stability of an SEIRS model with nonlinear incidence, vertical transmission and time delay . Applied Mathematics and Computation, 221:360–366, 2013. [69] R.T. Rust, T. Ambler, G.S. Carpenter, K. Kumar and R.K. Srivastava . Measuring Marketing Productivity: Current Knowledge and Future Directions . Journal of Marketing, 68(4):76–89, 2004. [70] L. Porter and G. Golan. From Subservient Chickens to Brawny Men: A Comparison of Viral Advertising to Television Advertising . Journal of Interactive Advertising, 6(2):30–38, 2006. [71] N. Adelsarbanlar and B. Khoshtinat. Critical factors and advantage factors influencing the implementation of viral marketing by considering the mediating role of Islamic marketing; a conceptual approach . Procedia Economics and Finance, 36:433–440, 2016. [72] J. Leskovec, L.A. Adamic and B.A. Huberman. The dynamics of viral marketing . ACM Trans. Web (TWEB), 1(1):1–39, 2007. [73] Long, C., Wong, R.C.W.: Viral marketing for dedicated customers . Inf. Syst. 46, 1–23 (2014). [74] Mochalova, A., Nanopoulos, A.: A targeted approach to viral marketing . Electron. Commer. Res. Appl. 13(4), 283–294 (2014). 83 [75] Woerndl, M., Papagiannidis, S., Bourlakis, M., Li, F.: Internet-induced marketing techniques: critical factors in viral marketing campaigns . Int. J. Bus. Sci. Appl. Manage. 3(1), 33–45 (2008). [76] Haryani, S., Motwani, B.: Discriminant model for online viral marketing influencing consumers behavioural intention . Pac. Sci. Rev. B: Humanit. Soc. Sci. 1(1), 49–56 (2015). [77] Rodrigues, H.S., Fonseca, M.J.: Can information be spread as a virus? Viral marketing as epidemiological model . Math. Methods Appl. Sci. 39(16), 4780–4786 (2016). [78] Gardner, J., Sohn, K., Seo, J., Weaver, J.: A sensitivity analysis of an epidemiological model of viral marketing: when viral marketing efforts fall flat . J. Mark Dev. Competit. 7(4), 25–46 (2013). [79] A. Karnik and P. Dayama, Optimal control of information epidemics , in Proc. Fourth International Conference on Communication Systems and Networks (COMSNETS), 2012. [80] Kandhway, K., & Kuri, J. (2014). How to run a campaign: Optimal control of SIS and SIR information epidemics. Applied Mathematics and Computation, 231, 79-92. [81] Gonçalves, J. N., Monteiro, M. T. T., & Rodrigues, H. S. (2018). On the Dynamics of a Viral Marketing Model with Optimal Control using Indirect and Direct Methods . Statistics, Optimization & Information Computing, 6(4), 633-644. [82] Lewis, F. L., Vrabie, D., & Syrmos, V. L. (2012). Optimal Control . Wiley. 84 A PPENDICES A PPENDIX 1 - Estimation of the optimal parameters (Movie Marketing Campaign) function MovieMarketingCampaign % This function fits the first set of BSfludata to and ... %SIR model clear all close all clc %load BSfludat.txt % loading data format long % specifying higher precision tdata = 1:8; % define array with t-coordinates f the data qdata = [0.27 2.73 2.85 6.25 2.82 0.91 1.02 0.50]; % define array with ycoordinates of the data tforward = 1:0.01:8; % t mesh for the solution of the differential equation tmeasure = [1:100:numel(tforward)]; a = 10; b = 0.1; % initial values of parameters to be fitted % END %----------------------------------------------- function dy = model_1(t,y,k) % DE a = k(1); % Assignes the parameters in theDE the current value of the parameters b = k(2); dy = zeros(2,1); % assigns zeros to dy dy(1) = - b * y(1) * y(2); % RHS of first equation dy(2) = b * y(1) * y(2) - a * y(2); % RHS of second equation end %--------------------------------------------- function error_in_data = moder(k) % computing the error in the data %[T Y] = ode23s(@(t,y)(model_1(t,y,k)),tforward,[(868.4-2.97),2.97]); [T Y] = ode23s(@(t,y)(model_1(t,y,k)),tforward,[(100-0.27),0.27]); % solves the DE; output is written in T and Y q = Y(tmeasure(:),2)'; % assignts the y-coordinates of the solution at the tcoordinates of tdata error_in_data = sum((q - qdata).^2);%computes SSE end %-------------------------------------------------- k = [a b] % main routine; assigns initial values of parameters aux=moder(k) % disp('f. objective with initial parameters') % disp(aux) % % [T Y] = ode23s(@(t,y)(model_1(t,y,k)),tforward,[(868.4-2.97),2.97]); % [T Y] = ode23s(@(t,y)(model_1(t,y,k)),tforward,[(86.84-0.54),0.54]); 85 % % solves the DE with the initial values of the parameters % % yint = Y(:,2); % % assigns the y-coordinates of the solution at tdata to yint % figure(1) % subplot(1,2,1); % plot(tdata,qdata,'r.'); % hold on % plot(tforward,yint,'b-'); % plotting of solution and data with initial guesses for the parameters % xlabel('Time in biweeks - initial parameters'); % ylabel('Views'); [k,fval] = fminsearch(@moder,k); % minimization routine; assigns the values of parameters ... %to k and the SSE to fval disp('final parameters') disp(k) % the parameters disp('f. objective final') disp (fval) disp('Improvement') aux1=aux-fval; disp(aux1) %[T Y] = ode23s(@(t,y)(model_1(t,y,k)),tforward,[(868.4-5.45),5.45]); % solving the DE with the final ... % values of the parameters [T Y] = ode23s(@(t,y)(model_1(t,y,k)),tforward,[(100-0.27),0.27]); % solving the DE with the final ... yint = Y(tmeasure(:),2); % computing the y-coordinates ... yint = Y(:,2); % computing the y-coordinates ...corresponding to the tdata subplot(1,2,2) plot(tdata,qdata,'r*'); hold on plot(tforward,yint,'b-'); xlabel('Time in weeks - optimal parameters'); % plotting final fit % ylabel('Views'); end 86 A PPENDIX 2 - Obtaining the control function (Movie Marketing Campaign) function y = code_MovieCampaign clear all close all clc test = -1; % variable for the stopping criterion % T=14; T=8; delta = 0.001; M = 1000; t=linspace(0,T,M+1); h=T/M; h2 = h/2; % N= 868.4; % total population % beta= 76.082343043043977; % estimated parameter beta. Estimated by another code. Beta -> b % gamma= 5.865289840869059; % estimated parameter gamma. Estimated by another code. Gamma -> a N= 100; % total population beta= 0.050434; % estimated parameter beta. Estimated by another code. Beta -> b gamma= 3.482370; % estimated parameter gamma. Estimated by another code. Gamma -> a % initializations of the variables S, I, and R to zero S=zeros(1,M+1); I=zeros(1,M+1); R=zeros(1,M+1); % initial condition for S, I, and R S(1)=(N-0.27)/N; % put the initial number of infected people here I(1)=0.27/N; R(1)=0; % initialization of the control to zero u=zeros(1,M+1); % initialization to zero of the adjoint variables (for each of the 3 constraints) lambda1=zeros(1,M+1); lambda2=zeros(1,M+1); lambda3=zeros(1,M+1); % transversality condition lambda1(M+1)=0; lambda2(M+1)=1; lambda3(M+1)=1; % initialization of the functional J to zero J=zeros(1,M+1); while(test < 0) % test of the iterative process, test was initialized to -1 % save the variables u, S, I, R, lambda1, lambda2, and lambda3 oldu = u; 87 oldS = S; oldI = I; oldR = R; oldlambda1 = lambda1; oldlambda2 = lambda2; oldlambda3 = lambda3; % "sweep" ALL values of the discretization forward (state variables) for i = 1:M % resolution of the SIR system by 4th order RK m11 = (-beta*S(i)*I(i))-u(i)*S(i); m12 = (beta*S(i)*I(i))-gamma*I(i)+(u(i)*S(i)); m13 = gamma*I(i); m21 = (-beta*(S(i)+h2*m11))*(I(i)+h2*m12)-0.5*(u(i)+u(i+1))*(S(i)+h2*m11); m22 = (beta*(S(i)+h2*m11))*(I(i)+h2*m12)- gamma*(I(i)+h2*m12)+0.5*(u(i)+u(i+1))*(S(i)+h2*m11); m23 = gamma*(I(i)+h2*m12); m31 = (-beta*(S(i)+h2*m21))*(I(i)+h2*m22)-0.5*(u(i)+u(i+1))*(S(i)+h2*m21); m32 = (beta*(S(i)+h2*m21))*(I(i)+h2*m22)- gamma*(I(i)+h2*m22)+0.5*(u(i)+u(i+1))*(S(i)+h2*m21); m33 = gamma*(I(i)+h2*m22); m41 = (-beta*(S(i)+h*m31))*(I(i)+h*m32)-u(i+1)*(S(i)+h*m31); m42 = (beta*(S(i)+h*m31))*(I(i)+h*m32)- gamma*(I(i)+h*m32)+u(i+1)*(S(i)+h*m31); m43 = gamma*(I(i)+h*m32); % here is the 4th order RK for the state variables S, I, and R S(i+1) = S(i) + (h/6)*(m11 + 2*m21 + 2*m31 + m41); I(i+1) = I(i) + (h/6)*(m12 + 2*m22 + 2*m32 + m42); R(i+1) = R(i) + (h/6)*(m13 + 2*m23 + 2*m33 + m43); end for i = 1:M j = M + 2 - i; % "sweep" ALL values of the discretization backward (adjoint variables) % resolution of the adjoint variables system by 4th order RK n11 = lambda1(j)*(beta*I(j)+u(j))-lambda2(j)*(beta*I(j)+u(j)); n12 = lambda1(j)*(beta*S(j))-lambda2(j)*(beta*S(j)-gamma)-lambda3(j)*gamma; n13 = 0; n21 = (lambda1(j)-h2*n11)*(beta*(0.5*(I(j)+I(j-1)))+(0.5*(u(j)+u(j-1))))- (lambda2(j)-h2*n12)*(beta*(0.5*(I(j)+I(j-1)))+(0.5*(u(j)+u(j-1)))); n22 = (lambda1(j)-h2*n11)*(beta*(0.5*(S(j)+S(j-1))))-(lambda2(j)- h2*n12)*(beta*(0.5*(S(j)+S(j-1)))-gamma)-(lambda3(j)-h2*n13)*gamma; n23 = 0; n31 = (lambda1(j)-h2*n21)*(beta*(0.5*(I(j)+I(j-1)))+(0.5*(u(j)+u(j-1))))- (lambda2(j)-h2*n22)*(beta*(0.5*(I(j)+I(j-1)))+(0.5*(u(j)+u(j-1)))); n32 = (lambda1(j)-h2*n21)*(beta*(0.5*(S(j)+S(j-1))))-(lambda2(j)- h2*n22)*(beta*(0.5*(S(j)+S(j-1)))-gamma)-(lambda3(j)-h2*n23)*gamma; n33= 0; 88 n41 = (lambda1(j)-h*n31)*(beta*I(j-1)+u(j-1))-(lambda2(j)-h*n32)*(beta*I(j- 1)+u(j-1)); n42 = (lambda1(j)-h*n31)*(beta*S(j-1))-(lambda2(j)-h*n32)*(beta*S(j-1)- gamma)-(lambda3(j)-h*n33)*gamma; n43 = 0; % here is the 4th order RK for the adjoint variables % note that lambda3 will always be zero lambda1(j-1) = lambda1(j) - (h/6)*(n11 + 2*n21 + 2*n31 + n41); lambda2(j-1) = lambda2(j) - (h/6)*(n12 + 2*n22 + 2*n32 + n42); lambda3(j-1) = lambda3(j) - (h/6)*(n13 + 2*n23 + 2*n33 + n43); end b=10; % weight associated with control: can be varied, making it more expensive or cheaper u1=min(0.1,max((S.*(lambda2-lambda1))/(2*b),0)); % %u1=0.025; u=0.5*(u1 + oldu); % update the value of u: average between the values % u=zeros(1,M+1); % without control % COST FUNCTION: maximize the infected and recovered at the end of the campaign and save costs J= I(M+1)+R(M+1)-trapz(t,b*(u.^2)); % it is a scalar, cost % calculations for the stopping criterion using the old and updated values temp1 = delta*sum(abs(u)) - sum(abs(oldu - u)); temp2 = delta*sum(abs(S)) - sum(abs(oldS - S)); temp3 = delta*sum(abs(I)) - sum(abs(oldI - I)); temp4 = delta*sum(abs(R)) - sum(abs(oldR - R)); temp5 = delta*sum(abs(lambda1)) - sum(abs(oldlambda1 - lambda1)); temp6 = delta*sum(abs(lambda2)) - sum(abs(oldlambda2 - lambda2)); temp7 = delta*sum(abs(lambda3)) - sum(abs(oldlambda3 - lambda3)); test = min(temp1, min(temp2, min(temp3, min(temp4, min(temp5, min(temp6,temp7)))))); end % save the values of the independent variable t, the state variables S, I, R, the control u, and the functional J - all in the matrix y which has 6 rows and M+1 columns y(1,:) = t; % first row of y contains the time y(2,:) = S; % second row of y contains S y(3,:) = I; y(4,:) = R; y(5,:) = u; y(6,:)= J; % printing the state variables S, I, and R figure(1); plot(y(1,:), y(2,:),':b','LineWidth',2);hold on; plot(y(1,:), y(3,:),'.k','LineWidth',2); plot(y(1,:), y(4,:),'-r','LineWidth',2);hold off; xlabel('time (weeks)') ; title('Movie Campaign'); legend(['S';'I';'R']); % printing the optimal control figure(2) plot(y(1,:), y(5,:),':b','LineWidth',2); xlabel('time (weeks)') ; title('Control'); legend('u'); % figure(3) 89 % plot(y(1,:), y(6,:),':b','LineWidth',2); % xlabel('t') ; title('Cost'); end 96 % figure(1) % subplot(1,2,1); % plot(tdata,qdata,'r.'); % hold on % plot(tforward,yint,'b-'); % plotting of solution and data with initial guesses for the parameters % xlabel('Time in biweeks - initial parameters'); % ylabel('Views'); [k,fval] = fminsearch(@moder,k); % minimization routine; assigns the values of parameters ... %to k and the SSE to fval disp('final parameters') disp(k) % the parameters disp('f. objective final') disp (fval) disp('Improvement') aux1=aux-fval; disp(aux1) %[T Y] = ode23s(@(t,y)(model_1(t,y,k)),tforward,[(868.4-0.46),0.46]); % solving the DE with the final ... % values of the parameters [T Y] = ode23s(@(t,y)(model_1(t,y,k)),tforward,[(172-8.60),8.60]); % solving the DE with the final ... yint = Y(tmeasure(:),2); % computing the y-coordinates ... yint = Y(:,2); % computing the y-coordinates ...corresponding to the tdata subplot(1,2,2) plot(tdata,qdata,'r*'); hold on plot(tforward,yint,'b-'); xlabel('Time in weeks - optimal parameters'); % plotting final fit % ylabel('Views'); end 97 A PPENDIX 6 - Obtaining the control function (Device Marketing Campaign) function y = code_DeviceCampaign clear all close all clc test = -1; % variable for the stopping criterion % T=14; T=8; delta = 0.001; M = 1000; t=linspace(0,T,M+1); h=T/M; h2 = h/2; % N= 868.4; % total population % beta= 76.082343043043977; % estimated parameter beta. Estimated by another code. Beta -> b % gamma= 5.865289840869059; % estimated parameter gamma. Estimated by another code. Gamma -> a N= 172; % total population beta= 0.032804; % estimated parameter beta. Estimated by another code. Beta -> b gamma= 3.137420; % estimated parameter gamma. Estimated by another code. Gamma -> a % initializations of the variables S, I, and R to zero S=zeros(1,M+1); I=zeros(1,M+1); R=zeros(1,M+1); % initial condition for S, I, and R S(1)=(N-8.60)/N; % put the initial number of infected people here I(1)=8.60/N; R(1)=0; % initialization of the control to zero u=zeros(1,M+1); % initialization to zero of the adjoint variables (for each of the 3 constraints) lambda1=zeros(1,M+1); lambda2=zeros(1,M+1); lambda3=zeros(1,M+1); % transversality condition lambda1(M+1)=0; lambda2(M+1)=1; lambda3(M+1)=1; % initialization of the functional J to zero J=zeros(1,M+1); while(test < 0) % test of the iterative process, test was initialized to -1 % save the variables u, S, I, R, lambda1, lambda2, and lambda3 oldu = u; oldS = S; 98 oldI = I; oldR = R; oldlambda1 = lambda1; oldlambda2 = lambda2; oldlambda3 = lambda3; % "sweep" ALL values of the discretization forward (state variables) for i = 1:M % resolution of the SIR system by 4th order RK m11 = (-beta*S(i)*I(i))-u(i)*S(i); m12 = (beta*S(i)*I(i))-gamma*I(i)+(u(i)*S(i)); m13 = gamma*I(i); m21 = (-beta*(S(i)+h2*m11))*(I(i)+h2*m12)-0.5*(u(i)+u(i+1))*(S(i)+h2*m11); m22 = (beta*(S(i)+h2*m11))*(I(i)+h2*m12)- gamma*(I(i)+h2*m12)+0.5*(u(i)+u(i+1))*(S(i)+h2*m11); m23 = gamma*(I(i)+h2*m12); m31 = (-beta*(S(i)+h2*m21))*(I(i)+h2*m22)-0.5*(u(i)+u(i+1))*(S(i)+h2*m21); m32 = (beta*(S(i)+h2*m21))*(I(i)+h2*m22)- gamma*(I(i)+h2*m22)+0.5*(u(i)+u(i+1))*(S(i)+h2*m21); m33 = gamma*(I(i)+h2*m22); m41 = (-beta*(S(i)+h*m31))*(I(i)+h*m32)-u(i+1)*(S(i)+h*m31); m42 = (beta*(S(i)+h*m31))*(I(i)+h*m32)- gamma*(I(i)+h*m32)+u(i+1)*(S(i)+h*m31); m43 = gamma*(I(i)+h*m32); % here is the 4th order RK for the state variables S, I, and R S(i+1) = S(i) + (h/6)*(m11 + 2*m21 + 2*m31 + m41); I(i+1) = I(i) + (h/6)*(m12 + 2*m22 + 2*m32 + m42); R(i+1) = R(i) + (h/6)*(m13 + 2*m23 + 2*m33 + m43); end for i = 1:M j = M + 2 - i; % "sweep" ALL values of the discretization backward (adjoint variables) % resolution of the adjoint variables system by 4th order RK n11 = lambda1(j)*(beta*I(j)+u(j))-lambda2(j)*(beta*I(j)+u(j)); n12 = lambda1(j)*(beta*S(j))-lambda2(j)*(beta*S(j)-gamma)-lambda3(j)*gamma; n13 = 0; n21 = (lambda1(j)-h2*n11)*(beta*(0.5*(I(j)+I(j-1)))+(0.5*(u(j)+u(j-1))))- (lambda2(j)-h2*n12)*(beta*(0.5*(I(j)+I(j-1)))+(0.5*(u(j)+u(j-1)))); n22 = (lambda1(j)-h2*n11)*(beta*(0.5*(S(j)+S(j-1))))-(lambda2(j)- h2*n12)*(beta*(0.5*(S(j)+S(j-1)))-gamma)-(lambda3(j)-h2*n13)*gamma; n23 = 0; n31 = (lambda1(j)-h2*n21)*(beta*(0.5*(I(j)+I(j-1)))+(0.5*(u(j)+u(j-1))))- (lambda2(j)-h2*n22)*(beta*(0.5*(I(j)+I(j-1)))+(0.5*(u(j)+u(j-1)))); n32 = (lambda1(j)-h2*n21)*(beta*(0.5*(S(j)+S(j-1))))-(lambda2(j)- h2*n22)*(beta*(0.5*(S(j)+S(j-1)))-gamma)-(lambda3(j)-h2*n23)*gamma; n33= 0; n41 = (lambda1(j)-h*n31)*(beta*I(j-1)+u(j-1))-(lambda2(j)-h*n32)*(beta*I(j- 1)+u(j-1)); n42 = (lambda1(j)-h*n31)*(beta*S(j-1))-(lambda2(j)-h*n32)*(beta*S(j-1)- gamma)-(lambda3(j)-h*n33)*gamma; 99 n43 = 0; % here is the 4th order RK for the adjoint variables % note that lambda3 will always be zero lambda1(j-1) = lambda1(j) - (h/6)*(n11 + 2*n21 + 2*n31 + n41); lambda2(j-1) = lambda2(j) - (h/6)*(n12 + 2*n22 + 2*n32 + n42); lambda3(j-1) = lambda3(j) - (h/6)*(n13 + 2*n23 + 2*n33 + n43); end b=100; % weight associated with control: can be varied, making it more expensive or cheaper u1=min(0.1,max((S.*(lambda2-lambda1))/(2*b),0)); % %u1=0.025; u=0.5*(u1 + oldu); % update the value of u: average between the values % u=zeros(1,M+1); % without control % COST FUNCTION: maximize the infected and recovered at the end of the campaign and save costs J= I(M+1)+R(M+1)-trapz(t,b*(u.^2)); % it is a scalar, cost % calculations for the stopping criterion using the old and updated values temp1 = delta*sum(abs(u)) - sum(abs(oldu - u)); temp2 = delta*sum(abs(S)) - sum(abs(oldS - S)); temp3 = delta*sum(abs(I)) - sum(abs(oldI - I)); temp4 = delta*sum(abs(R)) - sum(abs(oldR - R)); temp5 = delta*sum(abs(lambda1)) - sum(abs(oldlambda1 - lambda1)); temp6 = delta*sum(abs(lambda2)) - sum(abs(oldlambda2 - lambda2)); temp7 = delta*sum(abs(lambda3)) - sum(abs(oldlambda3 - lambda3)); test = min(temp1, min(temp2, min(temp3, min(temp4, min(temp5, min(temp6,temp7)))))); end % save the values of the independent variable t, the state variables S, I, R, the control u, and the functional J - all in the matrix y which has 6 rows and M+1 columns y(1,:) = t; % first row of y contains the time y(2,:) = S; % second row of y contains S y(3,:) = I; y(4,:) = R; y(5,:) = u; y(6,:)= J; % printing the state variables S, I, and R figure(1); plot(y(1,:), y(2,:),':b','LineWidth',2);hold on; plot(y(1,:), y(3,:),'.k','LineWidth',2); plot(y(1,:), y(4,:),'-r','LineWidth',2);hold off; xlabel('time (weeks)') ; title('Device Campaign'); legend(['S';'I';'R']); % printing the optimal control figure(2) plot(y(1,:), y(5,:),':b','LineWidth',2); xlabel('time (weeks)') ; title('Control'); legend('u'); % figure(3) % plot(y(1,:), y(6,:),':b','LineWidth',2); % xlabel('t') ; title('Cost'); end 100 A PPENDIX 7 - Estimation of the optimal parameters (Perfume Marketing Campaign) function PerfumeMarketingCampaign % This function fits the first set of BSfludata to and ... %SIR model clear all close all clc %load BSfludat.txt % loading data format long % specifying higher precision tdata = 1:6; % define array with t-coordinates f the data qdata = [0.54 2.7 8.35 8.68 3.68 0.09]; % define array with y-coordinates of the data tforward = 1:0.01:6; % t mesh for the solution of the differential equation tmeasure = [1:100:numel(tforward)]; a = 10; b = 0.1; % initial values of parameters to be fitted % END %----------------------------------------------- function dy = model_1(t,y,k) % DE a = k(1); % Assignes the parameters in theDE the current value of the parameters b = k(2); dy = zeros(2,1); % assigns zeros to dy dy(1) = - b * y(1) * y(2); % RHS of first equation dy(2) = b * y(1) * y(2) - a * y(2); % RHS of second equation end %--------------------------------------------- function error_in_data = moder(k) % computing the error in the data %[T Y] = ode23s(@(t,y)(model_1(t,y,k)),tforward,[(868.4-2.97),2.97]); [T Y] = ode23s(@(t,y)(model_1(t,y,k)),tforward,[(172-0.54),0.54]); % solves the DE; output is written in T and Y q = Y(tmeasure(:),2)'; % assignts the y-coordinates of the solution at the tcoordinates of tdata error_in_data = sum((q - qdata).^2);%computes SSE end %-------------------------------------------------- k = [a b] % main routine; assigns initial values of parameters aux=moder(k) % disp('f. objective with initial parameters') % disp(aux) % % [T Y] = ode23s(@(t,y)(model_1(t,y,k)),tforward,[(868.4-2.97),2.97]); % [T Y] = ode23s(@(t,y)(model_1(t,y,k)),tforward,[(86.84-0.54),0.54]); % % solves the DE with the initial values of the parameters % % yint = Y(:,2); % % assigns the y-coordinates of the solution at tdata to yint 101 % figure(1) % subplot(1,2,1); % plot(tdata,qdata,'r.'); % hold on % plot(tforward,yint,'b-'); % plotting of solution and data with initial guesses for the parameters % xlabel('Time in biweeks - initial parameters'); % ylabel('Views'); [k,fval] = fminsearch(@moder,k); % minimization routine; assigns the values of parameters ... %to k and the SSE to fval disp('final parameters') disp(k) % the parameters disp('f. objective final') disp (fval) disp('Improvement') aux1=aux-fval; disp(aux1) [T Y] = ode23s(@(t,y)(model_1(t,y,k)),tforward,[(868.4-2.97),2.97]); % solving the DE with the final ... % values of the parameters [T Y] = ode23s(@(t,y)(model_1(t,y,k)),tforward,[(172-0.54),0.54]); % solving the DE with the final ... yint = Y(tmeasure(:),2); % computing the y-coordinates ... yint = Y(:,2); % computing the y-coordinates ...corresponding to the tdata subplot(1,2,2) plot(tdata,qdata,'r*'); hold on plot(tforward,yint,'b-'); xlabel('Time in biweeks - optimal parameters'); % plotting final fit % ylabel('Views'); end 102 A PPENDIX 8 - Obtaining the control function (Perfume Marketing Campaign) function y = code_PerfumeCampaign clear all close all clc test = -1; % variable for the stopping criterion % T=14; T=6; delta = 0.001; M = 1000; t=linspace(0,T,M+1); h=T/M; h2 = h/2; % N= 868.4; % total population % beta= 76.082343043043977; % estimated parameter beta. Estimated by another code. Beta -> b % gamma= 5.865289840869059; % estimated parameter gamma. Estimated by another code. Gamma -> a N= 172; % total population beta= 0.032384000580986; % estimated parameter beta. Estimated by another code. Beta -> b gamma= 3.826522835439373; % estimated parameter gamma. Estimated by another code. Gamma -> a % initializations of the variables S, I, and R to zero S=zeros(1,M+1); I=zeros(1,M+1); R=zeros(1,M+1); % initial condition for S, I, and R S(1)=(N-0.54)/N; % put the initial number of infected people here I(1)=0.54/N; R(1)=0; % initialization of the control to zero u=zeros(1,M+1); % initialization to zero of the adjoint variables (for each of the 3 constraints) lambda1=zeros(1,M+1); lambda2=zeros(1,M+1); lambda3=zeros(1,M+1); % transversality condition lambda1(M+1)=0; lambda2(M+1)=1; lambda3(M+1)=1; % initialization of the functional J to zero J=zeros(1,M+1); while(test < 0) % test of the iterative process, test was initialized to -1 % save the variables u, S, I, R, lambda1, lambda2, and lambda3 103 oldu = u; oldS = S; oldI = I; oldR = R; oldlambda1 = lambda1; oldlambda2 = lambda2; oldlambda3 = lambda3; % "sweep" ALL values of the discretization forward (state variables) for i = 1:M % resolution of the SIR system by 4th order RK m11 = (-beta*S(i)*I(i))-u(i)*S(i); m12 = (beta*S(i)*I(i))-gamma*I(i)+(u(i)*S(i)); m13 = gamma*I(i); m21 = (-beta*(S(i)+h2*m11))*(I(i)+h2*m12)-0.5*(u(i)+u(i+1))*(S(i)+h2*m11); m22 = (beta*(S(i)+h2*m11))*(I(i)+h2*m12)- gamma*(I(i)+h2*m12)+0.5*(u(i)+u(i+1))*(S(i)+h2*m11); m23 = gamma*(I(i)+h2*m12); m31 = (-beta*(S(i)+h2*m21))*(I(i)+h2*m22)-0.5*(u(i)+u(i+1))*(S(i)+h2*m21); m32 = (beta*(S(i)+h2*m21))*(I(i)+h2*m22)- gamma*(I(i)+h2*m22)+0.5*(u(i)+u(i+1))*(S(i)+h2*m21); m33 = gamma*(I(i)+h2*m22); m41 = (-beta*(S(i)+h*m31))*(I(i)+h*m32)-u(i+1)*(S(i)+h*m31); m42 = (beta*(S(i)+h*m31))*(I(i)+h*m32)- gamma*(I(i)+h*m32)+u(i+1)*(S(i)+h*m31); m43 = gamma*(I(i)+h*m32); % here is the 4th order RK for the state variables S, I, and R S(i+1) = S(i) + (h/6)*(m11 + 2*m21 + 2*m31 + m41); I(i+1) = I(i) + (h/6)*(m12 + 2*m22 + 2*m32 + m42); R(i+1) = R(i) + (h/6)*(m13 + 2*m23 + 2*m33 + m43); end for i = 1:M j = M + 2 - i; % "sweep" ALL values of the discretization backward (adjoint variables) % resolution of the adjoint variables system by 4th order RK n11 = lambda1(j)*(beta*I(j)+u(j))-lambda2(j)*(beta*I(j)+u(j)); n12 = lambda1(j)*(beta*S(j))-lambda2(j)*(beta*S(j)-gamma)-lambda3(j)*gamma; n13 = 0; n21 = (lambda1(j)-h2*n11)*(beta*(0.5*(I(j)+I(j-1)))+(0.5*(u(j)+u(j-1))))- (lambda2(j)-h2*n12)*(beta*(0.5*(I(j)+I(j-1)))+(0.5*(u(j)+u(j-1)))); n22 = (lambda1(j)-h2*n11)*(beta*(0.5*(S(j)+S(j-1))))-(lambda2(j)- h2*n12)*(beta*(0.5*(S(j)+S(j-1)))-gamma)-(lambda3(j)-h2*n13)*gamma; n23 = 0; n31 = (lambda1(j)-h2*n21)*(beta*(0.5*(I(j)+I(j-1)))+(0.5*(u(j)+u(j-1))))- (lambda2(j)-h2*n22)*(beta*(0.5*(I(j)+I(j-1)))+(0.5*(u(j)+u(j-1)))); n32 = (lambda1(j)-h2*n21)*(beta*(0.5*(S(j)+S(j-1))))-(lambda2(j)- h2*n22)*(beta*(0.5*(S(j)+S(j-1)))-gamma)-(lambda3(j)-h2*n23)*gamma; n33= 0; n41 = (lambda1(j)-h*n31)*(beta*I(j-1)+u(j-1))-(lambda2(j)-h*n32)*(beta*I(j- 1)+u(j-1)); 104 n42 = (lambda1(j)-h*n31)*(beta*S(j-1))-(lambda2(j)-h*n32)*(beta*S(j-1)- gamma)-(lambda3(j)-h*n33)*gamma; n43 = 0; % here is the 4th order RK for the adjoint variables % note that lambda3 will always be zero lambda1(j-1) = lambda1(j) - (h/6)*(n11 + 2*n21 + 2*n31 + n41); lambda2(j-1) = lambda2(j) - (h/6)*(n12 + 2*n22 + 2*n32 + n42); lambda3(j-1) = lambda3(j) - (h/6)*(n13 + 2*n23 + 2*n33 + n43); end b=100; % weight associated with control: can be varied, making it more expensive or cheaper u1=min(0.1,max((S.*(lambda2-lambda1))/(2*b),0)); % %u1=0.025; u=0.5*(u1 + oldu); % update the value of u: average between the values % u=zeros(1,M+1); % without control % COST FUNCTION: maximize the infected and recovered at the end of the campaign and save costs J= I(M+1)+R(M+1)-trapz(t,b*(u.^2)); % it is a scalar, cost % calculations for the stopping criterion using the old and updated values temp1 = delta*sum(abs(u)) - sum(abs(oldu - u)); temp2 = delta*sum(abs(S)) - sum(abs(oldS - S)); temp3 = delta*sum(abs(I)) - sum(abs(oldI - I)); temp4 = delta*sum(abs(R)) - sum(abs(oldR - R)); temp5 = delta*sum(abs(lambda1)) - sum(abs(oldlambda1 - lambda1)); temp6 = delta*sum(abs(lambda2)) - sum(abs(oldlambda2 - lambda2)); temp7 = delta*sum(abs(lambda3)) - sum(abs(oldlambda3 - lambda3)); test = min(temp1, min(temp2, min(temp3, min(temp4, min(temp5, min(temp6,temp7)))))); end % save the values of the independent variable t, the state variables S, I, R, the control u, and the functional J - all in the matrix y which has 6 rows and M+1 columns y(1,:) = t; % first row of y contains the time y(2,:) = S; % second row of y contains S y(3,:) = I; y(4,:) = R; y(5,:) = u; y(6,:)= J; % printing the state variables S, I, and R figure(1); plot(y(1,:), y(2,:),':b','LineWidth',2);hold on; plot(y(1,:), y(3,:),'.k','LineWidth',2); plot(y(1,:), y(4,:),'-r','LineWidth',2);hold off; xlabel('time (biweeks)') ; title('Perfume Campaign'); legend(['S';'I';'R']); % printing the optimal control figure(2) plot(y(1,:), y(5,:),':b','LineWidth',2); xlabel('time (biweeks)') ; title('Control'); legend('u'); % figure(3) % plot(y(1,:), y(6,:),':b','LineWidth',2); % xlabel('t') ; title('Cost'); end 105 A PPENDIX 9 - R Code (allows for illustrating the fluctuations in views throughout the marketing campaign) # Data weeks < - c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20") views < - c(8.60, 24.76, 9.04, 0.78, 0.62, 0.74, 0.34, 0.32, 0.22, 0.18, 0.13, 0.14, 0.14, 0.13, 0.14, 0.42, 0.19, 0.16, 0.12, 0.10) #Plotting plot(views, type="o", pch=19, col="blue", xlab="Weeks", ylab="Views (in millions)", main="Weekly Views Over Time", xaxt="n") axis(side=1, at=1:length(weeks), labels=weeks, las=2, cex.axis=0.8) grid()