1 Introduction
This paper considers the problem of determining the global solution of a general continuous multi-locations problem, where a set of clients (i.e. points at given coordinates) have to be assigned to a set of facilities, for which the optimal locations have to be determined. In the paper, the distance from a client to a facility is assumed to be arbitrary in a sense that it is not necessarily measured by the standard Euclidean distance between two points; in particular, in our numerical part we consider the multi-Weber with polyhedral barriers problem. For this problem, a set of obstacles are introduced where travelling or facility placement is prohibited, which makes the distance metric non-convex. Also, we assume that the facilities could in addition be restricted to an arbitrary non-convex finite subset of the plane (e.g. this could be a union of a set of segments and triangles).
At optimality for the problems which are studied in this paper, a client always chooses the closest facility, thus the problem can be also seen as a clustering problem: the goal is to find the optimal partition of the clients into groups (clusters), and then the optimal facility can be determined for each cluster independently. Thus, for obtaining the global solution of the multi-locations problem, we employ a branch and bound with an all-possible-partitions enumeration tree and pruning criteria. The pruning criteria roughly uses the following simple idea: if we divide the clients into two groups and find the optimal solution within each group separately, summing the two terms we obtain a lower bound estimate for the partitions within a corresponding branch.
The Weber problem, i.e. the problem of determining the coordinates of the optimal point minimizing the sum of the Euclidean distances to other given points, has a long and rich history, many extensions and publications (Drezner
et al.,
2002). The extension we concentrate on in this paper was probably firstly introduced by Aneja and Parlar (
1994). In this model, obstacles (barriers) in the plane are introduced; it is not allowed to travel through these barriers or to place a solution point inside. In real life, such barriers could be considered to represent lakes or buildings on a geographical map, or some prohibited places in printed circuit boards (Hamacher and Nickel,
1995).
The Weber location with barriers problem has attracted the attention of many scientists. However, most of the work concentrates on solving the single location problem, see e.g. Aneja and Parlar (
1994), Klamroth (
2002), Bischoff and Klamroth (
2007), Oğuz
et al. (
2016). The first reason for this is the following motivation: having a “good” algorithm for the single location problem, we can implement a location-allocation algorithm in the style of Cooper (
1964). For example, such an algorithm for multilocations with polyhedral barriers problem is considered by Bischoff
et al. (
2009). The second reason why the case of multilocations has not received much scientific effort might be related to the combinatorial complexity of this problem.
The only non-theoretical work dedicated to the multi-Weber with barriers problem we have found in the scientific literature is the thesis of Krau (
1997). In his work, the author extends the column generation principle of Gilmore and Gomory (
1961) to the problem. The column generation approach seems to provide a benchmark solution for several clustering-like problems such as the minimum sum of squares clustering (Aloise
et al.,
2012) or the (barrierless) multi-Weber problem (du Merle
et al.,
1999). Using this method, Krau (
1997) solves the problem presented by Aneja and Parlar (
1994) which consists of 18 points and 12 barriers, and also an extended version of this problem with 30 points, for cluster sizes
$K=2,\dots ,7$.
As the results indicate, the cases with small
K seem to be the hardest for a column generation based algorithm (Krau,
1997). However, with our approach we have solved the problem instances of
$60/2$,
$45/3$,
$40/4$ and
$35/5$ (
$N/K$ means “
N points into
K clusters”) to global optimality (within
ϵ-accuracy with
$\epsilon =1\% $). To our knowledge, this is the first time the solution of instances with such a size to global optimality is reported. Moreover, we think our approach is very general. We believe the ideas could be also extended to other variants of multi-Weber problems.
Our paper is structured as follows. In Section
2, we formulate the general model of the problem we seek to solve in this paper. In Section
3, we describe the building blocks of our approach and give some mathematical proofs of intuitively rather obvious facts. Using these blocks, in Section
4 we present the sketch of the enumeration algorithm. Finally, in Section
5, we clarify algorithm details for the multi-Weber with polyhedral barriers problem and give an analysis of the performance of the algorithm.
5 Numerical Example
We apply the ideas from previous sections to the multi-Weber with polyhedral barriers problem. An example of the problem and its
ϵ-accuracy solution are illustrated in Fig.
2. The problem is defined within a unit-square with a
$10\times 10$ grid, with each square initially divided into 4 triangles. The blue polygons are the barriers; it is not allowed to travel through them – these barriers induce the distance metric
$d:\mathcal{S}\times \mathcal{S}\mapsto {\mathbf{R}^{+}}$. There are 10 barriers consisting of 100 triangles in total. The region-union
${\mathcal{R}^{\cup }}$ consists of the remaining 300 gray-coloured triangles (region-units
${\mathcal{R}_{m}}$):
${\mathcal{R}^{\cup }}={\textstyle\bigcup _{m=1}^{300}}{\mathcal{R}_{m}}$.

