(!****************************************************** Mosel Example Problems ====================== file c3toy.mos `````````````` Planning the production of toy lorrys (c) 2008 Fair Isaac Corporation author: S. Heipcke, Mar. 2002 *******************************************************!) model "C-3 Toy production" uses "mmxprs" declarations ITEMS: set of string ! Set of all products FINAL: set of string ! Set of final products ASMBL: set of string ! Set of assembled products PREPROD: set of string ! Set of preproducts CAP: array(ASMBL) of integer ! Capacity of assembly lines DEM: array(FINAL) of integer ! Demand of lorrys CPROD: array(ASMBL) of real ! Assembly costs CBUY: array(ITEMS) of real ! Purchase costs REQ: array(ASMBL,PREPROD) of integer ! Items req. for assembling a product end-declarations initializations from 'c3toy.dat' DEM CBUY REQ [CPROD, CAP] as 'ASSEMBLY' end-initializations finalize(ASMBL); finalize(PREPROD); finalize(FINAL); finalize(ITEMS) declarations produce: array(ASMBL) of mpvar ! Quantity of items produced buy: array(PREPROD) of mpvar ! Quantity of items bought end-declarations ! Objective: total costs Cost:= sum(p in PREPROD) CBUY(p)*buy(p) + sum(p in ASMBL) CPROD(p)*produce(p) ! Satisfy demands forall(p in FINAL) produce(p) >= DEM(p) ! Assembly balance forall(p in PREPROD) buy(p) + if(p in ASMBL, produce(p), 0) >= sum(q in ASMBL) REQ(q,p)*produce(q) ! Limits on assembly capacity forall(p in ASMBL) produce(p) <= CAP(p) forall(p in PREPROD) buy(p) is_integer forall(p in ASMBL) produce(p) is_integer ! Solve the problem minimize(Cost) ! Solution printing writeln("Total cost: ",getobjval) writeln("Buy:") forall(p in PREPROD) writeln(" ", strfmt(p,-18), ": ", strfmt(getsol(buy(p)),5)) writeln("Produce:") forall(p in ASMBL) writeln(" ", strfmt(p,-18), ": ", strfmt(getsol(produce(p)),5)) end-model