Location of Facility Based on Simulated Annealing and ( ZKW ) Algorithms

To copewith the facility location problem, amethod based on simulated annealing and “ZKW” algorithm is proposed in this article. The method is applied to some real cases, which aims to deploy video content server at appropriate nodes in an undirected graph to satisfy the requirements of the consumption nodes with the least cost. Simulated annealing can easily find the optimum with less reliance on the initial solution. “ZKW” algorithm can find the shortest path and calculate the least cost from the server node to consumption node quickly.The results of three kinds of cases illustrate the efficiency of ourmethod, which can obtain the optimum within 90 s. A comparison with Dijkstra and Floyd algorithms shows that, by using “ZKW” algorithm, the method can have large iteration with limited time. Therefore, the proposed method is able to solve this video content server location problem.

All these branches are applied to many fields like firefighting units [24], emergency services [16,25,26], healthcare location [27], gas marketing hubs [28], factory sites [29], supply chain network [30][31][32], and so on [33].Nowadays, with the development of Internet, more and more people surf the Internet to watch videos.And the fluency and quality of a video are vital because they will have a great impact on people's viewing experience.Although it is quite important to determine how to deploy the server to meet the requirements of consumers for a video service provider, the practical application of the problem is limited.
In this article, a method based on the simulated annealing and "ZKW" algorithms is proposed to deal with an application in such area.Simulated annealing algorithm, developed by Kirkpatrick et al. [34,35], can efficiently solve the NP problem with the advantages of avoiding falling into local optimum and less reliance on the initial solution; therefore, it is widely applied in many areas, such as image processing [36,37], vehicle routing [38,39], production scheduling [40], and machine learning [41]."ZKW" algorithm, proposed by ZKW [42], is an efficient and fast minimum-cost flow algorithm.We try to use simulated annealing algorithm to search optimum, which is searching some network nodes in the undirected graph to deploy video content server.At the same time, "ZKW" algorithm is used to find the shortest path and calculate the least cost from the video content server to the consumption node.The result of cases given by HUAWEI Code Craft illustrates that the proposed method can efficiently solve the facility location problem and find a good plan with limited time.What is more, a comparison with traditional shortest path algorithms, Dijkstra [43] and Floyd [44] algorithms, shows that, by using "ZKW" algorithm, the running speed is greatly improved.
The paper is organized as follows.Section 2 introduces some basic concepts about the simulated annealing and "ZKW" algorithm.Section 3 is an application in the cases given by HUAWEI Code Craft, which describes the problem and illustrates the specific model of simulated annealing and "ZKW" algorithm, and gives a pseudocode.The result analyses are given in Section 4 to indicate the effectiveness of the method.The conclusions are drawn in Section 5.

Preliminaries
In this section, some basic concepts are briefly introduced.
2.1.Simulated Annealing.Simulated annealing (SA), first proposed by Metropolis et al. [45] in 1953 and further developed by Kirkpatrick et al. [34,35] in 1983, is a stochastic searching optimization algorithm.The algorithm is deprived of the solid-annealing principle.It refers to heating the solid material at an enough high temperature, at which the inner particles of the material will become disordered and the internal energy will increase.Then, bringing down the temperature to decrease defect and reach an equilibrium at each temperature, the system's energy is minimized [35].
In optimization problem, the simulated annealing algorithm is explained as lowering the temperature of the system until it converges to a feasible and steady solution.During the process, while the temperature is high, accepting a solution that is worse than the current solution will be allowed to ensure the algorithm to jump out of local optimum.In the meantime, a slow decrease in the probability of accepting a worse solution with exploring the solution space is adopted to allow the algorithm to gradually focus on an area to search the optimum solution [35].
Suppose that there is an optimization problem, which is min  () ,  ∈ , where () is an objective function,  is a finite solution space, and  is the current solution.The solution steps of simulated annealing algorithm (the flow chart is shown in Figure 1) could be depicted as follows: (1) Choose an initial solution  ∈  at random and select an initial temperature  0 as well as a final temperature   .

