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





batch2.mos

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

   file batch2.mos
   ```````````````
   Looping over program executions coupled with 
   parameterized data in- and output.
       
   (c) 2008 Fair Isaac Corporation
       author: S.Heipcke, 2002, rev. 2017
*******************************************************!)

model "batch 2"
 uses "mmxprs"

 parameters
  INFILE="batchdata0.dat"
  OUTFILE="batchdata1.dat"
  LIM=100
 end-parameters

 declarations
  R=1..10
  A,B: array(R) of real
  x: array(R) of mpvar
  ACtr,AnObj: linctr
 end-declarations

 initializations from INFILE
  A as "a"   B as "b"
 end-initializations

 if(LIM>100) then
  forall(r in R) B(r)+=1
 end-if 

 ACtr:= sum(r in R) B(r)*x(r) <= LIM
 AnObj:=sum(r in R) A(r)*x(r)
 forall(r in R) x(r) is_binary
 
 maximise(AnObj)
 writeln("Objective: ", getobjval) 

 initializations to OUTFILE
  B as "b"
 end-initializations

end-model 

Back to examples browserPrevious exampleNext example