Agentbased models and industrial organization theory. A pricecompetition algorithm for agentbased models based on Game Theory
 Juan Manuel SanchezCartas^{1}Email authorView ORCID ID profile
https://doi.org/10.1186/s4029401800537
© The Author(s) 2018
Received: 5 December 2017
Accepted: 23 February 2018
Published: 12 March 2018
Abstract
Purpose
Simulating markets using agentbased models must consider pricing. However, the strategic nature of prices limits the development of agentbased models with endogenous price competition.
Methods
I propose an agentbased algorithm based on Game Theory that allows us to simulate the pricing in different markets. I test the algorithm in five theoretical economic models from the industrial organization literature.
Results
In all cases, the algorithm is capable of simulating the optimal pricing of those markets. It is also tested in two more cases: one in which the original work fails to predict the optimal outcome, and another one that is quite complex to solve analytically. Lastly, I present two potential extensions of this algorithm: one dynamic, and another one based on quantity competition.
Conclusions
Keywords
Background
Prices play an essential role in any market and understanding how they are fixed is a fundamental part of the Economic Science. However, complex problems such as social networks or the launching of new digital platforms can set new challenges in understanding how those prices are fixed.
To tackle these complex problems, some researchers have adopted the agentbased modeling approach. But, there is a lack of integration between this approach and the industrial organization literature. This lack of integration is clearly depicted by the absence of works that address prices in agentbased models (ABM), despite being considered an essential variable in markets.^{1}
To address this issue, I propose an algorithm for agentbased models that simulates price competition among companies. This algorithm establishes a new link between the industrial organization literature and the agentbased modeling. It is based on Game Theory, and it guarantees the optimality of consumers’ and companies’ behavior without needing to use the equilibrium equations of any theoretical model, nor relying on maximizing (minimizing) any real function.^{2} Intuitively, this algorithm resembles the best response map but without assuming any particular theoretical model or function. The algorithm encompasses two subalgorithms, one for consumers and another one for companies. Both subalgorithms encompass several behavioral rules that are combined to simulate the behavior predicted by Game Theory. In this sense, it is possible to address markets with heterogeneous decisionsmakers, asymmetric information flows and levels, continuous or discontinuous behaviors, etc. and without assuming that decisionmakers carried out complicated mathematical manipulations, and at the same time, it is also possible to guarantee the optimality and rationality of our results.^{3}
We test the algorithm in five different theoretical models, and we prove that the algorithm reproduces the Nash equilibria of those models. We also consider two extended versions of two theoretical models that are quite complex to solve. We prove that the algorithm also works in those cases. Lastly, we consider two more cases. The first one is dynamic, and the second one is based on quantity competition. In those two cases, we show that the algorithm is easily adaptable to other frameworks that are not static pricecompetition games.
This work does not pretend to provide groundbreaking evidence that agentbased models are better than other alternatives. We only try to establish a bridge between agentbased modeling and the mainstream industrial organization literature. And to do so, we apply the agentbase modeling to wellknown theoretical models.
Agentbased models and economic theory. An ongoing issue
The situation of agentbased models in Economics can be summarized as follows: Despite the power of ABM, widespread acceptance and publication of this method in the highestlevel journals has been slow. This is due in large part to the lack of commonly accepted standards of how to use ABM rigorously, Rand and Rust (2011). This problem is not new, but although some advances are taking place, there is plenty of room for improvement.

They rely on the equilibrium equations of the theoretical models, so the simulated markets are constrained by the theoretical assumptions.

They tend to assume other interactions among the agents even when the equilibrium of the theoretical model does not consider such interactions, which if taken into account, may change the equilibrium. Therefore, there is no standard rule or procedure to consider how to implement such theoretical frameworks.
Rixen and Weigand (2014) analyzes the diffusion of smart meters and, although they try to relax some assumptions, they remain constrained by the Cournot model. Lastly, Hamill and Gilbert (2016) shows how Cournot models can be simulated using agentbased models, but it relies on the equilibrium outcomes of the basic Cournot model as in the previous works. There are also other works which do not assume theoretical frameworks, but assume exogenous and nonoptimal prices such as Fuks and Kawa (2009), Zhang and Brorsen (2011) or Diao et al. (2011). To the best of our knowledge, only Leeuwen and Lijesen (2016) has considered a market with endogenous price competition but, it is limited to a Hotelling model, it is designed adhoc, it cannot be applied to other cases, it makes small but systematic errors when predicting prices, and it is not efficient when there are many consumers or companies.

Can theoretical models be simulated following a set of standard rules?

