I have the following table

Day State Orders
1     GA    20
1      FL   21
2      OH   22
3      FL    23
4      CA    25 
5      ID   22
6     IA    23
6     CA    22
7    NM     11

This is where the day columns is one the 365 days. The state is one of the 50 states and orders is how much each customer ordered.

I have 3 Fulfillment Center and 2 DC centers. I want basically certain orders for example in Georgia to be fufilled by my FC 1 and ones in ALASKA to be fulfilled by the FC 2 and the ones New Mexico by the FC 3. Certain states must be fulfilled by certain FC.

If they cannot be fulfilled by that FC then they must be fulfilled by the next closest fc. I am not sure how to model for example that certain states orders must be fulfilled using inventory from the preferred FC first and then if nothing is left over try another FC.

So I have the following decision variable

$x_{1,1},x_{1,2},..,x_{1,365}$ this is what we ship from the first FC FOR THE various day

I have got this formula this what we ship from the second fc to the customer for day $1,..,365$

$x_{21},x_{22},...,x_{2,365}$ this is what we ship from the second FC. I have got

$x_{3,1},x_{3,2},x_{3,3},...,x_{3,365}$ is how much we send from the third FC

We have the parameters are

$d_1,d_2,d_3,...,d_{365}$ for all the demand.

The demand is equal to all the orders from a particular day.

We have the following decision variable the orders being shipped from the dc to the dc so we have six possible combinations.

FC=1 dc=1 and at a day=1


We also have from FC=1 DC=2 AT AND DAY 1


FC=2 DC=1 DAY=365


We also have FC=2 DC=2 so we ship from the second dc to the second FDC




FC=3 DC=2 how much FC 3 orders from dc


We have $O_{i,j,k}$

where $i$ is the fc where $j$ is the dc where $k$ is the day

we have lost sales for the first day is the demand for first day minues all we ship from the various FC


demand for day 2 minus $l_2=d2-(x_{12}+x_{22}+x_{32})$

we do this for all the 365 days

We also have the following for the inventory FOR FC=1, the starting inventory is 50


where $I_{12}$ is the amount of inventory the 1 FC has on the second day

