How to write if statement for 3 dimensional problem linear programming

74 Views Asked by At

I have a problem regarding formulating the following with math notation. My goal is that if shop i’s arrival time is lower than all the other shop’s arrival times, then shop i must be allocated to the palletspace with the lowest distance (to obtain this, the solution would choose the port accordingly, I imagine)

My parameters are:

  1. SL denoting shop labels (i)
  2. PL denoting port labels (j)
  3. PSL denoting palletspace labels (l)
  4. A_i denoting the arrival times for a shop to a port (same no matter which port)
  5. D_jl denoting the distance from port j to palletspace l
  6. S =range(0, len(SL)
  7. P =range(0, len(PL)
  8. PS =range(0, len(PSL)

Variables: x_ijl = 1 if shop i is using pallet space l through port j y_ij = 1 if shop i is using port j

Now for the constraint I imagine it could be formulated as such: If A_i <= A_k, forall i in S, forall k in S Then x_ijl must be assigned to the pallet space with the lowest distance which isn’t already used by another shop (I have a constraint which ensures that one palletspace can’t be used by another).

So maybe something like: If A_i <= A_k, then x_ijl**distance_jl <= x_kjl*distance_jl

I don’t know guys, I’ve never wrote a linear program for this kind of if statement with multiple indexes…

I read this stack exchange post but I can’t adapt it to my problem… How to write if else statement in Linear programming?

1

There are 1 best solutions below

3
On

Because the arrival times are known, you don't need anything complicated. For $r\in\{1,\dots,|SL|\}$, let $i_r$ be the index of the shop with the $r$th lowest arrival time. In your example, $(i_1,i_2,i_3,i_4)=(1,4,3,2)$.

The desired constraints are $$\sum_{j,l} d_{jl} x_{i_rjl} \le \sum_{j,l} d_{jl} x_{i_{r+1}jl} \quad \text{for all $r\in\{1,\dots,|SL|-1\}$}.$$ Note that this formulation assumes that $$\sum_{j,l} x_{ijl} = 1 \quad \text{for all $i$}.$$ That is, each shop is assigned to exactly one port and pallet space.