Let us assume that we have \(N\) known demand points \(A_{1}\),..., \(A_{N}\) in a continuous space, \(A_{i}=(a_{i,1},\,\ldots,\,a_{i,d})\), \(A_{i}\in\mathbb{R}^{d}\), and \(S=\{X_{1},\,\ldots,\,X_{p}\}\subset\mathbb{R}^{d}\) is the set of sought points (medians, centers). The objective function (sum of distances) of the p-median problem is [1]:  
\[F\big{(}X_{1},\ldots,X_{p}\big{)}=F(S)=\sum_{i=1}^{N}min_{j=\overline{1,p}}L( A_{i},X_{j})\,\rightarrow\,min_{X_{1},\ldots,X_{p}\in\mathbb{R}^{d}}. \tag{1}\]  
Here, integer \(p\) must be known in advance.  
The distance metric L \((\cdot,\cdot)\) between objects is the key concept in the location theory. As a rule, a metric is understood as a function or an equation that determines the distance between any points and classes in a metric space [2]. A metric space is a set of points with a defined distance function. The distance of order l between two points is determined by the Minkowski function [3]:  
\[L_{l}\big{(}X_{j},A_{i}\big{)}=\left(\sum_{k=1}^{d}\left|x_{j,k}-a_{i,k} \right|^{l}\right)^{\frac{1}{l}}. \tag{2}\]  
The parameter \(l\) is determined by the researcher. We can use it to progressively increase or decrease the weight of the \(i\)th variable. Special cases of the Minkowski function are distinguished by the value of l. For \(l=2\) the function calculates Euclidean metric between two points. By default, location problems use Euclidean metric:  
\[L_{2}\big{(}X_{j},A_{i}\big{)}=\left(\sum_{k=1}^{d}\Big{(}x_{j,k}-a_{i,k} \Big{)}^{2}\right)^{1/2} \tag{3}\]  
Here, \(X_{j}=\left(x_{j,1},\ldots,x_{j,k}\right)\,\forall\,j=\overline{1,p},k= \overline{1,d}\,\) are sought centers, also called medians, \(A_{i}=(a_{i,1},\ldots,a_{i,k})\,\,\forall\,i=\overline{1,N}\) are known points called demand points or data vectors.  
For \(l=1\), the function calculates Manhattan distance [3]. For \(l=+\infty\), the function calculates Tschebychev distance (\(L_{\infty}\) metric), and for \(l=0\), the function calculates Hamming distance [4].  
[PERSON], in his work [5], investigated the problem of finding the center for a set of weighted points (the Weber problem or 1-median problem [5]) which is a special (simplest) case of the problem (1) for \(p=1\). At the same time, the Weber problem is a generalization of a similar Fermat problem [6] with three demand points (\(N=3\), \(p=1\)). [PERSON], in his work [7], proved a theorem formulated by [PERSON] [8] and derived a sequence that converged to the optimal solution of the Weber problem. This was a version of the gradient descent algorithm [9] for the Weber problem.  
The clustering problem is to divide a given set (sample) of \(N\) objects (data vectors) into \(p\) disjoint subsets, called clusters, so that each cluster consists of similar objects, and the objects of different clusters differ significantly. In the process of grouping a set of objects into certain groups (subsets), the general features of the object and the applied algorithms play an important role. Some of the automatic grouping problems can be considered from the point of view of location problems. The most popular k-means clustering model [10] can be described by Equation (1) where \(L\) (\(\cdot\),\(\cdot\)) is the squared Euclidean distance between two points. The existence of a trivial non-iterative solution of the corresponding Weber problem with the squared Euclidean distances [11] makes the k-means problem one of the most popular optimization models for clustering. A disadvantage of this model is its high sensitivity to the outliers (separately located data points), and the \(p\)-median model is free from this drawback.  
The network p-median problem [12] is to find the \(p\) nodes on a network that minimize the sum of the weighted distances from all nodes to the nearest of the \(p\) nodes selected as centers (medians). The network and continuous p-median problems are proved to be NP-hard [13; 14].