Fig. 2
Location with barriers problem example. We seek to cluster 25 given points into 5 clusters. The solution is proved by our algorithm to be within $\epsilon =0.01$ accuracy to the global optimum (i.e. the globally optimal loss differs by at most $1\% $ when compared with the reported solution).
5.1 Visibility Graph

Fig. 3
Visibility polygons for selected points.
To compute the distances
$d({p_{i}},{\mu _{k}})$ between client-points and facility-points, we need to find the so-called visibility-graph
$\mathcal{G}(V,E)$ (Viegas and Hansen,
1985). Each point
$p\in {\mathcal{R}^{\cup }}$ defines a visibility-polygon as illustrated in Fig.
3. This polygon contains the set of points “seen” from the corresponding point directly through a ray; to reach the points outside this polygon, we must bypass some barriers. It is easy to convince oneself that (see Viegas and Hansen,
1985), in case point
$q\in {\mathcal{R}^{\cup }}$ is not seen directly from point
p, the shortest path
$d(p,q)$ consists of a set of segments with the end-points at the corners of the barrier-regions. Therefore, the visibility-polygons for the barrier corner-points are particularly interesting (as in Fig.
3b). Barrier corner-points, together with client-points, define the set of vertices
V for the visibility-graph
$\mathcal{G}(V,E)$. The (directed) edges
E are inserted as follows: if vertex
$v\in V$ is “seen” from a barrier-corner-vertex
w (i.e.
v belongs to the visibility polygon of
w), we add the edge
$w\mapsto v$ to graph (with edge weight equal to the Euclidean-length from point
$p(v)$ to point
$p(w)$).
To compute the shortest paths from a given facility-point
μ to each client-vertex
$v({p_{1}}),\dots ,v({p_{N}})$, we could insert an additional vertex
$v(\mu )$ to the graph, find the set of vertices
$v\in V$ “seen” from
μ, and insert the corresponding edges. Now, the shortest-paths can be found with Dijkstra’s algorithm (Dijkstra,
1959).
Visibility graph for our example problem is shown in Fig.
4.