Can price competition be implemented in agentbased models following a set of common rules in concordance with Game Theory and economic intuitions?
Experimental: the pricecompetition algorithm. Applications to theoretical models
The algorithm
The algorithm is designed in a modular way. In this sense, each part of it can be used in different contexts and for different purposes. It consists in two subalgorithms: The consumers’ and the companies’ algorithm. The consumers’ reproduces the buying decisions of consumers and allows us to generate demands. The companies’ subalgorithm reproduces the process by which companies choose the price levels. The continuous interaction of both leads us to the equilibrium (or equilibria).
The consumers’ algorithm

Its modularity. This algorithm can be used independently of the price competition.

We do not impose any demand function, the demands are the emergent result of the consumers’ decisions. It only matters how consumers make decisions.

Consumers make decisions based on their utility functions, which can be discrete or continuous and have as many parameters as necessary. However, those functions are flexible, and each consumer has its own utility function. That implies the possibility of introducing multidimensional heterogeneity, externalities, etc. Also, we do not impose fixed utility functions, those utilities can be dynamic.

Although we assume perfect information throughout the paper, the algorithm can be adapted to deal with those cases in which information is not perfect. For example, we can assume there is a network that connects consumers and by which information flows.
The companies’ algorithm
 1.
In the first algorithm, each company considers a change in prices (increase or decrease). The parameter \(\epsilon\) controls this change (iteration parameter). The algorithm requires a starting price that can be any real number.^{7}
 2.
In the second, each company considers how that change in prices will affect the demands. To estimate the impact of that change in the demands, they estimate the change in the utilities taking other companies’ prices as given. Because all consumers compare the utility that each company’s product provides them, the price decisions of companies influence the other companies. If we assume that all companies are rational and fullyinformed. They will perfectly forecast the decision of consumers.^{8} Nonetheless, the algorithm can consider other assumptions about how companies make their decisions.
 3.
The third algorithm is an optional one. It is designed to control externalities such as direct and indirect network effects. It addresses the case in which the change in prices affects the decisions of other consumers that, at the same time, influences other consumers and so on. In some cases, when a company changes their prices, that decision attracts other consumers that, at the same time, attract more consumers and so on. This algorithm simulates these feedback loops until this effect disappears (convergent feedback loops or the attraction of all the consumers).
 4.
Companies compare the three actions: increase, decrease or maintain the prices, and they choose the most profitable one.
Theoretical frameworks
To prove that the proposed algorithm is capable of reproducing theoretical models, we need to apply it in several frameworks. We choose five theoretical economic models. All of them share only one feature: companies compete in prices for consumers. This framework only requires knowing the utility functions, so we will not solve those models analytically. However, we provide references to those theoretical models. All the assumptions made in the following sections are the original assumptions of the models. Some of them are very restrictive, but those models are very well known in Economics, and it is easier to prove the algorithm in an environment that is wellknown. Later, we will show how the algorithm is capable of dealing with those models but relaxing some of their assumptions.
Horizontal differentiation: the Hotelling framework
To guarantee that all consumers buy at least one platform, the theoretical model assumes that all consumers have an identical (and sufficiently high) reservation value, \(c^{u}\). Lastly, we assume each company sells a product that has an exogenous quality level \(q_{j}\), and they fix a price \(p_{j}\).
Vertical differentiation model
We make two extra assumptions that are common in literature to guarantee enough differentiated consumers and a covered market respectively:
Assumption 1
\(\overline{\theta } \ge 2 \underline{\theta }\)
Assumption 2
\(\frac{(\overline{\theta }  2 \underline{\theta })}{3} (q_{1}q_{2})\le \underline{\theta }q_{1}\)
The intuition of the vertical differentiation is the following: at the same level of prices, all consumers prefer one company over the rest. For example, at the same price, all consumers prefer a Ferrari over a Fiat.
Externalities: twosided markets
The second model is proposed by Gabszewicz and Wauthy (2004), which is another example of twosided markets. However, it has two interesting features: first, it presents vertical differentiation. This characteristic is unusual among the twosided market literature, mainly because it generates multiple equilibria. Second, there is no information about the stability of the equilibria, so we have the opportunity to test the algorithm in an environment in which several potential equilibria are possible.
In the original work, the authors assume that \(\theta ,\gamma ,v\tfrac{e}{j},x\tfrac{e}{j} \in [0,1]\), in other words, they assume a normalized market.
Warranties model

There is a unit mass of homogeneous consumers

There are two firms. A highquality one (\(\lambda _{1}\)) and a lowquality one (\(\lambda _{2}\)). Therefore, \(\lambda _{1}>\lambda _{2}\)

Consumers do not know the quality of each company

