INVERSE SINGLE FACILITY LOCATION PROBLEM ON A TREE WITH BALANCING ON THE

. We introduce a case of inverse single facility location problem on a tree where by minimum modifying in the length of edges, the diﬀerence of distances between the farthest and nearest clients to a given facility is minimized. Two cases are considered: bounded and unbounded nonnegative edge lengths. In the unbounded case, we show the problem can be reduced to solve the problem on a star graph. Then an O ( nlogn ) algorithm is developed to ﬁnd the optimal solution. For the bounded edge lengths case an algorithm with time complexity O ( n 2 ) is presented.

an O(n 2 ) algorithm for the inverse 1-median problem. The inverse 1-median and 1center problems on trees with Chebyshev and Hamming norms have been considered by Guan and Zhang [16] and Nguyen and Sepasian [26], respectively. Sepasian and Rahbarnia [30] investigated the inverse 1-median problem with varying vertex and edge length on trees. Nguyan [25] developed an algorithm for the inverse 1-median problem with variable vertex weight on block graphs. Recently, Nazari et al. [24] considered the inverse of backup 2-median problem on trees. Alizadeh et al. [1] proposed a combinatorial algorithm for the inverse obnoxious median problem on trees.
The balanced facility location problems deal with finding the location of the facilities such that the equality in serving to the demand points is maximized. This kind of facility location models have been considered by many authors. Among them, the model of maximizing the difference of distances between a demand point to its farthest and nearest facility has been considered by Gavalec and Hudec [15]. Berman et al. [6] studied the problem of finding the location of p facilities such that the maximum weight assigned to each facility is minimized. Marin [21] deals with the case that the difference between the maximum and minimum weights allocated to different facilities is minimized. Fathali and Zaferanieh [13] developed polynomial time algorithms for the balanced 2-median and obnoxious 2-median models on trees. Davoodi [11] presented a multi-objective model for balanced center location problem. Omidi et al. [27] considered the inverse 2-facility location problem on a tree which aim to modify the edge lengths such that the problem is balanced. Lejeune and Prasad [20] proposed a bi-criteria model for the problem in which has a trade off between effectiveness and equity. Landete and Marin [19] studied the problem of minimizing the differences of the weights that allocated to the facilities. Barbati and Piccolo [5] developed some properties of the equality measures in facility location models to describe the behavior of this problems. Sayar et al. [29] considered the problem of balancing allocation with regard to the efficiency of the servers. Pham et al. [28] discussed the balance vertices on trees and developed a linear time algorithm to find the set of balance vertices on the underlying tree. For more details and literature reviews on balancing in location theory see e.g. [22,12].
The 1-center problem consider the finding the location of a new facility such that the distance of farthest client to the new facility is minimized. Therefore, just the clients on the farthest points are investigated. To make a balance in serving the clients, other kind of objective functions can be considered. One of them, is minimizing the difference of distances between the farthest and closest clients to the new facility. Applications of this kind of location model arise when some clients may move to the location of other clients. In this paper, we consider the inverse of this single facility location problem on a tree, i.e. by modifying the lengths of edges with minimum total cost the difference of distances between the farthest and nearest clients to a given facility is minimized. Two cases are considered: 1-the length of edges are unbounded and nonnegative, 2-the length of edges are bounded and positive.
In what follows the considered inverse single facility model is defined in Section 2. In Section 3 we show that the problem with nonnegative unbounded edge lengths on tree graphs can be reduced to solve the problem on a star graph. Then an O(nlogn) algorithm is presented to solve this problem in Section 3.1. In Section 4 we consider the problem with bounded edge lengths on a tree and develop an O(n 2 ) algorithm.
2. Problem definition. Let the tree T with vertices set V , |V | = n, and edges set E, be given. For each edge e i ∈ E, let l i ≥ 0 be the length of edge e i . Let d(v i , v j ) be the length of the shortest path between vertices v i and v j in T . Let x ∈ V be the location of the given facility in T . In the inverse balanced facility location problem we want to modify the lengths of edges with minimum cost such that the difference distances between the farthest and closest clients to the given facility is minimized. For any edges e i , suppose that the cost of increasing per unit of l i is c + i ≥ 0 and the cost of decreasing per unit of l i is c − i ≥ 0. Let q + i and q − i be the amounts by which the length l i is increased and decreased, respectively. For each e i ∈ E, let Note that the new length of edges should not be negative, i.e. l i ≥ 0 or q − i ≤ l i , for every e i ∈ E. Let Then in our inverse model, among modified edge lengths minimizing f 2 , we want to find the modification that minimized f 1 . whered(u, x) is the length of shortest path between vertices u and x respect to the modified edge lengths.
As mentioned in Heuberger [18], possible application of the inverse location models arises when we are faced with the situation that the facility already exist and can not be relocated in reasonable costs. In this case, we may change the weight of vertices or edge lengths of the network as little as possible such that a given facility becomes optimum. Specially, our considered inverse model can be applied in the situation that a road network and the location of a facility server is given and we want to modify the traffic network such that the servicing of the facility to the clients is balanced.
3. The problem with unbounded edge lengths. In this section we consider the unbounded edge lengths case, i.e.l i ≥ 0, for every e i ∈ E. We focus on minimizing f 2 with minimum cost. Then obviously in this case, the optimal value of f 2 is zero, where the lengths of all paths from x to other vertices are equal. Therefore, we can consider the following model.
Therefore, in this section we try to find a solution that satisfied in (4), i.e. feasible solution, with minimum cost. Let P 1 and P 2 be the set of paths from x to the farthest and closest vertices in T \ {x}, respectively. Note that P 1 and P 2 are not fixed and will be updated during the algorithm. Also the following observations can be considered.