Fig. 4
Visibility graph for the example problem.
5.2 Minimal Distances to a Triangle-Facility
To apply the ideas from the previous sections, we have to compute the lower-bound distances ${d_{nm}^{\hspace{0.1667em}\inf }},\hspace{0.1667em}n\in {\mathbb{N}_{1}^{N}}$, $m\in {\mathbb{N}_{1}^{M}}$, i.e. the shortest possible distance ${d_{nm}^{\hspace{0.1667em}\inf }}$ from the client-point ${p_{n}}$ to the region-unit (triangle-facility in our case) ${\mathcal{R}_{m}}$.
For this task, we use the visibility-graph $\mathcal{G}(V,E)$ described in the previous subsection.
To find the lower-bound distances
${d_{nm}^{\hspace{0.1667em}\inf }},\hspace{0.1667em}n\in {\mathbb{N}_{1}^{N}}$, we firstly insert an additional vertex
$v({\mathcal{R}_{m}})$ into the graph. Now, we have to take care of the edges. This can be done as follows: for each
$v\in V$, intersect the visibility polygon
$\mathcal{VP}(v)$ of
v with triangle
${\mathcal{R}_{m}}$:
$\mathcal{I}(v,{\mathcal{R}_{m}})=\mathcal{VP}(v)\cap {\mathcal{R}_{m}}$. If the intersection
$\mathcal{I}(v,{\mathcal{R}_{m}})$ is empty, do nothing. Otherwise, find the nearest point
$\textbf{proj}(v,{\mathcal{R}_{m}})$ from
$p(v)$ to
$\mathcal{I}(v,{\mathcal{R}_{m}})$. Now, add to
$\mathcal{G}(V,E)$ a directed-edge
$v({\mathcal{R}_{m}})\mapsto v$ with weight
$\| p(v)-\textbf{proj}(v,{\mathcal{R}_{m}}){\| _{2}}$. The distances
${d_{nm}^{\hspace{0.1667em}\inf }},\hspace{0.1667em}n\in {\mathbb{N}_{1}^{N}}$ for the triangle-facility
${\mathcal{R}_{m}}$ can now again be found with Dijkstra’s algorithm (Dijkstra,
1959).
The output of this procedure is illustrated in Fig.
5.
To compute an upper bound for the sum of distances from triangle-facility
${\mathcal{R}_{m}}$ to all the clients, we could pick any point
$\mu \in {\mathcal{R}_{m}}$ and calculate the distances as outlined in Section
5.1, i.e. using the visibility graph. However, in our case where all the region-units are triangles, for finding an upper-bound faster, we can use the following simple idea.
-
• Pick the longest edge of the triangle, compute its length ${l_{1}}$.
-
• Pick the middle point of this edge. Define ${l_{2}}$ as the distance from this middle-point to the vertex in front of the longest edge.
-
• All the points within the triangle are at maximum distance $l=\max \big(\frac{{l_{1}}}{2},{l_{2}}\big)$. The upper bound for the triangle-facility ${\mathcal{R}_{m}}$ can be found by the formula $\big({\textstyle\sum _{n=1}^{N}}{d_{nm}^{\hspace{0.1667em}\inf }}\big)+Nl$.

Fig. 5
Shortest distances to triangle-facilities. The triangle-facility in Fig.
5b has the minimal sum of distances
${\textstyle\sum _{n=1}^{N}}{d_{nm}^{\hspace{0.1667em}\inf }}$ from all region-units
${\mathcal{R}_{m}}$,
$m=1,\dots ,M$.
5.3 Finding the Optimal Centre Within a Predefined Accuracy ϵ