Both companies have constant marginal costs, c.
Results and simulation tests
We create a world with 314 consumers (in the case of the market with twosided platforms, there are 628 consumers divided into two groups: users and developers, or visitors and exhibitors) and two companies. We run one thousand simulations for each case in NetLogo. In all those cases, we compare the theoretical and the simulated equilibria. We consider two \(\varepsilon\)values, 0.1 and 0.05. For each case, we only consider a set of parameters values, for example, different transportation costs or quality levels, etc. to show how the algorithm is capable of reaching the theoretical equilibria. We can consider other cases with other parameters but, for simplicity’s sake and without loss of generality, they are not included (although they are available upon request).^{16}
Horizontal differentiation: the Hotelling framework
We run the simulations considering different transportation costs and with symmetric quality levels (\(q_{1}=q_{2}\)). As depicted in Fig. 3, depending on what \(\varepsilon\)values we assume, we obtain different simulated prices that reproduce the theoretical prices properly.^{17}
Hotelling model
Variable  Coefficient (std. err.) 

(a) Hotelling, Iteration 0.1  
Simulated price  1.0459** (0.0073) 
N  90 
R^{2}  0.9957 
F \(_{(1,89)}\)  20,558.99 
(b) Hotelling, Iteration 0.05  
Simulated price  0.9821** (0.005) 
N  90 
R\(^{2}\)  0.9977 
F \(_{(1,89)}\)  38,519.85 
Let’s consider the difference between theoretical and simulated prices. We test if those errors are normally distributed. To do so, we consider three normality test, all of them assume the null hypothesis of normality.
Hotelling. Normality tests
\(\varepsilon\)/pvalues  Skewness and kurtosis test  Shapiro–Wilk test  Shapiro–Francia test 

0.10  0.0205  0.09909  0.60196 
0.05  0.0000  0.0000  0.001 
In Table 2, we observe the pvalues associated with those tests. Let’s consider first the case in which \(\varepsilon =0.1\). In this case, at 95% confidence level, only in the D’Agostino’s Ksquared test we can reject the null hypothesis of normality. It is reasonable to think that errors are normally distributed and therefore, the average (− 0.036) is a good representation of the simulations errors. In this case, it is an underestimation of 3.6%. However, given that the algorithm works considering 10% of change in prices (\(\varepsilon =0.1\)), this error is negligible.
On the other hand, when \(\varepsilon = 0.05\), all the tests suggest that the difference between simulated and theoretical prices is not normal. We run a variancecomparison test, and we find that, at 99% confidence level, the standard deviations between the cases with transportation costs in the interval [0.1;0.59] and in the interval [0.60;0.99] have different variances. Given that each simulation for each parameter is independent of the rest, we can analyze both subsamples separately. The first one considers transportation costs between 0.1 and 0.59 and the other one between 0.60 and 0.99. In those intervals, at 95% confidence level, we cannot reject the null hypothesis of equal variance.
Hotelling model, Iteration at 0.05
Intervals  Skewness and kurtosis test  Shapiro–Wilk test  Shapiro–Francia test 

[0.1;0.59]  0.5595  0.23156  0.86565 
[0.60;0.99]  0.2468  0.67779  0.68322 
Vertical differentiation model
Vertical differentiation model
Variable  Coefficient (std. err.) 

(a) Iteration 0.1  
Simulated price  1.0385** (0.0104) 
N  85 
R\(^{2}\)  0.9917 
F \(_{(1,84)}\)  10066.75 
(b) Iteration 0.05  
Simulated price  1.0314 ** (0.0054) 
N  85 
R\(^{2}\)  0.9977 
F \(_{(1,84)}\)  36883.17 
Vertical differentiation. Normality tests
\(\varepsilon\)  Skewness and kurtosis test  Shapiro–Wilk test  Shapiro–Francia test 

0.1  0.3097  0.77471  0.94308 
0.05  0.2197  0.22636  0.24974 
In Table 5, we observe that all the normality tests point out that, at 95% confidence level, we cannot reject the null hypothesis of normality. Therefore, the average of the errors can be interpreted as the average error of the algorithm in this model. In this case, the algorithm yields an average error of − 1.5% (− 0.015) when \(\varepsilon =0.1\) and 1% (0.01) when \(\varepsilon =0.05\). Nonetheless, the algorithm considers changes in prices of 10 and 5% respectively, so these errors are negligible.
In this model, demands are not equal. In contrast with the rest of the models, companies will not equally share the market. Nonetheless, the algorithm is also capable of simulating demands. In Fig. 5, we observe demands are well reproduced at the beginning, but there are divergences at highquality levels. This effect depends on the \(\varepsilon\) we assume, and it is exclusive of vertically differentiated models.
Vertical differentiation. Normality tests. Demands
\(\varepsilon\) (\(\Delta\))  Skewness and kurtosis test  Shapiro–Wilk test  Shapiro–Francia test 

0.1(0.14)  0.0037 (0.0674)  0.00000 (0.13764)  0.00001 (0.07698) 
0.05(0.09)  0.0009 (0.0396)  0.00001 (0.09888)  0.00002 (0.04154) 
0.01 (0.05)  0.000 (0.6848)  0.00000 (0.69446)  0.00001 (0.55921) 
Vertical differentiation models. Demands
Variable  Coefficient (std. err.) 

