Inventorymodel: an R Package for Centralized Inventory Problems

Inventory management of goods is an integral part of logistics systems; common to various economic sectors such as industry, agriculture and trade; and independent of production volume. In general, as companies seek to minimize economic losses, studies on problems of multi-agent inventory have increased in recent years. A multi-agent inventory problem is a situation in which several agents face individual inventory problems and agree to coordinate their orders with the objective of reducing their costs. The R package Inventorymodel allows the determination of both the optimal policy for some inventory situations with deterministic demands and the allocation of costs from a game-theoretic perspective. The required calculations may be computed for any number of agents although the computational complexity of this class of problems when the involved agents enlarge is not reduced. In this work, the different possibilities that the package offers are described and some examples of usage are also demonstrated.

Alejandro Saavedra-Nieves (Departamento de Estatística e Investigación Operativa, Universidade de Vigo)
2018-05-21

1 Introduction

Often, once a product is chosen to be acquired, the seller advises that he or she does not have a unit of that product in stock. Probably, this vendor has not managed the storage of this commodity efficiently since the possibility of not being able to satisfy the demand for a product in time leads to shortages. Specific techniques may prevent situations such as this, allowing for reduction in economic losses associated with the lack of products.

Inventory is defined as the amount of goods stored by a company at a moment of time, which represents a capital investment for the purchase and maintenance of the product in stock. Each company desires having the proper inventory level to meet the needs of customers, and so they would prefer to handle it optimally. Inventory theory focuses on the design and optimization of production systems to minimize economic losses due to product shortages. However, this implies the existence of extra costs associated with different assumptions imposed on the model with an influence on the overall cost of the procedure. The consideration of the holding cost or variable cost for the transportation of a new order from a supplier to the warehouse are examples, among others, of new conditions to take into account in the models. Generally, this study focuses on a single product with fixed characteristics that companies need. Moreover, it presents new inventory situations in which a customer can switch to another supplier to get the desired product or an analogous product with similar properties. So, in an inventory system, the following must be considered:

The main goal entails determining the optimal amount of product to request and the moment in which it is requested. The balance between quantity and the number of orders is essential. Not following the optimal policy implies that fewer orders than necessary are placed or that they are placed more frequently than usual, and hence the cost of the procedure increases.

Usually, we talk about inventory management for a single company, with a single decision determining the amount required depending on the demand or, for instance, the moment in which that order must be placed. Although individually, such inventory models totally ignore the decisions made by other agents in the same circumstances, it is possible to consider situations wherein they cooperate. Sometimes, in order to obtain savings, it is possible to consider the joint action of several individuals who, independently, would face situations of inventory management of a product as described.

In a centralized inventory problem, several agents who face individual inventory problems decide to coordinate their orders to reduce costs. The determination of the optimal level of inventory involves:

  1. formulation of an appropriate mathematical model that describes the situation of inventory (shortages, transportation costs, holding costs, etc.),

  2. identification of the optimal policy under the cooperation of a group of individuals, and

  3. allocation of the incurred costs among the involved agents by using, for instance, game theoretic procedures.

The analysis of cooperative multi-agent inventory problems has received much attention in recent years. The most basic models, the Economic Order Quantity (EOQ) model and the Economic Production Quantity (EPQ) model, are introduced in (Meca et al. 2003) for the cooperative case, using the Share the Ordering Costs rule (SOC rule) as a procedure to obtain allocations with interesting properties. However, other inventory problems have been treated in the literature under this approach, including those detailed below. In (Fiestras-Janeiro et al. 2012), the inventory transportation systems are defined as a new approach of the EOQ problem when individual transportation costs by a new order are taken into account. The line-rule allows us to allocate the costs generated by the joint order in these situations. This model is generalized in (Saavedra-Nieves et al. 2018), where a general function of transportation costs is considered and an extension of the line-rule is proposed. (Fiestras-Janeiro et al. 2014) describe two EOQ models with no holding costs: a basic model and a model with transportation costs. The Shapley value and the two-lines rule are the chosen allocation procedures for sharing costs in this class of situations. (Fiestras-Janeiro et al. 2015) introduce a cooperative multi-agent inventory model, where the holding costs are negligible and shortages are allowed. (Saavedra-Nieves et al. 2018a) introduce a variant of the previous model by considering that shortages are cheaper than the original product. For these models, two rules are proposed to allocate the collaborating costs. Apart from those mentioned above, (Nagarajan and Sošić 2008), (Dror and Hartman 2011), and (Fiestras-Janeiro et al. 2011) are examples of some recent surveys in this field.

This paper describes the R package Inventorymodel and its capabilities for determining the optimal policies in the mentioned inventory models under a game-theoretic approach. For each of them, an allocation procedure is implemented to share the collaborating costs. This package can be very useful when the number of involved agents increases due to the computational complexity of the calculus of all possible groups considerably increases.

The remainder of this paper is organized as follows. First, we introduce some game theoretic notations used in this class of problems. Then, we present the different inventory models included in the Inventorymodel package, describing, for each, the optimal policy and appropriate allocation rule for the collaborating costs. Usage of the package is illustrated through the analysis of different examples considered in the literature.

Preliminaries on game theory

In this section, we introduce some necessary theoretical game terminology.

The cost games correspond to one of the most important classes of cooperative games. They are necessary for analysing those cost situations where \(n\) agents collaborate. Its definition is based on the concept of coalition. In what follows, if \(N:=\{1,...,n\}\) denotes the set of agents which cooperate, a coalition of \(N\) is a subset \(S\subseteq N\) with \(s:=|S|\) elements. Following (González-Díaz et al. 2010), a cost game is a pair \((N, c)\), where \(N\) is the set of players and \(c\) is a characteristic function, a map from \(2^N\) to \(\mathbb{R}\) satisfying that \(c(\emptyset) = 0\). Usually, \(c(S)\) represents the cost of the collaboration of the players in the coalition \(S\), for every \(S\subseteq N\).

In this class of situations, some natural properties to verify are the following. We say that \((N,c)\) is subadditive if, for each \(S, T \subseteq N\), with \(S\cap T = \emptyset\), it satisfies \(c(S)+ c(T) \geq c(S\cup T)\). Subadditivity implies that agents in \(S\cup T\) do have economic incentives to collaborate with respect to the cooperation of the groups \(S\) and \(T\) independently. As consequence, the formation of coalition \(N\) is profitable. A game \((N,c)\) is concave if, for all \(i\in N\) and for all \(S\subset T \subseteq N\setminus \{i\}\), it satisfies \(c(S\cup \{i\})-c(S)\geq c(T\cup \{i\})-c(T)\). Under concavity, players will have more incentive to join the coalition with a lower cost to contribute.

When a set of \(N\) agents cooperate, an important issue is the definition of procedures to allocate the cost \(c(N)\) obtained by collaborating among the involved agents. Below, we introduce two of the most important classes of allocations in this context according to different criteria in order to define the new allocation rules. The first approach focuses on the equanimity of allocations between players that cooperate. The Shapley value, introduced in (Shapley 1953), is an example of a rule defined under this criteria to distribute \(c(N)\). The Shapley value of \((N,c)\), \(\Phi(N,c)\), is defined for each \(i\in N\) by: \[\Phi_i(N,c):=\frac{1}{n!}\sum_{\sigma \in \Pi(N)}m_i^{\sigma}(c),\] where \(\Pi(N)\) denotes the set of permutations of \(N\), \(P_i^{\sigma}:=\{j\in N: \sigma(j)<\sigma(i)\}\) denotes the predecessors of agent \(i\) by a permutation \(\sigma\), and \(m_i^{\sigma}(c):=c(P_{i}^{\sigma}\cup {i})-c(P_{i}^{\sigma})\) for each \(\sigma \in \Pi(N)\). The Shapley value assigns to each \(i\in N\) its expected value if an agreement is reached, and each agent has to pay its contribution in the costs to the indicated set of predecessors. It is assumed that the arrival order is random and all orders are equally likely.