Fig. 6
Illustration of the triangle-partitioning algorithm.
To find the globally-optimal centre for a set of points, i.e. optimal centree for some cluster
${\mathcal{C}_{k}}$, we use the triangle-partitioning algorithm in the style of Paulavičius and Žilinskas (
2013). For a start, we place all the initial triangles (region-units
${\mathcal{R}_{m}}$) in a MinPQ (Sedgewick and Wayne,
2011), ordered by the lower-bound value
Initially, the MinPQ contains
M elements. Now, pick from MinPQ the triangle-facility
${\mathcal{R}_{\min }}$ with the smallest lower-bound value (
32). Delete this triangle from MinPQ. Next, partition
${\mathcal{R}_{\min }}$ into two smaller triangles
${\mathcal{R}_{\text{left}}}$ and
${\mathcal{R}_{\text{right}}}$ along the longest edge (see the partitions of the triangle-facility from Fig.
5b in Fig.
6a, Fig.
6b). Both these triangles have an improved (increased) lower-bound estimates
because they were obtained by subdividing
${\mathcal{R}_{\min }}$ into two smaller pieces. Since the triangles have been shrunk, the gap between the lower bound and the upper bound for these triangles improves, i.e. we have shown that inequality (
28) holds with
${\varepsilon _{\text{left}}}=\text{diam}({\mathcal{R}_{\text{left}}})$ and
${\varepsilon _{\text{right}}}=\text{diam}({\mathcal{R}_{\text{right}}})$. Insert
${\mathcal{R}_{\text{left}}}$ and
${\mathcal{R}_{\text{right}}}$ into MinPQ. Continue deleting/partitioning triangles in MinPQ until the distance between the best known lower-bound and the best known upper-bound is within a predefined accuracy
ϵ, i.e. until condition
holds for some “small”
ϵ (take for example
$\epsilon =0.001$). The procedure is illustrated in Fig.
6.
5.4 Other Steps
Other steps in the algorithm of Section
4 given a routine to calculate
${d_{nm}^{\hspace{0.1667em}\inf }}$ and a routine to find the optimal centre for a cluster (as described in Section
5.3) are rather straightforward. We just emphasize that during enumeration procedure at any vertex
${v_{n}}\in \mathcal{T}(N,K)$, we use formula (
17a) to find
in
$O(M)$ time.
5.5 Algorithm Analysis
5.5.1 Improvement by Initial Subdivision of Region-Units
Our initial analysis of the algorithm for the problem instance presented in Fig.
2 is summarized in Table
1. In the experiment, we have analysed algorithm performance for the number of clients
$N=20,\dots ,25$ and the number of clusters
$K=3,4,5$. Table
1a shows time statistics for lower bound calculations (
Step 1 in the algorithm of Section
4), Table
1b shows time statistics for the enumeration of candidate solutions (
Step 3 in the algorithm of Section
4), and Table
1c gives the statistics for the number of candidate solutions to the global optima.
Table 1
Algorithm statistics for initial triangles (300 region-units). The question mark (?) indicates that the data is missing due to the time limit (see the last column in Table
1b and also compare with Table
2b).
While for the lower bound step times differ only slightly, the number of possible candidates to the global solution grows exponentially; the time to enumerate all these solutions is proportional. The reason to this is that our lower bound estimates are considerably (say, within $20\% $-tolerance) smaller than the value of the globally optimal solution.
We try the following simple “remedy” to this issue: suppose that each triangle-unit
${\mathcal{R}_{m}}$,
$m=1,\dots ,300$ is subdivided into 2 smaller triangles
${\mathcal{R}_{m1}}$,
${\mathcal{R}_{m2}}$. Such a subdivision gives an improvement of the error between the lower bound and the exact solution (as discussed in Section
3.5). The updated statistics are presented in Table
2. Comparing with Table
1, we can see time increase for lower bound calculations (as expected), though this time is not crucial in the total time of the algorithm. But for the numbering the candidate solutions, the effect is clear: the number of candidates is reduced significantly.
Table 2
Algorithm statistics when initial triangles are halved (600 region-units).
Continuing the experiment, we have halved the initial triangles 3 times, in total into 8 smaller triangles. The statistics are presented in Table
3. Comparing with Table
2, we can see that lower bound calculations take approximately 4 times more time, as expected – because we have 4 times more triangle-units. But as can be seen in Table
3c, the number of candidates to the global solution further decreases significantly.
Table 3
Algorithm statistics when initial triangles are divided into 8 pieces (2400 region-units).
5.5.2 Predicted time
Based on the observations of previous subsection, we decided to test our algorithm performance when initial triangle-units of ${\mathcal{R}^{\cup }}$ are subdivided 4 times into 16 smaller triangles. We have collected time statistics for various random problem instances. These problems were all generated within a unit-square with a $10\times 10$ grid, with each square initially divided into 4 pieces (in total, 400 problem-triangles). 10 barriers were then randomly generated, with a total of 100 triangles classified as barrier-triangles. The remaining 300 were subdivided into 16 smaller triangles, resulting that ${\mathcal{R}^{\cup }}$ consists of $M=300\times 16=4800$ triangle-units.