(a) Iteration 0.1  
Simulated demand  0.9556** (0.0231) 
N  85 
R\(^{2}\)  0.9534 
F \(_{(1,84)}\)  1717.66 
(b) Iteration 0.05  
Simulated demand  0.9850** (0.0165) 
N  85 
R\(^{2}\)  0.9771 
F \(_{(1,84)}\)  3585.43 
(c) Iteration 0.01  
Simulated demand  0.9987** (0.0067) 
N  85 
R\(^{2}\)  0.9962 
F \(_{(1,84)}\)  22024.81 
In contrast with the previous case, the lower the \(\varepsilon\), the more accurate are the simulated prices and demands in all cases. Figure 6 depicts the comparison between the cases in which \(\varepsilon = 0.05\), \(\varepsilon = 0.1\) and \(\varepsilon =0.01\).
Externalities: twosided markets
Hagiu and Halaburda’s model
This model considers that two platforms compete in prices for consumers (users and developers). Consumers value the presence of the other group so, the more, the better. For simplicity’s sake and without loss of generality, we assume both sides are symmetrical, and we only analyze one of them, in this case, we focus on users. We run simulations considering different transportation costs. In Fig. 7, we observe that the simulated and theoretical prices behave in a similar way. As in the previous cases, the simulated prices reproduce the theoretical ones properly.^{19}
Hagiu and Halaburda’s model
Variable  Coefficient (std. err.) 

(a) Twosided, Iteration 0.1  
Simulated price  0.9924** (0.0068) 
N  90 
R\(^{2}\)  0.9959 
F \(_{(1,88)}\)  21,373.90 
(b) Twosided, Iteration 0.05  
Simulated price  0.9201** (0.0055) 
N  90 
R\(^{2}\)  0.9968 
F \(_{(1,88)}\)  27,492.02 
In Table 9, we analyze the differences between the simulated and the theoretical prices. We observe that when \(\varepsilon =0.1\) and at 95% confidence level, we cannot reject the null hypothesis of normality. On the other hand, given that the average is approximately zero, we can state that, in this case, the algorithm makes no error. However, when we consider \(\varepsilon =0.05\), we can reject the null hypothesis of normality at 99% confidence level. However, this rejection is a consequence of an unusual behavior at high transportation costs. When transportation costs are higher than 0.9, simulated prices show great differences with theoretical prices as depicted in Fig. 7.
Hagiu and Halaburda's model. Normality tests
\(\varepsilon\)  Skewness and kurtosis test  Shapiro–Wilk test  Shapiro–Francia test 

0.1  0.2179  0.14804  0.77307 
0.05  0.0000 (0.2568)  0.0000 (0.3255)  0.0000 (0.4511) 
Gabszewicz and Wauthy’s model
In contrast with the previous model, the Gabszewicz and Wauthy’s model^{20} considers vertical differentiation between the platforms. However, this is not the only difference. The essential difference is that this model presents three different equilibria in the duopolistic framework. These equilibria are also different than the previous ones. They do not depend on parameters values. Each priceequilibrium is defined by constant prices and demands. Table 10 shows the different equilibria found by Gabszewicz and Wauthy. However, some of those equilibria are not stable, and the simulations are affected by this feature.
Gabszewicz and Wauthy’s equilibria
Equilibria  Prices  Demands  Profits 

Duopolistic equilibrium  \(p_{1}=\pi _{1}=2/49\) \(p_{2}=\pi _{2}=8/49\)  \(x_{1}=v_{1}=2/7\) \(x_{2}=v_{2}=4/7\)  \(\Pi _{1}=0.0233\) \(\Pi _{2}=0.1866\) 
Monopoly corner eq.  \(p_{1}=0, \pi _{1}=1/2\)  \(x_{1}=1,v_{1}=1/2\)  \(\Pi =1/4\) 
Monopoly equilibrium  \(p_{1}=\pi _{1}=1/2\)  \(x_{1}=v_{1}=1/2\)  \(\Pi =1/4\) 
In this case, the theoretical equilibrium is a constant value, so we present in Table 11 the simulation results with different \(\epsilon\)values and the theoretical equilibrium values. As we stated in the "Vertical differentiation model" section, the vertical differentiation can have dramatic effects on the equilibrium because it may lead to big changes. In the case of indirect network effects and vertical differentiation, those changes can be even more dramatic. For example, when \(\epsilon = 0.01\) or \(\epsilon =0.005\) the model collapses to the Bertrand equilibrium (which is another possibility considered by the authors). This result is a consequence of the extreme sensitivity of the model to changes, and the existence of several equilibria.
Prices, demands and profits. Simulation of Gabszewicz and Wauthy’s model
Equilibria  Passive beliefs  Responsive beliefs 