The second criteria is represented by the stability of the allocations. The core of \((N,c)\), as in (Gillies 1953), is the following set of payoff vectors for the members of \(N\): \[C(N,c):=\bigg\{x \in \mathbb{R}^N: \sum_{i \in N}x_i=c(N), \text{and for each non empty coalition } S \subset N, \sum_{i \in S} x_i \leq c(S) \bigg\}.\] It is said that the core allocations are stable in the sense that abandoning \(N\) and acting independently represents no improvement (in terms of gains) to coalition \(S\), with \(S\subset N\). This is due the fact that agents in \(S\) will pay more, when \(N\) does not form, than in those situations where its members act jointly with the rest of agents in \(N\setminus S\). The study of the core of a game \((N,c)\) and its cardinality become a complex issue in game theory since the number of associated constraints increases when \(n\) enlarges. For this reason, the definition of rules whose allocations are stable is a main goal in this class of problems. Under the verification of some properties of \((N,c)\), it is easy to study the core. In particular, if the cost game is concave, the Shapley value of \((N,c)\) is an element of this set, and when \((N,c)\) is subadditive, \(C(N,c)\) is a non-empty set.

2 Centralized inventory problems

The Inventorymodel package includes functions to obtain the optimal policy in this class of situations. In particular, different scenarios with deterministic demands are considered: for example, shortages can be allowed, transportation costs can be taken into account by assuming that agents are in a line or a general route, or different costs of product during shortages are allowed.

Depending on the considered assumptions, different parameters should be selected for modelling the problem among those described below. If a set of agents \(N\) cooperate to place joint orders, we can distinguish the following parameters:

This section introduces the different inventory models included in our package, which are dealt with in the literature by considering several assumptions about them.1

The EOQ and EPQ models under cooperation

The EOQ model under cooperation, introduced in (Meca et al. 2003), establishes the optimal policy for an agent \(i\in N\) to satisfy its demand of a product. This model supposes a fixed ordering cost, \(a>0\), and, for each \(i\in N\), a deterministic demand of \(d_i>0\) units of product per time unit and a holding cost by unit, \(h_i>0\). For this model, it is assumed that shortages are not allowed.

If \(Q_i\) denotes the required size of the order to satisfy \(d_i\), the time between two consecutive orders (length of the cycle) is \(Q_i/d_i\). If only one agent acts, we deal with a basic EOQ problem, a well-known problem in operations research. The optimal policy is simple in this case: once the stock runs out, this agent places a new order. When a group of agents \(S\subseteq N\) decides to cooperate, instead of ordering independently, it applies for a unique joint order. Moreover, all agents should order at the same time, and thus the lengths of the individual cycles coincide as well (this is, \(Q_i/d_i=Q_j/d_j\) for each pair of agents \(i, j\in S\)). In addition, if we define the number of orders per time unit by \(m_i=d_i/Q_i\), in the cooperative case we have that \(m_i=m_j\) for each \(i,j\in S\). Therefore, it is easy to check that the average cost per cycle is \[\label{EOQcost} C^S(\{Q_i\}_{i\in S}):=a \frac{d_k}{Q_k}+\sum_{i \in S}h_i\frac{Q_i}{2}, \text{for any k }\in S. \tag{1}\] Using optimization techniques, ((1)) takes its minimum value at \(Q^*_i:=\sqrt{\frac{2ad_i^2}{\sum_{j \in S}h_jd_j}}\) for each \(i\in S\). Hence, we can associate a cost game \((N,c)\), where \(c(S)=C^S(\{Q^*_i\}_{i\in S})\) for all \(S\subseteq N\). This is \[\label{NcEOQ} c(S):=a \frac{d_k}{Q^*_k}+\sum_{i \in S}h_i\frac{Q^*_i}{2}=2a\sqrt{\sum_{j \in S}{m^*_j}^2}, \tag{2}\] where \(m^*_i:=\frac{d_i}{Q^*_i}\) denotes the optimal number of orders per time unit for each \(i\in S\).

The EPQ model under cooperation is introduced by (Meca et al. 2003) by adding the following assumptions to those for the the EOQ model:

When an agent acts individually, the optimal policy is simple as well: once the stock runs out and the maximum level of shortage is reached, this agent places a new order. Following (Meca et al. 2003), when a group \(S\subseteq N\) is formed, its members apply for new joint orders. The average cost per cycle is \[\label{EPQcost} C^S(\{Q_i\}_{i\in S},\{\beta_i\}_{i\in S}):=a\frac{d_k}{Q_k}+\sum_{j \in S}h_j\frac{(Q_j(1-\frac{d_j}{r_j})-\beta_j)^2}{2Q_j(1-\frac{d_j}{r_j})}+\sum_{j \in S}b_j\frac{\beta_j^2}{2Q_j(1-\frac{d_j}{r_j})}, \text{for any k }\in S. \tag{3}\] So, ((3)) reaches the minima in \(Q^*_i:=\sqrt{\frac{2ad_i^2}{\sum_{j \in S}d_jh_j\frac{b_j}{h_j+b_j}(1-\frac{d_j}{r_j})}}\) and \(\beta^*_i:=Q^*_i\frac{h_i(1-\frac{d_i}{r_i})}{h_i+b_i}.\) With the appropriate calculations, we can associate a cost game \((N,c)\) to the EPQ model by defining, for each \(S\subseteq N\), \[\label{NcEPQ} c(S):=C^S(\{Q_i^*\}_{i\in S},\{\beta_i^*\}_{i\in S})=2a\sqrt{\sum_{j\in S}{m^*_j}^2}, \tag{4}\] where \(m^*_i:=\frac{d_i}{Q^*_i}\) denotes the optimal number of orders per time unit for each \(i\in S\).

The cooperative inventory cost situations defined in this section are denoted by \((N,a,m)\). The class of the obtained games is called inventory games, verifying that for each \(S\subseteq N\), \(c(S)=2a\sqrt{\sum_{j\in S}{m^*_j}^2}\) and also \(c^2(S)=\sum_{i \in S}c(\{i\})^2\).

The SOC rule, introduced by (Meca et al. 2003), establishes proportional allocations in situations such as detailed. Let \((N,a,m)\) be a situation of inventory as defined, and let \((N,c)\) be the associated cost game. When \(N\) cooperate, the SOC rule \(\sigma\) proposes to each agent \(i\in N\) a core allocation that includes a part of the fixed order cost (proportional to \({m}_i^2\)), a part of the holding costs and, in the EPQ model, a part relative to shortages. Hence, when \(N\) cooperates, for each \(i\in N\), \[\label{SOCrule} \sigma_i(N,c):=\frac{2a{m}_i^2}{\sqrt{\sum_{j \in N}{m}_j^2}}, \tag{5}\] while \(m_j\neq 0\) for \(j\in N\). Otherwise, \(\sigma_i(N,c)=0\). Following (Meca et al. 2003), as \(\sum_{i \in S}\sigma_i(N,c)\leq c(S)\) for all \(S\subset N\) and \(\sum_{i \in N}\sigma_i(N,c)= c(N)\), the stability of the allocations is ensured. It is remarkable that the calculation of \(\sigma_i(N,c)\) does not require the determination, in a explicit way, of the complete characteristic function of \((N,c)\).

The inventory transportation systems

An inventory transportation system is an inventory situation wherein agents face a basic EOQ model. As (Fiestras-Janeiro et al. 2012) propose, the cost of a new order has two components: the first is common to all and the second is proportional to the distance between the supplier and the agent.

Let \(N:=\{1,\dots,n\}\) be the set of agents. We consider as parameters the fixed ordering cost, \(a>0\), and for each \(i\in N\), the variable ordering cost, \(a_i>0\); the deterministic demand of the product, \(d_i>0\); and the holding cost by unit stored by the agent \(i\), \(h_i>0\). Let \((N,a,\{a_i,d_i,h_i\}_{i \in N})\) be an inventory transportation system. The formation of a group \(S\subseteq N\) implies that, instead of ordering independently, agents apply for a unique joint order. As we mention, all agents have to order at same time, and thus the lengths of the individual cycles are equal. In addition, in this model, we assume the following:

