FICO
FICO Xpress Optimization Examples Repository
FICO Optimization Community FICO Xpress Optimization Home
Back to examples browserPrevious exampleNext example

Looping over optimization runs (within a model, batch executions, and multiple models/submodel)

Description
This example shows different possibilities of looping over a series of optimization runs using different data sets.
  • In the first case (batch1.mos) the loop is implemented within a single Mosel model. At every loop execution a new data set is read and the model is redefined correspondingly.
  • The second model (batch2.mos) only defines and solves once the optimization problem. It is run either from a batch file (runbatch2), or from an application using the Mosel Libraries (batch2.c), or as a submodel from a second Mosel model (runbatch2.mos) and receives the name of the data set to be used through a runtime parameter.


Source Files
By clicking on a file name, a preview is opened at the bottom of this page.
batch1.mos[download]
batch2.mos[download]
batch2.c[download]
runbatch2[download]
runbatch2.mos[download]

Data Files





runbatch2.mos

(!*******************************************************
   Mosel Example Problems 
   ======================

   file runbatch2.mos
   ``````````````````
   Running several instances of a model from another
   Mosel model.
       
   (c) 2008 Fair Isaac Corporation
       author: S. Heipcke, May 2006
*******************************************************!)

model "Run model batch2"
 uses "mmjobs"

 parameters
  FILENAME = "batch2"
 end-parameters

 declarations
  modBatch: Model
 end-declarations
                                   ! Compile the model file
 if compile(FILENAME+".mos")<>0 then exit(1); end-if
 load(modBatch, FILENAME+".bim")   ! Load the bim file

 forall(i in 0..2) do                 ! Start model execution
  run(modBatch, "INFILE=batchdata" + i + ".dat, OUTFILE=batchdata" + 
                (i+1) + ".dat, LIM=" + (100+i*10))
  wait                             ! Wait for model termination
  dropnextevent                    ! Ignore termination event message
 end-do

end-model 

Back to examples browserPrevious exampleNext example