In facility location we have set of possible facilities locations, set of clients and the number k. For each client i and facility j, there is a cost of assigning i to j, m(i,j) (the transportation cost). The goal is to determine the set of k open facilities and assign each client to some set of open facilities to minimize the cost of assigning clients (the transportation cost).
More formally, let \(x_{ij}\) indicates if client i is assigned to facility j and \(y_i\) indicates if the facility is open, we want to minimize
\begin{eqnarray*}&\sum_{x_{ij}}x_{ij} * m(i,j)\\ where:&\\ &\forall_{i}\sum_j{x_{ij}} = 1\\ &\forall_{i,j}x_{ij} \le y_j\\ &\sum_{j}y_j = k\\ &x_{ij} \in \{0,1\}\\ &y_j \in \{0,1\}\\ \end{eqnarray*}
Facility Location (FL) problem is solved by local search. Given a move which opens one facility and close one facility, we check if the move can our solution, if yes, we apply the move.(see paal::local_search::facility_location::KMedianLocalSearchStep for more details). Current solution to the assignment problem (assign clients to chosen facilities) is kept in the class which models Voronoi concept, where generators are facilities and vertices are clients.
example file is k_median_example.cpp
The complexity of the computing the gain for each move equals complexity of the swap for facility location (see Facility Location).
The algorithm an analises is described in [2]