\(\epsilon = 0.1\)  \(P=x=\Pi =0\)  \(P=0.21\) \(x=0.698\) \(\Pi =0.293\) 
\(\epsilon = 0.05\)  \(P=x=\Pi =0\)  \(P=0.21\) \(x=0.647\) \(\Pi =0.291\) 
\(\epsilon = 0.01\)  \(P=x=\Pi =0\)  \(P=0.24\) \(x=0.599\) \(\Pi =0.287\) 
\(\epsilon = 0.005\)  \(P=x=\Pi =0\)  \(P=0.22\) \(x=0.672\) \(\Pi =0.296\) 
\(\epsilon = 0.001\)  \(P=0.215\) \(x=0.685\) \(\Pi =0.294\)  \(P=0.136\) \(x=0.8375\) \(\Pi =0.228\) 
Warranties model
In Fig. 8, we depict the theoretical prices and the average simulated ones with different values of \(\lambda _{1}.\) In Fig. 9, we observe the theoretical price and two simulated prices during the first 50 iterations. In this model, prices are not always stable at a specific point, but they oscillate around that point. This oscillating pattern is due to the discrete nature of the algorithm, that is applied in a continuous environment that is quite sensitive to small changes.
To test if simulated prices are able to reproduce the theoretical prices accurately, we run a linear regression in which the dependent variable is the theoretical price, and the explanatory variable is the simulated one. In Table 1, we observe that, in both cases, the rsquared is around 99%, so our simulated prices are able to explain 99% of the variations in theoretical prices. Nonetheless, in this case, we have seven observations only, so we cannot test the normality of these cases properly.^{24} However, Figs. 8 and 9 leave little room for doubt that the algorithm is capable of simulating the theoretical optimal prices.
Warranties model
Variable  Coefficient (std. err.) 

(a) Warranties, Iteration 0.1  
Simulated price  0.9756\(^{**}\) (0.0111) 
N  7 
R\(^{2}\)  0.9992 
F \(_{(1,6)}\)  7621.27 
(b) Warranties, Iteration 0.05  
Simulated price  0.9304\(^{**}\) (0.008) 
N  7 
R\(^{2}\)  0.9996 
F \(_{(1,6)}\)  14,831.19 
Relaxation of assumptions and extensions. New directions in agentbased modeling
Up to now, we have considered the theoretical models under their original assumptions. However, we can use the algorithm to address cases in which some assumptions are relaxed or even cases that are out of the reach of theoretical models. For instance, we can consider the market is not covered, utility functions are not linear, users are distributed following a normal, an exponential, or any other distribution, etc. In all of those cases, the algorithm works properly. We can even include new layers of complexity by assuming more than two companies, or by assuming that users are heterogeneous in several dimensions. In this section, we consider two different cases in which we relax such assumptions.
First, we simulate the Hagiu and Halaburda’s model presented in "Hagiu and Halaburda’s model" section, but this time we test the model outside of the parameter region defined by the authors. What is relevant about that region is that the theoretical model predicts negative profits, which is not realistic because platforms will prefer to fix zero prices in both sides than to lose money.
Second, we simulate the Hoteling’s model presented in "Horizontal differentiation: the Hotelling framework" section, but this time we assume that not all the consumers enter the market at the same time. In fact, we assume that there is diffusion of information process that determines who enters the market and when.
Lastly, we briefly show how this algorithm can address other theoretical models in the industrial organization literature that are based on quantity competition or consider a twostage competition (dynamic frameworks). I consider those models as extensions of the price competition algorithm, but not as extensions of the other theoretical frameworks.
Relaxed assumptions: Hagiu and Halaburda’s model
One of the assumptions of this model to guarantee that “all optimization problems with competing platforms are wellbehaved” is \(t^2>\delta ^{2}\), Eq. 3. If we assume this condition does not hold, the theoretical model predicts negative profits. Obviously, this is not optimal because a better option is to fix zero prices or to abandon the market, which guarantees zero profits.
Comparison between theoretical and simulated models when conditions regarding the “well behavior” of equilibria are relaxed
Variables/cases  Starting price  Deltas  Transportation costs  Equilibrium prices users (developers)  Equilibrium profits 