"ZKW"
Algorithm."ZKW" algorithm, proposed by ZKW [42], is a minimum-cost flow algorithm.The major idea of the algorithm is finding the augmenting path.Before further discussing the algorithm, the property of the shortest path will be introduced.Suppose that dis[] is the shortest distance from node  to the starting node and that (, ) is the distance between node  and node : (1) For any edge(, ) in the shortest path, it will satisfy dis[] ≤ dis[] + (, ).(2) For any node  in the shortest path, there will be a node  that will satisfy dis[] = dis[] + (, ).
In the process of finding a shortest path, if we follow the rule of dis[] ≤ dis[] + (, ) to augment, it will satisfy the first property.However, the second property may not be satisfied.In order to find a new augmenting path, the Dijkstra or Floyd algorithm is needed to recalculate and find out node  that satisfies the second property, which will waste lots of time.Thus, we can use the strategy of the KM algorithm [46][47][48].Every time, the edge that satisfies the second property will be augmented.If the path cannot reach the ending node, dis[] of node  that is on the augmenting path (ap) will add Δ, where Δ = min ∈ap,∉ap (dis[] + (, ) − dis[]).Therefore, there will be another edge that satisfies the second property that can be added.
The steps of the algorithm are as follows: (1) Clear the array dis, which means that there is only a starting node in the current subgraph.
(2) For the depth-first search, if in this process the ending node can be reached, backtrack and minus the flow that has been used.Then, run this step again.If the ending node cannot be reached, turn to the next step.
(3) Add Δ to dis[] and find another edge to add in the subgraph until no more edge can be added, thus, end.

Application in Facility Location Problem
In this section, the proposed method is described in detail when applying to real cases given by [49].

Problem Description
Network Structure Model [49].The real world is very complicated; complex network is used to model the uncertainty and complexity [50][51][52][53][54]. Facility location problem can be seen as a network optimization [55].Many methods for optimization and decision-making under uncertainty, such as fuzzy sets [56][57][58], evidence theory [59], and D numbers [60][61][62], are applied to address this issue [63,64].For the sake of simplicity, the problem is abstracted into a given undirected graph that consists of some network nodes.Each node is connected with at least one node through the network link.At the same time, the node can transmit data through the network link to the other nodes that are connected.The total bandwidth and the rental fee of each network link are different.The network link needs to charge the rental fee based on the usage of bandwidth.
Consumption Node [49].In the given undirected graph, some nodes are connected with the consumption nodes directly.The consumption requirement of each consumption node is different.One consumption node can obtain video data from several video content servers at the same time.
Video Content Server [49].The video content server can provide infinite video data, which means that it can serve several consumption nodes.The data is transmitted to the consumption node through the network path that is composed of network nodes and network links.
Requirements [49].Under the condition of satisfying the requirements of all consumption nodes, select some network nodes from the given network structure model and deploy the video content server reasonably and properly to receive the least cost, which consists of the cost of deploying the video content servers and rental fee.

Model of Simulated Annealing
The Objective Function.The problem requires choosing some appropriate network nodes to deploy the video content server so that the requirements of the consumption nodes could be satisfied with the least cost.The cost consists of the servers' cost and the rental fee.Therefore, we can obtain the objection function, which is where  is the total number of video content servers that need to be deployed; SC is the cost of video content server;  is the number of consumption nodes; thus, there are  network paths connecting the consumptions nodes and video content servers; CC  is the cost of rental fee for th consumption node.
The Domain Structure.Different domain structure will have a different influence on finding a good solution for the simulated annealing.In solving the problem, we propose three kinds of domain structures listed as follows: (i) Reducing a video content server at random, which means a network node that has been deployed with a video content server will be chosen randomly and removed from the current deploying plan (ii) Adding a video content server at random, which means a network node that has not been deployed with a video content server will be chosen randomly and added to the current deploying plan (iii) Changing a video content server at random, which means a network node that has been deployed with a video content server in the current deploying plan will be chosen randomly and replaced by another network node When choosing the structure at each iteration, the random number is used.That is, generating a random number  = (0, 1), where  1 ,  2 are the parameters used to adjust the selective probability of different domain structures.
The Temperature Parameters.Generally, there are two widely used cooling schedules, which are  +1 =   ⋅  and  +1 =   − Δ, where  and Δ are constants.The schedules are simple and practicable.However, the temperature does not cool down quickly; thus, we will adopt another schedule proposed by Lundy and Mees [65], which is  +1 =   /(1 +  ⋅   ), where  is a constant.When the temperature is high, the temperature of the schedule can cool down with a large interval.As the number of iterations increases, the schedule will have slower cooling than a proportional temperature reduction with fixed  and Δ.Therefore, the algorithm can search the optimum solution on an area.The comparison of different cooling schedules will be discussed in the next section.
In order to avoid being trapped in a local optimum, we suggest returning to a higher temperature and search again when the temperature is cooled down at a relatively low level.
The initial temperature and the final temperature will also have a great influence on the performance of the simulated annealing.In general, the initial temperature should be larger so that the algorithm can be in equilibrium at the beginning.And the final temperature should be smaller so that the algorithm can have enough time to reach an optimal solution.

