Assign M cars to N parking lots with limited spots I have a dataset with $M$ static cars locations and an information about $N$ parking areas with $k$ slots there. What clustering algorithm can I use to assign all cars to the parking zones in proportion to the number of parking slots?   
 A: Rather than treating this as a constrained clustering problem, I would argue it's more straight-forward to be seen as a transport problem.
Let's consider $\mathbf{A}$ the positions of the cars, $\mathbf{B}$ the positions of the parking lots and associated with that $\mathbf{d}$ the free spots in the lots, so
$\mathbf{A}=\begin{bmatrix}
       \mathbf{a}_1 \\
       \vdots \\
       \mathbf{a}_M          
     \end{bmatrix}$,
$\mathbf{B}=\begin{bmatrix}
       \mathbf{b}_1 \\[0.3em]
       \vdots \\[0.3em]
       \mathbf{b}_N          
     \end{bmatrix}$,
$\mathbf{d}=\begin{bmatrix}
       d_1 \\[0.3em]
       \vdots \\[0.3em]
       d_N          
     \end{bmatrix}$
Staying with the language used in transportation problems, your objective is to deliver the cars in $\mathbf{A}$ to the lots in $\mathbf{B}$ at the lowest transportation cost possible. Let's denote the cost of transporting car $\mathbf{a_i}$ to lot $\mathbf{b_j}$ as $c_{i,j}$. The cost function could for example be the estimated time it takes to move the car from $\mathbf{a_i}$ to $\mathbf{b_j}$.
This is a simple form of a transportation problem, because while we have a given ''demand'' $d$ at each parking lot, i.e. spots we can fill, there is only a ''supply'' of one car per row in $\mathbf{A}$. We denote the ''supply'' as a  column vector $\mathbf{s}$ of length $M$ with ones.
(P.S.: technically one could model the problem by exchanging supply and demand here, given that one adjusts the rest of the notation.)
We are interested in the matrix 
$$\mathbf{X}=\begin{bmatrix}
       x_{1,1} & \cdots & x_{1,M} \\
       \vdots & \ddots& \vdots\\
       x_{N,1} &\cdots & x_{N,M}       
     \end{bmatrix}
$$ 
where $x_{i,j}$ is the cars transported from $\mathbf{a}_i$ to $\mathbf{b}_j$ - of course in this simple version of the transport problem this is either 0 or 1.
The objective is then 
$$
\arg\min_{\mathbf{X}} \sum_{i=1}^{M} \sum_{j=1}^{N} c_{i,j}x_{i,j}
$$
subject to the constraints
\begin{align}
\sum_{j=1}^{N}x_{i,j}&=s_i \forall i\\
\sum_{i=1}^{M}x_{i,j}&\leq d_j \: \forall j\\
x_{i,j} &\geq 0 \: \forall i \:\forall j.
\end{align}
The first constraint means that the ''supply'' is used up, which means that all cars are assigned a parking lot. The second means that not more cars are sent to a parking lot than it has parking spots. The third means simply that $x_{i,j}$ is non-negative, since we can't transport a negative amount of cars from a to b.
This can then be solved with a constrained optimization solver.
There's a guide for solving such problems with SciPy, note however that their conditions are slightly different.
