# # the supply chain consists of sources of raw materials, # factories to produce finished goods, # and distribution centers for the finished goods. # # The supply chain is modeled over a horizon of T weeks. # # shipping costs money and takes time. # # manufacturing and shipping to demand center is assumed to take one week. # # if something is manufactured in week t, it can be sold in week t+1 # at a demand center # # safety stocks must be maintained at all factories and distribution centers. # the factories and distribution centers also have capacities. # # the demands at the distribution centers have a value, # and a cost for failing to meet the demand. # # the system is in some initial state, with initial inventories # at the distribution centers and at the factories. # assume shipping times are either 0 or 1 week for raws, # 0 weeks for finished items. # thus, only need to worry about initial inventory of raws, which # combines inventory left over plus stuff just arriving # after being shipped for a week. # the final situation must be the same as the initial situation. # set sources; # sources for raw materials set factories; # processing centers set demandcenters; # distribution centers set raw; # raw materials set finished; # finished products set rawarcs within {sources,factories}; # routes for shipping # raw material set finarcs within {factories,demandcenters}; # routes for shipping # finished products param T > 0, integer; # time horizon param rawarccost{raw,rawarcs} >= 0; # shipping cost on rawarcs param finarccost{finished,finarcs} >= 0; # shipping cost on finarcs param rawarctime{rawarcs} >= 0; # shipping time on rawarcs #param finarctime{finarcs} >= 0; param rawsourcecost{raw,sources} >= 0; # cost of raw materials param rawsourcesupply{raw,sources} >= 0; # availability of raw materials param demand{finished,demandcenters,1..T} >= 0; # demand for finished products param findcvalue{finished,demandcenters} >= 0; # sale price for finished prods param findccost{finished,demandcenters} >= 0; # shortfall cost for # finished products param manucombine{raw,finished} >= 0; # how many units of finished product # can be made from one unit of # a raw material param manucost{finished,factories} >= 0; # cost of making a finished good # (=0 in this project) param faccap{factories} >= 0; # capacity of a factory ... param rawfactor{raw} >= 0; # ... measured as a combination of # raw materials, weighted by # this parameter param safetyfac{raw,factories} >= 0; # required inventory at factories param safetydc{finished,demandcenters} >= 0; # required inventory at # demandcenters param initialraw{raw,factories} >= 0; # initial inventory at factories param initialfin{finished,demandcenters} >= 0; # initial inventory at # demandcenters param invcostrawfac{raw,factories} >= 0; # inventory cost of raw # material at factories param invcostfinfac{finished,factories} >= 0; # inventory cost of finished # products at factories param invcostfindc{finished,demandcenters} >= 0; # inventory costs at # demandcenters ######### var shipraw{raw,rawarcs,0..T} >= 0; # shipments of raw materials var shipfin{finished,finarcs,0..T} >= 0; # shipments of finished goods var useraw{raw,factories,1..T} >= 0; # amount of raw material used at each # factory var makefin{finished,factories,1..T} >= 0; # amount of finished product at each # factory var userawfin{raw,finished,factories,1..T} >= 0; # amount of a raw material # used in production of a # finished product at a # factory var inventoryrawfac{i in raw,j in factories,0..T} >= safetyfac[i,j]; # inventory of raw material at factory var inventoryfinfac{finished,factories,0..T} >= 0; # inventory of finished product at factory var inventoryfindc{i in finished,j in demandcenters,0..T} >= safetydc[i,j]; # inventory of finished product at demandcenter var sell{i in finished,j in demandcenters,t in 1..T} >= 0; # amount of finished product that is sold var buy{raw,sources,1..T} >= 0; # amount of raw material that is purchased var unmetdemand{finished,demandcenters,1..T} >= 0; # shortfall in meeting contracted demand ######### maximize profit: sum{i in finished, j in demandcenters, t in 1..T} findcvalue[i,j]*sell[i,j,t] # sell final product - sum{i in finished, (j,k) in finarcs, t in 1..T} finarccost[i,j,k]*shipfin[i,j,k,t] # ship finished product from factories to dc's. - sum{i in raw, (j,k) in rawarcs, t in 1..T} rawarccost[i,j,k]*shipraw[i,j,k,t] # ship raw materials - sum{i in raw, j in sources, t in 1..T} rawsourcecost[i,j]*buy[i,j,t] # purchase cost of raw materials - sum{i in finished, j in demandcenters, t in 1..T} findccost[i,j]*unmetdemand[i,j,t] # cost of unmet demand - sum{i in finished, j in factories, t in 1..T} manucost[i,j]*makefin[i,j,t] # manufacturing cost at the factories - sum{i in raw, j in factories, t in 1..T} invcostrawfac[i,j]*inventoryrawfac[i,j,t] - sum{i in finished, j in factories, t in 1..T} invcostfinfac[i,j]*inventoryfinfac[i,j,t] - sum{i in finished, j in demandcenters, t in 1..T} invcostfindc[i,j]*inventoryfindc[i,j,t] # three different inventory costs ; subject to supplylimit{i in raw, j in sources, t in 1..T}: buy[i,j,t] <= rawsourcesupply[i,j]; # sources have capacities subject to calcbuy{i in raw, j in sources, t in 1..T}: sum{(j,k) in rawarcs} shipraw[i,j,k,t] = buy[i,j,t]; # calculate the total amount purchased subject to sales{i in finished, j in demandcenters, t in 1..T}: sum{(k,j) in finarcs} shipfin[i,k,j,t-1] + inventoryfindc[i,j,t-1] = sell[i,j,t] + inventoryfindc[i,j,t]; # balance inventory at demand centers subject to shortfall{i in finished, j in demandcenters, t in 1..T}: sell[i,j,t] + unmetdemand[i,j,t] = demand[i,j,t]; # calculate the shortfall in demand subject to consume_raw{i in raw, j in factories, t in 1..T}: sum{(k,j) in rawarcs : rawarctime[k,j] = 0} shipraw[i,k,j,t] + sum{(k,j) in rawarcs : rawarctime[k,j] = 1} shipraw[i,k,j,t-1] + inventoryrawfac[i,j,t-1] = inventoryrawfac[i,j,t] + useraw[i,j,t]; # balance raw inventory at factories subject to rawassign{i in raw, k in factories, t in 1..T}: sum{p in finished} userawfin[i,p,k,t] = useraw[i,k,t]; # calculate how much raw material is used subject to caprawfac{k in factories, t in 1..T}: sum{i in raw} rawfactor[i]*useraw[i,k,t] <= faccap[k]; # factories can only process a limited amount of raw material subject to manufacture{i in raw, p in finished, k in factories, t in 1..T}: manucombine[i,p] * userawfin[i,p,k,t] = makefin[p,k,t]; # one unit of product p requires 1/manucombine[i,p] units of raw i. subject to assign_fin{p in finished, j in factories, t in 1..T}: makefin[p,j,t] + inventoryfinfac[p,j,t-1] = inventoryfinfac[p,j,t] + sum{(j,k) in finarcs} shipfin[p,j,k,t]; # assign finished products to demand centers subject to initinvraw{i in raw, j in factories}: inventoryrawfac[i,j,0] = initialraw[i,j]; # initialize the inventories of raw materials at the factories subject to initinvfinfac{i in finished, j in factories}: inventoryfinfac[i,j,0] = 0; # initialize the inventories of finished materials at the factories subject to initinvfin{i in finished, j in demandcenters}: inventoryfindc[i,j,0] = initialfin[i,j]; # initialize the inventories of finished products at the demand centers subject to initshipraw{i in raw, (j,k) in rawarcs}: shipraw[i,j,k,0] = 0; # initialize the initial shipping quantity to zero, # we assume these quantities are already included in # inventoryrawfac[i,k,0]. subject to initshipfin{i in finished, (k,j) in finarcs}: shipfin[i,k,j,0] = 0; # initialize shipfin to zero. # anything shipped at time 0 is already accounted for # in the inventory at time 1. subject to conservationraw{i in raw, j in factories}: inventoryrawfac[i,j,T] + sum{(k,j) in rawarcs : rawarctime[k,j] = 1} shipraw[i,k,j,T] >= inventoryrawfac[i,j,0]; # make sure the raw material available at the start of # period T+1 is equal to the raw material available at # the start of period 1. subject to conservationfin{i in finished, j in demandcenters}: inventoryfindc[i,j,T] + sum{(k,j) in finarcs} shipfin[i,k,j,T] >= inventoryfindc[i,j,0]; # make sure the finished products available at the start of # period T+1 is equal to the raw material available at # the start of period 1.