1. INTRODUCTION
Although the term Supply Chain Management (SCM) was coined over 30 years ago, the rising awareness about the importance of this concept for the performance of businesses is a much more recent phenomenon. In the e commerce branch of Logistics and SCM (LSCM), there are two major types of business models: businesstoconsumer (B2C) and businesstobusiness (B2B) (Bolumole et al., 2015;Edwards et al., 2019). The present study is focused on B2C models, where all transactions between the business and the consumer are done on the business’s website. B2C businesses need to pay close attention to SCM to ensure the services they provide are sufficiently diverse and flexible (Boyer and Hult, 2010). Supply chain resource allocation and planning optimization can help an ecommerce company to offer customized services to its customers (Bailey and Rabinovich, 2005). The growth of ecommerce across the world has drawn more attention to the intricacies of supply chains involved in online shopping and commerce. Indeed, the advent and rising accessibility of the Internet have made online shopping an extremely attractive subject of research (Çelik, 2007;Gehrt et al., 2012;Kim et al., 2013). Hence, a significant number of studies have examined different aspects of SCM in the context of ecommerce (Yao and Gu, 2015;Lancioni et al., 2000;Garcıa Dastugue and Lambert, 2018). However, only a few studies have investigated the combination of online transactions and specific supply chains (Rahman, 2019). Online pharmacies are a group of modern online businesses that facilitate access to a range of medicines and health services. These businesses fall in the category of ecommerce of the B2C type and are rapidly growing in many parts of the world. Given the close association between medicine as a commodity and the health of its consumers and the high demand for pharmaceutical products, medicine circulation needs to be done strictly on time and with due attention to all relevant requirements in terms of storage, handling, security, and delivery. There are more than 20,000 types of medicines, many of which can be purchased from online pharmacies. Online pharmacies have certain features that distinguish them from other online businesses; for example, the high frequency of orders placed in small batches, scattered customers, and the vital importance of ontime and complete delivery.
The modus operandi of online pharmacies, of which there are currently very few in the world, is that the customer uses an online system or software to register an order for medicines or cosmetics, which may or may not require a prescription. Once confirmed, the order will be sent to all pharmacies or vendors that are affiliated with the system. These pharmacies check their inventory to see whether they have the requested items and then reject or accept the order with due consideration of all pertinent issues, such as whether the sale will be economic, etc. Once the order is accepted by a pharmacy, the items can be either shipped to the customer or remain in the vendor to be picked up by the customer. In some online pharmacy systems, the customer can check which vendors have the requested items and choose one of them based on personal preferences such as distance, product price, and delivery time.
An online pharmacy system will require a number of brickandmortar pharmacies in its operation domain to ensure the efficiency of order processing and the availability of products and services. Since each brickandmortar pharmacy will be able to hold certain amounts of medicines for certain amounts of time, for some orders, the system may need multiple brickandmortar pharmacies to work together. Given the multitude of brickandmortar pharmacies in the service area, there will be many different ways to handle and distribute orders. Since it is common to use multiple medicines simultaneously to achieve the desired therapeutic effects, each order tends to contain multiple types of medicines, which must be delivered together. Thus, for timely delivery of all items of each order in a single batch, it is necessary to optimize not only order distribution but also vehicle routing decisions (Hartley, 2014;Liu et al., 2020).
The subject of this study is how to find the optimal routes for timely and costeffective pickup and delivery of medicines from pharmacies to customers. In this decision, it is important to remember that medicines have a limited lifespan and lose their value after a period. Another important concern in this area is that all medicines should be delivered on time, as failing to do so can have catastrophic consequences. These requirements highlight the importance of distribution optimization in this field. Evidence shows that online pharmacies can benefit from more coherent structures and frameworks for decision optimization, which can be derived from the models and solution methods previously developed for other purposes, such as vehicle routing. With these techniques, these businesses will be able to make better use of their transport fleet and distribution network in their efforts to overcome challenges and achieve improved performance.
One of the notable studies in the field of home delivery is the study carried out by Campbell and Savelsbergh (2005), where they modeled a home delivery system whereby the company decides which orders to accept and assigns the accepted orders to time slots with a cost optimization objective. These researchers divided the order fulfillment process into three phases: (1) order capture and promise, (2) order sourcing and assembly, and (3) order delivery. They proposed a twophase heuristic for order capture and promise. In the first phase of this heuristic, an insertion algorithm is used to insert the already accepted orders in schedules starting with the “heaviest” ones. In the second phase, it is determined whether the new order can be inserted into one of the time slots of the created schedule. These researchers also approximated the expected profit of accepting an incoming order. The experimental performance evaluations of this study showed the great capability of the created heuristic in producing feasible results.
One of the most recent studies in this field is the study of Cwioro et al. (2019) on Attended Home Delivery (AHD) services, i.e. online shopping services that require customers to be present when their deliveries arrive. In these services, the vendor and the customer must mutually agree on a time window during which the product is to be delivered to the customer. Typically, the optimization of AHD systems involves the problem of capacitated vehicle routing with time windows. In their study, Cwioro et al. (2019) focused on an online grocery shopping service of an international grocery retailer, and particularly on the challenges of the ordering phase, i.e. the phase during which customers place grocery orders on the company's website. In this study, it was assumed that the delivery schedule needs to be created dynamically as new orders are placed on the service’s website. This article provided a solution for determining which delivery time windows can be offered to potential customers and to iteratively create the schedule. The ordering phase calculations were divided into four main stages, which were carried out using a heuristic and a hybrid method based on mixedinteger programming. Finally, an experimental evaluation was performed to demonstrate the effectiveness of the proposed approach. In a study by Yanik et al. (2014), they developed a business model for collaborative competition based on multiproduct sourcing between esupermarkets. The logistics aspect of this study was the design and execution of a network where premium goods can be picked up from several vendors at different locations and delivered to customers. This study aimed to investigate the role of this delivery of premium products in profit generation, develop a model for the resulting multiplepickup singledelivery vehicle routing problem, and propose a solution method for this problem. In this study, it was assumed that a group of products, called standard products, are offered in brickandmortar grocery stores and another group, called premium products, are only offered at a set of external thirdparty vendors. In other words, the grocery stores add the premium products provided by thirdparty vendors to the list of their standard products in order to attract more customers. The routing problem of this article consisted of two parts: (1) selecting vendors and allocating them to customers whose orders include premium products; (b) routing the vehicles so that they pick up the ordered premium products from vendors and combine them with the ordered standard products for delivery in a single batch. After assigning vendors to a customer, a combination of multiple pickups and a single delivery route were defined for that customer. To solve the problem, these researchers developed a hybrid metaheuristic approach consisting of a genetic algorithm for vendor selection and allocation and a modified savings algorithm for capacitated VRP with multiple pickups and single delivery and time window (CVRPMPDTW).
Yu et al. (2018) published an article on order distribution and delivery in online pharmacies, which can be considered the one closest to this paper in terms of general approach and scope of work. This article aimed to develop a model and a solution method for urgent distribution and delivery of medicine in an online pharmacy system. This article first discussed the importance of medicine distribution for the field of medicine and the fast growth of ecommerce and how these have led to the emergence of online pharmacies and then explained why further research needs to be done in these areas. The article then discussed three approaches whereby orders can be handled in existing brickandmortar pharmacies. This paper presented a model for creating an order distribution scheme and a medicine pickup plan for the set of medicines included in the order. In this model, which was based on the Joint Collection method, the goal was to produce an optimal solution by identifying which pharmacies are the best choices for sending transport vehicles and how medicine should be allocated to pharmacies. The objective of this model was to minimize the total cost of order fulfillment without violating order delivery requirements.
2. OPTIMIZATION MODEL
In this paper, we intend to model an online pharmacy network where medicines are picked up from brickandmortar pharmacies and distributed to customers based on orders, but with details that make this network completely different from current online pharmacies. This network is assumed to be consisting of a set of brickandmortar pharmacies located at specific points within the area of operation and a thirdparty logistics company that has a transport fleet suitable for this operation. It is assumed that the vehicles of this fleet remain parked at brickandmortar pharmacies until the orders are received. Once orders are received, scheduling and routing are done accordingly and vehicles start to pick up medicines from pharmacies to fulfill the orders. Schedule and route plans are built according to the size of orders placed for each medicine in the current period and other problem conditions such as the inventory situation of pharmacies. In the proposed model, each customer is assigned to one of the pharmacies where a vehicle is available, and each vehicle is strictly required to fulfill the orders it is assigned by using its own inventory or by picking up medicine from other pharmacies.
For this model, we need information such as the inventory of each pharmacy and the distance between different points of the network (e.g. customers and pharmacies). It is assumed that this information can be obtained from the database of the online pharmacy software and from the data constantly exchanged with the thirdparty logistics company. The innovation of this model is in how an improved system of online pharmacies is implemented. Essentially, what presented in this article is the formulation of the described network as a multidepot vehicle routing problem with time windows (MDVRPTW) in which items can be picked up from and moved between depots and vehicles fulfill the needs of depots as well as customers in their tours; an approach that is rarely taken in the literature. Therefore, this study contributes to the literature by using the said approach for a realworld problem related to the field, i.e. scheduling and routing in online stores and particularly online pharmacies.
2.1. Mathematical Formulations and Problem Assumptions
To make the model as realistic as possible, the following assumptions are defined for the problem:

 There is a strict delivery time window for each customer (because medicine must be received and consumed on time).

 The transport fleet operating at each level is homogenous and has a limited capacity.

 Each customer has a constant demand in the form of one order in which the type and quantities of needed medicines are clearly specified.

 The inventory levels of pharmacies and the distance between every two nodes in the network are known.
