Overview of subroutines and reserved words
Topics covered in this chapter:
There is a range of built-in functions and procedures available in Mosel. They are described fully in the Mosel Language Reference Manual. Here is a summary.
- Accessing solution values: getsol, getact, getdual, getrcost, getslack, getobjval
- Arithmetic functions: abs, arctan, cos, sin, ceil, floor, round, exp, ln, log, sqrt, isodd, random, setrandseed
- List functions: maxlist, minlist, cutelt, cutfirst, cutlast, cuthead, cuttail, findfirst, findlast, getelt, getfirst, getlast, getreverse, reverse, gethead, gettail, splithead, splittail
- String functions: strfmt, substr, _
- Dynamic array handling: create, exists, finalize, delcell, isdynamic
- File handling: fclose, fflush, fopen, fselect, fskipline, fwrite, fwrite_, fwriteln, fwriteln_, getfid, getfname, getreadcnt, iseof, read, readln, write, write_, writeln, writeln_
- Accessing control parameters: getparam, localsetparam, restoreparam, setparam
- Getting information: getcoeff, getcoeffs, getnbdim, getsize, gettype, getvars
- Constraint definition: sethidden, ishidden, makesos1, makesos2, setcoeff, setname, setrange, settype
- Time and date: currentdate, currenttime, timestamp
- Bit values: bitflip, bitneg, bitset, bitshift, bittest, bitval
- Special values: isfinite, isinf, isnan
- Handling unions: geteltype, getstruct, gettypeid, isdefined
- Miscellaneous functions: asproc, assert, compare, datablock, dumpcallstack, exit, exportprob, reset, setioerr, setmatherr, publish, unpublish, memoryuse, newmuid, versionnum, versionstr
Modules
The distribution of Mosel contains several modules that add extra functionality to the language.
A full list of the functionality of a module can be obtained by using Mosel's exam command, for instance
mosel exam mmsystem
In this manual, we always use Xpress Optimizer as solver. Access to the corresponding optimization functions is provided by the module mmxprs.
In the mmxprs module are the following useful functions.
- Optimize: minimize, maximize
- MIP directives: setmipdir, clearmipdir
- Handling bases: savebasis, loadbasis, delbasis
- Force problem loading: loadprob
- Accessing problem status: getprobstat
- Deal with bounds: setlb, setub, getlb, getub
- Model cut functions: setmodcut, clearmodcut
For example, here is a nice habit to get into when solving a problem with Xpress Optimizer.
declarations status:array({XPRS_OPT,XPRS_UNF,XPRS_INF,XPRS_UNB,XPRS_OTH}) of string end-declarations status::([XPRS_OPT,XPRS_UNF,XPRS_INF,XPRS_UNB,XPRS_OTH])[ "Optimum found","Unfinished","Infeasible","Unbounded","Failed"] ... minimize(Obj) writeln(status(getprobstat))
In the mmsystem module are various useful functions provided by the underlying operating system and a few programming utilities :
- Delete a file/directory: fdelete, removedir
- Copy/move a file: fcopy, fmove
- Make a directory: makedir
- Current working directory: getcwd
- Get/set an environment variable's value: getenv, setenv
- File and system status: getfstat, getsysstat
- General system call: system
- Time and date: gettime, getdate, getweekday, getasnumber, ...
- Handling the type text: copytext, cuttext, deltext, readtextline, ...
- Sort an array of any type with 'order' property: qsort
Other modules mentioned in this manual are mmodbc, mmsheet, mmetc, and mmjobs.
See the module documentation in the Mosel Language Reference Manual or in the individual module reference manuals for full details.
Reserved words
The following words are reserved in Mosel. The upper case versions are also reserved (i.e. AND and and are keywords but not And). Do not use them in a model except with their built-in meaning.
and, any, array, as
boolean, break
case, constant, count, counter
declarations, div, do, dynamic
elif, else, end, evaluation
false, forall, forward, from, function
hashmap
if, imports, in, include, initialisations, initializations, integer, inter,
is, is_binary, is_continuous, is_free, is_integer, is_partint, is_semcont,
is_semint, is_sos1, is_sos2
linctr, list
max, min, mod, model, mpproblem, mpvar
namespace, next, not, nsgroup, nssearch
of, options, or
package, parameters, procedure, public, prod
range, real, record, repeat, requirements, return
set, shared, string, sum
then, to, true
union, until, uses
version
while, with
© 2001-2024 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.