Model of "ZKW" Algorithm.
In finding an optimum plan, we need to obtain the shortest path (the least cost) from the video content server to the consumption node.Generally, Dijkstra [43] and Floyd [44] are the two algorithms that are suited to the issue.However, the time complexity of Floyd algorithm is ( 3 ), and that of Dijkstra algorithm is ( 2 ).Neither is fast enough to get an optimal solution with limited time, which is 90 seconds in the problem.As being introduced above, "ZKW" algorithm can save the time that is used to recalculate dis[] every time, which is huge waste.Thus, "ZKW" algorithm is much better for applying to the problem.

The Pseudocode.
See Pseudocode 1. Operation system: 64-bit Windows 10, professional edition 4.2.The Result of the Proposed Method.Three kinds of cases will be applied to test the proposed method.The first case is a primary case, which contains 160 network nodes and 609 network links in the undirected graph with 72 consumption nodes.The second case is an intermediate case, which contains 300 network nodes and 1169 network links in the undirected graph with 135 consumption nodes.And the third case is an advanced case, which contains 800 network nodes and 2959 network links in the undirected graph with 360 consumption nodes.All data come from the preliminary contest in [49].The results are shown in Table 1.

Result Analyses
As shown in Table 1, for primary case, the total iteration can reach over 170 thousand within 90 seconds, which means the algorithm can process a great amount of searching.Thus, it can be easy to find an optimum.Similarly, the algorithm can also reach high iterations and relatively stable solutions in the intermediate and advanced cases.
In general, the proposed method not only is fast enough but also is able to find an optimal solution.So it is suitable for this facility location problem that needs to deploy the video content sever at appropriate network node to satisfy the requirement of the consumption nodes in the undirected graph.

Comparison of Different Methods to Calculate the Least
Cost.In this problem, the time is limited to 90 s; thus, the running speed is quite important: the faster the better.In searching appropriate network node to deploy the video content server in the undirected graph, the shortest path from the server to the consumption node needs to be found out and calculated.Generally, Dijkstra and Floyd algorithms are used to calculate the shortest path.However, the time complexities of algorithms are too high."ZKW" algorithm provides us with another method to find the shortest path."ZKW" is a cost flow algorithm.The problem can be explained as finding the least cost with set flow.And, by using the "ZKW" algorithm, the augmenting process is actually a process of finding the shortest path, so the time could be greatly saved.A comparison of Floyd, Dijkstra, and "ZKE" algorithms under the intermediate case is shown in Table 2.
It is easy to find in Table 2 that the iteration of "ZKW" algorithm incredibly increases when compared with Floyd and Dijkstra algorithms.In a condition that ensured the high speed, the method that uses "ZKW" algorithm can find a much better solution.By the way, although the iteration of "ZKW" algorithm is almost 100 times as large as that of Dijkstra algorithm, the least cost only reduces about 2000.It means that a large number of iterations failed or that they might be trapped in a local optimum.So the proposed method could be further improved.

