| |||||||||
Cut generation for an economic lot-sizing (ELS) problem Description This model implements various forms of cut-and-branch and branch-and-cut algorithms. In its simplest form (looping over LP solving) it illustrates the following
features:
Another implementation (main model: runels.mos, submodel: elsp.mos) parallelizes the execution of several model instances, showing the following features:
Further explanation of this example: elscb.mos, elsglobal.mos, runels.mos: Xpress Whitepaper 'Multiple models and parallel solving with Mosel', Section 'Solving several model instances in parallel'.
Source Files By clicking on a file name, a preview is opened at the bottom of this page. Data Files runels.mos (!******************************************************* Mosel Example Problems ====================== file runels.mos ``````````````` Run several instances of the model elsp.mos in parallel and coordinate the solution update. -- Using the 'bin' IO driver -- *** ATTENTION: This model will return an error if *** *** no more than one Xpress licence is available. *** *** This model cannot be run with a Community Licence for the provided data instance *** (c) 2008 Fair Isaac Corporation author: S. Heipcke, Nov. 2004, rev. Jul. 2017 *******************************************************!) model "Els main" uses "mmjobs", "mmsystem" parameters DATAFILE = "els.dat" T = 15 P = 4 end-parameters declarations RM = 0..5 ! Range of models TIMES = 1..T ! Time periods PRODUCTS = 1..P ! Set of products solprod: array(PRODUCTS,TIMES) of real ! Sol. values for var.s produce solsetup: array(PRODUCTS,TIMES) of real ! Sol. values for var.s setup DEMAND: array(PRODUCTS,TIMES) of integer ! Demand per period modELS: array(RM) of Model ! Models NEWSOL = 2 ! Identifier for "sol. found" event Msg: Event ! Messages sent by models params: text ! Submodel runtime parameters end-declarations ! Compile, load, and run models M1 and M2 M1:= 1; M2:=3 res:= compile("elsp.mos") ! Compile the submodel load(modELS(M1), "elsp.bim") ! Load submodels load(modELS(M2), "elsp.bim") forall(m in RM) modELS(m).uid:= m setmodpar(params, "DATAFILE", DATAFILE) setmodpar(params, "T", T); setmodpar(params, "P", P) forall(m in [M1,M2]) do setworkdir(modELS(m), ".") setmodpar(params, "ALG", m); ! Configure submodels run(modELS(m), params) ! Start submodel runs end-do objval:= MAX_REAL algsol:= -1; algopt:= -1 repeat wait ! Wait for the next event Msg:= getnextevent ! Get the event if getclass(Msg)=NEWSOL then ! Get the event class if getvalue(Msg) < objval then ! Value of the event (= obj. value) algsol:= Msg.fromuid ! ID of model sending the event objval:= getvalue(Msg) writeln("Improved solution ", objval, " found by model ", algsol) forall(m in RM | m <> algsol) send(modELS(m), NEWSOL, objval) else writeln("Solution ", getvalue(Msg), " found by model ", Msg.fromuid) end-if end-if until getclass(Msg)=EVENT_END ! A model has finished algopt:= Msg.fromuid ! Retrieve ID of terminated model forall(m in RM) stop(modELS(m)) ! Stop all running models if algsol=-1 then writeln("No solution available") exit(1) else ! Retrieve the best solution from shared memory initializations from "bin:shmem:sol"+algsol solprod solsetup end-initializations initializations from DATAFILE DEMAND end-initializations ! Solution printing writeln("Best solution found by model ", algsol) writeln("Optimality proven by model ", algopt) writeln("Objective value: ", objval) write("Period setup ") forall(p in PRODUCTS) write(strfmt(p,-7)) forall(t in TIMES) do write("\n ", strfmt(t,2), strfmt(sum(p in PRODUCTS) solsetup(p,t),8), " ") forall(p in PRODUCTS) write(strfmt(solprod(p,t),3), " (",DEMAND(p,t),")") end-do writeln end-if ! Cleaning up temporary files fdelete("elsp.bim") fdelete("shmem:sol"+M1); fdelete("shmem:sol"+M2) end-model | |||||||||
© Copyright 2023 Fair Isaac Corporation. |