Let set $I$ denote the facility location set, $N$ denote the customer set, and $d_{ni}, \forall n\in N, i \in I $ is the distance between customer $n$ and facility $i$. The problem is to locate facilities in $I$ with binary decision variable $v_i$, and assign customer $n$ to the opened $i$ with binary variable $y_{ni}$.
Note that there are many other constraints that I had omitted, and the problem is much difficult than the classic facility location problem. The most tricky part is how to build an equation which forces customer to visit their nearest and opened facility. Without this constraint, customer may visit farther facility, which is not what I want.
Now, I provide a equation as follows, which is nonlinear but can be linearized.
$$ \sum_{i\in I} d_{ni} y_{ni} = \min \{ M(1-v_i) + d_{ni}v_i,\forall i \in I\} \quad \forall n \in N $$
where $M$ is a sufficient large constant.
My problem is: Could anyone suggest a better way to force customers visit their nearest opened facility? I think the above relationship is complex. How to simplify this or provide another method?