According to (Fiestras-Janeiro et al. 2012), the average cost per cycle is determined by \[C^S(\{Q_i\}_{i\in S}):=(a+a_S)\frac{d_k}{Q_k}+\sum_{j\in S}h_j\frac{Q_j}{2}=(a+a_S)\frac{d_k}{Q_k}+\frac{Q_i}{2d_i}\sum_{j\in S}d_jh_j, \text{for any k }\in S.\] After some algebraic calculation, when \(S\subseteq N\) is formed, the optimal size of the order for \(i\in S\) is \({Q}^*_i:=\sqrt{\frac{2(a+a_S)d_i^2}{\sum_{j \in S}d_jh_j}}\), which is the optimal number of orders per time unit \({m}^*_S:=\frac{d_i}{Q^*_i}=\sqrt{\frac{\sum_{j \in S}d_jh_j}{2(a+a_S)}}\). So, for an inventory transportation system, we can define a cost game \((N,c)\) for \(S\subseteq N\) by \[\label{NcSTI} c(S):=C^S(\{Q_i^*\}_{i\in S})=\sqrt{2(a+a_S)\sum_{j \in S}d_jh_j}=2(a+a_S){m}^*_S. \tag{6}\] (Fiestras-Janeiro et al. 2012) propose the line-rule \(L(N,c)\) as the procedure to share the collaborating costs. This rule assigns to each \(i\in N\) \[\label{Lrule} L_i(N,c):=\frac{1}{|\Pi_L(N,c)|}\sum_{\sigma \in \Pi_L(N,c)}m_i^{\sigma}(N,c), \tag{7}\] where \(\Pi_L(N,c)\) denotes the set of permutations of \(N\) that reverse the order given by the distances from the agents to the supplier. Formally, \(\Pi_L(N,c):=\{\sigma \in \Pi(N):\sigma(i)\leq \sigma(j)\Rightarrow a_i\geq a_j \}\). So, this rule can be seen as a variation of the Shapley value for cost games. It requires less computational effort than the original, and (Fiestras-Janeiro et al. 2012) prove that it is an element of the core of the game using the subadditivity character of \((N,c)\) under these assumptions.

The inventory problems with no-holding costs and without shortages

A basic EOQ system without holding costs is a model with a deterministic demand, no holding costs, and a limited capacity of the warehouses and shortages are not allowed. Let \(N:=\{1,\dots,n\}\) be the set of agents. Following (Fiestras-Janeiro et al. 2014), the parameters associated with each \(i\in N\) in these systems are the fixed ordering cost, \(a>0\); the deterministic demand of the product of agent \(i\), \(d_i>0\); and the capacity of the warehouse of \(i\), \(K_i>0\).

We denote these systems by \((N,a,\{d_i,K_i\}_{i\in N})\). The optimal policy of a group \(S\subseteq N\) is very simple. When a group of agents \(S\) is formed, the length of a joint cycle is \(\min_{j \in S}\{K_j/d_j\}\) and its associated cost per time unit is \[\frac{\text{cost of a cycle}}{\text{length of a cycle}}=\frac{a}{\min_{j \in S}\{K_j/d_j\}}=a\max_{j\in S}\{\frac{d_j}{K_j}\}.\] Thus, we can associate with every basic EOQ system without holding costs and with general transportation costs \((N,a,A,\{ d_i,K_i\}_{i\in N})\) the cost game \((N,c)\) which is given for all \(S\subseteq N\) by \[\label{NcMFOC} c(S):=a\max_{j\in S}\{\frac{d_j}{K_j}\}. \tag{8}\]

Notice that the obtained cost game can be seen as an airport game (see (Littlechild and Owen 1973), for details). For it, the Shapley value is an excellent rule with stable allocations. Moreover, there is a simple procedure to obtain it. By ordering in a non-decreasing order, the ratio \(d_i/K_i\) for all \(i\in N\), the expression of the Shapley value for agent \(i\in N\), \(\Phi_i(N,c)\), is \[\label{SHMFOC} \Phi_i(N,c):=\frac{c(\{1\})}{n}+\sum_{j=2}^i\frac{c(\{j\})-c(\{j-1\})}{n-j+1}. \tag{9}\]

Below, we describe an inventory system with costs for transporting a new order.

A basic EOQ system without holding costs and with transportation costs is an inventory situation introduced by (Fiestras-Janeiro et al. 2014), where agents face a basic EOQ model. Let \(N:=\{1,\dots,n\}\) be the set of agents. For each \(i\in N\), the following parameters are considered: the fixed part of the ordering cost, \(a>0\); the variable part of the ordering cost, \(a_i>0\); the deterministic demand of the product of \(i\), \(d_i>0\); and the capacity of the warehouse of \(i\), \(K_i>0\).

These models are denoted by \((N,a,\{a_i,d_i,K_i\}_{i \in N})\). The formation of a group \(S\subseteq N\) implies that agents in \(S\) place a unique joint order instead of independent orders. All of them have to order at the same time, and thus the lengths of the individual cycles are equal. In addition, we consider the following two assumptions imposed on the inventory transportation systems (see (Fiestras-Janeiro et al. 2012), for instance):

The optimal policy of a group \(S\subseteq N\) in this context is simple. When agents in \(S\) place joint orders, since shortages are not allowed, the length of a cycle is \(\min_{j \in S}\{K_j/d_j\}\) and the minimum joint cost per time unit is \[\frac{\text{cost of a cycle}}{\text{length of a cycle}}=\frac{a+a_S}{\min_{j \in S}\{K_j/d_j\}}=(a+a_S)\max_{j\in S}\{\frac{d_j}{K_j}\}.\] Thus, we can associate with basic EOQ system without holding costs and with transportation costs \((N,a,\{a_i,d_i,K_i\}_{i \in N})\) the cost game \((N,c)\), which is given for all \(S\subseteq N\) by \[\label{NcMCT} c(S):=(a+a_S)\max_{j\in S}\{\frac{d_j}{K_j}\}. \tag{10}\]

For each system \((N,a,\{a_i,d_i,K_i\}_{i \in N})\), the two-lines rule assigns the cost allocation \(TL(N,c):=(TL(N,c))_{i\in N}\). Following (Fiestras-Janeiro et al. 2014), it belongs to the core of \((N,c)\) and is given, for each \(i\in N\), by \[\label{TLrule} TL_i(N,c):=\frac{1}{2|\Pi_1(N,c)|}\sum_{\sigma \in \Pi_1(N,c)}m_i^{\sigma}(N,c)+\frac{1}{2|\Pi_2(N,c)|}\sum_{\sigma \in \Pi_2(N,c)}m_i^{\sigma}(N,c), \tag{11}\] where \(\Pi_1(N,c)\) and \(\Pi_2(N,c)\) are the following sets:

Below, the assumption of a general transportation cost function is introduced in the previous model. (Saavedra-Nieves et al. 2018) analyse the EOQ systems without holding costs and with general transportation costs, a generalization of the basic model with transportation costs proposed in (Fiestras-Janeiro et al. 2014).

In some circumstances, it is certainly restrictive to consider that agents are located in the same route. For instance, they can be located in a circular route or other types of graphs, and that \(a_S:=A(S)\) for each \(S\subseteq N\) and for a general function \(A\). So, \(A\) is a general map to assign the variable part of the transportation cost of a group \(S\) that depends on the distance of a member of \(S\) to the supplier. In addition, we consider as parameters the fixed part of ordering cost, \(a>0\), the deterministic demand of the product of \(i\), \(d_i>0\), and the capacity of the warehouse of \(i\), \(K_i>0\).

Thus, this model is denoted by \((N,a,A,\{ d_i,K_i\}_{i\in N})\). The optimal policy of a group \(S\subseteq N\) is easy to obtain. Since holding costs are irrelevant, when the agents in \(S\) place joint orders, the length of a cycle is \(\min_{j \in S}\{K_j/d_j\}\), and then the minimum joint cost per time unit is \[\frac{\text{cost of a cycle}}{\text{length of a cycle}}=\frac{a+A(S)}{\min_{j \in S}\{K_j/d_j\}}=\big(a+A(S)\big)\max_{j\in S}\{\frac{d_j}{K_j}\}.\] Thus, we can associate with every basic EOQ system without holding costs and with general transportation costs \((N,a,A,\{ d_i,K_i\}_{i\in N})\) the cost game \((N,c)\), which is given by, for all \(S\subseteq N\), \[\label{NcMwhcct} c(S):=\big(a+A(S)\big)\max_{j\in S}\{\frac{d_j}{K_j}\}. \tag{12}\] Notice that for each \(S\subseteq N\), \(c(S)\) can be written as the sum of two terms. Therefore, \(c(S):=c_a(S)+c_b(S)\), with \(c_a(S)=a\max_{j\in S}\{\frac{d_j}{K_j}\}\) and \(c_b(S)=A(S)\max_{j\in S}\{\frac{d_j}{K_j}\}\) for each \(S\subseteq N\).