2.2 Sets and Indices

I and J: Sets of pharmacy nodes

p: Set of medicines

$n\in N,{n}_{p}\in N$ : Elements of the intersection of pharmacy and customer sets

m: Set of vehicles delivering medicine from pharmacies to customers

V: Set of vehicles moving medicine between pharmacies

c: Set of customers

u_{i}: Set of vehicles belonging to pharmacy i
2.3 Parameters

MM: A very large number

IO_{ip}: The initial stock of pharmacy i of medicine p

tc_{n,np}: The time it takes to move between pharmacies and customers or between two customers

D_{icp}: The demand of customer c for medicine p from pharmacy i

D'_{icp}: Equals 1 if customer c takes the D_{icp} amount of medicine p from pharmacy i, and is 0 otherwise

td_{ijv}: The time it takes for vehicle v to go from pharmacy i to pharmacy j

tc_{ic}: The time it takes to move between pharmacy i and customer c

CX_{vij}: The cost of moving from node i to node j by vehicle v

cc_{ip}: The inventory holding cost of pharmacy i for medicine p

cc'_{n'cm}: The cost of shipping medicine from node n' to node n by vehicle m

ub_{pc}: The maximum time allowed for medicine p to reach customer c

II_{p}: Inventory level of medicine p at pharmacy i
2.4 Variables

