(!******************************************************* Mosel Example Problems ====================== file coco3.mos ````````````` Coco Problem Phase 3. Introduce time periods and inventory. (c) 2001 Dash Associates authors: Y. Colombani & S.Heipcke *********************************************************!) model Coco3 ! Start a new model uses "mmxprs","mmetc" ! Load the optimizer and ETC libraries declarations NT=4 ! Number of time periods RP=1..2 ! Range of products (p) RF=1..2 ! factories (f) RR=1..2 ! raw materials (r) RT=1..NT ! time periods (t) REV: array(RP,RT) of real ! Unit selling price of product p CMAKE: array(RP,RF) of real ! Unit cost to make product p ! at factory f CBUY: array(RR,RT) of real ! Unit cost to buy raw material r REQ: array(RP,RR) of real ! Requirement by unit of product p ! for raw material r MXSELL: array(RP,RT) of real ! Max. amount of p that can be sold MXMAKE: array(RF) of real ! Max. amount factory f can make ! over all products PSTOCK0: array(RP,RF) of real ! Initial product p stock level ! at factory f RSTOCK0: array(RR,RF) of real ! Initial raw material r stock ! level at factory f CPSTOCK = 2.0 ! Unit cost to store any product p CRSTOCK = 1.0 ! Unit cost to store any raw mat. r MXRSTOCK = 300 ! Max. amount of r that can be ! stored each f and t make: array(RP,RF,RT) of mpvar ! Amount of product p made at ! factory f sell: array(RP,RF,RT) of mpvar ! Amount of product p sold from ! factory f in period t buy: array(RR,RF,RT) of mpvar ! Amount of raw material r bought ! for factory f in period t pstock: array(RP,RF,1..NT+1) of mpvar ! Stock level of product p at ! factory f at start of period t rstock: array(RR,RF,1..NT+1) of mpvar ! Stock level of raw material r at ! factory f at start of period t end-declarations ! Read data from files diskdata(ETC_DENSE,"revt.dat",REV) diskdata(ETC_DENSE,"cmake.dat",CMAKE) diskdata(ETC_DENSE,"cbuyt.dat",CBUY) diskdata(ETC_DENSE,"req.dat",REQ) diskdata(ETC_DENSE,"maxsellt.dat",MXSELL) diskdata(ETC_DENSE,"mxmake.dat",MXMAKE) diskdata(ETC_DENSE,"pstock0.dat",PSTOCK0) diskdata(ETC_DENSE,"rstock0.dat",RSTOCK0) ! Objective: maximize total profit MaxProfit:= sum(p in RP,f in RF,t in RT) REV(p,t) * sell(p,f,t) - ! revenue sum(p in RP,f in RF,t in RT) CMAKE(p,f) * make(p,f,t) - ! prod. cost sum(r in RR,f in RF,t in RT) CBUY(r,t) * buy(r,f,t) - ! raw mat. cost sum(p in RP,f in RF,t in 2..NT+1) CPSTOCK * pstock(p,f,t) - ! p stor. cost sum(r in RR,f in RF,t in 2..NT+1) CRSTOCK * rstock(r,f,t) ! r stor. cost ! Product stock balance forall(p in RP,f in RF,t in RT) PBal(p,f,t):= (pstock(p,f,t+1) = pstock(p,f,t) + make(p,f,t) - sell(p,f,t)) ! Raw material stock balance forall(r in RR,f in RF,t in RT) RBal(r,f,t):= rstock(r,f,t+1) = rstock(r,f,t) + buy(r,f,t) - sum(p in RP) REQ(p,r)*make(p,f,t) ! Capacity limit at factory f forall(f in RF,t in RT) MxMake(f,t):= sum(p in RP) make(p,f,t) <= MXMAKE(f) ! Limit on the amount of prod. p to be sold forall(p in RP,t in RT) MxSell(p,t):= sum(f in RF) sell(p,f,t) <= MXSELL(p,t) ! Raw material stock limit forall(f in RF,t in 2..NT+1) MxRStock(f,t):= sum(r in RR) rstock(r,f,t) <= MXRSTOCK ! Initial product levels forall(p in RP,f in RF) pstock(p,f,1) = PSTOCK0(p,f) ! Initial raw material levels forall(r in RR,f in RF) rstock(r,f,1) = RSTOCK0(r,f) maximize(MaxProfit) ! Solve the LP-problem ! Print out the solution writeln("Solution:\n Objective: ", getobjval) ! Uncomment to print out the solution values: (! forall(p in RP, f in RF) do forall(t in RT) write(" make(",p,",",f,",",t,"):", getsol(make(p,f,t)), " sell(",p,",",f,",",t,"):", getsol(sell(p,f,t)), " ") writeln end-do forall(p in RP, f in RF) do forall(t in 1..NT+1) write(" pstock(",p,",",f,",",t,"):", getsol(pstock(p,f,t))) writeln end-do forall(r in RR, f in RF) do forall(t in RT) write(" buy(",r,",",f,",",t,"):", getsol(buy(r,f,t))) writeln end-do forall(r in RR, f in RF) do forall(t in 1..NT+1) write(" rstock(",r,",",f,",",t,"):", getsol(rstock(r,f,t))) writeln end-do !) end-model