For every system as the proposed, (Saavedra-Nieves et al. 2018) introduce the following allocation. This rule proposes, for every \(i\in N\), \[\label{Rrule} R_i(N,c):=\frac{1}{|\Pi(N)|}\sum_{\sigma \in \Pi(N)}m_i^{\sigma}(c_a)+\frac{1}{|\Pi_n(N)|}\sum_{\sigma \in \Pi_n(N)}m_i^{\sigma}(c_b), \tag{13}\] where \(\Pi_n(N):=\{\sigma \in \Pi(N) \text{satisfying, for all } i\in\{1,\dots ,n-1\}, \text{that} \frac{d_{\sigma^{-1}(i)}}{K_{\sigma^{-1}(i)}}\geq \frac{d_{\sigma^{-1}(i+1)}}{K_{\sigma^{-1}(i+1)}}\}\) denotes the set of permutations that reverse the order of the ratios \(\{d_i/K_i\}_{i\in N}\). (Saavedra-Nieves et al. 2018) prove that if the game \((N,c_b)\) is subadditive and the function \(A\) is submodular2, the proposed rule is in the core of \((N,c)\).

The inventory problems with no-holding costs and shortages

An EOQ system without holding costs and shortages, introduced in the reference (Fiestras-Janeiro et al. 2015), is a multi-agent situation, where each agent faces a continuous review inventory problem with no-holding costs, with shortages and with a limited capacity warehouse. The parameters associated with each \(i\in N\) are the fixed part of the ordering cost, \(a>0\); the shortage cost per item and per time unit, \(b_i>0\); the demand of the product of \(i\), \(d_i>0\); and the capacity of the warehouse of \(i\), \(K_i>0\).

This model is denoted by \((N,a,\{b_i,d_i,K_i\}_{i\in N})\). As shortages are allowed, the optimal policy changes. When agent \(i\) reaches the maximum shortage level, agent \(i\) places a new order of size \(K_i+\beta_i\), where \(\beta_i\) is the level of shortages for \(i\). So, the length of the cycle is \(\frac{K_i+\beta_i}{d_i}\), and the length of the period with shortages is \(\frac{\max\{\beta_i,0\}}{d_i}\). When a group \(S\subseteq N\) cooperates, we assume that its members place joint orders, and thus: \[\frac{1}{x_i}=\frac{K_i+\beta_i}{d_i}=\frac{K_j+\beta_j}{d_j}=\frac{1}{x_j},\] where \(x_i\) and \(x_j\) denote the number of orders per time unit for each agent \(i,j\in N\). Hence, the average cost per cycle for a coalition \(S\) is \(a+\sum_{i\in S}b_i\frac{\max\{\beta_i,0\}}{2}\frac{\max\{\beta_i,0\}}{d_i}\), and the average cost by time unit is \[\frac{a+\sum_{i\in S}b_i\frac{\max^2\{\beta_i,0\}}{2d_i}}{\frac{K_j+\beta_j}{d_j}}= \frac{ad_j}{K_j+\beta_j}+\frac{d_j}{K_j+\beta_j}\sum_{i\in S}b_i\frac{\max^2\{\beta_i,0\}}{2d_i}.\] Denoting by \(x\) the common number of orders per time unit under cooperation, we have \(\beta_i=-K_i+\frac{d_i}{x}\) for all \(i\in S\), and the average cost per time unit can be written as: \[C^S(x):=ax+x\sum_{i\in S}\frac{b_i}{2d_i}{\max}^2\{-K_i+\frac{d_i}{x},0\}=ax+\frac{1}{x}\sum_{i\in S}\frac{b_i}{2d_i}{\max}^2\{-K_ix+d_i,0\}.\]