E_{vij}: Assigns node j to depot i and vehicle v belonging to that depot

TG_{m}: The departure time of vehicle m

II_{ip}: The inventory level of node i at the end of period p

y_{vjip}: The amount of medicine shipped from depot j to pharmacy i by vehicle v during period p.

AT'_{jpc}: The time medicine p for customer c reaches node j

TT_{cm}: The time vehicle m reaches customer c

u: A constraint variable for eliminating subtours

zz_{nn'm}: Equals 1 if vehicle m goes from node n to node n' and is 0 otherwise

AT_{ijv}: The time vehicle v departed from node i arrives at node j

C_{max}: The maximum time needed to fulfill deliveries

ID_{ip}: Equals 1 If medicine p is present in node i is 0 otherwise
$$\begin{array}{l}0.5({\displaystyle \sum}_{i\in I}{\displaystyle \sum}_{j\in J}{\displaystyle \sum}_{v\in V}C{X}_{vij}.{x}_{vij}+{\displaystyle \sum}_{i\in I}{\displaystyle \sum}_{p\in P}c{c}_{ip}.I{I}_{ip}\\ +{\displaystyle \sum}_{n\text{'}\in N}{\displaystyle \sum}_{n\in N}{\displaystyle \sum}_{m\in M}c{c}^{\text{'}}{}_{{n}^{\text{'}}nm}.z{z}_{{n}^{\text{'}}nm})+0.5({c}_{max})\end{array}$$ 
EE_{jc}: Equals 1 if customer c is assigned to depot i and is 0 otherwise.
2.5 Objective and Constraints
The objective function minimizes the cost of transport between pharmacies and from pharmacies to customers and the inventory holding cost arising from storing medicines in pharmacies. Constraint (1) and (2) specify the input and output of node j based on the vehicles belonging to node i. Constraint (3) is supposed to eliminate subtours. Constraint (4) ensures that if a vehicle enters a node, the next vehicle that exits that node is the same. Constraint (5) states that each node (depots or pharmacy) must be linked to another node or depot to which it is assigned. Constraint (6) guarantees that if one of the nodes of set j belongs to i, then there will be a route from depot i to those nodes. Constraint (7) ensure that there could be no route between two identical nodes. Constraint (8) determines the stock of medicine p in a pharmacy. Constraints (9) and (10) state that if depot or pharmacy i has a positive stock of medicine p, then IDip will be equal to 1. Constraint (11) determines the maximum capacity for transferring medicine p from node i to node j. Constraints (12) and (13) express the relationship between the variable y and the allocation variable E_{vij}. Constraint (14) states that E_{vij}=1 only when vehicle v belongs to i. Constraints (15), (16), and (17) determine the time of arrival at pharmacy j. Constraint (18) determines the time of arrival of medicine p for customer c assigned to pharmacy j. Constraints (19) and (20) determine the routes going in and out of node c. Constraint (21) is for the subtour removal. Constraint (22) states that the vehicles arriving at node n and those leaving node n must be the same. Constraint (23) guarantees that the routes assigned to a pharmacy are based on the customers allocated to the same pharmacy. Constraints (24) and (25) ensure that if customer c is assigned to pharmacy i, then EE_{ic}=1. Constraints (26) and (27) determine the departure time of vehicle m. Constraints (28) and (29) determine the time of arrival of vehicle m at customer c. Constraint (30) computes the maximum time needed to reach customer c by vehicle m and makes sure that it does not exceed the maximum allowed time. Constraint (31) determines the time of fulfillment of orders.
3. NUMERICAL CALCULATIONS
The smallscale instances of the proposed model with 4 pharmacies and 3 types of medicine were solved with GAMS 24.7.3 running on a computer with a Core i7 CPU and 8GB of RAM.
In order to research the relationship between the SCM quality deterioration factor γ_{p} and the objective value, we range γ_{1} and γ_{2} from 0.1 to 0.9, respectively. As shown in Figure 5, the objective value increases as the SCM quality deterioration factors increase. The parameter values and results obtained in this process are given in Table 1.
Sensitivity analysis was conducted using the additive weighting method with weights w_{1}=0.5 and w_{2}=0.5. Given the significant effect of the parameter cc'_{nn'm3} on system costs and delivery times AT'_{jpc}, sensitivity analysis was conducted on this parameter. The importance of this parameter stems from the fact that increasing cc'_{nn'm3} i.e. the cost of vehicle m3 should force the model to not use this vehicle to deliver goods as long as other vehicles are available, as it would increase the cost of the entire system. As shown in Table 2, changing this parameter changes the total cost of the model but has no effect on G_{max}. This is because the model is required to achieve the target order fulfillment time, or in other words, it must build a schedule in which cost is sacrificed for delivery time so that the final time of arrival at customer location does not exceed its upper limit i.e. ub_{cm} (this is a strict constraint). Therefore, it is willing to accept changes in system costs and schedule as long as the solution remains feasible and the system time remains unchanged.
4. CONCLUSION
The application of logistics and supply chain concepts in the field of ecommerce is a still evolving topic with many gaps in the research literature, which is more applicable and needful in the pandemic condition. Among the articles published in recent years on the topic of online stores and especially online pharmacies, very few have worked on the optimization of order allocation and delivery in situations where customers place a large number of orders with strict delivery time windows and the integration of this problem with the vehicle routing problem with pickups and deliveries, with due consideration of unique issues that arise when working with pharmaceutical products. Considering this gap in the literature and the growing role of ecommerce in modern life including how health services are provided, the field can benefit from an integrated system for the implementation of online pharmacies. Established businesses as well as startups can employ such tools for cost and time optimization of their online shopping systems, which will certainly increase their profit margins as cost and time are the two main determinants of success in this area. In this article, we designed an integrated model for strictly ontime fulfillment of orders placed by customers in an online pharmacy system by making vehicles pick up ordered items from the brickandmortar vendors. In the end, a small instance of the problem was solved and a sensitivity analysis was performed to evaluate the developed model. Future studies can improve this model and make it more realistic by considering several planning periods, heterogeneous transport fleet, and probabilistic demand, or test the model on realworld cases.