Utilities and shorthands
Topics covered in this section:
- tmp: accessing the temporary directory of Mosel
- tee: multiple output destinations
- null: disactivating a stream
This section lists several drivers that can be used from the Mosel libraries and also within Mosel models. These drivers are described in the `Mosel Language Reference Manual'.
tmp: accessing the temporary directory of Mosel
The driver tmp is an extension to the default driver that locates the specified file in the temporary directory used by Mosel. For example, we might wish to compile a submodel file to a BIM file located in the temporary directory:
if compile("", "burglar.mos", "tmp:burglar.bim")<>0 then exit(1); end-if load(modBurg, "tmp:burglar.bim") ! Load the BIM file
The same can be achieved with the following library commands (Mosel C libraries):
XPRMcompmod(NULL, "burglar.mos", "tmp:burglar.bim", "Burglar example"); mod = XPRMloadmod("tmp:burglar.bim",NULL); /* Load the BIM file */
The tmp driver can also be used with the library interfaces to other programming languages, such as the Mosel Java library:
mosel.compile("", "burglar2.mos", "tmp:burglar2.bim", ""); mod = mosel.loadModel("tmp:burglar2.bim");
Mosel's temporary directory is located in the system temporary directory, its actual definition depends on the system that is used for running Mosel and can be retrieved via the Mosel function getparam.
writeln("Temporary directory: ", getparam("tmpdir") )
tee: multiple output destinations
The tee driver duplicates output into up to 6 files simultaneously. It is particularly useful for creating output log files while still being able to watch progress output on screen. If we wish to maintain screen display and at the same time log the output in the file burglarsol.txt for the example burglar2ff.mos from Section Alternative text data file formats we may use the following Mosel code:
fopen("tee:burglarsol.txt&", F_OUTPUT+F_APPEND) writeln("Solution:\n Objective: ", getobjval) forall(i in ITEMS) writeln(" take(", i, "): ", getsol(take(i))) fclose(F_OUTPUT)
The tee driver also works with the library functions, such as to duplicate all the output generated by a model (output to a file and on screen, Mosel C libraries):
XPRMsetdefstream(mod, XPRM_F_WRITE, "tee:burglarlog.txt&");
Analogously with other library interfaces, such as the Mosel Java library:
mod.setDefaultStream(XPRM.F_OUTPUT, "tee:burglarlog.txt&");
null: disactivating a stream
The typical use of the null driver is to make (embedded) models silent by disabling their output, either from the host application embedding the model 'mod' (Mosel C libraries):
XPRMsetdefstream(mod, XPRM_F_WRITE, "null:");
Similarly with other library interfaces, such as with the Mosel Java library:
mod.setDefaultStream(XPRM.F_OUTPUT, "null:");
Or from within Mosel, such as in a model that controls the execution of a submodel 'submod':
setdefstream(submod, F_OUTPUT, "null:")
Or even directly in the (sub)model itself:
fopen(F_OUTPUT, "null:")
© 2001-2025 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.