mmjobs
Topics covered in this chapter:
- Example
- Data sharing between models
- Control parameters
- Procedures and functions
- I/O drivers
- The Mosel Remote Launcher xprmsrv
Thanks to this module it is possible to load several models in memory and execute them concurrently. In addition, other instances of Mosel might be started (either locally to the running system or remotely on another machine through the network) and used to run additional models controlled by the model that has started them. This means that the computing capacity of the running model is not restricted to the executing process. A general synchronization mechanism based on event queues as well as two specialized IO drivers are also provided in order to ease the implementation of parallel algorithms in Mosel.
To use this module, the following line must be included in the header of the Mosel model file:
uses 'mmjobs'
Example
The following example shows how to compile, load, and then run a model from another model. After having started the execution, it waits for 60 seconds before stopping the secondary model if the latter has not yet finished.
model "mmjobs example" uses "mmjobs","mmsystem" declarations mymod: Model event: Event end-declarations ! Compile 'mymod.mos' to memory if compile("","mymod.mos","shmem:bim")<>0 then exit(1) end-if load(mymod,"shmem:bim") ! Load bim file from memory... fdelete("shmem:bim") ! ... and release the memory block ! Disable model output setdefstream(mymod,"","null:","null:") run(mymod) ! Start execution and wait(60) ! wait 1 min for an event if waitexpired then ! No event has been sent... writeln("Model too long: stopping it!") stop(mymod) ! ... stop the model then wait wait end-if ! An event is available: model finished event:=getnextevent writeln("Exit status: ", getvalue(event)) writeln("Exit code : ", getexitcode(mymod)) unload(mymod) end-model
Data sharing between models
A model may share data with its submodels under certain conditions: any initialisation performed by the master model on these shared entities is available to the submodels at their startup and any modification carried out by both the master model and its submodels are effective for all models.
Entities to be shared must be global and identified by the declaration qualifier shared (they do not need to be public). Only scalars of basic types and native types supporting sharing, as well as sets, lists and arrays of basic types can be shared. For the arrays, index sets must be either shared or constants of basic types, shared hashmap arrays cannot have more than 1 dimension.
declarations sci: shared integer ss: shared set of string sa: shared dynamic array(ss,1..2) of real end-declarations
Data sharing is possible only between a model (the master model) and its clones (i.e. submodels loaded from the running model see load). The master model can manipulate its shared entities just like any other data structure as long as no compatible submodel is running. However, as soon as a submodel using shared data is started the sharing mode is enabled and access to shared entities is altered as follows: sets and lists behave as if they were constant, the structure of arrays is locked (i.e. it is no longer possible to add or remove cells of sparse arrays). Normal access to shared entities is restored when all submodels using them are reset (reset) or unloaded (unload). The current status of the sharing mode can be obtained from the sharingstatus control parameter (getparam).
model "shared example" uses 'mmjobs' declarations a: shared array(1..3) of integer m: Model end-declarations if getparam("sharingstatus")<>2 then ! in master model ('a' is empty) forall(i in 1..3) a(i):=i ! initialise 'a' writeln("master:",a) ! output: master:[1,2,3] load(m) ! clone master then run it run(m) waitforend(m) ! wait for its termination writeln("aftersub:",a) ! output: aftersub:[2,3,4] else ! in submodel ('a' is already initialised) writeln("sub:",a) ! output: sub:[1,2,3] forall(i in 1..3) a(i)+=1 ! modify 'a' end-if end-model
© 2001-2023 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.