Simulated case  0.25  0.65  0.15  − 0.05 (0.15)  0.05 
− 0.05  0.65  0.15  0.05  0.05  
− 0.05  0.8  0.4  0.05 (− 0.05)  0  
Theoretical case  0.65  0.15  − 0.5  − 0.5  
0.8  0.4  − 0.4  − 0.4 
Relaxed assumptions: Hotelling’s model
This case represents a Hotelling model in which consumers are entering the market in a nonrandom way. We assume that only a small percentage of consumers can enter the market in the first iteration (all of them are less than one node away from one another). Then, those consumers can transmit the information about the product they consume to others neighbors in their networks in the following iterations.^{27} For simplicity’s sake, we assume that users are linked in a random network. We assume there are two companies, and consumers can be in one of these states: uninformed, totally informed or partly informed about one company. In other words, this case mixes the spread of information in a network with two pricecompeting companies trying to attract consumers.^{28}
On the left side of Fig. 10, simulations show that prices are more volatile. This behavior is normal because new users are entering the market at each moment. Companies try to adjust prices to the expansion of the market, but companies are also competing, so they try to reduce prices. Prices only reach a stable position in the case with low differentiation because the competition is stronger than the expansion effect (new users).
On the right side of Fig. 10, simulations show the case with low differentiation is the only one that reaches a point where adoption is not growing anymore (the expansion effect is over, almost all the potential consumers are attracted). However, the other two cases are so volatile because the spread of information is less regular and slower than before.
We can observe too that high prices are a barrier that blocks other users from becoming consumers, which limits the adoption. When prices are high, some users do not consume the products although they know them. This limit the spread of information which leads to stopping the diffusion. On the other hand, users only know about the individual products, so there are cases in which users are only aware of one product and, because information initially spreads from clusters, there will be clusters that will never know about the existence of other companies. In this situation, there is volatility in prices and adoption because there is a tradeoff between rising prices (because of the differentiation levels and larger profits) and reducing prices (because of the competition between platforms and the boosting effect that it has on the demands).
Extension 1: the perfect competition framework. Competition in quantities
Consumers choices. Perfect Competition
Parameter values at a = 1  Quantities consumed  Parameter values at a = 1  Quantities consumed 

d = 0; b = 1  \(q_{1}=q_{2}=1\)  d = 0.7; b = 1  \(q_{1}=1\) or \(q_{1}=0\) \(q_{2}=0\) or \(q_{2}=1\) 
d = b  \(q_{1}=1\) or \(q_{1}=0\) \(q_{2}=0\) or \(q_{2}=1\)  d = 0.7; b = 0  \(q_{1}=q_{2}=1\) 
d = − 1; b = 0  \(q_{1}=q_{2}=1\)  d = 0.1; b = 1  \(q_{1}=q_{2}=1\) 
d = − 1; b = 1  \(q_{1}=q_{2}=1\)  d = 0.2; b = 1  \(q_{1}=q_{2}=1\) 
For example, when \(d=0\) and \(b=1\), it is optimal for consumers to buy products from both companies. So, both companies will produce enough products for all the consumers. But when \(d=b\), consumers only demand one product, and only one company will produce it.
Extension 2: Milgrom–Roberts Models of barriers to entry
The algorithm is flexible, and it can deal with dynamic frameworks. To test this statement, we chose the Milgrom–Roberts model.^{31} The model assumes two stages: At the first stage, there is a monopoly that produces a good with a marginal cost that may be high \(c_{h}\) or low \(c_{l}\). The information about the cost is not available outside of the monopoly. At the second stage, an entrant has the opportunity to enter the market. However, his/her decision of entering depends on the marginal cost of the incumbent and on its own marginal costs \(c_{e}\). If the cost of the incumbent is high, the entrant will have positive profits; if the cost is low, the entrant will have negative profits.

Competition: if both have low costs and profits are nonnegative.

Expulsion: the incumbent will be expelled from the market
Milgrom–Roberts model
Parameters values when \(c_{incumbent}=c_{h}\)  Market outcome  Parameters values when \(c_{incumbent}=c_{l}\)  Market outcome 

\(c_{l} = 0.1\); \(c_{h}=0.84\) \(c_{e} = 0.1\)  Incumbent is expelled  \(c_{l} = 0.1\); \(c_{h}=0.84\) \(c_{e} = 0.1\)  Duopoly competition 
\(c_{l} = 0.1\); \(c_{h}=0.84\) \(c_{e} = 0.2\)  Incumbent is expelled  \(c_{l} = 0.3\); \(c_{h}=0.84\) \(c_{e} = 0.1\)  Incumbent is expelled 
\(c_{l} = 0.1\); \(c_{h}=0.84\) \(c_{e} > 0.2\)  Block to entry  \(c_{l} = 0.1\); \(c_{h}=0.84\) \(c_{e} > 0.2\)  Block to entry 
Discussion. Similarities and dissimilarities between the algorithm and other approaches
The proposed algorithm resembles the optimization programs that are used in Economic Theory or Game Theory. In these cases, it is common to compute an optimization program from which the first and second order conditions are derived to identify the reaction functions and the equilibria. The algorithm is closely related to the idea of reaction functions. However, there are relevant similarities and differences. On the one hand, the algorithm acts in a similar way than reaction functions; the output of both is the best reply to a specific situation, and the continuous interaction of reaction functions or agents with the algorithm leads to the Nash equilibria. If it does not exist, the algorithm can find corner solutions or second best equilibria.^{33}

First, the algorithm does not provide a stylized expression that represents the equilibria. It computes a numerical one.