Observation 1.
A feasible solution can be obtained by either reduce the length of some edges on paths in P 1 or augment the length of some edges on paths in P 2 .
Observation 2. If there exists two paths p i ∈ P 1 and p j ∈ P 2 , such that p j contains p i then any change on edges of p j does not improve the feasibility of the solution.
Let Adj be the set of all adjacent edges of x. In the following lemma, we show that if any path in P 2 is a part of a path in P 1 , then in the optimal solution, the length of all nonadjacent edges to x is zero.
If there exists a path in P 1 which contains a path in P 2 , then in the optimal solution the length of each edge e / ∈ Adj is zero.
Proof. Let p i ∈ P 1 be contains p j ∈ P 2 . Then by observations 1 and 2, we should reduce the edges of p i \ p j . Therefore, to obtain a feasible solution, we set zero the length of all nonadjacent vertices of x. Also we can conclude the following lemmas.
Lemma 3.2. If just reduction length of edges is permitted, then to obtain an optimal solution it suffices to setl where Lm is the length of any path in P 2 . In this case the cost of finding the optimal solution can be computed as Proof. Since just reduction is permitted, then the same as Lemma 3.1, in the optimal solution the length of all nonadjacent edges to x are zero. Also the length of all adjacent edges of x, that they are not a part of any path in P 2 should be reduced to Lm. The reduction cost of edges is concluded immediately.
Lemma 3.3. If just augmenting length of edges is permitted, then to obtain a feasible solution it suffices to augment the length of edges adjacent to x.
In the following theorem we show that to solve the problem on a tree, it suffices to solve it on a more smaller sub-tree.
Lemma 3.4. Solving the problem on a tree, is equivalent to find the optimal solution on a tree which induced in x and its adjacent vertices.
Proof. The proof is concluded with this fact that to obtain a feasible solution we should reduce and augment the length of some edges on the paths in P 1 and P 2 , respectively. Then we will reach a path in P 2 which is a part of a path in P 1 . Therefore, by Lemma 3.1, the length of all nonadjacent edges to x should be zero in the optimal solution.
Let T x be the sub-tree of T which is induced by x and its adjacent vertices. Indeed, T x is a star graph. Therefore, in the next section, we concentrate on the finding the optimal solution on an star graph and show it can be found in O(n x logn x ) time, where n x is the number of edges of T x . Therefore, the following theorem can be concluded for the problem on a tree. Note that since d ≤ n, therefore the upper bound of complexity on a tree is O(nlogn).
3.1. The problem on a star graph. Let T be a star graph and x be the vertex of T with degree larger than 1. Note that we consider this case, because by Lemma 3.4 the problem on tree reduce to solve the problem on the mentioned star graph. Let P 3 and P 4 be the set of longest and shortest edges in T , respectively. Then to find the optimal solution on T , let be the ascending order of distances between vertices of T and x. The following actions can be used to achieve a feasible solution.
1. Reduce the length of each edge e j ∈ P 3 , j = 1, ..., n 1 , where n 1 = |P 3 |. In this case to guarantee all edges in P 3 remain longest edges in T , we should decrease the length of all of them, simultaneously. Note that the length of each edges in P 3 is d r and should be reduced to d r−1 . This reduction improves the feasibility with K 1 = d r − d r−1 , which needs the following cost 2. Augment the length of all edges in P 4 . In this case the length of any edge e in P 4 is equal to d 1 and can be increased to d 2 . Therefore, the feasibility is improved by The cost of this length augmentation is In each iteration of the algorithm we select one of these actions. The action with most feasibility improvement and minimum cost should be chosen. However, Therefore, the action corresponding to the following is selected.
These ideas lead us to the following algorithm for finding the optimal solution on a star graph.
Algorithm [ISFBDS]. Input: The star graph T , where x as the location of the facility, is the vertex of T with degree larger than 1. Also, the cost of increasing and decreasing of edges lengths are given.