Determination of Temperature
Constants  and .In the article, the cooling schedule  = /(1+) is chosen instead of  = .In order to illustrate the reason, the performances of these two schedules are discussed.And the most reasonable  and  need to be found out firstly.Suggested by [65],  should be less than 1/, where  is any upper bound on max Δ.In the advanced case,  is about 1000.And, typically, the value of  lies between 0.8 and 0.99.Therefore, based on the advanced case, the experiment is carried out and the result is shown in Figure 2.
In the given scope of , the variation curve of cost with the cooling schedule  = /(1 + ) is close to a parabolic curve, whose minimum could be reached at about 0.005.On the other side, in the given scope of , the variation curve of cost with the cooling schedule  =  is fluctuant, showing no obvious minimum.And the extremum is less than 700, which could be due to the stochastic error.So  is set at about 0.97.
With the initial temperature increasing, the iterations of two cooling schedules decrease (see Figure 3).This is because, in a higher temperature, simulated annealing will search for the solution in a large solution space, which may cost much time.Although higher initial temperature may lead to the possibility of finding the global optimum, the actual result (see Figure 4) indicates that the cost is larger than a low initial temperature, especially with the cooling schedule  = 0.97.Therefore, high initial temperature is not applicable for the advanced case.
Different cooling schedules will also have an impact on the performance of the algorithm.Apparently, the iteration of the schedule  = 0.97 is always lower than the schedule  = /(1 + 0.005).In addition, the cost of the schedule  =   0.97 is always larger than the schedule  = /(1 + 0.005).
What is more, the change of the initial temperature only has a little impact on the schedule  = /(1 + 0.005), while the result of the cooling schedule  = 0.97 changes a lot.Thus, the cooling schedule  = /(1 + 0.005) is more stable and has strong robustness.Generally, simulated annealing has a better performance than tabu search under the intermediate case, while tabu search performs better under the advanced case.And both algorithms are able to find the global optimum when the scale of problem is small.This might be due to the different strategy for the algorithm to escape from the local optimum.Tabu search will only try to escape when it is trapped in the local optimum, while simulated annealing could escape at any time.Therefore, when the solution space is so large that the algorithms are unlikely to find the global optimum or have less chance to reach a more reasonable space to search, tabu search is more likely to reach a better solution than simulated annealing.On the contrary, when the solution space is not so large, like the intermediate case, the simulated annealing's strategy may be more suitable.

Conclusions
In this article, a method that combines simulated annealing algorithm with "ZKW" algorithm is proposed to solve the facility location problem.The method is applied to the cases given by HUAWEI Code Craft, which aims to find the appropriate network nodes to deploy video content server to   satisfy the requirements of consumption nodes with the least cost in an undirected graph.By using the simulated annealing algorithm, we can easily find an optimum.Meanwhile, the "ZKW" algorithm makes it possible to find the shortest path and calculate the least cost with limited time.
The results of primary case, intermediate case, and advanced case illustrate the efficiency of the proposed method, which has not only a large iteration and less cost but also good robustness.Moreover, a comparison with traditional shortest path algorithms, Dijkstra and Floyd, shows that "ZKW" algorithm can greatly improve the speed of the program.In a limited amount of time, which is 90 s, the running speed is quite important.The higher the running speed is, the more possibility for the simulated annealing to find the optimum there is.Besides, a comparison with tabu search shows that our method is more suitable for an intermediate scale of problem.In general, the proposed method that combines simulated annealing algorithm with "ZKW" algorithms performs pretty well in solving this video content server location problem.

Figure 1 :
Figure 1: The flow chart of simulated annealing algorithm.

Figure 2 :
Figure 2: Cost under different  and .

Figure 3 :
Figure 3: Iteration under different initial temperature and cooling schedule.

5 Figure 4 :
Figure 4: Cost under different initial temperature and cooling schedule.

4 Figure 5 :
Figure 5: Comparison with tabu search under the primary case.

Figure 6 :
Figure 6: Comparison with tabu search under the intermediate case.

Figure 7 :
Figure 7: Comparison with tabu search under the advanced case.

Table 1 :
Results of the proposed method under different cases.

Table 2 :
Comparison of Floyd, Dijkstra, and "ZKW" algorithms under the intermediate case.