Fig. 7
Enumeration algorithm visited nodes log-proportion statistics. Number of clients N in the x-axis, number of clusters K in the title. Box-plots represent log-proportion statistics for a fixed N. Green line represents the linear model for the median log-proportion (${l_{0.5}}(N,K)={\alpha _{0.5}}[K]+{\beta _{0.5}}[K]N$), red – the 90th percentile.
Algorithmic complexity of our approach is strongly related with the size of the tree
$\mathcal{T}(N,K)$ of Fig.
1. Labeling with
${S_{2}}(N,K)$ the Stirling’s number of the second kind, and defining
${S_{2}}(N,K)=0$ when
$K\gt N$, one can calculate that
$\mathcal{T}(N,K)$ has
nodes. Our algorithm performance depends on what proportion of the tree will be explored. During the experiment, we have recorded the number of tree-nodes visited in the enumeration of candidate solutions step (
Step 3 in the algorithm of Section
4). The proportion statistics are represented in Fig.
7. Using the obtained linear models for log-proportion, we can predict the median time and the 90th percentile time outside of experiment data. On our machine, processing of a particular
${v_{n}}\in \mathcal{T}(N,K)$ using formula (
17a) takes approximately
$c=9.098275\times {10^{-6}}$ seconds. Thus, we can predict algorithm time using the formulas below:
In the above equations,
$\mathcal{N}(N,K)$ is the number of nodes in the tree as defined in (
33). The predicted times for various combinations of
$(N,K)$ when the number of triangle-units is fixed to
$M=4800$ are visualized in Fig.
8.

Fig. 8
Estimated time of the algorithm for various problems $[{\mathbb{P}_{1}^{N}}/K]|[{\mathcal{R}^{\cup }}]$ with K in the x-axis and N in the y-axis. Blue points represent the pairs for which time statistics were collected, red points have no time statistics corresponding to them and are predicted. In the figure, the letter next to a number means “s”-seconds, “m”-minutes, “h”-hours, “d”-days ($=24$ hours).
5.6 Solved Example Instances
Some examples of problems solved within
ϵ-accuracy are shown in Figs.
9 and
10. These are optimal solutions for largest problem instances we can solve in acceptable time. The results suggest themselves to be compared with the work of Rosing (
1992), where the author had studied the
unconstrained multi-Weber problem
without barriers. This paper was published more than 30 years ago, but the results of their work are comparable to ours in the sense that, just like us (see Fig.
10), they reported global solutions for up to 35/5 and 30/6 problems. Our contribution is that we have managed to solve
constrained multi-Weber problems
with barriers of the same size, i.e. the ideas presented in this paper allow us to solve much more general class of uncapacitated multi-location problems.

Fig. 9
Examples of within ϵ-accuracy solved problems ($\epsilon =1\% $).

Fig. 10
More examples of within ϵ-accuracy solved problems ($\epsilon =1\% $).
6 Conclusions
In this paper, we have outlined ideas how the globally-optimal solution of a very general multi-locations problem can be approached. The problem of finding the global solution perhaps is more of theoretical and intellectual than practical interest. Also, the question is more of proving that the best found solution is the global optimum. In practice, if one is faced with a barriers problem, a good-quality solution can be obtained by a location-allocation algorithm. The ideas of this paper can be easily extended for an implementation of such an algorithm.
We provided some numerical examples solving the multi-Weber with polyhedral barriers problem instances and predicted time for various sizes of problems. With our approach we have solved the problem instances of $60/2$, $45/3$, $40/4$, $35/5$ and $30/6$ ($N/K$ means “N points into K clusters”) to global optimality (within ϵ-accuracy with $\epsilon =1\% $). To our knowledge, this is the first time the solution of instances with such a size to global optimality is reported.