Abstract

To cope with the facility location problem, a method 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 our method, 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.

1. Introduction

Facility location problem, first introduced by Alfred and Friedrich [1], is a classical and well-studied problem. The goal of this problem is to find optimal locations to build facilities so that the solution of the problem can serve the consumers or clients with the least cost. Generally, the facility location problem could be divided into median problem [2, 3], covering problem [47], center problem [810], multiproduct problem [11, 12], dynamic location problem [13, 14], multiobjective location problem [1517], competitive problem [18, 19], network reliability problem [20, 21], and network center location problem [22, 23].

All these branches are applied to many fields like fire-fighting units [24], emergency services [16, 25, 26], healthcare location [27], gas marketing hubs [28], factory sites [29], supply chain network [3032], 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.

2. 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 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 as well as a final temperature .(2)Generate a domain solution , where is the domain structure of ; calculate the increment of the objection function .(3)If , then accept the new solution, ,  , and turn to the next step. Otherwise, generate a random number . According to the Metropolis criterion, if , accept the new solution, ,  .(4)If the heat balance (the inner cycle number larger than ) is reached, turn to the next step. Otherwise, go back to the second step.(5)Cool down the temperature , and . If , stop the algorithm. Otherwise, go back to the second step.

2.2. “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 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 .(2)For any node in the shortest path, there will be a node that will satisfy .

In the process of finding a shortest path, if we follow the rule of 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 [4648]. Every time, the edge that satisfies the second property will be augmented. If the path cannot reach the ending node, of node that is on the augmenting path will add , where . 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 , 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 and find another edge to add in the subgraph until no more edge can be added, thus, end.

3. Application in Facility Location Problem

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

3.1. Problem Description

Network Structure Model [49]. The real world is very complicated; complex network is used to model the uncertainty and complexity [5054]. Facility location problem can be seen as a network optimization [55]. Many methods for optimization and decision-making under uncertainty, such as fuzzy sets [5658], evidence theory [59], and D numbers [6062], 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.

3.2. 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; 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 , where 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 and , 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 , 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.

3.3. 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 , and that of Dijkstra algorithm is . 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 every time, which is huge waste. Thus, “ZKW” algorithm is much better for applying to the problem.

3.4. The Pseudocode

See Pseudocode 1.

  Read the data file;
  NowPlan=Initial a plan;
  The simulated annealing algorithm
  Initial the parameter;
  while do outer circulation
(6)    while do inner circulation
(7)      Generate a domain structure and a random number.
(8)      if then
(9)       NewPlan=Add a video content server;
(10)    else if (random a2) then
(11)     NewPlan=Reduce a video content server;
(12)    else
(13)     NewPlan=Change a video content server;
(14)    end if
(15)    Calculate the min cost of the plan by ZKW algorithm.
(16)    Transmit the data of the graph into the ZKW algorithm to calculate
     the mincost of the current plan.
(17)    Calculate = NewPlanCost − NowPlanCost.
(18)    if then
(19)     NowPlan = NewPlan;
(20)    else
(21)     Calculate and Generate a random number.
(22)     if ( random) then
(23)      NowPlan = NewPlan;
(24)     end if
(25)     end if
(26)    ;
(27)   end while inner circulation
(28)    ; Cool down the temperature.
(29)   if ( is low enough) then
(30)    set a large .
(31)   end if
(32) end while outer circulation
(33) ZKW algorithm
(34) Initial the parameter;
(35) method of bool
(36) Boolean the edges that still have flow but have not been visited.
(37) method of augment
(38) Augment until it reaches the ending node, then recall and minus
  the flow of the visited nodes, and recurse and continue augmenting.
(39) method of zkw
(40) while (Invoke the method of bool) do
(41)  while (Invoke the method of augment) do
(42)    for ( to visited.length) do
(43)    visited[] = false;
(44)   end for
(45)  end while
(46) end while
(47) return mincost;

4. Result Analyses

4.1. Operating Environment

The details of the operating environment are given as follows:CPU: Intel(R) Core(TM) i5-3337U CPU @ 1.80 GHzMemory: 4.00 GBKernel: Two coresCompiler: Java 1.7.0_71Operation 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.

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.

4.3. 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.

4.4. Determination of Temperature Constants and

In the article, the cooling schedule 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 , where is any upper bound on . In the advanced case, is about . And, typically, the value of lies between and . 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 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.

4.5. Comparison of Different Temperature Parameters

In order to find out a better temperature parameter of the simulated annealing algorithm, including the initial temperature and the cooling schedule, two cooling schedules and are selected to run the program with the initial temperature . Based on the advanced case, it will be run for five times to obtain a mean value when the parameter is changed. And the result is given in Figures 3 and 4.

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 . 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 is always lower than the schedule . In addition, the cost of the schedule is always larger than the schedule . What is more, the change of the initial temperature only has a little impact on the schedule , while the result of the cooling schedule changes a lot. Thus, the cooling schedule is more stable and has strong robustness.

4.6. Comparison with Tabu Search

Since tabu search (TS) could balance the global and local searching, while simulated annealing mainly focuses on global searching, in this article, a comparison with tabu search is made to further discuss the proposed method. The searching processes are shown in Figures 5, 6, and 7.

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.

5. 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.

Conflicts of Interest

The authors declare that there are no conflicts of interest regarding the publication of this paper.

Acknowledgments

This work is partially supported by the National Natural Science Foundation of China (Grants nos. 61573290 and 61503237).