$I_{1,2}=I_{11}-(x_{1,1} )+(o_{1,1,1}+o_{1,2,1}$

FOR FC=2 we have a starting inventory of 60


we also have for the second day inventory


We have FC =3 inventory


We have then this is the amount of inventory for fc 3 at day number 2 $I_{32}=I_{31}-x_{32}+o_{3,1,1}+o_{3,2,1}$

We have truck constraint $o_{113}<=nt*10$ where nt is the number of trucks

We have the following objective function $30(l_1+..+l_{365})+1(I_{11}+..+I_{1,365} )+1(I_{2,1}+..+I_{2,365}+1(I_{31}+I_{32}+⋯+I_{3,365}+5(O_{1,1,1}+⋯+O{3,2,365})$

  • 4
    $\begingroup$ It is a bit hard to read the question due to a combination of typos and LaTeX errors. Could you edit it to make it more readable? $\endgroup$
    – prubin
    Commented Nov 28, 2022 at 4:07
  • $\begingroup$ ok will edit the question $\endgroup$ Commented Nov 28, 2022 at 13:03
  • $\begingroup$ Edited a bit of the question $\endgroup$ Commented Nov 28, 2022 at 13:37

2 Answers 2


Create combinations of FC, Day, State, Preferred(1,0) like OS(1,1, "Alaska", 1) if FC=1 is preferred FC for Alaska, else OS(1,1, "Alaska", 0)
If certain states can't be serviced by an FC, just don't create that combination. This will save variables and constraints.
Define $b_{f,s}=1 \forall f \in\ FC \ \forall s \in\ states$ as binary initialized to 0.
C1 = $\sum_{s \in\ states} os_{f,d,s, p} \le x_{f,d} \forall f,d \in\ O$ : Choosing FC and day from set O will sum it for DCs used.

C2 = $\sum_{dc \in\ DC} o_{f,dc,s} = os_{f,d,s,p} \forall d \in\ day, \ \forall s \in\ states \ \forall f \in\ FC$.

C3 = $\sum_{f} os_{f,d,s,p} \le demand_{d,s} \ \forall s \in\ states \ \forall d \in\ days$. May be not required if you've a similar constraint with $o_{f,d,s}$.

C4 = $p*I_{f,d} \le M*b_{s,f}$: b is 1 if I > 0 for $\forall f \in\ FC \ d \in\ day$

C5 = $\sum_{f,p=0} (1-p)*b_{f,s} \le M*(1- p*b_{f,s}) \ \forall s \in\ states, S$:
M can be big enough, say more than $max(I_{f,d})$: c4, C5 ensure b flips for inventory for preferred state, FC but remains 1 for non preferred.

C6 = $\sum_{f,p=0} (1-p)*os_{f,d,s,p} \le (1-p)\sum_{f} b_{s,f}*I_{f,d}$: ensures flow from non-preferred only when inventory in preferred FC =0 for a state s\


The mentioned problem sounds like a variant of Multi echelon-Multi stage supply chain optimization problem in which you are willing to minimize transportation, inventory, and loading/unloading costs/units respectively. Let's describe that with a simple example as follows:

There are three suppliers (fulfillment centers), two distribution centers (DC), and three customers (Georgia, ALASKA, and New Mexico). We already assume a period of time around three days union the based line. $\text{T} = \{ 0 \cup t1, t2, t3\}$. The schematic of the network would be:

Network diagram

where, indices $c, d, s, t$ denote customers, DC, Suppliers, and Planning horizon respectively. Let $x_{(s,d,t)}$ be the number of products that would be supplied from supplier $s$ to DC $d$ at time $t$. Also, $y_{(d,c,t)}$ denotes the amount of shifted goods from DC $d$ to customer $c$ at time $t$. The variables $inv{^s}_{(s,t)}$ and $N{^v}_{(t)}$ declare the inventory of suppliers and the number of vehicles needed to transport goods between nodes. The linear programming formulation is:

\begin{array} \text{Min} \quad \mathbb{Z} = \sum_{s,d,t} x_{(s,d,t)}.cost{^{s}}_{(s,d)} + \sum_{c,d,t} y_{(c,d,t)}.cost{^{d}}_{(c,d)} + \sum_{s,t} inv{^s}_{(s,t)} + \sum_{t} N{^v}_{(t)}\\ \text{S.t:} \\ \sum_{d} y_{(c,d,t)} \geq Demand_{(c)} \quad \forall c,t & (1)\\ \sum_{d} x_{(s,d,t)} \leq cap{^{s}}_{(s)} \quad \forall s,t & (2)\\ \sum_{s} inv{^s}_{(s,t-1)} + \sum_{s} x_{(s,d,t)} = \sum_{c} y_{(c,d,t)} + \sum_{s} inv{^s}_{(s,t)} \quad \forall d,t & (3)\\ s_{(s,0)} = SS_{(s,0)} \quad \forall s & (4)\\ s_{(s,t)} \geq SS_{(s,t)} \quad \forall s,t & (5)\\ \sum_{s,d} x_{(s,d,t)} \leq N{^v}_{(t)}.cap^{v} \quad \forall t & (6)\\ x_{(s,d,t)}, y_{(c,d,t)}, inv{^s}_{(s,t)}, N{^v}_{(t)} \in \mathbb{R}_{+} \quad \forall s,d,c,t & (7)\\ \end{array}

So, $cost{^{s}}_{(s,d)}$, $cost{^{d}}_{(c,d)}$, $Demand_{(c)}$, $cap{^{s}}_{(s)}$, $SS_{(s,t)}$, and $cap^{v}$ are the problem data/parameters to define appropriate costs of shipping between nodes, $ s \rightarrow d$ and $ d \rightarrow c$, customers demand/orders, the suppliers capacity, initial inventory on hand, and capacity of the vehicles. Please, be aware that if you would like to prefer an assignment, you can change its related cost to get what you want. By the way, these costs may be still calculated easily based on the distances between the nodes.

Some notes:

  • I assume the number of vehicles as a decision variable, but you can set it up as a parameter.
  • Inventory position is usually defined for a specific item than to imply the amount of supply. (I think it would be somehow waired). Another way to capture this is to use auxiliaries variables, slack and surplus, with whose appropriate penalties in the objective function to violate some limitations.
  • I am not sure to understand what you mean by lost sales. You can assert the number of orders in each period with the suppliers capacities to ensure there is NO violation of that. If so, the second note would be helpful.

Finally, the results of the problem by assuming a constant order would be:

----     49 VARIABLE x.L  

               t1          t2          t3

s1.d1      60.000      60.000      60.000
s1.d2      20.000      20.000      20.000
s2.d2      90.000      90.000      90.000

----     49 VARIABLE y.L  

                      t1          t2          t3

d1.Georgia        60.000      60.000      60.000
d2.ALASKA         40.000      40.000      40.000
d2.NewMexico      70.000      70.000      70.000

----     49 VARIABLE N_v.L  

t1 17.000,    t2 17.000,    t3 17.000

  • $\begingroup$ Oh Sorry lost sales I meant like the $d[i]-x[i]$ like the amount of the demand not met $\endgroup$ Commented Dec 1, 2022 at 1:50
  • 1
    $\begingroup$ @FernandoMartinez, sorry for the delay. As you could see in constraint number $3$, the model does not allow the lost sale accurse. If you would like to violate this, you can use slack/surplus variables as I mentioned in the second note. Good luck. $\endgroup$
    – A.Omidi
    Commented Dec 2, 2022 at 10:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.