Output:
The new lengths of edgesl i such that f 2 = 0. Initialization: Let D = {d 1 , d 2 , ..., d r } be the increasing order of edge lengths of T , (therefore d 1 < d 2 < ... < d r ). Let P 3 and P 4 be the sets of edges that their lengths are d r and d 1 , respectively. Set f 1 := 0, f 2 := d r − d 1 , t := r and s := 1.

End while End of algorithm
To calculate the time complexity of the algorithm, let n T be the number of vertices of star T . Then the length edges of T can be sorted in O(n T logn T ) time.
In the worst case we may need to jump the length of an edge from d 1 to d 2 and then d 3 until reach d n T or vice versa. Therefore, in this case Iteration step will iterated O(n T ) time. Therefore the time complexity of the algorithm is O(n T logn T ).
Theorem 3.6. The inverse single facility location problem with balancing on distances from clients to server on stars can be solved in O(n T logn T ) time.
To illustrate the presented algorithm consider the following example.
Example 1. Consider the tree T depicted in Fig. 1. The length of edges and the costs of increasing and decreasing the lengths of edges are given in Table 1.
Using Lemma 3.4 it suffices to reduce the length of edges l 1 , l 4 , l 5 , l 7 , l 9 and l 10 to zero and find the solution on the remaining star graph. The cost of reduction  Table 1. The lengths and costs of changing lengths of edges in tree T .
In the next iteration we obtain P 3 = {e 3 , e 2 , e 8 } and P 4 = {e 6 }. Then C 1 = 2 + 1 + 2 and C 2 = 5. Since C 1 = C 2 then we can either reduce the length of edges in P 3 or augment the length of edge in P 4 . Let we set l 6 = 3 then f 1 = 14, f 2 = 0 and algorithm terminates. The total cost of finding the optimal solution on original tree is 88.
4. The problem with bounded edge lengths. In this section we consider the case that the length of edges are bounded, i.e. for each e i ∈ E, 0 < l i ≤l i ≤l i , wherel i and l i are the upper and lower bounds of the length of edge e i , respectively. In this case the optimal value of f 2 may not be zero.
Let T = (V, E) be the underlying network. Let the notations P 1 , P 2 , Lm and Adj are defined the same as Section 3. Then the observations 1 and 2 and Lemma 3.3 also hold for bounded edge lengths case. Since we suppose l i > 0 then the following observation also holds.
Observation 3. Each path in P 2 contains only one edge which are adjacent to x.
Lemma 4.1. In the bounded edge lengths case if there exists a path in P 1 which contains a path in P 2 , then in the optimal solution exist a path p i ∈ P 1 such that for each edge e r ∈ p i \ Adjl r = l r Proof. Since there exists a path in P 1 which contains a path in P 2 , by observation 2, we should just reduce the length of edges on the paths in P 1 . Therefore, we reduce the length of all edges in all paths in P 1 that are not adjacent to x, until the length of all edges of a path in P 1 that are not in Adj, reaches their lower bounds. Now to present the algorithm, we want to choose an edge and reduce or augment its length, in each iteration. Before explaining the algorithm, we need the following definition.
Definition 4.2. A path p in P 1 is called saturated if the length of all edges in p reaches their lower bounds, i.e. for each e t ∈ p, l t = l t , and a path q in P 2 is called saturated if for each e r ∈ q, l r =l r .
Firstly, let there is no path in P 1 that contains a path in P 2 . The same as Section 3, let d 1 < d 2 < ... < d r be the ascending order of distances between vertices of T and x. The following two actions may be used to achieve a feasible solution. Reduction. Reduce the length of an edge on each path p j ∈ P 1 , j = 1, ..., n 1 , where n 1 = |P 1 |. In this case to guarantee all path in P 1 remain longest path from x, we should decrease the length of all of them, simultaneously. If there exists a saturated path in P 1 then we can not reduce the length of longest path, therefore this action is incapable. Otherwise, in each path p j ∈ P 1 , j = 1, ..., n 1 , we select the edge with minimum reduction cost and reduce its length. Note that if this edge is in Adj then its length can not be less than Lm. Therefore, for j = 1, ..., n 1 , set Then we reduce the length of each e hj to l hj − K 1 , where which is the value of feasibility improvement. This reduction needs the following cost Augmentation. Augment the length of all edges on paths in P 2 . In this case the length of each edge e t on path p j ∈ P 2 is equal to d 1 . Note that p j contains singleton edge e t . Therefore, the feasibility can be improved by where n 2 = |P 2 |. The cost of this length augmentation is In each iteration the action with most feasibility improvement and minimum cost should be chosen. In the same manure of Section 3.1, the action corresponds to the following is selected. min{ pi∈P2, et∈pi In this case, i.e. in the case that there is no path in P 1 contains a path in P 2 , the algorithm terminates, if the following conditions hold.
C1. An adjacent edge to x in P 2 reaches its upper bound, on the other word there exists a saturated path in P 2 . C2. There exists a path p r ∈ P 1 , that all nonadjacent edges to x of p r reach their lower bounds and the length of edge in p r ∩ Adj reaches its lower bound or Lm. On the other word, let e a ∈ p r be the adjacent edges to x, then for each edge e t ∈ p r , e t = e a ,l t = l t and l a = max{l a , Lm}.
Second, if we reach the case that a path in P 1 contains a path in P 2 then in the current iteration and all the next iterations just reduction is considered. In this case the algorithm terminates if condition (C2) holds. These ideas lead us to the following algorithm.

Iteration step
1. If there exists a saturated path in P 1 and a saturated path in P 2 then stop, the current length of edges are optimal. 2. If there exists a saturated path in P 2 and condition (C2) holds then stop, the current length of edges are optimal. 3. If there exists a saturated path in P 1 then (a) Set C P2 := pi∈P2, et∈pi c + t . (b) Compute K 2 using relation (12). (c) For any edge e t on each path p i ∈ P 2 , set l t : If there exists a path in P 1 which contains a path in P 2 then (i) If condition (C2) holds then stop, the current length of edges are optimal. (ii) For each p j ∈ P 1 , j = 1, ..., n 1 , set hj (iii) Set Lm := d min1 and K 1 := min{d r − d r−1 , RL 1 , ..., RL n1 }, where for j = 1, ..., n 1 , RL j are defined in relation (10). (iv) For j = 1, ..., n 1 , set l hj := l hj − K 1 .
(  (12). (B) For any edge e t on each path p i ∈ P 2 , set l t : (b) If f 2 = 0 stop, the optimal solution is achieved. else (i) Find P 1 and P 2 which are the sets of longest and shortest paths from x, respectively. (ii) Find d min2 and d max2 which are the second closest and farthest vertices to x, respectively. (iii) Go to Step 1.

End of algorithm
To calculate the time complexity of ISFBDB algorithm, note that the longest and shortest paths can be computed in O(n) time (see e.g. [17,7]) and each step of the algorithm needs at most O(n) time. In each iteration either f 2 reduces from d r to d r−1 or an edge reaches to its lower or upper bound. Therefore, the iteration step repeats at most O(n) times. Thus the time complexity of algorithm is O(n 2 ). Example 2. Consider again the tree T in Example 1, where the bounds of its edge lengths are given in Table 2.
The distances of farthest and closest vertices to x are 15 and 1, respectively. Thus, d max1 = 15, d min1 = 1 and f 2 = 14, also P 1 = {p 1 } and P 2 = {p 2 } where p 1 = {e 3 , e 4 , e 5 } and p 2 = {e 6 }. Table 3 contains the iterations result for this example. In the first iteration there isn't any saturated path and the path p 1 does not contain p 2 . Therefore, in this iteration we should calculate both C P1 and ei li lili e1 = (v1, v2) Table 2. The edge length bounds of the tree T .
In the 4th iteration we will obtain l 5 = 4, l 9 = 2, f 1 = 39 and f 2 = 5. Then p 1 = {e 3 , e 4 , e 5 } is saturated and the current solution is optimal. The length of edges in the optimal solution are given in Table 4. 5. Summary and conclusion. In this paper, we investigated the inverse balanced distances of single facility location problem with variable edge lengths on trees. The goal in this problem is minimizing the difference distances between farthest and closest clients to the given facility by modifying the length of edges with minimum cost. A model and some properties are proposed for this problem. Then two algorithms with O(nlogn) and O(n 2 ) time complexity are developed for solving the unbounded and bounded edge lengths models, respectively.
The reverse model of the problem, in which we have a limited budgeting and we want to modify the length of edges such that the difference distances between farthest and closest clients to the given facility reduced as much as possible, can be  Table 4. The optimal edge lengths for Example 2.
considered in the future works. Also, considering the other cases of inverse models are interesting fields for future works.