Reformulate IF-statement in mathematical optimization

I have an optimization problem that chooses which location must be opened based on a set of possible locations. And per location we have a certain amount of available spots from which we must buy a number.

I have a constraint in the model which says that if a location is opened, the number of bought spots in this location must be an integer number which is at least 1. But if a location is not opened, you cannot buy any spots there.

It is modelled as follows:

  • $P$ = the set of all possible locations to open
  • $x_i$ = whether location $i$ is opened or not (0=not opened, 1=opened)
  • $p_i$ = amount of places bought at location $i$

\begin{equation} p_i=\begin{cases} p_i \geq 1, \ p_{i} \in \mathbb{Z}, & \text{if $x_i = 1$}\\ p_i = 0, & \text{if $x_i = 0$} \end{cases} \qquad \forall i \in P \label{open+parking} \end{equation}

How can I model this constraint such that I can use MILP or MIQCP to solve this optimization problem?


Solution 1:

Let $M_i$ be a constant upper bound on $p_i$ and impose linear constraints $$x_i \le p_i \le M_i x_i.$$

More generally, to enforce \begin{align} x_i=0 &\implies p_i=0 \\ x_i=1 &\implies p_i \in [m_i,M_i], \end{align} impose $$m_ix_i \le p_i \le M_i x_i.$$