Initializing help system before first use

Deploying models

Once a model has been compiled to a BIM file it may be deployed in a variety of ways. It may be

  • run from some remote code using the remote invocation library XPRD (see the XPRD reference manual),
  • be integrated in an application through the Mosel libraries (see Mosel libraries reference manual),
  • form part of an Xpress Insight application (see the Xpress Insight Developer Guide), or
  • simply be invoked from a command window or shell.

For the last option the usual approach consists in using the mosel command line tool (see section Running Mosel) with the run command. For instance, the following command may be used to run the model mycmd.bim:

> mosel run mycmd.bim

The aim of the deploy module is to ease the use of a model published this way. This module makes it possible to generate an executable program from the BIM file. Moreover, it gives the model access to the command line arguments and exposes a method for embedding configuration files into the resulting program. The deploy module is usually used through one of its two IO drivers: the first driver, csrc, generates a C program (based on the Mosel libraries) from a BIM file and the second one, exe, produces directly the executable by running a C compiler on the generated C source (this requires the availability of a C compiler on the system). For example the following command will create the program runmycmd (or runmycmd.exe on Windows) from the model mycmd.mos:

> mosel comp mycmd.mos -o deploy.exe:runmycmd

In addition to its IO drivers, the deploy module publishes two functions for accessing the program arguments: argc returns the number of parameters passed to the command (counting the command itself as the first) and argv(i) returns the ith argument (as a string). As an example, the following model displays the arguments it receives:

model mycmd
uses 'deploy'

writeln("My arguments:")
forall(i in 1..argc) writeln(argv(i))
end-model

After compiling this example into an executable with the command shown above, an execution of the command runmycmd a b c will display:

My arguments:
runmycmd
a
b
c

In addition to giving access to command line arguments, deploy makes it possible to embed files into the resulting executable. File locations are passed via model parameters. The following example outputs its source when the program is called with the argument 'src' — otherwise it reports an error message:

model mycmd2
uses 'deploy','mmsystem'

parameters
 SRC="null:"
end-parameters

if argc<>2 or argv(2)<>"src" then
 writeln("Usage: ", argv(1), " src")
 exit(1)
else
 writeln("Source:")
 fcopy(SRC,"")
end-if
end-model

In this example, the source file is identified by the model parameter SRC. To generate the program, the following command has to be issued:

> mosel comp mycmd2.mos -o deploy.exe:runmycmd2,SRC=mycmd2.mos

With the command above, the file mycmd2.mos is included in the executable and the SRC parameter is redefined such that the model can access the file through memory. Note that the model file can also be included in the executable in compressed form. To enable this feature, the parameter name has to be suffixed with -z in the compilation command:

> mosel comp mycmd2.mos -o deploy.exe:runmycmd2,SRC-z=mycmd2.mos

© 2001-2020 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.