The calculus of the optimal policy in this problem consists of calculating the minima of \(C^S(x)\). (Fiestras-Janeiro et al. 2015) propose an iterative algorithm to obtain this value. So, once it is applied, \(C^S(x)\) reaches its minimum value as follows: \[\label{NcMwhc} C^S(x_S^*):=\sum_{i\in i(S)}b_id_i\frac{1}{x_S^*}-\sum_{i\in i(S)}b_iK_i, in x_S^*:=\sqrt{\frac{\sum_{i\in i(S)}b_id_i}{2a+\sum_{i\in i(S)}b_i\frac{K_i^2}{d_i}}} \text{with } i(S):=\{i\in S: x_S^*<d_i/K_i\}. \tag{14}\] Thus, we can associate with every system as described the cost game \((N,c)\) which is given, for all \(S\subseteq N\), by \(c(S):=C^S(x_S^*)\). When agents in \(N\) cooperate, the authors propose a procedure to share the collaborating costs which ensures that the obtained allocation is in the core of \((N,c)\). The \(G\)-rule proposes \[\label{Grule} G_i(c):= \left\{ \begin{array}{ll} b_id_i\frac{1}{x_N^*}-b_iK_i, & \hbox{if $i\in i(N)$,} \\ 0, & \hbox{ otherwise.}\\ \end{array} \right. \tag{15}\] The stable character of the allocations can be justified by the fact of \(\sum_{i \in S}G_i(c)\leq c(S)\) for all \(S\subset N\) and \(\sum_{i \in N}G_i(c)= c(N)\) (for details, see (Fiestras-Janeiro et al. 2015)).

The previous model considers that the initial product and shortages have the same price by a unit of commodity. In some situations, the latter cost may be significantly smaller than the initial cost, as when shortages are produced by the same agent. (Saavedra-Nieves et al. 2018a) justify and analyse this new inventory situation.

An EOQ problem without holding costs and with two acquisition costs is a multi-agent inventory model wherein each agent faces a continuous-review inventory problem involving the same commodity. In this case, the considered parameters are the fixed part of the ordering cost, \(a>0\); the shortage cost per unit and per time unit, \(b_i>0\); the demand of the product of \(i\), \(d_i>0\); and the capacity of the warehouse of \(i\), \(K_i>0\). Additionally:

We denote this class of situations by \((N,a,c_1,c_2,\{b_i,d_i,K_i\}_{i\in N})\). In an analogous way to the model studied in (Fiestras-Janeiro et al. 2015), the inventory optimal policy varies when shortages are allowed. If agent \(i\) reaches the maximum shortage level, agent \(i\) places an order of size \(K_i+\beta_i\), with \(\beta_i\) the level of shortages for \(i\). The length of the cycle is given by \(\frac{K_i+\beta_i}{d_i}\) and the length of the period with shortages is \(\frac{\max\{\beta_i,0\}}{d_i}\). When a coalition \(S\) is formed, it verifies the following: \[\frac{1}{x_i}=\frac{K_i+\beta_i}{d_i}=\frac{K_j+\beta_j}{d_j}=\frac{1}{x_j},\] where \(x_i\) and \(x_j\) denote the number of orders per time unit for each agent \(i,j\in S\). Hence, the average cost per cycle for a coalition \(S\) is \(\left[a+c_1\sum_{i\in S}\left(K_i+\min\{\beta_i,0\}\right)\right]+\sum_{i\in S}\left[b_i\frac{\max^2\{\beta_i,0\}}{2d_i}+c_2\max\{\beta_i,0\}\right]\) and the average cost by time unit is \[\frac{d_j}{K_j+\beta_j}[a+c_1\sum_{i\in S}\left(K_i+\min\{\beta_i,0\}\right)]+\frac{d_j}{K_j+\beta_j}\sum_{i\in S}[b_i\frac{\max^2\{\beta_i,0\}}{2d_i}+c_2\max\{\beta_i,0\}].\] Taking \(\beta_i:=-K_i+\frac{d_i}{x}\) for all \(i\in S\), we have for each \(x>0\):

\[\begin{gathered} C^S(x):=x\left[a+c_1\sum_{i\in S}\left(K_i+\min\{-K_i+\frac{d_i}{x},0\}\right)\right]+\\+\frac{1}{x}\sum_{i\in S}\frac{b_i}{2d_i}\max~^{2} \{-K_ix+d_i,0\}+c_2\sum_{i\in S}\max\{-K_ix+d_i,0\}. \end{gathered}\]

Authors propose another iterative procedure to obtain the optimal inventory policy with the calculus of the minima of \(C^S(x)\). So, the minimum value of \(C^S(x)\) is \[\label{Ncmwhc2c}C^S(x^*_S):=\underset{i \in i(S)}{\overset{}\sum}b_{i}d_{i}\frac{1}{x^*_S}+c_1\underset{i \in S \setminus i(S)}{\overset{}\sum}d_{i}+\underset{i \in i(S)}{\overset{}\sum}(c_2d_{i\tag{16} (#eq:Ncmwhc2c)\] where \(x_S^*:=\sqrt{\frac{\underset{i \in i(S)}{\overset{}\sum}b_{i}d_{i}}{2a+2(c_1-c_2)\underset{i \in i(S)}{\overset{}\sum}K_{i}+\underset{i \in i(S)}{\overset{}\sum}b_{i}\frac{K_{i}^2}{d_{i}}}}\) with \(i(S):=\{i\in S: x_S^*<d_i/K_i\}\). A cost game \((N,c)\) can be associated with every system as proposed. It is given by \(c(S):=C^S(x_S^*)\) for all \(S\subseteq N\). When agents in \(N\) cooperate in \((N,a,c_1,c_2,\{b_i,d_i,K_i\}_{i\in N})\), the GR-rule allocates, for \(i\in N\): \[\label{GRrule}GR_i(c):=\begin{cases} b_id_i\frac{1}{x_N^*} +c_2d_{i}-b_{i}K_i,& \text{ si }i \in i(N),\\ c_1d_{i},& \text{ si }i \in N \setminus i(N). \end{cases} \tag{17}\]

In order to summarize the assumptions on the described models in this section, Table 1 relates them with the associated cost game and the allocation rule proposed for each case.

Table 1: Summary of assumptions, cost games, and allocations rules.
Ordering costs Variable ordering costs Holding costs Shortages \((N,c)\) Allocation rule
\(\checkmark\) - \(\checkmark\) - ((2)) SOC rule ((5))
\(\checkmark\) - \(\checkmark\) \(\checkmark\) ((4)) SOC rule ((5))
\(\checkmark\) \(\checkmark\) (\(a_i, i\in N\)) \(\checkmark\) - ((6)) Line-rule ((7))
\(\checkmark\) - - - ((8)) Shapley value ((9))
\(\checkmark\) \(\checkmark\) (\(a_i, i\in N\)) - - ((10)) Two-lines rule ((11))
\(\checkmark\) \(\checkmark\) (\(A(S), S\subseteq N\)) - - ((12)) R-rule ((13))
\(\checkmark\) - - \(\checkmark\) ((14)) G-rule ((15))
\(\checkmark\) - - \(\checkmark\) (two costs) ((16)) GR-rule ((17))

3 Inventorymodel in practice

This section presents an overview of the structure of the package. Inventorymodel is a tool for calculating the optimal policy in several inventory situations and for allocating the collaboration costs among the agents involved in the process. This software helps the user to determine faster the optimal policy when the number of agents increases. Remark that these functions only automatize the required operations for the calculus of the optimal costs under theses scenarios although the computational complexity still maintains.3

Inventorymodel package includes several functions that enable users to determine the optimal inventory policy for the inventory models decribed in previous section. Moreover, auxiliary functions are implemented to obtain some intermediate values in the calculation. This package has as dependencies e1071 and GameTheoryAllocation packages of which takes some functions in its calculations. The last one, in a primitive version, includes some generic functions related to game-theoretic concepts. The functions incorporated in the package are briefly described in Table 2.

Table 2: Summary of functions in the Inventorymodel package.
Function Description
coalitions Function to obtain all possible coalitions with \(n\) players.
EOQ Function to calculate the optimal policy and costs in an EOQ model ((2)).
EOQcoo Function to calculate the optimal policy and associated cost game in an EOQ model when \(n\) agents cooperate ((2)).
EPQ Function to calculate the optimal policy and costs in an EPQ model ((4)).
EPQcoo Function to calculate the optimal policy and associated cost game in an EPQ model when \(n\) agents cooperate ((4)).
inventorygames Function to determine the associated cost game in an EOQ ((2)) or an EPQ ((4)) model.
inventorymodelfunction Main function to obtain the optimal policy by selecting any model and its parameters.
linerule Function to obtain the line-rule allocation ((7)) for an inventory transportation system ((6)) when a coalition \(N\) is formed .
linerulecoalitional Function to obtain the line-rule allocation ((7)) for an inventory transportation system ((6)) for each possible coalition.
marginal_contribution_mean Intermediate auxiliary function to calculate the mean of the marginal contributions for a set of permutations.
mct Function to obtain the costs in a basic EOQ system without holding costs and with transportation cost ((10)).
mfoc Function to obtain the associated costs in a fixed order cost model ((8)).
mwhc Function to obtain the associated costs in a model without holding costs ((14)).
mwhc2c Function to obtain the associated costs in a model without holding costs and with two different costs of a product ((16)).
mwhcct Function to obtain the associated costs in a basic EOQ system without holding costs and with a general transportation cost ((12)).
shapley_mfoc Function to calculate the Shapley value ((9)) for the associated game in a fixed order cost model ((8)).
SOC Function to obtain the allocation proposed by the SOC rule ((5)) under an EOQ/EPQ model, see ((2)) and ((4)).
STI Function to obtain the optimal orders and associated cost in inventory transportation systems ((6)).
STIcoo Function to obtain the optimal orders and associated cost when \(n\) agents are cooperating in the inventory transportation system ((6)).
twolines Function to calculate the allocation proposed by the two-lines rule ((11)) in a basic EOQ system without holding costs and with transportation cost ((10)).

Users can obtain the optimal inventory policy in each case by introducing the associated parameters to each model in the corresponding function. Table 3 describes the different options to define the inventory models included in Inventorymodel. However, not all of the mentioned options are necessary since only some of them are specific for each inventory situation. Table 4 summarizes the required arguments in the specific function associated with each inventory model. Examples of usage for the implemented functions are described in the next section.

Table 3: Summary of arguments for functions in the Inventorymodel package.
Argument Description
model A character string that indicates the selected model and required only in the inventorymodelfunction. The possible values are "EOQ" (EOQ), "EPQ" (EPQ), "STI" (the inventory transportation systems), "FOC" (the fixed order cost model), "MCT" (the basic EOQ system without holding costs and with transportation cost), "MWHC" (the model without holding costs and shortages), "MWHC2" (the model without holding costs and two acquisition costs), and "MWHCCT" (the EOQ system without holding costs and with general transportation costs).
n An integer specifying the number of agents involved in the inventory model. It corresponds to the cardinality of the set \(N\).
a A real number that indicates the fixed cost per new order.
av A vector of dimension n that contains, in each component, the transportation costs associated with each agent \(i\in N\).
d A vector of dimension n that contains, in each component, the deterministic demands per time unit associated with each agent \(i\in N\).
h A vector of dimension n that indicates, in each component, the holding costs per product unit associated with each agent \(i\in N\).
m A vector of dimension n that indicates, in each component, the number of orders \(m_i\) associated with each agent \(i\in N\). These values are necessary only when information about demands is unknown.
r A vector of dimension n that contains, in each component, the replacement rate of a product associated with each agent \(i\in N\) in a EPQ model. In general, it verifies \(r_i>d_i\).
K A vector of dimension n that details, in each component, the warehouse capacity of the product associated with each agent \(i\in N\).
b A vector of dimension n that details, in each component, the cost by shortage unit of the product associated with each agent \(i\in N\).
c1 A real value with the acquisition cost of one unit of the purchased commodity.
c2 A real value with the acquisition cost of one unit of the produced commodity.
cooperation A variable that indicates if cooperation is considered. If it exists, cooperation=1, else cooperation=0.
allocation A variable that indicates if the defined allocation in each case is required. If it exists, allocation=1, else allocation=0.
Table 4: Arguments for each function in the Inventorymodel package.
Function model n a av d h m r K b c1 c2 cooperation allocation
EOQ - \(\checkmark\) \(\checkmark\) - \(\checkmark\) \(\checkmark\) \(\checkmark\) - - - - - - -
EOQcoo - \(\checkmark\) \(\checkmark\) - \(\checkmark\) \(\checkmark\) \(\checkmark\) - - - - - - -
EPQ - \(\checkmark\) \(\checkmark\) - \(\checkmark\) \(\checkmark\) \(\checkmark\) \(\checkmark\) - \(\checkmark\) - - - -
EPQcoo - \(\checkmark\) \(\checkmark\) - \(\checkmark\) \(\checkmark\) \(\checkmark\) \(\checkmark\) - \(\checkmark\) - - - -
inventorygames \(\checkmark\) - \(\checkmark\) - \(\checkmark\) \(\checkmark\) \(\checkmark\) \(\checkmark\) - \(\checkmark\) - - - -
inventorymodelfunction \(\checkmark\) \(\checkmark\) \(\checkmark\) \(\checkmark\) \(\checkmark\) \(\checkmark\) \(\checkmark\) \(\checkmark\) \(\checkmark\) \(\checkmark\) \(\checkmark\) \(\checkmark\) \(\checkmark\) \(\checkmark\)
linerule - \(\checkmark\) \(\checkmark\) \(\checkmark\) \(\checkmark\) \(\checkmark\) \(\checkmark\) - - - - - - -
linerulecoalitional - \(\checkmark\) \(\checkmark\) \(\checkmark\) \(\checkmark\) \(\checkmark\) \(\checkmark\) - - - - - - -
mct - \(\checkmark\) \(\checkmark\) \(\checkmark\) \(\checkmark\) - - - \(\checkmark\) - - - \(\checkmark\) -
mfoc - \(\checkmark\) \(\checkmark\) - \(\checkmark\) - - - \(\checkmark\) - - - \(\checkmark\) -
mwhc - \(\checkmark\) \(\checkmark\) - \(\checkmark\) - - - \(\checkmark\) \(\checkmark\) - - \(\checkmark\) \(\checkmark\)
mwhc2c - \(\checkmark\) \(\checkmark\) - \(\checkmark\) - - - \(\checkmark\) \(\checkmark\) \(\checkmark\) \(\checkmark\) \(\checkmark\) \(\checkmark\)
mwhcct - \(\checkmark\) \(\checkmark\) \(\checkmark\) \(\checkmark\) - - - \(\checkmark\) - - - \(\checkmark\) \(\checkmark\)
shapley_mfoc - \(\checkmark\) \(\checkmark\) - \(\checkmark\) - - - \(\checkmark\) - - - - -
SOC \(\checkmark\) \(\checkmark\) \(\checkmark\) - \(\checkmark\) \(\checkmark\) \(\checkmark\) \(\checkmark\) - - - - - -
STI - \(\checkmark\) \(\checkmark\) \(\checkmark\) \(\checkmark\) \(\checkmark\) \(\checkmark\) - - - - - - -
STIcoo - \(\checkmark\) \(\checkmark\) \(\checkmark\) \(\checkmark\) \(\checkmark\) \(\checkmark\) - - - - - - -
twolines - \(\checkmark\) \(\checkmark\) \(\checkmark\) \(\checkmark\) - - - \(\checkmark\) - - - - -

Additionally, the function coalitions takes, as a unique argument, the integer variable n (the number of involved agents) to calculate all possible subsets of the set of \(N\). The auxiliary function marginal_contribution_mean allows the calculation of the average of the marginal contribution vectors for some indicated permutations. Therefore, it only needs as arguments a matrix with the permutations to study (permute) and a vector that contains the characteristic function with associated cost values for each possible coalition in a set of agents \(N\) (costs).

Examples of application

Several examples of application of the Inventorymodel package are used to illustrate its performance in the different contexts considered. After installing the package from CRAN, as an initial step a user should load the package in the R Console:

> library("Inventorymodel")

Below, in order to illustrate the performance of those functions which determine the optimal order and the associated cost game, we consider examples extracted from the references. In this situations, the number of involved agents is always lesser than \(n=10\). For cases where \(n\) is greater, such as we have mentioned through this paper, the characteristic function requires a high memory size. Hence, the implemented functions only return the individual costs, \(c(\{i\})\), and values associated to the formation of coalition \(N\), \(c(N)\), with an analogous structure of the results.

The EOQ and EPQ models under cooperation in R

This example, taken from (Meca et al. 2004), describes the EOQ problem that surges when three airlines place joint orders. Let \(N=\{1,2,3\}\) be the set of agents and \(a=600\) the fixed cost of a new order with values for the individual demands, and the holding costs (by unit of product) are depicted in Table 5.

Table 5: Demands and holding costs for agents in \(N\) in the EOQ problem.
\(i\) 1 2 3
\(d_i\) 500 300 400
\(h_i\) 9.6 11 10

Using EOQcoo, we obtain the optimal policy for each possible subgroup \(S\subseteq N\) in terms of the number of orders and its associated costs (as a data frame in a list) following ((2)).

> EOQcoo(n = 3, a = 600, d = c(500, 300, 400), h = c(9.6, 11, 10))
EOQ model
Cooperative case
Optimal order
    Coalition        1        2        3 Coalitional costs
1           0   0.0000   0.0000   0.0000             0.000
2     '{ 1 }' 250.0000   0.0000   0.0000          2400.000
3     '{ 2 }'   0.0000 180.9068   0.0000          1989.975
4     '{ 3 }'   0.0000   0.0000 219.0890          2190.890
5   '{ 1,2 }' 192.4501 115.4701   0.0000          3117.691
6   '{ 1,3 }' 184.6372   0.0000 147.7098          3249.615
7   '{ 2,3 }'   0.0000 121.6327 162.1770          2959.730
8 '{ 1,2,3 }' 157.4592  94.4755 125.9673          3810.512

To evaluate the implementation in R of the EPQ model, we consider in the previous example a replacement rate \(r_i=600\) units of product for all \(i\in N\). Moreover, the cost by shortage unit is \(100\), \(150\) and \(200\) for each agent, respectively. Below, the optimal policy in terms of the number of orders and shortages is depicted ((4)). It is obtained by using EPQcoo in R.

> EPQcoo(n = 3, a = 600, d = c(500, 300, 400), h = c(9.6, 11, 10), 
+     r = rep(600, 3), b = c(100, 150, 200))
EPQ model
Cooperative case
`Optimal order`
    Coalition        1        2        3 Coalitional costs
1           0   0.0000   0.0000   0.0000            0.0000
2     '{ 1 }' 641.0928   0.0000   0.0000          935.9019
3     '{ 2 }'   0.0000 265.0557   0.0000         1358.2049
4     '{ 3 }'   0.0000   0.0000 388.8444         1234.4268
5   '{ 1,2 }' 363.7611 218.2567   0.0000         1649.4341
6   '{ 1,3 }' 387.3208   0.0000 309.8566         1549.1036
7   '{ 2,3 }'   0.0000 196.1473 261.5297         1835.3556
8 '{ 1,2,3 }' 291.2332 174.7399 232.9866         2060.2045

`Optimal shortages`
       1        2        3
0.000000 0.000000 0.000000
9.359019 0.000000 0.000000
0.000000 9.054699 0.000000
0.000000 0.000000 6.172134
5.310381 7.455973 0.000000
5.654318 0.000000 4.918359
0.000000 6.700683 4.151265
4.251580 5.969377 3.698200

The output is a list which contains as a first element a data frame with optimal orders and the associated costs, and a data frame where the optimal shortages by agent are depicted for the different coalitions.

The calculation of the SOC rule ((5)) in the abovementioned example for the EOQ problem completes this evaluation. To conclude, we use the SOC function to obtain this allocation (as a numeric vector).

> SOC(n = 3, a = 600, d = c(500, 300, 400), h = c(9.6, 11, 10), model = "EOQ")
EOQ model
`Share the ordering costs rule (individually)`
        1        2        3
    0.000    0.000    0.000
 2400.000    0.000    0.000
    0.000 1989.975    0.000
    0.000    0.000 2190.890
 1847.521 1270.171    0.000
 1772.517    0.000 1477.098
    0.000 1337.960 1621.770
 1511.608 1039.230 1259.673

In an obvious way, this function returns the allocation proposed by the SOC rule correspond to each possible group of agents.

The inventory transportation systems in R

To evaluate the performance of the inventory transportation systems in R, we consider the example depicted in (Fiestras-Janeiro et al. 2012). Let \(N=\{1,2,3\}\) be a set of three involved agents, with \(a=200\) as the fixed cost of a new order. The remainder of the data are detailed in Table 6.

Table 6: Distances to the supplier, demands, and individual holding costs.
\(i\) 1 2 3
\(a_i\) 300 300 900
\(d_i\) 90 80 20
\(h_i\) 0.06 0.06 0.1

The function STIcoo allows the determination of the optimal policy for each possible \(S\subseteq N\) in this inventory situation. Its result is shown below in terms of the number of orders and its associated costs ((6)).

> STIcoo(n = 3, a = 200, av = c(300, 300, 900), d = c(90, 80, 20), 
+    h = c(0.06, 0.06, 0.1))
`Optimal order`
          1        2        3   Coalition Order cost
1    0.0000    0.000   0.0000           0    0.00000
2 1224.7449    0.000   0.0000     '{ 1 }'   73.48469
3    0.0000 1154.701   0.0000     '{ 2 }'   69.28203
4    0.0000    0.000 663.3250     '{ 3 }'   66.33250
5  891.1328  792.118   0.0000   '{ 1,2 }'  100.99505
6 1551.8080    0.000 344.8462   '{ 1,3 }'  127.59310 
7    0.0000 1438.954 359.7385   '{ 2,3 }'  122.31108
8 1208.5759 1074.290 268.5724 '{ 1,2,3 }'  163.82918

Finally, we utilize the function linerule to obtain the allocation proposed by the line-rule when \(N\) is formed ((7)).

> linerule(n = 3, a = 200, av = c(300, 300, 900), d = c(90, 80, 20), 
+    h = c(0.06, 0.06, 0.1))
[1] 51.38935 46.10733 66.33250

The inventory problems with no-holding costs and without shortages in R

First, we evaluate the basic EOQ system without holding costs in R by taking the example considered in (Fiestras-Janeiro et al. 2014). There are five farms with \(40\), \(140\), \(120\), \(130\) and \(120\) cows, respectively. The fixed cost by order is \(a=200\) euros. The information about demands of the product and capacity of warehouses are depicted in Table 7.

Table 7: Demands and capacities of the warehouses.
\(i\) 1 2 3 4 5
\(d_i\) 0.4 1.4 1.2 1.3 1.2
\(K_i\) 4 10 8 8 6

By using the mfoc function, we obtain the individual inventory costs (as a numeric vector).

> mfoc(n = 5, a = 200, d = c(0.4, 1.4, 1.2, 1.3, 1.2), K = c(4, 10, 8, 8, 6), 
+    cooperation = 0)
MFOC model
[1] 20.0 28.0 30.0 32.5 40.0

When cooperation=1, the costs associated to each possible coalition ((8)) are depicted in a data frame.

Below, we obtain the Shapley value (as numeric) with the previous costs according to that described ((9)). For this, we use the shapley_mfoc function.

> shapley_mfoc(n = 5, a = 200, d = c(0.4, 1.4, 1.2, 1.3, 1.2), 
+    K = c(4, 10, 8, 8, 6))
Shapley-Value
MFOC model
[1]  4.000000  6.000000  6.666667  7.916667 15.416667

In order to evaluate the basic EOQ system without holding costs and with transportation costs in R, we consider the example proposed in (Fiestras-Janeiro et al. 2014) for three farms. In this case, if \(N=\{1,2,3\}\), the cost by a new order is \(a=100\), and the rest of the data are detailed in Table 8.

Table 8: Demands, capacities of the warehouses, and costs by transportation.
\(i\) \(d_i\) \(K_i\) \(a_i\) \(d_i/K_i\)
1 2 9 300 0.222
2 2 8 500 0.250
3 5 7 200 0.714

The function mct allows the calculation, for each \(S\subseteq N\), of the optimal costs of the collaboration ((10)). As cooperation=1, the output is a matrix; otherwise, it is a numeric vector.

> mct(n = 3, a = 400, av = c(300, 500, 200), d = c(2, 2, 5), K = c(9, 8, 7), 
+    cooperation = 1)
MCT model
Cooperative case
  1 2 3   Coalition     Cost
1 0 0 0           0   0.0000
2 1 0 0     '{ 1 }' 155.5556
3 0 1 0     '{ 2 }' 225.0000
4 0 0 1     '{ 3 }' 428.5714
5 1 1 0   '{ 1,2 }' 225.0000
6 1 0 1   '{ 1,3 }' 500.0000
7 0 1 1   '{ 2,3 }' 642.8571
8 1 1 1 '{ 1,2,3 }' 642.8571

For this class of problems, when \(N\) agents cooperate, the allocation proposed by the two-lines rule ((11)) for the dealt example is obtained by the function twolines:

> twolines(n = 3, a = 400, av = c(300, 500, 200), d = c(2, 2, 5), K = c(9, 8, 7))
MCT model
Cooperative case
Two-lines rule
[1]   0.0000 219.6429 423.2143

Finally, the performance of the implementation in R of the EOQ systems without holding costs and with general transportation costs is considered. For this, we take one example for \(n=3\) agents extracted from (Saavedra-Nieves et al. 2018). In that case, \(a=10\) and \(d/K=(1,0.95,0.9)\), and the transportation cost function is detailed in Table 9.

Table 9: Transportation costs function \(A\) for each \(S\subseteq N\).
\(S\) \(\{1\}\) \(\{2\}\) \(\{3\}\) \(\{1,2\}\) \(\{1,3\}\) \(\{2,3\}\) \(N\)
\(A(S)\) 10 10 10 20 20 20 30

The function mwhcct allows the determination of the optimal policy for this model ((12)), and with the selected option, we obtain the allocation the \(R\)-rule ((13)) proposes.

> mwhcct(n = 3, a = 10, av = c(0, 10, 10, 10, 20, 20, 20, 30), d = c(1, 0.95, 
+    0.9), K = c(1, 1, 1), cooperation = 1, allocation = 1)
MWHC with Transportation Costs model
Cooperative case
`Optimal solution`
  1 2 3   Coalition Cost
1 0 0 0           0  0.0
2 1 0 0     '{ 1 }' 20.0
3 0 1 0     '{ 2 }' 19.0
4 0 0 1     '{ 3 }' 18.0
5 1 1 0   '{ 1,2 }' 30.0
6 1 0 1   '{ 1,3 }' 30.0
7 0 1 1   '{ 2,3 }' 28.5
8 1 1 1 '{ 1,2,3 }' 40.0

`Allocation R rule`
    1     2  3
13.75 13.25 13

The results are in a list which contains a data frame with optimal costs and a vector with the allocation that the \(R\) rule proposes for this model.

The inventory problems with no-holding costs and shortages in R

The EOQ system without holding costs and shortages in R is evaluated using the example taken from (Fiestras-Janeiro et al. 2015). In that case, \(a=180\), and the rest of the necessary data in the model are given in Table 10.

Table 10: Demands, shortage costs, and capacities of the warehouses.
\(i\) 1 2 3 4
\(d_i\) 0.45 0.95 1.05 1.20
\(b_i\) 15 15 10 12
\(K_i\) 5 7.5 8 9

Using the function mwhc, the optimal policy ((14)) in terms of the number of orders and shortages is obtained, and the allocation proposed for this inventory scenario is also calculated for the case in which \(N\) cooperate.

> mwhc(n = 4, a = 180, b = c(15, 15, 10, 12), d = c(0.45, 0.95, 1.05, 1.2), 
+    K = c(5, 7.5, 8, 9), cooperation = 0, allocation = 0)
MWHC model
`Number of orders per time unit`
[1] 0.07520921 0.10684954 0.10406757 0.11094004

Costs
[1] 14.74965 20.86510 20.89599 21.79985

`Optimal shortages`
[1] 0.9833101 1.3910067 2.0895986 1.8166538

In this case, the output corresponds to a list with components for the orders, the costs, and the optimal shortages. When cooperation=1, the output is a list with the optimal policies for the different groups, indicating the orders and the costs, and the allocation proposed by \(G\) ((15)).

To conclude, we analyse the EOQ problem without holding costs and with two acquisition costs in R. For this, we consider an example from (Saavedra-Nieves et al. 2018a) for \(n=3\) agents whose associated data is depicted in Table 11. The remainder of the data are given by \(a=1\), \(c_1=3.5\), and \(c_2=3\).

Table 11: Demands, shortage costs, and capacities of the warehouses.
\(i\) 1 2 3
\(d_i\) 30 45 46
\(b_i\) 10 10 10
\(K_i\) 30 45 46

The function mwhc2c allows the calculation of the optimal policy in terms of the number of orders and shortages when all agents cooperate ((16)). Moreover, we obtain the proposed allocation in this case.

> mwhc2c(n = 3, a = 1, b = c(10, 10, 10), d = c(30, 45, 46), 
+     K = c(30, 45, 46), c1 = 3.5, c2 = 3, cooperation = 0, allocation = 0)
MWHC model
`Number of orders per time unit`
[1] 0.9505864 0.9515422 0.9515838

Costs
[1] 105.5947 157.9165 161.4046

`Optimal shortages`
[1] 1.559468 2.291648 2.340459

The output has the following structure: it is a list with the orders, the costs and the optimal shortages. When cooperation=1, the output corresponds to a list with the optimal policies for the different groups, with the associated orders and the costs in a data frame, and the allocation proposed by \(GR\) ((17)) for each coalition \(S\subseteq N\) in a matrix.

All examples dealt with in this section can be evaluated with inventorymodelfunction by introducing, for each case, the corresponding character chain for the associated model and its parameters (see Table 3 for details).

4 Computing time

To illustrate the time required by the different functions in the R package Inventorymodel, we performed the following simulations with artificial data. We generated, according to a uniform distribution, 100 samples of the involved parameters in the functions included in the package for values of \(n\) from \(3\) to \(10\).

For each sample, we evaluate the available functions. All the computations included in this paper have been performed on a personal computer with Intel(R) Core(TM) i5-4210U and 8 GB of memory using a single 2.40GHz CPU processor. The results of the evaluations for all samples are depicted in Tables 12 and 13, where the values are reported in seconds.4

Table 12: System time (in seconds) for 100 computations using Inventorymodel and for several values of \(n\).
\(n\) \(3\) \(4\) \(5\) \(6\) \(7\) \(8\) \(9\) \(10\)
EOQcoo 0.00 0.00 0.00 0.00 0.00 0.00 0.02 0.00
EPQcoo 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
STIcoo 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.04
mfoc 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
mct 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.01
mwhc 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.01
mwhc2c 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
mwhcct 0.00 0.00 0.00 0.00 0.00 0.02 0.00 0.01
Table 13: User time (in seconds) for 100 computations using Inventorymodel and for several values of \(n\).
\(n\) \(3\) \(4\) \(5\) \(6\) \(7\) \(8\) \(9\) \(10\)
EOQcoo 0.00 0.00 0.34 0.72 1.00 2.20 4.35 9.35
EPQcoo 0.00 0.00 0.26 0.24 0.63 1.35 2.72 5.98
STIcoo 0.00 0.00 0.37 0.65 1.14 2.13 4.50 9.43
mfoc 0.00 0.00 0.32 0.45 0.75 1.65 3.48 7.16
mct 0.00 0.00 1.00 1.96 4.03 8.34 17.97 38.22
mwhc 0.00 0.00 0.72 1.27 2.17 4.45 9.32 18.93
mwhc2c 0.00 0.00 0.92 1.64 3.26 7.31 14.38 31.86
mwhcct 0.00 0.00 0.84 1.76 3.52 7.27 15.47 32.79

We can observe that the runtime is mainly affected by the number of agents. As we expected, as the procedure is based on the subsets of \(N\), the dimension of the characteristic function determines the runtime required for its calculation. In view of Tables 12 and 13, it is easy to check that when \(n\) increases, the computing time increases too. However, in most of cases, it does not exceed ten seconds of running time for all computation. Only in seven situations the computing time is bigger (without exceeding a minute).

5 Conclusions

This paper discusses the implementation in R of several procedures to calculate the optimal policy in different inventory situations from using game theory results. Mechanisms to allocate the collaborating costs among the agents have been incorporated as well. Thus, the Inventorymodel package provides R users a set of functions to determine the optimal costs in different situations defined in the literature: with holding costs, with costs by the transport of a new order, with shortages, and with different prices of a unit of purchased and produced products. When the number of agents increases, these calculations become computationally more complicated since that the number of possible groups of agents considerably enlarges. Future research and development plans for forthcoming versions of the package include the addition of new inventory models that can be dealt with in the framework presented above and the inclusion of alternative procedures in order to reduce the computational complexity present in this class of problems.

6 Acknowledgements

The author acknowledges the financial support of Ministerio de Economı́a y Competitividad through projects MTM2014-53395-C3-2-P and MTM2014-53395-C3-3-P and the financial support of Xunta de Galicia through the ERDF (Grupos de Referencia Competitiva) ED431C 2016-040. The author acknowledges M. Gloria Fiestras-Janeiro for her constructive comments on this paper.

CRAN packages used

Inventorymodel, e1071, GameTheoryAllocation

CRAN Task Views implied by cited packages

Cluster, Distributions, Environmetrics, MachineLearning, Psychometrics

Note

This article is converted from a Legacy LaTeX article using the texor package. The pdf version is the official version. To report a problem with the html, refer to CONTRIBUTE on the R Journal homepage.

M. Dror and B. C. Hartman. Survey of cooperative inventory games and extensions. Journal of the Operational Research Society, 62(4): 565–580, 2011. URL https://doi.org/10.1057/jors.2010.65.
M. G. Fiestras-Janeiro, I. García-Jurado, A. Meca and M. A. Mosquera. Centralized inventory in a farming community. Journal of Business Economics, 84(7): 983–997, 2014. URL https://doi.org/10.1007/s11573-014-0710-z.
M. G. Fiestras-Janeiro, I. García-Jurado, A. Meca and M. A. Mosquera. Cooperation on capacitated inventory situations with fixed holding costs. European Journal of Operational Research, 241(3): 719–726, 2015. URL https://doi.org/10.1016/j.ejor.2014.09.016.
M. G. Fiestras-Janeiro, I. García-Jurado, A. Meca and M. A. Mosquera. Cooperative game theory and inventory management. European Journal of Operational Research, 210(3): 459–466, 2011. URL https://doi.org/10.1016/j.ejor.2010.06.025.
M. Fiestras-Janeiro, I. García-Jurado, A. Meca and M. Mosquera. Cost allocation in inventory transportation systems. Top, 20(2): 397–410, 2012. URL https://doi.org/10.1007/s11750-011-0207-7.
D. B. Gillies. Some theorems on n-person games. 1953.
J. González-Díaz, I. García-Jurado and M. G. Fiestras-Janeiro. An introductory course on mathematical game theory. American Mathematical Society Providence, 2010.
S. C. Littlechild and G. Owen. A simple expression for the Shapley value in a special case. Management Science, 20(3): 370–372, 1973. URL https://doi.org/10.1287/mnsc.20.3.370.
A. Meca, I. García-Jurado and P. Borm. Cooperation and competition in inventory games. Mathematical Methods of Operations Research, 57(3): 481–493, 2003. URL https://doi.org/10.1007/s001860200253.
A. Meca, J. Timmer, I. García, P. Borm, et al. Inventory games. European Journal of Operational Research, 156(1): 127–139, 2004. URL https://doi.org/10.1016/s0377-2217(02)00913-x.
M. Nagarajan and G. Sošić. Game-theoretic analysis of cooperation among supply chain agents: Review and extensions. European Journal of Operational Research, 187(3): 719–745, 2008. URL https://doi.org/10.1016/j.ejor.2006.05.045.
A. Saavedra-Nieves, I. García-Jurado and M. G. Fiestras-Janeiro. On coalition formation in a non-convex multi-agent inventory problem. Annals of Operations Research, 261(1): 255–273, 2018a. URL https://doi.org/10.1007/s10479-017-2616-y.
A. Saavedra-Nieves, I. García-Jurado and M. G. Fiestras-Janeiro. Placing joint orders when holding costs are negligible and shortages are not allowed. In Game theory in management accounting: Implementing incentives and fairness, Eds D. Mueller and R. Trost pages. 349–360 2018. Springer-Verlag. URL https://doi.org/10.1007/978-3-319-61603-2_16.
L. S. Shapley. A value for n-person games. Contributions to the Theory of Games, 2(28): 307–317, 1953.

References

Reuse

Text and figures are licensed under Creative Commons Attribution CC BY 4.0. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".

Citation

For attribution, please cite this work as

Saavedra-Nieves, "Inventorymodel: an R Package for Centralized Inventory Problems", The R Journal, 2018

BibTeX citation

@article{RJ-2018-023,
  author = {Saavedra-Nieves, Alejandro},
  title = {Inventorymodel: an R Package for Centralized Inventory Problems},
  journal = {The R Journal},
  year = {2018},
  note = {https://rjournal.github.io/},
  volume = {10},
  issue = {1},
  issn = {2073-4859},
  pages = {200-217}
}