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

Working with multiple models: submodels, coordination, communication, and parallelization

Description
The Mosel module mmjobs enables the user to work with several models concurrently. We show here a series of examples of basic tasks that typically need to be performed when working with several models in Mosel:

Parallel computing:
  • Running a submodel from another Mosel model: runtestsub.mos (master model executing testsub.mos)
  • Retrieving termination status from submodels (means of coordination of different models): runsubevnt.mos (master model executing testsub.mos)
  • Retrieving user event sent by the submodel: runsubevnt2.mos (master model executing testsubev.mos)
  • Stopping a submodel: runsubwait.mos (master model executing testsub.mos)
  • Compiling to memory: runsubmem.mos (master model executing testsub.mos)
  • Setting runtime parameters: runrtparam.mos (master model executing rtparams.mos)
  • Sequential execution of submodels: runrtparseq.mos (master model executing rtparams.mos)
  • Parallel execution of submodels: runrtparprl.mos (master model executing rtparams.mos)
  • Job queue for parallel execution of submodels: runrtparqueue.mos (master model executing rtparams.mos)
  • Using the shmem (shared memory) I/O driver for data exchange (bin format): runsubshm.mos (master model executing testsubshm.mos)
  • Using the shmem (shared memory) I/O driver for data exchange (raw format): runsubshmr.mos (master model executing testsubshmr.mos)
  • Using the mempipe (memory pipe) I/O driver for data exchange: runsubpip.mos (master model executing testsubpip.mos)
Distributed computing:
  • Check for available remote Mosel servers: findservers.mos
  • Run a single model on a remote machine: runrtdistr.mos (master model executing rtparams.mos)
  • Run a single model on a remote machine with configuration options: runrtdistrconf.mos (master model executing rtparams.mos)
  • Running parallel submodels in a distributed architecture: runrtpardistr.mos (master model executing rtparams3.mos)
  • Queuing submodels for parallel execution in a distributed architecture with one or several models per node: runrtparqueued.mos (master model executing rtparams3.mos)
  • 3-level tree of (parallel) submodels: runrtpartree.mos (master model executing rtparams2.mos)
  • Running a submodel that detaches itself from the master: runrtdetach.mos (master model executing rtparams4.mos)
  • Using the shmem (shared memory) I/O driver for data exchange (bin format): runsubshmdistr.mos (master model executing testsubshm.mos)
Further explanation of this example: Xpress Whitepaper 'Multiple models and parallel solving with Mosel', Section 'Basic tasks'.


Source Files





runtestsub.mos

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

   file runtestsub.mos
   ```````````````````
   Running a model from another Mosel model,
   waiting for the submodel termination.
       
   (c) 2008 Fair Isaac Corporation
       author: S. Heipcke, May 2006
*******************************************************!)

model "Run model testsub"
 uses "mmjobs"

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

! Uncomment one of the following lines to redirect the submodel output
! setdefstream(modSub, F_OUTPUT, "testout.txt") ! Output to file
! setdefstream(modSub, F_OUTPUT, "tee:testout.txt&")
                                                ! Output to file and on screen
! setdefstream(modSub, F_OUTPUT, "null:")       ! Disable all output

 run(modSub)                       ! Start model execution
 wait                              ! Wait for model termination
 dropnextevent                     ! Ignore termination event message

end-model 

Back to examples browserPrevious exampleNext example