Second, tractability is not an issue. Traditionally, researchers assume some assumptions like linear demands, constant values, continuity of functions, concave profits functions, etc. that may not be realistic. This is done to guarantee tractability and wellbehaved equilibria. However, that is not necessary with the algorithm. If there is no equilibrium, the algorithm chooses a secondbest solution (one which produces the most favorable outcome for the agent, taking other agents’ strategies as given). In some cases, several secondbest solutions can be found, in such cases, the algorithm may pivot from one to another. But, if the equilibrium is global, the algorithm will prove that by showing always the same outcome.

Third, we do not assume continuity or differentiability. The algorithm is discrete, and it approximates a continuous environment.
Nonetheless, some researchers may argue that the algorithm is not different than solving the model numerically. However, this is not true. To solve a model numerically requires solving the theoretical model analytically in advance in most of the cases,^{34} but with this algorithm, that is not necessary. The algorithm does not assume that agents make complicated mathematical manipulations. It consists of simple actions (consumers make their best decision, the one that maximizes their utility: buy one of the product or not; and companies increase, decrease or maintain prices, what it is more profitable at each time), and we prove that, with those simple actions, the theoretical equilibria predicted by many theoretical models can be reached.
I am not the first one in considering theoretical models for agentbased simulations. But this is the first time that an algorithm reproduces the optimizing behavior of agents like in theoretical economic models. So, it is possible to build agentbased models that are closely linked to traditional economics by using economic intuitions. I do not pretend to present the agentbased modeling as an alternative to the traditional industrial organization literature. Instead, this work presents the agentbased modeling as a complement of that literature. If we can agree that the rules presented in "The algorithm" section represent the same rules that we take as given (or we assume) in the consumer’s and company’s decision problems. Then, we can agree that the algorithm is a representation of the process of maximization of utility (profits) of users (and companies).
Nonetheless, the algorithm I propose is also criticizable. It is a tool designed to look for local equilibria. So, to address global equilibria, it requires different starting points, different number of iterations or even different discrete “jumps (ε)” in prices. If not, we are at risk of identifying local optima that are not the global ones.
Conclusions
We develop an algorithm for agentbased models that simulates the behavior of pricecompeting companies. This algorithm considers two subalgorithms: one for consumers, and another one for companies. The consumers’ algorithm specifies that all users will choose that product that provides them with the highest utility. The companies’ algorithm specifies that each company will change its prices by a small quantity if they believe that such change is profitable.
We test the pricecompetition algorithm in several theoretical frameworks such as the Hotelling model, a vertical differentiation model or a twosided market. In all of them, we prove the algorithm is capable of reaching the equilibria predicted by theory. We also prove that the algorithm works in cases that were not considered by theory, or in parameter regions where the theoretical model was not suitable to be analyzed. These results open the door to implementing endogenous pricing in agentbased models but also, to test theoretical models in a new environment or even to teach theoretical models in a new way.
We conclude with a discussion of the current limitations of this research, and how this line of research is related to other approaches used in the Economic literature.
In the current agentbased [literature] [...] research on the price, the most important attribute of a product, are very rare, Diao et al. (2011).
It works in both, discrete and continuous frameworks. If the optimum exists, the algorithm can identify it. If it does not exist, the algorithm chooses a secondbest solution that maximizes the utility (profits) of users (companies) given the actions of companies (users) in the local area.
We define a rational agent as the one who makes those choices that maximize their subjective utility given a specific set of information.
In this work, we consider only microeconomic models because they tend to be simpler in the number of relationships they take into account than macroeconomic models.
The pseudocode is available in the Annex. The consumer’s algorithm corresponds to the first two subalgorithms of the “Static situation of the market”, i.e. utilities and demands.
There is no range of prices previously fixed. The prices are free to vary, but it is important which is the initial price that we choose. It is recommendable to try several different prices with the only condition of not being so high that all the utilities are negative.
This opens a discussion about how the algorithm tackles the convergence, but as long as this algorithm resembles the best response map of price competing markets, the convergence towards the equilibrium is similar to the one expected using Bertrand’s Intuition or Paradox, [Tirole and Matutes (1990), Chapter 5].
The model predicts that only the highquality company will be willing to introduce the warranties.
The number of users and developers is arbitrarily selected, other numbers can be considered and conclusions will not change.
Technically, they will be indifferent, but we can only observe one reality, in this case, we assume it is the abandon.
This makes sense because of the vertical differentiation. The network effects are so strong that there is an incentive towards concentration in only one platform.
Nonetheless, the code and the software to simulate both cases are available at: https://goo.gl/zFvY7t.
We have only seven observation because we are working with the averages of simulated prices. The only test that we can properly run is the Wilk test and, in both cases, at 95% confidence level, we cannot reject the null hypothesis of normality.
Consumers only spread the information if they consume the product. In some cases, they may have the information but they do not spread it to their neighbors because they do not consume the product because their utility functions are negative at those prices. But, if they consume, they can “infect” their neighbors with the information about the product they consume (14% chance).
We acknowledge that the whole process is not explained in a conscientious way. However, this case is further analyzed in SanchezCartas and Leon (2017). We present this case only for illustrative purposes.
Simply computation with the parameter values and the utility function prove this point. The model can be downloaded at https://goo.gl/bjDP5E.
This model is an adaptation of Milgrom and Roberts (1982) that can be found in [Tirole and Matutes (1990), Chapter 9]. Code at https://goo.gl/djiCWh.
The Milgrom–Roberts model presents two different equilibria that are based on different assumptions. In contrast, the Gabszewicz and Wauthy’s model has multiple equilibria under the same assumptions.
For example, in a Cournot model, the equilibrium can be reached using the reaction functions only. Those functions also reproduce an interactive behavior among companies that leads to the equilibrium. The algorithm works in a similar way.
We can argue that some models cannot be solved analytically, and it is required solving them numerically. But that is not the point here. We argue that even such models require a previous theoretical work, in which optimization programs are defined, and some expressions are derived.
Declarations
Authors’ contributions
JMS designed the algorithm, tested it, and drafted the manuscript. The author read and approved the final manuscript.
Competing interests
The author declares that he has no competing interests.
Acknowledgements
I appreciate the helpful comments and advice on this research supplied by the participants at the 23rd International Conference in Computing in Economics and Finance and at the 15th International Conference on Practical Applications of Agents and MultiAgent Systems. I also want to stress my appreciation for the helpful comments of two anonymous reviewers that have significantly improved the final paper.
Consent for publication
Not applicable.
Ethics approval and consent to participate
Not applicable.
Funding
Not applicable.
Publisher’s Note
Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Open AccessThis article is distributed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/), which permits unrestricted use, distribution, and reproduction in any medium, provided you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license, and indicate if changes were made.
Authors’ Affiliations
References
 Barr J, Saraceno F (2005) Cournot competition, organization and learning. J Econ Dyn Control 29(1):277–295MathSciNetView ArticleMATHGoogle Scholar
 Belleflamme P, Peitz M (2015) Industrial Organization: Markets and Strategies. Cambridge University Press, University Printing House, CambridgeGoogle Scholar
 Chang MH (2011) Entry, exit, and the endogenous market structure in technologically turbulent industries. East Econ J 37(1):51–84View ArticleGoogle Scholar
 Diao J, Zhu K, Gao Y (2011) Agentbased simulation of durables dynamic pricing. Syst Eng Proc 2:205–212View ArticleGoogle Scholar
 Fuks K, Kawa A (2009) Simulation of resource acquisition by esourcing clusters using netlogo environment. In: KES international symposium on agent and multiagent systems: technologies and applications. Springer, Berlin. pp 687– 696Google Scholar
 Gabszewicz JJ, Wauthy X (2004) Twosided markets and price competition with multihoming. CORE Discussion Paper no 2004/30Google Scholar
 Hagiu A, Hałaburda H (2014) Information and twosided platform profits. Int J Ind Organ 34:25–35View ArticleGoogle Scholar
 Hamill L, Gilbert N (2016) Agentbased modelling in economics. Wiley, ChichesterGoogle Scholar
 Mbah AK, Paothong A (2015) Shapiro–Francia test compared to other normality test using expected pvalue. J Stat Comput Simul 85(15):3002–3016MathSciNetView ArticleGoogle Scholar
 Milgrom P, Roberts J (1982) Limit pricing and entry under incomplete information: an equilibrium analysis. Econometrica J Econ Soc 50(2):443–459Google Scholar
 Rand W, Rust RT (2011) Agentbased modeling in marketing: guidelines for rigor. Int J Res Mark 28(3):181–193View ArticleGoogle Scholar
 Rixen M, Weigand J (2014) Agentbased simulation of policy induced diffusion of smart meters. Technol Forecast Soc Change 85:153–167View ArticleGoogle Scholar
 SanchezCartas JM, Leon G (2017) On simulating the adoption of new products in markets with rational users and companies. In: International conference on practical applications of agents and multiagent systems. Springer, Berlin. pp 83– 94Google Scholar
 Tirole J, Matutes C (1990) La Teoría de la Organización Industrial, 1st edn. Ariel, BarcelonaGoogle Scholar
 van Leeuwen E, Lijesen M (2016) Agents playing hotelling’s game: an agentbased approach to a game theoretic model. Ann Reg Sci 57(2–3):393–411View ArticleGoogle Scholar
 Zhang T, Brorsen BW (2011) Oligopoly firms with quantityprice strategic decisions. J Econ Inter Coord 6(2):157–170View ArticleGoogle Scholar