FICO Xpress OptimizationR⃝

Last update March 2022

6.0
REFERENCE MANUAL

FICO Xpress MoselR⃝©2001–2022 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 thisdocumentation and the software described in it must conform strictly to the foregoing permitted uses, andno other use is permitted.
The information in this documentation is subject to change without notice. If you find any problems in thisdocumentation, please report them to us in writing. Neither FICO nor its affiliates warrant that thisdocumentation is error-free, nor are there any other warranties with respect to the documentation except as
may be provided in the license agreement. FICO and its affiliates specifically disclaim any warranties,
express or implied, including, but not limited to, non-infringement, merchantability and fitness for a particularpurpose. Portions of this documentation and the software described in it may contain copyright of various
authors and may be licensed under certain third-party licenses identified in the software, documentation, orboth.
In no event shall FICO or its affiliates be liable to any person for direct, indirect, special, incidental, or
consequential damages, including lost profits, arising out of the use of this documentation or the software
described in it, even if FICO or its affiliates have been advised of the possibility of such damage. FICO and its
affiliates have no obligation to provide maintenance, support, updates, enhancements, or modifications
except as required to licensed users under a license agreement.
FICO is a registered trademark of Fair Isaac Corporation in the United States and may be a registeredtrademark of Fair Isaac Corporation in other countries. Other product and company names herein may be
trademarks of their respective owners.
Xpress Mosel
Deliverable Version: A
Last Revised: March 2022
Version 6.0

Contents
1

Introduction
1.1 What is Mosel? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.2 General organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.3 Running Mosel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.3.1 mosel command: invocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.3.2 mosel command: interactive debugger . . . . . . . . . . . . . . . . . . . . . . . . .
1.3.3 mosel command: tracing mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.3.4 mosel command: restricted mode . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.3.5 mosel command: securing bim files . . . . . . . . . . . . . . . . . . . . . . . . . .
1.4 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.5 Structure of this manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1
1
1
2
2
6
10
11
12
12
13

I

Core System

14

2 The Mosel Language
2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.1.1 Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.1.2 Identifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.1.3 Reserved words . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.1.4 Separation of instructions, line breaking . . . . . . . . . . . . . . . . . . . . . . . .
2.1.5 Conventions in this document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.2 Structure of the source file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.3 The compiler directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.3.1 Directive uses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.3.2 Directive imports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.3.3 Directive options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.3.4 Directive version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.4 The parameters block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.5 Source file preprocessing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.5.1 Source file character encoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.5.2 Source file inclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.5.3 Line control directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.6 The declaration block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.6.1 Elementary types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.6.1.1 Basic types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.6.1.2 MP types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.6.2 Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.6.3 Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.6.4 Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.6.4.1 Special case of dynamic arrays of a type not supporting assignment . . .
2.6.5 Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.6.6 Subroutine references . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.6.7 Unions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.6.8 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Fair Isaac Corporation Proprietary Information

15
15
15
15
16
16
16
17
17
17
18
19
19
20
20
20
20
21
21
22
22
22
23
23
24
25
25
25
26
26

i

Contents

2.6.9 User defined types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.6.9.1 Naming new types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.6.9.2 Combining types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.7 Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.7.1 Type conversions and constructors . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.7.1.1 Union constructors and subroutine parameters . . . . . . . . . . . . . . .
2.7.2 Aggregate operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.7.3 Arithmetic expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.7.4 String expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.7.5 Set expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.7.6 List expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.7.7 Boolean expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.7.8 Linear constraint expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.7.9 Automatic arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.7.10 Operator -> (reference to) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.8 Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.8.1 Simple statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.8.1.1 Assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.8.1.2 Assignment of structured types . . . . . . . . . . . . . . . . . . . . . . . .
2.8.1.3 Assignment of subroutine references . . . . . . . . . . . . . . . . . . . .
2.8.1.4 Assignment of unions . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.8.1.5 About implicit declarations . . . . . . . . . . . . . . . . . . . . . . . . . .
2.8.1.6 Inline initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.8.1.7 Linear constraint expression . . . . . . . . . . . . . . . . . . . . . . . . . .
2.8.1.8 Procedure call . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.8.2 Initialization block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.8.2.1 Handling of unions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.8.2.2 About automatic finalization . . . . . . . . . . . . . . . . . . . . . . . . . .
2.8.3 Selections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.8.3.1 If statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.8.3.2 Case statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.8.4 Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.8.4.1 Forall loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.8.4.2 While loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.8.4.3 Repeat loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.8.4.4 break and next statements . . . . . . . . . . . . . . . . . . . . . . . . .
2.8.4.5 with statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.9 Procedures and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.9.1 Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.9.2 Variable number of parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.9.3 Formal parameters: passing convention . . . . . . . . . . . . . . . . . . . . . . . .
2.9.4 Local declarations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.9.5 Overloading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.9.6 Forward declaration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.9.7 Suffix notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.10 Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.10.1 The mpproblem type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.11 The public qualifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.12 Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.12.1 Version management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.12.2 The requirements block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.12.3 Control parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.13 Namespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.14 Annotations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.14.1 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Fair Isaac Corporation Proprietary Information

27
27
27
28
31
32
32
33
33
34
34
35
36
37
37
37
37
37
38
38
39
39
39
40
40
40
43
43
43
43
44
45
45
45
45
46
46
47
47
48
48
48
49
49
50
50
51
52
53
53
53
54
54
55
55

ii

Contents

2.14.2 Symbol association . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.14.3 Declaration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.15 File names and input/output drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.16 Character encoding of text files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.17 Working directory and temporary directory . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.18 Handling of input/output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.19 Deploying models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.20 Documenting models using annotations . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.20.1 doc annotation category . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.20.1.1 Global definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.20.1.2 Document structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.20.1.3 Symbol definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.20.1.4 Annotation definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.20.1.5 Package control parameters . . . . . . . . . . . . . . . . . . . . . . . . . .
2.20.2 moseldoc documentation processor . . . . . . . . . . . . . . . . . . . . . . . . . .
2.20.2.1 Running moseldoc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.20.2.2 Structure of the generated document . . . . . . . . . . . . . . . . . . . . .
2.20.2.3 Processing of annotation values . . . . . . . . . . . . . . . . . . . . . . .
2.21 Message translation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.21.1 Preparing the model source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.21.2 Building the message catalogs . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.21.3 Model execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

57
57
59
60
61
61
62
63
63
64
64
65
67
67
67
67
68
68
68
68
69
70

3 Predefined functions and procedures
71
abs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
arctan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
asproc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
assert . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
bitflip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
bitneg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
bitset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
bitshift . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
bittest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
bitval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
ceil . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
compare . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
cos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
create . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
currentdate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
currenttime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
cutelt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
cutfirst . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
cuthead . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
cutlast . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
cuttail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
delcell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
datablock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
dumpcallstack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
exists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
exit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
exp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
exportprob . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
fclose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
fflush . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
finalize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103

Fair Isaac Corporation Proprietary Informationiii

Contents

findfirst . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
findlast . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
floor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
fopen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
fselect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
fskipline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
fwrite, fwriteln . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getact . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getcoeff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getcoeffs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getdual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getelt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
geteltype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getfid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getfirst . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
gethead . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getfname . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getlast . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getnbdim . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getobjval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getparam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getrcost . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getreadcnt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getreverse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getsize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getslack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getsol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getstruct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
gettail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
gettype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
gettypeid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getvars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
isdefined . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
isdynamic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
iseof . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
isfinite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ishidden . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
isinf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
isnan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
isodd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ln . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
localsetparam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
log . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
makesos1, makesos2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
maxlist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
memoryuse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
minlist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
newmuid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
publish . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
random . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
read, readln . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
restoreparam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
reverse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
round . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Fair Isaac Corporation Proprietary Information

104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
127
128
129
130
131
132
133
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161

iv

ContentsII

setcoeff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
sethidden . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setioerr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setmatherr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setname . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setparam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setrandseed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setrange . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
settype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
sin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
splithead . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
splittail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
sqrt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
strfmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
substr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
timestamp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
unpublish . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
versionnum, versionstr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
write, writeln . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

162
163
164
165
166
167
169
170
171
172
173
174
175
176
177
178
179
180
181

Modules182

4 deploy
183
4.1 Procedures and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
argc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
argv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
4.2 I/O drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
4.2.1 Driver csrc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
4.2.2 Driver exe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
5 mmetc
188
5.1 Procedures and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
disc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
diskdata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
5.2 I/O drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
5.2.1 Driver diskdata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
6 mmhttp
194
6.1 New functionality for the Mosel language . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
6.1.1 The type reqqueue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
6.2 Control parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
http_async . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
http_browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
http_cookies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
http_defpage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
http_defport . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
http_expire . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
http_freeasync . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
http_keephdr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
http_listen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
http_maxconn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
http_maxcontime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
http_maxreq . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
http_maxreqtime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
http_maxasync . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199

Fair Isaac Corporation Proprietary Informationv

Contents

http_port . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
http_proxy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
http_proxyport . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
http_srvconfig . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
http_startwb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
https_defport . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
https_listen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
https_port . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.3 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.4 Procedures and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.4.1 HTTP client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
delcookies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
findcookie . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
httpcancel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
httpdel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
httpget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
httpgetheader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
httphead . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
httppatch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
httppost . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
httpput . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
httpreason . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
loadcookies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
savecookies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setcookie . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
tcpping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
urlencode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.4.2 HTTP server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
httppending . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
httpqueueinfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
httpreply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
httpreplycode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
httpreplyjson . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
httpreqconstat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
httpreqcookies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
httpreqfile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
httpreqfrom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
httpreqheader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
httpreqlabel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
httpreqpop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
httpreqpush . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
httpreqpushlim . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
httpreqstat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
httpreqtype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
httpstartsrv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
httpstopsrv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
jsonread . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
jsonwrite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
mksetcookie . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.5 I/O drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.5.1 Driver url . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

199
199
199
200
200
200
201
201
201
202
202
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
244

7 mmjava245
7.1 I/O drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
7.1.1 Driver java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245

Fair Isaac Corporation Proprietary Informationvi

Contents

7.1.2

Driver jraw . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246

8 mmjobs
247
8.1 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
8.2 Data sharing between models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
8.3 Control parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
conntmpl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
nodenumber . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
defaultnode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
jobid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
parentnumber . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
keepalive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
fsrvport . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
fsrvdelay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
fsrvnbiter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
sshcmd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
8.4 Procedures and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
8.4.1 Mosel instance management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
connect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
disconnect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
clearaliases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
getbanner . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
gethostalias . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
getaliases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
sethostalias . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
findxsrvs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
8.4.2 Model management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
compile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
detach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264
load . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
setdefstream . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
resetmodpar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
setcontrol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
setmodpar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270
setworkdir . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
run . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
getdsoprop, getdsopropnum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
getgid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274
getid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
getmodprop, getmodpropnum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276
getnode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
getrmtid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
getstatus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
getuid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
getexitcode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
stop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282
reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
unload . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
getannidents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
getannotations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
8.4.3 Synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
canceltimer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
send . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
settimer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
setuid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291

Fair Isaac Corporation Proprietary Informationvii

Contents

setgid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
wait . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
waitexpired . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
waitfor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
waitforend . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getnextevent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
dropnextevent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
isqueueempty . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
nullevent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getfromid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getfromgid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getfromuid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getclass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
gettimer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getvalue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
peeknextevent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
pipeflush . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
pipenotify . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.5 I/O drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.5.1 Driver shmem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.5.2 Driver mempipe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.5.3 Driver rcmd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.5.4 Driver xsrv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.5.5 Driver xssh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.5.6 Driver rmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.6 The Mosel Remote Launcher xprmsrv . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.6.1 Running the xprmsrv command . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.6.1.1 Main command line options . . . . . . . . . . . . . . . . . . . . . . . . . .
8.6.1.2 Secure server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.6.1.3 Private key management . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.6.1.4 Mode of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.6.2 Configuration file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.6.2.1 Access control list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

292
293
294
295
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
311
311
312
312
312
313
313
313
313
315
315
315
316
318

9 mmnl320
9.1 New functionality for the Mosel language . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320
9.1.1 The problem type mpproblem.nl . . . . . . . . . . . . . . . . . . . . . . . . . . . 320
9.1.2 The type nlctr and its operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320
9.1.3 Setting initial values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320
9.1.4 Example: using mmnl for QCQP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321
9.2 Procedures and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
clearinitvals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
copysoltoinit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
setinitval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326
getsol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
ishidden . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328
sethidden . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329
gettype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330
pwlin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
setname . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332
settype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333
10 mmoci334
10.1 Prerequisite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334
10.2 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334

Fair Isaac Corporation Proprietary Informationviii

Contents

10.3 Data transfer between Mosel and Oracle . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.3.1 From Oracle to Mosel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.3.2 From Mosel to Oracle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.4 Control parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
OCIautocommit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
OCIautondx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
OCIbufsize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
OCIcolsize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
OCIconnection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
OCIdebug . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
OCIfirstndx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
OCIndxcol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
OCIrowcnt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
OCIrowxfr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
OCIsuccess . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
OCItruncsize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
OCIverbose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.5 Procedures and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
OCIlogon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
OCIlogoff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
OCIexecute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
OCIreadinteger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
OCIreadreal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
OCIreadstring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
OCIcommit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
OCIrollback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.6 I/O drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.6.1 Driver oci . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

335
335
336
338
339
339
340
340
340
340
341
341
341
341
342
342
342
342
344
345
346
347
348
349
350
351
352
352

11 mmodbc
353
11.1 Prerequisite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
11.2 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
11.3 Data transfer between Mosel and the database . . . . . . . . . . . . . . . . . . . . . . . . 354
11.3.1 From the database to Mosel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354
11.3.2 From Mosel to the database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355
11.4 ODBC and MS Excel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
11.5 Control parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358
SQLautocommit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358
SQLautondx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359
SQLbufsize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359
SQLcolsize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359
SQLconnection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
SQLdebug . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
SQLdm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
SQLextn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
SQLfirstndx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361
SQLndxcol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361
SQLrowcnt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361
SQLrowxfr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361
SQLsuccess . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362
SQLtruncsize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362
SQLverbose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362
11.6 Procedures and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362
SQLcolumns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364
SQLcommit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365

Fair Isaac Corporation Proprietary Informationix

Contents

SQLconnect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
SQLdataframe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
SQLdisconnect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
SQLexecute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
SQLparam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
SQLgetparam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
SQLindices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
SQLprimarykeys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
SQLreadinteger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
SQLreadreal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
SQLreadstring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
SQLrollback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
SQLtables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
SQLupdate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11.7 I/O drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11.7.1 Driver odbc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

366
368
369
370
372
373
374
375
376
377
378
379
380
381
382
382

12 mmquad383
12.1 New functionality for the Mosel language . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383
12.1.1 The type qexp and its operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383
12.1.1.1 Example: using mmquad for Quadratic Programming . . . . . . . . . . . 383
12.1.2 Procedures and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384
exportprob . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385
getsol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 386
12.2 Published library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387
12.2.1 Complete module example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387
12.2.2 Description of the library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 389
getqexpsol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 390
getqexpstat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391
clearqexpstat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392
getqexpnextterm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393
13 mmreflect394
13.1 New functionality for the Mosel language . . . . . . . . . . . . . . . . . . . . . . . . . . . . 394
13.1.1 The type iterator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 394
13.1.2 The type reflecterror . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 394
13.2 Procedures and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395
callfunc, callfunclsa . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396
callproc, callproclsa . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397
findident . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398
getallidents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
getallparams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401
getannidents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402
getannotations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
getarrval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404
getcode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405
geteltype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406
getindices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407
getmsg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408
getnbargs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409
getrettype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410
getsignature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411
getstatus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412
inititer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413
nextcell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414

Fair Isaac Corporation Proprietary Informationx

Contents

setarrval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415
setindices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416
testtype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417
14 mmrobust
418
14.1 New functionality for the Mosel language . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418
14.1.1 The problem type mpproblem.xprs.robust . . . . . . . . . . . . . . . . . . . . 418
14.1.2 The type uncertain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418
14.1.3 The type robustctr and its operators . . . . . . . . . . . . . . . . . . . . . . . . . 419
14.1.4 The type uncertainctr and its operators . . . . . . . . . . . . . . . . . . . . . . 419
14.1.5 Example: using mmrobust for solving a robust problem . . . . . . . . . . . . . . . . 419
14.2 Control parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420
robust_uncertain_overlap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420
robust_check_feas_uncertainty_set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420
robust_check_feas_original_problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421
14.3 Procedures and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421
cardinality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422
getsol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423
getact . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424
ishidden . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425
scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426
sethidden . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427
getnominal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428
gettype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429
setnominal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 430
settype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431
15 mmsheet
432
15.1 I/O drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 432
15.1.1 Driver excel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433
15.1.2 Driver xls/xlsx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434
15.1.3 Driver csv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434
16 mmssl
436
16.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436
16.1.1 Document encryption in Mosel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436
16.1.2 The mmssl command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436
16.2 Control parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437
https_cacerts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 438
https_ciphers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 438
https_cltcrt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 438
https_cltkey . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439
https_srvcrt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439
https_srvkey . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439
https_trustsrv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440
ssl_cipher . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440
ssl_digest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440
ssl_dir . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441
ssl_privkey . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441
16.3 Procedures and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442
RSAfingerprint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443
RSAgenkey . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444
RSAgetkeysize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445
RSAisprivate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446
RSAloadkey . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447

Fair Isaac Corporation Proprietary Informationxi

Contents

RSApubdecrypt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
RSAprivdecrypt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
RSAprivencrypt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
RSApubencrypt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
RSAsavekey . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
msgdigest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
msgsign . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
msgverify . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
sslivsize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
sslkeysize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
sslmdsize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
sslrandom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
sslrandomdata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
x509check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
x509getinfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
x509newcrt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.4 I/O drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.4.1 Driver base64 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.4.2 Driver hex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.4.3 Driver crypt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.4.4 Driver hmac . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
464
464
464
465

17 mmsvg
466
17.1 SVG graph structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466
17.1.1 Object groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466
17.1.2 SVG styling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467
17.1.3 Interaction with the graphical display . . . . . . . . . . . . . . . . . . . . . . . . . . 468
17.1.4 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468
17.2 Control parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469
MMSVGDISPLAY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469
MMSVGTGZ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470
17.3 Procedures and Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470
svgaddgroup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 472
svgaddarrow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
svgaddcircle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474
svgaddellipse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475
svgaddfile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476
svgaddimage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 477
svgaddline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 478
svgaddpie . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 479
svgaddpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 480
svgaddpolygon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481
svgaddrectangle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482
svgaddtext . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483
svgaddxmltext . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484
svgclosing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 485
svgcolor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 486
svgdelobj . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487
svgerase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 488
svggetgraphstyle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489
svggetgraphstylesheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 490
svggetgraphviewbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491
svggetlastobj . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 492
svggetstyle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 493
svggetstylesheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 494

Fair Isaac Corporation Proprietary Informationxii

Contents

svgpause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
svgrefresh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
svgsave . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
svgsetgraphlabels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
svgsetgraphpointsize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
svgsetgraphscale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
svgsetgraphstyle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
svgsetgraphstylesheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
svgsetgraphviewbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
svgsetreffreq . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
svgsetstyle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
svgsetstylesheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
svgshowgraphaxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
svgwaitclose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

495
496
497
498
499
500
501
502
503
504
505
506
507
508

18 mmsystem509
18.1 New functionality for the Mosel language . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509
18.1.1 The type text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509
18.1.2 The type date . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509
18.1.3 The type time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509
18.1.4 The type datetime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 510
18.1.5 The type parsectx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 510
18.1.6 The type textarea . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 510
18.2 Control parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 510
datefmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 511
timefmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 511
datetimefmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 512
monthnames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 512
sys_endparse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513
sys_fillchar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513
sys_pid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513
sys_qtype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513
sys_regcache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 514
sys_sepchar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 514
sys_trim . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 514
sys_txtmem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 514
18.3 Procedures and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 515
addmonths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 518
compareic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519
copytext . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 520
cuttext . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 521
deltext . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522
endswith . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523
erase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 524
expandpath . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 525
fcopy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 526
fdelete . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 527
findfiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 528
findtext . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 529
fmove . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530
formattext . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 531
getasnumber . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533
getchar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 534
getcwd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 535
getdate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 536

Fair Isaac Corporation Proprietary Informationxiii

Contents

getday . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getdaynum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getdays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getdirsep . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getdsoparam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getendparse, setendparse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getenv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getfsize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getfstat, getflstat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getftime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
gethour . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getminute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getmonth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getmsec . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getoserror . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getoserrmsg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getpathsep . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getsucc, setsucc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getqtype, setqtype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getsecond . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getsepchar, setsepchar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getsize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getstart, setstart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getsysinfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getsysstat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
gettime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
gettmpdir . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
gettrim, settrim . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getweekday . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getyear . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
inserttext . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
isvalid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
jointext . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
makedir . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
makepath . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
newtar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
newzip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
nextfield . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
openpipe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
parseextn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
parseint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
parsereal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
parsetext . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
pastetext . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
pathmatch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
pathsplit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
qsort . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
quote . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
readlink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
readtextline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
regmatch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
regreplace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
removedir . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
removefiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setchar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Fair Isaac Corporation Proprietary Information

537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
579
580
582
583
584
585
587
588
589
590
592
593
594
595

xiv

Contents

setdate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setday . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setdsoparam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setenv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setoserror . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
sethour . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setminute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setmonth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setmsec . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setsecond . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
settime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setyear . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
sleep . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
splittext . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
startswith . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
symlink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
tarlist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
textfmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
tolower . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
toupper . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
trim . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
untar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
unzip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ziplist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
18.4 I/O drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
18.4.1 Driver text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
18.4.2 Driver pipe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
18.5 Published library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
18.5.1 Description of the library functions . . . . . . . . . . . . . . . . . . . . . . . . . . .
gettime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
settime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getdate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setdate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getdatetime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setdatetime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getcsttxtbuf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
gettxtsize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
gettxtbuf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
txtresize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
614
615
617
618
619
620
621
622
623
623
623
624
624
626
627
628
629
630
631
632
633
634
635

19 mmxml
636
19.1 Document representation in mmxml . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 636
19.1.1 Data model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 636
19.1.2 Paths in a document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 637
19.1.2.1 Axis specifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 638
19.1.2.2 Node test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 638
19.1.2.3 Abbreviated notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 638
19.1.2.4 Predicate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 638
19.1.3 JSON document as an XML tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 639
19.2 New functionality for the Mosel language . . . . . . . . . . . . . . . . . . . . . . . . . . . . 641
19.2.1 The type xmldoc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 641
19.3 Procedures and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 641
addnode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 643
copynode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 645

Fair Isaac Corporation Proprietary Information

xv

Contents

delattr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
delnode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getattr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
testattr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getencoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getname . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getvalue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getfirstattr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getnext . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getfirstchild . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getlastchild . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getnode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getnodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getparent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
gettype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getstandalone . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getxmlversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
gethspace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getvspace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getindentmode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getindentskip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getlinelen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getmaxnodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getsize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
jsonload . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
jsonparse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
jsonsave . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
load . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
save . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setattr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setencoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setmaxnodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setname . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setvalue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
sethspace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setvspace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setindentmode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setindentskip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setlinelen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setstandalone . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setxmlversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
xmlattr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
xmlencode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
xmldecode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
xmlparse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
673
674
675
676
677
678
679
680
681
683
684
685
686
687
688
689
690
691
692

20 mmxnlp
694
20.1 New functionality for the Mosel language . . . . . . . . . . . . . . . . . . . . . . . . . . . . 694
20.1.1 The userfunc type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 694
20.1.2 The tolset type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 695
20.1.3 The mpproblem.xprs.xnlp problem type . . . . . . . . . . . . . . . . . . . . . . 695
20.2 mmxnlp and the other Mosel modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 695
20.2.1 Overloaded functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 695
20.2.2 Module compatibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 696
20.3 Control parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 696

Fair Isaac Corporation Proprietary Information

xvi

Contents

XNLP_AUTOELIM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
XNLP_LOADASNL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
XNLP_LOADNAMES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
XNLP_NLPSTATUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
XNLP_SOLVER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
XNLP_VERBOSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20.4 Procedures and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
addmultistart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
chgdeltatype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
F . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
generateUFparallel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
printmodelmemory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
printmodelscaling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setcallback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setcomplementary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setdefvar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setdetrow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setenforcedctr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setinitsb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
settol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
settolset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
userfuncinfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
userfuncMosel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
validate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20.5 Error codes issued by mmxnlp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

697
697
697
698
698
698
698
700
701
702
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718

21 mmxprs
720
21.1 New functionality for the Mosel language . . . . . . . . . . . . . . . . . . . . . . . . . . . . 720
21.1.1 The problem type mpproblem.xprs . . . . . . . . . . . . . . . . . . . . . . . . . . 720
21.1.2 The type basis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 720
21.1.3 The type mpsol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 720
21.1.4 The type boolvar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 721
21.1.5 The type logctr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 721
21.2 Control parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 721
XPRS_colorder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 722
XPRS_enumsols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 722
XPRS_enummaxsol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 722
XPRS_enumduplpol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 723
XPRS_fullversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 723
XPRS_loadnames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 723
XPRS_maxupdc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 723
XPRS_problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 724
XPRS_probname . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 724
XPRS_verbose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 724
21.3 Procedures and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 724
addmipsol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 728
basisstability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 729
calcsolinfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 730
clearmipdir . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 731
clearmodcut . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 732
command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 733
copysoltoinit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 734
crossoverlpsol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 735
defdelayedrows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 736
defsecurevecs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 737

Fair Isaac Corporation Proprietary Information

xvii

Contents

estimatemarginals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
fixglobal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getbstat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getcomputeallowed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getdualray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getiis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getiissense . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getiistype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getinfcause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getinfeas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getlb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getloadedlinctrs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getloadedmpvars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getmatcoeff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getname . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getprimalray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getprobstat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getrange . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getscale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getsensrng . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getsize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getsol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getvar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getub . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getvars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
hasfeature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
implies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
indicator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
isiisvalid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
isintegral . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
loadbasis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
loadlpsol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
loadmipsol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
loadprob . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
maximize, minimize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
postsolve . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
readbasis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
readdirs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
readsol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
refinemipsol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
rejectintsol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
repairinfeas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
resetbasis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
resetiis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
resetsol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
savebasis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
savemipsol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
savesol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
savestate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
selectsol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setarchconsistency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setbstat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setcallback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setcomputeallowed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setcbcutoff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Fair Isaac Corporation Proprietary Information

738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
772
773
775
776
777
778
779
780
781
783
784
785
786
787
788
789
790
791
792
793
796
797

xviii

Contents

setgndata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setlb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setmatcoeff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setmipdir . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setmodcut . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setsol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setub . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
setucbdata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
stopoptimize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
unloadprob . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
uselastbarsol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
writebasis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
writedirs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
writeprob . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
writesol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
xor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
xprsmemoryuse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.4 Cut Pool Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
addcut . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
addcuts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
delcuts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
dropcuts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getcnlist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
getcplist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
loadcuts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
storecut . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
storecuts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824

22 python3825
22.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 825
22.1.1 Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 825
22.1.2 Windows Anaconda Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 826
22.1.3 Linux Anaconda Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 826
22.1.4 Python initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 827
22.1.5 Data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 827
22.2 Xpress Insight 4 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 828
22.3 Xpress Insight 5 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 829
22.4 Control parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 830
pyinitverbose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 831
pyusepandas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 831
22.5 Procedures and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 831
pycall . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 833
pyexec . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 835
pyget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 836
pygetdf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 837
pyinit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 839
pyinitpandas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 840
pyrun . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 841
pyset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 842
pysetdf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 843
pyunload . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 844
22.6 I/O drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 845
22.6.1 Driver python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 845
22.6.1.1 Type mapping to Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . 845
22.6.1.2 Type mapping from Python . . . . . . . . . . . . . . . . . . . . . . . . . . 846

Fair Isaac Corporation Proprietary Informationxix

Contents

22.7 Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 847
23 R
848
23.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 848
23.1.1 Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 848
23.1.2 R initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 849
23.1.3 Memory limit on Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 849
23.1.4 Data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 850
23.2 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 852
23.3 Control parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 853
Rverbose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 853
Rinteractive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 854
Rusemosstreams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 854
Rcleanscript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 854
Runloadscript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 854
Rsessionmode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 855
23.4 Procedures and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 855
Reval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 856
Rfree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 857
Rgetarr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 858
Rgetbool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 859
Rgetint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 860
Rgetreal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 861
Rgetstr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 862
Rinit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 863
Rprint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 864
Rset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 865
Rsetdf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 866
Rsource . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 867
Rerrcode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 868
Rerrmsg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 869
Rclearerr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 870
23.5 I/O drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 871
23.5.1 Driver rws . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 871
23.6 Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 871
24 zlib873
24.1 I/O drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 873
24.1.1 Driver gzip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 873
24.1.2 Driver deflate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 873
24.1.3 Driver zip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 873

Appendix875

A Syntax diagrams for the Mosel language
876
A.1 Main structures and statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 876
A.2 Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 880
A.3 Initializations data file format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 883
B Remote Invocation Protocol
884
B.1 Instance control parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 884
B.2 mcmd pseudo file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 885
B.3 Profiler interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 889
B.4 Debugger interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 889

Fair Isaac Corporation Proprietary Informationxx

Contents

C Error messages
891
C.1 General errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 891
C.2 Parser/compiler errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 893
C.2.1 Errors related to modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 901
C.2.2 Errors related to packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 901
C.3 Runtime errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 901
C.3.1 Initializations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 901
C.3.2 General runtime errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 902
C.3.3 BIM reader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 904
C.3.4 Module manager errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 904
D Contacting FICO
906
Product support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 906
Product education . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 906
Product documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 906
Sales and maintenance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 907
Related services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 907
FICO Community . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 907
About FICO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 907

Index

Fair Isaac Corporation Proprietary Information

908

xxi

CHAPTER 1

Introduction
1.1 What is Mosel?
Mosel is an environment for modeling and solving problems. To this aim, it provides a language that isboth a modeling and a programming language. The originality of the Mosel language is that there is no
separation between a modeling statement (e.g. declaring a decision variable or expressing a constraint)
and a procedure that actually solves the problem (e.g. call to an optimizing command). Thanks to thissynergy, one can program a complex solution algorithm by combining modeling and solving statements.
Each category of problem comes with its own particular types of variables and constraints and a single
kind of solver cannot be efficient in all cases. To take this into account, the Mosel system does not
integrate any solver by default but offers a dynamic interface to external solvers provided as modules.
Each solver module comes with its own set of procedures and functions that directly extends the
vocabulary and capabilities of the Mosel language. The link between Mosel and a solving module isachieved at the memory level and does not require any modification of the core system.
This open architecture can also be used as a means to connect Mosel to other software. For instance, amodule could define the functionality required to communicate with a specific database.
The modeling and solving tasks are usually not the only operations performed by a software application.
This is why the Mosel environment is provided either in the form of libraries or as a standalone program.

1.2 General organization
As input, Mosel expects a text file containing the source of the model/program to execute (henceforth weuse just the term ’model’ for ’model/program’ except where there might be an ambiguity). This source fileis first compiled by the Mosel compiler. During this operation, the syntax of the model is checked but nooperation is executed. The result of the compilation is a BInary Model (BIM) that is saved in a second file.
In this form, the model is ready to be executed and the source file is not required any more. To actually’run’ the model, the BIM file must be read in again by Mosel and then executed. These different phases
are handled by different modules that comprise the Mosel environment:
The runtime library: This library contains the VIrtual MAchine (VIMA) interpreter. It knows how to load amodel in its binary format and how to execute it. It also implements a model manager (for handlingseveral models at a time) and a Dynamic Shared Objects manager (for loading and unloading modules
required by a given model). All the features of this library can be accessed from a user application.
The compiler library: The role of this module is to translate a source file into a binary format suitable forbeing executed by the VIMA Interpreter.
The standalone application: The ’mosel’ application, also known as ’Mosel Console’, is a command line
interpreter linked to the two previous modules. It provides a single program to compile and executemodels.
Various modules: These modules complete the Mosel set of functionalities by providing, for instance,

Fair Isaac Corporation Proprietary Information

1

Chapter 1: Introduction

optimization procedures. As an example, the mmxprs module extends the Mosel language with theprocedure maximize that optimizes the current problem using the Xpress Optimizer.
This modularized structure offers various advantages:■

Once compiled, a model can be run several times, for instance with different data sets, without theneed for recompiling it.

■ The compiled form of the program is system and architecture independent: it can be run on any

operating system equipped with the Mosel runtime library and any modules required.

■ The BIM file can be generated in order to contain no symbols at all. It is then safe, in terms ofintellectual property, to distribute a model in its binary form.

■ As a library, Mosel can be easily integrated into a larger application. The model may be provided asa BIM file and the application only linked to the runtime library.

■ The Mosel system does not integrate any kind of solver but is designed in a way that a module canprovide solving facilities. The direct consequence of this is that Mosel can be linked to different
solvers and communicate with them directly through memory.

■ This open architecture of Mosel makes extensions of the functionality possible on a case by casebasis, without the need to modify the Mosel internals.

1.3 Running Mosel
The Mosel environment may be accessed either through its libraries or by means of two applications,perhaps the simplest of which is Xpress Workbench, a development studio type environment for working
with your Mosel models. Xpress Workbench is a complete modeling and optimization development
environment that presents Mosel in an easy-to-use graphical interface with a built-in text editor.
In its standalone version, Mosel offers a simple interface to execute certain generic commands directlyfrom the command prompt (or shell) of the operating system. The user may compile or execute source
models or programs (.mos files), run binary models (.bim files) or retrieve information related to theMosel environment itself (like properties of modules or version number of the system). An interactive
debugger as well as a profiler are also included: the debugger allows to execute the model step by step,
specify breakpoints from where status of the model can be examined. Running a model with the profiler
provides detailed information on what part of the code is actually executed and how much time eachstatement requires. This information may be helpful for optimizing the model (by locating hot spots
where the code is using a great deal of computer time) and also for building testsuites (by checking
whether the data sets used in the test set exercise all statements of a given model).

1.3.1 mosel command: invocation
The mosel executable is typically used with the following syntax from an operating system console:mosel command [-l lang] [-d dir] [-tf trf] [-sdm sdm] [-sr rst][-dp dsopath] [-bx bimpfx] cmd_args

Where the option -l selects the language for message translation (see Section 2.21); the option -d sets
the working directory of the process; the option -tf defines a trace file (see command trace below);
the option -sdm specifies the maximum size of stack dumps (displayed when a model terminates on aruntime error, an assertion fails or triggered by a call to dumpcallstack; this can also be set via theenvironment variable MOSEL_SDMAX, the default value of 0 disables the display of the stack trace); theoption -sr defines the active restrictions (see Section 1.3.4) and -dp specify an initial DSO path (tolocate modules and packages) while -bx sets a list of bim file prefixes (used to find packages, see

Fair Isaac Corporation Proprietary Information

2

Chapter 1: Introduction

Section 2.3.1). Both options -dp and -bx might be stated several times, the resulting setting willcorrespond to the concatenation of the provided values separated by the appropriate symbol. The
command parameter is one of the following commands and cmd_args are the associated arguments thatmust be stated after the options described above (square brackets indicate optional arguments):
comp[ile] [-gGIpwiweninaxSETVFD] [-pwd pwd] [-pk priv] [-k|-kf pub][-ix incpfx] [-o outf] [-c usrcom] src [src2 ...]
Compile the model src and generate the corresponding Binary Model (BIM) file if the compilation
succeeds. The extension .mos is appended to src if no extension is provided. If option ’-ooutf’ (filename to use for saving BIM file) is not given, the extension .bim is used to form thename of the binary file. The flag ’-g’ adds debugging information: private object names (e.g.
variables, constraints) are included in the BIM file as well as required information for locating
runtime errors. The flag ’-G’ adds both debugging and tracing information: it is required to run themodel with the debugger. When the ’-G’ flag is used, the compiler adds instructions in thegenerated code that may slow down execution speed of the model. The flag ’-I’ may also be
added to enable the xbim extension (see Section 2.3.3). The flag ’-D’ enables generation of
documentation annotations in the resulting BIM file (by default documentation annotations are
ignored). The flag ’-na’ disables assertions when the model is compiled with debug information(see assert). With the flag ’-wi’, the compiler emits a warning message each time a symbol is
implicitly declared and the flag ’-ni’ disables implicit declarations (see Section 2.8.1.5). When theflag ’-we’ is used warnings are handled like errors such that any warning will make the compilation
fail. The option ’-c usrcom’ may be used to add a commentary to the BIM file (see debugger
command LSMODS). The option ’-ix’ defines the file name prefix for file inclusion (see Section
2.5.2). If the flag ’-p’ is selected, only the syntax of the source file is checked, the compilation is
not performed and no output file is generated.
The flag ’-x’ will be used to generate a POT file (Portable Object Template) for message
translation (see Section 2.21).
The other options are related to handling encrypted or signed BIM files (see Section 1.3.5): option’-S’ will be used to produce a signed file. Unless the option ’-pk’ is specified, the default private
key personal.key (see ssl_dir) is used for the signature. The options ’-V’ and ’-T’ control
how to handle signed packages: by default signature of packages is ignored but, if the first option
is used, the signature is checked and the loading fails if it cannot be verified. With option ’-T’, only
signed packages with a valid signature can be used (i.e. packages without signature are notallowed). Public keys that are required for the verification are searched for in the default publickeys directory pubkeys (see ssl_dir).
BIM file encryption is enabled by the ’-E’ option: the encryption key is either deduced from thepassword stated via option ’-pwd’ (if the flag ’-F’ is active, the value of ’-pwd’ is interpreted as atext file the first line of which is the password) or generated randomly. Optionally, the encryption
key can be stored in the BIM file itself in encrypted form (this is required if it has been randomly
generated): in this case the encryption requires public keys of the recipients of the BIM file (whowill be able to decrypt the file using their own private keys). Public keys can be listed by using the’-k’ or ’-kf’ options: in the first case, one public key is listed at a time (the ’-k’ parameter may be
used several times) and in the second case a file containing a list of keys is specified. Each line ofthis file is interpreted as a key file name (except empty lines or lines starting with ’!’ or ’#’ that are
ignored). Unless they include a path specification, key files are considered to be located in thedefault public keys directory (for instance the key file "somekey" is searched in the public keys
directory but the file "./somekey" comes from the current working directory). An encrypted BIM
file can always be decrypted by its creator thanks to his private key.
Several source files may be passed to the compiler command in a single step (this is notcompatible with option ’-o’): each file gets compiled individually.
run [-TVF] [-pwd pwd] [-pk priv] [-k|-kf pub] [-is in] [-os out] [-es err][-dbg|-prof|-cov|-trac] [-sdir dir] [-nl] bim [param=value [...]]
Load the provided BIM file bim and then run it. Options ’-is in’, ’-os out’ and ’-es err’ canbe specified to define alternative default input, ouput and error streams to be used by Mosel. With
option ’-prof’ or ’-cov’ the model is run through the profiler (see commands profile andFair Isaac Corporation Proprietary Information

3

Chapter 1: Introduction

coverage below), the option ’-trac’ activates the tracing mode (see command trace) and with
option ’-dbg’ it is passed to the interactive debugger (see command debug). The option ’-sdir’
can be used in addition to the profiler or debugger to indicate alternative locations for source files(this option may be stated several times).
The options ’-V’ and ’-T’ control how to handle signed BIM files (see Section 1.3.5): by default
signature of files is ignored but, if the first option is used, the signature is checked and the loading
fails if it cannot be verified. With the second option, only signed BIM files with a valid signature
can be used (i.e. files without signature are not allowed). For this verification task public keys areusually searched for in the default public keys directory pubkeys (see ssl_dir) but alternatively
a list of expected keys may be specified with the ’-k’ or ’-kf’ options: in the first case, one public
key is listed at a time (the ’-k’ parameter may be used several times) and in the second case a listof keys is read from the given file. Each line of this file is interpreted as a key file name (except
empty lines or lines starting with ’!’ or ’#’ that are ignored). Unless they include a path
specification, key files are considered to be located in the default public keys directory (forinstance the key file "somekey" is searched in the public keys directory but the file"./somekey" comes from the current working directory). Moreover, the special file name ⁎implies that keys stored in the default location can also be used.
The options ’-pwd’ and ’-pk’ may be required to load an encrypted BIM file: the former defines the
password to use (if the flag ’-F’ is active, the value of ’-pwd’ is interpreted as a text file the firstline of which is the password) and the option ’-pk’ servers to specify a private key file (to be usedin place of the default personal.key in ssl_dir).
Optionally, a list of parameter values may be provided in order to initialize the run-time parametersof the model and/or the control parameters of the modules used. The syntax of such an
initialization is param_name = value for a model parameter and dsoname.ctrpar_name =value for a control parameter, where dsoname is the name of a module and ctrpar_name thecontrol parameter to set.
The option ’-nl’ can be used when running the debugger on Unix/Linux systems to deactivate thecommand history if the terminal is not properly handled by the command history mechanism.
exec[ute] [compile_opts] [run_opts] src [param=value [...]]
Compile src, load, and then run the model. This command is equivalent to the consecutive
execution of compile and run except that no BIM file is generated. All options documented for
both, compile and run, can be used with this command. The use of option ’-prof’, ’-cov’ or’-trac’ implies the compiler flag ’-G’ and the use of option -dbg will also add compiler flag ’-G’ ifflag ’-g’ is not explicitly specified.
debug [compile_opts] [run_opts] src [param=value [...]]
This command is equivalent to ’execute -dbg’, the model is compiled and then run through theinteractive debugger. If the model is compiled with flag ’-G’ (the default with this command), theexecution is immediately suspended before the first statement. Otherwise the execution starts as
usual but can be suspended by pressing ctrl-C. Note that if a critical operation is being processed,
the interruption is delayed until the operation completes (for instance, the Optimizer cannot beinterrupted during an iteration of its algorithm). Execution is suspended once more just before theprogram terminates: this makes it possible to inspect model data before the end of execution.
Refer to the Section 1.3.2 below for further information on the use of the debugger.
prof[ile] [compile_opts] [run_opts] src [param=value [...]]
This command is equivalent to ’execute -prof’, the model is compiled and then run throughthe profiler. After execution, the total execution time and some source coverage information isdisplayed. Moreover a file sourcefile.prof is generated based on the original source file. Eachline of this file consists in:■■

the number of times the corresponding statement has been executed;
the total amount of time (in seconds) or the percentage of the total execution time (if option’-prof 2’ is used) spent on this particular line (this measure is not valid if the statement is arecursive call);Fair Isaac Corporation Proprietary Information

4

Chapter 1: Introduction■

the elapsed time (in seconds) between the beginning of the execution and the last time theline was executed;■

the text of the model source

All lines of the original source file are transferred, lines that do not correspond to the beginning ofa statement are directly copied without further information.
If the model runs additional submodels via mmjobs, a report for each model execution is also
displayed and the associated annotated files are generated in a similar way as for the main model.
cover[age] [compile_opts] [run_opts] src [param=value [...]]
This command is equivalent to ’execute -cov’, the model is compiled and then run through theprofiler. The difference with the profile command described above is the type of reports generated:the files produced are taking the .cov extension and only collect the number of times eachstatement has been executed (if option ’-cov 2’ is used it is 0 or 1). Moreover existing files are
updated instead of being replaced (i.e. iteration counts of each statement are added up).
trace [compile_opts] [run_opts] src [param=value [...]]
This command is equivalent to ’execute -trac’, the model is compiled and then run in tracing
mode: the activity of the program is logged in a trace file that is automatically generated or
extended (if the file already existed). The file name for this report is either defined using the ’-tf’
option or taken from the environment variable MOSEL_TRFILE. In both cases a question mark in
the file name will be replaced by the process ID expressed in hexadecimal. If no trace file is defined
the default name ’tmpdir/xprm_?.trac’ will be used (’tmpdir’ being the temporary
directory of the system). Refer to the Section 1.3.3 below for further information on the trace file.
exam[ine] [-pwd pwd] [-pk priv] [-cspthHirvaumLVF] [mod|pkg [mod|pkg...]]
Display the list of constants, procedures/functions, types, IO drivers, control parameters andannotations of modules, packages or the Mosel core library. By default required packages are notloaded (but modules are loaded): using option ’-L’ will force loading of all dependencies. To load
only the header of the bim file to check its dependencies use option ’-H’. Optional flags may be
used to select which type of information is displayed: ’-h’ for general information, ’-c’ forconstants, ’-s’ for subroutines, ’-v’ for variables, ’-r’ for requirements, ’-t’ for types, ’-i’ for IO
drivers, ’-p’ for control parameters and ’-a’ for annotations. By default, listings are sorted inalphabetical order, option ’-u’ disables sorting. If both, a package and a module of the same name,are available only the information relating to the package is displayed. To select either the
package or the module, extension .bim or .dso can be appended to the library name. If the flag’-m’ is used and no package or module can be located then a binary model file is searched for in
the current working directory. The displayed information is related to the Mosel core library if noname is specified with the command.
The option ’-V’ can be added for checking the signature of signed BIM files (the result of theverification is reported in the header output). The options ’-pwd’ and ’-pk’ may be required to load
an encrypted BIM file: the former defines the password to use (if the flag ’-F’ is active, the value of’-pwd’ is interpreted as a text file the first line of which is the password) and the second option
specifies a private key file (to be used in place of the default personal.key in ssl_dir).
lslib [-p|-m]
Display a list of available modules and packages. Use the optional flag ’-p’ to list only packages
and ’-m’ to get modules only.
If none of the above keywords is recognized, the first argument of the command is interpreted as a Mosel
file. In the case of a BIM file, the command ’run’ is executed; otherwise the file name is passed to thecommand ’execute’.
The mosel command may also be started using only flags. Besides options ’-V’ (Mosel version
information) and ’-h’ (short help message), all other options relate to starting Mosel in server mode when
it is invoked from a remote instance: they should not be used directly (see the documentation of module
mmjobs in Chapter 8 for further explanations).

Fair Isaac Corporation Proprietary Information

5

Chapter 1: Introduction

After the completion of a command the mosel executable returns a non-zero status to the operating
system in case of error and the execution status of the model if a model has been run (e.g. with thecommand execute). This execution status is the value provided via the procedure exit in the model(by default this is 0).
Some examples:
Execute model ’mymodel.mos’ setting values for the model parameters A,B,C and D> mosel mymodel A=33 B="word" C=true D=5.3e-5

Compile model ’m.mos’ located on a web service and store the bim file locally in compressed form
> mosel comp -o zlib.gzip:m.bim.gz mmhttp.url:http://websrv/m.mos

Run ’optmod.bim’ from the debugger enabling verbose mode of module ’mmxprs’> mosel run -dbg optmod mmxprs.XPRS_verbose=true

List all available modules and packages> mosel lslib

Display the list of subroutines defined by ’mmxprs’> mosel exam -s mmxprs

Display all constants defined in the Mosel language> mosel exam -c

Display version information of Mosel> model -V

1.3.2 mosel command: interactive debugger
When a model that is executed through the debugger is interrupted (for instance, because the user has
typed ctrl-C or an error has occured), the execution is suspended, the text source of the statement being
processed is displayed and an interactive session starts. This mode is signaled by the specific prompt’dbg>’ and the following commands may be entered (the arguments enclosed in square brackets [] areoptional). The command line interpreter is case-insensitive, although we display commands in upper
case for clarity:
BCONDITION bk [cond]
Define or remove a condition on a breakpoint. This command may be used to put a condition(Boolean expression) on the specified break point: the execution is suspended at the breakpoint
only if the given condition is verified. To remove a condition previously set up, enter thiscommand without specifying any condition.
BREAK [procname]|[line [file]]
Install a breakpoint. When a breakpoint has been set up, execution is interrupted whenever thestatement corresponding to the specified location is reached. A procedure or function namemay be used as the location: in this case a breakpoint is installed at the beginning of eachprocedure or function of the provided name. If this command is used without parameters, thebreakpoint is defined at the current location.

Fair Isaac Corporation Proprietary Information

6

Chapter 1: Introduction

BREAKPOINTS
List the defined breakpoints.
BREAKSUB [0|1]
Decide whether to suspend execution whenever a submodel is started.
CONTINUE
Resume execution. If the interruption was not due to an error, execution of the model continues,
otherwise the execution of the model is aborted and Mosel exits.
DELETE [bk]Delete a breakpoint.
DISPLAY [expression]
Record an expression to be displayed at every interruption. Used with no expression, thiscommand gives a list of all recorded expressions.
DOWN [nblev]
Go down in the calling stack. If an argument is provided, it indicates how many levels down to go(default is 1).
EXPORTPROB [-pms] [filename [objective]]
Display or save to the given file (option filename) the matrix corresponding to the active
problem. The matrix output uses the LP format (default) or the MPS format (flag ’-m’). A problem
is available after the execution of a model. The flags may be used to select the direction of the
optimization (’-p’: maximize), the file format (’-m’: MPS format) and whether real object names
should be used (’-s’: scrambled names — this is the default if the object names are notavailable). The objective may also be selected by specifying a constraint name.
FINISH

Continue execution until the end of the current subroutine. The execution continues but will beinterrupted again after the subroutine terminates.

INFO [⁎|symbol [symbol...]]
Without arguments, this command displays information about the program being executed (thismay be useful for problem reporting). Any specified argument is interpreted as a symbol fromthe current model. If the requested symbol exists in the model, this command displays some
information about its type and structure. Several symbols may be given in a single call and if ’⁎’is used in place of a symbol name then the information is displayed for every symbol of themodel.
LIST [[start] nblines]
Display the source file that corresponds to the model being executed. When used with no extra
argument, this command lists 10 lines of the source model starting at the current statement;
used with a single positive parameter nblines, it displays nblines lines instead of the default 10
lines. If the parameter nblines is negative, it is interpreted as a starting point for the listing
relative to the current statement. When 2 parameters are used, the first one is understood as thefirst line to display (a negative value is relative to the current line) and the second one as thenumber of lines to display.
Examples (assuming current line is 5):>list>list 5>list -2
>list -2 5

displays lines 5 to 14
displays lines 5 to 9
displays lines 3 to 14
displays lines 3 to 7

LSATTR [typename]
Display the list of available attributes for all used native types or only those related to thespecified type typename

Fair Isaac Corporation Proprietary Information

7

Chapter 1: Introduction

LSLIBS

Display the list of all loaded dynamic shared objects (DSO) together with, for each module, itsversion number and its number of references (i.e. number of loaded models using it).

LSLOCAL
Display the list of symbols defined locally to the current context.
LSMODS

Display the list of all models currently loaded in core memory. The information displayed foreach model is:■

name: the model name and version number (given by the model and version statementsin the source file);■

number: the model number is automatically assigned when the model is loaded;■

size: the amount of memory used by the model (in bytes);■

system comment: a text string generated by the compiler indicating the source filename
and if the model contains debugging information and/or symbols;■

user comment: the comment defined by the user at compile time (cf. commandcompile);■modules: the name and version number of each module required by the model;■

pkg. req.: if the model is a package, the name and version number of each package
required by a model using this package;■

pkg. imp.: the name and version number of each package included by this model.

The active model is marked by an asterisk (’⁎’) in front of its name.
LSSYMB [-cspou]
Display the list of symbols published by the current model. The optional flags may be used tofilter what kind of symbol to display: ’-c’ for constants, ’-s’ for subroutines, ’-p’ for parametersand ’-o’ for everything else. By default the list is sorted in alphabetical order, option ’-u’ disablessorting.
MODEL [modnum]
With no argument this command lists all models running concurrently. The active model(debugger commands are applied to this model) is identified by a star ("⁎"). If provided, theargument is interpreted as a model number that becomes the active model.
NEXT [line [file]]
Continue execution until the next statement. The execution continues but will be interrupted
again after the current statement has been completed. If a location information is provided (bymeans of a line number and, if necessary, a file name), the next interruption will occur before thespecified statement is executed.
OPTION name [[=] value]
View or change the value of a command line parameter. These parameters are used by thecommand line interpreter to display real values (especially in command PRINT):■■

realfmt: C-style format for printing floating point numbers (default value: "%.10g")
zerotol: zero tolerance to decide whether two values are equal (default value: 1e-13). It
is also used when printing very small numbers: if a value is smaller than zerotol, "0" isdisplayed instead.

Although these parameters have the same name and function as those used by Mosel whenrunning a model, they are not synchronised with their internal counterpart.

Fair Isaac Corporation Proprietary Information

8

Chapter 1: Introduction

PRINT expression [>>filename]Evaluate then display the value of the given arithmetic or Boolean expression. For building theexpression, the following functions can be used: getparam, ceil, floor, round, abs,
getsize, getmodprop as well as all attributes (see LSATTR command above). In addition tothese Mosel functions, the interpreter implements getnbdim that returns the number ofdimensions of an array and getndx# that gets the index set of dimension number ’#’ of anarray (’#’ being an integer between 1 and the number of dimensions of the array). get-functions
may be called using the suffix notation (e.g. getact(c) is equivalent to c.act). For unions,the notation symbol.type is supported (e.g. "myun.integer"), it is also possible to use
suffixes array, set and list to access union values. Some functions can be applied to arrays:
the result is the evaluation of the function for each cell of the array. Symbols are expected to be
fully qualified: even if a symbol is expressed without namespace reference in the model source(thanks to the namespace search, see Section 2.13) it is necessary to use its full name from thedebugger. In particular private symbols of packages must be prefixed by the package name (forinstance the identifier aa declared in the package mypkg can be accessed using mypkg~aa). It
is possible to report only a part of a collection (array, set or list) by specifying range information.
Ranges definitions take one of these two forms:■[ maxelt ]: get at most ’maxelt’ elements■[ skip maxelt ]: get at most ’maxelt’ entries after skipping ’skip’ elements

Several range definitions may be specified (separated by blanks): they are used when exploring
complex structures (e.g. a list of list).
The display format of this command is compatible with the data file format of Mosel. Use theoperator >>filename to append output of the command to the file filename.
Examples:>print getsol(x) >> solfile.txt>print getact(C(1,"tut"))+c.size>print toto~a>print abs(mytol)>1>print myarray.ndx2 [3]

QUIT
STEP

Terminate the debug session. Model execution is aborted and Mosel exits.
Continue execution until the next statement stepping into procedures and functions. The
execution continues but will be interrupted again after the current statement has been
completed. If the current statement contains function or procedure calls, interruption will
happen in these procedures or functions.

UNDISPLAY [disp]
Remove an expression recorded with DISPLAY. If no parameter is provided, all recorded
expressions are removed, otherwise the parameter is understood as a record number.
UP [nblev]
Go up in the calling stack. If an argument is provided, it indicates how many levels up to go(default is 1). Note that expressions are evaluated according to the current stack frame. For
example, if variable i is defined in procedure B and execution is suspended in procedure A called
by B; it is necessary to go up in the stack in order to view the value of i because it does not exist
in the current frame.
WHERE [nblev]
Display the calling stack. The calling stack corresponds to the sequence of procedure andfunction calls being processed. For instance assume the model calls procedure A which calls
procedure B and the execution is suspended in procedure B: the calling stack will contain 3
records (location where A is called, location where B is called and current statement).

Fair Isaac Corporation Proprietary Information

9

Chapter 1: Introduction

If a command is not recognized, a list of possible keywords is displayed together with a short explanation.
The command names can be shortened as long as there is no ambiguity (e.g. un can be used in place of
UNDISPLAY but u is not sufficient because it could equally denote the UP command). String arguments(the parameter 10 is a number, but "10" or ’10’ are text strings) may be quoted with either single or
double quotes. Quoting is required if the text string starts with a digit or contains spaces and/or quotes.
Execution step by step and breakpoints can be used only if the model has been compiled using option -G.
In this case, before the execution starts, a breakpoint is automatically put at the first statement of themodel. Otherwise (model has been compiled with option -g), the model will be interrupted only if an error
occurs or keys ctrl-C are pressed.
When debugging a model that runs submodels via mmjobs a message is displayed each time asubmodel starts or terminates. Moreover, interrupting the execution of the model also suspends theexecution of all submodels: the entered commands are applied to the selected active model, the choiceof which can be changed with the command MODEL.
A program may interrupt its execution and trigger the interactive debugger by using the following special
annotation (See section 2.14):!@mc.dbgmsg break

When the program is compiled with tracing information (option -G) this annotation is replaced by aspecial instruction that will cause an interruption when the program is being run through the debugger(otherwise it is silently ignored).

1.3.3 mosel command: tracing mode
Running a program in tracing mode results in the generation of a trace file that collects the activity of the
program. Each record of this file consists in a single line of text that can take the following forms:
0O timestamp
The file has been open
0C timestamp
The file has been closed
mmS timestamp modelname
The model number mm with name modelname is starting. Line tracing is enabled
mmTrr timestamp modelname
The model number mm with name modelname is finishing, its status code is rr
mm- timestamp msg
The model number mm has disabled line tracing (with optional message msg), submodels are
not affected
mm+ timestamp msg
The model number mm has enabled line tracing (with optional message msg), submodels are
not affected
mm! timestamp msg
The model number mm logs message msg
mmLpp timestamp
The model number mm is loaded by model number pp
mmUpp timestamp
The model number mm is unloaded by model number pp

Fair Isaac Corporation Proprietary Information

10

Chapter 1: Introduction

mm:nn fname
The model number mm is executing the statement at line nn of file fname (that becomes thecurrent file for this model). These records are not emitted when line tracing is disabled.
mm nn

The model number mm is executing the statement at line nn of current file as specified
previously for the given model These records are not emitted when line tracing is disabled.

A program may control the behaviour of the tracer using the special annotation mc.dbgmsg (See section2.14). The following annotations are interpreted:!@mc.dbgmsg traceoff msg!@mc.dbgmsg traceon msg!@mc.dbgmsg tracelog msg

When the program is compiled with tracing information (option -G) this annotation is replaced by aspecial instruction that communicates with the tracer (it is silently ignored if the program is not run intracing mode). The first syntax disables the line tracing (it is active by default), the second has the
opposite effect while the last syntax makes it possible to insert a message in the trace file. In all cases
the message text msg is optional.

1.3.4 mosel command: restricted mode
Mosel may be run in restricted mode: by selecting which restrictions are to be applied, it is possible tocontrol what operations models can perform (in particular regarding disk access). Upon startup, if theoption -sr is not stated, the command line interpreter uses the value of the environment variable
MOSEL_RESTR for setting the execution restrictions. These restrictions are bit-encoded as an integer(each bit corresponding to a specific restriction) but restrictions can also be expressed by a list of one ormore of the following keywords (symbols are not case-sensitive and can be optionally separated by
spaces):
NoWrite (bit 0, value 1)
Disable write access on the local system. This restriction concerns all file access except
databases. Access to the temporary directory is not affected.
NoRead (bit 1, value 2)
Disable read access on the local system (this also implies NoWrite). This restriction concerns
all file access except databases. When this option is selected, the current working directory is
automatically set to the temporary directory (which can still be accessed).
NoExec (bit 2, value 4)
Disable external command execution. This restriction deactivates some procedures/functions
allowing execution of commands external to Mosel (for instance system or command). Also,
Mosel can only load modules from read-only locations when this restriction is active.
WDOnly (bit 3, value 8)
File access is limited to the current working directory and its subdirectories as well as the paths
specified by the environment variables MOSEL_RWPATH (for reading and writing) and
MOSEL_ROPATH (for reading only). The temporary directory can still be accessed.
NoTmp (bit 4, value 16)
Access to the temporary directory is disabled.
NoDB (bit 5, value 32)
Disable access to databases by blocking connection routines (e.g. SQLconnect or OCIlogon).

Fair Isaac Corporation Proprietary Information

11

Chapter 1: Introduction

For example, to disable write access and execution of external commands the environment variable
MOSEL_RESTR will have to be either the integer value 5 (1+4) or the string "NoWrite NoExec".
Restricted mode is observed by the Mosel core libraries (when accessing files and managing directories)
and the system requires that modules also satisfy the stated restrictions (although implementation of
restrictions may vary depending on the type of functionality provided by a given module): a module that
does not support the restricted mode of execution will fail to load when Mosel is running in this mode.

1.3.5 mosel command: securing bim files
The bim file format is secure with respect to the intellectual property of the author of the model (i.e. it is
not possible to recover the original model from the bim file). However, further security mechanisms may
be required when a bim file is to be transferred over an insecure media (like the internet): in particular it
might be necessary to (1) make sure the file has not been modified during the transfer and (2) guaranteethat only the addressee can access the file.
A digital signature ensures the first requirement: it is computed using a private key (exclusively owned by
the sender of the document) such that any addressee having the corresponding public key (provided by
the sender) can, at the same time, verify that the document has been prepared by the sender and that it
has not been altered during the transfer. From the Mosel command line tool, creating a signed bim filecan be done by using the ’-S’ compiler option. When loading a signed bim file with the run command, it
is required to enable the signature verification with options ’-V’ or ’-T’ as verification is not performed bydefault.
The second requirement can be satisfied by encrypting the bim file such that it appears as random data
during the transfer. Mosel supports two kinds of encryption processes: it can use a usual password
based key. In this case the same password is used for both encrypting and decrypting the bim file (thesender and the recipient have to share this key). The alternative is to rely on private/public key pairs likefor the signature procedure outlined above: encryption is achieved with the public key of the adressee.
Only the recipient will be able to decrypt the bim file using his private key. From the Mosel command line
tool, creating an encrypted bim file can be done by using the ’-E’ compiler option. A password isspecified with the ’-pwd’ option otherwise the public keys of the recipients have to be stated with the ’-k’or ’-kf’ options (a bim file can be encrypted for up to 128 public keys).
Both signature and encryption require the management of private and public keys. These keys are
expected to be stored in a predefined location specified by the module parameter ssl_dir.
Mosel relies on the RSA cryptographic system for the management of private/public key pairs (keys must
be of at least 1024bits). The signature procedure uses the SHA256 message digest algorithm. Bim files
are encrypted using the AES block cipher with keys of 128 bits.

1.4 References
Mosel could be described as an original combination of a couple of well known technologies. Here is a
non-exhaustive list of the most important ’originators’ of Mosel:■ The overall architecture of the system (compiler, virtual machine, native interface) is directly

inspired by the Java language. Similar implementations are also commonly used in the languages
for artificial intelligence (e.g. Prolog, Lisp).

■ The syntax and the major building blocks of the Mosel language are in some aspects a

simplification and for other aspects extensions of the Pascal language.

■ The aggregate operators (like ’sum’) are inherited from the ’tradition of model builders’ and can befound in most of today’s modeling languages.

■ The dynamic arrays and their particular link with sets are probably unique to Mosel but are at their

origin a generalization of the sparse tables of the mp-model model builder.

Fair Isaac Corporation Proprietary Information

12

Chapter 1: Introduction

1.5 Structure of this manual
The main body of this manual is essentially organized into two parts. In Chapter 2, the basic building
blocks of Mosel’s modeling and programming language are discussed.
Chapter 3 begins the reference section of this manual, providing a full description of all the functions andprocedures defined as part of the core Mosel language. The functionality of the Mosel language may be
expanded by loading modules: the following chapters describe the modules currently provided with thestandard Mosel distribution.

Fair Isaac Corporation Proprietary Information

13

I. Core System

CHAPTER 2

The Mosel Language
The Mosel language can be thought of as both a modeling language and a programming language. Likeother modeling languages it offers the required facilities to declare and manipulate problems, decisionvariables, constraints and various data types and structures like sets and arrays. On the other hand, italso provides a complete set of functionalities proper to programming languages: it is compiled andoptimized, all usual control flow constructs are supported (selection, loops) and can be extended bymeans of modules. Among these extensions, optimizers can be loaded just like any other type ofmodules and the functionality they offer may be used in the same way as any Mosel procedures orfunctions. These properties make of Mosel a powerful modeling, programming and solving language withwhich it is possible to write complex solution algorithms.
The syntax has been designed to be easy to learn and maintain. As a consequence, the set of reserved
words and syntax constructs has deliberately been kept small avoiding shortcuts and ‘tricks’ often
provided by modeling languages. These facilities are sometimes useful to reduce the size of a model
source (not its readability) but also are likely to introduce inconsistencies and ambiguities in the language
itself, making it harder to understand and maintain.

2.1 Introduction
2.1.1 Comments
A comment is a part of the source file that is ignored by the compiler. It is usually used to explain what
the program is supposed to do. Either single line comments or multi lines comments can be used in asource file. For the first case, the comment starts with the ’!’ character and terminates with the end of
the line. A multi-line commentary must be inclosed in ’(!’ and ’!)’. Note that it is possible to nest several
multi-line commentaries.
! In a comment
This text will be analyzed(! Start of a multi line(! Another comment
blablaend of the second level comment !)end of the first level !) Analysis continues here

Comments may appear anywhere in the source file.

2.1.2 Identifiers
Identifiers are used to name objects (variables, for instance). An identifier is an alphanumeric (plus ’_’)
character string starting with an alphabetic character or ’_’. All characters of an identifier are significant
and the case is important (the identifier ’word’ is not equivalent to ’Word’).

Fair Isaac Corporation Proprietary Information

15

Chapter 2: The Mosel Language

2.1.3 Reserved words
The reserved words are identifiers with a particular meaning that determine a specific behaviour within
the language. Because of their special role, these keywords cannot be used to name user defined objects(i.e. they cannot be redefined). The list of reserved words is:and, 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, 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.
Note that, although the lexical analyzer of Mosel is case-sensitive, the reserved words are defined both aslower and upper case (i.e. AND and and are keywords but not And).

2.1.4 Separation of instructions, line breaking
In order to improve the readability of the source code, each statement may be split across several lines
and indented using as many spaces or tabulations as required. However, as the line breaking is theexpression terminator, if an expression is to be split, it must be cut after a symbol that implies acontinuation like an operator (’+’, ’-’, ...) or a comma (’,’) in order to warn the analyzer that the expression
continues in the following line(s).
A+B-C+D
A+BC+D! Expression 1! Expression 2! Expression 3...
! ...end of expression 3

Moreover, the character ’;’ can be used as an expression terminator.
A+B ; -C+D

! 2 expressions on the same line

Some users prefer to explicitly mark the end of each expression with a particular symbol. This is possibleusing the option explterm (see Section 2.3) which disables the default behaviour of the compiler. In
that case, the line breaking is not considered any more as an expression separator and each statement
finishing with an expression must be terminated by the symbol ’;’.
A+B;
-C+D;
A+B
-C+D;

! Expression 1! Expression 2! Expression 3...
! ...end of expression 3

2.1.5 Conventions in this document
In the following sections, the language syntax is explained. In all code templates, the following
conventions are employed:■

word: ’word’ is a keyword and should be typed as is;■

todo: ’todo’ is to be replaced by something else that is explained later;■[ something ]: ’something’ is optional and the entire block of instructions may be omitted;■[ something ...]: ’something’ is optional but if used, it can be repeated several times.

Fair Isaac Corporation Proprietary Information

16

Chapter 2: The Mosel Language

2.2 Structure of the source file
The Mosel compiler may compile both models and packages source files. Once compiled, a model isready for execution but a package is intended to be used by a model or another package (see Section 2.3).
The general structure of a model source file is as follows:model model_name[ Directives ][ Parameters ][ Body ]end-model

The model statement marks the beginning the program and the statement end-model its end. Any text
following this instruction is ignored (this can be used for adding plain text comments after the end of the
program). The model name may be any quoted string or identifier, this name will be used as the model
name in the Mosel model manager. An optional set of directives and a parameters block may follow. The
actual program/model is described in the body of the source file which consists of a succession ofdeclaration blocks, subroutine definitions and statements.
The structure of a package (see Section 2.12) source file is similar to the one of a model:
package package_name[ Directives ][ Parameters ][ Body ]end-package

The package statement marks the beginning the library and the statement end-package its end. The
package name must be a valid identifier.
It is important to understand that the language is procedural and not declarative: the declarations andstatements are compiled and executed in the order of their appearance. As a consequence, it is notpossible to refer to an identifier that is declared later in the source file or consider that a statement
located later in the source file has already been executed. Moreover, the language is compiled and notinterpreted: the entire source file is first translated — as a whole — into a binary form (the BIM file), thenthis binary form of the program is read again to be executed. During the compilation, except for some
simple constant expressions, no action is actually performed. This is why only some errors can bedetected during the compilation time, any others being detected when running the program.

2.3 The compiler directives
The compiler accepts four different types of directives: the uses statement, the imports statement, theoptions statement and the version statement. Namespace declarations are also expressed bymeans of directives, see Section 2.13 for further explanations.

2.3.1 Directive uses
The general form of a uses statement is:uses libname1 [, libname2 ...][;]

This clause asks the compiler to load the listed modules or packages and import the symbols they define.
Both modules and packages must still be available for running the model. If the source file being

Fair Isaac Corporation Proprietary Information

17

Chapter 2: The Mosel Language

processed is a package, the bim files associated to the listed packages must be available for compilinganother file using this package. It is also possible to merge bim files of several packages by using
imports instead of uses when building packages.
By default the compiler tries first to find a package (the corresponding file is libname.bim) then, if thisfails, it searches for a module (which file name is libname.dso). It is possible to indicate the type of library
to look for by appending either ".bim" or ".dso" to the name (then the compiler does not try thealternative in case of failure). A package may also be specified by an extended file name (see Section2.15) including the IO driver in order to disable the automatic search (i.e. "a.bim" searches the file a.bim
in the library path but ":a.bim" takes the file a.bim from the current directory).
For example,
uses 'mmsystem','mmxprs.dso','mypkg.bim'
uses ':/tmp/otherpkg.bim'

Both packages and modules are searched in a list of possible locations. Upon startup, Mosel uses as thedefault for this list the value of the environment variable MOSEL_DSO completed by a path deduced fromthe location (rtdir) of the Mosel runtime library (in the following # can be "32" on a 32bit system, "64" on a
64bit system or an empty string):"rtdir\..\dso#" Under Windows if rtdir terminates by "\bin#" and "rtdir\..\dso#" exists or"rtdir/../dso#"
or"rtdir/dso#"

On Posix systems if rtdir terminates by "/lib#" and "rtdir/../dso#" exists

if this directory exists or"rtdir" if none of the above rules apply
The variable MOSEL_DSO is expected to be a list of paths conforming to the operating system
conventions: for a Posix system the path separator is ’:’ (e.g. "/opt/Mosel/dso:/tmp") and it is ’;’under Win32 (e.g. "E:\Mosel\Dso;C:\Temp"). The search path for modules and packages may also
be set from the mosel command (using the -dp option, see Section 1.3) as well as inspected andmodified from the Mosel Libraries (see functions XPRMgetdsopath and XPRMsetdsopath in the
Mosel Libraries Reference Manual). Note however that Mosel will ignore modules not located in read-only
locations when the restriction NoExec is active (see Section 1.3.4).
For locating packages Mosel will use the list of prefixes defined by the compiler option -bx (Section 1.3)or the environment variable MOSEL_BIM before proceeding to the search as decribed above. Thisparameter consists in a list of strings separated by the sequence || that are used as prefixes to the
package name. For instance if the option -bx "bimdir/||tmp:" is used with the directive uses
’mypkg’, the compiler will try to load the package "bimdir/mypkg.bim", then "tmp:mypkg.bim"
before looking for "mypkg.bim" and "mypkg.dso" in the usual locations.

2.3.2 Directive imports
The general form of an imports statement is:imports pkgname1 [, pkgname2 ...][;]

This clause is a special version of the uses directive that can only be used for packages: it asks thecompiler to load the listed packages, import the symbols they define and incorporate the corresponding
bim file. As a consequence, the generated file provides the functionality of the packages it imports. Whenused on a model file it removes the dynamic dependency on the listed packages (i.e. these packages are
no longer required to run the model).
For example,

Fair Isaac Corporation Proprietary Information

18

Chapter 2: The Mosel Language
imports 'mypkg'

2.3.3 Directive options
The compiler options may be used to modify the default behaviour of the compiler. The general form ofan options statement is:
options optname1 [, optname2 ...]The supported options are:■explterm: asks the compiler to expect explicit expression termination (see Section 2.1.4).

■

noimplicit: disables the implicit declarations (see Section 2.8.1.5). This option can also be
activated by using the ’-ni’ compiler flag (see Section 1.3)■

noautofinal: by default initialization from blocks finalize sets they populate (section 2.8.2.2).
This option disables this behaviour that may be activated afterwards using the autofinal control
parameter (cf. setparam).

■

keepassert: assertions (cf. assert) are compiled only in debug mode. With this option
assertions are preserved regardless of the compilation mode.

■

xbim: store additional symbol information in the generated bim file (in particular array index
names). This option can also be enabled by using the ’-I’ compiler flag (see Section 1.3).

■

■

■

fctasproc: by default return values of functions must be used such that a function call is not avalid statement. With this option functions can be used as procedures: when a statement consists
in a function call its return value is silently ignored (see also asproc).
tagpriv: when the model is compiled with debug information private symbols are preserved.
When this option is used these symbols are prefixed with ’~’ such that they can be easily
identified.
dynonly: this option can only be applied to a package: it marks the package as dynamic only suchthat it cannot be imported (see Section 2.3.2).

For example,
options noimplicit,explterm

2.3.4 Directive version
In addition to the model/package name, a file version number may be specified using this directive: aversion number consists in 1, 2 or 3 integers between 0 and 999 separated by the character ’.’.
version major [. minor [. release ]]For example,
version 1.2

The file version is stored in the BIM file and can be displayed from the Mosel console (command list)or retrieved using the Mosel Libraries (see function XPRMgetmodprop in the Mosel Libraries Reference
Manual). From the model itself, the version number is recorded as a string in the control parametermodel_version (see function getparam).

Fair Isaac Corporation Proprietary Information

19

Chapter 2: The Mosel Language

2.4 The parameters block
A model parameter is a symbol, the value of which can be set just before running the model (optionalparameter of the ’run’ command of the command line interpreter). The general form of the parameters
block is:parameters
ident1 = Expression1[ ident2 = Expression2 ...]
end-parameters

where each identifier identi is the name of a parameter and the corresponding expression Expressioni its
default value. This value is assigned to the parameter if no explicit value is provided at the start of theexecution of the program (e.g. as a parameter of the ’run’ command). Note that the type (integer, real, text
string or Boolean) of a parameter is implied by its default value. Model parameters are manipulated as
constants in the rest of the source file (it is not possible to alter their original value).
parameters
size=12R=12.67
F="myfile"
B=trueend-parameters! Integer parameter! Real parameter! Text string parameter! Boolean parameter

In addition to model parameters, Mosel and some modules and packages provide control parameters :they can be used to give information on the system (e.g. success of an I/O operation) or control its
behaviour (e.g. select output format of real numbers). These parameters can be accessed and modified
using the routines getparam and setparam. Refer to the documentation of these functions for acomplete listing of available Mosel parameters. The documentation of the modules include thedescription of the parameters they publish.

2.5 Source file preprocessing
2.5.1 Source file character encoding
The Mosel compiler expects source files to be encoded in UTF-8 and will handle properly UTF-16 and
UTF-32 encodings when the file begins with a BOM (Byte Order Mark). It is also possible to select analternative encoding using the encoding annotation (see section 2.14).
For instance to notify the compiler that the the source file is encoded using ISO-8859-1, the following
comment has to be copied at the beginning of the fie:!@encoding:iso-8859-1

2.5.2 Source file inclusion
A Mosel program may be split into several source files by means of file inclusion. The ’include’
instruction performs this task:
include filename

where filename is the name of the file to be included. This file name may contain environment variablereferences using the notation ${varname} (e.g. ’${MOSEL}/examples/mymodel’) that are expanded
to generate the actual name. The ’include’ instruction is replaced at compile time by the contents ofFair Isaac Corporation Proprietary Information

20

Chapter 2: The Mosel Language

the file filename.
Assuming the file a.mos contains:model "Example for file inclusion"
writeln('From the main file')
include "b.mos"
end-model

And the file b.mos:writeln('From an included file')

Due to the inclusion of b.mos, the file a.mos is equivalent to:model "Example for file inclusion"
writeln('From the main file')
writeln('From an included file')
end-model

If the compiler option -ix is used (Section 1.3) all file names used in the ’include’ instruction will be
prefixed as requested. For instance, if the option -ix "incdir/" is used with the compiler, thestatement include "myfile.mos" will be replaced by the content of "incdir/myfile.mos".
Note that file inclusion cannot be used inside of blocks of instructions or before the body of the program(as a consequence, a file included cannot contain any of the following statements: uses, options or
parameters).

2.5.3 Line control directives
In some cases it may be useful to process a Mosel source through an external preprocessor before
compilation. For instance this may enable the use of facilities not supported by the Mosel compiler likemacros, unrestricted file inclusion or conditional compilation. In order to generate meaningful error
messages, the Mosel compiler supports line control directives: these directives are inserted by
preprocessors (e.g. cpp or m4) to indicate the original location (file name and line number) of generated
text.
#[line] linenum [filename]To be properly interpreted, a line control directive must be the only statement of the line. Malformed
directives and text following valid directives are silently ignored.

2.6 The declaration block
The role of the declaration block is to give a name, a type, and a structure to the entities that theprocessing part of the program/model will use. The type of a value defines its domain (for instance
integer or real) and its structure, how it is organized, stored (for instance a reference to a single value or
an ordered collection in the form of an array). The declaration block is composed of a list of declaration
statements enclosed between the instructions declarations and end-declarations.
declarations
Declare_stat[ Declare_stat ...]
end-declarations

Several declaration blocks may appear in a single source file but a symbol introduced in a given block

Fair Isaac Corporation Proprietary Information

21

Chapter 2: The Mosel Language

cannot be used before that block. Once a name has been assigned to an entity, it cannot be reused foranything else.

2.6.1 Elementary types
Elementary objects are used to build up more complex data structures like sets or arrays. It is, of course,
possible to declare an entity as a reference to a value of one of these elementary types. Such a
declaration looks as follows:
ident1 [, ident2 ...]: [shared] type_namewhere type_name is the type of the objects to create. Each of the identifiers identi is then declared as areference to a value of the given type. The type name may be either a basic type (integer, real,
string, boolean), an MP type (mpvar, linctr), an external type or a user defined type (see section
2.6.9). MP types are related to Mathematical Programming and allow declaration of decision variables
and linear constraints. Note that the linear constraint objects can also be used to store linear expressions.
External types are defined by modules (the documentation of each module describes how to use thetype(s) it implements). The qualifier shared identifies variables that will be shared between several
concurrent models (see Section 8.2). Only entities of basic types and external types supporting sharing
can be shared.
declarations
i,j: integer
str: string
x,y,z: mpvar
end-declarations

2.6.1.1 Basic types
The basic types are:
■

■

■
■

integer: an integer value between -2147483648 and 2147483647. Integers may also be
expressed in hexadecimal by using the prefix 0x or 0X (e.g. 0x7b is the same as 123)
real: an approximation of a real value stored as a double precision floating-point number (values
ranging between -1.7e+308 and 1.7e+308). Floating point numbers expressed in hexadecimal
can also be used as real constants. The general form of such a constant is 0xh.hhhp[+/-]ddd
where ’h’ are hexadecimal digits and ’d’ decimal digits (e.g. 0x1.9p+3 is the same as 12.5)
string: some text.
boolean: the result of a Boolean (logical) expression. The value of a Boolean entity is either thesymbol true or the symbol false.

After its declaration, each entity receives an initial value of 0, an empty string, or false depending on its
type.

2.6.1.2 MP types
Two special types are provided for mathematical programming.
■

mpvar: a decision variable■linctr: a linear constraint

Fair Isaac Corporation Proprietary Information

22

Chapter 2: The Mosel Language

2.6.2 Sets
Sets are used to group an unordered collection of elements of a given type. Set elements are unique: if anelement is added several times it is only contained once in the set. Declaring a set consists of defining
the type of elements to be collected.
The general form of a set declaration is:
ident1 [, ident2 ...] : [shared] [dynamic] set of [constant] type_namewhere type_name is one of the elementary types. Each of the identifiers identi is then declared as a set of
the given type. The qualifier shared identifies sets that will be shared between several concurrent
models (see Section 8.2). Only sets of basic types can be shared. If the qualifier dynamic is used thecorresponding set(s) will never be finalized (see Section 2.8.2.2 and procedure finalize).
A set may collect references to constant elements of non-basic types: this kind of set will be created if
the type name is preceded by the constant keyword. Only native types supporting the constant
keyword and user defined types (see Section 2.6.9) referring to records including only basic types (seeSection 2.6.5) or unions compatible only with basic types (see Section 2.6.7) can be used in this context.
As opposed to an ordinary set, a set of constant references behaves as if it was collecting values of thenative type entities instead of their references. For instance adding 2 different variables of some native
type to a normal set will always result in 2 elements added to the set. However a single element will be
added to a set of constant references if these 2 variables have the same content (or the same textual
representation). Moreover, since references are not directly collected, any change to a variable previously
added to a set of constant references has no impact on the content of this set.
A particular set type is also available that should be preferred to the general form wherever possible
because of its better efficiency: the range set is an ordered collection of consecutive integers in a given
interval. The declaration of a range set is achieved by:ident1 [, ident2 ...] : [shared] [dynamic] range [set of integer]

Each of the identifiers identi is then declared as a range set of integers. Every newly created set is empty.
declarations
s1: set of string
r1: range
ds: set of constant dateend-declarations! type 'date' from module 'mmsystem'

2.6.3 Lists
Lists are used to group a collection of elements of a given type. An element can be stored several times
in a list and order of the elements is specified by construction. Declaring a list consists of defining thetype of elements to be collected.
The general form of a list declaration is:
ident1 [, ident2 ...] : [shared] list of type_namewhere type_name is one of the elementary types. Each of the identifiers identi is then declared as a list of
the given type. The qualifier shared identifies lists that will be shared between several concurrent
models (see Section 8.2). Only lists of basic types can be shared.
Every newly created list is empty.
declarations

Fair Isaac Corporation Proprietary Information

23

Chapter 2: The Mosel Language
l1: list of string
l2: list of real
end-declarations

A list element can be accessed using its order number. The first element has number 1 and index values
inferior to 1 point to elements starting from the end of the list. For instance if l is a list, l(2) is thesecond element of this list, l(0) is the last element of the list and l(-1) its predecessor.

2.6.4 Arrays
An array is a collection of labelled objects of a given type. A label is defined by a list of indices taking theirvalues in domains characterized by sets: the indexing sets. An array may be either dense or sparse: every
possible index tuple is associated to a cell in a dense array while sparse arrays are created empty. The
cells are then created explicitly (cf. procedure create) or when they are assigned a value (cf. Section
2.8.1.1) and the array may then grow ‘on demand’. It is also possible to delete some or all cells of a
dynamic array using the procedure delcell. A cell that has not been created can be identified using theexists function and its value is the default initial value of the type of the array. The general form of anarray declaration is:
ident1 [, ident2 ...] : [shared] [dynamic|hashmap] array(list_of_sets) of type_namewhere list_of_sets is a list of set declarations/expressions separated by commas and type_name is one of
the elementary types. Each of the identifiers identi is then declared as an array of the given type andindexed by the given sets. In the list of indexing sets, a set declaration can be anonymous (i.e. rs:setof real can be replaced by set of real if no reference to rs is required) or shortened to the type ofthe set (i.e. set of real can be replaced by real in that context). An anonymous indexing set isattached to the array: it is created at the same time as the array and, if its reference has not been saved
separately, it will be cleared when the array is reset (see reset) and deleted when the array is released.
Note also that different arrays sharing the same declaration including anonymous sets will not use thesame indexing sets. For instance, in the following declaration the arrays a1 and a2 do not have the samefirst indexing set:declarations
a1,a2:array ( range, S:set of string ) of real
end-declarations

The qualifier shared identifies arrays that will be shared between several concurrent models (see Section
8.2). Only arrays of basic types and indiced by shared or constant sets of basic types can be shared.
declarations
e: set of string
t1:array ( e, rs:set of real, range, integer ) of realt2:array ( {"i1","i2"}, 1..3 ) of integer
end-declarations

By default an array is dense (or static). For best performane it is better to index static arrays withconstant sets or initialize and finalize indexing sets as soon as possible (cf. procedure finalize). An
array is sparse (or dynamic) and created empty if either the qualifier dynamic or hashmap is used.
Arrays declared with either of these qualifiers behave the same but their internal representation differ: thedynamic representation requires less memory and is faster for linear enumeration while the hashmap
representation is faster for random access.
Note that once a set is employed as an indexing set, Mosel makes sure that its size is never reduced inorder to guarantee that no entry of any array becomes inaccessible. Such a set is called fixed.

Fair Isaac Corporation Proprietary Information

24

Chapter 2: The Mosel Language

2.6.4.1 Special case of dynamic arrays of a type not supporting assignment
Certain types do not have assignment operators: for instance, writing x:=1 is a syntax error if x is of typempvar. If an array of such a type is defined as dynamic the corresponding cells are not created. In thatcase, it is required to create each of the relevant entries of the array by using the procedure create since
entries cannot be defined by assignment.

2.6.5 Records
A record is a finite collection of objects of any type. Each component of a record is called a field and ischaracterized by its name (an identifier) and its type. The general form of a record declaration is:
ident1 [, ident2 ...] : record
field1 [, field2 ...]: type_name[...]end-record

where fieldi are the identifiers of the fields of the record and type_name one of the elementary types. Eachof the identifiers identi is then declared as a record including the listed fields.
Example:declarations
r1: record
i,j:integer
r:realend-record
end-declarations

Each record declaration is considered unique by the compiler. In the following example, although r1 andr2 have the same definitions, they are not of the same type (but r3 is of course of the type of r2):
declarations
r1: record
i,j:integer
end-record
r2,r3: record
i,j:integer
end-record
end-declarations

2.6.6 Subroutine references
Subroutines are typically used to execute predefined operations, for instance, the function cos computes
a cosine value while the procedure write displays some text on the console. A subroutine reference isan entity that is able to store a reference to a procedure or a function. The general form of a subroutinereference declaration is:
ident1 [, ident2 ...] : procedure [(List_of_params)]
orident1 [, ident2 ...] : function [(List_of_params)]: Type

Where List_of_params and Type are the properties of a compatible subroutine (see section 2.9). After its
creation a subroutine reference does not refer to any actual routine and is considered as undefined (useisdefined to identify this state); it can only be used (see section 2.7 and 2.8.1.8) once it has been

Fair Isaac Corporation Proprietary Information

25

Chapter 2: The Mosel Language

associated to a proper routine via an assignment (see section 2.8.1.3). This association may be cancelledusing reset.
The following example declares myfunc as a reference to a function returning a real and expecting a realas parameter; this symbol could be used to hold any function similar to cos or arctan for instance:
declarations
myfunct: function (real):real
end-declarations

2.6.7 Unions
A union is a container capable of holding an object of one of a predefined set of types. Defining an entityof this kind consists in specifying this set of compatible types or using the predefined union type any
than can handle any type without restriction. The general form of a union declaration is:
ident1 [, ident2 ...] : type1 or type2 [or type3...]
orident1 [, ident2 ...] : any

where typei is one of the compatible types for each of the identfiers identi. Although this enumeration is
not ordered the first type (type1) has a special meaning as it defines the representation to use when theunion is initialized from some textual form (see Section 2.8.2). In the case of the predefined union type
any the textual representation is handled by a string. If one of the compatible types is also a union the
resulting set of compatible types will include all types of this union.
Example:declarations
u: string or integer or boolean
ua: text or any
end-declarations

In the example above the identifier ’u’ can contain either a string or an integer or a boolean (but not
several values of these types at the same time). The identifier ’ua’ can receive a value of any type as if it
was declared as an ’any’ except that the type ’text’ will be used for textual initialisation (instead of ’string’as implied by ’any’).
In its initial state a union is undefined: it gets a value (and a type) either via assignment (see Section
2.8.1.4) or with the help of the create function. The state of a union can be checked with isdefined
and the function reset may be used to clear a union and restore its initial state.

2.6.8 Constants
A constant is an identifier for which the value is known at declaration time and that will never be modified.
The general form of a constant declaration is:
identifier = Expression

where identifier is the name of the constant and Expression its initial and only value. The expression must
be of one of the basic types, a set or a list of one of these types, a native type supporting constantdefinition, or a record type containing only basic types.
Example:declarations
STR='my const string'

Fair Isaac Corporation Proprietary Information

26

Chapter 2: The Mosel Language
I1=12
R=1..10! constant range
S={2.3,5.6,7.01} ! constant set
L=[2,4,6]! constant list
end-declarations

The compiler supports two kinds of constants: a compile time constant is a constant which value can becomputed by the compiler. A run time constant will be known only when the model is run.
Example:parameters
P=0
end-parameters
declarations
I=1/3
J=P⁎2
end-declarations! compile time constant! run time constant

2.6.9 User defined types
2.6.9.1 Naming new types
A new type may be defined by associating an identifier to a type declaration. The general form of a typedefinition is:
identifier = Type_def

where Type_def is a type (elementary, set, list, array or record) to be associated to the symbol identifier.
After such a definition, the new type may be used wherever a type name is required.
Example:declarations
entier=integer
setint=set of entier
arr=array(range) of integer
myany=string or integer
i:entier! <=> i:integers:setint! <=> s:set of integera:arr! <=> a:array(range) of integer
end-declarations

2.6.9.2 Combining types
Thanks to user defined types one can create complex data structures by combining structures offered by
the language. For instance an array of sets may be defined as follows:declarations
typset=set of integer
a1:array(1..10) of typset
end-declarations

In order to simplify the description of complex data structures, the Mosel compiler can generate
automatically the intermediate user types. Using this property, the example above can be written as
follows (both arrays a1 and a2 are of the same type):declarations
a2:array(1..10) of set of integer
end-declarations

Fair Isaac Corporation Proprietary Information

27

Chapter 2: The Mosel Language

2.7 Expressions
Expressions are, together with the keywords, the major building blocks of a language. This section
summarizes the different basic operators and connectors used to build expressions.
Expressions are constructed using constants, operators and identifiers (of objects or functions). If an
identifier appears in an expression its value is the value referenced by this identifier. In the case of a set, alist, an array or a record, it is the whole structure. To access a single cell of an array, it is required to’dereference’ this array. The dereferencing of an array is denoted as follows:array_ident (Exp1 [, Exp2 ...])

where array_ident is the name of the array and Expi an expression of the type of the ith indexing set of thearray. The type of such an expression is the type of the array and its value the value stored in the arraywith the label ’Exp1 [, Exp2 ...]’. In order to access the cell of an array of arrays, additional indexing
sequences may be appended or the list of indices for the second array can be added to the list of indicesof the first array. For instance, the array a:array(1..10) of array(1..10) of integer can bedereferenced with a(1)(2) or a(1,2).
Indexing sets of an array may be accessed using the following syntax:
array_ident.index(i) [.type_name]orarray_ident.index(i).range

Where array_ident is a reference to an array and i an integer indicating which index to consider (e.g. 1 forthe first index set, see getnbdim). The value of this expression is a set which type will be defined only
when the index set number is a compile time constant. The type type_name (or the keyword range)
might be added to the expression in order to enforce a type when it cannot be detected at compile time (aruntime error will be raised if this type does not correspond to the set or if the index number is not valid).
Similarly, to access the field of a record, it is required to ’dereference’ this record. The dereferencing of arecord is denoted as follows:
record_ident.field_ident

where record_ident is the name of the record and field_ident the name of the required field.
Dereferencing arrays of records is achieved by combining the syntax for the two structures. For instancea(1).bAccessing the value of a union is about the same as dereferencing a record except that field names are
replaced by type names:
union_ident.type_namewhere union_ident is the name of the union and type_name the name of one of its compatible types (forinstance u.integer). Trying to access a type that does not correspond to the actual value stored in theunion will cause the execution of the program to terminate on an error: the properties of the union toinspect must be checked prior to its dereferencing (see functions gettypeid, getstruct andgeteltype or Section 2.7.7 regarding the is operator). However, dereferencing a union for an
assignment (see Section 2.8.1.1) will impose the type of the union: if the union is already of the designed
type, its value will be updated, otherwise the current entity held in the union will be released and a new
instance of the requested type will be created.
Unions may also be accessed via the expected structure they hold:

Fair Isaac Corporation Proprietary Information

28

Chapter 2: The Mosel Language

union_ident.struct_name[.type_name]

Where struct_name is either array, set, range or list. With only a structure this expression is untyped
and can be only used in operations where knowing the structure is sufficient (e.g. with the function
getsize or the construct index on an array as described above). Except for range it is necessary toappend a type name to get a fully defined expression (for instance u.set.integer).
Arrays and lists held in a union can be directly dereferenced as follows:
union_ident.array(Exp1 [, Exp2 ...]).type_nameorunion_ident.list(Exp1).type_name

As for the preceding options for derefrencing unions, the structure and type of the entity stored in theunion must match the expression otherwise a runtime error is raised.
Each type is associated with an identification number. This ID, a positive integer, can be retrieved using
the following notation:
type_name.id

where type_name is the name of a type. The elementary types integer, real, string, boolean,mpvar and linctr have a constant ID (respectively 1,2,3,4,5 and 6) that never changes but all othertypes (like native types published by modules or user defined types) are assigned their ID at the beginningof the execution of the model such that it may change between executions (but this value is constantduring a given execution).
A function call is denoted as follows:
function_ident
or
function_ident (Exp1 [, Exp2 ...])

where function_ident is either the name of a function or a function reference and Expi the ith parameterrequired by this function (note that function parameters are evaluated from right to left). The first form isfor a function requiring no parameter.
The special function if is an operator that allows one to make a selection among expressions. Its syntax
is the following:
if (Bool_expr, Exp1, Exp2)

which evaluates to Exp1 if Bool_expr is true or Exp2 otherwise. The type of this expression is the type of
Exp1 and Exp2 which must be of the same type.
Parentheses may be used to modify the predefined evaluation order of the operators (see Table 2.1) or
simply to group subexpressions.
Operators that result in statements are discussed in other sections:■assignment operators: := += -= (see Section 2.8.1.1)■

inline array initialization: :: (see Section 2.8.1.6))

Table 2.2 summarizes the meaning and applicability of operators that are discussed for the different
expression types in the following sections.

Fair Isaac Corporation Proprietary Information

29

Chapter 2: The Mosel Language

Table 2.1: Priority and evaluation order of operators in Mosel (smaller values indicate higher priority)
Priority

Operators

Sense of evaluation

1
2
3
4
5
6
7
8
9

() {} [] . if count function calls type conversions-unary ˆ is
⁎ / div mod prod inter+ -binary sum union max min< <= > >= = <> in not in
not
and
or
array

→
←
→
→
→
→
→
→
→

Table 2.2: Meaning of operators for different expression types
Type

Operators

Description

All expressions
All except linear constraints
UnionsSymbols

()
if
is
->

Arithmetic expressionscountˆ⁎ / prod
div mod+ - sum
max min< <= > >=String expressions+<

Set expressions{}⁎ inter+ union<=>== <>in not inrange set

Constant set definition
Intersection
Union
Difference
SubsetSuperset
Equality and difference of contents
Set element
Constructors; clone operators

List expressions

[]
+ sum
= <>
list

Constant list definition
Concatenation
Difference
Equality and difference of contentsConstructor; clone operator

Boolean expressions

not
and
or

Negation
Logic ’and’
Logic ’or’

Linear constraint expressions⁎+ - sum<= >= =

Multiplication (one operand must be of numerical type)
Addition / subtraction
Relational operators

Automatic arrays

::
= <>
array

Inline array initialization (see Section 2.8.1.6)
Equality and difference of contentsConstructor

Fair Isaac Corporation Proprietary Information

Changing the evaluation order
Inline ’if’
Test properties’reference to’ operator

is not

<=

>

>=

=

=

<>

Counter
Exponential operator
Multiplication and division
Integer division and modulo
Addition and substraction
Maximum and minimum value
Comparators<>

Concatenation
Difference
Comparators (see Section 2.7.7)

30

Chapter 2: The Mosel Language

2.7.1 Type conversions and constructors
The Mosel compiler operates automatic conversions to the type required by a given operator in thefollowing cases:■■■in the dereference list of an array:
integer → real;

in a function or procedure parameter list:
integer → real, linctr;
real → linctr;
mpvar → linctr;
anywhere else:
integer → real, string, linctr;
real → string, linctr;
mpvar → linctr;
boolean → string.

It is possible to force a basic type conversion using the type name as a function (i.e. integer, real,
string, boolean). In the case of string, the result is the textual representation of the converted
expression. Note that the conversion of a real to a string depends on the control parameters realfmt,
zerotol and txtztol (see setparam). In the case of boolean, for numerical values, the result istrue if the value is nonzero and for strings the result is true if the string is the word ‘true’. When
converting a real to an integer the result is the integral part of the number (no rounding is performed).
Note that explicit conversions are not defined for MP types, and structured types (e.g. linctr(x) is a
syntax error).
For generating numerical values from strings it is in general preferrable to use the subroutinesparseint/parsereal that provide error handling functionality in place of the basic conversion
available through integer/real.
! Assuming A=3.6, B=2
integer(A+B)
string(A-B)
real(integer(A+B))! = 5! = "1.6"! = 5.6 (because the compiler simplifies
the expression)

Some native and record types might be used as function names to create new instances of thecorresponding type (see the documentation of each individual type for a list of possible constructors). If
the only argument of such a function call is an entity of the same type the result is a copy of the argument(the type must support assignment). For record types a specific syntax makes it possible to create andinitialize each field of the newly created entity in a single operation:
type_name (.field1:=val1 [, .field2:=val2 ...])

where type_name is the name of a record type and fieldi one of its fields to be initialised with thecorresponding vali value.
A local instance of a given type can be obtained with the following syntax:(type_name)

Where type_name is the name of a non basic type (i.e. any type except integer, real, string andboolean). The result of this expression is a newly created instance of the type local to the current
expression.

Fair Isaac Corporation Proprietary Information

31

Chapter 2: The Mosel Language

The constructor array (see 2.7.9) for creating new arrays ad-hoc is an aggregate operator, via list (see2.7.6), set and range (see 2.7.5) it is possible to perform transformations between set and list
structures.

2.7.1.1 Union constructors and subroutine parameters
Similarly to native types a union type may be used as a function that takes a single parameter. As a resultof such a construct a new instance of the specified union type is returned taking the same value and typeas the given parameter. If this parameter is not of a basic type (like a native object) the newly createdentity will contain a reference to this object. Moreover if the parameter is another union the resulting
entity will receive a reference to the value of this union (instead of a reference to the union) if this value isalso a reference. However it will receive a copy of this value if it is a basic type. Note that in this case thecompiler may not be able to detect a type incompatibility and a runtime error may happen if the value ofthe entity given as parameter is not compatible with the target union.
This wrapping mechanism is also used when a subroutine expects a union but it receives a compatible
type or a different union type: the compiler creates a local union of the required type initialized with theprovided value or reference.

2.7.2 Aggregate operators
Table 2.3: Aggregate operators in Mosel with default values for empty expressions
Operator

Description

Default values

count
prod
inter
sum
union
max
min
and
or
array

Counter
Product
Intersection of sets
Sum (arithmetic); concatenation (list, text)
Union of sets; concatenation of lists
Maximum value
Minimum value
Logic ’and’
Logic ’or’
Array creation

01
empty setarithmetic: 0, list: empty list
empty set or list
real: -MAX_REAL, integer: -MAX_INT-1
real: MAX_REAL, integer: MAX_INT
true
false
dynamic empty array

An operator is said to be aggregate when it is associated to a list of indices for each of which a set or listof values is defined. This operator is then applied to its operands for each possible tuple of values (e.g.
the summation operator sum is an aggregate operator). The general form of an aggregate operator is:Aggregate_ident (Iterator1 [, Iterator2 ...]) Expression
orcount (Iterator1 [, Iterator2 ...])

where the Aggregate_ident is the name of the operator and Expression an expression compatible with thisoperator (see below for the different available operators). The type of the result of such an aggregate
expression is the type of Expression. The count operator does not require an additional expression: itsvalue, an integer, corresponds to the number of times the expression of another aggregate operator usedwith the same iterator list would be evaluated (i.e. it is equivalent to sum(iteratorlist) 1).
An iterator is one of the following constructs:

Fair Isaac Corporation Proprietary Information

32

Chapter 2: The Mosel Language

SetList_expr
orident1 [, ident2 ...] in SetList_expr [| Bool_expr]
orident = Expression [| Bool_expr]
orident as counter

The first form gives the list of the values to be taken without specifying an index name. With the second
form, the indices named identi take successively all values of the set or list defined by SetList_expr. Withthe third form, the index ident is assigned a single value (which must be a scalar). For the second andthird cases, the scope of the created identifier is limited to the scope of the operator (i.e. it exists only forthe following iterators and for the operand of the aggregate operator). Moreover, an optional condition
can be stated by means of Bool_expr which can be used as a filter to select the relevant elements of thedomain of the index. It is important to note that this condition is evaluated as early as possible. As aconsequence, a Boolean expression that does not depend on any of the defined indices in the considerediterator list is evaluated only once, namely before the aggregate operator itself and not for each possible
tuple of indices. The last form of an iterator declares a counter for the operator: the value of thecorresponding symbol is incremented each time the operator’s expression is evaluated. For this case, if
ident has been declared before, it must be integer or real and its value is not reset. Otherwise, as forindices, the scope of the created integer identifier is limited to the scope of the operator and its initialvalue is 0. There can be only one counter for a given aggregate operator.
The Mosel compiler performs loop optimization when function exists is used as the first factors of thecondition in order to enumerate only those tuples of indices that correspond to actual cells in the array
instead of all possible tuples. To be effective, this optimization requires that sets used to declare thearray on which the exist condition applies must be named and the same sets must be used to define theindex domains. Moreover, the maximum speedup is obtained when order of indices is respected and all
indices are defined in the same aggregate operator.
An index is considered to be a constant: it is not possible to change explicitly the value of a named index(using an assignment for instance).

2.7.3 Arithmetic expressions
Numerical constants can be written using the common scientific notation. Arithmetic expressions arenaturally expressed by means of the usual operators (+, -, ⁎, / division, unary -, unary +,ˆraise to thepower). For integer values, the operators mod (remainder of division) and div (integral division) are also
defined. Note that mpvar objects are handled like real values in expression.
The sum (summation) aggregate operators is defined on integers, real and mpvar. The aggregate
operators prod (product), min (minimum) and max (maximum) can be used on integer and real values.
x⁎5.5+(2+z)^4+cos(12.4)
sum(i in 1..10) (min(j in s) t(i)⁎(a(j) mod 2))

2.7.4 String expressions
Constant strings of characters must be quoted with single (’) or double quote (") and may extend over
several lines. Strings enclosed in double quotes may contain C-like escape sequences introduced by the’backslash’ character (\a \b \f \n \r \t \v \xxx \uhhhh with xxx being the character code as anoctal number and hhhh a Unicode code as a four hexadecimal digits number).
Each sequence is replaced by the corresponding control character (e.g. \n is the ‘new line’ command) or,
if no control character exists, by the second character of the sequence itself (e.g. \\ is replaced by ’\’).

Fair Isaac Corporation Proprietary Information

33

Chapter 2: The Mosel Language

The escape sequences are not interpreted if they are contained in strings that are enclosed in single
quotes.
Example:’c:\ddd1\ddd2\ddd3’ is understood as c:\ddd1\ddd2\ddd3"c:\ddd1\ddd2\ddd3" is understood as c:ddd1ddd2ddd3

There are two basic operators for strings: the concatenation, written ’+’ and the difference, written ’-’.
"a1b2c3d5"+"e6"'a1b2c3d5'-"3d5"! = "a1b2c3d5e6"! = "a1b2c"

A constant string may also take 2 additional forms: initialised from the content of an external file or as a
portion of the current input file. For the first case, a text string enclosed in backquotes will be replaced by
the content of the file identified by this enclosed text. For the second case, a line ending by the backquotecharacter optionally followed by some label (consisting in any sequence of characters not including
backquote) will be interpreted as the beginning of a text block. The end of this text block is marked by aline starting with the previously used label (if any) followed by the backquote character.
Example:`afile.txt` ! This string is the content of "afile.txt"`MyMarker
line1
line2
MyMarker` ! This string is equivalent to "line1\nline2\n"2.7.5 Set expressions
Constant sets are described using one of the following constructs:{[ Exp1 [, Exp2 ...]]}
orInteger_exp1 .. Integer_exp2

The first form enumerates all the values contained in the set and the second form, restricted to sets ofintegers, gives an interval of integer values. This form implicitly defines a range set.
The basic operators on sets are the union written +, the difference written - and the intersection written ⁎.
The aggregate operators union and inter can also be used to build up set expressions.
{1,2,3}+{4,5,6}-(5..8)⁎{6,10}! = {1,2,3,4,5}{'a','b','c'}⁎{'b','c','d'}! = {'b','c'}union(i in 1..4|i<>2) {i⁎3}! = {3,9,12}
inter(i in [2,3]) union(j in 1..10) {i⁎j} ! = {6,12,18}

If several range sets are combined in the same expression, the result is either a range or a set of integers
depending on the continuity of the produced domain. If range sets and sets of integers of more than one
element are combined in an expression, the result is a set of integers. It is however possible to convert a
set of integers to a range by using the notation range(setexpr) where setexpr is a set expression
which result is either a set of integers or a range. Similarly stating set(lstexpr) will generate a set
from the elements of the list expression lstexpr.

2.7.6 List expressions
A constant list consist in a list of expressions enclosed in square brackets:

Fair Isaac Corporation Proprietary Information

34

Chapter 2: The Mosel Language[[ Exp1 [, Exp2 ...]]]

There are two basic operators for lists: the concatenation, written ’+’ and the difference, written ’-’. The
aggregate operator sum can also be used to build up list expressions (the operator union behaves likesum when applied to lists).
[1,2,3]+[1,2,3][1,2,3,4]-[3,4]sum(i in 1..3) [i⁎3]! = [1,2,3,1,2,3]! = [1,2]! = [3,6,9]

List expressions are untyped when they include values of different types. When possible the compiler will
convert elements of an untyped list to the required type. For instance list of a mix of integers and reals (ora list of integers) will be converted to a list of reals to perform an assignment to a list of reals. Otherwise
untyped lists are converted to lists of any (see Section 2.6.7).
A list can also be constructed from the elements of a set using the syntax list(setexpr) where
setexpr is a set expression.

2.7.7 Boolean expressions
A Boolean expression is an expression whose result is either true or false. The traditional comparators
are defined on integer and real values: <, <=, =, <> (not equal), >=, >. Comparisons are performed within
the tolerance specified by the control parameter "zerotol" (see setparam) when these operators areapplied to reals. For instance, two real values a and b will be considered equal if abs(a – b) ≤ zerotol.

These comparison operators are also defined for string expressions. In that case, the order is defined by
the ISO-8859-1 character set (i.e. roughly: punctuation <digits <capitals <lower case letters <accented
letters).

With sets, the comparators <= (‘is subset of’), >= (‘is superset of’), = (‘equality of contents’) and <>(‘difference of contents’) are defined. These comparators must be used with two sets of the same type.
Moreover, the operator ‘expr in Set_expr’ is true if the expression expr is contained in the set Set_expr.
The opposite, the operator not in is also defined.
With lists, the comparators = (‘equality of contents’) and <> (‘difference of contents’) are defined. These
comparators must be used with two lists of the same type.
With arrays, the comparators = (‘equality of contents’) and <> (‘difference of contents’) are defined.
These comparators must be used with two arrays of the same type and this type must support therequested operator (for instance arrays of mpvar cannot be compared).
With records, the comparators = (‘equality of contents’) and <> (‘difference of contents’) are defined.
These comparators must be used with two records of the same type and all fields of this record typemust support the requested operator (for instance records including mpvar entries cannot be compared).
With unions, the comparators = (‘equality of contents’) and <> (‘difference of contents’) are defined.
These comparators can be used either between two unions (not necessarily from the same definition) or
between a union and an entity of one of its compatible types. The result of the comparison is true if thetwo operands are of the same type, can be compared and have the same value. Two unions are also
considered equal if they are both uninitialized.
The operator is (as well as its opposite is not) is also defined on unions: its left operand must be aunion and its right operand can be either a type name (like integer or string) or a structure name(array, set, range, list, record, procedure or function) optionally followed by of and a typespecification (for instance u is list of real). The value of the test is true if the type ID of theunion (see gettypeid) corresponds to the specified type or if the union is of the specified structure(see getstruct).
To combine Boolean expressions, the operators and (logical and) and or (logical or) as well as the unary

Fair Isaac Corporation Proprietary Information

35

Chapter 2: The Mosel Language

operator not (logical negation) can be used. The evaluation of an arithmetic expression stops as soon as
its value is known.
The aggregate operators and and or are the natural extension of their binary counterparts.
3<=v1 and v2>=45 or t<>r and not r in {1..10}
and(i in 1..10) 3<=arr(i)2.7.8 Linear constraint expressions
Linear constraints are built up using linear expressions on the decision variables (type mpvar).
The different forms of constraints are:Linear_expr
orLinear_expr1 Ctr_cmp Linear_expr2
orLinear_expr SOS_type
ormpvar_ref mpvar_type1
or
mpvar_ref mpvar_type2 Arith_expr

In the case of the first form, the constraint is unconstrained and is just a linear expression. For the second
form, the valid comparators are <=, >=, = (range constraints may be created using the procedure
setrange). The third form is used to declare special ordered sets. The types are then is_sos1 andis_sos2. The coefficients of the variables in the linear expression are used as weights for the SOS (as aconsequence, a 0-weighted variable cannot be represented this way, procedure makesos1 or makesos2
has to be used instead).
The last two types are used to set up special types for decision variables. The first series does not require
any extra information: is_continuous (default), is_integer, is_binary, is_free. Continuous
and integer variables have the default lower bound 0, binary variables only take the values 0 or 1, and ’free’means that the variable is unbounded (i.e. ranging from - ∞ to + ∞ ). The second series of types is
associated with a threshold value stated by an arithmetic expressions: is_partint for partial integer,
the value indicates the limit up to which the variable must be integer, above which it is continuous. For
is_semcont (semi-continuous) and is_semint (semi-continuous integer) the value gives thesemi-continuous limit of the variable (that is, the lower bound on the part of its domain that is continuous
or consecutive integers respectively). Note that these constraints on single variables are also considered
as common linear constraints.
3⁎y+sum(i in 1..10) x(i)⁎i >= z-t
x is_free! Define an unbounded variable
x <= -2! Upper bound on xt is_integer! Define an integer variable t=0,1,2,...
t >= -7! Change lower bound on t: t=-7,-6,-5,...
sum(i in 1..10) i⁎x(i) is_sos1! SOS1 {x(1),x(2),...} with! weights 1,2,...
y is_semint 5! y=0 or y=5,6,...
y <= 20! Upper bound on y: y=0 or y=5,6,...,20Internally all linear constraints are stored in the same form: a linear expression (including a constantterm) and a constraint type (the right hand side is always 0). This means, the constraint expression
3⁎x>=5⁎y-10 is internally represented by: 3⁎x-5⁎y+10 and the type ‘greater than or equal to’. When areference to a linear constraint appears in an expression, its value is the linear expression it contains. For
example, if the identifier ctl refers to the linear constraint 3⁎x>=5⁎y-10, the expression z-x+ctl isequal to: z-2⁎x-5⁎y+10.

Fair Isaac Corporation Proprietary Information

36

Chapter 2: The Mosel Language

Note that the value of a unary constraint of the type x is_type threshold is x-threshold.

2.7.9 Automatic arrays
The array keyword can be used as an aggregate operator in order to create an array that will exist only
for the duration of the expression.
array (Iterator1 [, Iterator2 ...]) Expression

here, the iterators define the indices of the array and the expression, the associated values.
This automatic array may be used wherever a reference to an array is expected: for instance to save thesolution values of an array of decision variables in an initialization block (see Section 2.8.2).
initializations to "mydata.txt"
evaluation of array(i in 1..10) x(i).sol as "mylabel"
end-initializations

2.7.10 Operator -> (reference to)
The reference to operator creates a reference to its operand.
->NameRef
or->(Expr)

Where NameRef is the name of a subroutine, the name of a global entity of any type, or any dereferencing
of a non-basic type, and Expr an expression of a non-basic type.
When the reference to operator is applied to a subroutine name or to a subroutine reference, it returns asubroutine reference instead of trying to call the routine (see section 2.6.6). This subroutine reference
can be used wherever the corresponding type is expected, in particular for an assignment that initialises
another subroutine reference (see section 2.8.1.3). Note that the compiler does not guarantee whichroutine is returned if the name of a subroutine refers to several implementations (i.e. the routine has been
overloaded, see section 2.9.5) and the context does not make it possible to select a particular version.
In all other cases this operator is essentially used to create aliases (see section 2.8.1.4).

2.8 Statements
Four types of statements are supported by the Mosel language. The simple statements can be seen as
elementary operations. The initialization block is used to load data from a file or save data to a file.
Selection statements allow one to choose between different sets of statements depending on conditions.
Finally, the loop statements are used to repeat operations.
Each of these constructs is considered as a single statement. A list of statements is a succession ofstatements. No particular statement separator is required between statements except if a statement
terminates by an expression. In that case, the expression must be finished by either a line break or thesymbol ’;’.

2.8.1 Simple statements
2.8.1.1 Assignment
An assignment consists in changing the value associated to an identifier. The general form of an

Fair Isaac Corporation Proprietary Information

37

Chapter 2: The Mosel Language

assignment is:
ident_ref := Expression
orident_ref += Expression
orident_ref -= Expression

where ident_ref is a reference to a value (i.e. an identifier or an array/record dereference) and Expression
is an expression of a compatible type with ident_ref. The direct assignment, denoted := replaces thevalue associated with ident_ref by the value of the expression. The additive assignment, denoted +=, andthe subtractive assignment, denoted -=, are basically combinations of a direct assignment with anaddition or a subtraction. They require an expression of a type that supports these operators (forinstance it is not possible to use additive assignment with Boolean objects).
The additive and subtractive assignments have a special meaning with linear constraints in the sensethat they preserve the constraint type of the assigned identifier: normally a constraint used in an
expression has the value of the linear expression it contains, the constraint type is ignored.
c:= 3⁎x+y >= 5c+= yc:= 3⁎x+y >= 5
c:= c + y

! Implies c is 3⁎x+2⁎y-5 >= 0
! Implies c is 3⁎x+2⁎y-5 (c becomes unconstrained)

2.8.1.2 Assignment of structured types
The direct assignment := can also be used with sets, lists, arrays and records under certain conditions.
For sets and lists, reference and value must be of the same type, the system performing no conversion on
structures. For instance it is not possible to assign a set of integers to a set of reals although assigning
an integer value to a real object is valid.
When assigning records, reference and value must be of the same type and this type must be assignment
compatible: two records having identical definitions are not considered to be the same type by thecompiler. In most cases it will be necessary to employ a user type to declare the objects. A record isassignment compatible if all the fields it includes can be assigned a value. For instance a record
including a decision variable (type mpvar) cannot be used in an assignment: copying a value of such atype has to be performed one field at a time skiping those fields that cannot be assigned.
Two arrays can be used in an assignment if they have strictly the same definition and are assignment
compatible (i.e. their type supports assignment).

2.8.1.3 Assignment of subroutine references
Only the direct assignment := can be used with subroutine references, the value assigned to the entity
must have a compatible type and will usually be the result of the -> operator to prevent calling of theoperand. As the result of such a statement both subroutine references refer to the same routine and, if
the source reference is undefined the destination of the assignment will also become undefined.
declarations
myfunc,fct2,fct0:function (real):real
end-declarations
myfunc:=->cos! 'myfunc' refers to 'cos'
fct2:=->myfunc! as well as 'fct2'
writeln(myfunc(0),"=",fct2(0)) ! => 1=1
fct2:=->fct0! fct2 becomes undefined
writeln(isdefined(->fct2))! => false

Fair Isaac Corporation Proprietary Information

38

Chapter 2: The Mosel Language

2.8.1.4 Assignment of unions
Only the direct assignment := can be used with union entities: the value associated with the union is
replaced by a copy of the value of the expression that must have a type compatible with the union(otherwise a compilation error is raised). If the current value of the union is of the same type as theexpression then a direct assignment between the entity stored in the union and the provided expression
is performed. Otherwise, the current value of the union is released and a new instance of the required
type is created before a direct assignment is performed. Note that although no implicit type conversion is
performed, assigning an integer to a union compatible only with reals will succeed (i.e. the integer value
will be automatically converted to real).
If the expression is also a union then the assignment operation is executed on the value stored in thisunion, if its type is not compatible with the destination of the assignment a runtime error will be raised. If
the expression is an undefined union then the destination entity will also become undefined (i.e. thecurrent value of the union is released and the entity returns to its initial state).
If the expression is the result of the -> operator then the union will become an alias to the source
expression instead of receiving a copy of its value.
declarations
S:set of integer
u:any
end-declarationsu:=->S
S:={1,2,3}
writeln(u)u.set.integer+={4}writeln(u)writeln(S)! 'u' and 'S' refer to the same set! => {1,2,3}! => {1,2,3,4}! => {1,2,3,4}

2.8.1.5 About implicit declarations
Each symbol should be declared before being used. However, an implicit declaration is issued when a
new symbol is assigned a value the type of which is unambiguous.
! Assuming A,S,SE are unknown symbols
A:= 1! A is automatically defined!
as an integer reference
S:={1,2,3}! S is automatically defined!
as a set of integers
SE:={}! This produces a parser error as! the type of SE is unknown

In the case of arrays, the implicit declaration should be avoided or used with particular care as Mosel tries
to deduce the indexing sets from the context and decides automatically whether the created array must
be dynamic. The result is not necessarily what is expected.
A(1):=1
A(t):=2.5! Implies: A:array(1..1) of integer! Assuming "t in 1..10|f(t) > 0"
! implies: A:dynamic array(range) of real

The option noimplicit disables implicit declarations (see Section 2.3.3).

2.8.1.6 Inline initialization
Using inline initialization it is possible to assign several cells of an array in a single statement. The generalform of an inline initialization is:

Fair Isaac Corporation Proprietary Information

39

Chapter 2: The Mosel Language

ident_ref ::[ Exp1 [, Exp2 ...] ]orident_ref ::(Ind1 [, Ind2 ...] )[ Exp1 [, Exp2 ...] ]where ident_ref is the object to initialize (array, set or list) and Expi are expressions of a compatible typewith ident_ref. The first form of this statement may be used with lists, sets and arrays indiced by ranges:
the list of expressions is used to initialize the object. In the case of lists and sets this operation is similar
to a direct assignment, with an array, the first index of each dimension is the lower bound of the indexing
range or 1 if the range is empty.
The second form is used to initialize regions of arrays or arrays indiced by general sets: each Indi
expression indicates the index or list of indices for the corresponding dimension. An index list can be aconstant, a list of constants (e.g. [’a’,’b’,’c’]) or a constant range (e.g. 1..10) but all values must
be known at compile time.
declarations
T:array(1..10) of integer
U:array(1..9,{'a','b','c'}) of integer
end-declarations
T::[2,4,6,8]! <=> T(1):=2; T(2):=4;...
T::(2..5)[7,8,9,19]! <=> T(2):=7; T(3):=8;...
U::([1,3,6],'b')[1,2,3]! <=> U(1,'b'):=1; U(3,'b'):=2;...

2.8.1.7 Linear constraint expression
A linear constraint expression can be assigned to an identifier but can also be stated on its own. In thatcase, the constraint is said to be anonymous and is added to the set of already defined constraints. The
difference from a named constraint is that it is not possible to refer to an anonymous constraint again, forinstance to modify it.
10<=x; x<=20
x is_integer

2.8.1.8 Procedure call
Not all required actions are coded in a given source file. The Mosel language comes with a set ofpredefined procedures that perform specific actions (like displaying a message). It is also possible toimport procedures from external locations by using modules or packages (cf. Section 2.3).
The general form of a procedure call is:
procedure_ident
procedure_ident (Exp1 [, Exp2 ...])

where procedure_ident is either the name of a procedure or a procedure reference and, if required, Expi is
the ith parameter for the call (note that parameters of procedures are evaluated from right to left). Refer
to Chapter 3 of this manual for a comprehensive listing of the predefined procedures.The modules
documentation should also be consulted for explanations about the procedures provided by each module.
writeln("hello!")! Displays the message: hello!

2.8.2 Initialization block
The initialization block may be used to initialize objects (scalars, arrays, lists or sets) of basic type fromfiles or to save the values of such objects to files. Scalars and arrays of external/user types supporting
this feature may also be initialized using this facility.

Fair Isaac Corporation Proprietary Information

40

Chapter 2: The Mosel Language

The first form of an initialization block is used to initialize data from a file:initializations from Filename
item1 [ as Label1]
or[itemT11,itemT12 [ ,IdentT13 ...]] asLabelT1[
item2 [ as Label2]
or[itemT21,itemT22 [ ,IdentT23 ...]] asLabelT2...]
end-initializations

where Filename, a string expression, is the name of the file to read, itemi any object identifier and itemTijan array identifier. Each identifier is automatically associated to a label: by default this label is theidentifier itself but a different name may be specified explicitly using a string expression Labeli. If a given
item is of a record type, the operation is permitted only if all fields it contains can be initialized. For
instance, if one of the fields is a decision variable (type mpvar), the compilation will fail. Alternatively, thefields to be initialized can be listed using the following syntax as an item:
Identifier(field1 [ ,filedi ...])

If a given item is a namespace (see Section 2.13) all the identifiers it includes at the time of parsing thestatement are implicitly added to the block with the exception of namespaces and entities that are notcompatible with initializations (like decision variables). The associated labels are the fully qualified
names of the objects (i.e. the identifier prefixed by the namespace) unless a label is specified for thisrecord: in this case it is used as a replacement for the default prefix when generating the per entity labels
such that an empty string will remove entirely the prefix. Using the compiler option -wi makes it possible
to get a list of included identifiers by means of a compiler warning (see Section 1.3).
When an initialization block is executed, the given file is opened and the requested labels are searched forin this file to initialize the corresponding objects. Several arrays may be initialized with a single record. In
this case they must be all indexed by the same sets, have scalar types and the label is obligatory. Afterthe execution of an initializations from block, the control parameter nbread reports the numberof items actually read in. Moreover, if control parameter readcnt is set to true before the execution of
the block, counting is also achieved at the label level: the number of items actually read in for each label
may be obtained using function getreadcnt.
An initialization file must contain one or several records of the following form:
Label: value

where Label is a text string and value either a constant of a basic type (integer, real, string or
boolean) or a collection of values separated by spaces and enclosed in square brackets. Collections ofvalues are used to initialize lists, sets records or arrays — if such a record is requested for a scalar, thenthe first value of the collection is selected. When used for arrays, indices enclosed in round brackets may
be inserted in the list of values to specify a location in the corresponding array.
Note also that:■no particular formatting is required: spaces, tabulations, and line breaks are just normal separators■

the special value ’*’ implies a no-operation (i.e. the corresponding entity is not initialized)■

the special value ’?’ (nil value) implies a reset of the corresponding entity (the reset procedure isapplied to references, 0,false or and empty string is assigned to variables of basic types)

Fair Isaac Corporation Proprietary Information

41

Chapter 2: The Mosel Language■■■

single line comments are supported (i.e. starting with ’!’ and terminated by the end of the line)
Boolean constants are either the identifiers false (FALSE) and true (TRUE) or the numericalconstants 0 and 1
all text strings (including the labels) may be quoted using either single or double quotes. In thelatter case, escape sequences are interpreted (i.e. use of ’\’).

By default Mosel expects that initialization files are encoded in UTF-8 and it can handle UTF-16 and
UTF-32 when a BOM (Byte Order Mark) is used. To process files in another encoding, a special encoding
comment line must be put at the beginning of the file (see section 2.5.1). For instance a data file encodedwith CP1252 should start with the following comment line:!@encoding:CP1252

The second form of an initialization block is used to save data to a file:initializations to Filename
item1 [as Label1]
or[itemT11,itemT12 [ ,IdentT13 ...]]asLabelT1[
item2 [ as Label2]
or[itemT21,itemT22 [ ,IdentT23 ...]]asLabelT2...]
end-initializations

In this form, any itemi can be replaced by the value of an expression using the following construct (Labeli
is mandatory in this case):evaluation of expression

When this second form is executed, the value of all provided labels is updated with the current value ofthe corresponding identifier1 in the given file. If a label cannot be found, a new record is appended to theend of the file and the file is created if it does not yet exist.
For example, assuming the file a.dat contains:! Example of the use of initialization blocks
t:[ (1 un) [10 11] (2 deux) [⁎ 22] (3 trois) [30 33]]
t2:[ 10 (4) 30 40 ]'nb used': ?

consider the following program:model "Example initblk"
declarations
nb_used:integers: set of stringta,tb: dynamic array(1..3,s) of realt2: array(1..5) of integer
end-declarations
initializations from 'a.dat'[ta,tb] as 't'! ta=[(1,'un',10),(3,'trois',30)]! tb=[(1,'un',11),(2,'deux',22),(3,'trois',33)]t2! t2=[10,0,0,30,40]
1 A copy of the original file is saved prior to the update (i.e. the original version of fname can be found in fname˜).

Fair Isaac Corporation Proprietary Information

42

Chapter 2: The Mosel Language
nb_used as "nb used" ! nb_used=0
end-initializations
nb_used+=1ta(2,"quatre"):=1000
initializations to 'a.dat'[ta,tb] as 't'
nb_used as "nb used"s
end-initializations
end-model

After the execution of this model, the data file contains:! Example of the use of initialization blocks
t:[(1 'un') [10 11] (2 'deux') [⁎ 22] (2 'quatre') [1000 ⁎](3 'trois') [30 33]]
t2:[ 10 (4) 30 40 ]'nb used': 1's': ['un' 'deux' 'trois' 'quatre']

In case of error (e.g. file not found, corrupted data format) during the processing of an initialization block,the execution of the model is interrupted. However if the value of control parameter ioctrl is true,
executions continues. It is up to the user to verify whether data has been properly transfered by checking
the value of control parameter iostatus.

2.8.2.1 Handling of unions
When initializing unions the procedure will consider only scalar values of basic types: integers, reals andbooleans are assigned to the union; textual values are used to initialize the entity employing the first typefrom the list of compatible types specified for this union (for the union ’any’ this is a string). An I/O error
will be raised if this type does not support initialization.
When exporting unions, any non-scalar value and type that does not support conversion to string will
result in a NIL value in the generated file.

2.8.2.2 About automatic finalization
During the execution of an initializations from block all sets are automatically finalized just after having
been initialized (unless they have been explicitly declared as dynamic). This also applies to sets indirectly
initialized through the non-dynamic arrays for which they are index sets. In addition, such an array iscreated as a static array if it has not been used before the initialization block.
This behaviour is controled by the autofinal control parameter which value may be changed using the
setparam procedure (i.e. it is therefore possible to have automatic finalization active for only some
initializations blocks). The compiler option noautofinal (see section 2.3.3) allows to disable thisfeature from the beginning of the model (although it can be re-enabled as required using the control
parameter).

2.8.3 Selections
2.8.3.1 If statement
The general form of the if statement is:Fair Isaac Corporation Proprietary Information

43

Chapter 2: The Mosel Language

if Bool_exp_1
then Statement_list_1[
elif Bool_exp_2
then Statement_list_2...][ else Statement_list_E ]end-if

The selection is executed as follows: if Bool_exp_1 is true then Statement_list_1 is executed and theprocess continues after the end-if instruction. Otherwise, if there are elif statements, they are
executed in the same manner as the if instruction itself. If, all boolean expressions evaluated are false
and there is an else instruction, then Statement_list_E are executed; otherwise no statement is executedand the process continues after the end-if keyword.
if c=1then writeln('c=1')
elif c=2
then writeln('c=2')
else writeln('c<>1 and c<>2')
end-if

2.8.3.2 Case statement
The general form of the case statement is:case Expression_0 ofExpression_1: Statement_1
orExpression_1: do Statement_list_1 end-do[
Expression_2: Statement_2
orExpression_2: do Statement_list_2 end-do...][ else Statement_list_E ]end-case

The selection is executed as follows: Expression_0 (that must be of type integer, real, string or boolean) is
evaluated and compared sequentially with each expression of the list Expression_i until a match is found.
Then the statement Statement_i (resp. list of statements Statement_list_i) corresponding to the matchingexpression is executed and the execution continues after the end-case instruction. If no matching isfound and an else statement is present, the list of statements Statement_list_E is executed, otherwise
the execution continues after the end-case instruction. Note that, each of the expression lists
Expression_i can be either a scalar, a set or a list of expressions separated by commas. In the last twocases, the matching succeeds if the expression Expression_0 corresponds to an element of the set or an
entry of the list.
case c of1: writeln('c=1')
2..5 : writeln('c in 2..5')
6,8,10: writeln('c in {6,8,10}')else writeln('c in {7,9} or c >10 or c <1')end-case

Fair Isaac Corporation Proprietary Information

44

Chapter 2: The Mosel Language

2.8.4 Loops
2.8.4.1 Forall loop
The general form of the forall statement is:forall (Iterator_list) Statement
or
forall (Iterator_list) do Statement_list end-do

The statement Statement (resp. list of statements Statement_list) is repeated for each possible index
tuple generated by the iterator list (cf. Section 2.7.2).
forall (i in 1..10, j in 1..10 | i<>j) dowrite(' (' , i, ',' , j, ')')
if isodd(i⁎j) then s+={i⁎j}end-ifend-do2.8.4.2 While loop
The general form of the while statement is:while (Bool_expr) Statement
or
while (Bool_expr) do Statement_list end-do

The statement Statement (resp. list of statements Statement_list) is repeated as long as the condition
Bool_expr is true. If the condition is false at the first evaluation, the while statement is entirely skipped.
i:=1
while(i<=10) do
write(' ',i)
if isodd(i) then s+={i}end-ifi+=1
end-do2.8.4.3 Repeat loop
The general form of the repeat statement is:repeatStatement1[ Statement2 ...]
until Bool_expr

The list of statements enclosed in the instructions repeat and until is repeated until the condition
Bool_expr is true. As opposed to the while loop, the statement(s) is (are) executed at least once.
i:=1
repeatwrite(' ',i)
if isodd(i) then s+={i}end-ifi+=1
until i>10

Fair Isaac Corporation Proprietary Information

45

Chapter 2: The Mosel Language

2.8.4.4 break and next statements
The statements break and next are respectively used to interrupt and jump to the next iteration of aloop. The general form of the break and next statements is:break [n|label]ornext [n|label]

where n is an optional integer constant: n-1 nested loops are stopped before applying the operation. This
optional argument may also be a label (in the form an identifier or a string constant): in this case the loop
to consider is identified by a label that must be defined just before the corresponding loop using thefollowing syntax:
label :The label can be either an identifier (that is not associated to any entity) or a constant string. The scopeof each label is limited to the loop it identifies.
! in this example only the loop controls are shown
L1:! 1: Define label "L1"
repeat! 2: Loop L1
forall (i in S) do ! 3: Loop L2
while (C3) do! 4: Loop L3
break 3
! 5: Stop the 3 loops and continue after line 12
next! 6: Go to next iteration of L3 (line 4)
next 2! 7: Stop L3 and go to next 'i' (line 3)
end-do! 8: End of L3
next "L1"! 9: Stop L2, go to next iteration of L1 (line 12)
break!10: Stop L2 and continue after line 11
end-do!11: End of L2
until C1
!12: End of L1

2.8.4.5 with statement
The general syntax of this statement is:with locdef_1 [, locdef_2...] doStatement[ Statement ...]
end-doWhere locdef_i are local definitions of the following form:
ident=exp
orident(idndx_1 [, idndx_2...])=id_arr

In the first form ident is defined as an alias to the given expression exp and in the second form ident isequivalent to the array reference id_arr and each idndx_i are the corresponding indexing sets.
Although the with statement is not a loop it is handled like a single iteration forall loop such that it ispossible to use the break and next statements within the block of instructions.
! in this example LR is an array of records
with r=LR(10) do
r.x:=10! update LR(10).xr.y:=20! update LR(10).y

Fair Isaac Corporation Proprietary Information46

Chapter 2: The Mosel Language
end-do2.9 Procedures and functions
It is possible to group sets of statements and declarations in the form of subroutines that, once defined,
can be called several times during the execution of the model. There are two kinds of subroutines in
Mosel, procedures and functions. Procedures are used in the place of statements (e.g.
writeln("Hi!")) and functions as part of expressions (because a value is returned, e.g.
round(12.3)). Procedures and functions may both receive arguments, define local data and callthemselves recursively.

2.9.1 Definition
Defining a subroutine consists of describing its external properties (i.e. its name and arguments) and theactions to be performed when it is executed (i.e. the statements to perform). The general form of aprocedure definition is:procedure name_proc [(list_of_parms)]
Proc_body
end-procedure

where name_proc is the name of the procedure and list_of_parms its list of formal parameters (if any).
This list is composed of symbol declarations (cf. Section 2.6) separated by commas. The only
differences from usual declarations are that the variable name can be omitted (the declaration states
only the type of the entity) and no constants or expressions are allowed, including in the indexing list of
an array (for instance A=12 or t1:array(1..4) of real are not valid parameter declarations). The
body of the procedure is the usual list of statements and declaration blocks except that no type,procedure or function definition can be included.
procedure myproc
writeln("In myproc")
end-procedure
procedure withparams(a:array(r:range) of real, i,j:integer)
writeln("I received: i=",i," j=",j)forall(n in r) writeln("a(",n,")=",a(n))
end-procedure
declarations
mytab:array(1..10) of real
end-declarations
myprocwithparams(mytab,23,67)! Call myproc! Call withparams

The definition of a function is very similar to the one of a procedure:function name_func [(List_of_params)]: TypeFunc_bodyend-function

The only difference with a procedure is that the function type must be specified: it can be any type. Inside
the body of a function, a special variable of the type of the function is automatically defined: returned.
This variable is used as the return value of the function, it must therefore be assigned a value during theexecution of the function.

Fair Isaac Corporation Proprietary Information

47

Chapter 2: The Mosel Language
function multiply_by_3(i:integer):integer
returned:=i⁎3
end-function
writeln("3⁎12=", multiply_by_3(12))! Call the function

Normally all statements of a subroutine are executed in sequence. It is however possible to interrupt theexecution and return to the caller by using the special statement return.

2.9.2 Variable number of parameters
A subroutine may accept a variable number of parameters. To declare a routine of this kind, the lastparameter of the list of parameters must have the special type ...: this parameter will receive all the
additional arguments as a list of any (see Section 2.6.7) when the routine is called.
procedure printall(prefix:string,argv:...)
if argv.size=0 thenwriteln(prefix)! just the prefix
else
forall(p in argv) writeln(prefix,p) ! prefix and other arguments
end-ifend-procedure
printall("nothing")
printall("data ",1,"a",true)

The above code extract displays:
nothingdata 1
data adata true

2.9.3 Formal parameters: passing convention
Formal Parameters of basic types are passed by value and all other types are passed by reference. In
practice, when a parameter is passed by value, the subroutine receives a copy of the information so, if thesubroutine modifies this parameter, the effective parameter remains unchanged. But if a parameter ispassed by reference, the subroutine receives the parameter itself. As a consequence, if the parameter ismodified during the process of the subroutine, the effective parameter is also affected.
procedure alter(s:set of integer,i:integer)i+=1
s+={i}
end-procedure
gs:={1}gi:=5alter(gs,gi)
writeln(gs," ",gi)! Displays: {1,6} 5

2.9.4 Local declarations
Several declaration blocks may be used in a subroutine and all identifiers declared are local to thissubroutine. This means that all of these symbols exist only in the scope of the subroutine (i.e. between
the declaration and the end-procedure or end-function statement) and all of the resource they use
is released once the subroutine terminates its execution unless they are referenced outside of the routine(e.g. member of a set defined globally). As a consequence, active constraints (linctr that are not justlinear expressions) declared inside a subroutine and the variables they employ are still effective after the

Fair Isaac Corporation Proprietary Information48

Chapter 2: The Mosel Language

termination of the subroutine (because they are part of the current problem) even if the symbols used toname the related objects are not defined any more. Note also that a local declaration may hide a global
symbol.
declarations
i,j:integer
end-declarations! Global definition

procedure myproc
declarations
i:string! This declaration hides the global symbol
end-declarations
i:="a string"! Local 'i'
j:=4writeln("Inside of myproc, i=",i," j=",j)end-procedurei:=45! Global 'i'
j:=10
myprocwriteln("Outside of myproc, i=",i," j=",j)This code extract displays:
Inside of myproc, i=a string j=4
Outside of myproc, i=45 j=4

2.9.5 Overloading
Mosel supports overloading of procedures and functions. One can define the same function several
times with different sets of parameters and the compiler decides which subroutine to use depending on
the parameter list. This also applies to predefined procedures and functions.
! Returns a randomly generated integer in the interval [1,limit]
function random(limit:integer):integer
returned:=round(.5+random⁎limit)! Use the predefined! 'random' function
end-function

It is important to note that:■■a procedure cannot overload a function and vice versa;
it is not possible to redefine any identifier; this rule also applies to procedures and functions. A
subroutine definition can be used to overload another subroutine only if it differs for at least one
parameter. This means, a difference in the type of the return value of a function is not sufficient.

2.9.6 Forward declaration
During the compilation phase of a source file, only symbols that have been previously declared can beused at any given point. If two procedures call themselves recursively (cross recursion), it is therefore
necessary to be able to declare one of the two procedures in advance. Moreover, for the sake of clarity it
is sometimes useful to group all procedure and function definitions at the end of the source file. A
forward declaration is provided for these uses: it consists of stating only the header of a subroutine thatwill be defined later. The general form of a forward declaration is:forward procedure Proc_name [(List_of_params)]orforward function Func_name [(List_of_params)]: Type

Fair Isaac Corporation Proprietary Information

49

Chapter 2: The Mosel Language

where the procedure or function Func_name will be defined later in the source file. Alternatively asubroutine can be declared by stating its header inside of a declarations block. Note that a forward
declaration for which no actual definition can be found is considered as an error by Mosel.
forward function f2(x:integer):integerfunction f1(x:integer):integer
returned:=x+if(x>0,f2(x-1),0)
end-function! f1 needs to know f2

function f2(x:integer):integer
returned:=x+if(x>0,f1(x-1),0)
end-function! f2 needs to know f1

2.9.7 Suffix notation
Functions which name begins with get and taking a single argument may be called using a suffix
notation. This alternative syntax is constructed by appending to the variable name (the intended function
parameter) a dot followed by the function name without its prefix get. For instance the call getsol(x)is the same as x.sol. The compiler performing internally the translation from the suffix notation to theusual function call notation, the two syntaxes are equivalent.
Similarly, calls to procedures which name begins with set and taking two arguments may be written as
an assignment combined with a suffix notation. In this case the statement can be replaced by thevariable name (the intended first procedure parameter) followed by a dot and the procedure namewithout its prefix set then the assignment sign := and the value corresponding to the second parameter.
For instance the statement sethidden(ctl,true) can also be written ctl.hidden:=true. As forthe other alternative notation, the compiler performs the rewriting internally and the two syntaxes areequivalent.

2.10 Problems
In Mosel terms, a problem is a container holding various attributes and entities. The nature of theinformation stored is characterised by a problem type. The core system of Mosel provides thempproblem problem type for the representation of mathematical programming problems with linear
constraints. Other types may be published by modules either as entirely new problem types or as problem
type extensions. An extension adds extra functionality or properties to an existing type; for instance,
mpproblem.xprs provided by the module mmxprs adds support for solving mpproblem problems
while the type mpproblem.nl of mmnl makes it possible to include non-linear constraints in an
mpproblem.
When the execution of the model starts, an instance of each of the available problem types is created:
this main problem constitutes the default problem context. As a consequence, all problem related
operations (e.g., add constraints, solve...) refer to this context. Further problem instances may bedeclared just like any other symbol using a declarations section. The specification of a problem type (thatis used as an elementary type in a declaration) has two forms:
problem_type
orproblem_type1 and problem_type2 [and problem_typen ...]

where problem_type* are problem type names. The second syntax allows to define a problem instancethat refers to several problem types: this can be useful if a particular problem consists in the combinationof several problem types. Note also that the main problem can be seen as an instance of the combinationof all available problem types.
The with construct can be used to switch to a different problem context for the duration of a block ofFair Isaac Corporation Proprietary Information

50

Chapter 2: The Mosel Language

instructions. The general form of this construct is:with prob doStatement[ Statement ...]
end-dowhere prob is a problem reference or a problem type specification. In the first case the referenced
problem is selected, in the second case, a new problem instance is created for the duration of the block(i.e., it is released after the block has been processed). Both statements and declaration blocks as well asother with constructs may be included in this section: they are all executed in the context of the selected
problem.
declarations
p1,p2:mpproblem
p3:mpproblem and mypb
PT=mpproblem and mypb
a:array(1..10) of PT
x,y:mpvar
end-declarations
with p1 do
x+y>=0
end-dowith p2 do
x-y=1
end-do! assuming 'mypb' is a problem type! user defined problem type

Some problem types support assignment (operator :=) and additive assignment (operator +=). These
operators can be used between objects of same type but also when the right parameter of the operator is
a component of the assigned object. For instance, assuming the declarations of the previous example we
could state p3:=p2 meaning that the mpproblem part of p3 must be replaced by a copy of p2, the mypb
part of p3 remaining unchanged. From the same context, the assignment p2:=p3 produces acompilation error.

2.10.1 The mpproblem typeAn mpproblem instance basically consists in a set of linear constraints (the decision variables defined
anywhere in a model are shared by all problems). A constraint is incorporated into a problem when it isexpressed, so having the declaration of a linctr identifier in the context of a problem is not sufficient to
attach it to this problem. The association will occur when the symbol is assigned its first value.
Afterwards, the constraint will remain part of the same problem even if it is altered from within thecontext of another problem (a constraint cannot belong to several problems at the same time).
with p1 do
C1:=x+y+z>=0
x is_integer
end-dowith p2 do
2⁎x-3⁎z=0! here we state constraints of p2...
minimize(z)C1+= x.sol⁎z.sol
end-doIn the example above, the constraint C1 is part of problem p1. From the context of a second problem p2
the constraint C1 is modified using solution information of p2: this change affects only the first problem
since the constraint does not belong to the current context. Note that since is_integer is a (unary)
constraint, the decision variable x is integer for problem p1 but it is a continuous variable in p2.

Fair Isaac Corporation Proprietary Information

51

Chapter 2: The Mosel Language

When a problem is released or reset (see reset), all its constraints are detached. Constraints which are
not referenced (anonymous constraints) are released at the same time, named constraints however are
not freed, they become available to be associated to some other problem.
with mpproblem do
C1:=x+y+z>=0 ! (1)x-2⁎y=10! (2)x is_integer ! (3)end-dowith p1 do
C1
end-doIn this example, at the end of the first with block, the local problem is released. As a consequence theconstraint C1 is detached from this problem (but remains unchanged) and the 2 other constraints are
freed. The following statements add C1 to the problem p1.
The type mpproblem supports both assignment (operator :=) and additive assignment (operator +=).

2.11 The public qualifier
Once a source file has been compiled, the identifiers used to designate the objects of the model become
useless for Mosel. In order to access information after a model has been executed (for instance using
the print command of the interractive debugger), a table of symbols is saved in the BIM file.
The qualifier public can be used in declaration and definition of objects to mark those identifiers(including subroutines) that must be published in the table of symbols. Without this qualifier a symbol isconsidered to be private and it is not recorded in the table of symbols (unless the source is compiled withdebugging information).
public declarations
e:integer
f:integer
end-declarations! e is published! f is publisheddeclarations
public a,b,c:integerd:real
end-declarations! a,b and c are published! d is private

forward public procedure myproc(i:integer)! 'myproc' is publishedThis qualifier can also be used when declaring record types in order to select the fields of the record thatcan be accessed from outside of the file making the definitions: this allows to make available only a few
fields of a record, hidding what is considered to be internal data.
declarations
public t1=record
i:integer
public j:real
end-record
public t2=public record
i:integer
j:realend-record
end-declarations! t1.i is private! t1.j is public! t2.i is public! t2.j is public

Note that a public record type can only contain public types even if it does not publish its fields.

Fair Isaac Corporation Proprietary Information

52

Chapter 2: The Mosel Language

2.12 Packages
Declarations may be stored in a package: once compiled, the package can be used by any model bymeans of the uses or import statements (see Section 2.3.1). Except for its beginning and termination(keyword model is replaced by package) a package source is similar to a normal model source. The
following points should be noticed:■

all statements and declarations outside procedure or function definitions are used as an
initialization routine: they are automatically executed before statements of the model using the
package;■symbols that should be published by the package must be made explicitly public using the public
qualifier (see Section 2.11);■

model parameters of a package are automatically added to the list of parameters of the modelusing the package;■a package cannot be imported several times by a model and packages publish symbols of
packages they import. For instance, assuming package P1 imports package P2, a model using P1
cannot import or use explicitly P2 but has access to the functionality of P2 via P1.

2.12.1 Version management
When a package defines a version number (see Section 2.3.4) Mosel implements a compatility rulesimilar to the one used for modules: a package version A can be used in place of package version B if
major(A) = major(B) and minor(A) ≥ minor(B). This mechanism applies at compile time (when using
different packages with the same dependencies) and at runtime when loading a model. It is
recommended to update package version numbers as follows:■major number: any changes that will require recompilation of models using the package (inparticular removal of public functionality from the package)■

minor number: addition of new functionality that does not influence the behavior of existing uses ofthe package■

release number: bug fixes

2.12.2 The requirements block
Requirements are symbols a package requires for its processing but does not define. These required
symbols are declared in requirement blocks which are a special kind of declaration blocks in whichconstants are not allowed but procedure/functions can be declared. The symbols of such a block have tobe defined when the model using the package is compiled: the definitions may appear either in the modelor in another package but cannot come from a module. Several packages used by a given model may
have the same requirements (i.e. same identifier and same declaration). It is also worth noting that apackage inherits the requirements of the packages it uses.
requirements
an_int:integers0: set of string
bigar: array(S0) of realprocedure doit(i:integer)
end-requirements

Fair Isaac Corporation Proprietary Information

53

Chapter 2: The Mosel Language

2.12.3 Control parameters
Packages may define control parameters that can be used just like those of modules via routines
getparam and setparam. A control parameter is defined in the parameters block (see Section 2.4)
using the following syntax:
pname: type_namewhere pname is the name of the parameter as a constant string and type_name its type (either integer,
real, string or boolean). In addition to this declaration accessor routines must be defined: forhandling integer parameters the public function pkgname~getiparam(pname:string):integer
and the public procedure pkgname~setparam(pname:string,v:integer) must be defined(pkgname being the name of the current package). The function will be called by getparam to retrieve
the value of the specified parameter (as a string in lower case) and the procedure will be used by
setparam to change the parameter value. Similar definitions will be required for the other types(assuming the package declares parameters of the corresponding types), namely getrparam (realparameters), getsparam (string parameters) and getbparam (Boolean parameters) as well as theassociated procedures setparam. The following example shows the required definitions for the
package mypkg to publish real parameters p1 and p2:
parameters"p1":real"p2":real
end-parameters
declarations
myp1,myp2:real
end-declarations! private variables to hold parameter values! get value function for real parameters
public function mypkg~getrparam(p:string):realcase p of"p1": returned:=myp1"p2": returned:=myp2
end-caseend-function! set value procedure for real parameters
public procedure mypkg~setparam(p:string,v:real)case p of"p1": myp1:=v"p2": myp2:=v
end-case
end-procedure

2.13 Namespaces
All identifiers (variables and subroutines names) of a program are implicitly collected in a global
dictionary shared by the program itself and all packages and modules it uses. It is also possible to groupcertain identifiers under a namespace that is characterised by a name. A given identifier may appear inseveral namespaces and each of its occurrences refers to a different entity, as a consequence an entity isunambiguously identified by its name and the namespace to which it is a member: this is the fully
qualified name of this entity that is noted:
nspc~ident

Where nspc is a namespace name and ident an identifier in this namespace.
A namespace’s name is also an identifier that must be declared before being used even if it is defined by

Fair Isaac Corporation Proprietary Information

54

Chapter 2: The Mosel Language

a package already loaded. This declaration is achieved using the namespace compiler directive:
namespace ns1 [, ns2 ...]

Where nsi are the names of the namespaces that will be used in the program. As an identifier anamespace may be declared as part of another namespace and any of the nsi may have the form
nsx~nsy to declare nsy as a namespace included in nsx. Several namespace directives may be stated.
When the compilation starts a namespace is automatically created: it is used to collect all private
symbols of the program. When compiling a model this namespace has an empty name (i.e. a fully
qualified name of this namespace is of the form ~ident) and for a package it has the same name as the
package.
When looking for an identifier (that is not fully qualified) the compiler tries first to find it in the global
dictionary and then searches in a predefined list of namespaces. This list is initialised with thenamespace of private symbols and may be extended using the nssearch directive:
nssearch ns1 [, ns2 ...]

This statement adds the specified namespaces to the search list. If the directive is stated several times,
each added list is appended to the current list of namespaces. The namespace search is not recursive: it
is not sufficient to add a namespace to the search list to have all its included namespaces to be also partof the search list (e.g. if ns1 includes ns11 and ns12, the 3 names ns1,ns1~ns11 and ns1~ns12 mustbe put into the search list for all the identifiers to be searchable). Note that namespaces listed in a
nssearch directive do not need to be declared in a namespace directive.
Any namespace defined in a package is available to any model or package using it (and all the identifiers
it includes are implicitly public). Defining a namespace group makes it possible to allow only certain
packages to access a given namespace. The definition of such a group requires the use of a dedicatedcompiler directive:
nsgroup nspc: pkg1 [, pkg2 ...]
or
nsgroup nspc

Where pkgi are the package names (as constant strings) that will be allowed to access namespace nspc.
By default the automatic namespace containing the private symbols of a package has a group containing
only the package itself such that it cannot be used by any external component. It is however possible toredefine this initial group with a nsgroup directive, in particular the second form of the directive (without
specifying any package) makes the corresponding namespace available to any package. Note thatnamespaces listed in a nsgroup directive do not need to be declared in a namespace directive.

2.14 Annotations
Annotations are meta data expressed in the Mosel source file that are stored in the resulting bim file after
compilation. Thanks to a dedicated API it is possible to retrieve the information both from the model
itself during its execution (see getannotations) or before/after execution from a host application (seefunction XPRMgetannotations in the Mosel Libraries Reference Manual).

2.14.1 Syntax
Annotations are organised in categories. A category groups a set of annotations and other categories (orsub-categories). When expressing a full annotation name, categories are separated by the ’.’ symbol.
For instance:

Fair Isaac Corporation Proprietary Information

55

Chapter 2: The Mosel Language
doc.name

will be used to select the annotation name that is a member of the doc category. Similarly:
mycat1.cat2.info

will reference the annotation info recorded in the category cat2 that is itself part of category mycat1.
Annotations and annotation categories must be valid Mosel identifiers: their names can only usealpha-numeric symbols plus ’_’.
Some predefined categories are available at the beginning of the compilation:■■■

the default category (its name is empty) collects annotations that are not explicitly member of any
particular category. For instance the annotation myannot will be recorded in the default category.
This annotation may also be referenced by its full name .myannot
mc (for Mosel Compiler) is used to pass information to the compiler during the compilation. For
example, the mc.def annotation makes it possible to declare an annotation type (see section
2.14.3)doc can be used to document a model or package file (see section 2.20)

In the Mosel source file annotations are included in special comments. A single-line annotation is of theform:!@ name value

Here name is the name of the annotation (spaces between ’@’ and the name are ignored) and thefollowing text (up to the end of line) its corresponding value. The separation character between the nameand the value can be a space, ’:’ or ’=’ (there must be no space between the name and the symbol).
There is no restriction on the content of the value: it can be any kind of text (unless the annotation is
typed—see section 2.14.3).
A multi-line annotation is of the form:(!@name value...
@name2 value2...
!)

where name is an annotation name while the text following this name is its associated value. With this
syntax the value may spread over several lines, its termination is marked either by the end of thecomment block or by a new annotation specification. In this context, a new annotation must start withthe ’@’ symbol at the beginning of a new line (leading spaces are ignored). As for a one-line annotation,
symbols ’:’ and ’=’ can be used instead of a space to separate the name and its value.
If several annotations of the same category have to be defined in the same block, a current category may
be defined such that following annotation names can be shortened. This mechanism is activated by
specifying the category name terminated by a dot (the remainder of this line is ignored) before the firstannotation statement. The category selection is effective for the current comment block only andremains active until the next selection. Using a dot in place of a category name restores the default
behaviour (i.e. the full path must be used for annotation reference). For instance:(!@doc.
Switch to 'doc' category (this text is ignored)@name:my_function@type:integer@mycat.cat1. Switch to 'mycat.cat1'

Fair Isaac Corporation Proprietary Information

56

Chapter 2: The Mosel Language@memb1 10@memb2 20@.
Unselect current category@glb=useless!)Is equivalent to:(!@doc.name:my_function@doc.type:integer@mycat.cat1.memb1 10@mycat.cat1.memb2 20@glb=useless!)

By default any new annotation name is added to the internal dictionary and no checking is applied to theprovided value. If a given annotation is defined several times only the last assignment is preserved. The
compiler will however emit a warning if an attempt is made to assign a value to a category or to use anannotation as a category. For instance:!@mycat.memb1 10!@mycat.memb1.memb2 20

The second definition will fail to use mycat.memb1 as a category because the first one has already
implicitly declared it as an annotation.

2.14.2 Symbol association
An annotation is either global or associated with a specific public symbol (see section 2.11). The
association depends on the location of the definition in the source code:■

annotations preceding a subroutine declaration (forward statement) or definition are associatedwith the subroutine name■annotations preceding a declarations block are distributed to all the symbols declared in the block■

inside of a declarations block: annotations preceding or terminating the line of a declaration areassociated with the corresponding symbols

In all other cases the annotations are global (i.e. not associated with any particular symbol) — inparticular trying to associate annotations to private symbols will result in global annotations.
Annotations that precede a subroutine declaration, a declarations block or an entity in a declarations
block can be turned into global annotations by inserting the compiler annotation mc.flush between the
annotation and the following code.

2.14.3 Declaration
Declaration of annotations is achieved via the mc.def compiler annotation. Once an annotation isdeclared, the compiler checks the validity of definitions and rejects those that are not compliant, issuing awarning message (invalid annotations will not make the compilation fail unless the flag strict is used).
The general syntax of the annotation declaration statement is:!@mc.def aname [prop1[,prop2...]]

Where aname is an annotation name and prop? a property keyword. The possible keywords are:

Fair Isaac Corporation Proprietary Information

57

Chapter 2: The Mosel Language

alias name1 name2...

aname Defining an alias to name1, name2...

text|integer|real|boolean Type of the annotation value (default:text).
last|first|merge|multi

Handling of multiple definitions of an annotation (default:last)■

last: the last definition is kept■

first: keep the first definition (the following ones are ignored)■

merge: definitions are concatenated (separated by new lines)■

multi: all definitions are kept

global|specific By default, the association of annotations depends on the location of thedefinition. If global is stated, the annotation is always global; with option specific,
the annotation will be kept only if it can be associated with a symbol (otherwise it isignored instead of being stored as a global one).
values=v1 v2 v3... If used, this option must be the last one of the definition and it cannot be
combined with range. It defines a list of possible values for the annotation.
range=lb ub

If used, this option must be the last one of the definition, it requires the type to be
specified (integer or real) and it cannot be combined with values. It defines a rangeof possible values.

strictWhen this option has been stated any error detected on this annotation (or path whenapplied to a category) will make the compilation fail

Example:!@mc.def person.name text,first,specific!@mc.def person.age integer,first,specific,range=0 150!@mc.def person.gender values=male female

Categories are implicitly declared by the annotations they include (for instance declaring@mycat.myann implies the creation of mycat as a category). It is also possible to explicitly declare an
empty category (i.e. containing no annotation) using the mc.def construct by appending a dot to thecategory name (the only supported property is strict). For instance:!@mc.def mycat.

For a given annotation the declaration may be stated several times but the properties of an annotation
cannot be changed. For instance, the following declarations can be used in the same source:!@mc.def myann!@mc.def myann text,last

But the following declaration cannot be combined with any of the two preceding ones as they both resultin the annotation type text:!@mc.def myann integer

Declarations included in models are not exported to the bim file (i.e. they are only used during thecompilation procedure) but declarations stated in packages are published if they are relative to a user
defined category: any model using the package inherits the annotation declarations of the package.
Additional properties can be set using the mc.set compiler annotation. The general syntax of thisspecial statement is:Fair Isaac Corporation Proprietary Information

58

Chapter 2: The Mosel Language!@mc.set name flag

Where name is an annotation or category name and flag one of the following keywords:
complete

Applied to a category this flag indicates that no other annotation can be added to thiscategory (ignored for an annotation). It is however still possible to declare aliases. Notethat sub-categories are not concerned by this flag: if required each sub-category has also
to be tagged.

disableDisable the named category or annotation. From the point where this flag has been set
onwards, all definitions deriving from the provided name are silently ignored.

enableRevert the effect of disable.

unpublish

Disable the automatic publication of the specified declaration.

publishPublish the specified declaration.

Note that mc.set expects a full explicit name: for this command ann refers to category ann and not toannotation .ann as in other places.

2.15 File names and input/output drivers
Mosel handles data streams using I/O drivers: a driver is an interface between Mosel and a physical data
source. Its role is to expose the data source in a standard way such that from the user perspective, alldata sources can be accessed using the same methods (i.e. initializations blocks, file handling
functions). Drivers are specified in file names: all Mosel functions supporting I/O operations throughdrivers can be given an extended file name. This type of name is composed of the pairdriver_name:file_name. When Mosel needs to access a file, it looks for the specified driver in the table ofavailable drivers. This table contains all predefined drivers as well as drivers published by modules
currently loaded in memory. If the driver is provided by a module, the module name may also be indicatedin the extended file name: module_name.driver_name:file_name. Using this notation, Mosel loads therequired module if necessary (otherwise the file operation fails if the module is not already loaded). For
instance it is better to use mmodbc.odbc:database than odbc:database.
The file_name part of the extended file name is specific to the driver and its structure and meaning
depends on the driver. For instance, the sysfd driver expects a numerical file descriptor so file sysfd:1
is a valid name but sysfd:myfile cannot work. A driver may act as a filter and expects as file_nameanother extended file name (e.g. zlib.deflate:mem:myblk).
When no driver name is specified, Mosel uses the default driver which name is an empty string (myfile
is equivalent to :myfile). This driver relies on OS functions to access files from the file system. Notethat on the Windows operating system Mosel does not support relative paths on a specified drive (i.e. thefile "C:myfile" is equivalent to "C:\myfile", the behaviour may be different in other environments).
The tmp driver is an extension to the default driver: it locates the specified file in the temporary directory
used by Mosel (i.e. "tmp:toto" is equivalent to the expression getparam("tmpdir")+"/toto").
The null driver can be used to disable a stream: whatever written to file "null:" is ignored and readingfrom it is like reading from an empty file.
The mem driver uses a memory block instead of a file handled by the operating system. A file name forthis driver is of the form mem:label[/minsize[/incstep]] where label is an identifier whose firstcharacter is a letter and minsize an optional initial amount of memory to be reserved (size is expressedin bytes, in kilobytes with suffix "k" or in megabytes with suffix "m"). The label being recorded in the
dictionary of the model symbols it cannot be identical to any of the identifiers of the model (the function
newmuid might be used to generate a unique identifier). The memory block is allocated dynamically andresized as necessary. By default the size of the memory block is increased by pages of 4 kilobytes: theFair Isaac Corporation Proprietary Information

59

Chapter 2: The Mosel Language

optional parameter incstep may be used to change this page size (i.e. the default setting is"label/0/4k"). The special value 0 modifies the allocation policy: instead of being increased of a fixedamount, the block size is doubled. In all cases unused memory is released when the file is closed.
The mem driver may also be used to exchange data with an application using the Mosel libraries (refer tothe Mosel Libraries Reference Manual for further explanation).
The tee driver can only be open for writing and expects as file name a list of up to 6 extended file names
separated with ‘&’: it opens all the specified files and duplicates what it receives to each of them. If only
one file is given or if the string terminates with ‘&’, output is also sent to the default output stream (orerror stream if the file is used for errors). For instance, writing to the file "tee:log1&log2&" has theeffect of writing at the same time to files "log1" and "log2" as well as sending a copy to the console.
The bin driver can only be used for initializations blocks as a replacement of the default driver: itallows to write (and read) data files in a platform independent binary format. This file format is generally
smaller than its ASCII equivalent and preserves accuracy of floating point numbers. This driver can beused in 2 different ways: a single file including all records of the initialisations block is produced if a filename is provided. For instance, in the following example the file "mydata" will contain both A and B:
initialisations to "bin:mydata"AB
end-initialisations

With the second form (without file name) one file is generated for each record of the block. The following
example produces 2 files: "mydata_A" to contain the values of record A and "mydata_B" for values ofB:
initialisations to "bin:"
A as "mydata_A"
B as "mydata_B"
end-initialisations

When using this form in an initialisations to block, the option append may be specified suchthat files are open in append mode.
The other predefined drivers (sysfd, cb and raw) are useful when interfacing Mosel with a hostapplication. They are described in detail in the Mosel Libraries Reference Manual.
I/O drivers provided by modules of the Mosel distribution are documented with the corresponding
module (see Part II of this manual).

2.16 Character encoding of text files
Mosel uses UTF-8 for its internal representation of text strings and this is also the default character
encoding for text files. It is however possible to read and write text files in different encodings: for model
source and initialization block files the selection can be achieved by means of a special comment (seesections 2.5.1 and 2.8.2) but the encoding may also be specified at the time of opening a file by prefixing
its name with the "enc:" prefix:
enc:encoding [+unix|+dos|+sys] [+bom|+nobom],filename

Mosel supports natively the encodings UTF-8, UTF-16, UTF-32, ISO-8859-1, ISO-8859-15, CP1252 and
US-ASCII. For UTF-16 and UTF-32 the byte ordering depends on the architecture of the running system(e.g. this is Little Endian on an x86 processor) but it can also be specified by appending LE (Little Endian)or BE (Big Endian) to the encoding name (e.g. UTF-16LE). The availability and names of other encodings
depends on the operating system.
The following aliases may also be used in place of an encoding name: RAW (no encoding), SYS (default

Fair Isaac Corporation Proprietary Information

60

Chapter 2: The Mosel Language

system encoding), WCHAR (wide character for the C library), FNAME (encoding used for file names), TTY(encoding of the output stream of the console), TTYIN (encoding of the input stream of the console),
STDIN, STDOUT, STDERR (encoding of the default input/output/error stream).
In addition to the encoding name a couple of options might be applied: +unix and +dos select the line
termination (note that +dos is automatically used when writing to a physical file on Windows). Options+bom and +nobom decides whether a Byte Order Mark is to be inserted at the beginning of the file (thisoption only applies to UTF encodings when the file is not open in appending mode). By default a BOM isinserted when the encoding is UTF-16 or UTF-32, the option +nobom disables this insertion. The option+bom implies the insertion of a BOM on UTF-8 encoded files (this is usually not required for this encoding
but often used on Windows systems). The option +sys selects the line termination and BOM conventionof the running system (i.e. it is equivalent to +unix on a Posix system and +dos+bom on a Windows
machine).

2.17 Working directory and temporary directory
Except for absolute path names, file or path name expansion are relative to the current working directory.
By default this reference location corresponds to the operating system current working directory whichusually is the directory from which Mosel has been started. Since the working directory is an execution
parameter, a model may be running with a current working directory which might be different from theone used by the operating system. It is therefore recommended to use absolute file names when a Mosel
model communicates with an external component (for instance when a file name is part of the DSN to be
used for an ODBC connection).
In addition to the current working directory, Mosel creates a temporary directory that is shared by allmodels for storing temporary data handled as physical files. This directory is identified by theenvironment variable MOSEL_TMP or located in the system temporary directory as specified by one of theenvironment variables TMP, TEMP or USERPROFILE under Windows and TMPDIR on Posix systems. If
none of these environment variables is defined, the default base directory will be "C:\" on Windows and"/tmp" on Posix systems. The Mosel temporary directory is automatically created when needed anddeleted at program termination.
The path names of the working directory and the temporary directory are identified respectively by the"workdir" and "tmpdir" control parameters and can be retrieved using the getparam function. It is
possible to change the current working directory of a running model by updating the "workdir"
parameter using setparam.

2.18 Handling of input/output
At the start of the execution of a program/model, three text streams are created automatically: thestandard input, output and error streams. The standard output stream is used by the procedures writing
text (write, writeln, fflush). The standard input stream is used by the procedures reading text
(read, readln, fskipline). The standard error stream is the destination of error messages reported
by Mosel during its execution. These streams are inherited from the environment in which Mosel is being
run: usually using an output procedure implies printing something to the console and using an input
procedure implies expecting something to be typed by the user.
The procedures fopen and fclose make it possible to associate text files to the input, output and error
streams: in this case the IO functions can be used to read from or write to files. Note that when a file isopened, it is automatically made the active input, output or error stream (according to its opening status)
but the file that was previously assigned to the corresponding stream remains open. It is however
possible to switch between different open files using the procedure fselect in combination with thefunction getfid.
model "test IO"

Fair Isaac Corporation Proprietary Information

61

Chapter 2: The Mosel Language
def_out:=getfid(F_OUTPUT)
fopen("mylog.txt",F_OUTPUT)
my_out:=getfid(F_OUTPUT)
repeatfselect(def_out)
write("Text? ")text:=''
readln(text)
fselect(my_out)
writeln(text)
until text=''
fclose(F_OUTPUT)
writeln("Finished!")end-model! Save file ID of default output! Switch output to 'mylog.txt'! Save ID of current output stream! Select default ouput...
! ...to print a message! Read a string from the default input! Select the file 'mylog.txt'! Write the string into the file
! Close current output (='mylog.txt')! Display message to default output

2.19 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 1.3)
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 thecommand 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 ofa C compiler on the system). For example the following command will create the program runmycmd (orrunmycmd.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 thecommand runmycmd a b c will display:

Fair Isaac Corporation Proprietary Information

62

Chapter 2: The Mosel Language
My arguments:
runmycmdabc

In addition to giving access to command line arguments, deploy makes it possible to embed files into theresulting 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" thenwriteln("Usage: ", argv(1), " src")
exit(1)else
writeln("Source:")
fcopy(SRC,"")
end-ifend-model

In this example, the source file is identified by the model parameter SRC. To generate the program, thefollowing 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 isredefined 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

2.20 Documenting models using annotations
The predefined doc annotation category can be used to document a Mosel file. Using a dedicated set ofannotations the model author can add descriptions to the various entities defined in the source, theuser-defined descriptions are completed by definitions automatically generated by the Mosel compiler.
From a bim file that includes such definitions a documentation processor may produce a complete
document: as an example, the Xpress distribution comes with the moseldoc processor that generates anHTML documentation from an annotated bim file.

2.20.1 doc annotation category
Unlike other annotation categories, the doc annotation category is disabled by default such that thecorresponding annotations are silently ignored. To generate a documentation-enabled bim file thecompiler has to be run with the option -D. In addition to enabling the doc category, this flag also
activates the automatic generation of certain documentation annotations by the compiler. Alternatively tousing this flag, a model may define the following annotations:!@mc.set doc enable!@doc.autogen=true

Fair Isaac Corporation Proprietary Information

63

Chapter 2: The Mosel Language

Note that these special annotations can also be used in the source file as a means to exclude somedefinitions from the documentation, setting doc.autogen to false right before the definitions to be
excluded and back to true immediately after.

2.20.1.1 Global definitions
The following global annotations are automatically generated by the compiler:@doc.nameName of the package or model@doc.version

Version number as stated by the ’version’ statement@doc.dateCurrent date@doc.ispkg

Set to ’true’ if the file is a package

All automatic annotations can also be defined explicitly in the Mosel source to overwrite their default
values.
The following annotations may be added to complete the general appearance of the document to be
produced (they are used by the moseldoc documentation processor):@doc.title

Title of the document@doc.subtitle

Subtitle of the document@doc.xmlheader

Header of the XML document@doc.xmlroot

Name of the XML element containing the documentation@doc.id

Prefix used to generate IDs of chapters, sections, and subsections. If the
documentation for several packages is generated from a single master model thena unique ID must be explicitly defined in each of the packages in order to avoid ID
collision

The @doc category is complete (i.e. it is not possible to create new doc.X annotations), however, thecategory @doc.ext can be used to define further information assuming a particular documentation
processor can exploit it.

2.20.1.2 Document structure
Optionally, the resulting document may be organised in chapters, sections and subsections. Each ofthese constructs can contain both text paragraphs and entity descriptions (declarations and subroutines).
To enter a new documentation component, one of the following annotations has to be defined:@doc.chapter

Start a chapter@doc.section

Start a section inside of a chapter@doc.subsection Start a subsection inside of a section
Chapters and sections may also be taken from external files: the annotation @doc.include specifies afile name that must be a valid XML document including either chapters (tag <chapter>) or sections (tag<section>). The Mosel compiler will record the location of the inclusion that will be executed by themoseldoc processor.
In addition to the provided title a short title might also be defined (using @doc.shorttitle) that will be
used in place of the (long) title in the table of contents. Whenever a new division starts, a unique ID isFair Isaac Corporation Proprietary Information

64Chapter 2: The Mosel Language

automatically generated based on the section number and any defined prefix specified in the header ofthe document with @doc.id. It is also possible to explicitly define an ID using @doc.id just after
entering the section (this is required when the section has to be referenced using a <ref> tag).
From inside of any of these divisions a new paragraph is added with the @doc.p annotation. By default
any new addition (paragraph or entity description) is appended to the current component but it is possible
to select an alternative location. A target location has first to be defined using the annotation@doc.location: this creates a label associated with the current section. Defining the annotation@doc.relocate with this target elsewhere in the source file will move all subsequent additions to thetarget location; this relocation will continue up to the next division marker or relocation definition. Notethat defining an empty relocation reverts to the effective current location. Example:(!@doc.
@chapter My first chapter@p some text related to the first chapter@location first_chap@section first section of first chapter@p something about the section@relocate first_chap@p this paragraph will be inserted directly under first chapter@relocate@p but this one will remain in the section!)

2.20.1.3 Symbol definitions
The following sections list the various documentation annotations that can be defined depending on thekind of the entity (parameter, variable, type or subroutine) to be documented. Some of these annotations
are automatically defined by the compiler: in the case of values (like the value of a constant) the
automatic definition may not be performed if the value is the result of a calculation that cannot be
evaluated at compile time ("runtime constant"). In this case it is required to explicitly specify the text thatshould be retained in the documentation.
Parameters@doc.descr

Description (1-2 text lines)@doc.default

Default value (automatically generated)@doc.typeType (automatically generated)@doc.value

Possible value and explanation of its meaning (may be defined several times)@doc.info

Some more detailed explanations (may be defined several times)@doc.ignore

The symbol will be ignored by the documentation processor@doc.deprecated The parameter is deprecated and should no longer be used (an explanation can begiven)
Types, constants and variables
This set of annotations apply to symbols declared in declarations blocks. Record fields (both for a typedeclaration and for a variable) can be described using @doc.recflddescr: the value of this annotationconsists in the name of the field followed by its description (a space should separate these twocomponents)@doc.descr

Description (1-2 text lines)@doc.const

For a constant: value (automatically generated)

Fair Isaac Corporation Proprietary Information

65

Chapter 2: The Mosel Language@doc.typeType (automatically generated)@doc.typedef

For a type definition: type (automatically generated)@doc.value

Possible value and explanation of its meaning (may be defined several times)@doc.info

Some more detailed explanations (may be defined several times)@doc.setby

Name of subroutines modifying this entity@doc.recfldtype Type of a record field (automatically generated)@doc.recflddescr

Description of a record field@doc.ignore

The symbol will be ignored by the documentation processor@doc.reqmt

The symbol is a requirement (automatically generated)@doc.deprecated The type or variable is deprecated and should no longer be used (an explanation
can be given)
Procedures and functions
Information from different overloaded versions of a given subroutine is merged automatically. The@doc.group annotation may be used to merge information of routines with different names but used fora similar task (up to 3 different subroutine names can be grouped). The @doc.param annotation is used
to describe the parameters of the routine: the value of this annotation consists in the name of theparameter followed by its description (a space should separate these two components)@doc.group

Name of another subroutine that this one should be grouped with@doc.descr

Description (1-2 text lines)@doc.shortdescr Shortened description for table of contents and list display@doc.syntax

Routine signature (automatically generated)@doc.param

Name and meaning of a subroutine argument (may be defined several times)@doc.paramval

Possible value and meaning of a subroutine argument (may be defined several
times). The value of this annotation is the name of the parameter (as specified witha preceding @doc.param) followed by the value and the explanation@doc.return

For functions only: what is returned@doc.err

Possible error code (may be defined several times)@doc.example

Example of use (may be defined several times)@doc.info

Some more detailed explanations (may be defined several times)@doc.related

List of related symbols@doc.ignore

The subroutine will be ignored by the documentation processor@doc.reqmt

The subroutine is a requirement (automatically generated)@doc.deprecated The subroutine is deprecated and should no longer be used (an explanation canbe given)

Fair Isaac Corporation Proprietary Information

66

Chapter 2: The Mosel Language

2.20.1.4 Annotation definitions
A special set of annotations (category @doc.annot) is available for documenting annotation definitions
in Mosel packages (not supported for Mosel models). The annotations for documenting annotation
definitions are global annotations, their value must start with an annotation name in order to associatethem with the corresponding annotation definition.
@doc.annot.descr Annotation name followed by a short description (1-2 text lines)@doc.annot.default Annotation name and default value@doc.annot.value Annotation name, possible value and explanation of its meaning (may be defined
several times)@doc.annot.type Annotation type@doc.annot.info Annotation name and some more detailed explanations (may be defined several
times)@doc.annot.deprecated Annotation name and optionally some explanatory text
@doc.annotcat

Annotation category to document (may be defined several times), if undefined all
categories are documented@doc.annotloc

Insertion point (specified via @doc.location) for annotations documentation

2.20.1.5 Package control parameters
A special set of annotations (category @doc.cparam) is available for documenting control parameters ofMosel packages. The annotations for documenting control parameters are global annotations, their value
must start with a parameter name in order to associate them with the corresponding control parameter.
@doc.cparam.descr Parameter name followed by a short description (1-2 text lines)@doc.cparam.default Parameter name and default value@doc.cparam.value Parameter name, possible value and explanation of its meaning (may be
defined several times)@doc.cparam.type

Parameter type (automatically generated by the compiler)@doc.cparam.info Parameter name and some more detailed explanations (may be defined several
times)@doc.cparam.deprecated@doc.cparamloc

Parameter name and optionally some explanatory text

Insertion point (specified via @doc.location) for control parameters
documentation

2.20.2 moseldoc documentation processor
2.20.2.1 Running moseldoc
The moseldoc program takes as input either a bim file produced from a Mosel model compiled with the-D compiler option or directly a Mosel source file (in which case a compilation step is automatically
executed). Typically the generation of the documentation from a source file will be obtained with thefollowing command:>moseldoc mymodel.mos

Fair Isaac Corporation Proprietary Information

67

Chapter 2: The Mosel Language

The result of this process is an XML file ("mymodel_doc.xml") and a directory containing an HTMLversion of the documentation ("mymodel_html"). The program will produce only the XML file (from abim or source file) if option -xml is used and only the HTML output (from an XML file) if -html is
selected. The option -f is required to force the replacement of existing files.
As a Mosel program available in source form, moseldoc can be adapted to fit specific requirements. To
re-generate the executable use this compilation command:>mosel comp -s moseldoc.mos -o deploy.exe:moseldoc,css-z=moseldoc.css

2.20.2.2 Structure of the generated document
The resulting document respects the structure defined by the dedicated annotations (chapter, section,subsection). In each of these divisions, the paragraphs are exposed first, then the parameters andvariables and finally the list of subroutines. If no structural elements have been defined, a chapter per
entity type is automatically created to group similar objects (Parameters, Constants, Types, Variables andSubroutines).

2.20.2.3 Processing of annotation values
Values associated with descriptive text annotations (like section titles or descriptions) are interpreted asXML. Paragraphs (@doc.p) and examples (@doc.example) are handled in a specific way: by default thevalue is inserted as XML but, if the value starts with [TXT], the content is treated as plain text; if it starts
with [SRC], the value is considered to be some example code and it is reproduced preserving spacing. If
it starts with [NOD], it is interpreted as a self-contained XML node (i.e. it is not inserted in a paragraphblock). In an XML block of text, the markers ref (chapter/section/subsection reference), fctRef(subroutine reference) and entRef (entity reference) are processed such that in the HTML document
they are turned into hyperlinks to the corresponding objects. Similarly, the tt element type is replaced by
an appropriate style for displaying code samples.

2.21 Message translation
Mosel supports a message translation mechanism that makes it possible to display messages in thecurrent language of the operating environment. This system requires that all messages are originally
written in English and identified as messages to be translated (it is usually not desirable to translate all
text strings of a model). The Mosel compiler can then collect all messages to be translated for building
message catalogs. Each message catalog file contains the translations of the messages for a given
language: Mosel will select the appropriate file for the current language during its execution to use theright set of translations. The system is designed such that it will not fail if a translation or an entire
language is missing: in such a case the original English text is used.

2.21.1 Preparing the model source
Most often, not all text strings occurring in a program are to be translated to native language. This is why
it is necessary to tag each message to be translated such that the automatic message translation system
can process only the relevant texts. The tagging is achieved by using the operators _c(), _() or themodified procedures write_(), writeln_(), fwrite_() and fwriteln_().
The operator _c() is used to identify constant strings that should be collected for translation but thestring will not be translated at the place where it is used. This operator can be applied to a list of string
constants. A similar effect can be obtained with the annotation mc.msgid.
The function _() applies to both constant strings and variables: it replaces its argument by thetranslated string. As with the operator _c() constant strings are collected for the message catalogs, butthey will also be replaced by their translation at the place where the operator is applied to the string.

Fair Isaac Corporation Proprietary Information

68

Chapter 2: The Mosel Language

The write_ and writeln_ procedures are equivalent to their normal versions except that they process
the constant strings they have to display for translation.
All translations of a model (or package) are grouped under a domain: this identifier is used to name themessage catalog files. The default domain name is the model (or package) name after having replaced
spaces and non-ascii characters by underscores (for instance the domain name of the model "my mod"is "my_mod"). The domain name can also be specified using the mc.msgdom annotation.
The following model example shows the use of the various markers:model translate! The message domain is 'trs' (default name would be the model name 'translate')!@mc.msgdom trs
declarations! The elements of 'nums' are kept in English, but collected for translation
nums=[_c("one","two","three")]! Add 'four' to the message catalogs (although it is not used here)!@mc.msgid:four
end-declarations! Translate the message text, without translating 'nums'
writeln_("all numbers (in English): ", nums)
n:=getfirst(nums)! Translate the message text and the first occurrence of 'n', but not! its second occurrence
writeln_("the first number is: ", _(n), " (in English:", n, ")")
end-model

2.21.2 Building the message catalogs
Once the model source has been prepared, the list of messages to be translated can be extracted. This
operation is performed by the Mosel compiler when executed with the option -x:>mosel comp -x mymod.mos -o trs.pot

The output of this command is a Portable Object Template (POT): this is a text file consisting of a list ofpairs msgid (message to translate), msgstr (translation) for which only the first entry is populated.
With the example model from the previous section the generated POT file results in the following:# Created by Mosel v4.0.0 from 'translate.mos'# Domain name: trs
msgid "all numbers (in English): %L\n"msgstr ""msgid "four"
msgstr ""msgid "one"msgstr ""msgid "the first number is: %s (in English:%s)\n"msgstr ""msgid "three"msgstr ""msgid "two"msgstr ""For each of the supported languages a separate PO (Portable Object) file that will contain thecorresponding translations has to be created from this template. The command xprnls is used for thisFair Isaac Corporation Proprietary Information

69

Chapter 2: The Mosel Language

task (for further details please refer to the XPRNLS Reference Manual). For instance the following
command will create the file for the Italian translations of the messages:>xprnls init -o trs.it.po trs.pot

Here we name the file domain.language.po in order to ease the management of these translation files(where language stands for the ISO639 language code).
The generated file is a copy of the template with an additional header that should be completed by thetranslator (it is pre-populated with information obtained from the system), in particular the language(property "Language") and the encoding (property "Content-Type"). For each of the msgid records
the translation in the language associated to the file has to be provided in the msgstr record. Note thatsome messages include escape sequences (like "\n") and format markers (e.g. "%s"): thecorresponding translation must include the same format markers as the original text and they must
appear in the same order (otherwise the translation will be ignored).
The beginning of the translation file of our example for French (named "trs.fr.po") should be similar
to the following (the extract below shows only the header and the translation of the first message):
msgid ""
msgstr """Project-Id-Version: My translation example\n""POT-Creation-Date: 2015-12-04 18:16+0100\n""PO-Revision-Date: 2015-12-04 18:16+0100\n""Last-Translator: Jules Verne\n""Language: fr\n""Content-Type: text/plain; charset=ISO8859-15\n"msgid "all numbers (in English): %L\n"msgstr "tous les nombres (en anglais): %L\n"

The message catalogs for the PO files are obtained by running once more the xprnls command, thistime using the option mogen:>xprnls mogen -d locale trs.⁎.po

This command will compile each of the PO files into a Machine Object (MO) file named trs.mo that will besaved under the directory locale/lang/LC_MESSAGES. This directory tree must be distributed alongwith the model file for the automatic translation to work.

2.21.3 Model execution
During the execution of the model the message catalogs for the current language (as indicated by theoperating system) are loaded automatically from the ’locale’ directory. This location is defined by the"localedir" control parameter (by default this is "./locale"). If no message catalog can be found
for the requested language then the original English text is used. This will also be the case if a translation
is missing (e.g. if the message catalog has not been updated after some model source change).
When run on a computer configured for French our example displays:
tous les nombres (en anglais): [`one',`two',`three']le premier nombre est: un (en anglais:one)

Fair Isaac Corporation Proprietary Information70

CHAPTER 3

Predefined functions and proceduresThis chapter lists in alphabetical order all predefined functions and procedures included in the Mosel
language. Certain functions or procedures take predefined constants as input values or return values that
correspond to predefined constants. In every case, these constants are documented with the function orprocedure. In addition, Mosel defines a few other useful numerical constants:
MAX_INT

maximum integer number

MAX_REAL

maximum real number

M_Ebase of natural logarithms e

M_PIvalue of π

INFINITY

Infinity

NAN

Not A Number

Fair Isaac Corporation Proprietary Information

71

Chapter 3: Predefined functions and procedures

abs
Purpose
Synopsis

Get the absolute value of an integer or real.
function abs(i:integer):integerfunction abs(r:real):realArgumentsirInteger number for which to calculate the absolute value
Real number for which to calculate the absolute value

Return value
Absolute value of an integer or real number.
Further information
This function returns the absolute value of an integer or real number. The returned type corresponds tothe type of the input.
Related topics
exp, ln, log, sqrt.

Fair Isaac Corporation Proprietary Information72

Chapter 3: Predefined functions and procedures

arctanPurpose
Synopsis

Get the arctangent of a value.
function arctan(r:real):realArgumentrReal number to which to apply the trigonometric function

Return value
Arctangent of the argument.
ExampleThe following functions compute the arcsine and arccosine of a value:function arcsin(s:real):real
returned:=arctan(s/sqrt(1-s^2))
end-function
function arccos(c:real):real
returned:=arctan(sqrt(1-c^2)/c)
end-function

Related topics
cos, sin

Fair Isaac Corporation Proprietary Information73

Chapter 3: Predefined functions and procedures

asprocPurpose
SynopsisIgnore the return value of a function call.
procedure asproc(fctcall)

Argument
fctcall A function call
Exampleasproc(splithead(L,2))
Further information
This procedure makes it possible to call a function and ignore its return value (see also option
fctasproc in section 2.3.3).

Fair Isaac Corporation Proprietary Information

74

Chapter 3: Predefined functions and procedures

assertPurpose
Synopsis

Abort execution if a condition is not satisfied.
procedure assert(c:boolean)
procedure assert(c:boolean,m:string)procedure assert(c:boolean,m:string,e:integer)

Argumentscme

Condition to verify
Error message to display in case of failure
Error code to return in case of failure (default: 8)

Exampleassert(and(i in I) mydata(i)>0)
assert(isodd(a),"a is not odd!!")Further information
1. If the condition c is satisfied, this procedure has no effect, otherwise it displays an error message, calls
dumpcallstack(0), and aborts execution by calling exit. The versions of the procedure with 2 and 3
parameters can be used to replace the default message (location of the statement in the source) anddefault exit value (8).
2. If the message m starts with the symbols "." or ":" (e.g. ": my error") the resulting message will
be prefixed by the location of the statement in the source. Otherwise the provided message will replace
the default text and be printed unchanged.
3. Assertions are usually used as a debugging tool and are ignored (i.e. the statemens are not included atall) when the model is compiled without debugging information (i.e. none of options -g or -G is used) or
if the compiler flag -na is used. It is however possible to keep assert statements even when no
debugging information is included by specifying the compiler directive keepassert (see Section 2.3).
Related topics
exit, dumpcallstack

Fair Isaac Corporation Proprietary Information75

Chapter 3: Predefined functions and procedures

bitflip
Purpose
Synopsis

Flip bits (bitwise XOR).
function bitflip(i:integer, j:integer):integer

ArgumentsijInteger to be set
Value to flip

Return value
Bitwise XOR of the operands.
ExampleIn the following, i takes the value 9, j takes the value 141, and k takes the value 7:
i:= bitflip(12, 5)
j:= biflip(13, 128)k:= bitflip(13, 10)

Further information
This function computes the bitwise exclusive OR of its operands.
Related topics
bittest, bitshift, bitset, bitneg, bitval

Fair Isaac Corporation Proprietary Information

76

Chapter 3: Predefined functions and procedures

bitnegPurpose
Synopsis

Bitwise negation (bitwise NOT).
function bitneg(i:integer):integer

ArgumentiInteger to negate

Return value
Negated value of argument.
ExampleIn the following, i takes the value -6, j takes the value 2147483647, and k takes the value -4:i:= bitneg(5)j:= bitneg(-2147483647-1)
k:= bitneg(3)Further information
The bitwise NOT (or complement) consists in computing the logical negation of each bit: 1 is replaced by
0 and 0 is replaced by 1.
Related topics
bitset, bittest, bitflip, bitshift, bitval

Fair Isaac Corporation Proprietary Information

77

Chapter 3: Predefined functions and procedures

bitsetPurpose
Synopsis

Set bits (bitwise OR).
function bitset(i:integer, j:integer):integer

ArgumentsijInteger to be set
Value to set

Return value
Bitwise OR of the operands.
ExampleIn the following, i takes the value 13, j takes the value 141, and k takes the value 15:
i:= bitset(12, 5)
j:= bitset(13, 128)k:= bitset(13, 10)

Further information
This function computes the bitwise OR of its operands.
Related topics
bittest, bitshift, bitflip, bitneg, bitval

Fair Isaac Corporation Proprietary Information

78

Chapter 3: Predefined functions and procedures

bitshift
Purpose
Synopsis

Shift an integer by a number of bits.
function bitshift(i:integer, n:integer):integer

ArgumentsinInteger to be shifted
Number of bits: >0 for shifting to the left and <0 for shifting to the right

Return value
Shifted integer.
ExampleIn the following, i takes the value 160, j takes the value 32, and k takes the value 1:
i:= bitshift(5, 5)
j:= bitshit(1, 5)
k:= bitshit(128, -7)

Further information
Shifting of 1 bit to the right is the same as dividing it by 2 and shifting of 1 bit to the left is the same as
multiplying by 2.
Related topics
bitset, bittest, bitflip, bitneg, bitval

Fair Isaac Corporation Proprietary Information

79

Chapter 3: Predefined functions and procedures

bittestPurpose
Synopsis

Test bit settings (bitwise AND).
function bittest(i:integer, mask:integer):integer

Argumentsimask

Integer to be tested
Bit mask

Return value
Bits selected by the mask.
ExampleIn the following, i takes the value 4, j takes the value 5, and k takes the value 8:i:= bittest(12, 5)
j:= bittest(13, 5)
k:= bittest(13, 10)

Further information
This function compares a given number with a bit mask and returns those bits selected by the mask thatare set in the number (bit 0 has value 1, bit 1 has value 2, bit 2 has value 4, and so on - use function
bitval to get the value of a bit).
Related topics
bitset, bitshift, bitflip, bitneg, bitval

Fair Isaac Corporation Proprietary Information

80Chapter 3: Predefined functions and procedures

bitvalPurpose
Synopsis

Compute the value corresponding to a bit number.
function bitval(i:integer):integer

Argumenti

Bit number (between 0 and 31)

Return value
Value of the selected bit.
ExampleIn the following, i takes the value 1, j takes the value -2147483648, and k takes the value 16:i:= bitval(0)j:= bitval(31)k:= bitval(4)Further information
This function computes the value corresponding to a bit number. The evaluation of bitval(i)corresponds to bitshift(1,i)
Related topics
bitset, bitshift, bitflip, bitneg, bittest

Fair Isaac Corporation Proprietary Information81

Chapter 3: Predefined functions and procedures

ceil
Purpose
SynopsisRound a number to the next largest integer.
function ceil(r:real):integer

ArgumentrReal number to be rounded

Return value
Rounded value.
ExampleIn the following, i takes the value 6, j takes the value -6, and k takes the value 13:
i := ceil(5.6)
j := ceil(-6.7)
k := ceil(12.3)

Related topics
floor, round.

Fair Isaac Corporation Proprietary Information

82

Chapter 3: Predefined functions and procedures

comparePurpose
Synopsis

Compare 2 values.
function compare(arg1:ordered type, arg2:same type as arg1):integer

Arguments
arg1
arg2

First operand for the comparison
Second operand for the comparison (same type as arg1)

Return value
0 if arguments are identical, -1 if the first argument is less than the second argument and 1 otherwise.
Further information
This function is defined for integer, real, string and boolean variables. It is also available for module types
that implement the necessary functionality.

Fair Isaac Corporation Proprietary Information

83

Chapter 3: Predefined functions and procedurescos
Purpose
Synopsis

Get the cosine of a value.
function cos(r:real):realArgumentrReal number to which to apply the trigonometric function

Return value
Cosine value of the argument.
ExampleThe function tangent can be implemented as follows:
function tangent(x:real):real
returned:=sin(x)/cos(x)end-function

Related topics
arctan, sin.

Fair Isaac Corporation Proprietary Information

84

Chapter 3: Predefined functions and procedures

createPurpose
SynopsisCreate explicitly a cell of a dynamic array.
procedure create(x:array reference)
procedure create(u:union reference)

Argumentsxu
ExampleCell to be created
Union to initialize

The following declares a dynamic array of variables, creating only those corresponding to the odd indices.
It also initializes a union as a decision variable. Finally, it defines the linear expression ux + x(1) +x(3) + x(5) + x(7):declarations
x: dynamic array(1..8) of mpvar
ux: any
end-declarations
create(ux.mpvar)
forall(i in 1..8| isodd(i)) create(x(i))
C:= ux.mpvar + sum(i in 1..8) x(i)Further information
1. Usually cells of dynamic arrays are created by means of assignments. This procedure can be used as areplacement for an assignment, in particular when the type of a dynamic array does not provide any
assignment operator (like mpvar for instance).
2. In a similar way as for an array cell the create procedure may be used to initialize and set the type of aunion. If the union has already the requested type no operation if performed, otherwise the current value
is deleted and the new type is assigned to the entity (in association with the corresponding default value).
Related topics
Section 2.6.4, Section 2.6.7, reset, delcell.

Fair Isaac Corporation Proprietary Information

85

Chapter 3: Predefined functions and procedures

currentdate
Purpose
Synopsis

Return the current date as a Julian Day Number (JDN).
function currentdate:integer

Return value
The number of days elapsed since 1/1/1970 as an integer.
Further information
1. The control parameter "UTC" indicates whether this function returns a date in local or UTC time.
2. Refer to the module mmsystem for a set of dedicated types for handling date and time.
Related topics
setparam,timestamp,currenttime

Fair Isaac Corporation Proprietary Information

86Chapter 3: Predefined functions and procedures

currenttime
Purpose
Synopsis

Return the current time as the number of milliseconds since midnight.
function currenttime:integer

Return value
The number of milliseconds since midnight as an integer.
Further information
1. The control parameter "UTC" indicates whether this function returns a time in local or UTC time.
2. Refer to the module mmsystem for a set of dedicated types for handling date and time.
Related topics
setparam,timestamp,currentdate

Fair Isaac Corporation Proprietary Information

87

Chapter 3: Predefined functions and procedures

cuteltPurpose
Synopsis

Extract an element from a set or a list.
function cutelt(e:set):type_of_efunction cutelt(l:list):type_of_lfunction cutelt(l:list,p:integer):type_of_l

Arguments
e
l
p

A set
A listIndex of the element to remove (default:1)

Return value
An element of the set or list after it has been removed from its container.
Further information
When applied to a range set or list this function behaves like cutfirst. An error is generated if theargument of the function is empty.
Related topics
getelt.

Fair Isaac Corporation Proprietary Information

88Chapter 3: Predefined functions and procedures

cutfirst
Purpose
Synopsis

Extract the first element of a range set or a list.
function cutfirst(r:range):integerfunction cutfirst(l:list):type_of_l

Argumentsrl

A range set
A listReturn value
The first element of the set or list after it has been removed from its container.
Further information
This function is equivalent to calling getfirst and then cuthead for dropping one element.
Related topics
cutlast, cutelt.

Fair Isaac Corporation Proprietary Information

89

Chapter 3: Predefined functions and procedures

cutheadPurpose
SynopsisCut the first elements of a list.
procedure cuthead(l:list, o:integer)

Argumentslo

A listNumber of elements to remove if >0 or number of elements to keep if <0

ExampleL:=[1,2,3,4,5]
cuthead(L,2)
cuthead(L,-1)! => L=[3,4,5]! => L=[5]Further information
If the second parameter is 0, the list is unchanged. If the same parameter is larger than the size of the list,
all elements are deleted.
Related topics
cuttailFair Isaac Corporation Proprietary Information

90

Chapter 3: Predefined functions and procedures

cutlastPurpose
Synopsis

Extract the last element of a range set or a list.
function cutlast(r:range):integerfunction cutlast(l:list):type_of_l

Argumentsrl

A range set
A listReturn value
The last element of the set or list after it has been removed from its container.
Further information
This function is equivalent to calling getlast and then cuttail for dropping one element.
Related topics
cutfirst, cutelt.

Fair Isaac Corporation Proprietary Information

91

Chapter 3: Predefined functions and procedures

cuttailPurpose
SynopsisCut the last elements of a list.
procedure cuttail(l:list, o:integer)

Argumentslo

A listNumber of elements to remove if >0 or number of elements to keep if <0

ExampleL:=[1,2,3,4,5]
cuttail(L,2)
cuttail(L,-1)! => L=[1,2,3]! => L=[1]Further information
If the second parameter is 0, the list is unchanged. If the same parameter is larger than the size of the list,
all elements are deleted.
Related topics
cutheadFair Isaac Corporation Proprietary Information

92

Chapter 3: Predefined functions and procedures

delcellPurpose
Synopsis

Delete a cell or all cells of a dynamic array.
procedure delcell(x:array reference)
procedure delcell(a:array)

ArgumentsxaCell to be deleted
An arrayFurther information
1. The first form of the routine can only be applied to dynamic arrays (it is not possible to delete a cell of adense array). Using the second syntax of the procedure will release all cells of the array, note that in thecase of a dense array the entire data set will be reallocated when the array is accessed again.
2. Deleting a cell of an array of referenced objects (like mpvar) may not effectively release that object.
Actually, a referenced object is released only when all its references have been removed. For instance, if
an object appears in a set, deleting its main reference using delcell will not remove this object fromthe set.
Related topics
Section 2.6.4, create, reset.

Fair Isaac Corporation Proprietary Information

93

Chapter 3: Predefined functions and procedures

datablockPurpose
Synopsis

Get the file name of an embedded data block .
function datablock(src:string, prefix:string):string
function datablock(src:string):stringArguments
src
prefixName of the file to be embedded
Prefix to be used for accessing the data block (default: "zlib.deflate:")Return value
A file name pointing to the data block
ExampleIn the following code extract the bim file for submod.mos is generated during the compilation of thecurrent (master) model and is included in the resulting bim file for this model. At execution time themaster model will therefore not require any additional file for this submodel:load(submod,datablock("mmsystem.pipe:mosel comp -o - submod.mos"))run(submod)
waitforend(submod)
Note that the output of the compilation for the file submod.mos is redirected via the ’pipe’ onto themaster model while this model itself is being compiled.

Further information
1. This function makes it possible to embed in a bim file any data files that are available during thecompilation of the model source but cannot be accessed at execution time. The files specified by thisroutine are made available as memory blocks (see Section 2.15) during the execution of the model.
2. The file specified by the src argument is loaded into memory and saved in the resulting bim file during
the compilation of the source model. At execution time this function call results in a file name pointing toa memory location storing the previously saved data.
3. The file name src is handled in the same way as for source file inclusion (see Section 2.5.2), in particular
the same rules apply regarding the file location and the expansion of environment variables.
4. The prefix argument can be used to select a driver for processing the file. With its default value("zlib.deflate:") the file is compressed before being stored in the bim file, the decompression
occurs when the file is accessed during execution (i.e. the file name returned by the function begins withthe string "zlib.deflate:"). To keep the file in its original form use an empty string as the prefix (i.e.
"").
5. When several data blocks with the same name and prefix are used in a model source the corresponding
file is loaded and stored only once.
6. If the file to store is empty (or if its name is an empty string) the function call is replaced by the constant"null:" and no memory block is created.

Fair Isaac Corporation Proprietary Information

94

Chapter 3: Predefined functions and procedures

dumpcallstackPurpose
Synopsis

Display the current call stack of the system.
procedure dumpcallstack(ml:integer)

Argumentml

Maximum number of levels to display

Further information
1. This procedure displays the call stack of the running model, that is the sequence of subroutine calls
leading to the current statement. The parameter ml sets a limit on the number of steps to report, if thisvalue is 0 the default value defined at the global level will be used (see Section 1.3.1).
2. Stack dumps require debugging information: if the model has not been compiled with options -g or -G
calling the procedure will have no effect.
Related topics
assert.

Fair Isaac Corporation Proprietary Information95

Chapter 3: Predefined functions and procedures

existsPurpose
SynopsisCheck if a given entry in a dynamic array has been created.
function exists(x):boolean

Argumentx

Array reference (e.g. t(1))

Return value
true if the entry exists, false otherwise.
ExampleThe following, a dynamic array of decision variables only has its even elements created, which is checkedby displaying the existing variables:
declarations
S=1..8x: dynamic array(S) of mpvar
end-declarations
forall(i in S| not isodd(i)) create(x(i))
forall(i in S| exists(x(i)))
writeln("x(", i, ") exists")

Further information
1. If an array is declared dynamic its elements are not created at its declaration. This function indicates if agiven element has been created.
2. Under certain conditions, the exists function call is optimized by the compiler when used for filtering an
aggregate operator: the loop is only performed for the existing entries instead of enumerating all possible
tuples of indices for finding the relevant ones.
Related topics
Section 2.7.2, create.

Fair Isaac Corporation Proprietary Information

96

Chapter 3: Predefined functions and procedures

exit
Purpose
Synopsis

Terminate the program.
procedure exit(code:integer)

Argumentcode

Value to be returned by the program

Further information
This procedure terminates the current program and returns the given value. Models exit by default with avalue of 0 unless this is changed using exit. The Mosel command line interpreter uses this value as exit
status.
Related topics
Section 1.3.

Fair Isaac Corporation Proprietary Information

97

Chapter 3: Predefined functions and procedures

exp
Purpose
Synopsis

Get the natural exponent of a value.
function exp(r:real):realArgumentrReal value the function is applied to.

Return value
Natural exponent (er ) of the argument.
Related topics
abs, exp, ln, log, sqrt.

Fair Isaac Corporation Proprietary Information98

Chapter 3: Predefined functions and procedures

exportprob
Purpose

Synopsis

Export the current LP/MIP problem held in Mosel core (the portion of a problem defined with mpvar andlinctr only) to a file.
procedure exportprob(options:integer, filename:string, obj:linctr)
procedure exportprob(options:integer, filename:string)procedure exportprob(filename:string, obj:linctr)
procedure exportprob(filename:string)procedure exportprob

Arguments
options

File format options:

EP_MIN
minimization (default)
EP_MAX
maximization
EP_MPSMPS format
EP_STRIP Use scrambled names
EP_HEX
Ouput numbers in hexadecimal when using MPS format
Several options may be combined using +.
filename Name of the output file. If the empty string "" is given, output is printed to the standard
output (the screen)
obj
Objective function constraint
ExampleThe following prints the current problem to the screen using the default format and with MinCost as
objective function. The second statement exports the problem in LP-format and with scrambled names
to the file prob1.lp maximizing the constraint Profit:
declarations
MinCost, Profit:linctr
end-declarations
exportprob(0, "", MinCost)
exportprob(EP_MAX+EP_STRIP, "prob1", Profit)

Fair Isaac Corporation Proprietary Information

99

Chapter 3: Predefined functions and procedures

Further information
1. Problem types: This function exports only the LP/MIP problem directly handled by the Mosel corelibraries. It cannot report problem extensions managed by external modules—these are silently ignored.
For instance, quadratic constraints, indicator constraints or general constraints provided by the Xpress
Optimizer are not shown by this routine: for this type of problems, the module-specific writeprob
routine has to be used instead of exportprob.
2. Number format: Except when option EP_MPS+EP_HEX is used numbers are ouput according to therealfmt, txtztol and zerotol model parameters (see setparam). Mosel’s real number formatting
follows C printing format which is different, for example, from the formatting rules applied by Xpress
Optimizer, in particular in the module-specific writeprob routine.
3. File extension: If the given filename uses the default IO driver (no driver specified) and has no extension,
Mosel appends .lp to it for LP format files and .mps for MPS format.
4. Entity names: Normally, local symbols (i.e. defined in a procedure or function) are replaced by generated
names in the exported matrix. However, if the model has been compiled with option -G, names defined
locally to the routine calling exportprob are used in the exported matrix. Moreover, if a local symbol
hides a global one, this symbol is prefixed by ’~’.
5. If the model is compiled with -G and the control parameter recloc is set to true (see setparam),missing constraint names are replaced by the source location of the constraint definition (i.e. a
combination of the row number, source file name and line number in the file).
6. If no option is provided, the default format is LP for a minimization; if no constraint is given, the current
objective (if available) is exported. The matrix is printed to the standard output when this function is usedwithout parameter.
Related topics
setname.

Fair Isaac Corporation Proprietary Information

100Chapter 3: Predefined functions and procedures

fclosePurpose
Synopsis

Close the active input, output or error stream.
procedure fclose(stream:integer)

Argument
stream The stream to close:
F_INPUT
Input stream
F_OUTPUT Output stream
F_ERROR
Error stream
Further information
1. This procedure closes the file that is currently associated with the given stream. The file preceding theclosed file (in the order of opening) is then assigned to the corresponding stream. A file that is closedwith this procedure must previously have been opened with fopen. This function has no effect if thecorresponding stream is not associated with any explicitly opened file (i.e. it is not possible to close thedefault input, output or error streams). All open streams are automatically closed when the program
terminates.
2. An IO error will be raised if the operation does not succeed.
Related topics
fflush, fopen, fselect, getfid, iseof.

Fair Isaac Corporation Proprietary Information

101

Chapter 3: Predefined functions and procedures

fflush
Purpose
Synopsis

Force the operating system to write buffered data.
procedure fflush

Further information
This procedure forces a write of all buffered data of the default output stream. fflush is automaticallycalled when the stream is closed either with fclose or when the program terminates.
Related topics
fclose, fopen.

Fair Isaac Corporation Proprietary Information

102

Chapter 3: Predefined functions and procedures

finalize
Purpose
Synopsis

Finalize the definition of a set or list.
procedure finalize(s:set)procedure finalize(l:list)

ArgumentsslDynamic set
Dynamic list

Further information
1. This procedure finalizes the definition of a set (or list), that is, it turns a dynamic set into a constant set
consisting of the elements that are currently in the set.
2. Using this routine on sets declared dynamic has no effect.

Fair Isaac Corporation Proprietary Information

103

Chapter 3: Predefined functions and procedures

findfirst
Purpose
Synopsis

Find the first occurrence of an element in a list.
function findfirst(l:list, e:type_of_l):integer

Argumentsle

A list
The element to look for (it must be of the type of l)

Return value
The position of the element or 0 if the element is not included in the list.
ExampleL:=['a','b','c','d','b']i:=findfirst(L,'b')! => i=2
i:=findlast(L,'f')! => i=0
Related topics
findlast

Fair Isaac Corporation Proprietary Information

104

Chapter 3: Predefined functions and procedures

findlast
Purpose
Synopsis

Find the last occurrence of an element in a list.
function findlast(l:list, e:type_of_l):integer

Argumentsle

A list
The element to look for (it must be of the type of l)

Return value
The position of the element or 0 if the element is not included in the list.
ExampleL:=['a','b','c','d','b']i:=findlast(L,'b')! => i=5
i:=findlast(L,'f')! => i=0
Related topics
findfirst

Fair Isaac Corporation Proprietary Information

105

Chapter 3: Predefined functions and procedures

floor
Purpose
SynopsisRound a number to the next smallest integer.
function floor(r:real):integer

ArgumentrReal number to be rounded

Return value
Rounded value.
ExampleIn the following, i takes the value 5, j the value -7, and k the value 12:
i := floor(5.6)
j := floor(-6.7)
k := floor(12.3)

Related topics
ceil, round.

Fair Isaac Corporation Proprietary Information

106

Chapter 3: Predefined functions and procedures

fopen
Purpose
Synopsis

Open a file and make it the active input, output or error stream.
procedure fopen(f:string, mode:integer)

Arguments
fmode

The name of the file to be opened
The open mode that consists in a stream selection and optional flags. The stream is one of:
F_INPUT
Input stream (for reading)
F_OUTPUT Output stream (for writing)
F_ERROR
Error stream (for writing error messages)
Possible optional flags (to be combined with the stream selection):
F_APPEND Open for writing, appending new data to the end of the file (otherwise the file iscleared before opening)
F_TEXT
Text mode (the default)
F_BINARY Binary mode
F_LINBUF If open for writing, flushes buffer after end of each line (default when writing to a
console or for an error stream)
F_SILENT Do not display IO error messages

Further information
1. This procedure opens a file for reading or writing. If the operation succeeds, depending on the opening
mode, the file becomes the active input, output or error stream. The procedures write and writeln areused to write data to the default output stream and the functions read, readln, and fskipline areused to read data from the default input stream. Error messages are sent to the error stream.
2. The behavior of this function in case of an IO error (i.e. the file cannot be opened) is directed by thecontrol parameter ioctrl (see setparam): if the value of this parameter is ‘false’ (default value), theinterpreter stops. Otherwise, the interpreter ignores the error and continues. The error status of an IO
operation is stored in the control parameter iostatus (see getparam) which is 0 when the lastoperation has been executed successfully. Note that this parameter is automatically reset once its value
has been read using the function getparam. The behavior of IO operations after an unhandled error is
not defined.
3. The binary mode disables character encoding conversion (see section 2.16).
Related topics
fclose, fselect, getfid.

Fair Isaac Corporation Proprietary Information

107

Chapter 3: Predefined functions and procedures

fselect
Purpose
Synopsis

Select the active input, output or error stream.
procedure fselect(stream:integer)

Argument
stream The stream number
ExampleThe following saves the file ID of the default output before switching output to the file mylog.txt.
Subsequently, the file ID of the current output stream is saved and the default output is again selected.
def_out:= getfid(F_OUTPUT)
fopen("mylog.txt", F_OUTPUT)...
my_out:= getfid(F_OUTPUT)
fselect(def_out)

Further information
1. This procedure selects the given stream as the active input, output or error stream. The concerned
stream is designated by the opening status of the given stream (that is, if the given stream has been
opened for reading, it will be assigned to the default input stream). The stream number can be obtainedwith the function getfid.
2. The default input, output and error streams have respectively numbers 0, 1 and 2.
3. An IO error will be raised if the requested file ID does not exist.
Related topics
fclose, fopen, getfid, fwrite, fwriteln.

Fair Isaac Corporation Proprietary Information

108

Chapter 3: Predefined functions and procedures

fskipline
Purpose
Synopsis

Advance in the default input stream as long as comment lines are found.
procedure fskipline(filter:string)Argument
filterExampleList of comment signs

In the following, the first statement skips all lines beginning with either ‘#’ or ‘!’. The second statement
skips any following blank lines:
fskipline("!#")
fskipline("\n")Further information
This procedure advances in the input stream using the given list of comment signs as a filter. Eachcharacter of the given string is considered to be a symbol that marks the beginning of a comment line.
Note that the character ‘\n’ designates lines starting with nothing, that is, empty lines. During the parsing,spaces and tabulations are ignored.
Related topics
read, readln.

Fair Isaac Corporation Proprietary Information

109

Chapter 3: Predefined functions and procedures

fwrite, fwriteln
Purpose
Synopsis

Send an expression or list of expressions to the specified output stream.
procedure fwrite(fd:integer, e1:expr[, e2:expr...])
procedure fwriteln(fd:integer)
procedure fwriteln(fd:integer, e1:expr[, e2:expr...])

Argumentsfd
An output stream number
e1, e2,... Expression or list of expressions
Further information
1. These procedures are equivalent to calling fselect before using the corresponding output procedureand then restore the initial current stream with a second call to fselect.
2. The selected stream may also be an error stream.
Related topics
write, writeln, fselect, getfid.

Fair Isaac Corporation Proprietary Information

110Chapter 3: Predefined functions and procedures

getactPurpose
Synopsis

Get the activity value of a constraint.
function getact(c:linctr):realArgumentc

A linear constraint

Return value
Activity value or 0.
Further information
This function returns the activity value of a constraint if the problem has been solved successfully,
otherwise 0 is returned.
Related topics
getdual, getslack, getsol.

Fair Isaac Corporation Proprietary Information

111

Chapter 3: Predefined functions and procedures

getcoeff
Purpose
Synopsis

Get a constraint coefficient or constant term.
function getcoeff(c:linctr):realfunction getcoeff(c:linctr, x:mpvar):realfunction getcoeff(c:linctr, n:integer):realArgumentscxn

A linear constraint
A decision variable-1 for constant term, -2 for range lower bound

Return value
Coefficient of the variable or a constant term.
ExampleIn this example a single constraint with three variables is defined. The calls to getcoeff result in r
taking the value -1 and s taking the value -12.
declarations
x,y,z:mpvar
end-declarations
c:= 4⁎x + y -z <= 12
r:= getcoeff(c, z)
s:= getcoeff(c)Further information
This function returns the coefficient of a given variable in a constraint, or if no variable is given, theconstant term (= -RHS) of the constraint. The returned values correspond to a normalised constraint
representation with all variable and constant terms on the left side of the (in)equality sign.
Related topics
getcoeffs, getvars, setcoeff.

Fair Isaac Corporation Proprietary Information

112

Chapter 3: Predefined functions and procedures

getcoeffs
Purpose
Synopsis

Get all variable coefficients of a constraint.
procedure getcoeffs(c:linctr, a:array(set of mpvar) of real, s:set of
mpvar)

Argumentscas

A linear constraint
An array of reals indiced by decision variables
A set of decision variables

Further information
1. This procedure returns in the parameter a the coefficients of all variables of a constraint. After calling
this procedure, the coefficient of variable v of constraint c is a(v). The set s is used to specify for which
variables the coefficients have to be retrieved (if this set is empty all variables are considered).
2. If set s is empty all cells of array a are updated (i.e. cells corresponding to variables not included inconstraint c are set to 0). Otherwise only cells corresponding to elements of s are modified.
Related topics
getcoeffs, getcoeff

Fair Isaac Corporation Proprietary Information

113

Chapter 3: Predefined functions and procedures

getdualPurpose
Synopsis

Get the dual value of a constraint.
function getdual(c:linctr):realArgumentc

A linear constraint

Return value
Dual value or 0.
Further information
This function returns the dual value of a constraint if the problem has been solved successfully and theconstraint is contained in the problem, otherwise 0 is returned.
Related topics
getrcost, getslack, getsol.

Fair Isaac Corporation Proprietary Information

114

Chapter 3: Predefined functions and procedures

geteltPurpose
Synopsis

Get an element of a set or a list.
function getelt(e:set):type_of_efunction getelt(l:list):type_of_l

Arguments
e
l

A set
A listReturn value
An element of the set or list.
Further information
When applied to a range set or list this function behaves like getfirst. An error is generated if theargument of the function is empty.
Related topics
cutelt.

Fair Isaac Corporation Proprietary Information

115

Chapter 3: Predefined functions and procedures

geteltype
Purpose
Synopsis

Get the type ID of an element of a collection type.
function geteltype(u: union): integerfunction geteltype(tid: integer): integer

Argumentsutid

A unionA type ID

Return value
A type ID or -1 if the provided parameter is not a valid type ID or the union is not defined.
Exampledeclarations
MYSET=set of integers: MYSET
u1,u2,u3: any
end-declarations
...
u1:=s
u2:="bla"
writeln("ElType of MYSET: ", geteltype(MYSET.id),"\nElType of u1: ", u1.eltype,"\nElType of u2: ", u2.eltype,"\nElType of u3: ", u3.eltype)! = integer.id=1! = integer.id=1! = string.id=3! = -1Further information
1. This function retrieves the type ID of an element of a collection (array, set or list) represented by a type IDor the value stored in a union. If the referenced type is not a collection (i.e. it is a constant or a reference)
the type of the entity itself will be returned (that is the same value as gettypeid).
2. There are 2 versions of this routine: when used with a union the information reported comes from thecurrent value of this union (-1 is returned if the union is not initialized). If applied to an integer thefunction expects this integer to be a type ID (-1 is returned if this value does not correspond to a type ID).
Related topics
getstruct, gettypeid, geteltype.

Fair Isaac Corporation Proprietary Information

116

Chapter 3: Predefined functions and procedures

getfidPurpose
Synopsis

Get the stream number of the active input, output or error stream.
function getfid(stream:integer):integer

Argument
stream The stream to query:
F_INPUT
Input stream
F_OUTPUT Output stream
F_ERROR
Error stream
Return value
Stream number.
Further information
The returned value can be used as parameter for the function fselect.
Related topics
fselect.

Fair Isaac Corporation Proprietary Information

117

Chapter 3: Predefined functions and procedures

getfirst
Purpose
Synopsis

Get the first element of a range set or a list.
function getfirst(r:range):integerfunction getfirst(l:list):type_of_l

Argumentsrl

A range set
A listReturn value
The first element of the set or list.
ExampleIn this example the range set r is defined before its first and last elements are retrieved and displayed:declarations
r=2..8end-declarations...
writeln("First element of r: ", getfirst(r),"\nLast element of r: ", getlast(r))

Further information
When applied to a list, the type of the function is the type of the list. An error is generated if the argumentof the function is empty.
Related topics
getlast, cutfirst.

Fair Isaac Corporation Proprietary Information

118

Chapter 3: Predefined functions and procedures

getheadPurpose
Synopsis

Get a copy of the first elements of a list.
function gethead(l:list, o:integer):list

Argumentslo

A listNumber of elements to copy if >0 or number of elements to ignore if <0

Return value
A (partial) copy of the list.
ExampleL:=[1,2,3,4,5]
L2:=gethead(L,2)
L2:=gethead(L,-1)! => L2=[1,2]! => L2=[1,2,3,4]

Further information
This function does not alter its input list. If the second parameter is 0 an empty list is returned. If thesame parameter is larger than the size of the list the function returns a copy of the original list.
Related topics
gettailFair Isaac Corporation Proprietary Information

119Chapter 3: Predefined functions and procedures

getfname
Purpose
Synopsis

Get the file name associated to the active input, output or error stream.
function getfname(stream:integer):stringArgument
stream The stream to query:
F_INPUT
Input stream
F_OUTPUT Output stream
F_ERROR
Error stream
Return value
File name.

Fair Isaac Corporation Proprietary Information

120

Chapter 3: Predefined functions and procedures

getlastPurpose
Synopsis

Get the last element of a range set or a list.
function getlast(r:range):integerfunction getlast(l:list):type_of_l

Argumentsrl

A range set
A listReturn value
The last element of the set or list.
ExampleIn this example the range set r is defined before its first and last elements are retrieved and displayed:declarations
r=2..8end-declarations...
writeln("First element of r: ", getfirst(r),"\nLast element of r: ", getlast(r))

Further information
When applied to a list, the type of the function is the type of the list. An error is generated if the argumentof the function is empty.
Related topics
getfirst.

Fair Isaac Corporation Proprietary Information

121

Chapter 3: Predefined functions and procedures

getnbdimPurpose
Synopsis

Get the number of dimensions of an array.
function getnbdim(a:array):integer

Argumenta

An array

Return value
Number of dimensions of the array.

Fair Isaac Corporation Proprietary Information

122

Chapter 3: Predefined functions and procedures

getobjval
Purpose
Synopsis

Get the objective function value.
function getobjval:real

Return value
Objective function value or 0.
Further information
This function returns the objective function value if the problem has been solved successfully. If integer
feasible solution(s) have been found, the value of the best is returned, otherwise the value of the last LP
solved.
Related topics
getsol.

Fair Isaac Corporation Proprietary Information

123Chapter 3: Predefined functions and procedures

getparam
Purpose
Synopsis

Get the current value of a control parameter.
function getparam(name:string):integer|string|real|boolean

Argument
name

Name of the control parameter whose value is to be returned (case insensitive).

Return value
Current setting of the control parameter.

Fair Isaac Corporation Proprietary Information

124

Chapter 3: Predefined functions and procedures

Further information
1. Parameters whose values may be returned by this function include the settings of Mosel as well as thoseof any loaded module or package. The location of the parameter may be specified by prefixing its namewith the name of the module or package defining it (e.g. mmxprs.XPRS_verbose). The type of the
return value corresponds to the type of the parameter.
2. This function can be applied only to control parameters whose value can be accessed.
3. The name argument must be a constant string: a model parameter, variable or string expression cannot
be used as a control parameter name.
4. The following control parameters are supported by Mosel:
realfmt Default C printing format for real numbers (string)
zerotol zero tolerance in comparisons between reals (real)
txtztol zero tolerance is used when converting real values to their textual representation (Boolean)
ioctrl the interpreter ignores IO errors (Boolean)
iostatus status of the last IO operation (integer), which is 0 when the last operation has been
executed successfully. This parameter is automatically reset once its value has been read. Not
doing so may result in undefined behavior. When ioctrl is active the IO status must be read(and reset) after every IO operationnbread number of items recognized by the last read procedure or read in by the last initializations
block (integer)
readcnt generate per label counting when executing ‘initializations from’ blocks (Boolean)UTC
indicate whether the time functions return time expressed in local (false) or UTC (true) time
(Boolean)
autofinal indicate whether initialisation from blocks are finalizing sets (Boolean)
tmpdir the Mosel temporary directory (string)
workdir the current working directory of the model (string)
restrict active restrictions (integer). See Section 1.3.4 for further details.
modelname internal unique name of the model being executed.
modelnumber order number of the model being executed.
recloc indicate whether automatic recording of source location of constraints definitions is active(Boolean)
localedir directory where message catalogs are stored (string)lang current language (string)runparams parameter string used for the current execution (string)bimprefix list of bim file prefixes (string)
sharingstatus sharing status of the model (integer). This parameter is -1 if the model does notshare any data; 0 if the model shares data but no submodel is using it; 1 when shared data is inuse; 2 if the model is a submodel using shared data (see Section 8.2)
5. Function getparam may also be used to retrieve parser parameters. As opposed to the other parameters
whose value is computed at run time, these parameters are evaluated as soon as they are parsed:
parser_line number of the line being parsed (integer)parser_file current source file name (string)parser_date current local date (string)parser_time current local time (string)parser_UTCdate current UTC date (string)parser_UTCtime current UTC time (string)parser_version Mosel version (string)model_version Version of the model as given by the version directive (string)
Fair Isaac Corporation Proprietary Information

125

Chapter 3: Predefined functions and procedures

Related topics
setparam, getdsoparam.

Fair Isaac Corporation Proprietary Information

126Chapter 3: Predefined functions and procedures

getrcost
Purpose
Synopsis

Get the reduced cost value of a variable.
function getrcost(v:mpvar):realArgumentv

A decision variable

Return value
Reduced cost value or 0.
Further information
This function returns the reduced cost value of a variable if the problem has been solved successfully andthe variable is contained in the problem, otherwise 0 is returned.
Related topics
getslack, getsol, getdual.

Fair Isaac Corporation Proprietary Information

127

Chapter 3: Predefined functions and procedures

getreadcnt
Purpose
Synopsis

Get the number of items read in during last ‘initializations from’ for a given label.
function getreadcnt(l:string):integer

Argumentl

A labelReturn value
Number of items read in for label l.
Further information
Value 0 is returned if the given string does not correspond to a label or if control parameter readcnt has
not been set to true before execution of the initializations block.

Fair Isaac Corporation Proprietary Information

128

Chapter 3: Predefined functions and procedures

getreverse
Purpose
Synopsis

Duplicate and reverse a list.
function getreverse(l:list):list

Argumentl

A listReturn value
A reversed copy of the provided list.
ExampleL:=[1,2,3,4,5]
L2:=L.reverse! => L=[5,4,3,2,1]

Related topics
reverse.

Fair Isaac Corporation Proprietary Information

129

Chapter 3: Predefined functions and procedures

getsize
Purpose
Synopsis

Get the size of an array, set, list, constraint or string.
function getsize(a:array):integerfunction getsize(s:set):integerfunction getsize(l:list):integerfunction getsize(t:string):integerfunction getsize(c:linctr):integer

Arguments
a
s
l
t
c

An array
A set
A listA string
A linear constraint

Return value
Number of effective entries for an array, number of elements for a set or a list, number of characters for astring, number of terms for a constraint.
ExampleIn the following, a dynamic array is declared holding eight elements, of which only two are actually
defined. Calling getsize on this array returns 2 rather than 8. The length lw of the string w is 9.
declarations
a:dynamic array(1..8) of realw = "some text"
end-declarationsa(1):= 4a(5):= 7.2
la:= getsize(a)lw:= getsize(w)Further information
In the case of a dynamic array that has been declared with a maximal range this number may be smaller
than the size of the range, but it cannot exceed it. When used with a string, this function returns the lengthof the string (i.e. the number of characters it contains). If used with a linear constraint, this function
returns the number of terms of the constraint (the constant term is not taken into account).

Fair Isaac Corporation Proprietary Information

130Chapter 3: Predefined functions and procedures

getslack
Purpose
Synopsis

Get the slack value of a constraint.
function getslack(c:linctr):realArgumentc

A linear constraint

Return value
Slack value or 0.
Further information
This function returns the slack value of a constraint if the problem has been solved successfully and theconstraint is contained in the problem, otherwise 0 is returned.
Related topics
getdual, getrcost, getsol.

Fair Isaac Corporation Proprietary Information

131

Chapter 3: Predefined functions and procedures

getsolPurpose
Synopsis

Get the solution value of a variable or a linear expression (constraint).
function getsol(v:mpvar):realfunction getsol(c:linctr):realArgumentscv

A linear constraint
A decision variable

Return value
Solution value or 0.
Further information
This function returns the (primal) solution value of a variable if the problem has been solved successfully
and the variable is contained in the problem (otherwise 0). If used with a constraint, it returns theevaluation of the corresponding linear expression using the current solution.
Related topics
getdual, getrcost, getobjval.

Fair Isaac Corporation Proprietary Information

132

Chapter 3: Predefined functions and procedures

getstruct
Purpose
Synopsis

Get the structure of a type.
function getstruct(u: union): integerfunction getstruct(tid: integer): integer

Argumentsutid

A unionA type ID

Return value
Type structure as an integer. Possible structures are:
STRUCT_CONST
A constant
STRUCT_REF
A reference
STRUCT_ARRAY
An array
STRUCT_SET
A set
STRUCT_LIST
A listSTRUCT_ROUTINE A subroutine
STRUCT_NATTYPE A native type
STRUCT_PROBLEM A problem
STRUCT_RECORD
A record
STRUCT_USRTYPE A user type
STRUCT_UNION
A union-1
If the provided parameter is not a valid type ID or the union is not defined
Exampledeclarations
MYSET=set of integers: MYSET
u1,u2,u3: any
end-declarations
...
u1:=s
u2:="bla"
writeln("ElType of MYSET: ", getstruct(MYSET.id),"\nElType of u1: ", u1.struct,"\nElType of u2: ", u2.struct,"\nElType of u3: ", u3.struct)! = STRUCT_SET=12288! = STRUCT_SET=12288! = STRUCT_CONST=0! = -1Further information
1. This function retrieves the structure (constant, reference, array, set, list, or subroutine) of a type
represented by its ID or by the value stored in a union. The type ID of an element of a non-scalar type may
be obtained with geteltype.
2. When applied to the ID of a basic type (integer, real, string or boolean) this function will return
STRUCT_CONST although a variable of these types is a reference and a union may hold either a referenceor a constant for basic types.
3. There are 2 versions of this routine: when used with a union the information reported comes from thecurrent value of this union (-1 is returned if the union is not initialized). If applied to an integer thefunction expects this integer to be a type ID (-1 is returned if this value does not correspond to a type ID).

Fair Isaac Corporation Proprietary Information

133

Chapter 3: Predefined functions and procedures

Related topics
geteltype, gettypeid.

Fair Isaac Corporation Proprietary Information

134

Chapter 3: Predefined functions and procedures

gettailPurpose
Synopsis

Get a copy of the last elements of a list.
function gettail(l:list, o:integer):list

Argumentslo

A listNumber of elements to copy if >0 or number of elements to ignore if <0

Return value
A (partial) copy of the list.
ExampleL:=[1,2,3,4,5]
L2:=gettail(L,2)
L2:=gettail(L,-1)! => L2=[4,5]! => L2=[2,3,4,5]

Further information
This function does not alter its input list. If the second parameter is 0 an empty list is returned. If thesame parameter is larger than the size of the list the function returns a copy of the original list.
Related topics
getheadFair Isaac Corporation Proprietary Information

135

Chapter 3: Predefined functions and procedures

gettype
Purpose
Synopsis

Get the type of a constraint.
function gettype(c:linctr):integer

Argumentc

A linear constraint

Return value
Constraint type. Values applicable to any type of linear constraint are:
CT_EQ
Equality, ‘=’
CT_GEQ
Greater than or equal to, ‘ ≥ ’
CT_LEQ
Less than or equal to, ‘ ≤ ’
CT_RNG
Range
CT_UNB
Non-binding constraint
CT_SOS1 Special ordered set of type 1
CT_SOS2 Special ordered set of type 2
Values applicable for unary constraints are:
CT_CONT Continuous
CT_INT
Integer
CT_BIN
BinaryCT_PINT Partial integer
CT_SEC
Semi-continuous
CT_SINT Semi-continuous integer
CT_FREE Free
Related topics
settype.

Fair Isaac Corporation Proprietary Information

136

Chapter 3: Predefined functions and procedures

gettypeid
Purpose
Synopsis

Get the type ID of the value of a union.
function gettypeid(u: union): integer

Argumentu

A unionReturn value
A type ID, 0 if the information is not available or -1 if the union is not defined.
Exampledeclarations
MYSET=set of integers: MYSET
u1,u2,u3,u4: any
end-declarations
...
u1:=s
u2:={1,2,3}
u4:=13.3
writeln("ElType of u1: ", u1.typeid,"\nElType of u4: ", u4.typeid,"\nElType of u2: ", u2.typeid,"\nElType of u3: ", u3.typeid)! = MYSET.id! = real.id=2! = 0! = -1Further information
1. This function retrieves the type ID of the value stored in a union. This information is always defined if thevalue is a scalar (i.e. a constant or a reference) but it will be available for a structured type only if thevalue comes from an entity that is defined as an instance of a defined user type.
2. When the function returns 0, the properties of the value stored in the union can still be obtained via
getstruct and geteltype.
Related topics
getstruct, geteltype.

Fair Isaac Corporation Proprietary Information

137

Chapter 3: Predefined functions and procedures

getvars
Purpose
Synopsis

Get the set of variables of a constraint.
procedure getvars(c:linctr,s:set of mpvar)

Argumentscs
ExampleA linear constraint
A set of decision variables

The following returns the set of variables in a linear constraint to the set variable vset, and then loops
through them to find their solution values:
declarations
c:linctr
vset: set of mpvar
end-declarations
getvars(c,vset)
forall(x in vset) writeln(getsol(x))

Further information
This procedure returns in the parameter s the set of variables of a constraint. Note that this procedure
replaces the content of the set.
Related topics
getcoeffs, getcoeff

Fair Isaac Corporation Proprietary Information

138

Chapter 3: Predefined functions and procedures

isdefined
Purpose
SynopsisCheck whether an entity is defined.
function isdefined(v:reference):boolean

Argumentv

A variable of a reference type

Return value
true if the provided entity is defined.
Exampledeclarations
f: function(real):real
u: anyend-declarations
writeln(isdefined(u))
u:=1.5
writeln(isdefined(u))
writeln(isdefined(->f))
f:=->cos
writeln(isdefined(->f))
reset(->f)
writeln(isdefined(->f))! = false! = true! = false! = true! = false

Further information
This function returns true if the provided entity is not a NULL reference and, in the case of a union or asubroutine, if it has been assigned a value.

Fair Isaac Corporation Proprietary Information

139

Chapter 3: Predefined functions and procedures

isdynamic
Purpose
SynopsisCheck whether an array, set, or list is dynamic.
function isdynamic(a:array):booleanfunction isdynamic(s:set):booleanfunction isdynamic(l:list):boolean

Argumentsasl

An array
A set
A listReturn value
true if the provided entity is dynamic.
Further information
This function returns true when applied to sparse arrays (i.e. declared either as dynamic or hashmap).

Fair Isaac Corporation Proprietary Information

140

Chapter 3: Predefined functions and procedures

iseof
Purpose
Synopsis

Test whether the end of the default input stream has been reached.
function iseof:boolean

Return value
true if the end of the default input stream has been reached, false otherwise.
ExampleThe following opens a datafile of integers, reads one from each line and prints it to the console until theend of the file is reached:declarations
d:integer
end-declarations...
fopen("datafile.dat", F_INPUT)
while(not iseof) do
readln(d)writeln(d)end-dofclose(F_INPUT)

Further information
This function returns the “end of file” status of the active input stream.
Related topics
fclose, fopen.

Fair Isaac Corporation Proprietary Information

141

Chapter 3: Predefined functions and proceduresisfinite
Purpose
Synopsis

Test whether a real value is finite.
function isfinite(r: real):boolean

Argumentr

The value to test

Return value
true if the value is neither (-)INFINITY nor NAN.
Further information
The call isfinite(v) is equivalent to (not isnan(v) and not isinf(v)).
Related topics
setmatherr, isnan, isinf.

Fair Isaac Corporation Proprietary Information

142

Chapter 3: Predefined functions and procedures

ishiddenPurpose
Synopsis

Test whether a constraint is hidden.
function ishidden(c:linctr):boolean

Argumentc

A linear constraint

Return value
true if the constraint is hidden, false otherwise.
Further information
This function tests the current status of a constraint. At its creation a constraint is added to the current
problem, but using the function sethidden it may be hidden. This means, the constraint will not be
contained in the problem that is solved by the optimizer but it is not deleted from the definition of the
problem in Mosel.
Related topics
sethidden.

Fair Isaac Corporation Proprietary Information

143

Chapter 3: Predefined functions and procedures

isinf
Purpose
Synopsis

Test whether a real value is an infinity.
function isinf(r: real):boolean

Argumentr

The value to test

Return value
true if the value is INFINITY or -INFINITY.
Further information
When the parameter matherr is set to true (see setparam) mathematical functions return theconstant NAN or INFINITY instead of failing. This function can be used to identify incorrect results(direct comparison to NAN or INFINITY always fails).
Related topics
setmatherr, isnan, isfinite.

Fair Isaac Corporation Proprietary Information

144

Chapter 3: Predefined functions and procedures

isnan
Purpose
Synopsis

Test whether a real value is valid.
function isnan(r: real):boolean

Argumentr

The value to test

Return value
true if the value is not valid (i.e. it corresponds to Not A Number).
Further information
When the parameter matherr is set to true (see setparam) mathematical functions return theconstant NAN or INFINITY instead of failing. This function can be used to identify incorrect results(direct comparison to NAN or INFINITY always fails).
Related topics
setmatherr, isinf, isfinite.

Fair Isaac Corporation Proprietary Information

145

Chapter 3: Predefined functions and procedures

isodd
Purpose
Synopsis

Test whether an integer is odd.
function isodd(i:integer):boolean

Argumenti

An integer number

Return value
true if the given integer is odd, false if it is even.

Fair Isaac Corporation Proprietary Information

146

Chapter 3: Predefined functions and proceduresln
Purpose
Synopsis

Get the natural logarithm of a value.
function ln(r:real):realArgumentrReal value the function is applied to. This value must be positive.

Return value
Natural logarithm of the argument.
ExampleThe following example provides a function for calculating logarithms to any (positive) base:function logn(base,number: real):realif (number > 0 and base > 0) thenreturned:= ln(number)/ln(base)else
exit(1)
end-ifend-function

Related topics
exp, log, sqrt.

Fair Isaac Corporation Proprietary Information

147

Chapter 3: Predefined functions and procedures

localsetparam
Purpose
Synopsis

Set the value of a control parameter locally to a subroutine.
procedure localsetparam(name:string,val:integer|string|real|boolean)

Arguments
namevalName of a control parameter (case insensitive).
New value for the control parameter

Further information
1. This procedure is a special version of setparam that can only be used from a subroutine: the effect ofthe parameter change is reverted at the end of the subroutine.
2. Independently of the location of the call to this procedure and whether other modifications are performedon the parameter (using for instance setparam) the original value of the parameter is saved at the
beginning of the execution of the routine and restored before its termination.
Related topics
setparam, setdsoparam, restoreparam.

Fair Isaac Corporation Proprietary Information

148

Chapter 3: Predefined functions and procedures

log
Purpose
Synopsis

Get the base 10 logarithm of a value.
function log(r:real):realArgumentrReal value the function is applied to. This value must be positive.

Return value
Base 10 logarithm of the argument.
Related topics
exp, ln, sqrt.

Fair Isaac Corporation Proprietary Information

149

Chapter 3: Predefined functions and procedures

makesos1, makesos2
Purpose
SynopsisCreates a special ordered set (SOS) using a set of decision variables and a linear constraint.
procedure makesos1(cs:linctr, s:set of mpvar, c:linctr)
procedure makesos1(s:set of mpvar, c:linctr)
procedure makesos2(cs:linctr, s:set of mpvar, c:linctr)
procedure makesos2(s:set of mpvar, c:linctr)

Argumentscssc
ExampleA linear constraint
A set of decision variables
A linear constraint

The following generates the SOS1 set mysos based on the linear constraint rr. The resulting set
contains the variables x, y, and z with the weights 0,2, and 4.
declarations
x,y,z: mpvar
rr,mysos: linctr
end-declarations
rr:= 2⁎y+4⁎z
makesos1(mysos, {x,y,z}, rr)

Further information
These procedures generate a SOS set containing the decision variables of the set s with the coefficientsof the linear constraint c. The resulting set it assigned to cs if it is provided. Note that these procedures
simplify the generation of SOS with weights of value 0.

Fair Isaac Corporation Proprietary Information

150

Chapter 3: Predefined functions and procedures

maxlistPurpose
Synopsis

Get the maximum value of a list of integers or reals.
function maxlist(i1:integer, i2:integer[, i3:integer...]):integerfunction maxlist(r1:real, r2:real[, r3:real...]):realArguments
i1,i2,...
r1,r2,...

List of integer numbers
List of real numbers

Return value
Largest value in the given list.
ExampleIn the following r is assigned the value 7 by maxlist:
r:= maxlist(-1, 4.5, 2, 7, -0.3)

Further information
The returned type corresponds to the type of the input.
Related topics
minlist.

Fair Isaac Corporation Proprietary Information

151

Chapter 3: Predefined functions and procedures

memoryusePurpose
Synopsis

Get an estimate of the memory usage of an entity, a module or the entire model.
function memoryuse:realfunction memoryuse(ent:any entity):realfunction memoryuse(mname:string):realArguments
ent
An entity
mname A Module nameReturn value
An estimate of the memory usage in bytes or -1 if the evaluation cannot be performed.
Further information
1. When used with no argument this function returns the total amount of memory used by the runningmodel including the loaded modules (if they implement the functionality). A constant string is interpreted
as the name of a module: the returned value is the memory consumed by this module that must be
currently used by the model.
2. For entities of type integer, real, boolean and mpvar the value returned is the constant amount ofmemory required by a variable of the corresponding type. For a reference to a string or linctr theeffective memory used by the internal datastructure is returned. In the case of a set or a list only thememory used to represent the collection is accounted, not its content. However the value reported for anarray or record includes the memory used by the content of the structure except for strings.
Related topics
getmodpropnum.

Fair Isaac Corporation Proprietary Information

152

Chapter 3: Predefined functions and procedures

minlistPurpose
Synopsis

Get the minimum value of a list of integers or reals.
function minlist(i1:integer, i2:integer[, i3:integer...]):integerfunction minlist(r1:real, r2:real[, r3:real...]):realArguments
i1,i2,...
r1,r2,...

List of integer numbers
List of real numbers

Return value
Smallest value in the given list.
ExampleIn the following r is assigned the value -1 by maxlist:
r:= minlist(-1, 4.5, 2, 7, -0.3)

Further information
The returned type corresponds to the type of the input.
Related topics
maxlist.

Fair Isaac Corporation Proprietary Information

153

Chapter 3: Predefined functions and procedures

newmuid
Purpose
Synopsis

Generate a unique identifier.
function newmuid:string

Return value
An identifier string.
Further information
This function returns a string of the form muid#_xxx where # is an execution number in hexadecimal(specific to this model execution) and xxx a random hexadecimal number. It is guaranteed that eachgenerated value does not correspond to any symbol of the model and that it will never be returned again.

Fair Isaac Corporation Proprietary Information

154

Chapter 3: Predefined functions and procedures

publishPurpose
Synopsis

Publish a symbol.
procedure publish(name:string, ref:string, external or structured)

Arguments
namerefSymbol to identify the object
A reference to an object of an external type, a structure (e.g. set, list or array) or a string

Further information
1. This procedure can be used to publish an object in the model dictionary such that it can be found by nativecode using name. Any entity (including local and private) can be exposed with this routine as long as it isof a referenced type (basically any type except integer, real and boolean). If a string variable is used the
published symbol corresponds to a string constant initialized with the current value of this variable.
2. The provided name must be a valid identifier that is not yet being used by the model as symbol name(including entity and subroutine names). In case of error the procedure raises an IO error.
Related topics
unpublish, newmuid.

Fair Isaac Corporation Proprietary Information

155

Chapter 3: Predefined functions and procedures

randomPurpose
Synopsis

Generate a random number.
function random:real

Return value
A randomly generated number in the interval [0,1).
ExampleIn the following i is assigned a random integer value between 1 and 10:
i:= integer(round((10⁎random)+0.5))

Further information
Each model uses its own generator which is randomly initialized when the model execution starts. The
sequence may also be reset using procedure setrandseed.
Related topics
setrandseed.

Fair Isaac Corporation Proprietary Information

156

Chapter 3: Predefined functions and procedures

read, readln
Purpose
Synopsis

Read in formatted data from the active input stream.
procedure read(e1:expr[, e2:expr...])
procedure readln
procedure readln(e1:expr[, e2:expr...])

Argument
e1, e2,... Expression or list of expressions of basic type
ExampleThe following reads (possible split over several lines) 12 45 word, followed by toto(12 and45)=word:
declarations
i,j:integers:string
ts:array (range,range) of string
end-declarations
read(i, j, s)
readln("toto(", i, "and", j, ")=", ts(i,j))

Further information
1. These procedures assign the data read from the active input stream to the given symbols or try to matchthe given expressions with what is read from the input stream. If ei is a symbol that can be assigned avalue, the procedure tries to recognise from the input stream a constant of the required type and, if
successful, assigns the resulting value to ei. If ei is a constant or a symbol that cannot be reassigned,
the procedure tries to read in a constant of the required value and succeeds if the resulting value
corresponds to ei. These procedures do not fail but set the control parameter nbread to the number of
items actually recognized.
2. Note that the read procedures are based on the lexical analyser of Mosel: items are separated by spaces
and a string that contains spaces must be quoted using either single or double quotes (the quotes areautomatically removed once the string has been identified).
3. The procedure readln expects all the items to be recognized to be contained in single line. The function
read ignores changes of line. If the procedure readln is used without parameters it skips the end of thecurrent line.
Related topics
write, writeln, readtextline.

Fair Isaac Corporation Proprietary Information

157

Chapter 3: Predefined functions and procedures

reset
Purpose
Synopsis

Reset an entity.
procedure reset(x:resettable entity)

Argumentx

A reference to a set, a list, an array, a union, a record, an object of an external type or a problem

Further information
Only types supporting the ’copy’ operation (i.e. they can be assigned a value) can be reset, as aconsequence, a record can be reset only if all its fields can also be reset. The effect of this routine
depends on the type of the object, typically the object returns to its state just after being created. For
instance, applying it to an mpproblem will clear the problem by detaching all constraints it contains.
Related topics
delcell.

Fair Isaac Corporation Proprietary Information

158

Chapter 3: Predefined functions and procedures

restoreparam
Purpose
Synopsis

Restore the value of a control parameter.
procedure restoreparam(name:string)Argument
name

Name of a control parameter (case insensitive).

Further information
1. This procedure can only be used from a subroutine to restore the value of a parameter to its state at the
beginning of the routine.
2. Independently of the location of the call to this procedure and whether modifications are performed on
the parameter (using for instance setparam) the original value of the parameter is saved at the
beginning of the execution of the routine and restored before its termination.
Related topics
setparam, setdsoparam, localsetparam.

Fair Isaac Corporation Proprietary Information

159

Chapter 3: Predefined functions and procedures

reverse
Purpose
Synopsis

Reverse a list.
procedure reverse(l:list)

Argumentl

A listExampleL:=[1,2,3,4,5]
reverse(L)! => L=[5,4,3,2,1]
reverse(L)! => L=[1,2,3,4,5]
Related topics
getreverse.

Fair Isaac Corporation Proprietary Information

160

Chapter 3: Predefined functions and procedures

round
Purpose
SynopsisRound a number to the nearest integer.
function round(r:real):integer

ArgumentrReal number to be rounded

Return value
Rounded value.
ExampleIn the following, i takes the value 6, j the value -7, and k the value 12:
i := round(5.5)
j := round(-6.7)
k := round(12.3)

Related topics
ceil, floor.

Fair Isaac Corporation Proprietary Information

161

Chapter 3: Predefined functions and procedures

setcoeff
Purpose
Synopsis

Set the coefficient of a variable or the constant term.
procedure setcoeff(c:linctr, x:mpvar, r:real)procedure setcoeff(c:linctr, r:real)

Argumentscxr
ExampleA linear constraint
A decision variable
Coefficient or constant term

The following declares a constraint c and then changes some of its terms:
declarations
x,y,z: mpvar
end-declarations
c:= 4⁎x + y -z <= 12
setcoeff(c, y, 2)
setcoeff(c, 8.1)
The constraint is now 4 · x + 2 · y – z ≤ –8.1.

Further information
If a variable is given then this procedure sets the coefficient of this variable in the constraint to the given
value. Otherwise, it sets the constant term of the constraint.
Related topics
getcoeff.

Fair Isaac Corporation Proprietary Information

162

Chapter 3: Predefined functions and procedures

sethidden
Purpose
Synopsis

Hide or unhide a constraint.
procedure sethidden(c:linctr, b:boolean)

Argumentscb

ExampleA linear constraint
Constraint status:
true
Hide the constraint
false
Unhide the constraint

THe following defines a constraint and then sets it as hidden:
declarations
x,y,z: mpvar
end-declarations
c:= 4⁎x + y -z <= 12sethidden(c, true)

Further information
At its creation a constraint is added to the current problem, but using this procedure it may be hidden.
This means that the constraint will not be contained in the problem that is solved by the optimizer but it is
not deleted from the definition of the problem in Mosel. Function ishidden can be used to test thecurrent status of a constraint.
Related topics
ishidden.

Fair Isaac Corporation Proprietary Information

163

Chapter 3: Predefined functions and procedures

setioerr
Purpose
Synopsis

Raise an IO error.
procedure setioerr(msg:string)Argument
msg

Error message to display (or an empty string)

Further information
This function sets the control parameter iostatus (see getparam) such that an IO error is raised. If IO
errors are not handled by the model (see setparam), the execution is interrupted.
Related topics
setmatherr.

Fair Isaac Corporation Proprietary Information

164

Chapter 3: Predefined functions and procedures

setmatherr
Purpose
Synopsis

Raise a Math error.
procedure setmatherr(msg:string)Argument
msg

Error message to display (or an empty string)

Further information
If mathematical errors are not handled by the model (see setparam), the execution is interrupted. A
function ending with a call to this routine may set its return value to NAN or INFINITY in order to indicate
its error status.
Related topics
setioerr, isnan, isinf, isfinite.

Fair Isaac Corporation Proprietary Information

165

Chapter 3: Predefined functions and procedures

setname
Purpose
Synopsis

Associate a matrix name to a constraint or variable.
procedure setname(c:linctr, n:string)procedure setname(v:mpvar, n:string)Argumentscvn

A linear constraint
A decision variable
Name given to the constraint or variable

Further information
1. When exporting a problem to a matrix file, constraint/variable names are deduced from the global public
symbols: anonymous and local entities are usually named after their row/column number in the matrix.
This procedure makes it possible to give a name to these entities.
2. If the given name starts with the ’#’ character, the generated matrix name will include the order numberof the constraint or variable in the matrix.
Related topics
exportprob.

Fair Isaac Corporation Proprietary Information

166

Chapter 3: Predefined functions and procedures

setparam
Purpose
Synopsis

Set the value of a control parameter.
procedure setparam(name:string,val:integer|string|real|boolean)

Arguments
namevalExampleName of a control parameter (case insensitive).
New value for the control parameterSee example of function getparam.

Fair Isaac Corporation Proprietary Information

167

Chapter 3: Predefined functions and procedures

Further information
1. Control parameters include the settings of Mosel as well as those of any loaded module or package. The
location of the parameter may be specified by prefixing its name with the name of the module or package
defining it (e.g. mmxprs.XPRS_verbose). The type of the value must correspond to the type expectedby the parameter.
2. This procedure can be applied only to control parameters the value of which can be modified.
3. The name argument must be a constant string: a model parameter, variable or string expression cannot
be used as a control parameter name.
4. The following control parameters, supported by Mosel, can be altered with this procedure:
realfmt Default C printing format for real numbers (string, default: "%.10g")
zerotol zero tolerance in comparisons between reals (non-negative real strictly smaller than 1, default:
1.0e-13), see Section 2.7.7. This parameter is also used when displaying reals if the parametertxtztol is true: any value smaller than the zero tolerance is handled like the zero constanttxtztol decide whether values smaller than the zero tolerance must be reported as the zero constantwhen converting a real value to its textual representation (Boolean, default: true)
ioctrl specify whether the interpreter ignores IO errors (Boolean, default: false). When ioctrl isenabled it is required to get (and reset) the iostatus parameter (see getparam) after every IO
operation. Not doing so may result in undefined behavior
mathctrl specify whether the interpreter ignores Maths errors (Boolean, default: false)
readcnt generate per label counting when executing ‘initializations from’ blocks (Boolean, default:
false)
UTC
indicate whether the time functions return time expressed in local (false) or UTC (true) time
(Boolean, default: false)
autofinal indicate whether initialisation from blocks are finalizing sets (Boolean, default: true or
false if compiler option noautofinal is used)
workdir specify the current working directory of the model (string, initialised with the current working
directory of the Mosel instance). The provided value can be a relative path (e.g. "../somedir")recloc enable (or disable) automatic recording of source location of constraints definitions (Boolean,default: false). This parameter can be set to true only if the model has been compiled with
option -G; it makes it possible the creation of meaningful constraint names when exporting amatrix (see exportprob)
localedir directory where message catalogs are stored (string, default: "./locale")bimprefix list of bim file prefixes (string). This parameter is used to locate packages when compilinga model (compile) and loading a bim file (load), see Section 2.3.1.
5. The parameter realfmt requires a format of the form %[f][w][.p]c where f (flags) is an optional
string of 1 to 3 characters from the list ’#0 -+’; w (width) an optional string of 1 to 3 digits (the first one
cannot be 0); p (precision) an optional string of 1 to 2 digits and c (conversion specifier) a character fromthe list ’eEfgGaAjy’ (see formattext for further details). The conversion specifiers j and y are
Mosel extensions to the C standard that support flags ’0 -+’ and the optional width: they produce areversible textual representation of the real number (i.e. converting the string back to real restores theexact original value). The format ’j’ generates a decimal notation similar to the specification ECMA-262(e.g. "123.456") while the format ’y’ produces a scientific notation in all cases (e.g. "1.2345e2").
Related topics
getparam, setdsoparam, localsetparam, restoreparam.

Fair Isaac Corporation Proprietary Information

168

Chapter 3: Predefined functions and procedures

setrandseed
Purpose
Synopsis

Initialize the random number generator.
procedure setrandseed(s:integer)

Arguments

Seed value

Further information
This procedure sets its argument as the seed for a new sequence of pseudo-random numbers to be
returned by the function random.
Related topics
random.

Fair Isaac Corporation Proprietary Information

169

Chapter 3: Predefined functions and procedures

setrange
Purpose
Synopsis

Set the domain range of a constraint.
procedure setrange(c:linctr, lb:real, ub:real)

Argumentsclbub
ExampleA linear constraint expression
Lower boundUpper bound

The following sets the domain of the x variable and defines c as a range constraint.
declarations
x,y,z: mpvar
c: linctr
end-declarations
c:= 2⁎y+4⁎z+5
setrange(x,3,10)
setrange(c,1,30)! 3<=x<=10! -4<=2⁎y+4⁎z<=25

Further information
1. If the parameter c is a linear expression a new anonymous range constraint is added to the problem.
Otherwise, the provided constraint is turned into a range constraint (and added to the problem if required).
2. This procedure changes the type of the provided constraint to CT_RNG, stores the provided lower boundas an external information and records the upper bound as the constant term of the constraint. As aconsequence defining the range of a constraint modifies its constant term, this has to be taken into
account if a range constraint is converted to another type or used as part of a linear expression.

Fair Isaac Corporation Proprietary Information

170

Chapter 3: Predefined functions and procedures

settype
Purpose
Synopsis

Set the type of a constraint.
procedure settype(c:linctr, type:integer)

Argumentsctype

A linear constraint
Constraint type

Further information
The type (type) of a linear constraint may be set to one of:
CT_EQ Equality, ‘=’
CT_GEQ Greater than or equal to, ‘ ≥ ’
CT_LEQ Less than or equal to, ‘ ≤ ’
CT_UNB Non-binding constraint
CT_SOS1 Special ordered set of type 1
CT_SOS2 Special ordered set of type 2
Values applicable for unary constraints only are:
CT_CONT Continuous
CT_INT Integer
CT_BIN Binary
CT_PINT Partial integer
CT_SEC Semi-continuous
CT_SINT Semi-continuous integer
CT_FREE Free
Related topics
gettype

Fair Isaac Corporation Proprietary Information

171

Chapter 3: Predefined functions and proceduressin
Purpose
Synopsis

Get the sine of a value.
function sin(r:real):realArgumentrReal number to which to apply the trigonometric function

Return value
Sine value of the argument.
Related topics
arctan, cos.

Fair Isaac Corporation Proprietary Information

172

Chapter 3: Predefined functions and procedures

splithead
Purpose
Synopsis

Split a list returning the first elements.
function splithead(l:list, o:integer):list

Argumentslo

A listNumber of elements to remove if >0 or number of elements to keep if <0

Return value
The list of elements removed.
ExampleL:=[1,2,3,4,5]
L2:=splithead(L,2)
L2:=splithead(L,-1)! => L=[3,4,5] L2=[1,2]! => L=[5] L2=[3,4]Further information
If the second parameter is 0, the list is unchanged and an empty list is returned. If the same parameter islarger than the size of the list, all elements are deleted and the function returns a copy of the original list.
Related topics
splittailFair Isaac Corporation Proprietary Information

173

Chapter 3: Predefined functions and procedures

splittailPurpose
Synopsis

Split a list returning the last elements.
function splittail(l:list, o:integer):list

Argumentslo

A listNumber of elements to remove if >0 or number of elements to keep if <0

Return value
The list of elements removed.
ExampleL:=[1,2,3,4,5]
L2:=splittail(L,2)
L2:=splittail(L,-1)! => L=[1,2,3] L2=[4,5]! => L=[1] L2=[2,3]Further information
If the second parameter is 0, the list is unchanged and an empty list is returned. If the same parameter islarger than the size of the list, all elements are deleted and the function returns a copy of the original list.
Related topics
splithead

Fair Isaac Corporation Proprietary Information

174

Chapter 3: Predefined functions and procedures

sqrt
Purpose
Synopsis

Get the positive square root of a value.
function sqrt(r:real):realArgumentrReal value the function is applied to. This value must be non-negative.

Return value
Square root of the argument.
Related topics
abs, exp, ln, log.

Fair Isaac Corporation Proprietary Information

175

Chapter 3: Predefined functions and procedures

strfmtPurpose
SynopsisCreate a formatted string from a string or a number.
function strfmt(str:string,len:integer):string
function strfmt(i:integer, len:integer):string
function strfmt(r:real, len:integer):string
function strfmt(r:real, len:integer, dec:integer):stringArguments
str
i
r
len

dec

String to be formatted
Integer to be formatted
Real to be formatted
Reserved length (may be exceeded if given string is longer, in this case the string is always left
justified).
<0
Left justified within reserved space>0
Right justified within reserved space0
Use defaults
Number of digits after the decimal point

Return value
Formatted string.
ExampleThe following:
writeln("text1", strfmt("text2",8), "text3")
writeln("text1", strfmt("text2",-8), "text3")
r:=789.123456
writeln(strfmt(r,0)," ", strfmt(r,4,2), strfmt(r,8,0))
produces this output:
text1
text2text3
text1text2
text3
789.123 789.12

789

Further information
1. This function creates a formatted string from a string or an integer or real number. It can be used at any
place where strings may be used. Its most likely use is for generating printed output (in combination withwrite and writeln).
2. If the resulting string is longer than the reserved space it is not cut but printed in its entirety, overflowing
the reserved space to the right.
Related topics
write, writeln.

Fair Isaac Corporation Proprietary Information

176

Chapter 3: Predefined functions and procedures

substrPurpose
Synopsis

Get a substring of a string.
function substr(str:string, i1:integer, i2:integer):stringArguments
str
i1
i2

StringStarting position of the substring
End position of the substring

Return value
Substring of the given string.
Examplewrite(substr("Example text", 3, 10))
This outputs the text: ample te
Further information
This function returns the substring from the i1th to the i2th character of a given string (the counting starts
from 1). This function returns an empty string if the bounds are not compatible with the string (e.g.
starting position larger than the length of the string) or inconsistent (e.g. starting position after end
position).

Fair Isaac Corporation Proprietary Information

177

Chapter 3: Predefined functions and procedurestimestamp
Purpose
Synopsis

Generate a timestamp by combining the current UTC date and time.
function timestamp:real

Return value
The number of seconds since 1/1/1970 at midnight as a real.
Further information
1. This function corresponds to the expression (using UTC time):real(currentdate)⁎86400+currenttime/1000
2. A local time timestamp may be obtained using: getasnumber(datetime(SYS_NOW))
3. Refer to the module mmsystem for a set of dedicated types for handling date and time.
Related topics
currenttime,currentdate

Fair Isaac Corporation Proprietary Information

178

Chapter 3: Predefined functions and procedures

unpublish
Purpose
Synopsis

Unpublish a symbol.
procedure unpublish(name:string)Argument
nameSymbol to be removed from the dictionary

Further information
This procedure has the opposite effect of publish. If the given name does not correspond to apreviously published symbol no operation is performed.
Related topics
publish.

Fair Isaac Corporation Proprietary Information

179

Chapter 3: Predefined functions and procedures

versionnum, versionstr
Purpose
Synopsis

Version of Mosel, a module or package.
function versionnum(what:string):integerfunction versionstr(what:string):stringArgumentwhat

A module name, a package name, the string "xpress" or an empty string

Return value
A version number as a string formatted as "maj.min.rel" (with versionstr) or as an integer (withversionnum). An empty string or -1 is returned if the requested library cannot be found.
Further information
With an empty string these routines return the version of Mosel currently running, with the string"xpress" they give the version of the current FICO Xpress installation. Otherwise the argument is
expected to be the name of a module (no suffix or name ending with ".dso"), or the name of a package(name ending with ".bim"). In both cases the library must be currently used by the model. For a
package both imported and loaded at runtime packages are considered.

Fair Isaac Corporation Proprietary Information

180

Chapter 3: Predefined functions and procedures

write, writeln
Purpose
Synopsis

Send an expression or list of expressions to the active output stream.
procedure write(e1:expr[, e2:expr...])
procedure writeln
procedure writeln(e1:expr[, e2:expr...])

Argument
e1, e2,... Expression or list of expressions
ExampleThe following lines
Set1:={"first", "second", "fifth"}
write(Set1)! Print set contents without return
writeln! Print an empty line
b:=truewriteln("A real:", strfmt(7.1234, 4, 2), ", a Boolean:",b)! Output followed by return
produce this output:{`first', `second', `fifth'}
A real:7.12, a Boolean:true

Further information
These procedures write the given expression or list of expressions to the active output stream. The
procedure writeln adds the return character to the end of the output. Numbers may be formatted using
function strfmt (default formatting relies on parameters realfmt, zerotol and txtztol, seesetparam). Basic types are printed "as is". For elementary but non-basic types (linctr, mpvar) only
the address is printed. If the expression is a set or array, all its elements are printed.
Related topics
fwrite, fwriteln, read, readln, strfmt, formattext.

Fair Isaac Corporation Proprietary Information

181

II. Modules

CHAPTER 4

deployThis module defines two I/O drivers, deploy.csrc and deploy.exe for generating an executable programfrom a BIM file, along with two utility routines for accessing the program arguments with the Mosel
model. Its use is discussed in Section 2.19.

4.1 Procedures and functions
argc

Retrieve the number of arguments passed to a model executable.

p. 184argv

Retrieve an argument passed to a model executable.

p. 185

Fair Isaac Corporation Proprietary Information

183

Chapter 4: deploy

argc
Purpose
Synopsis

Retrieve the number of arguments passed to a model executable.
function argc: integer

Return value
Number of parameters passed to the command used for executing a model (counting the command
itself as the first).
Further information
This function makes it possible to access the program arguments when a model is run as an executablethat has been generated via the deploy.exe I/O driver (see Section 4.2.2). If the model is not run as an
executable but has instead been compiled to a standard BIM file then the returned value is always 1.
ExampleSee examples in Section 2.19.

Related topics
argv
ModuledeployFair Isaac Corporation Proprietary Information

184

Chapter 4: deploy

argv
Purpose
Synopsis

Retrieve an argument passed to a model executable.
function argv(ind: integer):stringArgumentindindex of the argument (positive integer)

Return value
Returns as a string the ith argument passed to the command used for executing a model.
Further information
This function makes it possible to access the program arguments when a model is run as an executablethat has been generated via the deploy.exe I/O driver (see Section 4.2.2). The number of arguments canbe retrieved via argc. If the model is not run as an executable but has instead been compiled to a
standard BIM file then there will be a single argument with the value mosel.
ExampleSee examples in Section 2.19.

Related topics
argc
ModuledeployFair Isaac Corporation Proprietary Information

185

Chapter 4: deploy

4.2 I/O drivers
The two I/O drivers provided by this module are designed to be used in combination with a Mosel
command compiling a model by applying them to the output filename. They are not intended to be usedin any other contexts.
deploy.⁎:filename[,p1[-z]=fp1[,...]]

4.2.1 Driver csrc
csrc:filename[,p1[-z]=fp1[,...]]

The csrc driver takes the following options:filename

Destination file name

p1[-z]=fp1 list of labels and filenames, the optional -z flag indicates that compression is to be used
Example:mosel comp mymodel.mos -o deploy.csrc:runmymod

This command produces a file runmymod.c that contains the model mymodel.mos in compiled (BIM)
form and a complete C program for executing it via the Mosel C Library API. The generated code needs tobe compiled into an executable for the targeted platform (see the makefile provided with the Mosel
Library API examples).

4.2.2 Driver exe
exe:filename[,p1[-z]=fp1[,...]]The exe driver takes the following options:filename

Destination file name

p1[-z]=fp1 list of labels and filenames, the optional -z flag indicates that compression is to be used
Example:mosel comp mymodel.mos -o deploy.exe:runmymod,MYFILE-z=otherfile.txt

Provided that a C compiler is available on the system, this command produces an executable for theplatform in which it is invoked (resulting in a file named runmymod on Unix platforms or runmymod.exe
under Windows). The executable serves for running the specified model, it also includes a second fileotherfile.txt in compressed form, identified via the model parameter MYFILE.
The generation of this executable is obtained by producing a C source using the deploy.csrc driverthat is compiled using the C-compiler installed on the system. This compiler can be specified by meansof the CC environment variable (default value: cl on Windows and cc on Posix systems) and its default
parameters can be selected with the environment variable CFLAGS. The location of the Xpress libraries is
automatically deduced from the running program that is expected to be part of a standard Xpress
installation.
For a full example, the reader is refered to the source of the moseldoc tool that is provided among theMosel examples of the Xpress distribution.

Fair Isaac Corporation Proprietary Information

186

Chapter 4: deploy

Note that the generated executable only includes the compiled model and the specified additional files, it
requires the same Xpress runtime dependencies (see the chapter Creating runtime distributions of theXpress Installation Guide) for its execution as what would be required for running the model after
compiling it into a standard BIM file.

Fair Isaac Corporation Proprietary Information

187

CHAPTER 5

mmetc
This compatibility module just defines the diskdata procedure required to use data files formatted for
mp-model from Mosel and provides a commercial discounting function. To use this module, the following
line must be included in the header of the Mosel model file:uses 'mmetc'

5.1 Procedures and functions
disc

Annual discount.

p. 189

diskdata

Read in or write an array or set of strings to a file.

p. 190Fair Isaac Corporation Proprietary Information

188

Chapter 5: mmetc

disc
Purpose
SynopsisAnnual discount.
function disc(a:real, t:real)

ArgumentsatDiscount factor, real number greater than -1
Time, real number

Return value
Annual discount value: 1/(1 + a)t–1 .
Further information
This function calculates the annual discount for the given period of time and discount factor.
Modulemmetc

Fair Isaac Corporation Proprietary Information

189

Chapter 5: mmetc

diskdata
Purpose
Synopsis

Read in or write an array or set of strings to a file.
procedure diskdata(format:integer, file:string, a:array)procedure diskdata(format:integer, file:string, s:set)procedure diskdata(format:integer, file:string, l:list)

Arguments
formatFormat options:dense data format
sparse data format
strings quoted with single quotes
strings are not quoted in the filewrite to a fileappend output to the end of an existing filetables are transposed
read from file (default)
skip zero values
use CSV format
skip first line (header) of the filesimilar to sparse format but indices are not read or written (only applies
to 1-dimension arrays indiced by ranges)
ETC_EMPTYNDX
missing indices are replaced by a default value
ETC_DATAFRAME dense data format for a 2-dimension array and first index as a range (forthe line numbers)
Several options may be combined using ‘+’.
Extended file nameArray to export or initialize
Set to export or initialize
List to export or initialize
ETC_DENSE
ETC_SPARSEETC_SGLQETC_NOQETC_OUTETC_APPENDETC_TRANSETC_INETC_NOZEROSETC_CSV
ETC_SKIPH
ETC_AUTONDX

file
a
s
l
ExampleThe following example declares two sets and two dynamic arrays. The array ar1 is read in from the filein.dat. Then both arrays, ar1 and ar2, are saved to the file out.dat (in sparse format) and finally thecontents of the set Set1 is appended to the file out.dat.
declarations
Set1: set of string
R: range
ar1,ar2: array(Set1,R) of real
end-declarations
diskdata(ETC_SPARSE, "in.dat", ar1)
diskdata(ETC_OUT, "out.dat", [ar1, ar2])
diskdata(ETC_OUT+ETC_APPEND, "out.dat", Set1)

Fair Isaac Corporation Proprietary Information

190

Chapter 5: mmetc

Further information
1. This procedure reads in data from a file or writes to a file, depending on the parameter settings. The fileformat used is compatible with the command DISKDATA of the modeler mp-model (unless the option
ETC_CSV is specified).
2. Only arrays lists and sets of basic and native types (including mpvar and linctr for writing) can beused with this procedure, in particular records are not supported.
3. If option "dataframe" is combined with "skiph" the array to be processed must be indiced by a range
and a set of strings. The second index is automatically populated with the column names of the header
row when reading (the same line is generated when writing).
4. In case of error the procedure raises an IO error.
Modulemmetc

Fair Isaac Corporation Proprietary Information

191

Chapter 5: mmetc

5.2 I/O drivers
This module provides the diskdata IO driver designed to be used as an interface for initializations
blocks for both reading and writing files formated for the diskdata procedure.

5.2.1 Driver diskdata
diskdata:[dense|sparse|autondx|dataframe;][sglq|noq|csv;][cols();][skiph;emptyndx;append;trans;nozeros;fsep=c;dsep=c]

The driver can only be used in ‘initializations’ blocks. In the opening part of the block, no file name has tobe provided, but general options can be stated at this point: they will be applied to all labels. In the block,each label entry is understood as the file name to use for the actual processing. Note that, before the file
name, one can add further options separated by comas or semicolons, that are effective to the particular
entry. Here, the csv option might be followed by a list of columns separated by commas and enclosed inparenthesis. This selection may also be achieved using the cols option. The columns are identified bytheir number (first column has index 1) and must be given in ascending order without duplicate. If the lastcolumn number is suffixed by the plus sign, the following columns will also be included in the selection(e.g. "csv(1,3+)" skips the second column). To use names, the option skiph must be used and thecolumn names are taken from the header row that is skipped through this option. When using skiph,column numbers need to be stated by prefixing the column number by # (even in this case columns mustbe given in ascending order).This column selection is ignored for a writing operation. The file name given
can use extended notation.
The diskdata driver takes the following options:dense

dense data format

sparsesparse data format

autondx

sparse data format with automatic indexation (applies only to 1-dimension arrays indicedby ranges)

autondx=st same as autondx but starting index is set to st (instead of 1)
dataframedense data format for a 2-dimension array and first index as a range (for the line numbers)

sglq

strings quoted with single quotes

noq

strings are not quoted in the filecsv

use CSV format: quoting and escaping with double quotes, all lines are processed (i.e.
characters ’!’ and ’&’ are ordinary symbols), all columns are interpreted as textcols(c1[,c2,...]) select a list of columns
skiph

When reading, the first line of the file is skipped, when writing, the first line of the file ispreserved (or a comment line is inserted if the file does not already exist)

emptyndx

When reading array indices an empty cell causes a failure. With this option empty cells are
replaced by the default value of the corresponding type (e.g. 0 for a numerical value)

appendappend output to the end of an existing filetranstables are transposed

nozeros

skip zero values

fsep=ccharacter used to separate fields. The default value is ","; tabulation or ";" are also
often employed

Fair Isaac Corporation Proprietary Information

192

Chapter 5: mmetc

dsep=ccharacter used as decimal separator (default: ".")

Example:declarations
Set1: set of string
ar1,ar2: array(Set1,range) of real
r: realend-declarations
initializations from "diskdata:"
ar1 as "sparse;csv(1,3,4);ind.dat"r as "r_init.dat"
end-initializations! Declare a set of strings! Declare two dynamic arrays! Declare a real value! Use 'diskdata' format for reading! Read `ar1' from 'in.dat' in sparse format! using CSV conventions and selecting columns 1,3 and 4! Initialize `r' from 'r_init.dat'

initializations to "diskdata:append" ! Use 'diskdata' format for output[ar1, ar2] as "out.dat"! Save two arrays in sparse format
Set1 as "out.dat"! Save set `Set1' to the same file
end-initializations

Fair Isaac Corporation Proprietary Information

193

CHAPTER 6

mmhttp
The module mmhttp makes it possible to communicate with external components via HTTP requests.
Both modes, client or server side, can be used in a Mosel model: the client routines allow a Mosel model
to send the HTTP requests GET, POST, PUT, PATCH or DELETE to a web service. A model may also act asa web service by starting the integrated HTTP server. In this mode, the model gets notified about
connections from remote clients via specific mmjobs events. The model can then reply to these requests
using a set of dedicated routines.
To use this module, the following line must be included in the header of the Mosel model file:uses 'mmhttp'6.1 New functionality for the Mosel language
6.1.1 The type reqqueue
The type reqqueue can be used to implement multithreaded HTTP servers: it represents a queue ofpending HTTP requests to be processed by the server. A queue of this type must be declared as a global
shared entity such that each cloned submodel of the master model can access it. A submodel ready tohandle a new request has to call httpreqpop in order to warn the queue manager of its availability andthen wait for an event. When the server receives a request that has to be processed by one of these
submodels it moves this request to the queue using httpreqpushlim or httpreqpush, as a result therequest is sent to one of the available submodels that is notified as if the request had been directly
received from the network (see Section 6.4.2). If no submodel is ready, the request is recorded in thequeue until a model becomes available for processing it.

6.2 Control parameters
The following parameters are defined by mmhttp:http_async

HTTP requests processing mode.

p. 195

http_browser

Path to the web browser.

p. 195

http_cookies

Handling of cookies.

p. 196

http_defpage

Default page of the web server.

p. 196

http_defport

Default server TCP port.

p. 196

http_expire

Expiration delay of open connections.

p. 196

http_freeasync

Number of available asynchronous connections.

p. 197

Fair Isaac Corporation Proprietary Information

194

Chapter 6: mmhttp

http_keephdr

Whether to keep HTTP headers in results.

p. 197

http_listenInterface used by server.

p. 197

http_maxasync

Maximum number of pending asynchronous requests.

p. 199http_maxconn

Maximum number of open connections.

p. 197

http_maxcontime

Maximum time for a connection.

p. 198

http_maxreq

Maximum number of waiting connections.

p. 198

http_maxreqtime

Maximum time for a connection.

p. 198

http_port

Server TCP port.

p. 199http_proxy

Proxy address.

p. 199http_proxyport

Proxy TCP port.

p. 199http_srvconfig

Server options.

p. 200

http_startwb

Decide whether to start a web browser with the server.

p. 200https_defport

Default secure server TCP port.

p. 200https_listenInterface used by secure server.

p. 201

https_port

Secure server TCP port.

p. 201

http_async
Description

This parameter selects the processing mode of the HTTP request functions(httpget|put|post|del). These functions return immediately after the connection to the server
has been established (without waiting for the reply by the server) when this parameter is set totrue. The model is notified about the completion of the request via an event of class
EVENT_HTTPEND.

Type

Boolean, read/write

Default value

false

Affects routines

httpdel, httpget, httppost, httpput, httppatch.

See also

http_maxasync.

Modulemmhttphttp_browser
Description

The path to a web browser to be executed when the parameter http_startwb is active.

Type

String, read/write

ValuesPath to a web browser

Affects routines

httpstartsrv.

See also

http_startwb.

ModulemmhttpFair Isaac Corporation Proprietary Information

195

Chapter 6: mmhttp

http_cookies
Description

Decides whether cookie management is enabled: when this parameter is set to true thecookie store is updated according to server replies and request headers are completed with therelevant cookies. Changing the value of this parameter does not affect the cookie store (i.e.
existing cookies are not modified).

Type

Boolean, read/write

Default value

false

Affects routines

httpdel, httpget, httppost, httpput, httppatch.

Modulemmhttphttp_defpage
Description

The default page is selected when the server receives a request not specifying any path (e.g.
"http://server/").

Type

String, read/write

ValuesThe label to be used as the default page. Selecting an empty string restores the default value

Default value"index.html"

Affects routines

httpstartsrv.

Modulemmhttphttp_defport
Description

This is the port number used by the web server upon its startup. If this parameter is 0, the port
number is selected automatically by the operating system (the actual port number can be
retrieved through parameter http_port).

Type

Integer, read/write

Values

Between 0 and 65535

Default value0

Affects routines

httpstartsrv.

See also

http_port.

Modulemmhttphttp_expire
Description

Connections held in the connection pool are automatically closed if they are not used for morethan the amount of time (in seconds) defined by this parameter.

Type

Integer, read/write

Values

Between 5 and 60 by steps of 5 seconds

Fair Isaac Corporation Proprietary Information

196

Chapter 6: mmhttp

Default value

5

See also

http_maxconn.

Modulemmhttphttp_freeasync
Description

Up to http_maxasync asynchronous requests can be used concurrently. This parameter
reports the current number of asynchronous requests that can still be initiated.

Type

Integer, read only

See also

http_maxasync.

Modulemmhttphttp_keephdr
Description

By default results of HTTP queries do not include the HTTP header lines. This parameter can beused to retrieve these header lines in addition to the result document (use httpgetheader toseparate the header from the effective result document).

Type

Boolean, read/write

Default value

false

Affects routines

httpdel, httpget, httppost, httpput, httppatch.

Modulemmhttphttp_listen
Description

This is the interface used by the web server upon its startup. The default value implies binding
to all available interfaces.

Type

String, read/write

Default value

0.0.0.0

Affects routines

httpstartsrv.

Modulemmhttphttp_maxconn
Description

This parameter defines the size of the connection pool: whenever an HTTP request is emitted
mmhttp tries to use one of the already open connections. After the end of the operation theconnection is saved into the pool (if the server supports this functionality). Setting thisparameter to 0 disables the pool (i.e. each query is executed on a new connection). When thisparameter is changed all connections of the pool are closed.

Type

Integer, read/write

Values

Between 0 and 8

Default value

4

Fair Isaac Corporation Proprietary Information

197

Chapter 6: mmhttp

See also

http_expire.

Modulemmhttphttp_maxcontime
Description

Maximum amount of time (in seconds) allowed for connecting to a HTTP server and send arequest. If the operation is longer than the specified duration the request is cancelled and theprocedure results in an IO error. A value of 0 disables this time limit.

Type

Integer, read/write

Default value0

See also

http_maxreqtime.

Affects routines

httpdel, httpget, httppost, httpput, httppatch.

Modulemmhttphttp_maxreq
Description

The maximum number of active concurrent connections the server is maintaining. Above thislimit, connections are rejected and clients are notified with the HTTP code 500.

Type

Integer, read/write

ValuesAt least 1

Default value

16

Affects routines

httpstartsrv.

Modulemmhttphttp_maxreqtime
Description

Maximum amount of time (in seconds) allowed for processing a request. If the operation islonger than the specified duration the request is cancelled and the procedure results in an IO
error. A value of 0 disables this time limit.

Type

Integer, read/write

Default value0

See also

http_maxcontime.

Affects routines

httpdel, httpget, httppost, httpput, httppatch.

ModulemmhttpFair Isaac Corporation Proprietary Information

198

Chapter 6: mmhttp

http_maxasync
Description

This parameter defines the maximum number of active asynchronous requests that can besent by a Mosel model. This parameter can only be changed if asynchronous mode is not
active and there is no active request.

Type

Integer, read/write

Values

Between 4 and 58

Default value

8

Affects routines

httpdel, httpget, httppost, httpput, httppatch.

See also

http_async, http_freeasync.

Modulemmhttphttp_port
Description

This parameter reports the port number currently used by the web server.

Type

Integer, read only

Affects routines

httpstartsrv.

See also

http_defport.

Modulemmhttphttp_proxy
Description

When this parameter is defined, HTTP connections are sent through this proxy server (insteadof establishing direct connections).

Type

Integer, read/write

Default value""

Affects routines

httpdel, httpget, httppost, httpput, httppatch.

See also

http_proxyport.

Modulemmhttphttp_proxyport
Description

The value of this parameter corresponds to the connection port of the proxy server (whendefined).

Type

Integer, read/write

Values

Between 1 and 65535

Default value

80

Affects routines

httpdel, httpget, httppost, httpput, httppatch.

See also

http_proxy.

ModulemmhttpFair Isaac Corporation Proprietary Information

199

Chapter 6: mmhttp

http_srvconfig
Description

This parameter specifies which request types are accepted by the HTTP server started from a
Mosel model. For instance, if the application will only process HTTP GET queries the value of
this parameter should be HTTP_GET. Moreover, if the flag HTTP_SSL is set, the server will also
listen for HTTPS connections and, if the flag HTTP_SSLONLY is used, only the HTTPS server
will be started (i.e. normal HTTP queries will be rejected). When an HTTPS server is started, theflag HTTP_CLTAUTH enables client authentication: clients are accepted only if they present a
known certificate.

Type

Integer, read/write

Default value

HTTP_DELETE+HTTP_GET+HTTP_POST+HTTP_PUT

Affects routines

httpstartsrv.

Modulemmhttphttp_startwb
Description

If this parameter is true a web browser pointing to the default page is launched just after the
web server starts.

Type

Boolean, read/write

Default value

false

Affects routines

httpstartsrv.

See also

http_browser.

Modulemmhttphttps_defport
Description

This is the port number used by the web secure server upon its startup. If this parameter is 0,
the port number is selected automatically by the operating system (the actual port number canbe retrieved through parameter https_port).

Type

Integer, read/write

Values

Between 0 and 65535

Default value0

Affects routines

httpstartsrv.

See also

https_port.

ModulemmhttpFair Isaac Corporation Proprietary Information

200

Chapter 6: mmhttp

https_listen
Description

This is the interface used by the secure web server upon its startup. The default value implies
binding to all available interfaces.

Type

String, read/write

Default value

0.0.0.0

Affects routines

httpstartsrv.

Modulemmhttphttps_port
Description

This parameter reports the port number currently used by the secure web server.

Type

Integer, read only

Affects routines

httpstartsrv.

See also

https_defport.

Modulemmhttp

6.3 Constants
mmhttp defines the following constants for frequently used HTTP status codes (the codes of the 200
series indicate success, the 400 series are error codes, according to the RFC 2616 specification). Notethat the textual representations of HTTP status codes can be obtained via function httpreason.
■

HTTP_OK: 200■

HTTP_CREATED: 201■

HTTP_ACCEPTED: 202■

HTTP_NO_CONTENT: 204■

HTTP_RESET_CONTENT: 205■

HTTP_BAD_REQUEST: 400■

HTTP_UNAUTHORIZED: 401■

HTTP_PAYMENT_REQUIRED: 402■

HTTP_FORBIDDEN: 403■

HTTP_NOT_FOUND: 404■

HTTP_METHOD_NOT_ALLOWED: 405■

HTTP_NOT_ACCEPTABLE: 406■

HTTP_PROXY_AUTHENTICATION_REQUIRED: 407■

HTTP_REQUEST_TIMEOUT: 408

Fair Isaac Corporation Proprietary Information

201

Chapter 6: mmhttp

6.4 Procedures and functions
6.4.1 HTTP client
The HTTP requests GET, HEAD, POST, PUT, PATCH and DELETE can be sent to a web service using
functions httpget, httphead, httppost, httpput, httppatch and httpdel respectively. Each ofthese functions takes at least two parameters: the URL of the resource and a file name where to store theresult of the operation. POST, PUT and PATCH requests require an additional file, namely the data source
to be sent to the web service.
HTTP requests are either processed synchronously or asynchronously.
When a request is sent in synchronous mode (the default), the HTTP function call returns after theprocessing has completed and the return value corresponds to the status of the request (a successful
request will have a status value between 200 and 299). The following example uses www.bing.com tosearch for ’FICO’ using a synchronous request:
status:=httpget("http://www.bing.com/search?q=FICO", "result.html")
if status div 100=2 thenwriteln("Found FICO!")else
writeln("Request failed with code :", status, " (", httpreason(status), ")")
end-ifIf the asynchronous mode is active (that is, the parameter http_async is set to true) the HTTP
functions return just after the request has been sent, without waiting for the reply by the server. The
processing continues in a separate thread of execution (up to http_maxasync requests can be handled
at the same time) and the function returns a request identifier (or an error code in case of failure during
the connection phase). Once the request has completed (i.e. the server has replied) an event of class
EVENT_HTTPEND is raised (please refer to the documentation of the module mmjobs for further
explanation on how to handle events). The associated value of this event isrequest_id+status/1000. For instance if request number 1300 succeeded with status 204 (’nodata’) the corresponding event value is 1300.204. An asynchronous request can be cancelled using
httpcancel: in this case an event is still generated but its status is 998.
In the following example, search for ’FICO’ is sent to BING, Yahoo and Ask at the same time. A loop isthen started to wait for answers from each of the search engines.
setparam("http_async",true)! Switch to asynchronous modereqyahoo:=httpget("http://us.search.yahoo.com/search/?p=FICO", "resyahoo.html")
writeln("Request ", reqyahoo, " sent to Yahoo")reqbing:=httpget("http://www.bing.com/search?q=FICO", "resbing.html")
writeln("Request ", reqbing, " sent to BING")
reqask:=httpget("http://uk.ask.com/web?q=FICO", "resask.html")
writeln("Request ", reqask, " sent to Ask")
if reqbing<1000 or reqyahoo<1000 or reqask<1000 thenwriteln("A request has failed!")else
nbdone:=0
repeatwait! Wait for an event
evt:=getnextevent
if evt.class = EVENT_HTTPEND then
! One of the requests completed
reqnum:=floor(evt.value)! Get request number
write("Request ", reqnum, " done: ")status:=round((evt.value-reqnum)⁎1000)! Get HTTP status
if status div 100=2 then
! 200<=status<300 is successwriteln("Found FICO!")else! Any other value is an error code
writeln("Failed with code :", status, " (", httpreason(status), ")")
end-ifnbdone+=1
end-ifFair Isaac Corporation Proprietary Information

202

Chapter 6: mmhttp
until nbdone=3
end-if! Finished when all requests are done

By default the module performs direct TCP connections to the servers but a proxy may be specified using
the http_proxy and http_proxyport parameters.
It is possible to set a limit on the time spent for connecting to a server by using http_maxcontime. The
parameter http_maxreqtime defines a time limit on the entire request (i.e. connection and retrieval of
result). mmhttp will wait undefinitely for each request if none of these parameters is defined.
When requests are sent to a secure server (i.e. URL starting with "https://") the trusted certificatesfile https_cacerts must be available such that authenticity of servers can be verified. If thisverification is not required, the control parameter https_trustsrv has to be set to true. If therequested secure server requires client authentication, client certificate https_cltcrt and associatedprivate key https_cltkey must be defined. Note that these parameters are published by mmssl: thismodule has to be used when a secure requests have to be sent.
HTTP client functions:delcookies

Delete cookies from the cookie store.

p. 204findcookie

Get the value of a cookie from the cookie store.

p. 205httpcancel

Cancel an asynchronous request.

p. 206

httpdelPerform an HTTP DELETE request.

p. 207

httpgetPerform an HTTP GET request.

p. 208httpgetheader

Extract the HTTP header of a result file.

p. 209httphead

Perform an HTTP HEAD request.

p. 210

httppatch

Perform an HTTP PATCH request.

p. 211

httppost

Perform an HTTP POST request.

p. 212

httpput

Perform an HTTP PUT request.

p. 213

httpreason

Generate the text representation of an HTTP status code.

p. 214

loadcookies

Load cookies from a file.

p. 215savecookies

Save the cookie store into a file.

p. 216setcookie

Define or update a cookie.

p. 217

tcpping

Test availability of a service on a server.

p. 218urlencode

Encode a text string for a URL.

p. 219Fair Isaac Corporation Proprietary Information

203

Chapter 6: mmhttp

delcookies
Purpose
Synopsis

Delete cookies from the cookie store.
procedure delcookies(domain:text|string)Argument
domain

Domain filter of the cookies to be deleted or an empty string to select all cookies

Related topics
setcookie.
ModulemmhttpFair Isaac Corporation Proprietary Information

204

Chapter 6: mmhttp

findcookie
Purpose
Synopsis

Get the value of a cookie from the cookie store.
function findcookie(name:string, domain:text, path:text, strict:boolean,val:text)

Arguments
namedomainpath
strictval

Cookie name
Domain of the cookie
Path in the domain
If true perfect matching is required for name, domain and path (like for setcookie),otherwise any cookie of the requested name with a compatible domain and path is returned
Returned value when a corresponding cookie is found

Return value
true if the cookie was found (its value is saved in val), false otherwise
Related topics
delcookies, findcookie.
ModulemmhttpFair Isaac Corporation Proprietary Information

205

Chapter 6: mmhttp

httpcancel
Purpose
SynopsisCancel an asynchronous request.
procedure httpcancel(id: integer)

Argument
id

Number of the request to cancel

Further information
This procedure has no effect if the request number cannot be found (e.g. the request has completed in
the meantime). If the request is effectively cancelled an event of class EVENT_HTTPEND is raised with arequest status of value 998.
Related topics
httppost, httpput, httpget, httphead, httpdel, httppatch.
ModulemmhttpFair Isaac Corporation Proprietary Information

206

Chapter 6: mmhttp

httpdelPurpose
Synopsis

Perform an HTTP DELETE request.
function httpdel(url:string|text, result:string):integerfunction httpdel(url:string|text, result:string, xhdr:string|text):integer

Argumentsurl
URL to process
result File to store the result of the request
xhdr
Additional headers to add to the request
Return value
HTTP status of the request (e.g. 200 for success, see Section 6.3 for a list of predefined status code
constants; value 999 indicates that an I/O error occurred during the operation) or the request number ( ≥1000) if the asynchronous mode is active
Further information
1. The function returns after the request has been processed when synchronous mode is active (seehttp_async). Otherwise, using asynchronous mode, the function returns immediately after having sent
the request and the model is notified about the completion of the operation by an event of class
EVENT_HTTPEND. In this mode the result file result must be a physical file (although drivers "tmp:"
and "null:" can still be used).
2. When cookie management is enabled (see http_cookies) an additional header "Cookie:" is inserted
into the request if the cookie store contains compatible cookies. This behaviour is disabled if thisoptional header is already specified via the parameter xhdr.
3. An IO error will be raised if the destination file cannot be accessed.
Related topics
httppost, httpput, httppatch, httpget, httphead, httpcancel.
ModulemmhttpFair Isaac Corporation Proprietary Information

207

Chapter 6: mmhttp

httpgetPurpose
Synopsis

Perform an HTTP GET request.
function httpget(url:string|text, result:string):integerfunction httpget(url:string|text, result:string, xhdr:string|text):integer

Argumentsurl
URL to process
result File to store the result of the request
xhdr
Additional headers to add to the request
Return value
HTTP status of the request (e.g. 200 for success, see Section 6.3 for a list of predefined status code
constants; value 999 indicates that an I/O error occurred during the operation) or the request number ( ≥1000) if asynchronous mode is active
ExampleRetrieve the default entry page of the FICO website in French and store it in the file "fico.html":
status:=httpget('http://www.fico.com/fr/Pages/default.aspx', 'fico.html')

Further information
1. The function returns after the request has been processed when synchronous mode is active (seehttp_async). Otherwise, using asynchronous mode, the function returns immediately after having sent
the request and the model is notified about the completion of the operation by an event of class
EVENT_HTTPEND. In this mode the result file result must be a physical file (although drivers "tmp:"
and "null:" can still be used).
2. When building a query it is important to encode data to be sent using urlencode
3. By default the header "Accept-Encoding: gzip" is inserted into the request and the result data is
automatically decompressed if the server supports compression. This behaviour is disabled if thisoptional header is already specified (e.g. the parameter xhdr includes "Accept-Encoding:identity").
4. When cookie management is enabled (see http_cookies) an additional header "Cookie:" is inserted
into the request if the cookie store contains compatible cookies. This behaviour is disabled if thisoptional header is already specified via the parameter xhdr.
5. An IO error will be raised if the destination file cannot be accessed.
Related topics
httppost, httpput, httppatch, httpdel, httphead, urlencode, httpcancel.
ModulemmhttpFair Isaac Corporation Proprietary Information

208

Chapter 6: mmhttp

httpgetheader
Purpose
Synopsis

Extract the HTTP header of a result file.
function httpgetheader(sfile:string|text):text
function httpgetheader(sfile:string|text, dfile:string|text):text

Arguments
sfile Name of the file to process
dfile Destination file (can be the same as sfile)
Return value
Header of the result document
Further information
1. Result files of queries inlude the HTTP header when the parameter http_keephdr is set to true: thisfunction returns the header of a result file when this setting is active.
2. The optional destination file dfile receives a copy of the original result file after the header has been
removed.
3. An IO error will be raised in case of failure during a file operation.
Related topics
httpget, httppost, httpput, httppatch, httpdel.
ModulemmhttpFair Isaac Corporation Proprietary Information

209

Chapter 6: mmhttp

httphead
Purpose
Synopsis

Perform an HTTP HEAD request.
function httphead(url:string|text, result:string):integerfunction httphead(url:string|text, result:string, xhdr:string|text):integer

Argumentsurl
URL to process
result File to store the result of the request
xhdr
Additional headers to add to the request
Return value
HTTP status of the request (e.g. 200 for success, see Section 6.3 for a list of predefined status code
constants; value 999 indicates that an I/O error occurred during the operation) or the request number ( ≥1000) if asynchronous mode is active
Further information
1. The HEAD request is equivalent to a GET request except that no result is returned by the server, only theheader can be retrieved (see httpgetheader).
2. An IO error will be raised if the destination file cannot be accessed.
Related topics
httppost, httpput, httppatch, httpdel, httpget, urlencode, httpcancel.
ModulemmhttpFair Isaac Corporation Proprietary Information

210

Chapter 6: mmhttp

httppatch
Purpose
Synopsis

Perform an HTTP PATCH request.
function httppatch(url:string|text, data:string, result:string):integerfunction httppatch(url:string|text, data:string, result:string,
xhdr:string|text):integer

Argumentsurl
URL to processdata
Data file to be sent to the server
result File to store the result of the request
xhdr
Additional headers to add to the request
Return value
HTTP status of the request (e.g. 200 for success, see Section 6.3 for a list of predefined status code
constants; value 999 indicates that an I/O error occurred during the operation) or the request number ( ≥1000) if asynchronous mode is active
Further information
1. The function returns after the request has been processed when synchronous mode is active (seehttp_async). Otherwise, using asynchronous mode, the function returns immediately after having sent
the request and the model is notified about the completion of the operation by an event of class
EVENT_HTTPEND. In this mode the result file result must be a physical file (although drivers "tmp:"
and "null:" can still be used).
2. The parameter xhdr is typically used when the data type has to be specified. For instance, when the data
sent is URL-encoded it may be necessary to use "Content-Type:application/x-www-form-urlencoded" as the value for xhdr in order to indicate to the server
how to decode and process this data.
3. When cookie management is enabled (see http_cookies) an additional header "Cookie:" is inserted
into the request if the cookie store contains compatible cookies. This behaviour is disabled if thisoptional header is already specified via the parameter xhdr.
4. An IO error will be raised in case of failure during a file operation.
Related topics
httpget, httphead, httpput, httppost, httpdel, urlencode, httpcancel.
ModulemmhttpFair Isaac Corporation Proprietary Information

211

Chapter 6: mmhttp

httppost
Purpose
Synopsis

Perform an HTTP POST request.
function httppost(url:string|text, data:string, result:string):integerfunction httppost(url:string|text, data:string, result:string,
xhdr:string|text):integer

Argumentsurl
URL to processdata
Data file to be sent to the server
result File to store the result of the request
xhdr
Additional headers to add to the request
Return value
HTTP status of the request (e.g. 200 for success, see Section 6.3 for a list of predefined status code
constants; value 999 indicates that an I/O error occurred during the operation) or the request number ( ≥1000) if asynchronous mode is active
Further information
1. The function returns after the request has been processed when synchronous mode is active (seehttp_async). Otherwise, using asynchronous mode, the function returns immediately after having sent
the request and the model is notified about the completion of the operation by an event of class
EVENT_HTTPEND. In this mode the result file result must be a physical file (although drivers "tmp:"
and "null:" can still be used).
2. The parameter xhdr is typically used when the data type has to be specified. For instance, when the data
sent is URL-encoded it may be necessary to use "Content-Type:application/x-www-form-urlencoded" as the value for xhdr in order to indicate to the server
how to decode and process the data.
3. By default the header "Accept-Encoding: gzip" is inserted into the request and the result data is
automatically decompressed if the server supports compression. This behaviour is disabled if thisoptional header is already specified (e.g. the parameter xhdr includes "Accept-Encoding:identity").
4. When cookie management is enabled (see http_cookies) an additional header "Cookie:" is inserted
into the request if the cookie store contains compatible cookies. This behaviour is disabled if thisoptional header is already specified via the parameter xhdr.
5. An IO error will be raised in case of failure during a file operation.
Related topics
httpget, httphead, httpput, httppatch, httpdel, urlencode, httpcancel.
ModulemmhttpFair Isaac Corporation Proprietary Information212

Chapter 6: mmhttp

httpput
Purpose
Synopsis

Perform an HTTP PUT request.
function httpput(url:string|text, data:string, result:string):integerfunction httpput(url:string|text, data:string, result:string,
xhdr:string|text):integer

Argumentsurl
URL to processdata
Data file to be sent to the server
result File to store the result of the request
xhdr
Additional headers to add to the request
Return value
HTTP status of the request (e.g. 200 for success, see Section 6.3 for a list of predefined status code
constants; value 999 indicates that an I/O error occurred during the operation) or the request number ( ≥1000) if asynchronous mode is active
Further information
1. The function returns after the request has been processed when synchronous mode is active (seehttp_async). Otherwise, using asynchronous mode, the function returns immediately after having sent
the request and the model is notified about the completion of the operation by an event of class
EVENT_HTTPEND. In this mode the result file result must be a physical file (although drivers "tmp:"
and "null:" can still be used).
2. The parameter xhdr is typically used when the data type has to be specified. For instance, when the data
sent is URL-encoded it may be necessary to use "Content-Type:application/x-www-form-urlencoded" as the value for xhdr in order to indicate to the server
how to decode and process this data.
3. When cookie management is enabled (see http_cookies) an additional header "Cookie:" is inserted
into the request if the cookie store contains compatible cookies. This behaviour is disabled if thisoptional header is already specified via the parameter xhdr.
4. An IO error will be raised in case of failure during a file operation.
Related topics
httpget, httphead, httppost, httppatch, httpdel, urlencode, httpcancel.
ModulemmhttpFair Isaac Corporation Proprietary Information

213

Chapter 6: mmhttp

httpreason
Purpose
Synopsis

Generate the text representation of an HTTP status code.
function httpreason(code:integer):stringArgument
code

HTTP status code (see Section 6.3 for a list of predefined status code constants)

Return value
Text associated to the provided status code or an empty string if the code is unknown
ExampleThe following displays "Bad Request":
writeln(httpreason(400))

Further information
The HTTP standard specifies a set of predefined status codes. This function returns the text associatedwith a given code. For instance, upon success a request will reply with code 200 ("OK") or 204 ("NoContent").
ModulemmhttpFair Isaac Corporation Proprietary Information

214

Chapter 6: mmhttp

loadcookies
Purpose
Synopsis

Load cookies from a file.
function loadcookies(fname:string|text, host:string):integer

Arguments
fname Source file namehost If not empty only cookies compatible with this host name are recorded
Return value
Number of cookies added to the store
Further information
1. This function loads cookies from the specified file and record them into the cookie store. The file must be
encoded as a HTTP header and only "Set-Cookie" headers are processed (other lines are silently
ignored).
2. An IO error will be raised if the source file cannot be accessed.
Related topics
savecookies, setcookie.
ModulemmhttpFair Isaac Corporation Proprietary Information

215

Chapter 6: mmhttp

savecookies
Purpose
Synopsis

Save the cookie store into a file.
function savecookies(fname:string|text, domain:string):integer

Arguments
fnamedomainDestination file name
Domain filter of the cookies to be saved or an empty string to select all cookies

Return value
Number of records generated
Further information
1. This function saves the selected cookies into a text file. The cookies are encoded according to thestandard "Set-Cookie" header (one record per line per cookie).
2. An IO error will be raised if the destination file cannot be accessed.
Related topics
loadcookies, findcookie.
ModulemmhttpFair Isaac Corporation Proprietary Information

216

Chapter 6: mmhttp

setcookie
Purpose
SynopsisDefine or update a cookie.
procedure setcookie(name:string, value:text, domain:text, path:text,
exp:integer)

Arguments
nameCookie namevalue
Associated value
domain Domain of the cookie: if it does not start with a dot the domain is interpreted as a host nameand the cookie is a host only cookie
path
Path in the domain
exp
Expiration time: with a negative value the cookie is deleted; with 0 the cookie never expires(session cookie) and a positive value is interpreted as an amount of time in seconds after
which the cookie will expire
Further information
This procedure adds a cookie to the cookie store. If an existing cookie has the same name, domain andpath as those specified to the procedure its value and expiration information is updated.
Related topics
delcookies, findcookie.
ModulemmhttpFair Isaac Corporation Proprietary Information

217

Chapter 6: mmhttp

tcpping
Purpose
Synopsis

Test availability of a service on a server.
function tcpping(host:string|text,port:integer):integer

Arguments
host
port

Name of server to test
Service port

Return value
Test result:0Connection succeeded
1
Invalid parameters
2
Host name not found3
Connection failed
Further information
This function opens a TCP connection to to the given host and port and closes it immediately in case of
success.
ModulemmhttpFair Isaac Corporation Proprietary Information

218

Chapter 6: mmhttp

urlencode
Purpose
Synopsis

Encode a text string for a URL.
function urlencode(data:string|text):text

Argument
data

Text to encode

Return value
Encoded text suitable for building a URL
ExampleThe following request sends query "qry" to the server "srv" requiring parameters "a" and "b". The
values associated with these parameters are URL-encoded:
status:=httpget("http://srv/qry?a="+urlencode(a)+"&b="+urlencode(b), "result.txt")

Further information
1. This function converts a text string into a format that is compatible with URL conventions. The
conversion consists in replacing characters with a special meaning by a portable representation basedon the character code. For example, the character "&" is replaced by "%26".
2. Typically, query parameters have to be encoded when sending them via an HTTP GET request, data sent
via POST may also have to be encoded.
ModulemmhttpFair Isaac Corporation Proprietary Information219

Chapter 6: mmhttp

6.4.2 HTTP server
The mmhttp module integrates an HTTP server that is started using the procedure httpstartsrv andstopped with httpstopsrv (the server is stopped in any case when the execution of the model
terminates). The server behaviour may be changed using these module parameters: http_defportdefines the TCP port on which the server is listening (by default a random port is selected);
http_defpage indicates which page or label the server has to consider when no path is specified in arequest (by default this is "index.html"); http_srvconfig defines the set of request types
supported by the model (for instance only GET and POST) as well as whether a secure server is to be
started; http_maxreq sets a limit on the number of simultaneous connections that are kept active.
When a secure server (HTTPS) is requested (the server config includes flags HTTP_SSL or
HTTP_SSLONLY) besides the optional basic settings similar to those used for the standard server (likehttps_defport) additional parameters have to be set. The server certificate https_srvcrt as wellas its private key https_srvkey are required. Moreover, if the clients are requested to authenticate
themselves (server option HTTP_CLTAUTH), the authorised certificate file https_cacerts must
include the expected certificates. Note that these parameters are published by mmssl: this module has tobe used when a secure server is started.
The server runs in the background and notifies the model of incoming connections through events ofclass EVENT_HTTPNEW (please refer to the documentation of mmjobs for further explanation on how tohandle events). The value associated with this event is a request number: the connection to the client is
kept open and the model has to reply to the request in order to complete the operation. Any dataassociated with the incoming request (query in the case of a GET or data sent via POST, PUT or PATCH) is
saved into a temporary file before the event is sent. URL encoded information is automatically decodedand converted to a format compatible with initialisations from blocks. The function
httppending may also be used to retrieve the list of requests currently waiting for a reply.
Request properties can be obtained through a set of dedicated routines: httpreqfrom is the IP addressof the client; httpreqtype is the request type (i.e. GET, POST, PUT, PATCH or DELETE);
httpreqheader is the request header; httpreqstat reports the status associated to a request
number (for instance whether it is active, or has associated data); httpreqlabel is the label of therequest; httpreqcookies returns the cookies found in the header. The label of a request is its URL
after having removed server reference and the query data (for example, the label returned for"http://srv/some/path?a=10" is "some/path"); httpreqfile is the name of the temporary
file holding data associated to the request. The connection status of a request might be inspected withhttpreqconstat that indicates whether the cleint is still waiting for a reply.
Three different methods can be used to reply to a request: httpreplycode will only return a status
code associated with a short (error) message; httpreply takes as input a file to be sent back to theclient (with a success status code) and httpreplyjson converts its input parameter into JSON datathat is sent back to the client.
The following example shows how to implement a simple file server. This program expects GET(download a file) and PUT (upload a file) requests sent to the port 2533. The URI of the request isinterpreted as the file name: for example, the URL "http://srv:2533/myfile.txt" could be used
to access file "myfile.txt" stored on host "srv" running this example.
setparam("http_defport", 2533)! Set server port (2533)
setparam("http_srvconfig",HTTP_GET+HTTP_PUT) ! Only GET and PUT requests
setparam("workdir", getparam("tmpdir"))! Move to temporary directory
httpstartsrv! Server now running
repeatwait! Wait for an event
ev:=getnextevent
if ev.class=EVENT_HTTPNEW then
! Request pending
r:=integer(ev.value)! Get request ID
fname:=httpreqlabel(r)! File name will be the URI
if httpreqtype(r)=HTTP_GET then! Client wants to get the fileif bittest(getfstat(fname), SYS_TYP) = SYS_REG then

Fair Isaac Corporation Proprietary Information

220

Chapter 6: mmhttp
httpreply(r,fname)else
httpreplycode(r,404)
end-ifelif httpreqtype(r)=HTTP_PUT and
httpreqstat(r)>=2 thenfmove(httpreqfile(r), fname)
if getsysstat=0 then
httpreplycode(r,204)
else
httpreplycode(r,403)
end-ifelse
httpreplycode(r,400)
end-ifend-ifuntil false! If available: send it! Otherwise: reply "Not Found"! Client wants to put a file
! File must be non-empty! Try to save it! If success: reply "No Content"! Otherwise: reply "Forbidden"! Empty files are refused

In the above example all requests are handled by the same model but it is also possible to dispatch theprocessing of the requests to several submodels running concurrently to improve the efficiency of theservice. To implement a multithreaded server a queue of requests of type reqqueue (See Section 6.1)
has to be declared as a global shared entity and each of the submodels must be clones of the server
model (in order to have access to this shared queue). The master model can then start all of its
submodels and initialise the HTTP server as in the preceding example but it can move the HTTP requests
it receives to the queue using httpreqpush. The submodels enter a loop starting with a call tohttpreqpop (to indicate that they are ready to handle a request) followed by a wait: requests comingfrom the master model are notified via an event of class EVENT_HTTPNEW and exposed just as in asingle-model server. The general structure of the server looks like the following:parameters
MASTER=true
NBW=5
end-parameters! Running the master or a worker?
! Number of submodels to startdeclarations
queue: shared reqqueue! The shared queue of requests
procedure run_masterprocedure run_worker
procedure process_request(req:integer)
end-declarations
if MASTER thenrun_masterelse
run_worker
end-if! The master model runs the HTTP server
procedure run_masterdeclarations
workers:array(1..NBW) of Model
end-declarations
forall(i in 1..NBW) doload(workers(i))! Each worker is a clone of the serverrun(workers(i),"MASTER=false")
end-dosetparam("http_defport", 2533)! Set server port (2533)
setparam("http_srvconfig",HTTP_GET+HTTP_PUT) ! Only GET and PUT requests
setparam("workdir", getparam("tmpdir"))! Move to temporary directory
httpstartsrv! Server now running
repeatwait! Wait for an event
ev:=getnextevent
if ev.class=EVENT_HTTPNEW then
! Request pending
r:=integer(ev.value)! Get request ID
httpreqpush(r,queue)! Move it to the queue

Fair Isaac Corporation Proprietary Information

221

Chapter 6: mmhttp
end-ifuntil false
end-procedure! Each worker waits for requests sent by the master model and processes themprocedure run_worker
setparam("workdir", getparam("tmpdir"))! Move to temporary directory
repeathttpreqpop(queue)! Model readywait! Wait for an event
ev:=getnextevent
if ev.class=EVENT_HTTPNEW then
! Request pending
r:=integer(ev.value)! Get request ID
process_request(r)! Actual processing
end-ifuntil false
end-procedure

HTTP server functions:
httppending

Get a list of requests waiting for a reply.

p. 223

httpqueueinfo

Get size information of a queue of requests.

p. 224

httpreply

Reply to an HTTP request with a file.

p. 225httpreplycode

Reply to an HTTP request only with a status code.

p. 226

httpreplyjson

Reply to an HTTP request with JSON data.

p. 227

httpreqconstat

Check the connection status of a request.

p. 228httpreqcookies

Retrieve the cookies of a request.

p. 229httpreqfile

Get the data file associated to a request.

p. 230

httpreqfrom

Get the IP address of the sender of a request.

p. 231

httpreqheader

Get the header associated to a request.

p. 232

httpreqlabel

Get the label associated to a request.

p. 233

httpreqpop

Ask for a HTTP request from a queue.

p. 234

httpreqpush

Move a request to a queue.

p. 235httpreqpushlim

Move a request to a queue with restriction.

p. 236

httpreqstat

Get the status associated with a request.

p. 237

httpreqtype

Get the type of a request.

p. 238httpstartsrv

Start the HTTP server.

p. 239httpstopsrv

Stop the HTTP server.

p. 240jsonread

Initialise a Mosel entity from a JSON data file.

p. 241

jsonwrite

Generate a JSON representation of a Mosel entity.

p. 242mksetcookie

Generate a set-cookie header line.

p. 243

Fair Isaac Corporation Proprietary Information

222

Chapter 6: mmhttp

httppending
Purpose
Synopsis

Get a list of requests waiting for a reply.
function httppending(lp:list of integer):integerfunction httppending:integer

Argument
lp

List of request numbers

Return value
Number of requests in the waiting queue
Further information
This function returns in lp the list of requests currently waiting for a reply in the server queue (thecontent of the list is replaced).
ModulemmhttpFair Isaac Corporation Proprietary Information

223

Chapter 6: mmhttp

httpqueueinfo
Purpose
Synopsis

Get size information of a queue of requests.
function httpqueueinfo(rq:reqqueue, what:integer):integer

Argumentsrq
what

A queue of requests
What information to retrieve:
0
Number of requests waiting in the queue
1
Number of models having access to the queue
2
Number of models ready for processing a request
3
The result of httpqueueinfo(rq,2)-httpqueueinfo(rq,0)Return value
Requested information or 0 for an unknown code.
Related topics
httpreqpushlim.
ModulemmhttpFair Isaac Corporation Proprietary Information

224

Chapter 6: mmhttp

httpreply
Purpose
Synopsis

Reply to an HTTP request with a file.
procedure httpreply(reqid:integer)
procedure httpreply(reqid:integer, fname:string)procedure httpreply(reqid:integer, fname:string|text, xhdr:string|text)
procedure httpreply(reqid:integer, code:integer, fname:string|text,
xhdr:string|text)

Arguments
reqid Request number
code 0 or HTTP status code to be returned (see Section 6.3 for a list of predefined status code
constants)
fname Name of the file holding the response data
xhdr Additional headers to include in the response
Further information
1. This procedure replies to the specified request sending the provided file and using 200 (’OK’) as the HTTP
status code (if no code is given or if its value is 0).
2. The first form of the procedure is the same as providing an empty file name with the second form: in thiscase no data is sent to the client and the returned status code becomes 204 (’No Content’).
3. If the specified request is of type HEAD (see httphead) this procedure sends only the header part of theresult.
4. An IO error will be raised if the response file cannot be accessed.
Related topics
httpreplycode, httpreplyjson, mksetcookie.
ModulemmhttpFair Isaac Corporation Proprietary Information

225

Chapter 6: mmhttp

httpreplycode
Purpose
Synopsis

Reply to an HTTP request only with a status code.
procedure httpreplycode(reqid:integer, code:integer)
procedure httpreplycode(reqid:integer, code:integer, msg:string)procedure httpreplycode(reqid:integer, code:integer, msg:string,
xhdr:string|text)

Arguments
reqid
code
msg
xhdr

Request number
HTTP status code to be returned (see Section 6.3 for a list of predefined status code constants)
Explanation text
Additional headers to include in the response

Further information
1. This procedure replies to the specified request using the provided code that should be a valid HTTP
status (i.e. 3 digit number).
2. Unless the provided code is 204 (No Content) a basic HTML page is generated as the data associated to
the response including the standard reason (e.g. Bad Request for code 400) as well as the given
explanation text.
3. If the specified request is of type HEAD (see httphead) this procedure sends only the header part of theresult.
Related topics
httpreply, httpreplyjson, mksetcookie, Section 6.3.
ModulemmhttpFair Isaac Corporation Proprietary Information

226

Chapter 6: mmhttp

httpreplyjson
Purpose
Synopsis

Reply to an HTTP request with JSON data.
procedure httpreplyjson(reqid:integer)
procedure httpreplyjson(reqid:integer, mosobj:⁎)

Arguments
reqidmosobjRequest number
Mosel object to use for the reply

Further information
1. This procedure replies to the specified request by sending the provided Mosel object encoded as a JSON
object and a status code of 200.
2. When the first form is used, the returned data is the JSON constant null.
3. If the specified request is of type HEAD (see httphead) this procedure sends only the header part of theresult.
Related topics
httpreply, httpreplycode.
ModulemmhttpFair Isaac Corporation Proprietary Information

227

Chapter 6: mmhttp

httpreqconstat
Purpose
SynopsisCheck the connection status of a request.
function httpreqconstat(reqid:integer):integer

Argument
reqid Request number
Return value
Request status:<0
Invalid request number
0
Request not active
1
The client has closed the connection
2
The client is still waiting for a reply
Further information
1. A disconnection can only be reliably detected if the remote end of the link has performed an orderly
shutdown. As a consequence a return status 2 is not the guarantee that the connection to the client iseffectively still valid.
2. A request must always be released by a call to a reply routine (e.g. httpreply), even after adisconnection has been detected.
Related topics
httpreqstat.
ModulemmhttpFair Isaac Corporation Proprietary Information

228

Chapter 6: mmhttp

httpreqcookies
Purpose
Synopsis

Retrieve the cookies of a request.
procedure httpreqcookies(reqid:integer, cook:array(string) of text)

Arguments
reqid Request number
cook An array where cookie values are returned (indiced by the names of the cookies)
Further information
This procedure decodes the header "Cookie" of a request to populate the provided array.
Related topics
httpreqfrom, httpreqlabel, httpreqstat, httpreqtype, httpreqheader, httpreqfile,mksetcookie.
ModulemmhttpFair Isaac Corporation Proprietary Information229

Chapter 6: mmhttp

httpreqfile
Purpose
Synopsis

Get the data file associated to a request.
function httpreqfile(reqid:integer):stringArgument
reqid Request number
Return value
Full path to the data file
Further information
1. Each request is associated with a data file located in the temporary directory. This function returns thefull path to this file.
2. The data file is specific to the given request number and can be used (for instance, to store the responseto the request) even if no data is associated with the request.
Related topics
httpreqfrom, httpreqlabel, httpreqstat, httpreqtype, httpreqheader,httpreqcookies.
ModulemmhttpFair Isaac Corporation Proprietary Information

230

Chapter 6: mmhttp

httpreqfrom
Purpose
Synopsis

Get the IP address of the sender of a request.
function httpreqfrom(reqid:integer):text

Argument
reqid Request number
Return value
IP of the sender of the request as a text string
Related topics
httpreqtype, httpreqfile, httpreqstat, httpreqlabel, httpreqheader,httpreqcookies.
ModulemmhttpFair Isaac Corporation Proprietary Information

231

Chapter 6: mmhttp

httpreqheader
Purpose
Synopsis

Get the header associated to a request.
function httpreqheader(reqid:integer):text

Argument
reqid Request number
Return value
Header of the request
Further information
The header of the request is a block of text consisting of lines of the form fieldname:value (e.g.
Content-Type: application/json).
Related topics
httpreqfrom, httpreqfile, httpreqstat, httpreqlabel, httpreqtype, httpreqcookies.
ModulemmhttpFair Isaac Corporation Proprietary Information

232Chapter 6: mmhttp

httpreqlabel
Purpose
Synopsis

Get the label associated to a request.
function httpreqlabel(reqid:integer):text

Argument
reqid Request number
Return value
Label of the request
Further information
1. The label of the GET or DELETE request is the URL after having removed server reference and query data(for instance the label returned for "http://srv/some/path?a=10" is "some/path"). Any query
data is automatically saved into the associated request file (httpreqfile) in a format compatible withinitialisations blocks. When such a file has been created the request status (httpreqstat) has value 3.
2. In the case of a POST, a PUT or a PATCH request the returned value also includes the undecoded data.
Related topics
httpreqfrom, httpreqfile, httpreqstat, httpreqtype, httpreqheader, httpreqcookies.
ModulemmhttpFair Isaac Corporation Proprietary Information

233

Chapter 6: mmhttp

httpreqpop
Purpose
Synopsis

Ask for a HTTP request from a queue.
procedure httpreqpop(rq:reqqueue)

Argumentrq

A queue of requests

Further information
1. This procedure has to be used by a model to notify the manager of a queue of requests that it is ready forprocessing an HTTP request. After this call, as soon as a new request is available an event of class
EVENT_HTTPNEW is sent to the model that can handle it as if it was running the HTTP server.
2. The model is flagged as available if no request is waiting in the queue. This flag is cleared when a request
is passed to the model: it is therefore required to call the procedure again after a request has beenprocessed.
Related topics
httpreqpushlim, httpreqpush, httpqueueinfo.
ModulemmhttpFair Isaac Corporation Proprietary Information

234

Chapter 6: mmhttp

httpreqpush
Purpose
SynopsisMove a request to a queue.
procedure httpreqpush(reqid:integer,rq:reqqueue)

Arguments
reqid Request number or -1
rq
A queue of requests
Further information
1. This routine moves the selected request to a queue of requests in order to make it available to otherserver models. The request can no longer be accessed by the calling model after it has been passed tothis procedure.
2. If the provided request is -1 this routine only clears the availability flag of the model (i.e. it is no longer
ready to process a request).
Related topics
httpreqpushlim, httpreqpop, httpqueueinfo.
ModulemmhttpFair Isaac Corporation Proprietary Information

235

Chapter 6: mmhttp

httpreqpushlim
Purpose
SynopsisMove a request to a queue with restriction.
function httpreqpushlim(reqid:integer,rq:reqqueue,lim:integer):boolean

Arguments
reqid Request number or -1
rq
A queue of requests
lim
Maximum number of waiting requests or -1 for no limit
Return value
true if the operation succeeded, false otherwise.
Further information
1. This function moves the selected request to a queue of requests in order to make it available to otherserver models. The operation is canceled if the current number of elements in the queue exceeds thegiven limit lim and false is returned. Otherwise, true is returned and the request can no longer beaccessed by the calling model.
2. If the provided request is -1 this routine only clears the availability flag of the model (i.e. it is no longer
ready to process a request). In this case the return value indicates whether the flag was reset or not: witha false result the flag was already cleared before the function call.
Related topics
httpreqpush, httpreqpop, httpqueueinfo.
ModulemmhttpFair Isaac Corporation Proprietary Information

236

Chapter 6: mmhttp

httpreqstat
Purpose
Synopsis

Get the status associated with a request.
function httpreqstat(reqid:integer):integer

Argument
reqid Request number
Return value
Request status:<0
Invalid request number
0
Request not active1
No associated data2
Raw data available
3’initialisations from’ data available
Further information
1. If the return value is 2 or 3 a data file is available (see httpreqfile). If this function returns 3 then thefile can be read using an initialisations from block: data that was originally URL-encoded has been
decoded by the server and stored using Mosel’s initialisations format.
2. The status 3 will be produced when the request is of type GET or DELETE and has associated data. This
will also be the case with a query of type POST or DELETE if the content type is"application/x-www-form-urlencoded".
Related topics
httpreqfrom, httpreqfile, httpreqlabel, httpreqtype, httpreqheader, httpreqcookies,
httpreqconstat.
ModulemmhttpFair Isaac Corporation Proprietary Information

237

Chapter 6: mmhttp

httpreqtype
Purpose
Synopsis

Get the type of a request.
function httpreqtype(reqid:integer):integer

Argument
reqid Request number
Return value
Request type:<00
HTTP_GETHTTP_POSTHTTP_PUTHTTP_DELETE
HTTP_HEAD
HTTP_PATCH

Invalid request number
Request not active
GET (1)POST (2)PUT (4)DELETE (8)HEAD (128)
PATCH (256)

Related topics
httpreqfrom, httpreqfile, httpreqstat, httpreqlabel, httpreqheader,httpreqcookies.
ModulemmhttpFair Isaac Corporation Proprietary Information

238

Chapter 6: mmhttp

httpstartsrv
Purpose
SynopsisStart the HTTP server.
procedure httpstartsrv
procedure httpstartsrv(srvdir:string, moslab:string)Arguments
srvdirmoslabServer directory
Label identifying commands

Further information
1. The server takes its configuration from the parameters http_defport, http_srvconfig,
http_listen, http_maxreq and http_defpage.
2. Only one server can be run by a model: if the server is already running, no operation is performed.
3. The server processes only authorised request types (see http_srvconfig): the model is notified ofevery valid request by an event of class EVENT_HTTPNEW. Malformed or unauthorised requests areautomatically rejected.
4. When the function is used with arguments, srvdir designates a directory: mmhttp will act as a fileserver for the files stored in this directory (via GET queries). The argument moslab is a prefix that
identifies requests that are to be handled by the model.
5. An IO error is raised if the server cannot start because of a network setting (typically the TCP port isalready used or requires higher privileges).
6. If the parameter http_startwb is set to true a web browser (as defined by http_browser) is
launched just after the server has started.
Related topics
httpstopsrv.
ModulemmhttpFair Isaac Corporation Proprietary Information

239

Chapter 6: mmhttp

httpstopsrv
Purpose
Synopsis

Stop the HTTP server.
procedure httpstopsrv

Further information
1. This procedure has no effect if no server is running.
2. During its shutting down procedure the server closes all waiting requests (with a response code 410)
such that it is no longer possible for the model to reply to these requests (however, events corresponding
to these requests may still be in the event queue).
Related topics
httpstartsrv.
ModulemmhttpFair Isaac Corporation Proprietary Information

240

Chapter 6: mmhttp

jsonread
Purpose
Synopsis

Initialise a Mosel entity from a JSON data file.
procedure jsonread(fname:text|string, mosobj:⁎)

Arguments
fname
Name of a JSON filemosobj A Mosel entity
Further information
1. This procedure accepts basic types (integer, real, boolean, string), native types compatible withfrom/tostring (e.g. text or date, they are initialised from json strings), records (only public fields ofsupported types are populated from the corresponding json object members), lists of compatible types(populated from json arrays) and unions. Unsupported entities are silently ignored (e.g. sets and arrays)
and entries in the JSON document that do not correspond to an expected entry are also ignored.
2. Unions have a special handling: they can be initialised with a scalar (number, boolean or string) or an
object if the union itself is already a field of a record (in this case the union takes the type of the structurethat includes it).
3. Although basic types are supported the routine cannot initialise a scalar of a basic type: its input
parameter must be a record, a union, a variable of a native type (supporting serialisation) or a list.
4. The procedure does not reset its input parameter: in particular when initialising a list, the values from the
JSON file will be appended to the existing content. Note that the special value null from the JSON data
might be applied to lists, records and unions to reset these entities.
5. An IO error will be raised if the source file cannot be accessed or if a parsing error occurs.
Related topics
jsonwrite.
ModulemmhttpFair Isaac Corporation Proprietary Information

241

Chapter 6: mmhttp

jsonwrite
Purpose
Synopsis

Generate a JSON representation of a Mosel entity.
procedure jsonwrite(fname:text|string, mosobj:⁎)procedure jsonwrite(fname:text|string, mosobj:⁎, flags:integer)

Arguments
fname
Name of a file to store the generated text
mosobj A Mosel entity
flags
Option flags (can be combined with ’+’):
HTTP_SKIP_EMPTYCOL
HTTP_SKIP_EMPTYUNION

Skip empty collections in records
Skip empty unions in records

Further information
1. This procedure generates a JSON representation of a Mosel entity: records are exposed as json objects;
lists and sets are represented by json arrays; arrays result in either json objects or arrays depending on
their structure and scalar values are output as json numbers, Booleans or strings. Types not supporting
serialisation (i.e. conversion from/to some textual representation) are reported as the null json value.
2. When exporting a record, only public fields of types supporting serialisation are output: for instance afield of type mpvar will be silently ignored. With the flag HTTP_SKIP_EMPTYCOL empty collections(list,set or array) will also be skipped, and with the option HTTP_SKIP_EMPTYUNION undefined unions
will be ignored.
3. If the file name is an empty string, the generated text is sent to the current output stream (by default thisis the console). An IO error will be raised if the destination file cannot be accessed.
Related topics
jsonread.
ModulemmhttpFair Isaac Corporation Proprietary Information

242

Chapter 6: mmhttp

mksetcookie
Purpose
Synopsis

Generate a set-cookie header line.
function mksetcookie(name:string, value:text, domain:text, path:text,
exp:integer):text

Arguments
nameCookie namevalue
Associated value
domain Domain of the cookie: if it does not start with a dot the domain is interpreted as a host nameand the cookie is a host only cookie
path
Path in the domain
exp
Expiration time: with a negative value the cookie will be deleted; with 0 the cookie never
expires (session cookie) and a positive value is interpreted as an amount of time in seconds
after which the cookie will expire
Return value
A text string of the form "Set-Cookie: name=value\n"Further information
This function may be used to send cookies to a client by generating a set-cookie header that can bedirectly appended to the additional headers string of httpreply or httpreplycode. The returned
string is terminated by an end of line.
Related topics
httpreply, httpreplycode, httpreqcookies.
ModulemmhttpFair Isaac Corporation Proprietary Information

243Chapter 6: mmhttp

6.5 I/O drivers
The mmhttp module publishes the url driver with which a URL can be used as a file. Thanks to thisfacility it is possible to use files stored on an HTTP enabled file server just as if they were located on thelocal file system. For example, the following command downloads and executes the Mosel file"hello.mos" stored on the web server mysrv:> mosel exec mmhttp.url:http://mysrv/hello.mos

6.5.1 Driver url
url:URL

The file name for this driver is a URL. Currently only HTTP URLs are supported (i.e. the name must begin
with "http://"). The behaviour of the driver depends on the file operation:
reading

A GET request is sent to the specified URL at the time of opening the file. The following
read operations are executed directly from the result stream generated by the server.

writing

The written data is first saved into a temporary file and then sent to the specified URL via
a PUT request when the file is closed.

deleting

When deleting a file (e.g., using fdelete) through this driver a DELETE request is sent tothe specified URL.

Fair Isaac Corporation Proprietary Information

244

CHAPTER 7

mmjavaThe mmjava module for Mosel is intended for users who integrate their Mosel models into Javaapplications. This module can only be used from a Java enabled application.

7.1 I/O drivers
This module provides the java and jraw IO drivers. The first one can be used to link a Mosel output (input)
stream to a Java OutputStream (InputStream) or a Java ByteBuffer. The second driver is a
modified version of the raw driver suitable for Java: instead of an address, this driver takes as input areference to an object.
For both drivers, file names are replaced by references to objects. These references are of two kinds:
direct references to public static objects (e.g. "java.lang.Sytem.out") and names defined using the
XPRM.bind method. The second technique will be used with non static objects: the method XPRM.bindestablishes a link between a name and an object. This name can then be used as an object reference formmjava drivers.
When using Java object from Mosel, it is important to make sure objects and related fields can beaccessed: in particular the class and its fields must be public.

7.1.1 Driver java
java:[rewind,]static object|named object

With this driver a Java stream (OutputStream or InputStream) as well as a ByteBuffer can beused in place of a file in Mosel. This facility is specially useful for redirecting default Mosel streams toJava objects. Note that the Mosel Java interface uses this driver for redirecting default streams (in, out,
and error) to the corresponding Java streams (System.in, System.out and System.err).
When the file is open for reading and the referenced object is a ByteBuffer, the option rewind can beused in order to rewind the buffer before starting to read.
Example:mosel=new XPRM();
mosel.bind("out", myout);/⁎ Associate 'myout' object with string "out" ⁎//⁎ Redirect default output to 'myout' ⁎/mosel.setDefaultStream(XPRM.F_OUTPUT|XPRM.F_LINBUF, "java:out")/⁎ Redirect error stream to Java output stream ⁎/mosel.setDefaultStream(XPRM.F_ERROR, "java:java.lang.System.out"

If the driver is used in an initializations from block (resp. initializations to block) andthe provided object implements interface XPRMInitializationFrom (resp.
XPRMInitializationTo) then the corresponding Java methods are used to process the initialization(refer to the Mosel Library JavaDoc for further explanation).

Fair Isaac Corporation Proprietary Information

245

Chapter 7: mmjava

This driver supports the delete operation: deleting a java file name from the Mosel code (e.g.
fdelete("java:out")) corresponds to executing unbind on the corresponding identifier. The
operator first tries to unbind the identifier associated to the running model (XPRMModel.unbind) andthen uses the global reference (XPRM.unbind) if the first attempt fails.

7.1.2 Driver jraw
jraw:[noindex,all]The driver can only be used in ‘initializations’ blocks. In the opening part of the block, no file name has tobe provided, but general options can be stated at this point: they will be applied to all labels. Two options
are supported:
allforces output of all cells of an array even if it is dynamic (by default only existing cells are
considered).

noindexindicates that only data (no indices) are transfered between the Java objects and Mosel.
By default, the first fields of each object are interpreted as index values for the array to betransfered. This behavior is changed by this option.

In the block, each label entry is understood as an object reference to use for the actual processing. Note
that, before the object reference, one can add further options separated by comas, that are effective tothe particular entry.
If the Model object to be initialized (or saved) is a scalar or an array with option noindex, the driver
expects a Java object of a corresponding type (i.e. same basic type and scalar or one dimension array). If
the option noindex is not used and the Mosel object is an array, the label must specify which fields ofthe class have to be taken into account for the mapping. This is indicated by a list of field names
separated by commas and noted in brackets (e.g. "myobj(fi1,fi2,fi3)").
In the following example the jraw driver is used to initialize an array of reals, a, and an array of integers,ia, with data held in the Java application that executes the model.
Java part:
public class MyData {/⁎ A class to store an `array(string, int) of real' ⁎/public String s; public int r; public double v;
MyData(String i1, int i2, double v0) { s=i1; r=i2; v=v0; }}...
MyData[] data;
int[] intarr;...
mosel=new XPRM();
mosel.bind("data", data);/⁎ Associate `data' object with string "data" ⁎/mosel.bind("ia", intarr);/⁎ Associate `intarr' object with string "ia" ⁎/Mosel part:declarations
a:array(string, range) of real
ia:array(range) of integer
end-declarations...
initializations from "jraw:"
aa as "data(s,r,v)" ! Initialize `aa' with fields s,r,v of object `data'ia as "noindex,ia" ! Initialize `ia' with array `ia'; no index (only values)
end-initializations

Fair Isaac Corporation Proprietary Information

246

CHAPTER 8

mmjobsThanks 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 thathas 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'

8.1 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 latterhas 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
thenexit(1)
end-ifload(mymod,"shmem:bim")
fdelete("shmem:bim")! Load bim file from memory...
! ... and release the memory block! Disable model output
setdefstream(mymod,"","null:","null:")run(mymod)! Start execution andwait(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 finishedevent:=getnextevent
writeln("Exit status: ", getvalue(event))

Fair Isaac Corporation Proprietary Information

247

Chapter 8: mmjobs
writeln("Exit code

: ", getexitcode(mymod))unload(mymod)
end-model

8.2 Data sharing between models
A model may share data with its submodels under certain conditions: any initialisation performed by themaster 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 andarrays of basic types can be shared. For the arrays, index sets must be either shared or constants ofbasic types, shared hashmap arrays cannot have more than 1 dimension.
declarations
sci: shared integer
ss: shared set of stringsa: 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 anyother data structure as long as no compatible submodel is running. However, as soon as a submodelusing shared data is started the sharing mode is enabled and access to shared entities is altered asfollows: 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 modecan be obtained from the sharingstatus control parameter (getparam).
model "shared example"
uses 'mmjobs'
declarations
a: shared array(1..3) of integer
m: Modelend-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 itrun(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-ifend-model

8.3 Control parameters
The following parameters are defined by mmjobs:
conntmpl

Fair Isaac Corporation Proprietary Information

Default connection template.

p. 249248

Chapter 8: mmjobs

defaultnodeDefault node number used by driver ’rmt:’.

p. 249fsrvdelay

Maximum wait time for findxsrvs.

p. 251

fsrvnbiter

Number of iterations performed by findxsrvs.

p. 251

fsrvport

UDP port used by findxsrvs.

p. 250jobid

ID of the current model.

p. 250keepalive

Keepalive timer setting.

p. 250nodenumber

ID of the current instance.

p. 249parentnumber

ID of the parent of the current instance.

p. 250sshcmd

SSH command for xssh driver.

p. 251

conntmpl
Description

The connection template is used by the connect function to generate a valid host specificationfrom an identifier (typically corresponding to a host name). The generation is performed byreplacing in the template each occurrence of the %h marker by the original identifier.

Type

String, read/write

Values

A string containing "%h" at least once

Default value"xsrv:%h"Affects routines

connect.

Modulemmjobsnodenumber
Description

The ID (or node number) of the current instance as returned by the function getid applied tothis instance. The ID of the initial (root) instance is 0

Type

Integer, read only

Modulemmjobsdefaultnode
Description

This parameter is used by the IO driver "rmt:" when it is not given any node reference (seeSection 8.5.6). By default its value is 0 (the initial node) but it may be changed by a parent
model using the instance parameter defaultnode (see Annex B).

Type

Integer, read only

ModulemmjobsFair Isaac Corporation Proprietary Information249

Chapter 8: mmjobs

jobid
Description

The ID of the current model as returned by the function getid applied to this model. The ID of
the initial (root) model is 0

Type

Integer, read only

Modulemmjobsparentnumber
Description

The ID (or node number) of the parent (i.e., creator) of the current instance. The ID of the initialinstance is 0 and its parent is -1.

Type

Integer, read only

Modulemmjobskeepalive
Description

When using a Mosel remote instance (see connect), the server sends to its client a keepalive
message at fixed interval. A connection is considered broken if more thanmaxfail*interval seconds have elapsed since the last message received. Setting 0 for
maxfail disables this mechanism. This parameter can only be changed if no remote Mosel
instance is connected.

Type

String, read/write

Values

A string of the form "maxfail/interval"

Default value"2/60"

Modulemmjobsfsrvport
Description

This parameter defines the UDP port to be used by the findxsrvs routine for its broadcast
messages.

Type

Integer, read/write

Default value

2514

Affects routines

findxsrvs.

See also

fsrvnbiter, fsrvdelay.

ModulemmjobsFair Isaac Corporation Proprietary Information

250

Chapter 8: mmjobs

fsrvdelay
Description

After it has sent its broadcast message, the findxsrvs routine waits for up to fsrvdelay
milliseconds for answers before aborting.

Type

Integer, read/write

Default value

1000

Affects routines

findxsrvs.

See also

fsrvnbiter, fsrvport.

Modulemmjobsfsrvnbiter
Description

This control parameter specifies the number of times the procedure findxsrvs sends a
broadcast message.

Type

Integer, read/write

Default value

1

Affects routines

findxsrvs.

See also

fsrvdelay, fsrvport.

ModulemmjobssshcmdDescription

When connecting to a remote host via the "xssh:" I/O driver, an external program is used toestablish the SSH tunnel: this parameter specifies which program to use. The arguments of the
program are identified with the symbol "%h" for the target host, "%p" for the TCP port and"%f" for the known host file (which is "-" when no file is provided). For instance the following
string will select ssh as the program to handle the secure tunnel: "ssh -q -p %p -s %h
xprmsrv".
Note that this control parameter is read-only when Mosel is running under restriction NoExec(see Section 1.3.4).

TypeString, read/write

Affects routines

connect.

Values

A string including at least "%h"Default value"xprmsrv -sshclt %h -p %p -kh %f"

ModulemmjobsFair Isaac Corporation Proprietary Information

251

Chapter 8: mmjobs

8.4 Procedures and functions
8.4.1 Mosel instance management
The type Mosel is used to reference a Mosel instance. Before an instance can execute commands (likeloading or running a model), it must be connected. Connecting an instance consists in starting an
additional operating system process running Mosel: this is done by the connect function. To improvereadability of the model source, one can use host aliases (defined by means of the sethostalias
routine) to designate connection targets. Once work with a particular instance has been finished, theinstance can be disconnected (disconnect): this terminates the process running Mosel (and releases
all associated resources).
clearaliases

Delete all defined aliases.

p. 255connect

Connect a Mosel instance.

p. 253

disconnect

Disconnect a Mosel instance.

p. 254findxsrvs

Search xprmsrv servers on the local network.

p. 260getaliases

Retrieve the list of all defined aliases.

p. 258getbanner

Get the banner displayed by an instance on startup.

p. 256gethostalias

Get the value of a host alias.

p. 257sethostalias

Define a host alias.

p. 259Fair Isaac Corporation Proprietary Information

252

Chapter 8: mmjobs

connect
Purpose
Synopsis

Connect a Mosel instance.
function connect(mi:Mosel, host:string|text):integer

Argumentsmihost

The instance to connect
A host specification

Return value
0 if successful, a positive value otherwise
ExampleStart instance inst1 on a separate process:r:=connect(ins1,"")
With default settings, the 2 following statements are equivalent:
r:=connect(ins2,"ariane")
r:=connect(ins3,"xsrv:ariane")

Further information
1. Any Mosel instance has to be connected before it can be used for executing commands.
2. If the host provided is an empty string (""), it is replaced by "rcmd:" (instance started on the samemachine in a separate process). Otherwise, the string host is searched in the list of defined aliases (seesethostalias) and, if found, it is replaced by the associated text. If the resulting specification does notcontain any IO driver reference, a valid specification is generated using the current connection template(see conntmpl): each occurrence of the %h marker in the template is replaced by the value of host.
3. The host argument (or the string resulting from the transformations described above) is expected to be
an extended file name using an IO driver the task of which is to start a process running the mosel
program in remote mode and create/manage the communication streams between the processes. The
mmjobs module provides three drivers supporting this service (see Section 8.5): "rcmd:" to start a
Mosel instance on a separate process on the same machine, "xsrv:" to start a Mosel instance on ahost running the Mosel Remote Launcher (see Section 8.6) and "xssh:" to use a secure connection
with an xprmsrv server.
Related topics
sethostalias, findxsrvs, disconnect, Driver rcmd, Driver xsrv, Driver xssh
ModulemmjobsFair Isaac Corporation Proprietary Information

253

Chapter 8: mmjobs

disconnect
Purpose
Synopsis

Disconnect a Mosel instance.
procedure disconnect(mi:Mosel)

Argumentmi

The instance to disconnect

Further information
This routine should be used to terminate a Mosel instance started by connect.
Related topics
connect.
ModulemmjobsFair Isaac Corporation Proprietary Information

254

Chapter 8: mmjobs

clearaliases
Purpose
Synopsis

Delete all defined aliases.
procedure clearaliases

Further information
This routine deletes all host aliases previously defined by sethostalias.
Related topics
sethostalias,getaliases,gethostalias,connect.
ModulemmjobsFair Isaac Corporation Proprietary Information

255

Chapter 8: mmjobs

getbanner
Purpose
Synopsis

Get the banner displayed by an instance on startup.
function getbanner(mi:Mosel):stringArgumentmi

A connected instance

Return value
The text displayed by Mosel when it started the instanceFurther information
When a new instance is started, the text displayed by Mosel is saved (this includes typically copyrightnotice and version information): this function returns this startup banner.
Related topics
connect.
ModulemmjobsFair Isaac Corporation Proprietary Information

256Chapter 8: mmjobs

gethostalias
Purpose
Synopsis

Get the value of a host alias.
function gethostalias(alias:string):stringArgument
alias Internal identifier
Return value
The host specification corresponding to the alias or an empty string if the alias is not defined
Related topics
sethostalias,clearaliases,getaliases, connect.
ModulemmjobsFair Isaac Corporation Proprietary Information

257

Chapter 8: mmjobs

getaliases
Purpose
Synopsis

Retrieve the list of all defined aliases.
procedure getaliases(aliases:list of string)Argument
aliases A list to return the aliases
ExampleThe following procedure displays all aliases:
procedure showaliases
declarations
l:list of string
end-declarations
getaliases(l)forall(h in l)
writeln(h,"->",gethostalias(h))
end-procedure

Further information
This procedure resets its aliases argument.
Related topics
sethostalias,clearaliases,gethostalias, connect.
ModulemmjobsFair Isaac Corporation Proprietary Information

258

Chapter 8: mmjobs

sethostalias
Purpose
SynopsisDefine a host alias.
procedure sethostalias(alias:string,host:string)Arguments
alias Internal identifier
host Corresponding host specification
ExampleThe first statement defines "localhost" as a separate process on the same machine and "win" for aremote access to the machine "winpc":
sethostalias("localhost","rcmd:")
sethostalias("win","xsrv:winpc")

Further information
Host aliases are used by connect to start Mosel instances. If the argument host is the empty string,the corresponding alias is removed from the list (or nothing is done if the alias was not defined before).
Related topics
gethostalias,clearaliases,getaliases, connect.
ModulemmjobsFair Isaac Corporation Proprietary Information259

Chapter 8: mmjobs

findxsrvs
Purpose
Synopsis

Search xprmsrv servers on the local network.
procedure findxsrvs(group:integer,maxip:integer,addrs:set of string)Argumentsgroup Group number of the request
maxip Maximum number of addresses to collectaddrs Set to store the addresses foundFurther information
1. This procedure sends a broadcast message over the local network and waits for replies from running
xprmsrv servers (see Section 8.6). A given server will reply only to selected group numbers: the groupargument specifies this property.
2. The IP addresses of the hosts having replied to the request are returned via the last argument of theprocedure in the form of strings. The maximum size of this set is fixed by maxip. Note that the provided
set is not cleared: if it already contains maxip elements the routine returns immediately.
3. Control parameters fsrvnbiter, fsrvdelay and fsrvport can be used to tune the behaviour offindxsrvs. This routine repeats fsrvnbiter times the following procedure: it sends a broadcast
message to the fsrvport UDP port and then waits for up to fsrvdelay milliseconds for replies.
Related topics
connect, disconnect.
ModulemmjobsFair Isaac Corporation Proprietary Information

260

Chapter 8: mmjobs

8.4.2 Model management
The type Model is used to reference a Mosel model. This section describes the procedures and functions
available for model management: compilation of source model files, loading of bim files, execution andretrieval of model information. Note that before it can be used, a model has to be initialized by loading abim file (load).
compileCompile a source model.

p. 262

detachDetach the current model from its parent node.

p. 264getannidents

Get model identitifiers for which annotations are available.

p. 285getannotations

Get model annotations associated to a given symbol.

p. 286

getdsoprop, getdsopropnum

Get module information.

p. 273getexitcode

Get the exit code of a model.

p. 281

getgidGet the group ID of a model.

p. 274getid

Get the ID of a model or Mosel instance.

p. 275

Get model information.

p. 276

getmodprop, getmodpropnum
getnodeGet the ID (node number) of the Mosel instance of a model.

p. 277

getrmtid

Get the ID of a model on a remote instance.

p. 278

getstatus

Get the status of a model or of an instance.

p. 279getuidGet the user ID of a model.

p. 280load

Load a Binary Model file.

p. 265reset

Reset a model.

p. 283

resetmodpar

Remove a parameter from a model parameter string.

p. 268run

Run a model.

p. 272

setcontrol

Set an instance control parameter on a remote instance.

p. 269setdefstream

Set default input/output streams of a model.

p. 267

setmodpar

Add or change the value of a parameter in a model parameter string. p. 270

setworkdir

Set the initial working directory of a model.

p. 271

stop

Stop a running model.

p. 282

unloadUnload a model.

p. 284

Fair Isaac Corporation Proprietary Information

261

Chapter 8: mmjobs

compilePurpose
Synopsis

Compile a source model.
function compile(src:string|text):integerfunction compile(opt:string|text, src:string|text):integerfunction compile(opt:string|text, src:string|text, dst:
string|text):integerfunction compile(opt:string|text, src:string|text, dst: string|text,
com:string|text, pass:string|text, pke:string|text,
kls:string|text):integerfunction compile(mi:Mosel, opt:string|text, src:string|text, dst:
string|text):integerfunction compile(mi:Mosel, opt:string|text, src:string|text, dst:
string|text, com:string|text, pass:string|text, pke:string|text,
kls:string|text):integer

Arguments
opt

src
dst
com
mi
pass
pke
kls
Return value
0
1
2
3
4
ExampleCompilation options (may be separated by spaces or ’-’ symbols):"g"Include debugging information"G"
Include tracing information"s"
Strip symbols"p"parse only: stop after the syntax analysis of the source file, do not compile (no file
generated)"bx=prefix" Package prefix list (can be quoted with single or double quotes)"ix=prefix" Include source prefix (can be quoted with single or double quotes)"S"
Sign the bim file"E"
Encrypt the bim file"F"
The argument pass is a file name (not the password itself)"V"
Accept to load signed packages only if their signature can be verified"T"
Accept to load only signed packages with a valid signature
Source file name
Destination file nameComment to store in the bim file
The Mosel instance to perform the compilation
Password or password file (for encryption with a password)
Private key file (for bim file signing)
File of public keys (for encryption with public keys)
Function executed successfully
Parsing phase has failed (syntax error or file access error)
Error in compilation phase (a semantic error has been detected)
Error writing the output file
License error (compiler not authorized)

Compile the local file "src.mos" stored on the current directory using the instance inst1 and store theresulting BIM file on the current directory of this instance:
r:=compile(ins1,"","rmt:src.mos","dst.bim")

Fair Isaac Corporation Proprietary Information

262

Chapter 8: mmjobs

Further information
1. This function compiles a given model source file into a binary model file (bim file) that is required as input
to function load for executing the model.
2. If no destination file name is provided, the output file takes the same name as the source file with theextension .bim.
3. When sending a compilation request to a separate Mosel instance, it is important to keep in mind that theoperation is performed in the environment of this instance (in particular its current working directory) andfile names should be specified appropriately (the rmt: IO driver can be particularly helpful in thiscontext). An IO error will be raised in case of network failure.
4. The argument kls is a list of public key files (i.e. each line of the file is a key file name): when encrypting
a file, the encryption is performed for each of the listed public keys such that the bim file can bedecrypted by any of the corresponding private keys.
5. When prefixes provided via bx or ix are quoted with double quotes, backslashes are interpreted suchthat special characters can be included in the string. It is therefore required to double this symbol when it
has to be included (e.g. ’bx="C:\\mydir"’).
6. If the option bx is not stated, the current value of the control parameter bimprefix will be used instead
during the compilation for loading packages (See section 2.3.1).
Related topics
load.
ModulemmjobsFair Isaac Corporation Proprietary Information

263

Chapter 8: mmjobs

detach
Purpose
Synopsis

Detach the current model from its parent node.
procedure detach

Further information
1. This procedure detaches the model calling it from its parent model such that it becomes a master model
running on a root node. As a consequence the connection to its parent model is closed, its model number
is set to 0 and the node number of its instance becomes 0 (root node). The parent node is notified of thedetachment by means of a termination event for the model which gets the status RT_DETACHED.
2. The operation is possible only if the hosting intance is running exclusively this model (i.e. no submodel isloaded at the time of calling detach) and no file is open between the hosting instance or the model andits parent (in particular the default streams have to be set to "null:").
3. After a model is detached, it can no longer communicate with its parent using events or access files
through the "rmt:" driver. The HTTP protocol (available through the module mmhttp) might be used as
an alternative to the facilities provided by mmjobs in this case.
4. The instance running the detached model terminates automatically after the end of execution of themodel.
5. This routine can only be called by a submodel running on a remote instance. It has no effect if used by amaster model.
Related topics
getstatus, run.
ModulemmjobsFair Isaac Corporation Proprietary Information

264

Chapter 8: mmjobs

load
Purpose
Synopsis

Load a Binary Model file.
procedure load(mo:Model)
procedure load(mo:Model, bimf:string|text)
procedure load(mo:Model, mr:Model)
procedure load(mo:Model, bimf:string|text, opt:string|text,
pass:string|text, pke:string|text, kls:string|text)
procedure load(mi:Mosel, mo:Model, bimf:string|text)
procedure load(mi:Mosel, mo:Model, bimf:string|text, opt:string|text,
pass:string|text, pke:string|text, kls:string|text)

Arguments
mo
mr
bimf
mi
opt

pass
pke
kls

Model object to be initialized
Model object used as a reference
Bim file name
The instance on which the model will be run
Loading options (may be separated by spaces or ’-’ symbols):"c"
Check signature (if the file is signed)"V"
If the file is signed, load it only if the signature is valid"T"
Load only signed files with a valid signature"F"
The argument pass is a file name (not the password itself)"l"
Do not load required packages
Password or password file (for encrypted bim files)
Private key file (for encrypted bim files)
File of public keys

Further information
1. This procedure initializes the model mo with the bim file bimf. If mo has already been initialized, themodel it references is unloaded before trying to load the new file (note that this operations fails if themodel is running). If the file bimf cannot be accessed or one of the required modules cannot be loaded,
the procedure generates an IO error (which may be intercepted if the control parameter ioctrl is true).
2. When loading a model from a separate Mosel instance, it is important to keep in mind that the operationis performed in the environment of this instance (in particular its current working directory) and filenames should be specified appropriately (the rmt: IO driver can be particularly helpful in this context).
3. The argument kls is a list of public key files (i.e. each line of the file is a key file name): when a signed
bim file is loaded, its signature is checked with the keys listed in this file. If this argument is not specified,
the signing key is searched in the default public keys directory located at
getparam("ssl_dir")+"/pubkeys".
4. Packages required for the loading of a model are located using the list of prefixes defined by the control
parameter bimprefix (See section 2.3.1).
5. When invoked with a single argument this routine creates a new model from the one being executed(without using any bim file): this clone can access data shared by its master model (see Section 8.2).
Similarly, when a model is used in place of a bim file the new generated model is a copy of the provided
reference model. Note that all copies of a given model share the constant information (like constantstrings or the code segment) of the reference model. As a consequence, during a debugging session,
setting a breakpoint in a model loaded this way also installs the same breakpoint in all other models
coming from the same source (including the reference model).

Fair Isaac Corporation Proprietary Information

265

Chapter 8: mmjobs

Related topics
compile, setdefstream, run, unload.
ModulemmjobsFair Isaac Corporation Proprietary Information

266

Chapter 8: mmjobs

setdefstream
Purpose
Synopsis

Set default input/output streams of a model.
procedure setdefstream(mo:Model, wmd:integer, fname:string)procedure setdefstream(mo:Model, input:string, output:string, error:string)procedure setdefstream(mi:Mosel, wmd:integer, fname:string)procedure setdefstream(mi:Mosel, input:string, output:string, error:string)Arguments
mo
mi
wmd

A ModelA Mosel instanceStream to set. Possible values:
F_INPUT
Default input stream
F_OUTPUT
Default output stream
F_ERROR
Default error stream
F_LINBUF
Use line buffering
fname
Extended file name to be used for the stream.
input
Extended file name to be used for the input stream.
output Extended file name to be used for the output stream.
error
Extended file name to be used for the error stream.

Further information
1. This function sets default IO streams to be used by a model. Model streams can be changed only whenthe model is not running. Each stream is associated to an extended file name (i.e. IO drivers can be used).
For output streams, F_LINBUF may be specified (e.g.F_OUTPUT+F_LINBUF) in order to enable line
buffering for the corresponding stream (the error stream is always open using line buffering).
2. For input and output streams, the filename is stored and streams are actually open when execution of themodel starts: in case of an invalid file name, the error is not reported by this function. The error stream is
immediately opened so in the case of an invalid file name it is detected by this function.
3. Using an empty string as the file name implies resetting to the original default stream.
4. When applied to a Mosel instance, this routine sets the default streams for this instance. These streams
can only be changed if the instance has not yet loaded any model.
5. When using this routine on a separate Mosel instance or on a model loaded on a separate Mosel instance,
it is important to keep in mind that the operation is performed in the environment of this instance (inparticular its current working directory) and file names should be specified appropriately (the rmt: IO
driver can be particularly helpful in this context).
6. An IO error will be raised in case of failure during a file operation.
Related topics
getfname.
ModulemmjobsFair Isaac Corporation Proprietary Information

267

Chapter 8: mmjobs

resetmodpar
Purpose
Synopsis

Remove a parameter from a model parameter string.
procedure resetmodpar(plist:text, pname:string|text)

Arguments
plist Text object storing the parameterspname Parameter name
Further information
1. This function helps in building the model parameter string to be passed to the run procedure by
removing a parameter definition (previously set with setmodpar) from a parameter string. The plist
text is left unchanged if the requested parameter cannot be found.
2. It is expected that the provided text string is either empty or composed of a list of assignments of theform "pname=val,pname2=val2...".
Related topics
setmodpar, run.
ModulemmjobsFair Isaac Corporation Proprietary Information

268

Chapter 8: mmjobs

setcontrol
Purpose
Synopsis

Set an instance control parameter on a remote instance.
procedure setcontrol(mi:Mosel, ctrl:string, val:string)procedure setcontrol(mo:Model, ctrl:string, val:string)Arguments
mi
mo
ctrl
val

A Mosel instanceA model reference (it must be loaded onto a remote instance)
Control nameControl value

Further information
1. This procedure is used to change an instance control parameter in the context of the Remote Invocation
Protocol (see Annex B).
2. An IO error is raised in case of error.
ModulemmjobsFair Isaac Corporation Proprietary Information

269

Chapter 8: mmjobs

setmodpar
Purpose
Synopsis

Add or change the value of a parameter in a model parameter string.
procedure setmodpar(plist:text, pname:string|text,
val:integer|real|boolean|string|text)

Arguments
plist Text object storing the parameterspname Parameter nameval
Value assigned to the parameter.
Further information
1. This function helps in building the model parameter string to be passed to the run procedure. As input ittakes a text object that it modifies by either adding an assignment of the form pname=val or byreplacing an existing assignment. The routine adds the necessary quoting as necessary.
2. It is expected that the provided text string is either empty or composed of a list of assignments of theform "pname=val,pname2=val2...".
Related topics
resetmodpar, run.
ModulemmjobsFair Isaac Corporation Proprietary Information

270

Chapter 8: mmjobs

setworkdir
Purpose
Synopsis

Set the initial working directory of a model.
procedure setworkdir(mo:Model, cwd:string)Argumentsmocwd
ExampleA model reference
Initial working directory

The following statement sets the initial working directory of submodel sub to the current directory of its
master model:
setworkdir(sub,'.')

Further information
1. This procedure defines the initial working directory to be used when the execution of the model (re)starts.
As a consequence it cannot be used to change the environment of a running model.
2. For a local execution the provided path is expanded just before the beginning of the execution relatively
to the current working directory of the caller. For a remote execution the path is relative to the directory of
the instance running the model.
Related topics
run.
ModulemmjobsFair Isaac Corporation Proprietary Information

271

Chapter 8: mmjobs

run
Purpose
Synopsis

Run a model.
procedure run(mo:Model)
procedure run(mo:Model, plist:string|text)

Arguments
moModel to be executed
plist String composed of model parameter initializations separated by commas
Further information
1. This procedure starts the execution of a model in a new thread: when the procedure returns, the model is
not necessarily started (this may be delayed depending on the operating system load) and notnecessarily terminated (the second model is executing concurrently to the caller).
2. By default the execution starts in the working directory of the Mosel instance (that might be different
from the working directory of the calling model). A different initial path can be setup using setworkdir.
3. When the execution of the model is completed (normal termination, interruption after calling stop, or
runtime error) or could not be started, an event of class EVENT_END is sent to the caller. The execution
status is returned via the event value but it may also be obtained using getstatus. The exit code related
to the last execution may be retrieved using getexitcode.
4. An event EVENT_END is also received after a model has detached itself although its execution may
continue (see detach). In this case the model status is RT_DETACHED and its associated instance isdisconnected.
5. The specified model must have been previously initialized with load and must not be running. If thesame model has to be executed several times concurrently, it must be loaded several times in different
model objects.
6. The parameter string plist may be built and modified using setmodpar and resetmodpar. Theseroutines handle transparently the protection of parameter values by adding the appropriate quotes whenrequired.
Related topics
load, wait, waitforend, setmodpar, stop, getstatus, getexitcode, reset.
ModulemmjobsFair Isaac Corporation Proprietary Information

272

Chapter 8: mmjobs

getdsoprop, getdsopropnum
Purpose
Synopsis

Get module information.
function getdsoprop(dso:string, prop:integer):string
function getdsopropnum(dso:string, prop:integer):realArguments
dso
prop

The name of a module currently loaded into memory
The property to retrieve. Possible values:
PROP_NAME
Module name
PROP_VERSION Module version
PROP_PATH
Path to the module file

Return value
The property as a string (real for getdsopropnum) or an empty string (-1 for getdsopropnum) in caseof error (invalid property or the module was not found)
Related topics
getmodprop
ModulemmjobsFair Isaac Corporation Proprietary Information

273

Chapter 8: mmjobs

getgidPurpose
Synopsis

Get the group ID of a model.
function getgid(mo:Model):integer

Argumentmo

A modelReturn value
Group ID of the model
Further information
A model can be associated with a group ID using setgid. This group ID may be used to identify theorigin of an event (see getfromgid) or as a filter for a wait (see waitfor).
Related topics
getuid, getid, setgid
ModulemmjobsFair Isaac Corporation Proprietary Information274

Chapter 8: mmjobs

getid
Purpose
Synopsis

Get the ID of a model or Mosel instance.
function getid(mo:Model):integerfunction getid(mi:Mosel):integer

Argumentsmomi

A modelA Mosel instance

Return value
ID of the model or instance as an integer
Further information
1. Each model object has a unique ID number that can be obtained with this function. This ID may be used
to identify the origin of an event (see getfromid) or as a filter for a wait (see waitfor).
2. The ID number of a Mosel instance is its node number. The initial instance has node number 0.
Related topics
getuid, getgid, jobid
ModulemmjobsFair Isaac Corporation Proprietary Information

275

Chapter 8: mmjobs

getmodprop, getmodpropnum
Purpose
Synopsis

Get model information.
function getmodprop(mo:Model, prop:integer):string
function getmodprop(prop: integer):string
function getmodpropnum(mo:Model, prop:integer):realfunction getmodpropnum(prop: integer):realArgumentsmo
prop

A modelThe property to retrieve. Possible values:
PROP_NAME
Model name (cf. model statement)
PROP_ID
Order number
PROP_VERSION Model version
PROP_SYSCOM
System comment
PROP_USRCOM
User comment
PROP_SIZE
Amount of memory (in bytes) used by the model
PROP_DATE
Compilation date
PROP_UNAME
Unique model nameReturn value
The property as a string (real for getmodpropnum) or an empty string (-1 for getmodpropnum) in caseof error
Further information
The second form of the function reports information for the calling model.
Related topics
getdsoprop, memoryuse
ModulemmjobsFair Isaac Corporation Proprietary Information276

Chapter 8: mmjobs

getnodePurpose
Synopsis

Get the ID (node number) of the Mosel instance of a model.
function getnode(mo:Model):integerfunction getnode(mi:Mosel):integer

Argumentsmomi

A modelA Mosel instance

Return value
ID of the instance on which the model is loaded as an integer or -1 if the model has not been loaded
Further information
1. This function returns the node number of the current instance if the provided model is local.
2. When applied to a Mosel instance this function returns the same information as getid.
ModulemmjobsFair Isaac Corporation Proprietary Information

277

Chapter 8: mmjobs

getrmtid
Purpose
Synopsis

Get the ID of a model on a remote instance.
function getrmtid(mo:Model):integer

Argumentmo

A modelReturn value
ID of the model on the remote instance as an integer or -1 if the model has not been loaded or is local to
the running instance.
Further information
This ID corresponds to the model number assigned to the model by Mosel when it is loaded (i.e. the valueof the control parameter modelnumber). This function can only be used on models handled by remote
instances.
ModulemmjobsFair Isaac Corporation Proprietary Information

278

Chapter 8: mmjobs

getstatus
Purpose
Synopsis

Get the status of a model or of an instance.
function getstatus(mo:Model):integerfunction getstatus(mi:Mosel):integer

Argumentsmomi

A modelA Mosel instance

Return value
The status of a Mosel instance is 0 if it is connected, any other value indicates that it is not ready. The
model status can be:
RT_NOTINIT
Model has not been initialized or has been unloaded
RT_RUNNING
Model is running
RT_OK
Model is ready for execution and/or no error occurred during last execution
RT_MATHERR
A mathematical error occurred
RT_ERROR
A runtime error occurred
RT_IOERRAn IO error occurred
RT_NULL
A NULL reference error occurred
RT_LICERR
Execution could not start because no license was available
RT_FDCLOSED Execution on a separate instance has been interrupted
RT_DETACHED Execution on a separate instance continues although the instance has been
disconnected (see detach)
RT_STOP
Execution has been interrupted by a call to stop
Related topics
connect, stop, getexitcode.
ModulemmjobsFair Isaac Corporation Proprietary Information279

Chapter 8: mmjobs

getuidPurpose
Synopsis

Get the user ID of a model.
function getuid(mo:Model):integer

Argumentmo

A modelReturn value
User ID of the model
Further information
A model can be associated with a user ID using setuid. This user ID may be used to identify the originof an event (see getfromuid) or as a filter for a wait (see waitfor).
Related topics
getgid, getid, setuid
ModulemmjobsFair Isaac Corporation Proprietary Information

280

Chapter 8: mmjobs

getexitcode
Purpose
Synopsis

Get the exit code of a model.
function getexitcode(mo:Model):integer

Argumentmo

A modelReturn value
Exit code of the last execution or 0
Further information
1. The exit code of the last execution corresponds to the value stated via a call to the procedure exit. The
default exit value (i.e. procedure exit has not been called) is 0.
2. The value of the exit code is defined only when the execution of the model succeeded (i.e. its status is
RT_OK). This function will return 0 before the model is executed or after a runtime error.
Related topics
getstatus.
ModulemmjobsFair Isaac Corporation Proprietary Information

281

Chapter 8: mmjobs

stop
Purpose
Synopsis

Stop a running model.
procedure stop(mo:Model)

ArgumentmoModel to interrupt

Further information
If the model is not currently running, no operation is performed. Note that the effect of this call may not
be immediate and the corresponding model may continue running a few seconds before its effective
interruption (for instance the time required to complete an IO operation).
Related topics
run.
ModulemmjobsFair Isaac Corporation Proprietary Information

282

Chapter 8: mmjobs

reset
Purpose
Synopsis

Reset a model.
procedure reset(mo:Model)

ArgumentmoModel to reset

Further information
This procedure resets a model after its execution: all resources it has allocated are released. The model
returns to its state just after it has been loaded into memory. Note that this function is automaticallycalled before a model is unloaded or run.
Related topics
run, unload.
ModulemmjobsFair Isaac Corporation Proprietary Information

283

Chapter 8: mmjobs

unloadPurpose
Synopsis

Unload a model.
procedure unload(mo:Model)

ArgumentmoModel to unload

Further information
1. This procedure unloads the given model. All resources used by this model, including modules, arereleased. The function fails if the model is running.
2. An IO error will be raised in case of network failure while unloading a model from a remote instance.
Related topics
load.
ModulemmjobsFair Isaac Corporation Proprietary Information284

Chapter 8: mmjobs

getannidents
Purpose
Synopsis

Get model identitifiers for which annotations are available.
procedure getannidents(mo:Model, si:set of string)Argumentsmosi

A model reference
Set receiving the identifiers

Further information
This routine cannot be used with remote models.
Related topics
getannotations, applied to the model itself: getannidents.
ModulemmjobsFair Isaac Corporation Proprietary Information

285

Chapter 8: mmjobs

getannotations
Purpose
Synopsis

Get model annotations associated to a given symbol.
procedure getannotations(mo:Model, id:string, prefix:string, si:set of
string, ann:array(string) of string)procedure getannotations(mo:Model, id:string, prefix:string, lsa:list of
string)Argumentsmo
A model reference
id
Symbol for which annotations are requested (an empty string will report global declarations)prefix Prefix filter: only annotations with a name starting by the specified prefix will be returnedsi
Set receiving the annotation names
ann
Array receiving the annotation values (indiced by names)
lsa
List receiving the annotation names and values
ExampleThe following code snippet implements a function to retrieve a specific annotation for the specified
model entity (if several matching annotations are found the value of the first is returned):public function getannot(mo:Model, symb:string, aname:string):string
declarations
l:list of string
end-declarations
getannotations(mo,symb,aname,l)if l.size>=2 and l(1)=aname thenreturned:=l(2)end-ifend-function
writeln("Value of first annotation 'my.annot' for entity 'x': ",getannot(mo,"x","my.annot"))
writeln("Value of first global annotation 'my.annot': ",getannot(mo,"","my.annot"))

Further information
1. With the version taking a list, each annotation is represented by 2 entries: the first one is the annotation
name and the second one its value. Note that the version returning information via an array will only
report partial information in the case of annotations defined several times.
2. These routines cannot be used with remote models.
Related topics
getannidents, applied to the model itself: getannotations.
ModulemmjobsFair Isaac Corporation Proprietary Information

286

Chapter 8: mmjobs

8.4.3 Synchronization
Synchronization between running models can be implemented using events. Events are characterized bya class and a value and may be exchanged between a model and its parent model. The model from whichan event has been sent is identified by its unique ID, its user ID and its group ID. An event queue isattached to each model to collect all events sent to this model and is managed with a FIFO policy (First In– First Out). Depending on the needs, a model may check whether its queue is empty or simply suspend
its execution until it has been sent an event.
The type Event represents an event in the Mosel language. Objects of type Event may be compared with =or <> and assigned with :=. The function nullevent returns an event without class and value: this is
the initial value of a newly created event and no model can send an event of this kind (i.e. the class isnecessarily not null).
canceltimer

Cancel an active timer.

p. 288dropnextevent

Drop the next event in the event queue of the model.

p. 299getclass

Get the class of an event.

p. 305getfromgid

Get the group ID of the sender of an event.

p. 303getfromid

Get the ID of the sender of an event.

p. 302

getfromuid

Get the user ID of the sender of an event.

p. 304getnextevent

Get the next event in the event queue of the model.

p. 298gettimer

Get the amount of time remaining before a timer expires.

p. 306

getvalueGet the value associated with an event.

p. 307

isqueueempty

Check whether there are events waiting in the event queue.

p. 300nullevent

Return a ‘null’ event.

p. 301

peeknextevent

Peek the next event in the event queue of the model.

p. 308

pipeflush

Clears the internal buffer of a memory pipe.

p. 309pipenotify

Register for a notification associated to a memory pipe.

p. 310send

Send an event to a running model.

p. 289setgidSet the group ID of a model.

p. 292

settimer

Create or update a timer.

p. 290setuidSet the user ID of a model.

p. 291

wait

Wait for an event.

p. 293

waitexpired

Indicate whether the previous ’wait’ or ’waitfor’ expired.

p. 294

waitfor

Wait for specific events.

p. 295

waitforend

Wait for the end of execution of a model.

p. 297

Fair Isaac Corporation Proprietary Information

287

Chapter 8: mmjobs

canceltimer
Purpose
SynopsisCancel an active timer.
procedure canceltimer(tid:integer)

Argumenttid

A timer identifier

Further information
1. This procedure has no effect if it cannot find the requested timer. However it will delete from the event
queue the event EVENT_TIMER coresponding to a timer that is no longer active.
2. If the provided timer identifier tid is negative or null all timers are cancelled.
Related topics
settimer, gettimer.
ModulemmjobsFair Isaac Corporation Proprietary Information

288

Chapter 8: mmjobs

send
Purpose
Synopsis

Send an event to a running model.
procedure send(mo:Model, class:integer, value:real)procedure send(class:integer, value:real)

Arguments
moModel to send the event toclass Event class (must be >1)
value Event value
Further information
1. Events can be sent to models started by the caller (the child models) by using the first form of theprocedure and to the model having started the caller (the parent model) with the second form of theprocedure. An event can be received only by a running model using the mmjobs module: sending an eventto a model that is not running or not using mmjobs is a no-operation.
2. Events are characterized by a class and a value. Event class values can be used to indicate the causeof the event (for instance, 2 could mean ‘a new solution has been found’) and the associated value may
specify a property of the given instance (for example an objective value). Except for the special value 1(EVENT_END) class values have no predefined meaning.
3. An event of class EVENT_END (=1) and model status as the event value is automatically sent by eachmodel to its parent model when it terminates its execution.
Related topics
wait, waitfor.
ModulemmjobsFair Isaac Corporation Proprietary Information289

Chapter 8: mmjobs

settimer
Purpose
SynopsisCreate or update a timer.
function settimer(tid:integer, dur:integer, rep:boolean):integerfunction settimer(dur:integer, rep:boolean):integer

Arguments
tid
dur
rep

A timer identifier
A duration in milliseconds
Decides whether the timer will be armed one time only or automatically repeated

Return value
Timer identifier as a positive integer
Further information
1. This function creates or updates an interval timer: after a timer has been armed by a call to this routine an
event of class EVENT_TIMER is scheduled for being sent to the model after the specified amount of time
has elapsed. The value of such an event is the timer identifier tid. Note that the system will not emit a
new event if an identical event is already in the queue.
2. If the option rep is set to false the timer is released after its termination, otherwise it is immediately
re-armed with the same interval after each expiration until it is explicitly cancelled (see canceltimer).
3. If the provided identifier tid is not positive a new timer is created with a newly generated identifier, thiscorresponds to the behaviour of the second form of this function.
4. When the provided identifier corresponds to an existing timer, this one is first cancelled with a call tocanceltimer before being re-created with the new properties.
Related topics
canceltimer, gettimer.
ModulemmjobsFair Isaac Corporation Proprietary Information

290

Chapter 8: mmjobs

setuidPurpose
Synopsis

Set the user ID of a model.
procedure setuid(mo:Model,uid:integer)

Argumentsmouid

A modelNew user ID

Further information
This function defines the user ID associated to a model (by default it is 0). This user ID may be used to
identify the origin of an event (see getfromuid).
Related topics
setgid, getuid
ModulemmjobsFair Isaac Corporation Proprietary Information

291

Chapter 8: mmjobs

setgidPurpose
Synopsis

Set the group ID of a model.
procedure setgid(mo:Model,gid:integer)

Argumentsmogid

A modelNew group ID

Further information
This function defines the group ID associated to a model (by default it is 0). This group ID may be used to
identify the origin of an event (see getfromgid).
Related topics
setuid, getgid
ModulemmjobsFair Isaac Corporation Proprietary Information

292

Chapter 8: mmjobs

wait
Purpose
Synopsis

Wait for an event.
procedure wait
procedure wait(dur:integer)

Argumentdur

A duration in seconds or the constant WAIT_INFINITE

Further information
This procedure suspends the execution of the caller until an event is available. The second form specifies
a time limit: the processing is suspended for at most dur seconds, the special value WAIT_INFINITE isinterpreted as an infinite duration. The behaviour of the procedure is undefined if the specified duration issmaller than 1 second.
Related topics
send, waitfor, waitforend, waitexpired, isqueueempty, getnextevent, dropnextevent.
ModulemmjobsFair Isaac Corporation Proprietary Information

293

Chapter 8: mmjobs

waitexpired
Purpose
Synopsis

Indicate whether the previous ’wait’ or ’waitfor’ expired.
function waitexpired:boolean

Return value
true if the last call to wait or waitfor terminated after expiration of a time limit
Related topics
wait, waitfor.
ModulemmjobsFair Isaac Corporation Proprietary Information

294

Chapter 8: mmjobs

waitforPurpose
Synopsis

Wait for specific events.
procedure waitfor(mask:integer)
procedure waitfor(mask:integer,dur:integer)
procedure waitfor(mask:integer,dur:integer,opt:integer)
procedure waitfor(mask:integer,id:integer,dur:integer,opt:integer)

Arguments
mask
id
dur
opt

ExampleBit mask of expected events
ID of model for which events are expected
A duration in seconds, the constant WAIT_INFINITE or a timer identifier as a negative integer
Options:
WAIT_EXACT Mask must be exactly matched
WAIT_KEEP Keep unexpected events
WAIT_UID
Wait for a particular user ID
WAIT_GID
Wait for a particular group ID

The following statement waits for an event of class 3 coming from a model of group 100 without
dropping any event:waitfor(3,100,WAIT_INFINITE,WAIT_KEEP+WAIT_EXACT+WAIT_GID)

Further information
1. This procedure suspends the execution of the caller until an event of a particular class is available. The
second form specifies a time limit: the processing is suspended for at most dur seconds, the special
value WAIT_INFINITE is interpreted as an infinite duration.
2. If the time limit is 0 the execution is not suspended but the queue of events is processed once and asubsequent call to waitexpired will return true if no valid event was found.
3. The parameter dur may also take a negative value: in this case it is interpreted as the opposite of a timer
identifier (see settimer) and the function will wait until this timer expires if no valid event arrives. Whenthe routine interrupts its monitoring due to the expiration of a timer the first event in the queue is theevent EVENT_TIMER associated to this timer. Note that if no timer corresponds to the given value theroutine will terminate only when an expected event is available as if WAIT_INFINITE had been used.
4. By default, the parameter mask is interpreted as a bit mask to select the expected events: all events sent
to the model are automatically dropped until an event ev satisfies the following condition:
bittest(getclass(ev),mask)<>0

5. If the parameter opt includes option WAIT_EXACT, the parameter mask becomes the target event class:
the wait will end when an event of a class equal to mask is found.
6. If the parameter opt includes option WAIT_KEEP, unexpected events are not dropped but the first event
satisfying the condition is moved to the top of the queue such that it is returned by the next call togetnextevent.
7. With the last form of the function an ID is specified: it characterises events coming from a particularmodel or a group of models. By default the argument id is interpreted as the unique model ID (seegetid), if option WAIT_UID is used, the ID is interpreted as a user ID (see getuid) and with option
WAIT_GID the argument is a group ID (see getgid).

Fair Isaac Corporation Proprietary Information

295

Chapter 8: mmjobs

Related topics
send, wait, waitexpired, isqueueempty, getnextevent, dropnextevent.
ModulemmjobsFair Isaac Corporation Proprietary Information

296

Chapter 8: mmjobs

waitforend
Purpose
Synopsis

Wait for the end of execution of a model.
procedure waitforend(mo:Model)
procedure waitforend(mo:Model,dur:integer)

Argumentsmodur

A modelA duration in seconds, the constant WAIT_INFINITE or a timer identifier as a negative integer

Further information
1. This procedure suspends the execution of the caller until a given model has terminated its execution. The
second form specifies a time limit: the processing is suspended for at most dur seconds, the special
value WAIT_INFINITE is interpreted as an infinite duration.
2. Before the procedure returns all events received from the model to monitor are removed from the event
queue (including the EVENT_END event) unless the time limit has been reached. In this case some of theevents of the submodel may have been removed from the event queue.
3. If the time limit is 0 the execution is not suspended but the queue of events is processed once and asubsequent call to waitexpired will return true if the model was still running when the procedure wascalled (the event queue is not modified in this case).
4. The parameter dur may also take a negative value: in this case it is interpreted as the opposite of a timer
identifier (see settimer) and the function will wait until this timer expires if no valid event arrives. Whenthe routine interrupts its monitoring due to the expiration of a timer the first event in the queue is theevent EVENT_TIMER associated to this timer. Note that if no timer corresponds to the given value theroutine will terminate only when an expected event is available as if WAIT_INFINITE had been used.
Related topics
wait, waitexpired.
ModulemmjobsFair Isaac Corporation Proprietary Information

297

Chapter 8: mmjobs

getnextevent
Purpose
Synopsis

Get the next event in the event queue of the model.
function getnextevent:Event

Return value
The next event or nullevent if the queue is empty
Further information
The returned event is removed from the queue after it has been retrieved with this function.
Related topics
peeknextevent, dropnextevent, isqueueempty.
ModulemmjobsFair Isaac Corporation Proprietary Information

298

Chapter 8: mmjobs

dropnextevent
Purpose
Synopsis

Drop the next event in the event queue of the model.
procedure dropnextevent

Further information
This procedure has no effect if the event queue is empty.
Related topics
peeknextevent, getnextevent, isqueueempty.
ModulemmjobsFair Isaac Corporation Proprietary Information

299

Chapter 8: mmjobs

isqueueempty
Purpose
SynopsisCheck whether there are events waiting in the event queue.
function isqueueempty:boolean

Return value
false if at least one event is available in the queue, true otherwise.
Related topics
dropnextevent, peeknextevent, getnextevent.
ModulemmjobsFair Isaac Corporation Proprietary Information

300

Chapter 8: mmjobs

nulleventPurpose
Synopsis

Return a ‘null’ event.
function nullevent:Event

Return value
An event of class and value equal to 0
Further information
Variables of type Event are initialized with this function.
Related topics
getnextevent.
ModulemmjobsFair Isaac Corporation Proprietary Information

301

Chapter 8: mmjobs

getfromid
Purpose
Synopsis

Get the ID of the sender of an event.
function getfromid(ev:Event):integer

Argumentev

An event

Return value
The ID of the sender of the event. 0 is returned for a nullevent
Further information
1. Each model has a unique ID that is attached to each event it sends. With this function one can identify thesender of a given event.
2. The ID of an event sent from the parent model is always 0.
Related topics
getid, getfromgid, getfromuid, getvalue, getclass.
ModulemmjobsFair Isaac Corporation Proprietary Information

302

Chapter 8: mmjobs

getfromgid
Purpose
Synopsis

Get the group ID of the sender of an event.
function getfromgid(ev:Event):integer

Argumentev

An event

Return value
The group ID of the sender of the event. 0 is returned for a nullevent
Further information
1. Each model can be associated with a group ID that is attached to each event it sends. With this function
one can identify the sender of a given event.
2. The group ID of an event sent from the parent model is always 0.
Related topics
getgid, setgid, getvalue, getfromid, getfromuid, getclass.
ModulemmjobsFair Isaac Corporation Proprietary Information

303

Chapter 8: mmjobs

getfromuid
Purpose
Synopsis

Get the user ID of the sender of an event.
function getfromuid(ev:Event):integer

Argumentev

An event

Return value
The user ID of the sender of the event. 0 is returned for a nullevent
Further information
1. Each model can be associated with a user ID that is attached to each event it sends. With this function
one can identify the sender of a given event.
2. The user ID of an event sent from the parent model is always 0.
Related topics
getuid, setuid, getvalue, getfromid, getfromgid, getclass.
ModulemmjobsFair Isaac Corporation Proprietary Information

304

Chapter 8: mmjobs

getclass
Purpose
Synopsis

Get the class of an event.
function getclass(ev:Event):integer

Argumentev

An event

Return value
The class of the event (>0) or 0 for a nullevent
Further information
A model sends automatically an event of class EVENT_END(=1) when it terminates its processing. Other
values are application specific.
Related topics
getvalue, getfromid, getfromgid, getfromuid.
ModulemmjobsFair Isaac Corporation Proprietary Information

305

Chapter 8: mmjobs

gettimer
Purpose
Synopsis

Get the amount of time remaining before a timer expires.
function gettimer(tid:integer):integer

Argumenttid

A timer identifier

Return value
Remaining time in milliseconds before the timer expires or 0 if the corresponding event is alreadyavailable in the queue or -1 if no timer corresponds to the provided identifier
Further information
This function will return 0 if an event corresponding to the specified timer is waiting in the queue of event
even if this timer has been automatically re-armed.
Related topics
canceltimer, settimer.
ModulemmjobsFair Isaac Corporation Proprietary Information

306

Chapter 8: mmjobs

getvalue
Purpose
Synopsis

Get the value associated with an event.
function getvalue(ev:Event):realArgumentev

An event

Return value
The value of the event
Further information
In the case of an event of class EVENT_END(=1), this value corresponds to the model status.
Related topics
getclass, getfromid, getfromgid, getfromuid.
ModulemmjobsFair Isaac Corporation Proprietary Information

307

Chapter 8: mmjobs

peeknextevent
Purpose
Synopsis

Peek the next event in the event queue of the model.
function peeknextevent:Event

Return value
A copy of the next event or nullevent if the queue is empty
Further information
The returned event is a copy of the first available event of the queue. The event queue is not changed bythis function.
Related topics
getnextevent, dropnextevent, isqueueempty.
ModulemmjobsFair Isaac Corporation Proprietary Information

308

Chapter 8: mmjobs

pipeflush
Purpose
Synopsis

Clears the internal buffer of a memory pipe.
function pipeflush(pname:string):boolean

Argument
pname Name of the pipe to clear
Return value
true if the operation was successful
Further information
This function can be called only if the caller is the model that has opened the pipe for reading or if nomodel is reading from this pipe.
ModulemmjobsFair Isaac Corporation Proprietary Information309

Chapter 8: mmjobs

pipenotify
Purpose
Synopsis

Register for a notification associated to a memory pipe.
function pipenotify(pname:string,class:integer,value:real):boolean

Arguments
pname Name of the pipe to monitor
class Event class (0 or must be >1)
value Event value
Return value
true if the operation was successful
Further information
1. This function sets up a monitor on a memory pipe (See section 8.5.2) such that an event (with thespecified class and value) is sent to the model when some data is available for reading from the pipe.
The event is sent immediately and no monitor is installed if the pipe is already non-empty.
2. The mechanism is effective for one notification only: after the event has been sent the monitor isremoved, the function must be called again if the program requires further notifications.
3. It is not possible to install several monitors on a given pipe (the function returns false if a monitor isalready active), however a model can remove a monitor that it has previously requested through thisfunction by calling it again with a class set to 0.
ModulemmjobsFair Isaac Corporation Proprietary Information

310

Chapter 8: mmjobs

8.5 I/O drivers
The mmjobs module provides a modified version of the mem IO driver designed to be used in a
multithreaded environment: memory blocks allocated by the shmem IO driver are persistent (i.e. they are
not released after the model terminates) and can be used by several models. Thanks to this facility,
models running concurrently may exchange data through memory by means of initialization blocks for
instance.
The driver mempipe offers another communication mechanism between models: a memory pipe may be
open by two models simultaneously. One of them for writing and the other one for reading. This driver
also supports initialization blocks.
The drivers rcmd, xsrv and xssh allow to start additional Mosel instances: they have to be used to build
host specifications as expected by the connect function. Finally, thanks to the rmt driver a Mosel
instance can access files available from the environment of another instance.

8.5.1 Driver shmem
shmem:label[/minsize[/incstep]]

The file name for this driver is a label: this is the identifier (the first character must be a letter) of thememory block. A label is not local to a particular model and remains valid after the end of the executionof the model having created it. All memory blocks are released when the module mmjobs is unloaded but
a given memory block may also be deleted explicitly by calling the fdelete procedure of module
mmsystem or by using the fremove C-function of the Native Interface. Note also that deleting thespecial file "shmem:⁎" has the effect of releasing all memory blocks handled by the driver.
Several models may open a given label at the same time and several read operations may be performed
concurrently. However, writing to a memory block can be done by only one model at a time: if several
models try to read and write from/to the same label, only one (it becomes the owner of the memory
block) performs its IO operations for writing and the others are suspended until the owner closes its filedescriptor to the specified label. Then, one of the waiting models is restarted and becomes the newowner: this process continues until all file descriptors to the label are closed.
The memory block is allocated dynamically and resized as necessary. By default the size of the memory
block is increased by pages of 4 kilobytes: the optional parameter incstep may be used to change thispage size (i.e. the default setting is "label/0/4k"). The special value 0 modifies the allocation policy:
instead of being increased of a fixed amount, the block size is doubled. In all cases unused memory isreleased when the file is closed.

8.5.2 Driver mempipe
mempipe:name[/minsize]

A memory pipe is characterized by its name. Only one model may open a pipe for reading but several
models may open the same pipe for writing. However, if several models try to write to the same pipe, only
one (it becomes the owner of the memory pipe) performs its IO operations and the others are suspended
until the owner closes its file descriptor to the specified pipe. Then, one of the waiting models is restarted
and becomes the new owner: this process continues until all file descriptors to the pipe are closed.
Each pipe is associated with a buffer: a model can write to a pipe without blocking until this buffer is full.
The default size of such a buffer is of 2 kilobytes but a different size may be specified by appending therequired size to the pipe name (e.g. "mempipe:mypipe/256" sets the size of the pipe to 256 bytes).
This setting will be ignored if the buffer has already been allocated and is larger than the requested size,
the buffer will be reallocated anyway if it is not large enough to store a write operation.
There is no notion of ’end of file’ in a pipe: if a model tries to read from an empty pipe (i.e. no model is

Fair Isaac Corporation Proprietary Information

311

Chapter 8: mmjobs

writing to the other end and the pipe buffer is empty) no error is raised and the model is suspended until
something is available. Similarly trying to write to a pipe for which no model is reading from the other end
might be a blocking operation if its buffer is full. In order to avoid lock ups, it is usually good practice tosynchronize the models relying on events, for instance using the pipenotify function. Also, getting thesize of a memory pipe with getfsize will return the amount of data currently available in the pipeinternal buffer and deleting a pipe with fdelete will release the data structure allocated for the pipe.
The content of a pipe may also be cleared thanks to function pipeflush.

8.5.3 Driver rcmd
rcmd:[command]

This driver starts the specified command in a new process and connects its standard input and output
streams to the calling Mosel instance. The created process is executed in the same current working
directory as the controlling model and inherits the environment variables defined using setenv. The
default command is "mosel -r". A typical use for this driver is to start an instance on the current
machine or on a remote computer through an external program. For instance:
rcmd:rsh sunbox mosel -r

When Mosel is running in restricted mode (see Section 1.3.4), the restriction NoExec disables this driver.

8.5.4 Driver xsrv
xsrv:hostname[(port)][/ctx[/pass]][|var=val...]This driver connects to the host hostname running the Mosel Remote Launcher (see Section 8.6)
through a TCP socket on port port (default value: 2513) asking for the context ctx (default: xpress)
using the password pass (default: no password). Additional environment variables can be specified:assignments of the form var=val must be separated by the symbol | and variable values may include
variable references noted ${varname} (expansion is performed on the remote host in the context of its
environment). The special environment variable MOSEL_CWD defines the current working directory for the
newly created instance.
xsrv:winbox(3211)/xpr64|MOSEL_CWD=C:\workdir|MYDATA=${MOSEL_CWD}\data

8.5.5 Driver xssh
xssh:hostname[(port,kwf)][/ctx[/pass]][|var=val...]This driver is the secure version of the xsrv driver decribed above: it establishes the connection to thexprmsrv server through an encrypted SSH tunnel (using 2515 as the default TCP port number). In addition
to the port number, the driver can also take a file name (kwf) used as the known host file for server
authentication: this file contains the list of known hosts with their corresponding public keys. When theconnection is established to the remote host, the public key stored in this file is compared with the key
provided by the server. The connection is canceled if keys do not match. Generating this known hosts filerequires running the command xprmsrv -key public on the remote server in order to retrieve its
public key (see Section 8.6.1).
For instance, the following command will include the server mysun in the knownhosts.txt file (thecommand must be run on the server):xprmsrv -key public -hn mysun >>knownhosts.txt

Fair Isaac Corporation Proprietary Information

312Chapter 8: mmjobs

Then after having moved the file to the machine(s) from where connections are initiated, the following
connection string may be used to open secure connections with server authentication:
xssh:mysun(knownhosts.txt)

The remote connection is handled by a separate process. By default the program xprmsrv is used as thehelper program but it can be replaced by another SSH client by changing the control parameter sshcmd.

8.5.6 Driver rmt
rmt:[node,bs]filename

This driver can be used with any routine expecting a physical file for accessing files on remote instances.
By default, the file is located on the instance running on the node identified by the parameter
defaultnode but a particular instance may be specified by prefixing the file name by its node number
enclosed in square brackets. The special node number -1 designates the parent node of the current
instance.
load(mi,mo,"rmt:[-1]model.bim")

By default the driver creates a buffer of 8 kilobytes for its communication operations. The size of thisbuffer might be changed by specifying the desired buffer size (in kilobytes) after the node number (forinstance "rmt:[0,4]filename" to use a 4096 bytes buffer). If only the buffer size has to be statedthe node number can be omitted (e.g. "rmt:[,4]filename"). Note that a buffer size must be between
2 and 63.
In addition to physical files, this driver also emulates the behaviour of drivers cb, sysfd, tmp, shmem,
mempipe (for writing only) and java such that it can transfer streams from one instance to another. For
instance, "rmt:sysfd:2" is the standard error stream of the process running the default node.

8.6 The Mosel Remote Launcher xprmsrv
The xprmsrv program is the server part of the "xsrv:" and "xssh:" IO drivers: it must be running oneach computer on which instances will be started using these drivers. The communication between two
Mosel instances is achieved through a single TCP stream. Mosel instances are started in the context ofexecution environments: such an environment consists in a set of environment variables as well as thename of the program to start with its initial working directory. The server can manage different execution
environments which are identified by a name and optionally protected by a password. Thanks to thisfeature a single server can offer several versions of Xpress or dedicated settings for particular distributed
applications.
This program is also used as an SSH client by mmjob and XPRD when connecting to an xprmsrv server
through a secure tunnel. Therefore it must be available when using the "xssh:" IO driver even if noserver is to be run on the host machine.

8.6.1 Running the xprmsrv command
8.6.1.1 Main command line options
The first argument of the command that is not identified as an option is used as the name for a
configuration file. The following options are accepted:-hDisplay a short help message and terminate.

-V

Display the version number and terminate.

Fair Isaac Corporation Proprietary Information

313

Chapter 8: mmjobs-tc

Display the current configuration and terminate.

-tm #The server will terminate after # seconds of inactivity.

-f

Force automatic setting of environment variable XPRESSDIR even if it is already defined.

-v [#]

Set the verbosity level of the communication protocol. The default value is 1 (report only
errors) when the server is running in background (service/daemon) and 2 (report activity)
when the server is run from a console.

-l fname

Set a logfile to record all messages.

-li addr

Set the address of the interface to use (default: 0.0.0.0 for all interfaces).

-p portSet the TCP port to listen to (default port is 2513, -1 to disable).

-bp port

Set the UDP port for broadcast (default port is 2514, -1 to disable).

-pf pfname Define a file name for recording the process number of the server. This file is removed
when the server exits.
Start the server in background (or as a daemon on Posix systems).

-d

The following options are used by the Windows version of the server:-service install Install the server as a service. All other provided options (including configurationfile) are recorded and will be used by the server. If the corresponding service has alreadybeen installed, its execution settings are updated with the provided options.
-service remove Remove the previously installed service.
-service start

Start the previously installed service.

-service reload Reload configuration.
-service stop

Stop the previously started service.

-service status Check whether the service is already running.
-u userThis option is used only when installing the service: it selects the user running the service.

-pwd pwd

This option specifies the password required for the user indicated by the -u option.

The following options are used by all other platforms:-u user

User that should be running the server.

-g groupGroup that should be running the server.

When the server is run as a service (under Windows) or as a daemon (on Posix systems) that are usually
started by a privileged user, it is recommended to use the appropriate option to run the process as an
unprivileged user for security reasons. For instance, under Windows, installing the service can be doneusing the following command in order to use the network service account:xprmsrv -service install -u "NT AUTHORITY\NetworkService" conffile

Similarly on a Posix system, the server can be run as the nobody user:
xprmsrv -d -u nobody conffile

Fair Isaac Corporation Proprietary Information314

Chapter 8: mmjobs

8.6.1.2 Secure server
xprmsrv can also accept secure connections through SSH tunnels: this is the protocol used by the xssh
IO driver. The following options are used to setup the secure server:-sp port

Set the TCP port for SSH connections (default port is 2515, -1 to disable).

-k fname

Private key file name.

-sc cilst

Set the list of accepted ciphers in order of preference (default: "aes256-ctr
aes192-ctr aes128-ctr aes256-cbc aes192-cbc aes128-cbc
blowfish-cbc 3des-cbc").

The secure server requires a private key to authenticate itself (see following section). By default it will use
the file "xprmsrv_rsa.pem" located in the same directory as the xprmsrv executable. It is important tostore this file in a secure location as it identifies the server, in particular it must not be readable by Mosel
models started by the server. If this file is missing or the provided file name cannot be accessed the
secure server will be disabled.

8.6.1.3 Private key management
A new private key can be generated with the following command:
xprmsrv -key new

Additionally, option -k filename can be specified to change the default key file location. Note that thisprocedure does not remove an existing key file.
The following command loads and check the validity of a key file:xprmsrv -key check

When executed on a valid key file this command displays the fingerprint of the public part of the key aswell as its properties.
The SSH protocol makes possible authentication of a server by a client. This optional feature, supportedby the IO driver xssh, requires a known host file on the client side: this text file consists in a list of hostserver names with their associated public key. The command xprmsrv -key public generates therequired data for such a file using the hostname reported by the operating system to identify the server.
Often this hostname does not correspond to the public name of the machine. In such a case, it ispossible to replace the label in the file or use the option -hn name to select a different name. For
instance, the following command will append to the file knownhosts.txt the public data key for theserver using keyfile mykey.pem with host name srvname:xprmsrv -key public -k mykey.pem -hn srvname >>knownhosts.txt

8.6.1.4 Mode of operation
The server proceeds as follows:
1. If the environment variable XPRESSDIR is not defined or if the -f option is in use, the value of thisenvironment variable is deduced from the location of the program itself. Under Posix operating
systems, the environment variable XPAUTH_PATH is also set up.
2. The environment variables MOSEL_DSO and MOSEL_BIM (see Section 2.3.1), MOSEL_TMP (seeSection 2.17), MOSEL_EXECPATH (see system), MOSEL_RWPATH, MOSEL_ROPATH (see Section

Fair Isaac Corporation Proprietary Information

315

Chapter 8: mmjobs

1.3.4) and XPRMSRV_ACCESS (see Section 8.6.2.1) are cleared and the environment variable
MOSEL_RESTR is initialised with value "NoReadNoWriteNoExecNoDBWDOnly" (see Section
1.3.4).
3. The default execution environment xpress is created: it refers to the Xpress installation detected
at the first step.
4. If available, the configuration file is read (see Section 8.6.2): it can be used to define global settings(e.g., defining the logfile) or/and create and modify execution environments by defining
environment variables.
5. The process then starts its main loop listening to the specified TCP and UDP ports.
6. When a connection is requested, a new session is started to process commands from the client.
These commands are used to authenticate the client, select an environment and finally start theMosel program in a separate process. This process inherits all the environment variables defined in
the context and starts in the specified working directory (by default: the location pointed by
XPRESSDIR). In addition, on Posix systems, the path ${XPRESSDIR}/lib is added to the
dynamic library path of the operating system. Once the process is started, xprmsrv detaches itself
from the client — the communication is established directly between the two Mosel instances.

8.6.2 Configuration file
The configuration file consists in a list of variable definitions of one of the following forms:
varname=value
varname?=value

Each statement is recorded in the current environment. The value may contain variable references noted${varname}, the expansion is executed when the environment is processed except for self referencesthat are expanded at the time of defining the variable (e.g.PATH=${PATH}:otherpath). When the first
syntax is used, the variable cannot be changed by a remote host; the second syntax (using ?=) allows aremote host to modify the corresponding variable before starting the Mosel instance.
Switching to a different environment is done by giving the name of the environment enclosed in square
brackets:[newenv]

If the environment name has not yet been used, a new environment is created unless the line ends withthe symbol ’+’ (e.g. [myenv]+). In this case the following definitions are included only if theenvironment already exists. If the line ends with the symbol ’=’ (e.g. [myenv]=) the previous definitions
for this context are cleared. These markers can be combined (e.g. [myenv]+=) such that the definition
block replaces the corresponding context only if it exists.
Upon startup, two environments are automatically created: "global" to store general configuration andsettings shared by all environments and "xpress" (it can also be referred to as ⁎ or default) the
default execution environment. When the reading of the configuration file begins, the global environment
is selected: in this environment all variable definitions are processed immediatly and added to thexprmsrv process environment. In this context, some variables have a special meaning and are nothandled as ordinary environment variables (all paths must be absolute):
LOGFILEthe file to be used for recording all messages. Messages are sent to the standard error
stream when this parameter is not set.

LISTENaddress of the interface to use (default value: 0.0.0.0 for all interfaces).

Fair Isaac Corporation Proprietary Information

316

Chapter 8: mmjobs

TCP_PORT

the port number to use for TCP connections (default value: 2513, -1 to disable).

UDP_PORT

the port number to use for UDP connections (default value: 2514, -1 to disable). The server
listen to this port for broadcast messages (see procedure findxsrvs).

SSH_PORT

the port number to use for SSH connections (default value: 2515, -1 to disable).

KEYFILE

private key file name used by the SSH protocol (default value: xprmsrv_rsa.pem located in
the same directory as the xprmsrv executable).

SSH_CIPHERS

the list of accepted ciphers in order of preference (default: "aes256-ctr
aes192-ctr aes128-ctr aes256-cbc aes192-cbc aes128-cbc
blowfish-cbc 3des-cbc").

VERBOSITY

verbosity level for the communication protocol (default value: 1 if the server is running inbackground and 2 if it is run from a console).

GROUPMASK

Bit mask to select what broadcast requests to accept (default value: ANY). The server
replies to a request of group grp only if bit test grp&GROUPMASK is not 0 (see procedure
findxsrvs). The mask value can be given as an integer (e.g. 3 to allow groups 1 and 2),
an hexadecimal number (e.g. 0xFF for groups 1 to 128) or the special keyword ANY (allgroups allowed).

MAXAUTHTIMEa connection is closed if the authentication procedure takes more than the specified
amount of time in seconds (default value:30).

MAXSESSIONS

maximum number of concurrent sessions (the default value 0 disables this limitation).

XPRMSRV_ACCESSCONFDIR

access control list (see Section 8.6.2.1).

a configuration directory path. The server includes each of the files stored in this directory(sorted in alphabetical order) after it has finished reading the main configuration file.

If the corresponding command line options are used (namely options -l, -p, -bp, -sp, -k, -sc and -v)
the settings of the configuration file are ignored.
In other contexts, the following variables have a special meaning:
MOSEL_CMD

the command to execute. The default value is "${XPRESSDIR}/bin/mosel -r"

MOSEL_CWD

default working directory. The default value is "${XPRESSDIR}"RUN_BEFORE command to be run before MOSEL_CMD. This command is executed in the sameenvironment as MOSEL_CMD after all variables have been defined.
RUN_AFTER

command to be run after MOSEL_CMD. This command is executed in the environment of
the server but the variable itself is expanded in the context of MOSEL_CMD before its
execution.

PASS

password required to use this environment (empty by default). If this variable is set to thespecial value "⁎", the associated environment is disabled.

MAXSESSIONS

maximum number of concurrent sessions running under this context (by default there isno limit; a maximum of 0 or less disables the environment).

XPRMSRV_ACCESSXPRMSRV_SID

context specific access control list (applied after the global access list).

session ID: if not explicitly defined this variable is automatically set by the server.

XPRMSRV_PEER IP address of the remote host: if not explicitly defined this variable is automatically set
by the server.

Fair Isaac Corporation Proprietary Information

317

Chapter 8: mmjobs

For instance, the following configuration file sets the logfile to "/tmp/logfile.txt"; adds the
password "hardone" to the default context and defines an additional context named xptest pointing
to a different installation of xpress:# simple xprmsrv config file
LOGFILE=/tmp/logfile.txt[xpress]
PASS=hardone[xptest]XPRESSDIR=/opt/xpressmp/testing
XPAUTH_PATH=/opt/xpressmp/lic
MOSEL_RESTR=NoWriteNoDBNoExecWDOnly
MOSEL_CWD?=${XPRESSDIR}/workdir

Assuming the server using this configuration is running on the machine mypc, the following statements
will create two instances on this machine, one for each of the defined execution environments:
r1:=connect(m1, "xsrv:mypc/xpress/hardone")r2:=connect(m2, "xsrv:mypc/xptest")

Since MOSEL_CWD has been initialised with the ?= symbol, the remote host can change its working
directory. For instance:
r2:=connect(m2, "xsrv:mypc/xptest|MOSEL_CWD=/tmp")

While the server is running it is possible to request a reload of its configuration: this procedure consists inreading again the configuration file(s) in order to update the definition of the contexts. During thisoperation only context specific definitions are processed (all global definitions are silently ignored). Under
Windows configuration change can only be requested on a running service using the reload command:
xprmsrv -service reload

On a Unix system configuration change is performed after reception of a signal USR1. For instance if PID
is the process ID of a running xprmsrv server:
kill -USR1 PID

The configuration update can only be executed when the server is not monitoring any Mosel instance. If arequest cannot be processed immediately it is delayed until the server is idle. Moreover if an error is
detected while reading the configuration an error is reported but the server continues running with its
current settings.

8.6.2.1 Access control list
The environment variable XPRMSRV_ACCESS may be defined in each context of the configuration file.
This variable defines which hosts are allowed to connect to the server or use a particular context. The
restriction applies to the server itself when the variable is defined in the global context and as asupplementary restriction when it is included in any other context (i.e. a host cannot be allowed in acontext if it is rejected by the global context).
The value of the variable must consist in a list of hosts and subnetworks separated by spaces. Each entryof this list can optionally be preceded by the + sign (for accepting the host; this is the default if no policy
is specified) or - sign (to reject connection). Order of the list members is important: when checking
authorisation for a given host the list is processed from left to right. The first matching entry will decide
whether access is allowed or denied. A given host will be rejected if no matching entry can be found.

Fair Isaac Corporation Proprietary Information

318

Chapter 8: mmjobs

A host is identified by its name (e.g. myhost) or its IP address (e.g. 192.168.1.1). A subnetwork is
defined by a routing prefix that can be expressed as a partial address (e.g. 192.168.1); or using the
CIDR notation - the first address of the network followed by the bit-length of the prefix, separated by aslash "/" character (e.g. 192.168.1.0/24). The subnet mask may also be used instead of the
bit-length which is a quad-dotted decimal representation like an address (e.g.
192.168.1.0/255.255.255.0). The special identifier ALL is replaced by the subnetwork definition
0.0.0.0/0 (any host) and the identifier SELF is replaced by the hostname of the server.
In the first example below, host uranus is rejected and subnetwork 192.168.1.0/24 is allowed toconnect. Note that uranus will be rejected even if it is part of the autorised subnetwork because its
reference appears first in the list. In the second example, all hosts are allowed except 2 subnetworks(192.168.1.0/24 and 192.168.2.0/24):
XPRMSRV_ACCESS=-uranus 192.168.1
XPRMSRV_ACCESS=-192.168.1.0/255.255.255.0 -192.168.2.0/24 +ALL

All defined control lists are preprocessed just after the configuration file has been read in order to resolve
host names and check for syntax errors. Unresolved host names are ignored (although a warning isdisplayed in such a case) but a syntax error on a control list will cause the server to abort its processing.

Fair Isaac Corporation Proprietary Information

319

CHAPTER 9

mmnl
The mmnl module extends the Mosel language with a new type for representing nonlinear expressions
and constraints and also with some additional subroutines. To use this module the following line must be
included in the header of the Mosel model file:uses 'mmnl'

The first section presents the new functionality for the Mosel language provided by mmnl, namely the
new type nlctr and a set of subroutines that may be applied to objects of this type.
The following sections give detailed documentation of the subroutines (other than mathematicaloperators) defined by this module.

9.1 New functionality for the Mosel language
9.1.1 The problem type mpproblem.nl
This module exposes its functionality through an extension to the mpproblem problem type. As aconsequence, all routines presented here are executed in the context of the current problem.

9.1.2 The type nlctr and its operators
The module mmnl defines the type nlctr to represent nonlinear constraints in the Mosel Language. As
shown in the following example (Section 9.1.4), mmnl also defines the standard arithmetic operations
that are required for working with objects of this type. By and large, these are the same operations as forlinear expressions (type linctr of the Mosel language) with additionally the possibility to multiply or
divide by decision variables and to use the exponential notation xˆr (assuming that x is of type mpvar).
Nonlinear constraints may also be defined by using overloaded versions of Mosel’s arithmetic andtrigonometric functions on expressions involving decision variables (see Section 9.2 for a complete list).

9.1.3 Setting initial values
An important feature in Nonlinear Programming is the possibility to set initial values for decision variables.
With mmnl this is done by the procedure setinitval. Nonlinear solvers use initial values as starting
point for the search. The choice of the initial values may not only have an impact on the time spent by thesolver but also, depending on the problem type, on the best (locally optimal) solution found by the solver.
The definitions of initial values can be removed with clearinitvals. It is also possible to employ thesolution values obtained from the immediately preceding optimization run as initial values to the next bycalling the procedure copysoltoinit.

Fair Isaac Corporation Proprietary Information320

Chapter 9: mmnl

9.1.4 Example: using mmnl for QCQP
The following example shows how to solve a QCQP (Quadratically Constrained Quadratic Programming)
problem with the Xpress-MP QCQP solver. To use this solver we need to load the module mmxprs in
addition to mmnl since the module mmnl does not include any solver.
The problem we wish to solve is a classical NLP test problem (source:
http://www.orfe.princeton.edu/ rvdb/ampl/nlmodels/ that determines the shape of a hanging chain byminimizing its potential energy. The objective function is linear and the problem has convex quadratic
constraints.
model "catenary"
uses "mmxprs", "mmnl"
parameters
N = 100
L = 1
H = 2⁎L/N
end-parameters
declarations
RN = 0..N
x: array(RN) of mpvar
y: array(RN) of mpvar
end-declarations! Number of chainlinks! Difference in x-coordinates of endlinks! Length of each link

! x-coordinates of endpoints of chainlinks! y-coordinates of endpoints of chainlinks

forall(i in RN) x(i) is_free
forall(i in RN) y(i) is_free! Objective: minimise the potential energy
potential_energy:= sum(j in 1..N) (y(j-1)+y(j))/2! Bounds: positions of endpoints! Left anchor
x(0) = 0; y(0) = 0! Right anchor
x(N) = L; y(N) = 0! Constraints: positions of chainlinks
forall(j in 1..N)
Link_up(j):= (x(j)-x(j-1))^2+(y(j)-y(j-1))^2 <= H^2! Setting start values
forall(j in RN) setinitval(x(j), j⁎L/N)
forall(j in RN) setinitval(y(j), 0)
setparam("XPRS_verbose", true)
minimise(potential_energy)
writeln("Solution: ", getobjval)
forall(j in RN)
writeln(strfmt(getsol(x(j)),10,5), " ", strfmt(getsol(y(j)),10,5))
end-model

A QCQP matrix can be exported to a text file (in MPS or LP format) by adding the following lines to yourmodel after the problem definition:
setparam("XPRS_loadnames", true)loadprob(potential_energy)
writeprob("catenary.mat", "")! Enable loading of names! Load the problem! Write an MPS matrix ("l" for LP format)

Not all problems with quadratic constraints conform with the properties required by QCQP solvers.
Xpress-Optimizer therefore performs a convexity check before starting the optimization. This test takessome time and if you know that your problem is convex you may disable it by setting the following

Fair Isaac Corporation Proprietary Information

321

Chapter 9: mmnl

parameter before starting the optimization.
setparam("XPRS_ifcheckconvexity", false)! Disable convexity check9.2 Procedures and functions
The module mmnl overloads certain mathematical functions of the Mosel language, replacing anargument of type real by the types linctr and nlctr. The return value of these functions is of typenlctr. This means they can be used as operators in the definition of nonlinear constraints as shown in
the example of Section 9.1.4. The relevant functions are:■■Arithmetic functions:absabsolute value

ceilrounding to the next largest integer

exp

natural exponent of the argument

floor

rounding to the next smallest integerlnnatural logarithm of the argumentlogbase 10 logarithm of the argumentround

rounding to the nearset integer

sqrt

positive square root of the argument

sign

sign of an expression (-1 if negative, 1 if positive, 0 othewise)

fmin

Minimum value of a list of expressions (this function accepts a variable number ofarguments or a list)

fmax

Maximum value of a list of expressions (this function accepts a variable number ofarguments or a list)

Trigonometric functions:arccosarccosine of the argument

arcsinarcsine of the argument

arctanarctangent of the argumentcos

cosine of the argumentsinsine of the argumenttantangent of the argument

Since these mathematical operators are fairly self-explanatory, we shall forego any more detailed
documentation of these functions.
The following list gives an overview of all other functions and procedures defined by mmnl for which we
give detailed descriptions later.
clearinitvals

Delete all initial value definitions.

p. 324

copysoltoinit

Copy solution values to initial values.

p. 325getsolGet the solution value of a nonlinear constraint.

p. 327gettypeGet the type of a nonlinear constraint.

p. 330ishidden

Test whether a constraint is hidden.

p. 328Fair Isaac Corporation Proprietary Information322

Chapter 9: mmnl

pwlin

Generate a piecewise linear function.

p. 331sethidden

Hide or unhide a nonlinear constraint.

p. 329setinitval

Set an initial value (start value) for a variable.

p. 326setname

Associate a matrix name to a nonlinear constraint.

p. 332

settypeSet the type of a nonlinear constraint.

p. 333

Fair Isaac Corporation Proprietary Information

323

Chapter 9: mmnl

clearinitvals
Purpose
Synopsis
ExampleDelete all initial value definitions.
procedure clearinitvals
The following copies the solution values from an optimization run to the initial values of the variables
involved. Later all initial value definitions are deleted and a new initial value is set for variable x.
uses "mmnl"
declarations
x,y: mpvar
end-declarations...
minimize(sin(x+y))
copysoltoinit...
clearinitvals
setinitval(x, -1)

Further information
This procedure deletes all previously defined initial values for decision variables.
Related topics
copysoltoinit, setinitval.
Modulemmnl

Fair Isaac Corporation Proprietary Information324

Chapter 9: mmnl

copysoltoinit
Purpose
Synopsis
ExampleCopy solution values to initial values.
procedure copysoltoinit
The following copies the solution values of all variables in an optimization run to their initial values andthen sets a different initial value for variable x(1).
uses "mmnl"
declarations
x: array(1..10) of mpvar
y,z: mpvar
end-declarations...
maximize(x(1)⁎x(3) + ln(y+z))
copysoltoinit
setinitval(x(1), 0)

Further information
This procedure copies the solution values of decision variables in the immediately preceding optimization
run to their initial values for the next run. Doing so it overrides any previously set initial values for the
involved variables. However, the settings for decision variables that did not occur in the previously solved
problem remain unchanged.
Related topics
copysoltoinit, clearinitvals, setinitval.
Modulemmnl

Fair Isaac Corporation Proprietary Information

325

Chapter 9: mmnl

setinitval
Purpose
Synopsis

Set an initial value (start value) for a variable.
procedure setinitval(x:mpvar, val:real)

Argumentsxval
ExampleA decision variable
A real number to be used as initial value

The following sets an initial value of 0 for variable x. For y its solution from the preceding optimization isset as its new initial value.
uses "mmnl"
declarations
x,y: mpvar
end-declarations
setinitval(x, 0)
setinitval(y, getsol(y))

Further information
This procedure sets an initial value for a decision variable. Initial values are used by nonlinear solvers as a(good) starting point for the search. It is in general not required that the initial values be part of a feasible
solution to the optimization problem. All previously set initial values can be removed by calling
clearinitvals. The procedure copysoltoinit can be used to turn the solution of a previous
optimization run into initial values for the next run.
Related topics
clearinitvals, copysoltoinit.
Modulemmnl

Fair Isaac Corporation Proprietary Information326

Chapter 9: mmnl

getsolPurpose
Synopsis

Get the solution value of a nonlinear constraint.
function getsol(c:nlctr):realArgumentc

A nonlinear constraint

Return value
Solution value or 0.
ExampleThe following prints the solution values of a nonlinear constraint and a nonlinear expression.
uses "mmnl"
declarations
x,y,z: mpvar
Ctr: nlctr
end-declarations...
! (Define and solve the problem)
writeln("Evalution of Ctr: ", getsol(Ctr))
writeln("Evaluation of an expression: ", getsol(abs(x⁎y)+5⁎z^3))

Further information
This function returns the evaluation of a nonlinear constraint using the current solution values of its
variables. Note that the solution value of a variable is 0 if the problem has not been solved or the variable
is not contained in the problem that has been solved.
Related topics
maximize/minimize, copysoltoinit.
Modulemmnl

Fair Isaac Corporation Proprietary Information

327

Chapter 9: mmnl

ishiddenPurpose
Synopsis

Test whether a constraint is hidden.
function ishidden(c:nlctr):boolean

Argumentc

A nonlinear constraint

Return value
true if the constraint is hidden, false otherwise.
ExampleThe following tests whether a nonlinear constraint is hidden.
uses "mmnl"
declarations
c: nlctr
end-declarations
if ishidden(c) thenwriteln("Constraint 'c' is currently hidden.")end-ifFurther information
This function tests the current status of a constraint. At its creation a constraint is added to the current
problem, but using the function sethidden it may be hidden. This means, the constraint will not be
contained in the problem that is solved by the nonlinear solver but it is not deleted from the definition of
the problem in Mosel.
Related topics
sethidden.
Modulemmnl

Fair Isaac Corporation Proprietary Information

328

Chapter 9: mmnl

sethidden
Purpose
Synopsis

Hide or unhide a nonlinear constraint.
procedure sethidden(c:nlctr, b:boolean)

Argumentscb

ExampleA nonlinear constraint
Constraint status:
true
Hide the constraint
false
Unhide the constraint

The following defines a constraint and then sets it as hidden:
uses "mmnl"
declarations
x,y,z: mpvar
end-declarations
c:= 4⁎cos(x) + y - z^2 <= 12sethidden(c, true)

Further information
At its creation a constraint is added to the current problem, but using this procedure it may be hidden.
This means that the constraint will not be contained in the problem that is solved by the nonlinear solver
but it is not deleted from the definition of the problem in Mosel. Function ishidden can be used to test
the current status of a constraint.
Related topics
ishidden.
Modulemmnl

Fair Isaac Corporation Proprietary Information329

Chapter 9: mmnl

gettype
Purpose
Synopsis

Get the type of a nonlinear constraint.
function gettype(c:nlctr):integer

Argumentc

A nonlinear constraint

Return value
Constraint type. Applicable values for nonlinear constraints are:
CT_EQ
Equality, ‘=’
CT_GEQ Greater than or equal to, ‘ ≥ ’
CT_LEQ Less than or equal to, ‘ ≤ ’
CT_UNB Non-binding constraint, i.e. free
Related topics
settype.
Modulemmnl

Fair Isaac Corporation Proprietary Information

330

Chapter 9: mmnl

pwlin
Purpose
Synopsis

Generate a piecewise linear function.
function pwlin(x:mpvar, points:list of real):nlctr
function pwlin(x:mpvar, brks:list of real, slopes:list of real):nlctr
function pwlin(fcts:list of pws):nlctr

Argumentsx
points

Input variable of the function
List of breakpoints; each point is defined by its coordinates (i.e. the size of the list must be
even)
List of x-values for the breakpoints
List of slopes to be applied between each breakpoint (there must be 1 more slope thanbreakpoints)
List of segments of the function by means of pws constructs

brks
slopesfcts

Return value
The piecewise linear expression as an nlctr entity
ExampleThe following code extract generates 3 identical piecewise linear functions using the different methods
supported by this routine:
pwl1:=pwlin(x,[0.0,0, 1,10, 2,13, 3,15, 4,16])
pwl2:=pwlin(x,[1.0,2,3],[10.0,3,2,1])
pwl3:=pwlin([pws(0,10⁎x),pws(1,10+3⁎(x-1)),pws(2,13+2⁎(x-2)),
pws(3,15+(x-3))])Further information
1. The first form of the routine expects a list of coordinates: each point is defined by the value for thevariable x and the value of the function on this point. With the second form the list brks specifies thepoints where the slope of the function changes and the list slopes gives the actual slopes. The firstslope applies for values before the first breakpoint and the last one is for values after the last breakpoint.
Note that with this syntax it is assumed that the evaluation of the function is 0 for x=0.
2. Using the last form of the routine makes it possible to describe the function by means of linear
expressions. Each element of the list fcts must be a pws construct that is composed of a real (the firstx-value of the segment) and a linear expression on the input variable (segments must depend on thesame input variable).
Modulemmnl

Fair Isaac Corporation Proprietary Information

331

Chapter 9: mmnl

setname
Purpose
Synopsis

Associate a matrix name to a nonlinear constraint.
procedure setname(c:nlctr, n:string)Argumentscn

A nonlinear constraint
Name given to the constraint

Further information
1. When exporting a problem to a matrix file, constraint names are deduced from the global public symbols:
anonymous and local constraints are usually named after their row number in the matrix. This proceduremakes it possible to give a name to these constraints.
2. If the given name starts with the ’#’ character, the generated matrix name will include the row number ofthe constraint in the matrix.

Fair Isaac Corporation Proprietary Information

332

Chapter 9: mmnl

settype
Purpose
Synopsis

Set the type of a nonlinear constraint.
procedure settype(c:nlctr, type:integer)

Argumentsctype

A nonlinear constraint
Constraint type. Applicable values are:
CT_EQ
CT_GEQ
CT_LEQ
CT_UNB

Equality, ‘=’Greater than or equal to, ‘ ≥ ’Less than or equal to, ‘ ≤ ’
Non-binding constraint

Further information
This procedure can be used to change the type of a nonlinear constraint, turning it into an equality or
inequality or making it unbounded, i.e. free.
Related topics
gettype.
Modulemmnl

Fair Isaac Corporation Proprietary Information333

CHAPTER 10

mmoci
The Mosel OCI (Oracle Call Interface) interface provides a set of procedures and functions that may be
used to access Oracle databases. To use the OCI interface, the following line must be included in theheader of a Mosel model file:uses 'mmoci'This manual describes the Mosel OCI interface and shows how to use some standard PL/SQL
commands, but it is not meant to serve as a manual for PL/SQL. The reader is referred to the
documentation of Oracle for more detailed information on these topics.

10.1 Prerequisite
The Oracle interface defined by the module mmoci accesses Oracle databases via the Oracle Call
Interface (OCI). Oracle’s Instant Client package must be installed on the machine that runs the Mosel
model.

10.2 Example
Assume that the Oracle database contains a table “pricelist” of the following form:
articlenum

color

price

1001

blue

10.49

1002

red

10.49

1003

black

5.99

1004

blue

3.99

...
The following small example shows how to logon to a database from an Mosel model file, read in data,
and logoff from the database.
model 'OCIexample'
uses 'mmoci'declarations
prices: array (range) of real
end-declarations
setparam("OCIverbose", true)
OCIlogon("scott","tiger","")

Fair Isaac Corporation Proprietary Information! Enable OCI message printing in case of error! connect to Oracle as the user 'scott/tiger'

334

Chapter 10: mmociwriteln("Connection number: ", getparam("OCIconnection"))OCIexecute("select articlenum,price from pricelist", prices)! Get the entries of field `price' (indexed by! field `articlenum') in table `pricelist'
OCIlogoff
end-model! Disconnect from the database

Here the OCIverbose control parameter is set to true to enable OCI message printing in case of error.
Following the connection, the procedure OCIexecute is called to retrieve entries from the field price(indexed by field articlenum) in the table pricelist. Finally, the connection is closed.
For further examples of working with databases and spreadsheets, the reader is referred to the Xpress
whitepaper Using ODBC and other database interfaces with Mosel.

10.3 Data transfer between Mosel and Oracle
Data transfer beetween Mosel and Oracle is achieved by calls to the procedure OCIexecute. The valueof the control parameter OCIndxcol and the type and structure of the second argument of theprocedure decide how the data are transferred between the two systems.

10.3.1 From Oracle to Mosel
Information is moved from Oracle to Mosel when performing a SELECT command for instance.
Assuming mt has been declared as follows:
mt: array(1..10,1..3) of integer

the execution of the call:
OCIexecute("SELECT c1,c2,c3 from T", mt)behaves differently depending on the value of OCIndxcol. If this control parameter is true, thecolumns c1 and c2 are used as indices and c3 is the value to be assigned. For each row (i,j,k) of theresult set, the following assignment is performed by mmoci:mt(i,j):=k

With a table T containing:c1 c2 c3 c4
1 2 5 74 3 6 8

We obtain the initialization:m2(1,2)=5, m(4,3)=6

If the control parameter OCIndxcol is false, all columns are treated as data. In this case, for each row(i,j,k) the following assignments are performed:
mt(r,1):=i; mt(r,2):=j; mt(r,3):=k

where r is the row number in the result set.
Here, the resulting initialization is:mt(1,1)=1, mt(1,2)=2, mt(1,3)=5

Fair Isaac Corporation Proprietary Information

335

Chapter 10: mmoci
mt(2,1)=4, mt(2,2)=3, mt(2,3)=6

If the SQL statement selects 4 columns (instead of 3) as in:
OCIexecute("SELECT c1,c2,c3,c4 from T", mt)

and the control parameter OCIndxcol is false, the first column is used as the first array index while
the remaining columns are treated as data. As a consequence, for each row (i,j,k,l) the following
assignments are performed:
mt(i,1):=j; mt(i,2):=k; mt(i,3):=l

The resulting initialization is therefore:mt(1,1)=2, mt(1,2)=5, mt(1,3)=7
mt(4,1)=3, mt(4,2)=6, mt(4,3)=8The second argument of OCIexecute may also be a list of arrays. When using this version, the value of
OCIndxcol is ignored and the first column(s) of the result set are always considered as indices and thefollowing ones as values for the corresponding arrays. For instance, assuming we have the following
declarations:m1, m2: array(1..10) of integer

With the statement:
OCIexecute("SELECT c1,c2,c3 from T", [m1,m2])

for each row (i,j,k) of the result set, the following assignments are performed:
m1(i):=j; m2(i):=k

So, if we use the table T of our previous example, we get the initialization:m1(1)=2, m1(4)=5m2(1)=3, m2(4)=6

10.3.2 From Mosel to Oracle
Information is transferred from Mosel to Oracle when performing an INSERT command for instance. In
this case, the way to use the Mosel arrays has to be specified by using parameters in the SQL command.
These parameters are identified by their name in the expression. For instance in the following expression
3 parameters (:1, :2 and :3) are used:
INSERT INTO T (c1,c2,c3) VALUES (:1,:2,:3)

mmoci expects that parameters are always named :n where n is the parameter number starting at 1 but
does not impose any order (i.e. :3,:1,:2 is also valid) and a given parameter may be used several
times in an expression. The command is then executed repeatedly as many times as the provided data
allows to build new tuples of parameters. The initialization of parameters is similar to what is done for a
SELECT statement.
Assuming mt has been declared as follows:
mt: array(1..2,1..3) of integer

and initialized with this assignment:
mt::[1,2,3,

Fair Isaac Corporation Proprietary Information

336

Chapter 10: mmoci
4,5,6]

the execution of the call:
OCIexecute("INSERT INTO T (c1,c2,c3) VALUES (:1,:2,:3)",mt)behaves differently depending on the value of OCIndxcol. If this control parameter is true, for each
execution of the command, the following assignments are performed by mmoci:':1':= i, ':2':= j, ':3':= mt(i,j)

The execution is repeated for all possible values of i and j (in our example 6 times). The resulting table T
is therefore:c1 c2 c3
1 1 1
1 2 2
1 3 3
2 1 4
2 2 5
2 3 6

Note that mmoci uses the names of the parameters to perform an initialization and not their relative
position. This property is particularly useful for UPDATE statements where the order of parameters needs
to be changed. For instance, if we want to update the table T instead of inserting new rows, we can write:
OCIexecute("UPDATE T c3=:3 WHERE c1=:1, c2=:2",mt)This command is executed exactly in the same way as the INSERT example above (i.e. we do not have’:3’:=i, ’:1’:=j, ’:2’:=mt(i,j) as the order of appearance in the command suggests but’:1’:=i, ’:2’:=j, ’:3’:=mt(i,j)).
The same functionality may also be used to reorder or repeat columns. With the same definition of thearray mt as before and a 4-column table S in the database the execution of the command
OCIexecute("INSERT INTO S (c1,c2,c3,c4) VALUES (:1,:2,:3,:2)",mt)results in the following contents of table S:c1 c2 c3 c4
1 1 1 11 2 2 2
1 3 3 32 1 4 12 2 5 22 3 6 3

If the control parameter OCIndxcol is false, only the values of the Mosel array are used to initialize theparameters. So, for each execution of the command of our initial example (with 3 parameters), we have:':1':=mt(i,1), ':2':=mt(i,2), ':3':=mt(i,3)

The execution is repeated for all possible values of i (in our example 2 times). The resulting table T istherefore:c1 c2 c3
1 2 3
4 5 6

However if the SQL query defines 4 parameters (instead of 3) as in:Fair Isaac Corporation Proprietary Information

337

Chapter 10: mmoci
OCIexecute("INSERT INTO T (c1,c2,c3,c4) VALUES (:1,:2,:3,:4)",mt)and the control parameter OCIndxcol is false, the first parameter is used as the first array index while
the remaining parameters are populated with data. As a consequence, for each execution of thecommand, the following assignments are performed by mmoci:':1':= i, ':2':= mt(i,1), ':3':= mt(i,2), ':4':=mf(i,3)

The execution is repeated for all possible values of i (in our example 2 times). The resulting table T istherefore:c1 c2 c3 c4
1 1 2 32 4 5 6

When OCIexecute is used with a list of arrays, the behavior is again similar to what has been describedearlier for the SELECT command: the first parameter(s) are assigned index values and the final ones theactual array values. For instance, assuming we have the following declarations:m1,m2: array(1..3) of integer

And the arrays have been initialized as follows:
m1::[1,2,3]
m2::[4,5,6]

Then the following call:
OCIexecute("INSERT INTO T (c1,c2,c3) VALUES (:1,:2,:3)",[m1,m2])

executes 3 times the INSERT command. For each execution, the following parameter assignments are
performed:':1':=i, ':2':=m1(i), ':3':=m2(i)The resulting table T is therefore:c1 c2 c3
1 1 4
2 2 5
3 3 6

10.4 Control parameters
The following parameters are defined by mmoci:
OCIautocommit

Enable/disable "commit on success" in OCI.

p. 339OCIautondx

Enable automatic indexation of arrays.

p. 339

OCIbufsize

Data buffer size.

p. 340

OCIcolsize

Maximum string length.

p. 340

OCIconnection

Identification number of the active OCI connection.

p. 340

OCIdebug

Enable/disable debug mode.

p. 340

OCIfirstndx

Initial index value for an automatic indexation.

p. 341

Fair Isaac Corporation Proprietary Information

338

Chapter 10: mmoci

OCIndxcol

Indicate whether to use first columns as indices.

p. 341OCIrowcnt

Number of lines affected by the last SQL command.

p. 341OCIrowxfr

Number of lines transferred during the last SQL command.

p. 341

OCIsuccessIndicate whether the last SQL command succeeded.

p. 342

OCItruncsize

Length of the largest string that has been truncated.

p. 342OCIverbose

Enable/disable message printing by OCI.

p. 342

All parameters can be accessed with the Mosel function getparam, and those that are not marked
read-only in the list below may be set using the procedure setparam.
Example:setparam("OCIverbose", true)
csize:=getparam("OCIcolsize")setparam("OCIconnection", 3)! Enable message printing by OCI! Get the maximum string length! Select the connection number 3

OCIautocommit
Description

Enable/disable "commit on success" in OCI.

Type

Boolean, read/write

Valuestrue Changes to the database are committed automatically.
false transactions have to be explicitly committed (or rolled back) using OCIcommit (orOCIrollback).

Default value

true

Modulemmoci

OCIautondx
Description

Enable automatic indexation of arrays.

Type

Boolean, read/write

Valuestrue Enable automatic indexation.
false Disable automatic indexation.

Default value

false

Note

Automatic indexation affects handling of arrays in SQL queries. It can be used only on
1-dimension arrays indiced by ranges: when this mode is enabled indices are not imported orexported, only array values are exchanged with the database. For reading, the initial index value
is taken from the parameter OCIfirstndx and incremented at each iteration. When writing allcells of the arrays are exported.

Affects routines

OCIexecute.

See also

OCIfirstndx.

Modulemmoci

Fair Isaac Corporation Proprietary Information

339

Chapter 10: mmoci

OCIbufsize
Description

Size in kilobytes of the buffer used for exchanging data between Mosel and Oracle.

Type

Integer, read/write

ValuesAt least 1

Default value

4

Affects routines

OCIexecute, OCIreadstring.

Modulemmoci

OCIcolsize
Description

Maximum length of strings accepted to exchange data, anything exceeding this size is cut off.

Type

Integer, read/write

ValuesAt least 8

Default value

64

Note

When exporting external type entities as text strings to the database and the column size is too
small the resulting cells might be empty.

Affects routines

OCIexecute, OCIreadstring.

See also

OCItruncsize.

Modulemmoci

OCIconnection
Description

Identification number of the active OCI connection. By changing the value of this parameter, it
is possible to work with several connections simultaneously.

Type

Integer, read/write

Affects routines

OCIlogoff, OCIexecute, OCIreadinteger.OCIreadreal, OCIreadstring.

Set by routines

OCIlogon.

Modulemmoci

OCIdebug
Description

When this parameter is set to true, OCIverbose is also enabled and any SQL request sent to
Oracle is displayed to the error stream before execution. This option is ignored if the model is
not compiled with debug information.

Type

Boolean, read/write

Valuestrue Enable debug mode.
false Disable debug mode.

Default value

false

See also

OCIverbose.

Modulemmoci

Fair Isaac Corporation Proprietary Information

340

Chapter 10: mmoci

OCIfirstndx
Description

Initial index value for an automatic indexation.

Type

Integer, read/write

Default value

1

Affects routines

OCIexecute.

See also

OCIautondx.

Modulemmoci

OCIndxcol
Description

Indicates whether the first columns of each row must be interpreted as indices in all cases.
Setting it to the value false might be useful, for example, if one is trying to access a
non-relational table, perhaps a dense table. Note this mode can be enabled only is at least thelast dimension of each array is of fixed size.

Type

Boolean, read/write

Valuestrue Interpret the first columns of each row as indices.
false Do not interpret the first columns of each row as indices.

Default valuetrue

Affects routines

OCIexecute, OCIreadinteger.OCIreadreal, OCIreadstring.

Modulemmoci

OCIrowcnt
Description

Number of lines affected by the last SQL command.

Type

Integer, read only

Set by routines

OCIexecute, OCIreadinteger.OCIreadreal, OCIreadstring.

See also

OCIrowxfr.

Modulemmoci

OCIrowxfr
Description

Number of lines transferred during the last SQL command.

Type

Integer, read only

Set by routines

OCIexecute, OCIreadinteger.OCIreadreal, OCIreadstring.

See also

OCIrowcnt.

Modulemmoci

Fair Isaac Corporation Proprietary Information

341

Chapter 10: mmoci

OCIsuccess
Description

Indicate whether the last SQL command has been executed successfully.

Type

Boolean, read only

Valuestrue Succes.
false Error.

Set by routines

All OCI functions.

Modulemmoci

OCItruncsize
Description

Length of the largest string that has been truncated.

Type

Integer, read only

Note

When exporting text to the database all strings must fit into the predefined column size
(OCIcolsize). If strings are truncated due to this limit the operation status is set to false(see OCIsuccess) and this parameter receives the size that should be used to avoid any
truncation.

Set by routines

OCIexecute.

See also

OCIsuccess, OCIcolsize.

Modulemmoci

OCIverbose
Description

Enable/disable message printing by OCI.

Type

Boolean, read/write

Valuestrue Enable message printing.
false Disable message printing.

Default value

true

Modulemmoci

10.5 Procedures and functions
This section lists in alphabetical order the functions and procedures that are provided by the mmocimodule.
OCIcommit

Commit the current transaction.

p. 350

OCIexecute

Execute an SQL command.

p. 346

OCIlogoff

Terminate the active database connection.

p. 345

OCIlogon

Connect to a database.

p. 344

OCIreadinteger

Read an integer value from a database.

p. 347

Fair Isaac Corporation Proprietary Information

342

Chapter 10: mmoci

OCIreadreal

Read a real value from a database.

p. 348

OCIreadstring

Read a string from a database.

p. 349

OCIrollback

Roll back the current transaction.

p. 351

Fair Isaac Corporation Proprietary Information

343

Chapter 10: mmoci

OCIlogon
Purpose
Synopsis

Connect to a database.
procedure OCIlogon(s:string|text)
procedure OCIlogon(u:string|text, p:string|text, db:string|text)

Argumentssnpdb
ExampleLogon string as "user/password@db"
User name
Password
Database name (may be "" for the default database)

The following connects to the database ‘test’ as the user ‘yves’ with the password ‘DaSH’:
OCIlogon("yves/DaSH@test")
Open a connection to the default database the user ’scott’ with the password ’tiger’
OCIlogon("scott","tiger","")

Further information
1. This procedure establishes a connection to the database db as user n/p. It is possible to open several
connections but the connection established last becomes active. Each connection is assigned an
identification number which can be obtained by getting the value of the parameter OCIconnection after
this procedure has been executed. This parameter can also be used to change the active connection.
2. When Mosel is running in restricted mode (see Section 1.3.4), the restriction NoDB disables this routine.
Related topics
OCIlogoff.
Modulemmoci

Fair Isaac Corporation Proprietary Information344

Chapter 10: mmoci

OCIlogoff
Purpose
Synopsis

Terminate the active database connection.
procedure OCIlogoff

Further information
The active connection can be accessed or changed by setting the control parameter OCIconnection.
Related topics
OCIlogon.
Modulemmoci

Fair Isaac Corporation Proprietary Information

345

Chapter 10: mmoci

OCIexecute
Purpose
Synopsis

Execute an SQL command.
procedure OCIexecute(s:string|text)
procedure OCIexecute(s:string|text, a:array)procedure OCIexecute(s:string|text, l:list)
procedure OCIexecute(s:string|text, m:set)

Argumentssalm
ExampleSQL command to be executed
An array
A list. May be a list of arrays
A set

The following example contains four OCIexecute statements performing the following tasks:■ Get all different values of the column color in the table pricelist.
■ Initialize the arrays colors and prices with the values of the columns color and price of thetable pricelist.

■ Create a new table newtab in the active database with 2 columns, ndx and price.
■ Add data entries to table newtab.

declarations
prices: array(1001..1004) of realcolors: array(1001..1004) of string
allcolors: set of string
end-declarations
OCIexecute("select color from pricelist", allcolors)
OCIexecute("select articlenum,color,price from pricelist",[colors,prices])
OCIexecute("create table newtab (ndx integer, price double)")OCIexecute("insert into newtab (ndx, price) values (:1,:2)", prices)
Further information
1. This procedure executes the given SQL command. The user is referred to the Oracle documentation forfurther information on PL/SQL.
2. For output commands (like insert into) this procedure accepts arrays, sets and lists of basic types(integer, real, string or Boolean) as well as module types for which from/to string conversions areavailable. Record types composed of scalars or other records can also be used (the fields that cannot be
handled are silently ignored). It is also possible to use a list of arrays of basic types (all arrays must be
indexed by the same sets) or a list of scalar elements of different basic or module types.
3. For input commands (like select from) the same restrictions apply for arrays,lists and list of arrays
but sets must be of a basic type.
Related topics
OCIreadinteger, OCIreadreal, OCIreadstring.
Modulemmoci

Fair Isaac Corporation Proprietary Information

346

Chapter 10: mmoci

OCIreadinteger
Purpose
Synopsis

Read an integer value from a database.
function OCIreadinteger(s:string|text):integer

Arguments

SQL command for selecting the value to be read

Return value
Integer value read or 0.
ExampleThe following gets the article number of the first data item in table pricelist for which the field color
is set to blue:
i:=OCIreadinteger("select articlenum from pricelist where color=blue")

Further information
1. 0 is returned if no integer value can be found.
2. If the given SQL selection command does not denote a single value, the first value to which the selection
criterion applies is returned.
Related topics
OCIexecute, OCIreadreal, OCIreadstring.
Modulemmoci

Fair Isaac Corporation Proprietary Information

347

Chapter 10: mmoci

OCIreadreal
Purpose
Synopsis

Read a real value from a database.
function OCIreadreal(s:string|text):realArguments

SQL command for selecting the value to be read

Return value
Real value read or 0.
ExampleThe following returns the price of the data item with index 2 in table newtab:
r:=OCIreadreal("select price from newtab where ndx=2")

Further information
1. 0 is returned if no real value can be found.
2. If the given SQL selection command does not denote a single value, the first value to which the selection
criterion applies is returned.
Related topics
OCIexecute, OCIreadinteger, OCIreadstring.
Modulemmoci

Fair Isaac Corporation Proprietary Information

348

Chapter 10: mmoci

OCIreadstring
Purpose
Synopsis

Read a string from a database.
function OCIreadstring(s:string|text):stringArguments

SQL command for selecting the string to be read

Return value
String read or empty string.
ExampleThe following retrieves the color of the (first) data item in table pricelist with article number 1004:
s:=OCIreadstring("select color from pricelist where articlenum=1004")

Further information
1. The empty string is returned if no real value can be found.
2. If the given SQL selection command does not denote a single entry, the first string to which the selection
criterion applies is returned.
Related topics
OCIexecute, OCIreadinteger, OCIreadreal.
Modulemmoci

Fair Isaac Corporation Proprietary Information349

Chapter 10: mmoci

OCIcommit
Purpose
Synopsis

Commit the current transaction.
procedure OCIcommit

Further information
This procedure is required only if the control parameter OCIautocommit is set to false.
Related topics
OCIrollback.
Modulemmoci

Fair Isaac Corporation Proprietary Information

350

Chapter 10: mmoci

OCIrollback
Purpose
Synopsis

Roll back the current transaction.
procedure OCIrollback

Further information
This procedure can be used only if the control parameter OCIautocommit is set to false.
Related topics
OCIcommit.
Modulemmoci

Fair Isaac Corporation Proprietary Information

351

Chapter 10: mmoci

10.6 I/O drivers
This module provides a driver designed to be used in initializations blocks for both reading andwriting data. The oci IO driver simplifies access to Oracle databases.

10.6.1 Driver oci
oci:[debug;][noindex;][colsize=#;][bufsize=#;]logstring

The driver can only be used in ‘initializations’ blocks. The database to use has to be given in the opening
part of the block as user/password@dbname. Before this identifier, the following options may bestated:debug

to execute the block in debug mode (to display what SQL queries are produced). This
option is ignored if the model is not compiled with debug information.

noindexto indicate that only data (no indices) are transferred between the data source and Mosel.
By default, the first columns of each table are interpreted as index values for the array to
be transferred. This behaviour is changed by this option.

colsize=c

to set the size of a text column (default 64 characters).

bufsize=c

to set the size of the data buffer in kilobytes (default 4).

In the block, each label entry is understood as a table name optionally followed by a list of column names
in brackets (e.g. "my_table(col1,col2)"). All columns are used if no list of names is specified. Note
that, before the table name, one can add option noindex to indicate that for this particular entry indices
are not used.
Example:initializations from "mmoci.oci:scott/tiger@orcl"
NWeeks as "PARAMS(Weeks)"! Initialize `NWeeks' with column `Weeks'! of table `PARAMS'BPROF as "noindex;BPROFILE"! Initialize `BPROF' with table `BPROFILE'! all columns being data (no indices)
end-initializations

Fair Isaac Corporation Proprietary Information

352

CHAPTER 11

mmodbcThe Mosel ODBC interface provides a set of procedures and functions that may be used to accessdatabases for which an ODBC driver is available. This module also includes the SQLite database engine
that can be directly run without the need for any additional software.
To use the ODBC interface, the following line must be included in the header of a Mosel model file:uses 'mmodbc'

This manual describes the Mosel ODBC interface and shows how to use some standard SQL commands,
but it is not meant to serve as a manual for SQL. The reader is referred to the documentation of thesoftware he is using for more detailed information on these topics.

11.1 Prerequisite
The ODBC technology relies on a driver manager that is used as an interface between applications (likemmodbc) and a data source itself accessed through a dedicated driver. As a consequence, this module
requires that both, a driver manager and the necessary drivers (one for each data source to be used), areinstalled and set up on the operating system.
Under Windows, usually the driver manager is part of the system and most data sources are provided
with their ODBC driver (for instance Excel, Access or SQLServer).
On the other supported operating systems it may be necessary to install a driver manager (as well as thenecessary drivers). The module mmodbc supports two driver managers: iODBC (http://www.iodbc.org)
and unixODBC (http://www.unixodbc.org). Upon startup the module tries to load the dynamic library"libiodbc.so" then, if this fails, tries "libodbc.so". If none of these libraries can be found only the
SQLite integrated driver will be available, please make sure that one of the driver managers is installed
and that the corresponding libraries can be accessed (in general this requires updating someenvironment variable).

11.2 Example
Assume that the data source “mydata” defines a database that contains a table “pricelist” of the following
form:
articlenum

color

price

1001

blue

10.49

1002

red

10.49

1003

black

5.99

1004

blue

3.99

...

Fair Isaac Corporation Proprietary Information

353

Chapter 11: mmodbc

The following small example shows how to connect to a database from an Mosel model file, read in data,
and disconnect from the data source.
model 'ODBCexample'
uses 'mmodbc'
declarations
prices: array (range) of real
end-declarations
setparam("SQLverbose", true)
SQLconnect("DSN=mydata")! Enable ODBC message printing in case of error! Connect to the database defined by `mydata'

writeln("Connection number: ", getparam("SQLconnection"))SQLexecute("select articlenum,price from pricelist", prices)! Get the entries of field `price' (indexed by! field `articlenum') in table `pricelist'
SQLdisconnect
end-model! Disconnect from the database

Here the SQLverbose control parameter is set to true to enable ODBC message printing in case oferror. Following the connection, the procedure SQLexecute is called to retrieve entries from the fieldprice (indexed by field articlenum) in the table pricelist. Finally, the connection is closed.
For further examples of working with databases and spreadsheets, the reader is referred to the Xpress
whitepaper Using ODBC and other database interfaces with Mosel.

11.3 Data transfer between Mosel and the database
Data transfer beetween Mosel and the database is achieved by calls to the procedure SQLexecute. The
value of the control parameter SQLndxcol and the type and structure of the second argument of theprocedure decide how the data are transferred between the two systems.

11.3.1 From the database to Mosel
Information is moved from the database to Mosel when performing a SELECT command for instance.
Assuming mt has been declared as follows:
mt: array(1..10,1..3) of integer

the execution of the call:
SQLexecute("SELECT c1,c2,c3 from T", mt)behaves differently depending on the value of SQLndxcol. If this control parameter is true, thecolumns c1 and c2 are used as indices and c3 is the value to be assigned. For each row (i,j,k) of theresult set, the following assignment is performed by mmodbc:
mt(i,j):=k

With a table T containing:c1 c2 c3 c4
1 2 5 74 3 6 8

We obtain the initialization:

Fair Isaac Corporation Proprietary Information354

Chapter 11: mmodbc
m2(1,2)=5, m(4,3)=6

If the control parameter SQLndxcol is false, all columns are treated as data. In this case, for each row(i,j,k) the following assignments are performed:
mt(r,1):=i; mt(r,2):=j; mt(r,3):=k

where r is the row number in the result set.
Here, the resulting initialization is:mt(1,1)=1, mt(1,2)=2, mt(1,3)=5mt(2,1)=4, mt(2,2)=3, mt(2,3)=6

If the SQL statement selects 4 columns (instead of 3) as in:
SQLexecute("SELECT c1,c2,c3,c4 from T", mt)

and the control parameter SQLndxcol is false, the first column is used as the first array index while
the remaining columns are treated as data. As a consequence, for each row (i,j,k,l) the following
assignments are performed:
mt(i,1):=j; mt(i,2):=k; mt(i,3):=l

The resulting initialization is therefore:mt(1,1)=2, mt(1,2)=5, mt(1,3)=7
mt(4,1)=3, mt(4,2)=6, mt(4,3)=8The second argument of SQLexecute may also be a list of arrays. When using this version, the value of
SQLndxcol is ignored and the first column(s) of the result set are always considered as indices and thefollowing ones as values for the corresponding arrays. For instance, assuming we have the following
declarations:m1, m2: array(1..10) of integer

With the statement:
SQLexecute("SELECT c1,c2,c3 from T", [m1,m2])

for each row (i,j,k) of the result set, the following assignments are performed:
m1(i):=j; m2(i):=k

So, if we use the table T of our previous example, we get the initialization:m1(1)=2, m1(4)=5m2(1)=3, m2(4)=6

11.3.2 From Mosel to the database
Information is transferred from Mosel to the database when performing an INSERT command for
instance. In this case, the way to use the Mosel arrays has to be specified by using parameters in the SQL
command. These parameters are identified by the symbol ‘?’ in the expression. For instance in thefollowing expression 3 parameters are used:
INSERT INTO T (c1,c2,c3) VALUES (?,?,?)

The command is then executed repeatedly as many times as the provided data allows to build new tuplesof parameters. The initialization of parameters is similar to what is done for a SELECT statement.

Fair Isaac Corporation Proprietary Information

355

Chapter 11: mmodbc

Assuming mt has been declared as follows:
mt: array(1..2,1..3) of integer

and initialized with this assignment:
mt::[1,2,3,
4,5,6]

the execution of the call:
SQLexecute("INSERT INTO T (c1,c2,c3) VALUES (?,?,?)",mt)behaves differently depending on the value of SQLndxcol. If this control parameter is true, for each
execution of the command, the following assignments are performed by mmodbc (?1,?2,?3 denoterespectively the first second and third parameter):'?1':= i, '?2':= j, '?3':= mt(i,j)

The execution is repeated for all possible values of i and j (in our example 6 times). The resulting table T
is therefore:c1 c2 c3
1 1 1
1 2 2
1 3 3
2 1 4
2 2 5
2 3 6

If the control parameter SQLndxcol is false, only the values of the Mosel array are used to initialize theparameters. So, for each execution of the command, we have:'?1':=mt(i,1), '?2':=mt(i,2), '?3':=mt(i,3)

The execution is repeated for all possible values of i (in our example 2 times). The resulting table T istherefore:c1 c2 c3
1 2 3
4 5 6

However if the SQL query defines 4 parameters (instead of 3) as in:
SQLexecute("INSERT INTO T (c1,c2,c3,c4) VALUES (?,?,?,?)",mt)and the control parameter SQLndxcol is false, the first parameter is used as the first array index while
the remaining parameters are populated with data. As a consequence, for each execution of thecommand, the following assignments are performed by mmodbc:'?1':= i, '?2':= mt(i,1), '?3':= mt(i,2), '?4':=mf(i,3)

The execution is repeated for all possible values of i (in our example 2 times). The resulting table T istherefore:c1 c2 c3 c4
1 1 2 32 4 5 6

When SQLexecute is used with a list of arrays, the behavior is again similar to what has been described

Fair Isaac Corporation Proprietary Information

356

Chapter 11: mmodbc

earlier for the SELECT command: the first parameter(s) are assigned index values and the final ones theactual array values. For instance, assuming we have the following declarations:m1,m2: array(1..3) of integer

And the arrays have been initialized as follows:
m1::[1,2,3]
m2::[4,5,6]

Then the following call:
SQLexecute("INSERT INTO T (c1,c2,c3) VALUES (?,?,?)",[m1,m2])

executes 3 times the INSERT command. For each execution, the following parameter assignments are
performed:'?1':=i, '?2':=m1(i), '?3':=m2(i)The resulting table T is therefore:c1 c2 c3
1 1 4
2 2 5
3 3 6

11.4 ODBC and MS Excel
Microsoft Excel is a spreadsheet application. Since ODBC was primarily designed for databases special
rules have to be followed to read and write Excel data using ODBC:■ A table of data is referred to as either a named range (e.g. MyRange), a worksheet name (e.g.

[Sheet1$]) or an explicit range (e.g. [Sheet1$B2:C12]).

■

By default, the first row of a range is used for naming the columns (to be used in SQL statements).
The option FIRSTROWHASNAMES=0 disables this feature and columns are implicitly named F1, F2...
However, even with this option, the first row is ignored and cannot contain data.

■ The data type of columns is deduced by the Excel driver by scanning the first 8 rows. The number ofrows analyzed can be changed using the option MAXSCANROWS=n (n between 1 and 8).

It is important to be aware that when writing to database tables specified by a named range in Excel, they
will increase in size if new data is added using an INSERT statement. To overwrite existing data in theworksheet, the SQL statement UPDATE can be used in most cases (although this command is not fully
supported). Now suppose that we wish to write further data over the top of data that has already been
written to a range using an INSERT statement. Within Excel it is not sufficient to delete the previous databy selecting it and hitting the Delete key. If this is done, further data will be added after a blank rectangle
where the deleted data used to reside. Instead, it is important to use Edit/Delete/Shift cells up within
Excel, which will eliminate all traces of the previous data, and the enlarged range.
Microsoft Excel tables can be created and opened by only one user at a time. However, the "Read Only"
option available in the Excel driver options allows multiple users to read from the same .xls files.
When first experimenting with acquiring or writing data via ODBC it is tempting to use short names forcolumn headings. This can lead to horrible-to-diagnose errors if you inadvertently use an SQL keyword.
We strongly recommend that you use names like “myParameters”, or “myParams”, or “myTime”, which
will not clash with SQL reserved keywords.

Fair Isaac Corporation Proprietary Information

357

Chapter 11: mmodbc

11.5 Control parameters
The following parameters are defined by mmodbc:
SQLautocommit

Enable/disable auto commit mode.

p. 358SQLautondx

Enable automatic indexation of arrays.

p. 359

SQLbufsize

Data buffer size.

p. 359

SQLcolsize

Maximum string length.

p. 359

SQLconnection

Identification number of the active ODBC connection.

p. 360SQLdebug

Enable/disable debug mode.

p. 360

SQLdm

Driver manager currently used.

p. 360

SQLextn

Enable/Disable extended syntax.

p. 360

SQLfirstndx

Initial index value for an automatic indexation.

p. 361

SQLndxcol

Indicate whether to use first columns as indices.

p. 361

SQLrowcnt

Number of lines affected by the last SQL command.

p. 361

SQLrowxfr

Number of lines transferred during the last SQL command.

p. 361

SQLsuccessIndicate whether the last SQL command succeeded.

p. 362

SQLtruncsize

Length of the largest string that has been truncated.

p. 362

SQLverbose

Enable/disable message printing by the ODBC driver.

p. 362

All parameters can be accessed with the Mosel function getparam, and those that are not marked
read-only in the list below may be set using the procedure setparam.
Example:setparam("SQLverbose", true)
csize:=getparam("SQLcolsize")setparam("SQLconnection", 3)! Enable message printing by the ODBC driver! Get the maximum string length! Select the connection number 3

SQLautocommit
Description

When this parameter is set to true (the default), any change to the database is sent
immediately. Otherwise, if transactions are supported by the database, changes are retained
until a call to SQLcommit (commit changes) or SQLrollback (discard changes) is issued.
The value of this parameter is used at the time the database is open with SQLconnect: once
connection is established, changing this parameter has no impact on the existing connections(i.e. they remain in their initial transaction mode)Type

Boolean, read/write

Valuestrue Enable auto commit mode.
false Disable auto commit mode (i.e. transactions).

Default valuetrue

Affects routines

SQLconnect.

ModulemmodbcFair Isaac Corporation Proprietary Information

358

Chapter 11: mmodbc

SQLautondx
Description

Enable automatic indexation of arrays.

Type

Boolean, read/write

Valuestrue Enable automatic indexation.
false Disable automatic indexation.

Default value

false

Note

Automatic indexation affects handling of arrays in SQL queries. It can be used only on
1-dimension arrays indiced by ranges: when this mode is enabled indices are not imported orexported, only array values are exchanged with the database. For reading, the initial index value
is taken from the parameter SQLfirstndx and incremented at each iteration. When writing allcells of the arrays are exported.

Affects routines

SQLexecute.

See also

SQLfirstndx.

ModulemmodbcSQLbufsize
Description

Size in kilobytes of the buffer used for exchanging data between Mosel and the ODBC driver.

Type

Integer, read/write

ValuesAt least 1

Default value

4 on Posix systems and 8 on Windows

Affects routines

SQLexecute, SQLreadstring.

Modulemmodbc

SQLcolsize
Description

Maximum length of strings accepted to exchange data, anything exceeding this size is cut off.

Type

Integer, read/write

ValuesAt least 8

Default value

64

Affects routines

SQLexecute, SQLreadstring.

Note

The column size is expressed in bytes when using an ANSI interface (with a multibyte encoding
a single character may occupy more than one byte) and in characters when using a Unicodeinterface. When exporting text strings to the database and the column size is significantly too
small the resulting cells might be empty.

See also

SQLtruncsize.

ModulemmodbcFair Isaac Corporation Proprietary Information359

Chapter 11: mmodbc

SQLconnection
Description

Identification number of the active ODBC connection. By changing the value of this parameter,
it is possible to work with several connections simultaneously.

Type

Integer, read/write

Affects routines

SQLdisconnect, SQLexecute, SQLreadinteger.SQLreadreal, SQLreadstring.

Set by routines

SQLconnect.

ModulemmodbcSQLdebug
Description

When this parameter is set to true, SQLverbose is also enabled and any SQL request sent to
ODBC is displayed to the error stream before execution. This option is ignored if the model is
not compiled with debug information.

Type

Boolean, read/write

Valuestrue Enable debug mode.
false Disable debug mode.

Default value

false

See also

SQLverbose.

Modulemmodbc

SQLdm
Description

Driver manager currently used.

Type

Integer, read only

Values<0
No driver manager available (Unix/Linux).
0
Unspecified (manager not loaded dynamically).
1
iODBC.
2
unixODBC.
A negative value for this parameter indicates that no driver manager could be found on thesystem. As a consequence only the integrated SQLite driver can be accessed.

Note
ModulemmodbcSQLextn
Description

Enable/Disable extended syntax.

Type

Boolean, read/write

Valuestrue Enable extended syntax.
false Disable extended syntax.

Default valuetrue

Affects routines

SQLconnect, SQLexecute.

ModulemmodbcFair Isaac Corporation Proprietary Information

360

Chapter 11: mmodbc

SQLfirstndx
Description

Initial index value for an automatic indexation.

Type

Integer, read/write

Default value

1

Affects routines

SQLexecute.

See also

SQLautondx.

ModulemmodbcSQLndxcol
Description

Indicates whether the first columns of each row must be interpreted as indices in all cases.
Setting it to the value false might be useful, for example, if one is trying to access a
non-relational table, perhaps a dense spreadsheet table. Note this mode can be enabled only if
at least the last dimension of each array is of fixed size.

Type

Boolean, read/write

Valuestrue Interpret the first columns of each row as indices.
false Do not interpret the first columns of each row as indices.

Default valuetrue

Affects routines

SQLexecute, SQLreadinteger.SQLreadreal, SQLreadstring.

ModulemmodbcSQLrowcnt
Description

Number of lines affected by the last SQL command.

Type

Integer, read only

Set by routines

SQLexecute, SQLreadinteger.SQLreadreal, SQLreadstring.

See also

SQLrowxfr.

ModulemmodbcSQLrowxfr
Description

Number of lines transferred during the last SQL command.

Type

Integer, read only

Set by routines

SQLexecute, SQLreadinteger.SQLreadreal, SQLreadstring.

See also

SQLrowcnt.

ModulemmodbcFair Isaac Corporation Proprietary Information

361

Chapter 11: mmodbc

SQLsuccess
Description

Indicate whether the last SQL command has been executed successfully.

Type

Boolean, read only

Valuestrue Succes.
false Error.

Set by routines

All ODBC functions.

Modulemmodbc

SQLtruncsize
Description

Length of the largest string that has been truncated.

Type

Integer, read only

Note

When exporting text to the database all strings must fit into the predefined column size
(SQLcolsize). If strings are truncated due to this limit the operation status is set to false(see SQLsuccess) and this parameter receives the size that should be used to avoid any
truncation.

Set by routines

SQLexecute.

See also

SQLsuccess, SQLcolsize.

ModulemmodbcSQLverbose
Description

Enable/disable message printing by the ODBC driver.

Type

Boolean, read/write

Valuestrue Enable message printing.
false Disable message printing.

Default value

true

Modulemmodbc11.6 Procedures and functions
This section lists in alphabetical order the functions and procedures that are provided by the mmodbc
module.
SQLcolumns

Get the columns of a given table.

SQLcommit

Terminate the current transaction by committing any pending changes.
p. 365

SQLconnect

Connect to a database.

p. 366

SQLdataframe

Retrieve a dataframe of an SQL query.

p. 368Fair Isaac Corporation Proprietary Information

p. 364362

Chapter 11: mmodbc

SQLdisconnect

Terminate the active database connection.

p. 369

SQLexecute

Execute an SQL command.

p. 370SQLgetparamGet the value of an SQL parameter.

p. 373SQLindicesGet the list of indices of a given table.

p. 374

SQLparam

Generate an SQL parameter.

p. 372SQLprimarykeys

Get the list of primary keys of a given table.

p. 375

SQLreadinteger

Read an integer value from a database.

p. 376

SQLreadreal

Read a real value from a database.

p. 377

SQLreadstring

Read a string from a database.

p. 378SQLrollback

Terminate the current transaction by discarding any pending changes. p. 379

SQLtables

Get the list of tables available in the database.

p. 380SQLupdate

Update the selected data with the provided array(s).

p. 381

Fair Isaac Corporation Proprietary Information

363

Chapter 11: mmodbc

SQLcolumns
Purpose
Synopsis

Get the columns of a given table.
function SQLcolumns(t:string,cname:array(range) ofstring,cstype:array(range) of string):integerfunction SQLcolumns(t:string,cname:array(range) ofstring,citype:array(range) of integer):integerfunction SQLcolumns(t:string,cname:array(range) of string):integer

Argumentst
cname
cstypecitype

The table nameAn array of strings to return the column names
An array of strings to return the column types (textual representation)
An array of integers to return the column types (type codes)

Return value
Number of columns.
ExampleThe following example displays the names and types of columns of table ’dtt’:
declarations
CR:range
cname:dynamic array(CR) of string
ctype:dynamic array(CR) of string
end-declarations
nbc:=SQLcolumns("dtt",cname,ctype)write("Table 'dtt' has columns:")
forall(c in 1..nbc) write(' ',cname(c),'(',ctype(c),')')
writeln

Related topics
SQLtables, SQLprimarykeys, SQLindices.
ModulemmodbcFair Isaac Corporation Proprietary Information364

Chapter 11: mmodbc

SQLcommit
Purpose
Synopsis

Terminate the current transaction by committing any pending changes.
procedure SQLcommit

Further information
If the database supports transactions and the connection has been created in manual commit mode (seeSQLautocommit), all changes to the database are recorded as a transaction. This procedure commits
all pending changes corresponding to the current transaction and starts a new transaction.
Related topics
SQLrollback.
ModulemmodbcFair Isaac Corporation Proprietary Information

365

Chapter 11: mmodbc

SQLconnect
Purpose
Synopsis

Connect to a database.
procedure SQLconnect(s:string|text)

Arguments
ExampleConnection string

The following connects to the MySQL database ‘test’ as the user ‘yves’ with the password ‘DaSH’:
SQLconnect("DSN=mysql;DB=test;UID=yves;PWD=DaSH")
Open the database mydata.sqlite with the integrated SQLite engine:
SQLconnect("mydata.sqlite")

Fair Isaac Corporation Proprietary Information

366

Chapter 11: mmodbc

Further information
1. This procedure establishes a connection to the database defined by the given connection string. If
extended mode is in use (default) and the ODBC driver manager publishes its driver list, the connection
string may be reduced to a file name as long as this name allows identification of the required driver (byusing the filename extension).
2. Both Unicode and ANSI ODBC interfaces are supported. By default the Unicode interface is used on
Windows and the ANSI interface is selected on Posix systems. It is possible to choose the interface byusing the "enc:" file name prefix: any of the UTF encodings (except UTF-8) will enable the Unicodeinterface. Otherwise the ANSI interface is selected using the specified encoding. For instance for using
the ANSI interface under Windows with an Access database: "enc:sys,mydb.mdb". Similarly, to use
the Unicode interface of MySQL on a Unix machine, the connection strings looks like:"enc:wchar,DSN=mysql;DB=test".
3. It is possible to open several connections but the connection established last becomes active. Eachconnection is assigned an identification number which can be obtained by getting the value of theparameter SQLconnection after this procedure has been executed. This parameter can also be used tochange the active connection.
4. ODBC drivers are not necessarily executed from the same working directory as the model. As aconsequence, a driver expecting a file as data source may not be able to locate the file if its name isrelative to the current directory (e.g. "DSN=Microsoft Access Driver; DBQ=mydb.mdb"). The
use of the function expandpath from mmsystem allows to avoid this problem by generating an absolute
path name for the given name (e.g. "DSN=Microsoft Access Driver;
DBQ="+expandpath("mydb.mdb")).
5. When Mosel is running in restricted mode (see Section 1.3.4), connections using a file name are notpossible if restriction NoRead or NoWrite is active and connections using a DSN are disabled by
restriction NoDB.
6. The embedded SQLite database engine is selected when specifying a file name with extension ".db",".db3", ".sqlite" or ".sqlite3". The driver may also be selected with the help of an extended
connection string starting with the DRIVER keyword and using "mmsqlite" as the driver name. In thiscase the option DB has to be set in order to select the database file and READONLY may also be added toopen the database read-only. The option TIMEOUT will define the busy timeout for the connection: this isan amount of time (in milliseconds) indicating for how long SQLite will try to execute a query when the
database is locked (by default the query fails if the database is already used by a concurrent connection).
A typical connection string for this SQLite driver is therefore of the form:"DRIVER=mmsqlite;READONLY=FALSE;TIMEOUT=0;DB=mydata.db" (that is the same as"mydata.db"). When using this syntax a temporary database can be created by using an empty filename and an in-memory database is generated if the file name is ":memory:".
Related topics
SQLdisconnect.
ModulemmodbcFair Isaac Corporation Proprietary Information

367

Chapter 11: mmodbc

SQLdataframe
Purpose
Synopsis

Retrieve a dataframe of an SQL query.
procedure SQLdataframe(query: string|text, dfrm: array(R:range, C:set of
string))Arguments
query SQL query
dfrm An array to receive the dataframe
ExampleThe example shows how to populate an array of type any from a join of two tables.
declarations
DFT:array(RT:range,CST:set of string) of text
DFA:array(RA:range,CSA:set of string) of any
end-declarations
SQLdataframe("select ⁎ from mytesttable", DFT)
writeln("Field indices: ", CST)
SQLdataframe("select ⁎ from mytesttable inner join anothertable " +"on id=customer", DFA)writeln("Field indices: ", CSA)
writeln("Number of data records (rows): ", RA.size)

Further information
1. This procedure retrieves the dataframe associated to an SQL query: lines of the result set are numbered
starting from 1 (index set R) and columns (index set C) are named after the corresponding column namesof the result set (if a column has no name a unique identifier is generated by the routine), the type of theoutput array is expected to be compatible with the columns of the result set.
2. The routine supports union types (like any), this will be the preferred approach when getting thedataframe from a query for which no type information is available. Otherwise the data received from thedatabase is cast to the type of the provided array (this may lead to invalid data for instance if thedatabase returns some textual information while the array if of a numerical type).
Related topics
SQLexecute

Fair Isaac Corporation Proprietary Information

368

Chapter 11: mmodbc

SQLdisconnect
Purpose
Synopsis

Terminate the active database connection.
procedure SQLdisconnect

Further information
The active connection can be accessed or changed by setting the control parameter SQLconnection.
Related topics
SQLconnect.
ModulemmodbcFair Isaac Corporation Proprietary Information369

Chapter 11: mmodbc

SQLexecute
Purpose
Synopsis

Execute an SQL command.
procedure SQLexecute(s:string|text)
procedure SQLexecute(s:string|text, a:array)procedure SQLexecute(s:string|text, l:list)
procedure SQLexecute(s:string|text, m:set)procedure SQLexecute(s:string|text, lp:list, a:array)procedure SQLexecute(s:string|text, lp:list, l:list)
procedure SQLexecute(s:string|text, lp:list, m:set)

Arguments
s
a
l
m
lp
ExampleSQL command to be executed
An array
A listA set
A list of parameters

The following example contains four SQLexecute statements performing the following tasks:■ Get all different values of the column color in the table pricelist.
■ Initialize the arrays colors and prices with the values of the columns color and price of thetable pricelist.

■ Create a new table newtab in the active database with 2 columns, ndx and price.
■ Add data entries to table newtab.

declarations
prices: array(1001..1004) of realcolors: array(1001..1004) of string
allcolors: set of string
end-declarations
SQLexecute("select color from pricelist", allcolors)
SQLexecute("select articlenum,color,price from pricelist",[colors,prices])
SQLexecute("create table newtab (ndx integer, price double)")SQLexecute("insert into newtab (ndx, price) values (?,?)", prices)

Fair Isaac Corporation Proprietary Information

370

Chapter 11: mmodbc

Further information
1. This procedure executes the given SQL command. The user is referred to the documentation of thedatabase driver he is using for more information about the commands that are supported by it. Note that
if extended syntax is in use (default), parameters usually noted ’?’ in normal SQL queries may benumbered (like ’?1’,’?2’,...) in order to control in which order are mapped columns of data source table toMosel arrays. This feature is especially useful when writing ’update’ queries for which indices must
appear after values (e.g. "update mytable set datacol=?2 where ndxcol=?1").
2. For output commands (like insert into) this procedure accepts arrays, sets and lists of basic types(integer, real, string or Boolean) as well as module types for which from/to string conversions areavailable. Record types composed of scalars or other records can also be used (the fields that cannot be
handled are silently ignored). It is also possible to use a list of arrays of basic types (all arrays must be
indexed by the same sets) or a list of scalar elements of different basic or module types.
3. For input commands (like select from) the same restrictions apply for arrays,lists and list of arrays
but sets must be of a basic type.
4. The form using an extra list argument will be used with input commands requiring parameters: the list
defines the value of the parameters.
Related topics
SQLupdate, SQLreadinteger, SQLreadreal, SQLreadstring, SQLdataframe.
ModulemmodbcFair Isaac Corporation Proprietary Information

371

Chapter 11: mmodbc

SQLparam
Purpose
Synopsis

Generate an SQL parameter.
function SQLparam(i:integer):SQLparameter
function SQLparam(r:real):SQLparameter
function SQLparam(s:string):SQLparameter

Argumentsirs

The initial value as an integer
The initial value as a real
The initial value as a string

Return value
SQL parameter suitable for SQL routines.
ExampleThe following calls a procedure named myproc using 3 parameters. The first one is an input string
parameter (’hello’), the second is an input/output integer parameter (10) and the last one is an output
string parameter. The procedure returns a result set that mmodbc will use to initialise result. After
execution of the query, the new values of the 2 input/output parameters set by the procedure may bedisplayed using the appropriate SQLgetparam routines.
SQLexecute("CALL myproc(?,?,?)",['hello',SQLparam(10),SQLparam("")],result)writeln("P1=",SQLgetiparam(1))
writeln("P2=",SQLgetsparam(2))

Further information
1. This routine can only be used in a list of parameters for an SQL query: it defines an input/output
parameter. The input value of the parameter is provided via the argument function (an integer, a real or astring) and the output value (set by the database during the execution of the query) can be retrieved using
one of the SQLgetparam functions.
2. SQL parameters are typed: the type of the parameter is deduced from its initial values (passed to the
SQLparam function).
Related topics
SQLexecute, SQLreadreal, SQLreadstring, SQLreadinteger, SQLgetparam.
ModulemmodbcFair Isaac Corporation Proprietary Information

372

Chapter 11: mmodbc

SQLgetparam
Purpose
Synopsis

Get the value of an SQL parameter.
function SQLgetiparam(n:integer):integerfunction SQLgetrparam(n:integer):realfunction SQLgetsparam(n:integer):stringArgumentnParameter number ( ≥ 1)

Return value
The value of the corresponding parameter.
Further information
1. This routine can be used after a query using input/output SQL parameters has been executed to retrieve
the values of the parameters.
2. Each of the 3 functions is associated to a specific type: for instance SQLgetiparam will return values
only for integer parameters.
Related topics
SQLparam.
ModulemmodbcFair Isaac Corporation Proprietary Information

373

Chapter 11: mmodbc

SQLindices
Purpose
Synopsis

Get the list of indices of a given table.
procedure SQLindices(t:string,ls:list of string)Argumentst
ls

The table name
A list of strings to return the index names

Further information
The provided list is reset.
Related topics
SQLtables, SQLcolumns, SQLprimarykeys.
ModulemmodbcFair Isaac Corporation Proprietary Information

374

Chapter 11: mmodbc

SQLprimarykeys
Purpose
Synopsis

Get the list of primary keys of a given table.
procedure SQLprimarykeys(t:string,ls:list of string)procedure SQLprimarykeys(t:string,li:list of integer)

Argumentst
lsli

The table name
A list of strings to return the column names
A list of strings to return the column numbers

Further information
The provided list is reset.
Related topics
SQLtables, SQLcolumns, SQLindices.
ModulemmodbcFair Isaac Corporation Proprietary Information

375

Chapter 11: mmodbc

SQLreadinteger
Purpose
Synopsis

Read an integer value from a database.
function SQLreadinteger(s:string|text):integerfunction SQLreadinteger(s:string|text,p:list):integer

Argumentssp

SQL command for selecting the value to be readA list of SQL parameters

Return value
Integer value read or 0.
ExampleThe following gets the article number of the first data item in table pricelist for which the field color
is set to blue:
i:=SQLreadinteger("select articlenum from pricelist where color=blue")

Further information
1. 0 is returned if no integer value can be found.
2. If the given SQL selection command does not denote a single value, the first value to which the selection
criterion applies is returned.
3. The second argument can be used to specify SQL parameter values if the SQL query contains parameter
markers.
Related topics
SQLexecute, SQLreadreal, SQLreadstring.
ModulemmodbcFair Isaac Corporation Proprietary Information

376

Chapter 11: mmodbc

SQLreadreal
Purpose
Synopsis

Read a real value from a database.
function SQLreadreal(s:string|text):realfunction SQLreadreal(s:string|text,p:list):realArgumentssp

SQL command for selecting the value to be readA list of SQL parameters

Return value
Real value read or 0.
ExampleThe following returns the price of the data item with index 2 in table newtab:
r:=SQLreadreal("select price from newtab where ndx=2")

Further information
1. 0 is returned if no real value can be found.
2. If the given SQL selection command does not denote a single value, the first value to which the selection
criterion applies is returned.
3. The second argument can be used to specify SQL parameter values if the SQL query contains parameter
markers.
Related topics
SQLexecute, SQLreadinteger, SQLreadstring.
ModulemmodbcFair Isaac Corporation Proprietary Information

377

Chapter 11: mmodbc

SQLreadstring
Purpose
Synopsis

Read a string from a database.
function SQLreadstring(s:string|text):string
function SQLreadstring(s:string|text,p:list):stringArgumentssp

SQL command for selecting the string to be readA list of SQL parameters

Return value
String read or empty string.
ExampleThe following retrieves the color of the (first) data item in table pricelist with article number 1004:
s:=SQLreadstring("select color from pricelist where articlenum=1004")

Further information
1. The empty string is returned if no real value can be found.
2. If the given SQL selection command does not denote a single entry, the first string to which the selection
criterion applies is returned.
3. The second argument can be used to specify SQL parameter values if the SQL query contains parameter
markers.
Related topics
SQLexecute, SQLreadinteger, SQLreadreal.
ModulemmodbcFair Isaac Corporation Proprietary Information

378

Chapter 11: mmodbc

SQLrollback
Purpose
Synopsis

Terminate the current transaction by discarding any pending changes.
procedure SQLrollback

Further information
If the database supports transactions and the connection has been created in manual commit mode (seeSQLautocommit), all changes to the database are recorded as a transaction. This procedure discards
all pending changes corresponding to the current transaction and starts a new transaction.
Related topics
SQLcommit.
ModulemmodbcFair Isaac Corporation Proprietary Information

379

Chapter 11: mmodbc

SQLtables
Purpose
Synopsis

Get the list of tables available in the database.
procedure SQLtables(l:list of string)Argumentl

A list of strings to return the table names

Further information
This procedure retrieves the list of tables available in the current database. The provided list is reset.
Related topics
SQLcolumns, SQLprimarykeys, SQLindices.
ModulemmodbcFair Isaac Corporation Proprietary Information

380

Chapter 11: mmodbc

SQLupdatePurpose
Synopsis

Update the selected data with the provided array(s).
procedure SQLupdate(s:string|text, a:array)procedure SQLupdate(s:string|text, la:list)

Argumentssala
ExampleAn SQL ‘SELECT’ command
An array of one of the basic types (integer, real, string or Boolean)
A list of arrays of basic types (integer, real string or Boolean)

The following example initializes the array prices with the values of the table pricelist, changes
some values in the array and finally, updates the date in the table pricelist.
declarations
prices: array(1001..1004) of real
end-declarations
SQLexecute("select articlenum,price from pricelist", prices)
prices(1002):=prices(1002)⁎0.9; prices(1003):=prices(1003)⁎0.8
SQLupdate("select articlenum,price from pricelist", prices)

Further information
This procedure updates the data selected by an SQL command (usually ‘SELECT’) with an array or tuple ofarrays. This procedure is available only if the data source supports positioned updates (for instance, MS
Access does but MS Excel does not). An IO error will be raised if the required functionality is not available.
Related topics
SQLexecute.
ModulemmodbcFair Isaac Corporation Proprietary Information

381

Chapter 11: mmodbc

11.7 I/O drivers
In order to simplify access to ODBC enabled data sources, this module provides a driver designed to be
used in initializations blocks for both reading and writing data.

11.7.1 Driver odbc
odbc:[debug;][noindex;][colsize=#;][bufsize=#;]DSN

The driver can only be used in ‘initializations’ blocks. The Data Source Name to use has to be given in the
opening part of the block. Before the DSN, the following options may be stated:debug

to execute the block in debug mode (to display what SQL queries are produced). This
option is ignored if the model is not compiled with debug information,

noindexto indicate that only data (no indices) are transferred between the data source and Mosel.
By default, the first columns of each table are interpreted as index values for the array to
be transferred. This behaviour is changed by this option,colsize=c

to set the size of a text column (default 64 characters),

bufsize=c

to set the size of the data buffer in kilobytes (default 4).

In the block, each label entry is understood as a table name optionally followed by a list of column names
in brackets (e.g. "my_table(col1,col2)"). All columns are used if no list of names is specified. Note
that, before the table name, one can add option noindex to indicate that for this particular entry indices
are not used.
Example:initializations from "mmodbc.odbc:auction.db3"
NWeeks as "PARAMS(Weeks)"! Initialize `NWeeks' with column `Weeks'! of table `PARAMS'BPROF as "noindex;BPROFILE"! Initialize `BPROF' with table `BPROFILE'! all columns being data (no indices)
end-initializations

Fair Isaac Corporation Proprietary Information

382

CHAPTER 12

mmquadThe mmquad module extends the Mosel language with a new type for representing quadratic
expressions.To use this module, the following line must be included in the header of the Mosel model file:uses 'mmquad'

The first section presents the new functionality for the Mosel language that is provided by mmquad,
namely the new type qexp and a set of subroutines that may be applied to objects of this type.
Via the inter-module communication interface, the module mmquad publishes several of its libraryfunctions. These are documented in the second section. By means of an example it is shown how thefunctions published by mmquad can be used in another module for accessing quadratic expressions andworking with them.

12.1 New functionality for the Mosel language
12.1.1 The type qexp and its operators
The module mmquad defines the type qexp to represent quadratic expressions in the Mosel Language.
As shown in the following example, mmquad also defines the standard arithmetic operations that are
required for working with objects of this type. By and large, these are the same operations as for linear
expressions (type linctr of the Mosel language) with in addition the possibility to multiply two decisionvariables or one variable with itself. For the latter, the exponential notation xˆ2 may be used (assumingthat x is of type mpvar).

12.1.1.1 Example: using mmquad for Quadratic Programming
Quadratic expressions as defined with the help of mmquad may be used to define quadratic objectivefunctions for Quadratic Programming (QP) or Mixed Integer Quadratic Programming (MIQP) problems.
The Xpress-Optimizer module mmxprs for instance accepts expressions of type qexp as arguments for
its optimization subroutines minimize and maximize, and for the procedure loadprob (see also the
mmxprs Reference Manual). The following
model "Small MIQP example"
uses "mmxprs", "mmquad"declarations
x: array(1..4) of mpvar
Obj: qexp
end-declarations! Define some linear constraints
x(1) + 2⁎x(2) - 4⁎x(4) >= 03⁎x(1) - 2⁎x(3) - x(4) <= 100

Fair Isaac Corporation Proprietary Information

383

Chapter 12: mmquadx(1) + 3⁎x(2) + 3⁎x(3) - 2⁎x(4) >= 10
x(1) + 3⁎x(2) + 3⁎x(3) - 2⁎x(4) <= 30
2 <= x(1); x(1) <= 20
x(2) is_integer; x(3) is_integerx(4) is_free! The objective function is a quadratic expression
Obj:= x(1) + x(1)^2 + 2⁎x(1)⁎x(2) + 2⁎x(2)^2 + x(4)^2! Solve the problem and print its solution
minimize(Obj)writeln("Solution: ", getobjval)
forall(i in 1..4) writeln(getsol(x(i)))
end-model

12.1.2 Procedures and functions
The module mmquad overloads certain subroutines of the Mosel language, replacing an argument of typelinctr by the type qexp.
exportprob

Export a quadratic problem to a file.

p. 385getsolGet the solution value of a quadratic expression.

p. 386

Fair Isaac Corporation Proprietary Information

384

Chapter 12: mmquadexportprob
Purpose
Synopsis

Export a quadratic problem to a file.
procedure exportprob(options:integer, filename:string, obj:qexp)
procedure exportprob(filename:string, obj:qexp)

Arguments
options

File format options:

EP_MINLP format, minimization
EP_MAX
LP format, maximization
EP_MPSMPS format
EP_STRIP Use scrambled names
EP_HEX
Ouput numbers in hexadecimal when using MPS format
filename Name of the output file; if empty, output printed to standard output (screen)
obj
Objective function (quadratic expression)
ExampleThe following example prints the problem to screen using the default format, and then exports the
problem in LP-format to the file prob1.lp maximizing constraint Profit:
uses "mmquad"declarations
Profit:qexp
end-declarations...
exportprob(0, "", Profit)
exportprob(EP_MAX, "prob1", Profit)

Further information
This procedure overloads the exportprob subroutine of Mosel to handle quadratic objective functions.
It exports the current problem to a file, or if no file name is given (empty string ""), prints it on screen. If
the given filename has no extension, Mosel appends .lp to it for LP format files and .mat for MPS
format.
ModulemmquadFair Isaac Corporation Proprietary Information

385

Chapter 12: mmquad

getsolPurpose
Synopsis

Get the solution value of a quadratic expression.
function getsol(q:qexp):realArgumentq

A quadratic expression

Return value
Solution value or 0.
Exampleuses "mmquad"declarations
x,y,z: mpvar
Profit:qexp
end-declarations...
! (Define and solve the problem)
writeln("Profit value: ", getsol(Profit))
writeln("Evaluation of an expression: ", getsol(x⁎y+5⁎z^2))
Further information
This function returns the evaluation of a given quadratic expression using the current (primal) solution
values of its variables. Note that the solution value of a variable is 0 if the problem has not been solved or
the variable is not contained in the problem that has been solved.
ModulemmquadFair Isaac Corporation Proprietary Information

386

Chapter 12: mmquad12.2 Published library functions
The module mmquad publishes some of its library functions via the service IMCI for use by othermodules (see the Mosel Native Interface Reference Manual for more detail about services). The list of
published functions is contained in the interface structure mmquad_imci that is defined in the module
header file mmquad.h.
From another module, the context of mmquad and its communication interface can be obtained using
functions of the Mosel Native Interface as shown in the following example.
static XPRMnifct mm;
XPRMcontext mmctx;
XPRMdsolib dso;
mmquad_imci mq;
void ⁎⁎quadctx;
dso=mm->finddso("mmquad");/⁎ Retrieve the mmquad module⁎/
quadctx=⁎(mm->getdsoctx(mmctx, dso, (void ⁎⁎)(&mq)));/⁎ Get the module context and thecommunication interface of mmquad ⁎/Typically, a module calling functions that are provided by mmquad will include this module into its list of
dependencies in order to make sure that mmquad will be loaded by Mosel at the same time as the calling
module. The “dependency” service of the Mosel Native Interface has to be used to set the list of module
dependencies:
static const char ⁎deplist[]={"mmquad",NULL};/⁎ Module dependency list ⁎/static XPRMdsoserv tabserv[]={{XPRM_SRV_DEPLST, (void ⁎)deplist}};/⁎ Table of services ⁎/12.2.1 Complete module example
If the Mosel procedures write / writeln are applied to a quadratic expression, they print the addressof the expression and not its contents (just the same would happen for types mpvar or linctr).
Especially for debugging purposes, it may be useful to be able to display some more detailed information.
The module example printed below defines the procedure printqexp that displays all the terms of aquadratic expression (for simplicity’s sake, we do not retrieve the model names for the variables but
simply print their addresses).
model "Test printqexp module"
uses "printqexp"
declarations
x: array(1..5) of mpvar
q: qexp
end-declarations
printqexp(10+x(1)⁎x(2)-3⁎x(3)^2)
q:= x(1)⁎(sum(i in 1..5) i⁎x(i))
printqexp(q)end-model

Note that in this model it is not necessary to load explicitly the mmquad module. This will be done by theprintqexp module because mmquad appears in its dependency list.
#include <stdlib.h>

Fair Isaac Corporation Proprietary Information

387

Chapter 12: mmquad#include "xprm_ni.h"#include "mmquad.h"/⁎⁎⁎⁎ Function prototypes ⁎⁎⁎⁎/
static int printqexp(XPRMcontext ctx,void ⁎libctx);/⁎⁎⁎⁎ Structures for passing info to Mosel ⁎⁎⁎⁎//⁎ Subroutines ⁎/static XPRMdsofct tabfct[]={{"printqexp", 1000, XPRM_TYP_NOT, 1, "|qexp|", printqexp}};
static const char ⁎deplist[]={"mmquad",NULL};/⁎ Module dependency list ⁎//⁎ Services ⁎/static XPRMdsoserv tabserv[]={{XPRM_SRV_DEPLST, (void ⁎)deplist}};/⁎ Interface structure ⁎/static XPRMdsointer dsointer={
0,NULL, sizeof(tabfct)/sizeof(XPRMdsofct),tabfct,
0,NULL, sizeof(tabserv)/sizeof(XPRMdsoserv),tabserv};/⁎⁎⁎⁎ Structures used by this module ⁎⁎⁎⁎/
static XPRMnifct mm;/⁎ For storing Mosel NI function table ⁎//⁎⁎⁎⁎ Initialize the module library just after loading it ⁎⁎⁎⁎/
DSO_INIT printqexp_init(XPRMnifct nifct, int ⁎interver,int ⁎libver, XPRMdsointer ⁎⁎interf){
mm=nifct;/⁎ Save the table of Mosel NI functions ⁎/⁎interver=MM_NIVERS;/⁎ Mosel NI version ⁎/⁎libver=MM_MKVER(0,0,1);/⁎ Module version ⁎/⁎interf=&dsointer;/⁎ Pass info about module contents to Mosel ⁎/}return 0;/⁎⁎⁎⁎ Implementation of "printqexp" ⁎⁎⁎⁎/
static int printqexp(XPRMcontext ctx, void ⁎libctx){
XPRMdsolib dso;
mmquad_imci mq;
mmquad_qexp q;
void ⁎⁎quadctx;
void ⁎prev;
XPRMmpvar v1,v2;
double coeff;
int nlin,i;
dso=mm->finddso("mmquad");/⁎ Retrieve reference to the mmquad module⁎/
quadctx=⁎(mm->getdsoctx(ctx, dso, (void ⁎⁎)(&mq)));/⁎ Get the module context and thecommunication interface of mmquad ⁎/q = XPRM_POP_REF(ctx);/⁎ Get the quadratic expression from the stack ⁎//⁎ Get the number of linear terms ⁎/mq->getqexpstat(ctx, quadctx, q, &nlin, NULL, NULL, NULL);/⁎ Get the first term (constant) ⁎/prev=mq->getqexpnextterm(ctx, quadctx, q, NULL, &v1, &v2, &coeff);
if(coeff!=0) mm->printf(ctx, "%g ", coeff);for(i=0;i<nlin;i++)/⁎ Print all linear terms ⁎/{Fair Isaac Corporation Proprietary Information

388

Chapter 12: mmquad
prev=mq->getqexpnextterm(ctx, quadctx, q, prev, &v1, &v2, &coeff);
mm->printf(ctx,"%+g %p ", coeff, v2);}
while(prev!=NULL)/⁎ Print all quadratic terms ⁎/{prev=mq->getqexpnextterm(ctx, quadctx, q, prev, &v1, &v2, &coeff);
mm->printf(ctx,"%+g %p ⁎ %p ", coeff, v1, v2);}
mm->printf(ctx,"\n");}return XPRM_RT_OK;

12.2.2 Description of the library functions
clearqexpstat

Free the memory allocated by getqexpstat.

p. 392

getqexpnextterm

Enumerate the terms of a quadratic expression.

p. 393getqexpsol

Evaluate a quadratic expression.

p. 390getqexpstat

Get information about a quadratic expression.

p. 391

Fair Isaac Corporation Proprietary Information

389

Chapter 12: mmquadgetqexpsol
Purpose
Synopsis

Return an evaluation of a quadratic expression based on the current solution.
double getqexpsol(XPRMctx ctx, void ⁎quadctx, mmquad_qexp q);

Arguments
ctx
Mosel’s execution context
quadctx Context of mmquadqReference to a quadratic expression
Return value
An evaluation of the expression on the current solution.
Further information
This function returns an evaluation of a quadratic expression based on last solution obtained from theoptimizer. This is the function called when using getsol on a quadratic expression from a Mosel
program.
ModulemmquadFair Isaac Corporation Proprietary Information390

Chapter 12: mmquadgetqexpstat
Purpose
Synopsis

Get information about a quadratic expression.
int getqexpstat(XPRMctx ctx, void ⁎quadctx, mmquad_qexp q, int ⁎nblin, int⁎nbqd, int ⁎changed, XPRMmpvar ⁎⁎lsvar);

Arguments
ctx
quadctx
q
nblin
nbqd
changedlsvar

Mosel’s execution context
Context of mmquad
Reference to a quadratic expression
Pointer to which the number of linear terms is returned (may be NULL)
Pointer to which the number of quadratic terms is returned (may be NULL)
Pointer to which the change flag is returned (may be NULL). Possible values of this flag:
1
The expression q has been modified since the last call to this function
0
Otherwise
Pointer to which is returned the table of variables that appear in the quadratic expression q(may be NULL)

Return value
Total number of terms in the expression.
Further information
This function returns in its arguments information about a given quadratic expression. Any of thesearguments may be NULL to indicate that the corresponding information is not required. The last entry of
the table lsvar is NULL to indicate its end. This table is allocated by the module mmquad, it must be
freed by the next call to this function or with function clearqexpstat.
ModulemmquadFair Isaac Corporation Proprietary Information

391

Chapter 12: mmquadclearqexpstat
Purpose
Synopsis

Free the memory allocated by getqexpstat.
void clearqexpstat(XPRMctx ctx, void ⁎quadctx);

Arguments
ctx
Mosel’s execution context
quadctx Context of mmquad
Further information
A call to this function frees the table of variables that has previously been allocated by a call to function
getqexpstat.
Related topics
getqexpstat.
ModulemmquadFair Isaac Corporation Proprietary Information

392

Chapter 12: mmquadgetqexpnextterm
Purpose
Synopsis

Enumerate the list of terms contained in a quadratic expression.
void ⁎getqexpnextterm(XPRMctx ctx, void ⁎quadctx, mmquad_qexp q, void ⁎prev,
XPRMmpvar ⁎v1, XPRMmpvar ⁎v2, double ⁎coeff);

Arguments
ctx
quadctx
q
prev
v1,v2
coeff

Mosel’s execution context
Context of mmquad
Reference to a quadratic expression
Last value returned by this function. Should be NULL for the first call
Pointers to return the decision variable references for the current term
Pointer to return the coefficient of the current term

Return value
The value to be used as prev for the next call o NULL when all terms have been returned.
ExampleThe following displays the terms of a quadratic expression:
void dispqexp(XPRMcontext ctx, mmquad_qexp q){
void ⁎prev;
XPRMmpvar v1,v2;
double coeff;
int nlin,ct;}

mq->getqexpstat(ctx, quadctx, q, &nlin, NULL, NULL, NULL);
ct=0;
prev=mq->getqexpnextterm(ctx, quadctx, q, NULL, &v1, &v2, &coeff);
mm->printf(ctx, "%g ", coeff);
while(prev!=NULL) {prev=mq->getqexpnextterm(ctx, quadctx, q, prev, &v1, &v2, &coeff);if(ct<nlin) { mm->printf(ctx,"%+g %p", coeff, v2); ct++; }else mm->printf(ctx,"%+g %p ⁎ %p", coeff, v1, v2);}
mm->printf(ctx,"\n");Further information
This function can be called repeatedly to enumerate all terms of a quadratic expression. For the first call,the parameter prev must be NULL and the function returns the constant term of the quadratic
expression (for v1 and v2 the value NULL is returned and coeff contains the constant term). For thefollowing calls, the value of prev must be the last value returned by the function. The enumeration iscompleted when the function returns NULL.
If this function is called repeatedly, after the constant term it returns next all linear terms and then thequadratic terms.
ModulemmquadFair Isaac Corporation Proprietary Information

393

CHAPTER 13

mmreflect
This module allows a model or package to programatically access Mosel entities whose names andtypes were not known at compile-time. To use this module, the following line must be included in theheader of the Mosel model file:uses 'mmreflect'13.1 New functionality for the Mosel language
13.1.1 The type iterator
This module provides the type iterator for enumerating the cells of an array without referring to its
individual indices. This type acts as an indexer such that an entity of this type can be used as the only
index of a compatible array for its dereferencing. Internally it maintains a reference to an array and aposition in this array in the form of an index tuple.
Before an iterator is used it must be initialised and bound to an array with a call to inititer (thisassociation may be cancelled by resetting the entity with reset). The status of an iterator (e.g. whether
it has been initialised, whether the enumeration has been completed) is returned by getstatus andpositioning it to the next available cell of the array is achieved by calling nextcell. The index tuple held
in an iterator can be accessed with getindices and setindices. The following example shows how
to copy the content of array ar1 to array ar2 using an iterator:
declarations
ar1:dynamic array(S1:set of string,R1:range) of integer
ar2:dynamic array(set of string,set of integer) of real
itr:iterator
end-declarations
ar1('a',1):=10
ar1('b',1):=20
inititer(itr,ar1)! 'itr' is associated to 'ar1'
while(nextcell(itr)) do! iterate over the existing cells of 'ar1'
ar2(itr):=ar1(itr)! 'itr' can be used with both 'ar1' and 'ar2'
writeln("indices:", itr.indices)
end-doNote that although the iterator itr is bound to array ar1, it can also be used to dereference ar2 since
this array is compatible with ar1 in terms of number and type of its indexing sets.

13.1.2 The type reflecterror
An entity of type reflecterror is returned by certain functions of this module: it characterises theexecution status of the function. The code and message associated to this status can be retrieved with

Fair Isaac Corporation Proprietary Information

394

Chapter 13: mmreflectgetcode and getmsg, no error occurred if the code is 0.
This type is defined such that an expression of type reflecterror used as a statement will cause aruntime error if the status is not null and it will be ignored otherwise. Thanks to this property a function
returning an entity of this type can be used either as a function or as a procedure: in the first case error
management will be handled by the model and in the second case any error will cause a program
termination.
err:=callproc("myproc")
if err.code<>0 thenwriteln("Failed to call 'myproc' (",err.msg,")")
exit(1)
end-if13.2 Procedures and functions
callfunc, callfunclsa

Call a public function with the given name.

p. 396

callproc, callproclsa

Call a public procedure with the given name.

p. 397findident

Find an identifier in the dictionary.

p. 398getallidents

Get all identitifiers of a model.

p. 400getallparams

Get all runtime parameters.

p. 401getannidents

Get all identitifiers of a model for which annotations are available.

p. 402

getannotations

Get model annotations associated to a given symbol.

p. 403getarrval

Get the value of a cell of an array.

p. 404getcodeGet the code associated to a reflect error.

p. 405geteltype

Get the type ID of an element of a collection.

p. 406getindices

Retrieve the index tuple held in an iterator.

p. 407

getmsgGet the message associated to a reflect error.

p. 408getnbargs

Retrieve the number of arguments required by a subroutine.

p. 409getrettype

Retrieve the return type of a subroutine.

p. 410getsignature

Retrieve the signature of a subroutine.

p. 411getstatus

Get the status of an iterator.

p. 412

inititer

Initialise an iterator.

p. 413

nextcellAdvance an iterator to the next cell of its array.

p. 414

setarrval

Set the value of a cell of an array.

p. 415setindicesSet the index tuple of an iterator.

p. 416

testtype

Test the return value of findident.

p. 417

Fair Isaac Corporation Proprietary Information

395

Chapter 13: mmreflect

callfunc, callfunclsa
Purpose
SynopsisCall a public function with the given name.
function callfunc(func:string|any, retval:any):reflecterror
function callfunc(func:string|any, retval:any, p1, p2...):reflecterror
function callfunclsa(func:string|any, retval:any, lsa:list):reflecterror

Arguments
func
The name or a reference to the function to callretval Union where the result of the function call is returnedpiParameters of the function
lsa
List of parameters of the function
Return value
The error status as a reflecterror
ExampleThe following Mosel code:
public function product(i:integer,j:integer):integer
returned:=i⁎j
end-function
declarations
u:any
end-declarations
callfunc('product',u,4,4)
writeln("4⁎4=",u.integer)
produces this output:
4⁎4=16Further information
1. When used with a name, this routine selects the function to call based on the provided arguments without
performing any conversion (for instance, using an integer where a real is expected will not work). The
execution will terminate on a runtime error if no compatible function can be found.
2. The result of the function call is returned via the parameter retval that must be a union compatible withthe type of the function. The execution will terminate on a runtime error if the result of the call cannot besaved in the provided entity.
3. The last version of the subroutine makes it possible to pass all the subroutine parameters via a single list.
4. The execution status of the function is notified via its return value. If this value is ignored (i.e. the function
is used as a procedure) the execution of the model will be interrupted in case of error (e.g. routine notfound or invalid number or type of parameters).
Related topics
callproc
ModulemmreflectFair Isaac Corporation Proprietary Information

396

Chapter 13: mmreflect

callproc, callproclsa
Purpose
SynopsisCall a public procedure with the given name.
function callproc(proc:string|any):reflecterror
function callproc(proc:string|any, p1, p2...):reflecterror
function callproclsa(proc:string|any, lsa:list):reflecterror

Arguments
proc
pi
lsa

The name or a reference to the procedure to callParameters of the procedure
List of parameters of the procedure

Return value
The error status as a reflecterror
ExampleThe following Mosel code:
public procedure myproc(i:integer)
writeln('hello world ',i);end-procedure
callproc('myproc',333)
produces this output:
hello world 333

Further information
1. When used with a name this routine selects the procedure to call based on the provided arguments
without performing any conversion (for instance, using an integer where a real is expected will not work).
The execution will terminate on a runtime error if no compatible procedure can be found.
2. The last version of the subroutine makes it possible to pass all the subroutine parameters via a single list.
3. The execution status of the function is notified via its return value. If this value is ignored (i.e. the function
is used as a procedure) the execution of the model will be interrupted in case of error (e.g. routine notfound or invalid number or type of parameters).
Related topics
callfunc
ModulemmreflectFair Isaac Corporation Proprietary Information

397

Chapter 13: mmreflect

findident
Purpose
Synopsis

Find an identifier in the dictionary.
function findident(name:string, value:any):integerfunction findident(name:string, value:any, exptype:integer):integerfunction findident(name:string, values:list of any):integer

Arguments
name
value
valuesexptype

Identifier
Union where the value of the dictionary entry is returned
List of all entities having this name as a list of unions
Expected type

Return value
Aggregated type information of the returned dictionary entry, 0 if the identifier cannot be found or -1 if thevalue cannot be saved in the value variable.
ExampleThe following:
public declarations
glbint:integer
val:any
procintarg=procedure(integer)
end-declarations
public procedure doit(i:integer)
writeln("Got ",i)end-procedure
writeln("glbint=",glbint)
if testtype(findident("glbint",val),STRUCT_REF+integer.id) thenval.integer:=123
end-ifwriteln("glbint=",glbint)
if findident("doit",val,procintarg.id)<>0 thenval.procintarg(33)! Call the procedure
end-ifproduces this output:
glbint=0
glbint=123
Got 33

Fair Isaac Corporation Proprietary Information

398

Chapter 13: mmreflect

Further information
1. This function returns the dictionary entry of a given identifier along with its type. The returned type
information is bit encoded and includes a type code and a structure that can be decoded using
getstruct, geteltype and gettypeid. Alternatively, testtype might be used to filter this value.
2. When using the second form, the function succeeds only if it can find an entity of the provided type
exptype. Note that the value returned in this case is not necessarily exptype (i.e. the function has
succeeded when its return value is positive).
3. The last form of the function makes it possible to retrieve all overloaded versions of a subroutine. As forthe previous case, the function has succeeded if its return value is positive.
4. If the identifier corresponds to a global entity of a basic type (i.e. integer, real, boolean or string) the
resulting union value will contain a reference to the actual variable and any change to its value will beapplied to the global entity.
Related topics
testtype, getstruct, geteltype
ModulemmreflectFair Isaac Corporation Proprietary Information

399

Chapter 13: mmreflectgetallidents
Purpose
Synopsis

Get all identitifiers of a model.
procedure getallidents(li:list of string)Argumentli

List receiving the identifiers

Further information
When the model is compiled with debugging information both private and public identifiers are returned(otherwise only the public symbols are reported).
Related topics
getallparams, getannidents.
ModulemmreflectFair Isaac Corporation Proprietary Information

400

Chapter 13: mmreflectgetallparams
Purpose
Synopsis

Get all runtime parameters.
procedure getallparams(li:list of string)Argumentli

List receiving the identifiers

Related topics
getallidents, getannidents.
ModulemmreflectFair Isaac Corporation Proprietary Information

401Chapter 13: mmreflectgetannidents
Purpose
Synopsis

Get all identitifiers of a model for which annotations are available.
procedure getannidents(si:set of string)procedure getannidents(li:list of string)Argumentssili

Set receiving the identifiers
List receiving the identifiers

Related topics
getannotations, applied to submodels: getannidents.
ModulemmreflectFair Isaac Corporation Proprietary Information402

Chapter 13: mmreflectgetannotations
Purpose
Synopsis

Get model annotations associated to a given symbol.
procedure getannotations(id:string, prefix:string, si:set of string,
ann:array(string) of string)procedure getannotations(id:string, prefix:string, lsa:list of string)Arguments
id
Symbol for which annotations are requested (an empty string will report global annotations)prefix Prefix filter: only annotations with a name starting with the specified prefix will be returnedsi
Set receiving the annotation names
ann
Array receiving the annotation values (indexed by anootation names)
lsa
List receiving the annotation names and values
ExampleThe following code snippet implements a function to retrieve a specific annotation for the specified
model entity (if several matching annotations are found the value of the first is returned):public function getannot(symb:string, aname:string):string
declarations
l:list of string
end-declarations
getannotations(symb,aname,l)if l.size>=2 and l(1)=aname thenreturned:=l(2)end-ifend-function
writeln("Value of first annotation 'my.annot' for entity 'x': ",getannot("x","my.annot"))
writeln("Value of first global annotation 'my.annot': ",getannot("","my.annot"))

Further information
With the version taking a list, each annotation is represented by 2 entries: the first one is the annotation
name and the second one its value. Note that the version returning information via an array will only
report partial information in the case of annotations defined several times.
Related topics
getannidents, applied to submodels: getannotations.
ModulemmreflectFair Isaac Corporation Proprietary Information

403

Chapter 13: mmreflectgetarrval
Purpose
Synopsis

Get the value of a cell of an array.
function getarrval(arr:array, val:any, ...):reflecterror
function getarrval(arr:array, val:any, lsndx:list):reflecterror

Argumentsarr
An array or a union containg an arrayval
A union reference where the value will be returned
lsndx List of indices to use
Return value
The error status as a reflecterror
Further information
1. The procedure will use the arguments after val as the list of indices to use (that can be an iterator) or
take the provided list lsndx if it is the only argument.
2. Thanks to this procedure it is possible to retrieve the value of an array cell without knowing its type.
However, it is more efficient to dereference the array directly when the type is known (e.g.
un.array(1).integer).
3. The execution status of the function is notified via its return value. If this value is ignored (i.e. the function
is used as a procedure) the execution of the model will be interrupted in case of error (e.g. invalid number
or type of indices).
Related topics
setarrval.
ModulemmreflectFair Isaac Corporation Proprietary Information404

Chapter 13: mmreflectgetcodePurpose
Synopsis

Get the code associated to a reflect error.
function getcode(rst:reflecterror):integer

Argument
rst

A reflect error

Return value
The code associated to the error entity or 0 if no error was recorded
Related topics
getmsg.
ModulemmreflectFair Isaac Corporation Proprietary Information405

Chapter 13: mmreflectgeteltype
Purpose
Synopsis

Get the type ID of an element of a collection.
function geteltype(a: array): integerfunction geteltype(s: set): integerfunction geteltype(l: list): integer

Argumentsasl

An array
A set
A listReturn value
A type ID.
Examplepublic declarations
myar: dynamic array(range,set of integer) of real
end-declarations
writeln(myar.eltype=real.id)! = true

Related topics
geteltype.
ModulemmreflectFair Isaac Corporation Proprietary Information

406

Chapter 13: mmreflect

getindices
Purpose
Synopsis

Retrieve the index tuple held in an iterator.
function getindices(it:iterator):list of any

Argumentit

An iterator

Return value
The list of indices stored in the iterator or an empty list if the iterator is not in the state ITER_READY
ExampleSee example in section 13.1.1.

Further information
Trying to use this function on an unbound iterator will cause a runtime error.
Related topics
setindices.
ModulemmreflectFair Isaac Corporation Proprietary Information

407

Chapter 13: mmreflectgetmsgPurpose
Synopsis

Get the message associated to a reflect error.
function getmsg(rst:reflecterror):stringArgument
rst

A reflect error

Return value
The message associated to the error entity
Related topics
getcode.
ModulemmreflectFair Isaac Corporation Proprietary Information

408

Chapter 13: mmreflect

getnbargs
Purpose
Synopsis

Retrieve the number of arguments required by a subroutine.
function getnbargs(sbr:procedure|function):integer

Argumentsbr

A reference to a subroutine or a union containing a subroutine

Return value
The number of arguments required by the subroutine
ExampleSee example for getsignature.

Related topics
getsignature, getrettype.
ModulemmreflectFair Isaac Corporation Proprietary Information409

Chapter 13: mmreflectgetrettype
Purpose
Synopsis

Retrieve the return type of a subroutine.
function getrettype(sbr:procedure|function):integer

Argumentsbr

A reference to a subroutine or a union containing a subroutine

Return value
The return type of the subroutine (this is 0 for a procedure)
ExampleSee example for getsignature.

Related topics
getsignature, getnbargs.
ModulemmreflectFair Isaac Corporation Proprietary Information

410

Chapter 13: mmreflect

getsignature
Purpose
Synopsis

Retrieve the signature of a subroutine.
function getsignature(sbr:procedure|function):stringArgumentsbr

A reference to a subroutine or a union containing a subroutine

Return value
The signature of the subroutine
Examplepublic declarations
f2: function(real, set of string):boolean
end-declarations
writeln("f takes ", getnbargs(->f2)," arguments, ","f returns a boolean: ", getrettype(->f2)=boolean.id,", signature of f: ", getsignature(->f2))! = 2! = true! = rEs

Further information
The signature of a subroutine is a text string characterising the types of the parameters it requires (but it
does not provide information on the return type of a function). This string is empty for a subroutine notrequiring any argument.
Related topics
getnbargs, getrettype.
ModulemmreflectFair Isaac Corporation Proprietary Information

411

Chapter 13: mmreflect

getstatus
Purpose
Synopsis

Get the status of an iterator.
function getstatus(it:iterator):integer

Argumentit

An iterator

Return value
Status of the iterator:
ITER_FREE
Not bound to any array (initial state)
ITER_BOUND Bound to an array but enumeration has not yet started
ITER_READY The iterator contains a valid reference
ITER_DONE
Enumeration has finished
Exampledeclarations
it: iterator
A: hashmap array(range,string) of real
end-declarations
A(2,'a'):= 0.5; A(3,'b'):= 1.25
writeln(it.status=ITER_FREE)
inititer(it,A)writeln(it.status=ITER_BOUND)
while (nextcell(it)) dowriteln(it.status=ITER_READY)
writeln('A(', it.indices, ')=', A(it))
end-dowriteln(it.status=ITER_DONE)
reset(it)writeln(it.status=ITER_FREE)! true! true! true! A([2,'a'])=0.5

A([3,'b'])=1.25! true! trueFurther information
An iterator can be used to dereference an array only when it is in the ITER_READY state.
Related topics
inititer, nextcell.
ModulemmreflectFair Isaac Corporation Proprietary Information

412

Chapter 13: mmreflect

inititer
Purpose
Synopsis

Initialise an iterator.
procedure inititer(it:iterator, a:array)procedure inititer(it:iterator, a:array, sparsenum:boolean)

Argumentsit
An iteratora
An array reference
sparsenum Sparse enumeration (default: true)
ExampleSee example for getstatus and section 13.1.1.

Further information
1. This function (re)initialises an iterator by binding it to the specified array and setting its state to
ITER_BOUND. The iterator is first reset if it was already in use.
2. The sparsenum argument decides whether the enumeration should select only the existing entries of
the array if it is of a sparse format (this option has no effect on a dense array).
Related topics
getstatus, nextcell.
ModulemmreflectFair Isaac Corporation Proprietary Information

413

Chapter 13: mmreflect

nextcellPurpose
Synopsis

Advance an iterator to the next cell of its array.
function nextcell(it:iterator):boolean

Argumentit

An iterator

Return value
true if the iterator is positioned on a cell, false if the enumeration has finished
ExampleSee example for getstatus and section 13.1.1.

Further information
1. Once an iterator has been bound to an array with inititer this function can be called iteratively until it
returns false in order to enumerate all cells of the associated array. The state of the iterator is set to
ITER_READY whenever true is returned (i.e. the iterator can be used to dereference an array).
2. After this function has returned false the iterator is in the state ITER_DONE. Calling it again will have noeffect and the return value will remain false.
3. Trying to use this function on an unbound iterator will cause a runtime error.
Related topics
getstatus, inititer.
ModulemmreflectFair Isaac Corporation Proprietary Information

414

Chapter 13: mmreflectsetarrval
Purpose
Synopsis

Set the value of a cell of an array.
function setarrval(arr:array, val:any, ...):reflecterror
function setarrval(arr:array, val:any, lsndx:list):reflecterror

Argumentsarr
An array or a union containing an arrayval
Value to be assigned
lsndx List of indices to use
Return value
The error status as a reflecterror
Further information
1. The procedure will use the arguments after val as the list of indices for accessing a cell of the array (thiscan also be an iterator) or it takes the provided list lsndx if this is the only argument.
2. If the provided value val is a string and the array is of a native type, this procedure will try to initialise thearray cell from this textual representation. Otherwise the specified value must be of the same type as thearray.
3. The execution status of the function is notified via its return value. If this value is ignored (i.e. the function
is used as a procedure) the execution of the model will be interrupted in case of error (e.g. invalid number
or type of indices).
Related topics
getarrval.
ModulemmreflectFair Isaac Corporation Proprietary Information

415

Chapter 13: mmreflect

setindices
Purpose
Synopsis

Set the index tuple of an iterator.
procedure setindices(it:iterator, lsndx:list)
procedure setindices(it:iterator, ...)

Argumentsit
An iterator
lsndx List of indices to use
Further information
1. The procedure will use the arguments after it as the list of indices forming the index tuple or it takes theprovided list lsndx if this is the only argument. After this call the iterator is in state ITER_READY even if
the designated cell does not exist in the array.
2. This procedure will cause a runtime error if the program is trying to set indices that are not compatible
with the corresponding indexing sets of the reference array (e.g. incompatible type or non-existentelement of a finalised set).
3. Trying to use this procedure on an unbound iterator will cause a runtime error.
Related topics
getindices.
ModulemmreflectFair Isaac Corporation Proprietary Information

416

Chapter 13: mmreflect

testtype
Purpose
Synopsis

Test the return value of findident.
function testtype(rts:integer, props:integer):boolean

Arguments
rts
Return value of findident
props Properties to test (can be combined by addition):
STRUCT_⁎A structure (e.g. STRUCT_ARRAY)⁎.id
A type ID (e.g. integer.id)
EPROP_PRIV
Entity is private
EPROP_PUBLIC
Entity is public
EPROP_CONST
Entity is constant
EPROP_VAR
Entity is not constant
EPROP_RANGE
Entity is a range set
EPROP_GENSET
Entity is a general set (i.e. not a range)
EPROP_DENSE
Entity is a dense array
EPROP_SPARSE
Entity is a sparse array
EPROP_DYNAMIC Entity is a sparse dynamic array
EPROP_HASHMAP Entity is a sparse hashmap array
Return value
true if the provided encoded type has all the requested properties
Examplepublic declarations
Ar: dynamic array(1..10) of real
S=1..5u1,u2:any
end-declarations
r1:=findident("Ar",u1)r2:=findident("S",u2)writeln(testtype(r1,STRUCT_ARRAY+EPROP_SPARSE))
writeln(testtype(r1,EPROP_DENSE))
writeln(testtype(r2,EPROP_RANGE+EPROP_CONST))
writeln(testtype(r2,STRUCT_SET+integer.id))! true! false! true! trueFurther information
1. This function checks whether an encoded type returned by findident corresponds to a set ofproperties.
2. The props argument cannot include more than one structure and one type ID each (all conditions mustbe satisfied at the same time). The function will always return false if it is given an invalid combination(for instance EPROP_CONST+EPROP_VAR or STRUCT_SET+EPROP_DENSE cannot succeed).
ModulemmreflectFair Isaac Corporation Proprietary Information

417

CHAPTER 14

mmrobust
The mmrobust module extends the Mosel language with new types for representing robust constraints
and describe the associated uncertainty sets. To use this module the following line must be included in
the header of the Mosel model file:uses 'mmrobust'

This is the reference manual of mmrobust. It is highly recommended to study the Xpress white paper onrobust optimization found under docs/robust in the Xpress installation.
The first section presents the new functionality for the Mosel language provided by mmrobust, namely
the new types uncertain, robustctr and uncertainctr and a set of subroutines that may be
applied to objects of these types.
The following sections give detailed documentation of the subroutines (other than mathematicaloperators) defined by this module.

14.1 New functionality for the Mosel language
14.1.1 The problem type mpproblem.xprs.robust
This module exposes its functionality through an extension to the mpproblem.xprs problem type. As aconsequence, all routines presented here are executed in the context of the current problem.

14.1.2 The type uncertain
An uncertain is a quantity whose value is not known, but carries a level of uncertainty. The type
uncertain is used in the robust constraints of type robctr to express constraints that are subject touncertainty, and in uncertainctr constraints that describe the set of values that the uncertain cantake. The values of the uncertain quantity will take the possible worst case against the optimality andfeasibility of the problem. An uncertain can be intuitively thought of as a variable that is not under ourcontrol, but which has a value defined by an opponent to be the worst with respect to the model.
It is important to note that an uncertain does not have a default lower bound of zero imposed by
Mosel, in contrast to mpvars. This difference in default behavior is to reflect the most typical use cases.
An uncertain can be assigned a nominal value using the assignement operator :=. The working of thenominal value is discussed in the Xpress robust optimization white paper found under docs/robust in the
Xpress installation.
The actual value of uncertains and robust constraints can be obtained after the solution of the robust
problem through getsol and getact. The usage of getsol is extended as explained below.

Fair Isaac Corporation Proprietary Information

418

Chapter 14: mmrobust

If an uncertain u is used in a single robust constraint or only in the objective function, then getsol(u)returns one of the possible realizations of the uncertainty set that induced the optimal solution found by
Mosel.
If the same uncertain is used in two robust constraints named RCon1 and RCon2 respectively, theoptimal solution of the problem may imply that the uncertain has different values for RCon1 and RCon2.
Then its value can be obtained for the two constraints via the command getsol(u,RCon1) andgetsol(u,RCon2).
Finally, the left-hand side of a robust constraint (e.g. RCon1) can simply be obtained via the command
getact(RCon1), whereas getsol(RCon1) returns the evaluation of left-hand side - right-hand side.

14.1.3 The type robustctr and its operators
The module mmrobust defines the type robustctr to represent robust constraints in the Mosel
Language. It also defines the standard arithmetic operations that are required for working with objects ofthis type. By and large, these are the same operations as for linear expressions (type linctr of theMosel language) with additionally the possibility to include uncertain terms (i.e. of type uncertain).

14.1.4 The type uncertainctr and its operators
An uncertainty constraint uncertainctr describes the possible values of the uncertain data, or inother words defines the feasible set of the uncertains. Intuitively, if we visualize the role of anuncertain as a value under the control of an opponent, then the set of uncertainctrs defines thelimitations under which the opponent is operating when choosing the worst possible values in respect of
the optimality and feasibility of the model.

14.1.5 Example: using mmrobust for solving a robust problem
Consider the following example
model BaseModel
uses "mmrobust";
declarations
x, y, z : mpvar
end-declarations
x + 2⁎y + 3⁎z <= 10
maximize(x+y+z)
writeln("x = ", getsol(x), "y = ", getsol(y), "z = ", getsol(z))

end-modelThis problem will solve to "x = 10 y = 0 z = 0".
Let us now assume that we only know that the sum of the first two coefficients is 3, and we need asolution that is valid for all realizations within this assumption.
model RobustModel
uses "mmrobust";
declarations
x, y, z : mpvar
u, v : uncertain
end-declarations

Fair Isaac Corporation Proprietary Information

419

Chapter 14: mmrobustu⁎x + v⁎y + 3⁎z <= 10
u+v <= 4
setparam("xprs_verbose", true)
maximize(x+y+z)
writeln("x = ", getsol(x), "y = ", getsol(y), "z = ", getsol(z), "; u = ", getsol(u), "end-modelThis problem will solve to "x = 2.5 y = 2.5 z = 0; u = 2 v = 2".
It is easy to check that any realization of the uncertains u and v will keep the solution vector feasible, andthat it is optimal within this assumption.

14.2 Control parameters
The following parameters are defined by mmrobust:robust_check_feas_original_problem

Check if original, non-robust problem is feasible. p. 421

robust_check_feas_uncertainty_set

Check if uncertainty sets are non-empty.

p. 420robust_uncertain_overlap Use of uncertain data in multiple robust constraints.

p. 420robust_uncertain_overlap
Description

This parameter allows for models where more than one robust constraint can use an
uncertain. Because each robust constraint is dealt with independently in the robust problem,the optimal solution implicitly may associate different values of the uncertain quantities witheach robust constraint.

Type

Boolean, read/write

Default value

false

Modulemmrobust

robust_check_feas_uncertainty_set
Description

This parameter allows for checking whether the uncertainty sets contain at least one feasible
vector of uncertains. In other words, with this parameter set to true Mosel will check if the
opponent actually has a choice of uncertains. If at least one uncertainty set is empty, a warning
will be issued. Uncertainty sets should not be empty as otherwise a robust problem cannot becreated.

Type

Boolean, read/write

Default value

false

Modulemmrobust

Fair Isaac Corporation Proprietary Information

420

v = ",

Chapter 14: mmrobust

robust_check_feas_original_problem
Description

This parameter allows for checking whether the problem where all uncertains are set to theirdefault value is feasible or not. This is off by default but can be useful to check correctness of
one’s model without uncertainty before solving the robust problem.

Type

Boolean, read/write

Default value

false

Modulemmrobust

14.3 Procedures and functions
The module mmrobust overloads certain mathematical operators making possible the expression of
linear and quadratic expressions involving the type uncertain in order to create both robustctr anduncertainctr objects. Since these mathematical operators are fairly self-explanatory, we shall forego
any more detailed documentation of these functions.
The following list gives an overview of all other functions and procedures defined by mmrobust for which
we give detailed descriptions later.
cardinality

Create a cardinality uncertain constraint.

p. 422

getact

Get the activity value of a robust constraint.

p. 424

getnominal

Get the nominal value of an uncertain.

p. 428

getsolGet the realisation of an uncertain or robust constraint.

p. 423gettypeGet the type of a constraint.

p. 429ishidden

Test whether a constraint is hidden.

p. 425scenario

Create a scenario uncertain constraint.

p. 426sethidden

Hide or unhide a constraint.

p. 427

setnominal

Set the nominal value of an uncertain.

p. 430settypeSet the type of a constraint.

p. 431

Fair Isaac Corporation Proprietary Information

421

Chapter 14: mmrobust

cardinality
Purpose
SynopsisCreate a cardinality uncertain constraint.
function cardinality(su:set of uncertain,m:integer):uncertainctr

Argumentssum

Uncertains to be added to the constraint
Maximum number of uncertains that can be different from their nominal value

Return value
The new cardinality uncertain constraint.
Further information
A cardinality unertain constraint limits the number of unceratins that can take a non-zero value, or bedifferent from their nominal value.
Modulemmrobust

Fair Isaac Corporation Proprietary Information

422

Chapter 14: mmrobust

getsolPurpose
Synopsis

Get the realisation of an uncertain or robust constraint.
function getsol(u:uncertain, rc:robustctr):realfunction getsol(u:uncertain):realfunction getsol(rc:robustctr):realArgumentsrcu

A robust constraint
An uncertain

Return value
Solution value or 0.
Further information
This function returns the realization of uncertain u for the robust optimization problem solved. The valueof u is only available after solving the robust optimization problem. The value of u is 0 if the problem has
not been solved or the uncertain or constraint is not contained in the problem that has been solved.
If the uncertain u appears in more than one constraint, it is necessary to specify the constraint withfunction call getsol(u,rc): this is a consequence of robust optimization, for which the same
uncertain can assume different values in different constraints. If the uncertain u only appears in one
constraint, then it suffices to call getsol(u).
The function getsol(rc) returns the evaluation of a constraint with the current realization of thesolution and the uncertains. Therefore, if a constraint is of the form u⁎x + v⁎y + z ≤ 3 andx,y,zare variables while u,v are uncertains, the current realization of x,y,z,u,v will be used to returnu⁎x + v⁎y + z - 3.
Note that robust equality constraints (for instance, u⁎x + v⁎y + z = 3) have a special status in
Mosel. The value of uncertains u and v is, in general, related to an inequality constraint and can be safely
obtained in this case only. In order to use getsol for equality robust constraints as well, it would be best
to decompose these constraints into two inequality constraints (i.e. u⁎x + v⁎y + z ≤ 3 and u⁎x +v⁎y + z ≥ 3) and then request u and v from each of the two constraints. Note that both uncertains
might differ in value when requested from either inequality constraint.
Related topics
getact.
Modulemmrobust

Fair Isaac Corporation Proprietary Information

423

Chapter 14: mmrobust

getactPurpose
Synopsis

Get the activity value of a robust constraint.
function getact(rc:robustctr):realArgumentrc

A robust constraint

Return value
Solution value or 0.
Further information
This function returns returns the value of the left-hand side of a constraint with the current realization of
the solution and the uncertains. Therefore, if a constraint is of the form u⁎x + v⁎y + z ≤ 3 andx,y,zare variables while u,v are uncertains, the current realization of x,y,z,u,v will be used to returnu⁎x + v⁎y + z.
Note that robust equality constraints (for instance, u⁎x + v⁎y + z = 3) have a special status in
Mosel. The value of uncertains u and v is, in general, related to an inequality constraint and can be safely
obtained in this case only. In order to use getact for equality robust constraints as well, it would be best
to decompose these constraints into two inequality constraints (i.e. u⁎x + v⁎y + z ≤ 3 and u⁎x +v⁎y + z ≥ 3) and then request u and v from each of the two constraints. Note that both uncertains
might differ in value when requested from either inequality constraint.
Related topics
getsol.
Modulemmrobust

Fair Isaac Corporation Proprietary Information424

Chapter 14: mmrobust

ishiddenPurpose
Synopsis

Test whether a constraint is hidden.
function ishidden(rc:robustctr):booleanfunction ishidden(uc:uncertainctr):boolean

Argumentsrc
uc

A robust constraint
An uncertain constraint

Return value
true if the constraint is hidden, false otherwise.
Further information
This function tests the current status of a constraint. At its creation a constraint is added to the current
problem, but using the function sethidden it may be hidden. This means, the constraint will not be
contained in the problem that is solved by the solver but it is not deleted from the definition of the
problem in Mosel.
Related topics
sethidden.
Modulemmrobust

Fair Isaac Corporation Proprietary Information

425

Chapter 14: mmrobust

scenario
Purpose
SynopsisCreate a scenario uncertain constraint.
function scenario(data:array (range,set of uncertain) of real):uncertainctr

Argument
data

Scenario data

Return value
The new scenario uncertain constraint.
Further information
A scenario uncertain constraint takes historical data of the possible realizations of the uncertain data.
In effect, the introduced uncertain constraint enforced that for any solution to the robust optimization
problem, any robust constraint robustctr is satisfied for all realizations of the uncertains as definedby the data array.
This function stores a reference to the provided array (i.e. it does not make a copy of it). As aconsequence any modification to the array will imply modifications to the constraint even after theconstraint has been built. Invalid data is only reported at the time of loading the problem into the
optimiser.
Modulemmrobust

Fair Isaac Corporation Proprietary Information

426

Chapter 14: mmrobust

sethidden
Purpose
Synopsis

Hide or unhide a constraint.
procedure sethidden(rc:robustctr, b:boolean)
procedure sethidden(uc:uncertainctr, b:boolean)

Argumentsrcucb

A robust constraint
An uncertain constraint
Constraint status:
true
Hide the constraint
false
Unhide the constraint

Further information
At its creation a constraint is added to the current problem, but using this procedure it may be hidden.
This means that the constraint will not be contained in the problem that is solved by the solver but it is
not deleted from the definition of the problem in Mosel. Function ishidden can be used to test thecurrent status of a constraint.
Related topics
ishidden.
Modulemmrobust

Fair Isaac Corporation Proprietary Information

427

Chapter 14: mmrobust

getnominal
Purpose
Synopsis

Get the nominal value of an uncertain.
function getnominal(u:uncertain):realArgumentu

An uncertain

Return value
The nominal value of the uncertain
Related topics
setnominal.
Modulemmrobust

Fair Isaac Corporation Proprietary Information

428

Chapter 14: mmrobust

gettype
Purpose
Synopsis

Get the type of a constraint.
function gettype(rc:robustctr):integerfunction gettype(uc:uncertainctr):integer

Argumentsrc
uc

A robust constraint
An uncertain constraint

Return value
Constraint type. Applicable values for nonlinear constraints are:
CT_EQ
Equality, ‘=’
CT_GEQ
Greater than or equal to, ‘ ≥ ’
CT_LEQ
Less than or equal to, ‘ ≤ ’
CT_CARD Cardinality
CT_SCEN Scenario
CT_UNB
Non-binding constraint, i.e. free
Related topics
settype.
Modulemmrobust

Fair Isaac Corporation Proprietary Information429

Chapter 14: mmrobust

setnominal
Purpose
Synopsis

Set the nominal value of an uncertain.
procedure setnominal(u:uncertain,n:real)

Argumentsun

An uncertain
A real constant

Further information
Calling this procedure has the same effect as assigning a value to the uncertain using the operator :=.
Related topics
getnominal.
Modulemmrobust

Fair Isaac Corporation Proprietary Information

430

Chapter 14: mmrobust

settype
Purpose
Synopsis

Set the type of a constraint.
procedure settype(rc:robustctr, type:integer)
procedure settype(uc:uncertainctr, type:integer)

Arguments
rc
uc
type

A robust constraint
An uncertain constraint
Constraint type. Applicable values are:
CT_EQ
CT_GEQ
CT_LEQ
CT_UNB

Equality, ‘=’Greater than or equal to, ‘ ≥ ’Less than or equal to, ‘ ≤ ’
Non-binding constraint

Further information
This procedure can be used to change the type of a constraint, turning it into an equality or inequality or
making it unbounded, i.e. free.
Related topics
gettype.
Modulemmrobust

Fair Isaac Corporation Proprietary Information

431

CHAPTER 15

mmsheetThe Mosel module mmsheet implements several I/O drivers for accessing and modifying spreadsheet
files in different formats from ‘initializations’ blocks. The I/O drivers rely on different technologies foraccessing spreadsheets.

15.1 I/O drivers
The I/O drivers provided by mmsheet are all designed to be used in ‘initializations’ blocks and expect thesame type of information regarding file names and record references. The common form of a filespecification for all the mmsheet drivers is:
mmsheet.⁎:[noindex|partndx|autondx[=#];][grow;][skiph;][emptyndx;][bufsize=#;]filename

The spreadsheet file name must be a physical file (with its extension), except for the "csv:" driver that
accepts extended file names. The driver options (stated before the file name) shared by all mmsheet
drivers are:noindex

Indicates that only data (no indices) are transferred between the spreadsheet and Mosel.
By default, the first columns of each table are interpreted as index values for the array to
be transferred. This behaviour is changed by this option.

partndx

Indicates that the first nbdim-1 columns are interpreted as indices (nbdim being thenumber of dimensions of the array to process) and remaining ones are used as data forthe last dimension.

autondx[=st] Indices are not read or written but automatically generated from the line number (thisoption only applies to 1-dimension arrays indiced by ranges). By default the first index has
value 1 but a different value st may be stated.
grow

When writing data, the driver uses the provided range ignoring the end of the data if there
is not enough space. When this option is specified, the driver extends the range by adding
lines if necessary.

skiphWith this option, the driver skips the first line (or header) of the provided range. If therange contains only one line, the following line is selected.

emptyndx

When reading array indices an empty cell causes a failure. With this option empty cells are
replaced by the default value of the corresponding type (e.g. 0 for a numerical value)bufsize=c

To set the size of the data buffer in kilobytes (default c=2).

The driver-specific options are documented separately for each driver in the following sections.

Fair Isaac Corporation Proprietary Information

432

Chapter 15: mmsheet

In the initializations block, each label entry is understood as a range in the workbook: named ranges are
represented by their name (e.g. "MyRange") and explicit ranges are noted using square brackets (e.g.
"[sheet1$a1:c2]"). For explicit ranges, the sheet is identified by its name or number and separated
from the cell selection with the $ sign. The first sheet of the workbook is selected if no indication is given.
Similarly, the used cells of the selected sheet are assumed if no selection is provided. The cell selection
can be stated either using the usual format with a letter to select the column followed by a line number(e.g. "a1:c1") or by specifying row and column numbers by prefixing the row number by the letter "R"
and the column number by the letter "C" (e.g. "R1C1:R1C3"). It is also possible to select some of thecolumns from the specified range: this can be done either with a list of names or a list of column
numbers (relative to the beginning of the range) noted in parentheses after the range description. To use
names, the option skiph must be used and the column names are taken from the header row that isskipped through this option. When using skiph, column numbers need to be stated by prefixing thecolumn number by #. Note that, before the range selection, one can add options as for the file opening.
For instance, "skiph;grow;" can be used for writing data to a named range formatted for an ODBC
connection.
In addition to the above options a label may consist in the string "rangesize;" followed by a range
specification (e.g. "rangesize;[]"), this special label can only be used to populate a list of integers
that receives the size of the range in the form of 2 integers (number of lines and number of columns).
Example:initializations from "mmsheet.excel:skiph;auction.xls"
NWeeks as "[b1:d12]"! Initialize `NWeeks' with data in b2:d12
BPROF as "noindex;BPROFILE"! Initialize `BPROF' with named range `BPROFILE'! all columns being data (no indices)
mycols as "[b1:h12](#3,#5,#7)" ! Initialize `mycols' with columns d2:d12,! f2:f12 and h2:h12
mycol2 as "[b1:h12](nam1,#5,nam3)"! Initialize `mycol2' with the column named! 'nam1', the column f2:f12 and the column! named 'nam3'
end-initializations

The mapping between the selected cells of the workbook and the Mosel data structures is similar to theone used for databases (options noindex and partndx correspond to setting parameter
mmodbc.SQLndxcol to false): refer to the section Data transfer between Mosel and the database of
the mmodbc chapter for further explanation.
Although direct read and write operations are not supported by these drivers, a spreadsheet may be open
using fopen: this allows to keep the document open across several ’initializations’ blocks and avoid thecost of loading and unloading the file (that may be expensive particularly with the "excel:" driver).
Cells of a spreadsheet are implicitly typed as either numbers, booleans or text strings. When getting thevalue of a cell the driver may have to perform a type conversion: the conversion from a number to its
textual representation relies on the real format "realfmt" (see setparam) that may have to bechanged when using a driver of this module. For instance the number 1234567 will be converted to thetext string 1.23457e+06 with the default real format ("%g"). To preserve the integer representation ofsuch a cell it is required to use "%.10g" as the real format.
For further examples of working with databases and spreadsheets, the reader is referred to the Xpress
whitepaper Using ODBC and other database interfaces with Mosel.

15.1.1 Driver excel
mmsheet.excel:[noindex|partndx;][grow;][skiph;][emptyndx;][newxl;][bufsize=#;]filename

This driver uses directly the application Excel for accessing the file (relying on COM/OLE as thecommunication channel): as a consequence it is available only under the Windows platform and requires

Fair Isaac Corporation Proprietary Information

433

Chapter 15: mmsheet

Excel to be installed on the host executing the Mosel model. All file formats handled by the version of
Excel can be used but this driver does not support creation of new files (i.e. it can only modify existing
files). In addition to the options described in the introductory section, the option newxl may be used: by
default the driver does not open the file if it can find a running instance of Excel having the required file
open: it works directly with the application and modifications made to the workbook are not saved when
the file is closed in Mosel. If this option is specified a new instance of Excel is started in all cases and theworkbook is saved before quitting the application when the file is closed in Mosel.

15.1.2 Driver xls/xlsx
mmsheet.xls:[noindex|partndx|autondx[=#];][grow;][skiph[+];][emptyndx;][bufsize=#;]filename
mmsheet.xlsx:[noindex|partndx|autondx[=#];][grow;][skiph[+];][emptyndx;][bufsize=#;]filename

These two drivers rely on the libxl library to access the spreadsheet file: they are available on the
Windows, Linux and MacOS platforms and do not require any additional software. The first driver handles
xls files while the second deals with xlsx and xlsm format Excel files. These drivers can be used to create
new files: when used for writing (through an ‘initializations to’ block) non-existing sheets areautomatically added to the workbook and the file is created if necessary. When the option skiph+ isused instead of skiph when writing to a file, the necessary header row is created if this row is empty(this option behaves like skiph when reading a file and when no column name is provided).

15.1.3 Driver csv
mmsheet.csv:[noindex|partndx|autondx[=#];][alltxt;][grow;][skiph[+];][emptyndx;][bufsize=#;][fsep=c;][dsep=c;][true=s;][false=s;]filename

This driver works on spreadsheets saved in ascii CSV format (Comma Separated Values). It is available
on all platforms that are supported by Mosel and can open or create files using extended format filenames (i.e. combining several I/O drivers). A CSV file contains a single sheet (number 1 identified as"Sheet1") and does not support named ranges, that is, cell references must use the explicit notation.
When the option skiph+ is used instead of skiph when writing to a file, the necessary header row iscreated if this row is empty (this option behaves like skiph when reading a file and when no column
name is provided). The following driver-specific options may be used to specify the properties of theformat to handle:
alltxtby default the driver tries to guess the type of the cells while reading the document (cells
can be either numbers, booleans or text strings). When this option is used all cells arerecorded as text strings

dsep=ccharacter used as decimal separator (default: ".")

fsep=ccharacter used to separate fields. The default value is ","; tabulation or ";" are also
often employed

true=stext representing the true value of a Boolean (default: "TRUE")

false=stext representing the false value of a Boolean (default: "FALSE")

For example, the following statements will read data from a file formatted for the French language andthat has been compressed with gzip:
initializations from "mmsheet.csv:fsep=;;dsep=,;true=vrai;false=faux;zlib.gzip:mydata.csv.gz"
A as "[a1:c12]"
end-initializations

Fair Isaac Corporation Proprietary Information

434

Chapter 15: mmsheet

The csv driver supports the getfsize function applied to a file already loaded into memory: it reports
the amount of memory currently allocated for the corresponding document. For instance the following
displays the memory used by "mydata.csv":
fopen("mmsheet.csv:mydata.csv",F_INPUT)
writeln(getfsize("mmsheet.csv:mydata.csv"))
fclose(F_INPUT)

Fair Isaac Corporation Proprietary Information

435

CHAPTER 16

mmssl
The Mosel module mmssl is an interface to the OpenSSL cryptographic library (http://www.openssl.org).
It brings most of the functionality of this library to the Mosel language and serves as the cryptographic
component in other parts of Mosel. In particular, it provides support for the HTTPS protocol in mmhttp
and implements the encryption and signing mechanisms used by the Mosel core libraries when secure
BIM files are used.

16.1 Overview
16.1.1 Document encryption in Mosel
Encryption and decryption of documents are achieved by cipher algorithms. Ciphers can be of two kinds:
symmetric ciphers use the same encryption key to perform the encryption and decryption tasks while
asymmetric ciphers require one key to execute the encryption and another one for the decryption. In
mmssl, symmetric ciphers are made available through the crypt I/O driver (Section 16.4.3): the encryption
key (the size of which depends on the cipher) is automatically generated based on some given
passphrase (either input from an external file or directly in the file name specification). The
implementation of the crypt driver allows the user to select which specific cipher algorithm it should use(for instance AES, DES or IDEA).
For asymmetric encryption, mmssl relies on the RSA cryptographic system. For the RSA algorithm, a key(RSAgenkey) consists of two components: a public part that is usually distributed to the individuals withwhom documents are to be exchanged and a private part that must be kept secret by the owner of the key(this private key also includes the public key). In this framework, a document encrypted using a public key(RSApubencrypt) can only be decrypted with the corresponding private key (RSAprivdecrypt).
Moreover, the key pair can also be used for signing documents: the electronic signature of a document iscreated with a private key (msgsign) and the corresponding public key is used to verify this signature(msgverify). Since only the owner of the private key can create the signature, the recipient has aguarantee on the origin of the document.
RSA keys are commonly stored as text files in the OpenSSL PEM standard format, this is also the mostconvenient representation for exchanging key information (RSAsavekey). In addition to this file format,
mmssl can store a key in the form of a Mosel array of integers (RSAloadkey). By using this encoding amodel may embbed keys or retrieve them from any of the usual model data sources.

16.1.2 The mmssl command
The module mmssl is distributed together with a command line tool of the same name as the module:
mmssl. This program helps setting up an initial working environment and performs basic key andcertificate operations directly from a shell (Unix) or command window (Windows). Running the mmssl
program without any arguments will display a short help message, otherwise the following commands
can be used:

Fair Isaac Corporation Proprietary Information

436

Chapter 16: mmssl

setup

Check the configuration directory of mmssl and create it if necessary (see parameter ssl_dir)

genkey keyfile [size]
Generate a new RSA key pair of the specified size (default: 1024) and save it into keyfile.
getpub keyfile keyfilepub
Extract the public key of the private RSA key file keyfile and save it into keyfilepub
chkkey keyfile [keyfile...]Check the validity of the provided key file(s)gencert certfile [prod=value...]Generate an X509 certificate using the provided properties (see x509newcrt for further detail)chkcert certfile [keyfile]
Check the validity of the provided X509 certificate. If an additional private key file is provided, its
compatibility with the certificate is also checked.
list [digest|cipher]
Display the list of supported message digests (digest) or cipher algorithms (cipher). Bothlists are reported with the short form of the command.
Many procedures of the mmssl module require the availability of a configuration directory. To create andpopulate an initial setup it is recommended to run the following command before starting to use themodule:> mmssl setup

Note that the setup procedure is not destructive: if the configuration directory has already been createdthe command will only check its validity, add any missing components and suggest how to proceed incase of incorrect settings.

16.2 Control parameters
Via the getparam function and the setparam procedure it is possible to access the following control
parameters of module mmssl (the reader is reminded that parameters may be spelled with lower or upper
case letters or a mix of both):
https_cacerts

List of trusted certification authorities.

p. 438https_ciphers

Ciphers accepted for SSL communication.

p. 438https_cltcrt

HTTPS client certificate.

p. 438https_cltkey

HTTPS client private key.

p. 439https_srvcrt

HTTPS server certificate.

p. 439https_srvkey

HTTPS server private key.

p. 439https_trustsrv

Whether to trust server certificates.

p. 440ssl_cipher

Default symmetric cipher.

p. 440ssl_digest

Default message digest algorithm.

p. 440ssl_dir

mmssl configuration directory.

p. 441

ssl_privkey

Default user private key.

p. 441

Fair Isaac Corporation Proprietary Information

437

Chapter 16: mmssl

https_cacerts
Description

Location of the file containing the certificates of the trusted certification authorities.

Type

String, read/write

Note

The file identified by this parameter consists of a list of certificates (in PEM format) of trusted
certification authorities (in order to be able to check the validity of servers they have certified)and certificates of servers trusted by the application (typically using self-signed certificatesthat could not be certified by an external authority, see x509newcrt). This file is used when
HTTPS client connections are established to check the identity of the server unless the control
parameter https_trustsrv is set to true. It is also required by servers that perform client
authentication (see option HTTP_CLTAUTH of server configuration http_srvconfig): in thiscase the certificates are used to identify the clients.
When this parameter has not been initialised, the default location
getparam("ssl_dir")+"/ca-bundle.crt" is used. This default file collecting thecertificates of the major certification authorities is installed by the mmssl setup command(Section 16.1.2).

Affects routines

httpget, httppost, httpdel, httpput, httpstartsrv

See also

https_trustsrv

Modulemmssl

https_ciphers
Description

This parameter is used during the algorithm negociation of an HTTPS session initialisation to
select which cryptographic algorithm to use.

Type

String, read/write

Default value"TLSv1.2+HIGH:TLSv1+HIGH:@STRENGTH"

Note

This parameter is employed by both the server and the client in an HTTPS session. Please referto the OpenSSL documentation for a detailed explanation on how to build this selection string.

Affects routines

httpstartsrv, httpget, httppost, httpdel, httpput

Modulemmssl

https_cltcrt
Description

Location of the client certificate (for HTTPS queries).

Type

String, read/write

Note

This parameter specifies the location of the client certificate (that must be in PEM format).
Such a certificate (and its associated private key https_cltkey) is required when sending
HTTPS requests to a server that requires client authentication (see option HTTP_CLTAUTH ofserver configuration http_srvconfig).

Affects routines

httpget, httppost, httpdel, httpput

See also

https_cltkey

Modulemmssl

Fair Isaac Corporation Proprietary Information

438

Chapter 16: mmssl

https_cltkey
Description

Location of the client private key (for HTTPS queries).

Type

String, read/write

Note

This parameter specifies the location of the client private key. Such a key (and its associatedcertificate https_cltcrt) is required when sending HTTPS requests to a server that requiresclient authentication (see option HTTP_CLTAUTH of server configuration http_srvconfig).

Affects routines

httpget, httppost, httpdel, httpput

See also

https_cltcrt

Modulemmssl

https_srvcrt
Description

Location of the server certificate (required by an HTTPS server).

Type

String, read/write

Note

Running an HTTPS server requires a server certificate and its associated private key. Thisparameter defines the location of the certificate file (in PEM format); to create a certificate youcan either use the mmssl command (Section 16.1.2) or the Mosel function x509newcrt. If novalue has been assigned to this parameter the default certificate filegetparam("ssl_dir")+"/server.crt" will be used by the server.

Affects routines

httpstartsrv

See also

https_srvkey

Modulemmssl

https_srvkey
Description

Location of the server private key (required by an HTTPS server).

Type

String, read/write

Note

Running an HTTPS server requires a server certificate and its associated private key. Thisparameter defines the location of the private key file; to create a certificate use either themmssl command (Section 16.1.2) or the function x509newcrt). If no value has been assigned
to this parameter the default key file getparam("ssl_dir")+"/server.key" will be usedby the server.

Affects routines

httpstartsrv

See also

https_srvcrt

Modulemmssl

Fair Isaac Corporation Proprietary Information

439

Chapter 16: mmssl

https_trustsrv
Description

This parameter decides whether the HTTPS client should trust servers without checking theircertificates.

Type

Boolean, read/write

Default value

false

Note

When this parameter is false (the default) whenever an HTTPS connection is opened (via
httpget for instance) the authenticity of the remote server is checked using the list of trusted
certification authorities (as defined by the control parameter https_cacerts) and theoperation is aborted if the verification fails. Changing the value of this parameter disables thistest.

Affects routines

httpget, httppost, httpdel, httpput

See also

https_cacerts

Modulemmssl

ssl_cipher
Description

Name of symmetric cipher to use when no algorithm is specified.

Type

String, read/write

Default value"AES-128-CBC"

Note

This parameter defines the default symmetric cipher used by the crypt I/O driver. The name of acipher consists in up to 3 components separated by the "-" symbol: the algorithm name (e.g.
aes, bf, des), the key size (when the algorithm may be used with different sizes of keys) and theblock chaining mode (e.g. cbc, cfb1, cfb8, ecb, ofb). For instance, "des-ofb" designates DES
with Output Feedback chaining.
Use the command mmssl list cipher to get a full list of the supported cipher names.

Affects routines

I/O driver "crypt:" (Section 16.4.3)

Modulemmssl

ssl_digest
Description

Name of message digest to use when no algorithm is specified.

Type

String, read/write

Default value"SHA256"

Note

This parameter defines the default message digest algorithm used by the crypt I/O driver,
msgdigest, msgsign and msgverify.
Use the command mmssl list digest to get a full list of the supported names.

Affects routines

msgdigest, msgsign, msgverify, I/O driver "crypt:" (Section 16.4.3)

Modulemmssl

Fair Isaac Corporation Proprietary Information

440

Chapter 16: mmssl

ssl_dir
Description

This parameter is the path to the configuration directory of mmssl. Its content is used by boththe mmssl routines and the Mosel core libraries for handling signed and encrypted bim files.

Type

String, read only

Note

By default this location is the path "$HOME/.mmssl" (on Unix systems) or"%USERPROFILE%\.mmssl" (on Windows). Assuming the active restrictions do not preventthe operation, this directory will be created if it does not exist at the time of loading the module.
It is also possible to select a different location by defining the environment variable MOSEL_SSL(in this case, the directory is not automatically created and must be available at loading time).
The configuration directory should contain the following entries:
personal.key

RSA private key of the user: it is used for signing documents to be
published and for decrypting documents that have been encrypted withthe corresponding public key.

personal

RSA public key of the user: to be provided with documents signed withpersonal.key such that recipients can check the signature. The public
key is also used to encrypt documents to be decrypted withpersonal.key.

pubkeyspublic keys repository: this directory is the default location where publickeys are searched for checking the signature of a document.

ca-bundle.crt

trusted certificates file: mmhttp uses this file when checking authenticity
of servers (HTTPS client) or clients (HTTPS server).

server.crt

HTTPS server certificate: this file is required by the HTTPS server ofmmhttp together with the corresponding private key.

server.key

HTTPS server private key: this file is required by the HTTPS server ofmmhttp together with the corresponding certificate.

The program mmssl can be used to create and populate this directory (Section 16.1.2).
Even if Mosel is run under restrictions, mmssl can still access its configuration directory forgetting public keys stored under the pubkeys directory, read the file of trusted certificatesca-bundle.crt and load the private key personal.key to decrypt a document. However,
the module requires explicit read access to use the private key personal.key for signingtasks and load the HTTPS server configuration (files server.key and server.crt).
Modulemmssl

ssl_privkey
Description

Name of the file holding the user’s private key.

Type

String, read/writeNote

The key identified by this parameter is used when a required private key is not provided.
If no value has been assigned to this parameter the default key filegetparam("ssl_dir")+"/personal.key" will be used.

Affects routines

msgsign, x509newcrt, RSAprivdecrypt, BIM file signing and encryption

Modulemmssl

Fair Isaac Corporation Proprietary Information

441

Chapter 16: mmssl

16.3 Procedures and functions
msgdigest

Compute the message digest of a document.

p. 453

msgsignCompute the digital signature of a document.

p. 454

msgverify

Verify the digital signature of a document.

p. 455

RSAfingerprint

Generate the fingerprint of an RSA key.

p. 443

RSAgenkey

Create a new RSA key pair.

p. 444

RSAgetkeysize

Get the size of an RSA key.

p. 445

RSAisprivate

Check whether an RSA key is private.

p. 446

RSAloadkey

Load an RSA key file into memory.

p. 447

RSAprivdecrypt

Decrypt a document using an RSA private key.

p. 449

RSAprivencrypt

Encrypt a document using an RSA private key.

p. 450

RSApubdecrypt

Decrypt a document using an RSA public key.

p. 448

RSApubencrypt

Encrypt a document using an RSA public key.

p. 451

RSAsavekey

Save an RSA key to a file.

p. 452

sslivsize

Get the size of the initialisation vector of a cipher.

p. 456sslkeysize

Get the size of the key required by a symmetric cipher.

p. 457

sslmdsize

Get the size of a message digest.

p. 458sslrandom

Generate a random number.

p. 459sslrandomdata

Generate a random data file.

p. 460x509check

Check the compatibility of a private key with an X509 certificate.

p. 461x509getinfo

Retrieve information stored in an X509 certificate.

p. 462x509newcrt

Create a new self-signed X509 certificate.

p. 463

Fair Isaac Corporation Proprietary Information

442

Chapter 16: mmssl

RSAfingerprint
Purpose
Synopsis

Generate the fingerprint of an RSA key.
function RSAfingerprint(key:array(range) of integer):text
function RSAfingerprint(key:array(range) of integer, mdalg:string):text
function RSAfingerprint(kfile:string):text

Arguments
key
RSA key in the form of an array of integer
kfile File containing the key
mdalg Name of the digest algorithm to use (default: MD5)Return value
Fingerprint as a text string of hexadecimal digits.
Further information
1. By default mmssl uses an MD5 hash of the public part of the RSA key as its fingerprint. Unless anotherdigest algorithm is selected, the return value of this function is therefore a text string of 32 hexadecimal
digits that characterises a given key.
2. The function can process both public and private keys either directly from a key file or from an array ofintegers (as produced by RSAloadkey or RSAgenkey).
Related topics
RSAloadkey
Modulemmssl

Fair Isaac Corporation Proprietary Information

443

Chapter 16: mmssl

RSAgenkey
Purpose
SynopsisCreate a new RSA key pair.
function RSAgenkey(size:integer, key:array(range) of integer):integerfunction RSAgenkey(size:integer, kfile:string):integer

Arguments
size Size of the key to generate (in bits, must be at least 1024)
key
Array to store the new key
kfile File where to save the key
Return value
Number of integers (first syntax) or size of the file (second syntax) or -1 in case of I/O error and -2 if theprovided array is not suitable to store the key.
Further information
1. The generated key can be retrieved either as an array of integers or directly saved into a file. In bothcases, the public key may be extracted using RSAsavekey.
2. The function creates keys of at least 1024 bits: a request for a key of a smaller size will result in a 1024
bits key.
Related topics
RSAloadkey, RSAsavekey
Modulemmssl

Fair Isaac Corporation Proprietary Information444

Chapter 16: mmssl

RSAgetkeysize
Purpose
Synopsis

Get the size of an RSA key.
function RSAgetkeysize(key:array(range) of integer):integerfunction RSAgetkeysize(kfile:string, ispriv:boolean):integer

Arguments
key
RSA key in the form of an array of integer
kfile File containing the key
ispriv Must be true if the key file contains a private key
Return value
Size of the key (number of bits) or -1 in case of an error.
Further information
A return value of -1 indicates an error condition. Typically this will occur if the file cannot be accessed or
the ispriv parameter is not correct (e.g. ispriv is true and the file is a public key).
Related topics
RSAisprivate, RSAloadkey
Modulemmssl

Fair Isaac Corporation Proprietary Information

445

Chapter 16: mmssl

RSAisprivate
Purpose
SynopsisCheck whether an RSA key is private.
function RSAisprivate(key:array(range) of integer):booleanfunction RSAisprivate(kfile:string):boolean

Arguments
key
RSA key in the form of an array of integer
kfile File containing the key
Return value
true if the key is an RSA private key, false otherwise.
Further information
A return value of false does not necessarily indicate that the provided data corresponds to a valid public
key: this value is also returned in the case of an I/O error (e.g. the file does not exist).
Related topics
RSAloadkey
Modulemmssl

Fair Isaac Corporation Proprietary Information

446

Chapter 16: mmssl

RSAloadkey
Purpose
Synopsis

Load an RSA key file into memory.
function RSAloadkey(key:array(range) of integer, kfile:string,
ispriv:boolean):integerfunction RSAloadkey(key:array(range) of integer, kfile:string):integer

Arguments
key
RSA key in the form of an array of integer
kfile File containing the key
ispriv Must be true if the key file contains a private key
Return value
The number of integers saved into the array, or -1 in the case of an I/O error, or -2 if the provided array is
not suitable to store the key.
Further information
If the ispriv parameter is not provided, the function calls first RSAisprivate to determine its value.
Related topics
RSAsavekey
Modulemmssl

Fair Isaac Corporation Proprietary Information

447

Chapter 16: mmssl

RSApubdecrypt
Purpose
Synopsis

Decrypt a document using an RSA public key.
function RSApubdecrypt(kfile:string, src:string, dest:string):integer

Arguments
kfile File containing the public key
src
Name of the file to decryptdst
Name of the file to store the decrypted document
Return value
Length of the resulting document or -1 in the case of an error.
Further information
1. This function is used to decrypt a document that has been encrypted using RSAprivencrypt. It
requires the public part of the key used for encryption.
2. If the key file name does not include an explicit path (e.g."somekey"), it is searched for in the default
public keys directory located at getparam("ssl_dir")+"/pubkeys" instead of the current working
directory. It is required to prefix the key file name with "./" in order to access a key file from the current
directory (e.g."./somekey").
Related topics
RSAprivencrypt, msgverify
Modulemmssl

Fair Isaac Corporation Proprietary Information

448

Chapter 16: mmssl

RSAprivdecrypt
Purpose
Synopsis

Decrypt a document using an RSA private key.
function RSAprivdecrypt(kfile:string, src:string, dest:string):integer

Arguments
kfile File containing the private key
src
Name of the file to decryptdst
Name of the file to store the decrypted document
Return value
Length of the resulting document or -1 in the case of an error.
Further information
This function is used to decrypt a document that has been encrypted using RSApubencrypt. It requires
the private part of the key used for encryption.
Related topics
RSApubencrypt
Modulemmssl

Fair Isaac Corporation Proprietary Information449

Chapter 16: mmssl

RSAprivencrypt
Purpose
Synopsis

Encrypt a document using an RSA private key.
function RSAprivencrypt(kfile:string, src:string, dest:string):integer

Arguments
kfile File containing the private key
src
Name of the file to encryptdst
Name of the file to store the encrypted document
Return value
Length of the resulting document or -1 in the case of an error.
Further information
1. This function can be used to encrypt a document using an RSA private key (with PKCS1 as the padding
algorithm). Decryption will be done using function RSApubdecrypt with the help of the corresponding
RSA public key.
2. The algorithm used here cannot handle documents larger than (RSAgetkeysize(kfile)/8-11)
bytes. It is usually used to generate a digital signature from a message digest.
Related topics
RSApubdecrypt, msgsign
Modulemmssl

Fair Isaac Corporation Proprietary Information450

Chapter 16: mmssl

RSApubencrypt
Purpose
Synopsis

Encrypt a document using an RSA public key.
function RSApubencrypt(kfile:string, src:string, dest:string):integer

Arguments
kfile File containing the public key
src
Name of the file to encryptdst
Name of the file to store the encrypted document
Return value
Length of the resulting document or -1 in the case of an error.
Further information
1. This function can be used to encrypt a document using an RSA public key (with PKCS1 OAEP as the
padding algorithm). Decryption will be done using function RSAprivdecrypt with the help of thecorresponding RSA private key.
2. The algorithm used here cannot handle documents larger than (RSAgetkeysize(kfile)/8-41)
bytes. Typically, encryption of larger documents will be performed with a symmetric cipher (see crypt
I/O driver, Section 16.4.3) using a randomly generated key (that can be produced with sslrandomdata),
in which case the asymmetric cipher is used to encrypt only this random key. The decryption then also
operates in two steps: the key is first decrypted using RSAprivdecrypt (with a private key) and after
this the document can be restored from the decrypted symmetric key.
3. If the key file name does not include an explicit path (e.g."somekey"), it is searched for in the default
public keys directory located at getparam("ssl_dir")+"/pubkeys" instead of the current working
directory. It is required to prefix the key file name with "./" in order to access a key file from the current
directory (e.g."./somekey").
Related topics
RSAprivdecrypt
Modulemmssl

Fair Isaac Corporation Proprietary Information

451

Chapter 16: mmssl

RSAsavekey
Purpose
Synopsis

Save an RSA key to a file.
function RSAsavekey(key:array(range) of integer, kfile:string,
ispriv:boolean):integerfunction RSAsavekey(key:array(range) of integer, kfile:string):integer

Arguments
key
RSA key in the form of an array of integer
kfile Destination fileispriv Save the private key if true, only the public key otherwise
Return value
A positive value on success or -1 in case of error.
ExampleIn the code below a new 2048 bits key is generated and both, private and public parts are saved into
different files:
if RSAgenkey(2048,k)<=0 thenwriteln("Failed to create RSA key")elif RSAsavekey(k,"perso.key",true)<1 or
RSAsavekey(k,"perso",false)<1 thenwriteln("Failed to save key file")
end-ifFurther information
1. This function saves the RSA key that is provided as an array of string into a file in a textual representation.
The ispriv parameter can be used to select which part of the key to export.
2. If the ispriv parameter is not provided, the function will produce a private key file if the key is private
and a public key file otherwise.
Related topics
RSAloadkey, RSAgenkey
Modulemmssl

Fair Isaac Corporation Proprietary Information

452

Chapter 16: mmssl

msgdigest
Purpose
Synopsis

Compute the message digest of a document.
function msgdigest(mdalg:string, fname:string, mdf:string):integerfunction msgdigest(fname:string, mdf:string):integer

Arguments
mdalg Name of the algorithm to use
fname Name of the file to be processed
mdf
File where to store the digest
Return value
Size of the message digest in bytes or -1 if case of error.
ExampleThe following procedure implements the command ’md5sum’:
procedure md5sum(f:string)if msgdigest("md5",f,"mem:dgst")<>16 thenwriteln("Failed to compute digest")
else
fcopy("mem:dgst",F_BINARY,"hex:",F_TEXT)
writeln(" ",f)end-ifend-procedure

Further information
1. This function computes a message digest (MD) using either the algorithm specified by the mdalg
argument or the default algorithm as defined by the control parameter ssl_digest. The produced
output takes the form of a binary file the size of which is returned by the function.
2. The set of supported algorithms includes "md5", "sha", and "sha256". For a full list use the command
mmssl list digest.
Related topics
sslmdsize
Modulemmssl

Fair Isaac Corporation Proprietary Information

453

Chapter 16: mmssl

msgsignPurpose
Synopsis

Compute the digital signature of a document.
function msgsign(mdalg:string, pkey:string, fname:string,
sgf:string):integerfunction msgsign(fname:string, sgf:string):integer

Arguments
mdalg
pkey
fname
sgf

Name of the message digest algorithm to use
Name of the private key file to use for signing
File to sign
File where the signature is to be saved

Return value
Length of the signature or -1 in the case of an error.
Further information
1. This function computes the digital signature of a document by encrypting the message digest of its input
file using an RSA private key. The resulting signature can be verified with the function msgverify usedwith the appropriate public key.
2. If no message digest algorithm is specified, the default algorithm defined by the control parameter
ssl_digest is used. Unless a specific key file is selected, the default private key defined by the control
parameter ssl_privkey or, (if this parameter is not defined) the key undergetparam("ssl_dir")+"/personal.key" is used.
Related topics
msgverify
Modulemmssl

Fair Isaac Corporation Proprietary Information

454

Chapter 16: mmssl

msgverify
Purpose
Synopsis

Verify the digital signature of a document.
function msgverify(mdalg:string, key:string, fname:string,
sgf:string):integerfunction msgverify(key:string, fname:string, sgf:string):integer

Arguments
mdalg
key
fname
sgf

Name of the message digest algorithm to use
Name of the public key file to use
File to verify
Signature used for the verification

Return value
1 if the signature is valid, 0 if the verification failed and -1 in the case of an error.
Further information
1. This function verifies the digital signature of a document by comparing the message digest of the
document with the information obtained by decrypting the provided signature with a given RSA public key.
Typically this signature has been obtained with the function msgsign and the appropriate private key.
2. If no message digest algorithm is specified, the default algorithm defined by the control parameter
ssl_digest is used. Note that the same algorithm has to be used for both signing and verifying.
3. If the key file name does not include an explicit path (e.g."somekey"), it is searched for in the default
public keys directory located at getparam("ssl_dir")+"/pubkeys" instead of the current working
directory. It is required to prefix the key file name with "./" in order to access a key file from the current
directory (e.g."./somekey").
Related topics
msgsign
Modulemmssl

Fair Isaac Corporation Proprietary Information

455

Chapter 16: mmssl

sslivsize
Purpose
Synopsis

Get the size of the initialisation vector (IV) required by a symmetric cipher.
function sslivsize(cipalg:string):integer

Argument
cipalgName of the cipher to consider

Return value
Size of a IV in bytes or -1 if the cipher is not supported.
ExampleThe following statement generates a random IV for the default cipher algorithm:
sslrandomdata("myiv",sslivsize(""))

Further information
Some encryption algorithms require an initialisation vector (IV) in addition to the encryption key. Like thekey, the IV is an array of bytes of a fixed size. This function returns the length (in bytes) of the IV requiredby a given symmetric cipher algorithm. A return value of -1 indicates an unrecognised algorithm name:this property can be used to check whether a given algorithm is available.
Related topics
sslkeysize
Modulemmssl

Fair Isaac Corporation Proprietary Information

456

Chapter 16: mmssl

sslkeysize
Purpose
Synopsis

Get the size of the key required by a symmetric cipher.
function sslkeysize(cipalg:string):integer

Argument
cipalgName of the cipher to consider

Return value
Size of a key in bytes or -1 if the cipher is not supported.
Further information
This function returns the length (in bytes) of an encryption key required by a given symmetric cipher
algorithm. A return value of -1 indicates that the algorithm name has not been recognised: this property
can be used to check whether a given algorithm is available.
Related topics
sslivsize
Modulemmssl

Fair Isaac Corporation Proprietary Information

457

Chapter 16: mmssl

sslmdsize
Purpose
Synopsis

Get the size of a message digest.
function sslmdsize(mdalg:string):integer

Argument
mdalg Algorithm to consider
Return value
Size of the message digest in bytes or -1 if the algorithm is not supported.
Further information
This function returns the length (in bytes) of a digest produced by the requested message digest
algorithm. A return value of -1 indicates that the algorithm name has not been recognised: this property
can be used to check whether a given algorithm is available.
Related topics
msgdigest
Modulemmssl

Fair Isaac Corporation Proprietary Information

458

Chapter 16: mmssl

sslrandom
Purpose
Synopsis

Generate a random number.
function sslrandom:integer

Return value
A randomly generated integer.
Further information
This function returns an integer by combining 4 bytes obtained from a cryptographically strong
pseudo-random generator.
Related topics
sslrandomdata
Modulemmssl

Fair Isaac Corporation Proprietary Information459

Chapter 16: mmssl

sslrandomdata
Purpose
Synopsis

Generate a random data file.
procedure sslrandomdata(fname:string, size:integer)

Arguments
fname Name of the file where to save the generated data
size Number of bytes to generate
ExampleThe following statement generates a random key for the default cipher algorithm:
sslrandomdata("mykey",sslkeysize(""))

Further information
1. This function generates size bytes from a cryptographically strong pseudo-random generator that it
saves in the specified file fname.
2. An IO error will be raised if the destination file cannot be accessed.
Related topics
sslrandom
Modulemmssl

Fair Isaac Corporation Proprietary Information

460

Chapter 16: mmssl

x509check
Purpose
SynopsisCheck the compatibility of a private key with an X509 certificate.
function x509check(x509:string, kfile:string):integer

Arguments
x509 File containing the certificate in PEM format
kfile File containing the private key
Return value
0 if the key is compatible with the certificate, 1 if the key is not compatibe and -1 in the case of an error.
Further information
This function checks whether the public key recorded in the specified certificate corresponds to theprovided private key (the certificate can only be used by the owner of the public key).
Related topics
x509getinfo
Modulemmssl

Fair Isaac Corporation Proprietary Information

461

Chapter 16: mmssl

x509getinfo
Purpose
Synopsis

Retrieve information stored in an X509 certificate.
function x509getinfo(x509:string, info:array(string) of text):integer

Arguments
x509
info

Certificate file in PEM format
Array where to store certificate information

Return value
Number of items stored in the array or -1 in case of error.
ExampleThe example below shows how to display the properties of a certificate:declarations
info:array(S:set of string) of text
end-declarations
if x509getinfo("srv.crt",info)<1 thenwriteln("Failed to load certificate")
else
forall(s in S | exists(info(s)))
writeln("", s, ":", info(s))
end-ifFurther information
This function retrieves some of the information recorded in an X509 certificate. The data is recorded in
the provided array indexed by the labels of the records in the certificate. The possible labels are:Version Format version of the certificate
Serial Serial number
Issuer Issuer of the certificate
Subject Entity associated to the public key stored in the certificate
NotBefore Valid after this date
NotAfter Valid until this date
SgnAlg Algorithm used to sign the certificate
A self-signed certificate (such as those created with x509newcrt) will have identical values for Issuer
and Subject.
Related topics
x509check
Modulemmssl

Fair Isaac Corporation Proprietary Information

462

Chapter 16: mmssl

x509newcrt
Purpose
SynopsisCreate a new self-signed X509 certificate.
function x509newcrt(x509:string, kfile:string, info:array(string) oftext):integer

Arguments
x509 Certificate file to create (PEM format)
kfile File containing the private key
info Array describing the certificate properties
Return value
0 if success or -1 in the case of an error.
ExampleThe following example creates a certificate that is valid for 3 years, using a new RSA key:info("Version"):="1"
info("Serial"):="123456789"
info("Duration"):=text(365⁎3)
info("C"):="FR"info("O"):="My Company"
info("CN"):="www.mycomp.com"
if RSAgenkey(1024,"srv.key")<=0 thenwriteln("Failed to create RSA key")elif x509newcrt("srv.crt","srv.key",info)<>0 thenwriteln("Failed to create certificate")
end-ifFurther information
1. This function creates a self-signed X509 certificate. Such a certificate can be used to run an HTTPS
server but clients of such a server have to disable server certificate verification (see https_trustsrv)
or include this certificate in their trusted certificate file (see https_cacerts).
2. The routine expects an array with indices defining the following entries (a default value applies if the entry
is missing):
Version Format version of the certificate (default: 1)
Serial Serial number (default: 1)
Duration Validity (in days) from the current date (default: 365)CCountry code (default: system country or ’EU’)O
Organisation name (default: anonymous)
CN
Common Name (typically the host name to authenticate, default: localhost)
The entries C, O and CN are used to generate the Issuer and Subject records of the certificate. The
provided key is used both as the certificate key (using the public part of the key) and as the signing key.
Related topics
x509check, x509getinfo
Modulemmssl

Fair Isaac Corporation Proprietary Information

463

Chapter 16: mmssl

16.4 I/O drivers
The mmssl module publishes two drivers for converting binary documents to textual representation and adriver dedicated to symmetric encryption. These drivers have the same behaviour: encryption or
encoding is performed when the driver is used for writing while decryption/decoding is done on a streamthat is open for reading.

16.4.1 Driver base64
base64:[nonl,]filename

This driver can be used to handle documents encoded using the base64 standard. When used in an
output stream, it generates the base64 encoded version of its binary input and in an input stream it
expects a base64 encoded document that it decodes.
For instance the following statement encodes "mydata.bin":fcopy("mydata.bin",F_BINARY,"mmssl.base64:mydata.b64",F_TEXT)

By default a base64 document is split into lines of 76 characters but with the option nonl the entire
document is output as (or read from) a single line.

16.4.2 Driver hex
hex:filename

This driver produces a textual representation of a binary document by replacing each byte by its
hexadecimal representation (e.g. the value 13 is converted to the string "0d").
The following code extract displays the hexadecimal representation of the binary input file "mem:md5":
fcopy("mem:md5",F_BINARY,"mmssl.hex:",F_TEXT)
writeln

16.4.3 Driver crypt
crypt:[[nosalt,][md=a,][cipher=c,][key=kf,][iv=if,]pwd=p|pf]filename

The crypt driver performs encryption (when writing) or decryption (when reading) of its stream using asymmetric cipher (that is, the same key is used for encryption and decryption). Options are provided
enclosed in square brackets, at the least a password has to be provided. For instance, the following
statement encrypts the file "mydata" using the password stored in the file "passfile":
fcopy("mydata","mmssl.crypt:[passfile]mydata.enc")

The password is read from the first line of the password file (that is opened as a text document).
Alternatively, the password may be directly passed through the file name using the pwd= option:
fcopy("mydata","mmssl.crypt:[pwd=mysecret]mydata.enc")

Encryption (or decryption) is performed using the default cipher as defined by the control parameter
ssl_cipher. Another cipher can be selected using the cipher option.
The encryption (or decryption) process requires a key as well as an initialisation vector. The size of thesecomponents depends of the selected cipher and the appropriate data is generated by a key derivation

Fair Isaac Corporation Proprietary Information

464

Chapter 16: mmssl

routine using the provided password as input. This procedure employs a message digest algorithm andmay use some initial value (or salt). Without any specific option the driver relies on the default message
digest algorithm defined by the control parameter ssl_digest and generates a random salt of 8 bytes.
These bytes are then saved at the beginning of the encrypted document such that the decryption process
can retrieve them and regenerate the encryption key and initialisation vector from the provided password.
This default behaviour can be changed using the nosalt option to avoid using a salt and the option md
to select some other message digest algorithm. It is also possible to provide the encryption key and theinitialisation vector via dedicated files using options key and iv. In this case no password has to beprovided.

16.4.4 Driver hmac
hmac:[[md=a,]key=kf|key]filename

The hmac driver computes a HMAC (keyed-hash message authentication code) of its input stream using
the provided key and hash function (the driver does not support reading). Options are provided enclosed
in square brackets, at the least a key has to be provided. For instance, the following statement generates
the HMAC of the file "mydata" using the key stored in the file "keyfile":
fcopy("mydata","mmssl.hmac:[keyfile]mydata.hmac")

The key is read from the key file that is opened as a binary document. Alternatively, the key may bedirectly passed through the file name using the key= option:
fcopy("mydata","mmssl.hmac:[key=mykey]mydata.hmac")

Computation of a HMAC is based on a message digest algorithm, without any specific option the driverrelies on the default message digest algorithm defined by the control parameter ssl_digest otherwise,
the option md can be used to select some other algorithm.

Fair Isaac Corporation Proprietary Information

465

CHAPTER 17

mmsvg
The mmsvg package provides a set procedures which allow users to display graphs of functions,diagrams, networks, various shapes etc. in SVG format. To use this module the following line must be
included in the header of the Mosel model file:uses "mmsvg"

mmsvg requires a webbrowser in order to be able to display graphics. Running a Mosel model that uses
the svgrefresh routine provided by this module opens a window in the default browser that isconfigured on the system. In the absence of a webbrowser, it is still possible to generate graphics andsave them to file via svgsave.

17.1 SVG graph structure
The SVG graph format is an XML format, that is, the elements of a graph are organized in a hierarchicaltree structure. mmsvg structures graphical objects in three levels:
1. SVG graph
2. object group
3. graphical object
Each individual graphical object (line, polygon, text etc.) must be created within an object group. By
default this is the last group that has been added to the graph, but some other object reference can bestated. A default graph object is always present and object groups are created within this default graph.

17.1.1 Object groups
Object groups are identified via a string ID that is specified by the user at their creation, this ID must be
unique. Each object group receives an entry in the legend of the graph. Typically a group serves torepresent a collection of graphical objects that are logically related. The style defined for a group isapplied to all its objects unless it is overwritten by individual settings, meaning that it is usually more
efficient to state generally valid style settings for an entire group instead of repeating them for eachindividual object.
At the creation of a group, optionally a group color can be specified. If no color is given, then a default
color will be selected from a built-in list of color values.
Graphical objects are displayed in the order of definition of object groups, and within each group in theorder of their definition.

Fair Isaac Corporation Proprietary Information

466

Chapter 17: mmsvg

17.1.2 SVG styling
Style definitions can be applied to all levels of SVG elements, to the graph, object groups, or for individual
objects. mmsvg defines a set of property constants but other SVG styling options can equally be used bydirectly stating their name in the svgset[graph]style routines. For a complete list of SVG styleproperties and their permissible values the reader is refered to the SVG property specifications at
https://www.w3.org/TR/SVG/propidx.html.
SVG_COLOR

Default color name (for object groups)

SVG_DECORATION

Text decoration; possible values include ’none’, ’underline’, ’overline’,’line-through’, ’blink’

SVG_FILL

Fill color name

SVG_FILLOPACITY

Fill opacity; values between 0.0 and 1.0

SVG_FONTWhitespace separated list of font settings

SVG_FONTFAMILY

Font family definition; this can be generic families (’serif’, ’sans-serif’,’cursive’, ’fantasy’, ’monospace’) or specific font names

SVG_FONTSIZE

Font size; constants (’xx-small’, ’x-small’, ’small’, ’medium’, ’large’, ’x-large’,’xx-large) or percentage value or length (e.g. in ’em’, ’pt’, ’px’, ’cm’)

SVG_FONTSTYLE

Font style; values ’normal’, ’italic’, ’oblique’

SVG_FONTWEIGHT

Font weight; numbers 100,...900 or constants (’bold’, ’bolder’, ’lighter’,’normal’)SVG_OPACITY

Generic opacity setting; values between 0.0 and 1.0

SVG_STROKE

Color for lines and borders

SVG_STROKEDASH

Line style; comma-separated list of lengths or percentages specifying
lengths of alternating dashes and gaps

SVG_STROKEOPACITY

Stroke opacity, values between 0.0 and 1.0

SVG_STROKEWIDTH

Stroke width; percentage or length

SVG_TEXTANCHOR

Vertical alignment of text; possible values include ’start’, ’middle’, ’end’

Other predefined constants are SVG_CURRENT for the current color and SVG_NONE.
mmsvg defines the following color constants (applicable to the properties SVG_COLOR, SVG_FILL,
SVG_STROKE) that can be used in place of SVG color keywords or color definitions generated via thesvgcolor routine:■

SVG_BLACK, SVG_BLUE, SVG_BROWN, SVG_CYAN, SVG_GOLD, SVG_GRAY, SVG_GREEN,
SVG_LIME, SVG_MAGENTA, SVG_ORANGE, SVG_PINK, SVG_PURPLE, SVG_RED, SVG_SILVER,
SVG_WHITE, SVG_YELLOW

For a full list of SVG color keywords and their definitions please see
https://www.w3.org/TR/SVG/types.html.
The complete set of style properties specified for a graph, object group or individual objects can be
retrieved via the routines svggetstylesheet and svggetgraphstylesheet, for example in order tocopy them to some other object via svgsetstylesheet or svgsetgraphstylesheet respectively.

Fair Isaac Corporation Proprietary Information

467

Chapter 17: mmsvg

17.1.3 Interaction with the graphical display
The command svgrefresh sends the current graph and any additional files that might have been added
to it (see svgaddfile) to the built-in server that handles the coordination with the display and triggers
an update of the graphical display. The end of the model execution will also terminate the display, unlessa call to the routine svgwaitclose is added at the end of the model, in which case the model waits forthe closing of the display window.
Inserting a call to the routine svgpause into a model will pause its execution at this point until the user
hits the ’Continue’ button in the graphical display. Typically, this feature will be used to allow the user timefor visual inspection of the output if a model iteratively generates graphics or updates to a graphic.

17.1.4 Example
The following example shows how to define a few simple graphical objects, saves the resulting graphic toa file and also displays it in a webbrowser. The model waits until the browser is closed.
model "svg example"
uses "mmsvg"! ⁎⁎⁎⁎ Line objects ⁎⁎⁎⁎
svgaddgroup("gl", "Lines")! Group with automatic color
svgaddline(10,10,250,10)! Simple line with default style
PointList:=sum(i in 1..20)[i⁎10,40+round(20⁎random)]svgaddline(PointList)! Polyline
l:=svggetlastobj! Retrieve object reference
svgsetstyle(l, SVG_STROKE, SVG_MAGENTA) ! Change line color
svgsetstyle(l, SVG_STROKEDASH, "1,1")! Dotted line! ⁎⁎⁎⁎ Various shapes ⁎⁎⁎⁎
svgaddgroup("gs", "Shapes", SVG_GREY)! Group with user-defined color
svgaddrectangle(275,25,250,250)! Draw a squaresvgsetstyle(svggetlastobj, SVG_STROKEWIDTH, 3)! Wider bordersvgaddcircle(400,150,75)! Draw a circle
svgsetstyle(svggetlastobj, SVG_FILL, SVG_CURRENT) ! Fill with group color
svgaddpolygon([200,400,200,350,300,300,500,350,600,350,600,400])
svgsetstyle(svggetlastobj, SVG_FILL, SVG_GREEN)! Fill with user color! ⁎⁎⁎⁎ Pie chart ⁎⁎⁎⁎
forall(i in 1..6) svgaddgroup("gp"+i,"Pie"+i)setrandseed(3); ttl:=0.0
forall(i in 1..5) do
rd:=random/6
svgaddpie("gp"+i, 150, 525, 100, ttl, ttl+rd)
ttl+=rdend-dosvgaddpie("gp6", 150, 525, 100, ttl, 1)! Pie slices with auto-colors! ⁎⁎⁎⁎ Text objects ⁎⁎⁎⁎
svgaddgroup("gt", "Text", SVG_BLACK)! Group with user-defined color
svgaddtext(20, 100, "Text with default formatting")
svgaddtext(20, 120, "Formatted text")
t:=svggetlastobj
svgsetstyle(t, SVG_FONTSIZE, "20pt")
svgsetstyle(t, SVG_FONTSTYLE, "italic")
svgsetstyle(t, SVG_FONTWEIGHT, "bold")
svgsetstyle(t, SVG_COLOR, SVG_BLUE)svgaddxmltext(20, 150, 'XML formatted text:<tspan font-size="large"> large</tspan><tspan text-decoration="underline">underlined</tspan><tspan stroke="red"> red</tspan>')svgsetgraphviewbox(0,0,610,635)! Optional: specify graph size

svgsave("svgexpl.svg")! Save graphic to file

Fair Isaac Corporation Proprietary Information

468

Chapter 17: mmsvg

svgrefreshsvgwaitclose
end-model! Display graphic! Wait until window is closed

Figure 17.1: Graphical output produced by the example

17.2 Control parameters
The following parameters are defined by mmsvg:
MMSVGDISPLAY

Enable/disable rendering.

p. 469MMSVGTGZ

Location of the mmsvg.tgz archive.

p. 470MMSVGDISPLAY
Description

When this parameter is set to true (the default) the first call to svgrefresh starts a web
browser for displaying the current graph. Changing the value of this parameter disables
rendering: after a warning message is reported calls to svgrefresh have no effect and thefunction svgclosing always returns true. Note that setting the environment variable
MMSVGDISPLAY to a non empty string has the same effect as changing this control parameter.

Type

Boolean, read/write

Valuestrue Enable rendering.
false Disable rendering.

Default valuetrue

Affects routines

svgrefresh, svgclosing.

Modulemmsvg

Fair Isaac Corporation Proprietary Information

469

Chapter 17: mmsvg

MMSVGTGZ
Description

The function svgrefresh requires the archive mmsvg.tgz for its processing. By default thisfile is expected to be located in the same directory as the module mmsystem. This parameter
makes it possible to specify an alternate location.

Type

String, read/write

Default value""

Affects routines

svgrefresh.

Modulemmsvg

17.3 Procedures and Functions
svgaddarrow

Add an arrow to an object group.

p. 473

svgaddcircle

Add a circle to an object group.

p. 474

svgaddellipse

Add an ellipse to an object group.

p. 475

svgaddfile

Add a file to a graph.

p. 476

svgaddgroup

Add a new object group to the user graph.

p. 472

svgaddimage

Add an image to an object group.

p. 477

svgaddline

Add a line or polyline to an object group.

p. 478

svgaddpie

Add a pie slice.

p. 479svgaddpoint

Add a small square to mark a point.

p. 480svgaddpolygon

Add a polygon to an object group.

p. 481

svgaddrectangle

Add a rectangle to an object group.

p. 482

svgaddtext

Add a text to an object group.

p. 483

svgaddxmltext

Add an XML formatted text to an object group.

p. 484

svgclosing

Test whether the display window is being closed.

p. 485

svgcolor

Compute a composite color.

p. 486

svgdelobj

Delete the specified graphical object.

p. 487

svgerase

Erase all object groups or the contents of a specific group.

p. 488svggetgraphstyle

Retrieve a style property of a graph.

p. 489Retrieve the style definitions of a graph.

p. 490svggetgraphviewbox

Retrieve the viewbox definition of a graph.

p. 491

svggetlastobj

Retrieve the identifier of a graphical object.

p. 492

svggetstyle

Retrieve a style property of a graphical object or object group.

p. 493

svggetstylesheet

Retrieve style definitions of a graphical object or object group.

p. 494

svgpause

Suspend the execution of a model.

p. 495svggetgraphstylesheet

Fair Isaac Corporation Proprietary Information

470

Chapter 17: mmsvg

svgrefresh

Refresh the graph display.

p. 496

svgsave

Save a graph to a file.

p. 497

svgsetgraphlabels

Set x- and y-axis labels for a graph.

p. 498

svgsetgraphpointsize

Set point size property for a graph.

p. 499svgsetgraphscale

Set scaling value for a graph.

p. 500svgsetgraphstyle

Set a style property of a graph.

p. 501

svgsetgraphstylesheet

Set the style definitions for a graph.

p. 502

svgsetgraphviewbox

Set the visible area for a user graph.

p. 503

svgsetreffreq

Set the refresh frequency for a graph.

p. 504

svgsetstyle

Set a style property for a graphical object or object group.

p. 505

svgsetstylesheet

Set the style for a graphical object or object group.

p. 506

svgshowgraphaxes

Force displaying of graph axes.

p. 507

svgwaitclose

Delay model termination.

p. 508Fair Isaac Corporation Proprietary Information

471

Chapter 17: mmsvg

svgaddgroup
Purpose
Synopsis

Add a new object group to the user graph.
procedure svgaddgroup(gid: string, desc: text, color: text)
procedure svgaddgroup(gid: string, desc: text)

Arguments
gid
Object group ID (must be unique within a graph).
desc A text that will appear in the legend.
color A color specification obtained using svgcolor or one of the predefined constants (see list in
section 17.1.2).
ExampleThe following adds two groups ’g1’ and ’g2’ to the user graph:svgaddgroup("g1", "sine", SVG_RED)
svgaddgroup("g2", "random numbers")! User-specified group color! Automatically selected color

Further information
1. A group is identified by its ID whereas the ’desc’ serves as text for the legend of the graphic. A groupcontains any number of individual objects (points, lines, arrows, texts etc.) which were added to it.
2. An empty string for the ’desc’ attribute indicates that the group is not to be included in the legend.
3. If no color is specified at the creation of a group it will be assigned a default color from a built-in list. Thissetting can be overwritten for individual objects within the group. Note that any style settings that arecommon to a large number of objects within a group should preferrably be specified for the group rather
than for the individual objects.
Related topics
svgsetstyle.

Fair Isaac Corporation Proprietary Information

472

Chapter 17: mmsvg

svgaddarrow
Purpose
Synopsis

Add an arrow to an object group.
procedure svgaddarrow(gid: string, x1: real, y1: real, x2: real, y2: real)procedure svgaddarrow(x1: real, y1: real, x2: real, y2: real)

Arguments
gid
x1
y1
x2
y2
ExampleObject group ID.
The x coordinate of the first point.
The y coordinate of the first point.
The x coordinate of the second point.
The y coordinate of the second point.

The following adds two arrows to a group named ‘thetime’. The arrows suggest three o’clock:svgaddgroup("arrows", "thetime", SVG_BLACK)
svgaddarrow("arrows", 0, 0, 0, 5)
svgaddarrow(0, 0, 4.5, 0)
svgsetgraphviewbox(-5, -6, 10, 12)

Further information
1. The arrow connects the two points whose coordinates are given as parameters, pointing to the secondone.
2. If no group ID is specified, the arrow is added to the last group that has been created.

Fair Isaac Corporation Proprietary Information

473

Chapter 17: mmsvg

svgaddcircle
Purpose
Synopsis

Add a circle to an object group.
procedure svgaddcircle(gid: string, x: real, y: real, r: real)procedure svgaddcircle(x: real, y: real, r: real)

Argumentsgidxyr
ExampleObject group ID.
The x coordinate of the center point.
The y coordinate of the center point.
The length of the radius of the circle.

The following code draws a filled, semi-transparent circle centered at the origin with a radius of 10.
declarations
circ: integer
end-declarations
svgaddcircle(0, 0, 10)
circ:=svggetlastobj
svgsetstyle(circ, SVG_FILL, SVG_CYAN)
svgsetstyle(circ, SVG_OPACITY, 0.5)

Further information
If no group ID is specified, the circle is added to the last group that has been created.

Fair Isaac Corporation Proprietary Information

474

Chapter 17: mmsvg

svgaddellipse
Purpose
Synopsis

Add an ellipse to an object group.
procedure svgaddellipse(gid: string, x: real, y: real, rx: real, ry: real)procedure svgaddellipse(x: real, y: real, rx: real, ry: real)

Arguments
gid
x
y
rx
ry
ExampleObject group ID.
The x coordinate of the center point of the ellipse.
The y coordinate of the center point of the ellipse.
The horizontal radius.
The vertical radius.

The following code draws a very "flat" ellipse centered at the origin filled with the group color.
svgaddellipse(0,0,5,0.5)
svgsetstyle(svggetlastobj, SVG_FILL, SVG_CURRENT)

Further information
If no group ID is specified, the ellipse is added to the last group that has been created.

Fair Isaac Corporation Proprietary Information

475

Chapter 17: mmsvg

svgaddfile
Purpose
Synopsis

Add a file to a graph.
procedure svgaddfile(fname: string, fid: string)Arguments
fname Filename (including path) of the file to be included.
fid
Name for the file used within the SVG graph.
ExampleThe following code adds an image file to the current graph and displays it in an area with corner points atthe coordinates (100,100) and (250,250).
svgaddfile("./someimage.png", "myimg.png")
svgaddimage("myimg.png", 100, 100, 150, 150)

Further information
1. This routine is typically used in combination with svgaddimage to associate some external file with thegraph.
2. Using an empty file name fname will remove the corresponding fid from the file database.
Related topics
svgaddimage.

Fair Isaac Corporation Proprietary Information

476

Chapter 17: mmsvg

svgaddimage
Purpose
Synopsis

Add an image to an object group.
procedure svgaddimage(gid: string, fid: text, x: real, y: real, w: real, h:
real)
procedure svgaddimage(fid: text, x: real, y: real, w: real, h: real)

Arguments
gid
fid
x
y
w
h
ExampleObject group ID.
Name for the file used within the SVG graph.
The x coordinate of the lower left corner.
The y coordinate of the lower left corner.
The width of the image.
The height of the image.

The following code adds an image file to the current graph and displays it 3 times at different positions (3squares forming a row).
svgaddfile("./someimage.png", "myimg.png")
forall(i in 1..3)
svgaddimage("myimg.png", 100⁎i, 100, 100, 100)

Further information
1. Any external file to be displayed within a graph needs to be associated with the graph via a call to
svgaddfile.
2. If no group ID is specified, the image is added to the last group that has been created.
Related topics
svgaddfile.

Fair Isaac Corporation Proprietary Information

477

Chapter 17: mmsvg

svgaddline
Purpose
Synopsis

Add a line or polyline to an object group.
procedure svgaddline(gid: string, x1: real, y1: real, x2: real, y2: real)procedure svgaddline(x1: real, y1: real, x2: real, y2: real)procedure svgaddline(gid: string, points: list of integer|real)procedure svgaddline(points: list of integer|real)

Arguments
gid
x1
y1
x2
y2
pointsExampleObject group ID.
The x coordinate of the first point.
The y coordinate of the first point.
The x coordinate of the second point.
The y coordinate of the second point.
A list of points.

The following code draws the outline of a triangle, given the correct aspect ratio of the user graph.
svgaddgroup("t", "triangle", SVG_ORANGE)
svgaddline([-2, -2, 0, 2, 2, -2, -2, -2)])
svgsetgraphviewbox(-5, -5, 10, 10)
If the shape is to be filled (here: using the group color), you need to use polygon drawing instead of apolyline:
svgaddpolygon([-2, -2, 0, 2, 2, -2)])
svgsetstyel(svggetlastobj, SVG_FILL, SVG_CURRENT)

Further information
1. The line connects the two points whose coordinates are given as parameters or the points contained in
the specified list in their order of appearance in the list.
2. If no group ID is specified, the line is added to the last group that has been created.
Related topics
svgaddpolygon.

Fair Isaac Corporation Proprietary Information

478

Chapter 17: mmsvg

svgaddpie
Purpose
Synopsis

Add a filled pie slice at the given coordinates.
procedure svgaddpie(gid: string, x: real, y: real, r: real, p1: real, p2:
real)procedure svgaddpie(x: real, y: real, r: real, p1: real, p2: real)

Arguments
gid
x
y
r
p1
p2
ExampleObject group ID.
The x coordinate of the center point.
The y coordinate of the center point.
Radius (side length of the pie slice).
Start position on the circle (percentage).
End position on the circle (percentage).

This code draws a pie chart with 5 slices of 20% width each around the center point (150,150) with aradius of 100.
forall(i in 1..5) do
svgaddgroup("gp"+i, "Pie"+i)
svgaddpie(150, 150, 100, (i-1)⁎0.2, i⁎0.2)
end-doFurther information
1. Pie slices are by default filled with the group color. If they are not to be filled with any color specify value
SVG_NONE for the style property SVG_FILL.
2. If no group ID is specified, the pie slice is added to the last group that has been created.

Fair Isaac Corporation Proprietary Information

479

Chapter 17: mmsvg

svgaddpoint
Purpose
Synopsis

Add a small square to mark a point at the given coordinates.
procedure svgaddpoint(gid: string, x: real, y: real)procedure svgaddpoint(x: real, y: real)

Argumentsgidxy
ExampleObject group ID.
The x coordinate of the point.
The y coordinate of the point.

This code plots 100 random points:
svgaddgroup("cloud", "Random points", SVG_YELLOW)
svgsetgraphviewbox(-5, -5, 10, 10)
forall(i in 1..100)
svgaddpoint("cloud", -2+4⁎random, -2+4⁎random)

Further information
If no group ID is specified, the point is added to the last group that has been created.
Related topics
svgsetgraphpointsize.

Fair Isaac Corporation Proprietary Information

480

Chapter 17: mmsvg

svgaddpolygon
Purpose
Synopsis

Add a polygon to an object group.
procedure svgaddpolygon(gid: string, points: list of integer|real)procedure svgaddpolygon(points: list of integer|real)

Arguments
gid
Object group ID.
points A list of points.
ExampleThe following code draws two semi-transparent, partially overlapping polygons, the first is filled with thegroup color, the second with a different color:svgaddgroup("p", "Polygons")
svgsetstyle(SVG_OPACITY, 0.5)
svgsetstyle(SVG_FILL, SVG_CURRENT)
svgaddpolygon([-2, -2, 0, 2, 2, -2)])
svgaddpolygon([-1, -2, 1, 2, 3, -2)])
svgsetstyle(svggetlastobj, SVG_FILL, SVG_GREY)

Further information
1. The last point in the list of points is automatically connected to the first point in the list to form a closed
shape.
2. If no group ID is specified, the polygon is added to the last group that has been created.
Related topics
svgaddline.

Fair Isaac Corporation Proprietary Information

481

Chapter 17: mmsvg

svgaddrectangle
Purpose
Synopsis

Add a rectangle to an object group.
procedure svgaddrectangle(gid: string, x: real, y: real, w: real, h: real)

Arguments
gid
x
y
w
h
ExampleObject group ID.
The x coordinate of the lower left corner.
The y coordinate of the lower left corner.
The width of the rectangle.
The height of the rectangle.

The following code draws a rectangle filled with the group color covering an area 10 units long and 1 unit
high starting at the origin.
svgaddrectangle(0,0,10,1)
svgsetstyle(svggetlastobj, SVG_FILL, SVG_CURRENT

Further information
If no group ID is specified, the rectangle is added to the last group that has been created.

Fair Isaac Corporation Proprietary Information

482

Chapter 17: mmsvg

svgaddtext
Purpose
Synopsis

Add a text to an object group.
procedure svgaddtext(gid: string, x: real, y: real, msg: text)
procedure svgaddtext(x: real, y: real, msg: text)

Arguments
gid
x
y
text
ExampleObject group ID.
The x coordinate of the point.
The y coordinate of the point.
The text that will be displayed at the given point.

This code complements the time graph with a dial:! This should complement the example for svgaddarrowforall(i in 1..12)
svgaddtext(4.8⁎cos(1.57-6.28⁎i/12), 5⁎sin(1.57-6.28⁎i/12), text(i))

Further information
1. By default the specified point denotes the lower left corner of the text display area; the vertical alignment
can be changed via the style option SVG_ANCHOR (values ’start’, ’middle’, or ’end’).
2. If no group ID is specified, the text is added to the last group that has been created.
Related topics
svgaddxmltext.

Fair Isaac Corporation Proprietary Information

483

Chapter 17: mmsvg

svgaddxmltext
Purpose
Synopsis

Add an XML formatted text to an object group.
procedure svgaddxmltext(gid: string, x: real, y: real, msg: text)
procedure svgaddxmltext(x: real, y: real, msg: text)

Arguments
gid
x
y
text
ExampleObject group ID.
The x coordinate of the point.
The y coordinate of the point.
The text that will be displayed at the given point.

This code displays some text with individual formatting on different words:
svgaddxmltext(20, 150, 'XML formatted text:<tspan font-size="20px">large</tspan>,<tspan font-style="oblique">oblique</tspan>,<tspan font-weight="bold">bold</tspan>,<tspan text-decoration="underline">underlined</tspan>,<tspan stroke="red">red</tspan>')Further information
1. By default the specified point denotes the lower left corner of the text display area; the vertical alignment
can be changed via the style option SVG_ANCHOR (values ’start’, ’middle’, or ’end’).
2. If no group ID is specified, the text is added to the last group that has been created.
Related topics
svgaddtext.

Fair Isaac Corporation Proprietary Information

484

Chapter 17: mmsvg

svgclosing
Purpose
Synopsis

Test whether the display window is being closed.
function svgclosing:boolean

Return value’false’ until the display window is about to be closed, ’true’ afterwards.
ExampleThe following loop uses the browser window opening status as stopping criterion.
solct:= 0
svgrefresh! Start graph display before svgclosing test
while (solct<NBSOL and not svgclosing) do
solct+=1
draw_solution(solct) ! Draws a graph calling svgrefresh and svgpause
end-dosvgwaitclose

Further information
This function can be used to intercept the event of the display window being closed in order to adapt the
behaviour of the model execution (e.g. to interrupt a loop with repeated graphical displays or an
optimization solver run).
Related topics
svgwaitclose.

Fair Isaac Corporation Proprietary Information

485

Chapter 17: mmsvg

svgcolor
Purpose
Synopsis

Compute a composite color by combining amounts of red, green and blue.
function svgcolor(red, green, blue: integer): text
function svgcolor(red, green, blue: real): text
function svgcolor(red, green, blue: text): text

Arguments
red

Amount of red (integer between 0 and 255, real between 0 and 1, or hexadecimal value between
0 and FF).
green Amount of green (integer between 0 and 255, real between 0 and 1, or hexadecimal value
between 0 and FF).
blue Amount of blue (integer between 0 and 255, real between 0 and 1, or hexadecimal value between
0 and FF).

Return value
Hexadecimal representation of the composite color.
ExampleThe following definitions mix red with green and store the result in a variable. All three forms result in thesame color.
declarations
a_color: text
end-declarations
a_color:=svgcolor(255,255,0)a_color:=svgcolor(1.0,1.0,0.0)
a_color:=svgcolor("FF","FF","0")Further information
If the color component values are out of range, mmsvg will raise an I/O error.

Fair Isaac Corporation Proprietary Information

486

Chapter 17: mmsvg

svgdelobj
Purpose
Synopsis

Delete the specified graphical object.
procedure svgdelobj(obj: integer)

Argument
obj

Object ID as returned by svggetlastobj.

Further information
This procedure serves for deleting a specific graphical object. Use svgerase to delete the wholecontents of an object group or all groups.
Related topics
svgerase, svggetlastobj.

Fair Isaac Corporation Proprietary Information

487

Chapter 17: mmsvg

svgerase
Purpose
Synopsis

Erase all object groups or the contents of a specific group.
procedure svgerase
procedure svgerase(gid: string)Argument
gid

Object group ID.

Further information
1. This procedure can be used together with svgpause to explore a number of different user graphversions during the execution of a Mosel model.
2. If a group ID is specified only the objects within this group are removed without deleting the groupdefinition itself.
3. Use svgdelobj to delete individual graphical objects.
Related topics
svgdelobj, svgpause.

Fair Isaac Corporation Proprietary Information

488

Chapter 17: mmsvg

svggetgraphstylePurpose
Synopsis

Retrieve a style property of a graph.
function svggetgraphstyle(prop: string):text

Argument
prop

The desired property (mmsvg constant or SVG property name).

Return value
Value of the property or empty string.
ExampleThis code retrieves the font family defined for a graph and applies it to an object group.
svgaddgroup("g", "A group")svgsetstyle("g", SVG_FONTFAMILY, svggetgraphstyle("b", SVG_FONTFAMILY))

Further information
This function can be used to retrieve a style property of a graph in order to apply it to some object orgroup of objects. Use svggetgraphstylesheet to retrieve the whole set of style properties of a graph.
Related topics
svggetstyle, svgsetstyle, svgsetgraphstyle, svggetgraphstylesheet,svgsetgraphstylesheet, svggetstylesheet, svgsetstylesheet.

Fair Isaac Corporation Proprietary Information489

Chapter 17: mmsvg

svggetgraphstylesheet
Purpose
Synopsis

Retrieve the style definitions of a graph.
function svggetgraphstylesheet:array of text

Return value
An array of style properties (’stylesheet’) with their respective values.
ExampleThis code retrieves the style properties of a graph and applies them to an object group.
svgaddgroup("a", "A group")svgsetstylesheet("a", svggetgraphstylesheet)

Further information
This function can be used to retrieve the set of style properties (’stylesheet’) of a graph in order to apply it
to some object or group of objects. Use svggetgraphstyle to retrieve individual style properties of agraph.
Related topics
svggetstyle, svgsetstyle, svggetgraphstyle, svgsetgraphstyle,svgsetgraphstylesheet, svggetstylesheet, svgsetstylesheet.

Fair Isaac Corporation Proprietary Information

490

Chapter 17: mmsvg

svggetgraphviewbox
Purpose
Synopsis

Retrieve the viewbox definition of a graph.
function svggetgraphviewbox:svgbox

Return value
An object of type ’svgbox’ that holds the view box defined for the graph.
ExampleThis code displays the viewbox defined for a graph.
writeln(svggetgraphviewbox)

Further information
This function can be used to retrieve the viewbox (=visible area) defined for a graph.
Related topics
svgsetgraphviewbox.

Fair Isaac Corporation Proprietary Information

491

Chapter 17: mmsvg

svggetlastobj
Purpose
Synopsis

Retrieve the identifier of a graphical object.
function svggetlastobj:integer

Return value
Integer identifier of the last graphical object that has been added.
ExampleThis code retrieves an object identifier to apply several style settings.
declarations
t: integer
end-declarations
svgaddgroup("gt", "Text")
svgaddtext(20, 120, "Formatted text")
t:=svggetlastobj
svgsetstyle(t, SVG_COLOR, SVG_GREEN)
svgsetstyle(t, SVG_FONTSTYLE, "italic")

Further information
This function serves for retrieving the identifier of a graphical object, in particular in order to apply stylesettings to this object.
Related topics
svgsetstyle.

Fair Isaac Corporation Proprietary Information

492

Chapter 17: mmsvg

svggetstylePurpose
Synopsis

Retrieve a style property of a graphical object or object group.
function svggetstyle(gid: string, prop: string):text
function svggetstyle(prop: string):text
function svggetstyle(obj: integer, prop: string):text

Arguments
gid
obj
prop

Object group ID.
Object ID.
The desired property (mmsvg constant or SVG property name).

Return value
Value of the property or empty string.
ExampleThis code retrieves the color of a group and applies it to an object belonging to another group.
svgaddgroup("a", "Group A")
svgaddgroup("b", "Group B")
svgaddtext("a", 20, 120, "Formatted text")
svgsetstyle(svggetlastobj, SVG_COLOR, svggetstyle("b", SVG_COLOR))

Further information
This function can be used to retrieve a style property of some object in order to apply it to some otherobject or group of objects. Use svggetstylesheet to retrieve the whole set of style properties of an
object or group of objects.
Related topics
svgsetstyle, svggetgraphstylesheet, svgsetgraphstylesheet, svggetstylesheet,svgsetstylesheet.

Fair Isaac Corporation Proprietary Information

493

Chapter 17: mmsvg

svggetstylesheet
Purpose
Synopsis

Retrieve style definitions of a graphical object or object group.
function svggetstylesheet(gid: string):array of text
function svggetstylesheet:array of text
function svggetstylesheet(obj: integer):array of text

Arguments
gid
obj

Object group ID.
Object ID.

Return value
An array of style properties (’stylesheet’) with their respective values.
ExampleThis code retrieves the style properties of a group and applies them to an object belonging to anothergroup.
svgaddgroup("a", "Group A")
svgaddgroup("b", "Group B")
svgaddtext("a", 20, 120, "Formatted text")
svgsetstylesheet(svggetlastobj, svggetstylesheet("b"))Further information
This function can be used to retrieve the set of style properties (’stylesheet’) of some object in order toapply it to some other object or group of objects. Use svggetstyle to retrieve individual styleproperties of an object or group of objects.
Related topics
svggetstyle, svgsetstyle, svggetgraphstylesheet, svgsetgraphstylesheet,svgsetstylesheet.

Fair Isaac Corporation Proprietary Information

494

Chapter 17: mmsvg

svgpause
Purpose
Synopsis

Suspend the execution of a Mosel model at the line where the call occurs.
procedure svgpause

Further information
While the model run is suspended, the displayed graph or other model output can be inspected. This
allows for visualization of intermediate states or solutions. To continue, click on the ’Continue’ button in
the display window.

Fair Isaac Corporation Proprietary Information

495

Chapter 17: mmsvg

svgrefresh
Purpose
Synopsis
ExampleRefresh the graph display.
procedure svgrefreshThis code defines some objects and draws the graph, it then adds further objects and updates te display..
svgaddgroup("a", "Group A")
svgaddtext(0, 0, "Some text")
svgrefresh! Display the graphsvgaddgroup("b", "Group B")
svgaddtext("a", 0, 20, "Some more text")
svgaddcircle(10,10, 45)
svgrefresh! Update the display

Further information
svgrefresh needs to be called in order to trigger the display of a graph. The subroutine can be called
repeatedly in order to update the display—each time it will be completely redrawn. The refresh frequency
can be controlled via svgsetreffreq.
Related topics
svgsetreffreq.

Fair Isaac Corporation Proprietary Information

496

Chapter 17: mmsvg

svgsave
Purpose
Synopsis

Save a graph to a file.
procedure svgsave(fname: string)Argument
fname The (extended) filename to be used as output destination.
ExampleThis code saves a graph to the file ’mygraph.svg’ in the model working directory.
svgaddgroup("a", "Group A")
svgaddrectangle(20, 120, 200, 250)
svgsave("mygraph.svg")

Further information
This procedure can be used independently of the graphical display in order to produce output in SVG
format of the current graph definition.

Fair Isaac Corporation Proprietary Information

497

Chapter 17: mmsvg

svgsetgraphlabels
Purpose
SynopsisSet x- and y-axis labels for a graph.
procedure svgsetgraphlabels(xlabel: text, ylabel: text)

Arguments
xlabelylabelExampleLabel text for the x-axis.
Label text for the y-axis.

The following line sets the x-axis label text to ’Time in sec’ and the y-axis label to ’Solution value’.
svgsetgraphlabels("Time in sec", "Solution value")

Further information
1. By default (no labels specified or empty strings) no label text is displayed.
2. The axes are displayed only if a label is defined (for x or y axis) unless svgshowgraphaxes has been
used.
Related topics
svgsetgraphscale, svgsetgraphpointsize, svgsetgraphviewbox, svgshowgraphaxes.

Fair Isaac Corporation Proprietary Information

498

Chapter 17: mmsvg

svgsetgraphpointsize
Purpose
SynopsisSet point size property for a graph.
procedure svgsetgraphpointsize(val: real)

Argumentval
ExampleThe new value for the point size.

This code shows how to modify graph scaling properties.
svgsetgraphpointsize(0.5)
svgsetgraphscale(10)Further information
This routine is likely to be used in combination with svgsetgraphscale in order to resize a graph.
Related topics
svgsetgraphscale, svggetgraphstyle, svgsetgraphstyle, svggetgraphstylesheet,svgsetgraphstylesheet.

Fair Isaac Corporation Proprietary Information

499

Chapter 17: mmsvg

svgsetgraphscale
Purpose
Synopsis

Set scaling value for a graph.
procedure svgsetgraphscale(val: real)

Argumentval
ExampleThe new scaling value.

This code shows how to modify graph scaling properties.
svgsetgraphpointsize(0.5)
svgsetgraphscale(10)Further information
This routine is likely to be used in combination with svgsetgraphpointsize in order to resize a graphfor display.
Related topics
svgsetgraphpointsize, svggetgraphstyle, svgsetgraphstyle, svggetgraphstylesheet,svgsetgraphstylesheet.

Fair Isaac Corporation Proprietary Information

500

Chapter 17: mmsvg

svgsetgraphstylePurpose
Synopsis

Set a style property of a graph.
procedure svgsetgraphstyle(prop: string, val: text|real)

Arguments
prop
val

The desired property (mmsvg constant or SVG property name).
The new value for the property (usually a text, but properties like SVG_OPACITY or
SVG_STROKEWIDTH also accept numerical values).

Return value
Value of the property or empty string.
ExampleThis code retrieves the font family defined for a group and applies it to the entire graph.
svgaddgroup("g", "A group")svgsetgraphstyle(SVG_FONTFAMILY, svggetstyle("g", SVG_FONTFAMILY))

Further information
This procedure can be used to define a style property of a graph. Use svgsetgraphstylesheet todefine the whole set of style properties of a graph.
Related topics
svggetstyle, svgsetstyle, svggetgraphstyle, svggetgraphstylesheet,svgsetgraphstylesheet, svggetstylesheet, svgsetstylesheet.

Fair Isaac Corporation Proprietary Information

501

Chapter 17: mmsvg

svgsetgraphstylesheet
Purpose
Synopsis

Set the style definitions for a graph.
procedure svgsetgraphstylesheet(stsh: array (svgstyleattrs) of text)

Argument
stsh
ExampleStyle definition.

This code retrieves the style properties of a group and applies them to the entire graph.
svgaddgroup("a", "A group")svgsetgraphstylesheet(svggetstylesheet("a"))Further information
This procedure can be used to define the set of style properties (’stylesheet’) of a graph. Use
svgsetgraphstyle to define individual style properties of a graph.
Related topics
svggetstyle, svgsetstyle, svggetgraphstyle, svgsetgraphstyle,svggetgraphstylesheet, svggetstylesheet, svgsetstylesheet.

Fair Isaac Corporation Proprietary Information502

Chapter 17: mmsvg

svgsetgraphviewbox
Purpose
Synopsis

Set the visible area for a user graph.
procedure svgsetgraphviewbox(x: real, y: real, w: real, h: real)procedure svgsetgraphviewbox(box: svgbox)

Arguments
x
y
w
h
box

The x coordinate of the lower left corner.
The y coordinate of the lower left corner.
The width of the viewbox.
The height of the viewbox.
Viewbox specification as returned by svggetgraphviewbox.

Further information
1. The viewable area is determined by its lower left corner, its width and height.
2. mmsvg automatically determines a viewbox (enclosing all specified coordinates) that can be retrieved
with svggetgraphviewbox.
Related topics
svggetgraphviewbox, svgsetgraphlabels, svgsetgraphscale.

Fair Isaac Corporation Proprietary Information503

Chapter 17: mmsvg

svgsetreffreq
Purpose
Synopsis

Set the refresh frequency for a graph.
procedure svgsetreffreq(val: real)

Argumentval

The new refresh frequency (maximum number of refreshs per second).

Further information
The refresh frequency indicates how often individual calls to svgrefresh are posted to the display. If
several refresh occur during the specified time span, only the last one is executed.
Related topics
svgrefresh.

Fair Isaac Corporation Proprietary Information504

Chapter 17: mmsvg

svgsetstylePurpose
Synopsis

Set a style property for a graphical object or object group.
procedure svgsetstyle(gid: string, prop: string, val: text|real)procedure svgsetstyle(prop: string, val: text|real)procedure svgsetstyle(obj: integer, prop: string, val: text|real)

Arguments
gid
obj
prop
val
ExampleObject group ID.
Object ID.
The desired property (mmsvg constant or SVG property name).
The new value for the property (usually a text, but properties like SVG_OPACITY or
SVG_STROKEWIDTH also accept numerical values).

This code retrieves the color of a group and applies it to an object belonging to another group.
svgaddgroup("a", "Group A")
svgaddgroup("b", "Group B")
svgaddtext("a", 20, 120, "Formatted text")
svgsetstyle(svggetlastobj, SVG_COLOR, svggetstyle("b", SVG_COLOR))

Further information
This procedure can be used to define a style property of some object or group of objects. Use
svgsetstylesheet to redefine the whole set of style properties of an object or group of objects.
Related topics
svggetstyle, svggetgraphstylesheet, svgsetgraphstylesheet, svggetstylesheet,svgsetstylesheet.

Fair Isaac Corporation Proprietary Information505

Chapter 17: mmsvg

svgsetstylesheet
Purpose
Synopsis

Set the style for a graphical object or object group.
procedure svgsetstylesheet(gid: string, stsh: array (svgstyleattrs) of
text)
procedure svgsetstylesheet(stsh: array(svgstyleattrs) of text)
procedure svgsetstylesheet(obj: integer, stsh: array(svgstyleattrs) of
text)

Arguments
gid
obj
stsh
ExampleObject group ID.
Object ID.
Style definition.

This code retrieves the style properties of a group and applies them to an object belonging to anothergroup.
svgaddgroup("a", "Group A")
svgaddgroup("b", "Group B")
svgaddtext("a", 20, 120, "Formatted text")
svgsetstylesheet(svggetlastobj, svggetstylesheet("b"))Further information
This procedure can be used to define a set of style properties (’stylesheet’) of some object or group of
objects. Use svgsetstyle to modify individual style properties of an object or group of objects.
Related topics
svggetstyle, svgsetstyle, svggetgraphstylesheet, svgsetgraphstylesheet,svgsetstylesheet.

Fair Isaac Corporation Proprietary Information

506

Chapter 17: mmsvg

svgshowgraphaxes
Purpose
Synopsis

Force displaying of graph axes.
procedure svgshowgraphaxes(force:boolean)

Argument
force Decide whether graph axes must be shown when no label is defined.
Further information
By default the axes are only shown if a label text is defined (for x or y axis). This procedure makes it
possible to display the axes even if no label is used.
Related topics
svgsetgraphlabels.

Fair Isaac Corporation Proprietary Information

507

Chapter 17: mmsvg

svgwaitclose
Purpose
Synopsis

Delay model termination.
procedure svgwaitclose(msg:text,mode:integer)
procedure svgwaitclose(msg:text)
procedure svgwaitclose

Arguments
msg
mode

ExampleSome message to display.
Mode of operation:0
Wait until the browser window is closed
1Same as above except if running from Workbench: termination occurs after thegraph is loaded

This code shows a typical call sequence for graphical display.
svgaddgroup("a", "Group A")
svgaddrectangle(20, 120, 200, 250)
svgrefresh! Display the graphic
svgwaitclose! Model waits here until display window is closed

Further information
1. A call to this routine is typically added to the end of any model that includes graphical display (that is,calls to svgrefresh) via mmsvg to allow the user time for inspecting the graphical output. If thissubroutine call is not present, then model termination may close the display window or prevent thebrowser to load the graph.
2. The last form of the routine is equivalent to svgwaitclose("",0).
Related topics
svgrefresh, svgclosing.

Fair Isaac Corporation Proprietary Information

508

CHAPTER 18

mmsystem
The mmsystem module provides a set of procedures and functions related to the operating system. Notethat the behavior of these operators may vary between systems. To use this module, the following line
must be included in the header of the Mosel model file:uses 'mmsystem'

18.1 New functionality for the Mosel language
18.1.1 The type text
This module provides the type text for text manipulation. Like the Mosel basic type string, this new
type may be generated from all objects that can be converted to a text representation and supports theusual string operations (like concatenation or formatting). In addition, text objects can be generated fromstructured entities (like arrays or lists); altered (one can get and change a single as well as a sequence ofcharacters in a text); offer a wider set of operations (like insertion/deletion/search of substrings) and, as
all module types, are passed by reference to subroutines. Note that this type supports creation of
constants (i.e. it can be used in sets of constants) and implicit conversion from string: a routine
expecting a text as parameter may be used with a string instead (in this case the compiler creates a
temporary text from the provided string). When creating a text object from a structured type it is possible
to specify a limit on the size of the generated string. For instance if S is a set, text(S,128) will produce
a textual representation of S of at most 128 characters.

18.1.2 The type date
As the name suggests, the type date is used to represent a calendar date. Internally, a date is stored as
three independent integers for representing the year (-32768 to 32767), the month (-128 to 127) and the
day in the month (-128 to 127). The validity of a date can be checked using the function isvalid. A dateobject can be initialized by a text string, a single or three numerical values. In the first case, the conversion
is processed using a predefined date format (see datefmt); in the second case, the integer is interpreted
as the number of days elapsed since 1/1/1970 (this value can be negative); finally, if three integers areused, they are respectively interpreted as the year, month and day for the date. The constant SYS_NOW
may also be used to initialize a date: date(SYS_NOW) is the current date (local time). This type also
supports creation of constants (i.e. it can be used in sets of constants), assignment, comparison as well
as difference (returned in number of days) and addition/subtraction of an integer (number of days).

18.1.3 The type time
The type time is used to represent a time during the day. Internally, a time object is stored as an integer
representing a number of milliseconds. A time object can be initialized by a text string or one to four
numerical values. In the first case, the conversion is processed using a predefined time format (seeFair Isaac Corporation Proprietary Information509

Chapter 18: mmsystem

timefmt); in the second case, the integer is interpreted as a number of milliseconds. When two to four
integers are used, they are understood as the hours, minutes, seconds and milliseconds. The constant
SYS_NOW may also be used to initialize a time: time(SYS_NOW) is the current time (local time). This
type also supports creation of constants (i.e. it can be used in sets of constants), assignment,
comparison as well as difference (returned in number of milliseconds) and addition/subtraction of an
integer (number of milliseconds).

18.1.4 The type datetime
The type datetime is used to represent a timestamp by combining a date and a time. A datetime object
can be initialized by a text string, a pair date and time or a numerical value. In the first case, theconversion is processed using a predefined time format (see datetimefmt); in the third case, thenumber is interpreted as the number of seconds elapsed since 1/1/1970 at midnight (this value can be
negative). If the provided number is a real value, the fractional part is stored as a number of milliseconds.
The constant SYS_NOW may also be used to initialize a datetime: datetime(SYS_NOW) is the current
date and time (local time). This type also supports creation of constants (i.e. it cand be used in sets ofconstants), assignment, comparison as well as difference (returned in number of seconds) andaddition/subtraction of a numerical value (number of seconds).

18.1.5 The type parsectx
This module publishes a set of routines for parsing input text strings (for instance parseint or
nextfield). These routines use several module parameters for both their configuration and as a way torecord their internal state: a variable of type parsectx may be used as a replacement for these moduleparameters in order to implement parsing procedures independent of the rest of the program. A single
parsectx object integrates endparse (see sys_endparse), sepchar (see sys_sepchar), trim(see sys_trim) and qtype (see sys_qtype). The current value of each of these components can beaccessed using the corresponding set and get routine (for instance getendparse).

18.1.6 The type textarea
The textarea type is used by the regular expression matching function regmatch to return locations in
the input string. Each text area is defined by a starting position (that is an offset in the original string) andan ending position characterised by the offset of the character following the region to be considered.
Functions getstart and getsucc can be used to retrieve these properties.
For instance, the following statement displays the region ta of the text txt:
writeln(copytext(txt,ta.start,ta.succ-1))

This can also be written as follows:
writeln(copytext(txt,ta))

18.2 Control parameters
Via the getparam function and the setparam procedure it is possible to access the following control
parameters of module mmsystem (the reader is reminded that parameters may be spelled with lower orupper case letters or a mix of both):datefmt

Date text format.

p. 511

datetimefmt

Date and time text format.

p. 512

Fair Isaac Corporation Proprietary Information

510

Chapter 18: mmsystemmonthnames

List of month names.

p. 512

sys_endparse

End of parsing position.

p. 513sys_fillchar

Padding character for text resize.

p. 513sys_pid

Process identification.

p. 513

sys_qtype

Text quoting convention.

p. 513sys_regcache

Number of regular expressions in cache.

p. 514sys_sepchar

Separator character.

p. 514

sys_trim

Whether to trim spaces in text parsing.

p. 514

sys_txtmem

Size of the text block.

p. 514

timefmt

Time text format.

p. 511

datefmt
Description

Define the text format for both reading and writing a date.

Type

String, read/write

Default value"%.y-%0m-%0d"

Note

The date format consists in a text string in which the date information (like day number) is
specified using tags. A tag begins by the character "%" optionally followed by "." or "0" anda character indicating which specific information must be provided. The possible values are:
C Century
Y Year number in the century
y Yearm Month (1-12)
N Name of month according to parameter monthnamesd Day (1-31)% The symbol "%"If the second character is used, the corresponding information is produced in fixed format withspace (".") or zero ("0") as the padding character. For instance, the day 1 will be displayed as"1" with the format "%d"; as " 1" with "%.d" and as "01" with "%0d".

See also

datetimefmt,monthnames

Modulemmsystem

timefmt
Description

Define the text format for both reading and writing time.

Type

String, read/write

Default value"%0H:%0M:%0S%f"

Note

The time format consists in a text string in which the time information (like number of seconds)
is specified using tags. A tag begins by the character "%" optionally followed by "." or "0"and a character indicating which specific information must be provided. The possible values
are:

Fair Isaac Corporation Proprietary Information

511

Chapter 18: mmsystem

H Hour (0-23)
h Hour (1-12)
M Minute (0-59)
S Seconds (0-59)
s Milliseconds (0-999)
f Milliseconds as a fractonal value with a comma as the decimal separator (,001-,999)
F Milliseconds as a fractonal value with a dot as the decimal separator (.001-.999)
p text "pm" or "am"P text "PM" or "AM"% The symbol "%"If the second character is used, the corresponding information is produced in fixed format withspace (".") or zero ("0") as the padding character. For instance, the hour 1 will be displayedas "1" with the format "%H"; as " 1" with "%.H" and as "01" with "%0H". When theformats f or F are used for parsing they both accept dot and comma as the decimal separator.
The formats f and F without second character ("." or "0") display nothing if the number ofmilliseconds is 0.
See also

datetimefmt

Modulemmsystem

datetimefmt
Description

Define the text format for both reading and writing a datetime object.

Type

String, read/write

Default value"%.y-%0m-%0dT%0H:%0M:%0S%f"

Note

The datetime format accepts the syntaxes of the date format and the time format in the same
string.

See also

datefmt,timefmt

Modulemmsystemmonthnames
Description

Define month names to be used with the %N format.

Type

String, read/write

Default value"jan feb mar apr may jun jul aug sep oct nov dec"

NoteThis parameter is used when converting dates from/to strings with the %N format. The string
must contain 12 words separated by spaces. For conversions from strings, the comparison is
not case sensitive.

See also

datefmt,datetimefmt

ModulemmsystemFair Isaac Corporation Proprietary Information

512Chapter 18: mmsystem

sys_endparse
Description

Index in the text string where the parsing stopped. This parameter is updated and may be used
(as a starting position) by the parse⁎ routines.

Type

Integer, read/write

Set by routinesparseint, parsereal, parseextn, parsetext, nextfield

Modulemmsystem

sys_fillchar
Description

Character code used to fill empty regions generated in text strings when using the function
setchar.

Type

Integer, read/write

Values

Between 1 and 127

Default value

32 (space character)

Affects routines

setcharModulemmsystem

sys_pid
Description

System identification (Process ID) of the process running Mosel.

Type

Integer, read only

Default value

assigned by the operating system

Modulemmsystem

sys_qtype
Description

Convention to use when quoting/parsing a text string.

Type

Integer, read/write

Default value

0

Note

Supported quoting conventions are:0
Mosel: strings optionally quoted with either single or double quotes. Withdouble quotes, escape sequences starting with the backslash character ("\")
are supported
1
C/C++: double quotes with escape sequences starting with the backslashcharacter ("\")
2
CSV: strings are optionally quoted with double quotes. The symbol "double
quotes" is doubled when it is included in a quoted string3
JSON: double quotes with escape sequences starting with the backslash character ("\")-1 No quoting

Affects routinesparsetext, quote

ModulemmsystemFair Isaac Corporation Proprietary Information

513

Chapter 18: mmsystem

sys_regcache
Description

Regular expression searches require a compilation procedure to be performed before the actual
search. In order to speedup handling of expressions, a number of compiled expressions are
saved in a cache pool: this parameter specifies the size of this pool. Note that setting thisparameter has the effect of clearing the cache (even if the pool size if kept unchanged).

Type

Integer, read/write

Values

Between 1 and 25

Default value

3

Affects routines

regmatch, regreplace

Modulemmsystem

sys_sepchar
Description

Character code used as a field separator for text parsing routines.

Type

Integer, read/write

Values

Between 1 and 127

Default value

32 (space character)

Affects routinesparsetext, quote, nextfield

Modulemmsystem

sys_trim
Description

If this parameter is true, function nextfield skips blank characters around field separators.

Type

Boolean, read/write

Default valuetrue

Affects routines

nextfield

Set by routines

nextfield

See also

sys_sepchar

Modulemmsystem

sys_txtmem
Description

All text objects are stored in a single block of memory. This parameter corresponds to thesize of this block expressed in kilobytes. Changing this value makes it possible either topre-allocate memory by increasing the size of the block or release unused memory by reducing
its size. If the requested size is not large enough to contain the currently defined text objects,
the memory block is reduced to the smallest possible size.

Type

Integer, read/write

Default value

0 (at program startup)

ModulemmsystemFair Isaac Corporation Proprietary Information

514

Chapter 18: mmsystem

18.3 Procedures and functions
In general, the procedures and functions of mmsystem do not fail but set a status variable that can beread with getsysstat. To make sure the operation has been performed correctly, check the value of
this variable after each system call.
addmonths

Add a number of months to a date or datetime.

p. 518compareic

Compare 2 text strings ignoring case.

p. 519copytext

Copy a part of a text or string.

p. 520cuttext

Cut a part of a text returning a copy of the deleted string.

p. 521deltext

Delete a part of a text.

p. 522

endswith

Check whether a text or string ends with a given string.

p. 523erase

Securely deletes the content of a text entity.

p. 524

expandpath

Expand a path or file name.

p. 525

fcopy

Copy a file.

p. 526

fdeleteDelete a file.

p. 527findfiles

Search for files according to file name patterns.

p. 528findtext

Search for a string in a text or string.

p. 529fmove

Rename or move a file.

p. 530formattext

Create a text from a format string and its parameters.

p. 531getasnumber

Convert a date, time or datetime into a number.

p. 533getcharGet a character in a string or text.

p. 534getcwdGet the current working directory.

p. 535getdateGet the date part of a datetime.

p. 536getdayGet the day number in the month of a date or datetime.

p. 537

getdaynum

Get the day number in the year of a date or datetime.

p. 538getdaysGet the number of days of a month.

p. 539getdirsep

Get the directory separator of the running operating system.

p. 540getdsoparamGet the value of a control parameter.

p. 541getendparse, setendparse Get and set endparse property of a parser context.

p. 542

getenv

Get the value of an environment variable.

p. 543getfsize

Get the size of a file.

p. 544getfstat, getflstat

Get the status of a file or directory.

p. 545getftime

Get time information of a file.

p. 546gethour

Get the hour part of a time or datetime.

p. 547

getminuteGet the minute part of a time or datetime.

p. 548Fair Isaac Corporation Proprietary Information

515

Chapter 18: mmsystem

getmonth

Get the month number of a date or datetime.

p. 549getmsec

Get the millisecond part of a time or datetime.

p. 550getoserrmsg

Get the message associated to a system error code.

p. 552

getoserror

Get the system error code of the last command.

p. 551

getpathsep

Get the path separator of the running operating system.

p. 553

getqtype, setqtype

Get and set qtype property of a parser context.

p. 555getsecondGet the second part of a time or datetime.

p. 556

getsepchar, setsepchar

Get and set sepchar property of a parser context.

p. 557

getsizeGet the size of a text.

p. 558

getstart, setstart

Get and set start property of a text area.

p. 559getsucc, setsucc

Get and set succ (position of successor character) property of a text area.
p. 554

getsysinfo

Get information about the running operating system.

p. 560

getsysstat

Get the system status.

p. 561

gettimeGet a time measure or the time part of a datetime.

p. 562gettmpdir

Get the temporary directory as a text object.

p. 563gettrim, settrim

Get and set trim property of a parser context.

p. 564getweekday

Compute the day of the week for a date or datetime.

p. 565getyearGet the year part of a date or datetime.

p. 566

inserttext

Paste a text or string into a text.

p. 567

isvalid

Check whether a date, time or datetime is valid.

p. 568jointext

Merge elements of a list or set into a text string.

p. 569makedir

Create a new directory in the given file system.

p. 570

makepath

Create a new directory including its parents if necessary.

p. 571

newtarCreate a Unix tar archive from a list of files.

p. 572

newzipCreate a Zip archive from a list of files.

p. 573

nextfield

Advance to next field in a structured text string.

p. 574

openpipe

Start an external process for bidirectional communication.

p. 575parseextn

Initialise an object of a module type from a text.

p. 576parseint

Convert a text into an integer.

p. 577parsereal

Convert a text into a real.

p. 579parsetext

Extract a text from a text.

p. 580pastetext

Paste a text or string into a text.

p. 582

pathmatch

Check whether a file name matches a given pattern.

p. 583

Fair Isaac Corporation Proprietary Information

516

Chapter 18: mmsystempathsplit

Split a path into its components.

p. 584

qsort

Sort a list or an array or (a subset of) the indices of an array.

p. 585quote

Quote and encode a text string.

p. 587

readlink

Get the value of a symbolic link.

p. 588readtextline

Read a line of text from the current input stream.

p. 589regmatchCompare text strings using a regular expression.

p. 590regreplace

Replace portions of a text string based on a regular expression.

p. 592

removedir

Remove a directory.

p. 593

removefiles

Remove files selected using file name patterns.

p. 594setcharSet a character in a text.

p. 595setdateSet the date part of a datetime.

p. 596setdaySet the day number of a date or datetime.

p. 597setdsoparamSet the value of a control parameter.

p. 598setenv

Set the value of an environment variable.

p. 599sethour

Set the hour part of a time or datetime.

p. 601

setminuteSet the minute part of a time or datetime.

p. 602

setmonth

Set the month number of a date or datetime.

p. 603

setmsec

Set the millisecond part of a time or datetime.

p. 604setoserror

Set the current system error code.

p. 600setsecond

Set the second part of a time or datetime.

p. 605settimeSet the time part of a datetime.

p. 606setyearSet the year part of a date or datetime.

p. 607

sleep

Suspend execution for a fixed amount of time.

p. 608splittext

Split a text string.

p. 609startswith

Check whether a text or string starts with a given string.

p. 610symlink

Create a symbolic link.

p. 611systemExecute an external program.

p. 612tarlistGet the list of files included in a Unix tar archive.

p. 614

textfmt

Create a formatted text from a string, a text or a number.

p. 615

tolower

Generate the lowercase version of the provided text.

p. 617

toupper

Generate the uppercase version of the provided text.

p. 618trim

Remove blank characters at the beginning and/or end of a text string. p. 619

untar

Extract files from a Unix tar archive.

p. 620unzip

Extract files from a Zip archive.

p. 621

ziplistGet the list of files included in a Zip archive.

p. 622

Fair Isaac Corporation Proprietary Information

517

Chapter 18: mmsystem

addmonths
Purpose
Synopsis

Add a number of months to a date or datetime.
function addmonths(d:date, nbm:integer):datefunction addmonths(dt:datetime, nbm:integer):datetime

Argumentsddt
nbm

A date object
A datetime object
The number of months to be added (can be negative)

Return value
The modified date or datetime.
Examplewriteln(addmonths(date(2000,1,31),1))! displays: 2000-02-29
writeln(addmonths(date(2012,12,12),-12)) ! displays: 2011-12-12
Further information
The day number is preserved unless it is not compatible with the computed month: in this case the day
number is moved to the last day of the month.
ModulemmsystemFair Isaac Corporation Proprietary Information

518

Chapter 18: mmsystemcompareic
Purpose
Synopsis

Compare 2 text strings ignoring case.
function compareic(arg1:string|text, arg2:string|text):integer

Arguments
arg1
arg2

First operand for the comparison
Second operand for the comparison

Return value
0 if strings are identical, -1 if the first string is less than the second string and 1 otherwise.
Further information
This function behaves like compare but ignoring case.
ModulemmsystemFair Isaac Corporation Proprietary Information

519

Chapter 18: mmsystem

copytext
Purpose
Synopsis

Copy a part of a text or string.
function copytext(t:text|string, i1:integer, i2:integer):text
function copytext(t:text|string, ta:textarea):text

Arguments
t
i1
i2
ta

A string or text object
Starting position of the region to copy
End position of the region to copy
A text area object

Return value
A copy of the region.
ExampleThe following:
writeln(copytext("abcdefgh",3,7))
writeln(copytext("abcdefgh",7,10))
produces this output:
cdefg
gh

Further information
This function returns an empty text if the bounds are not compatible with the string (e.g. starting position
larger than the length of the string) or inconsistent (e.g. starting position after end position).
Related topics
deltext, inserttext, pastetext, cuttext
ModulemmsystemFair Isaac Corporation Proprietary Information

520

Chapter 18: mmsystemcuttext
Purpose
SynopsisCut a part of a text returning a copy of the deleted string.
function cuttext(txt:text, i1:integer, i2:integer):text
function cuttext(txt:text, ta:textarea):text

Arguments
txt
i1
i2
ta

A text object
Starting position of the region to cut
End position of the region to cut
A text area object

Return value
A copy of the region. The input text is modified accordingly.
ExampleThe following:t:=text("abcdefgh")writeln(cuttext(t,3,7))
writeln(t)produces this output:
cdefg
abh

Further information
This function returns an empty text if the bounds are not compatible with the string (e.g. starting position
larger than the length of the string) or inconsistent (e.g. starting position after end position).
Related topics
deltext, inserttext, pastetext, copytext
ModulemmsystemFair Isaac Corporation Proprietary Information

521

Chapter 18: mmsystem

deltext
Purpose
Synopsis

Delete a part of a text.
procedure deltext(txt:text, i1:integer, i2:integer)
procedure deltext(txt:text, ta:textarea)

Arguments
txt
i1
i2
ta
ExampleA text object
Starting position of the region to delete
End position of the region to delete
A text area object

The following:t:=text("abcdefgh")deltext(t,3,7)
writeln(t)produces this output:
abh

Related topics
cuttext, inserttext, pastetext, copytext
ModulemmsystemFair Isaac Corporation Proprietary Information

522

Chapter 18: mmsystemendswith
Purpose
SynopsisCheck whether a text or string ends with a given string.
function endswith(txt:text|string, tofs:text|string):boolean

Arguments
txt
tofs

A string or text object
String to find

Return value
true if the ending of txt corresponds to tofs.
Related topics
startswith
ModulemmsystemFair Isaac Corporation Proprietary Information

523

Chapter 18: mmsystemerase
Purpose
Synopsis

Securely deletes the content of a text entity.
procedure erase(txt:text)

Argumenttxt

A text object to be erased

Further information
This function resets the text string it receives after having replaced each of its characters by a space.
ModulemmsystemFair Isaac Corporation Proprietary Information

524

Chapter 18: mmsystem

expandpath
Purpose
Synopsis

Expand a path or file name.
function expandpath(fname:string|text):text

Argument
fname File name to be expanded
Return value
An absolute path to the given file name or an empty string in case of failure.
Further information
1. This function expands a path or file name: it replaces all relative references (like "." or "..") andcompletes the path such that the returned string is an absolute path to the provided file name.
2. Only the "tmp:" IO driver can be expanded: any other driver reference will make the function fail andresult in an empty string.
ModulemmsystemFair Isaac Corporation Proprietary Information

525

Chapter 18: mmsystem

fcopy
Purpose
Synopsis

Copy a file.
procedure fcopy(namesrc:string|text, namedest:string|text)
procedure fcopy(namesrc:text, opts:integer, namedest:text, optd:integer)

Arguments
namesrc
opts
namedest
optd
ExampleThe name of the file to be copied
Open options for the input file
The destination nameOpen options for the output file

The following statement appends file "src" to file "dst":
fcopy("src",0,"dst",F_APPEND)

Further information
1. This procedure copies the file namesrc to namedest (that is replaced if it already exists). The provided
names may use extended notation.
2. With the second form of the procedure it is possible to select options used to open the 2 files (as usedwith the fopen procedure). The first syntax corresponds to:
fcopy(src,F_SILENT+F_BINARY,dst,F_SILENT+F_BINARY)
Related topics
fopen, getsysstat
ModulemmsystemFair Isaac Corporation Proprietary Information

526

Chapter 18: mmsystemfdeletePurpose
Synopsis

Delete a file.
procedure fdelete(filename:string|text)

Argument
filename The extended name of the file to be deleted
Further information
The provided name may use extended notation.
Related topics
removedir, removefiles, getsysstat
ModulemmsystemFair Isaac Corporation Proprietary Information

527

Chapter 18: mmsystemfindfiles
Purpose
Synopsis

Search for files according to file name patterns.
procedure findfiles(opt:integer,lsf:list of text,
dir:string|text,filters:string|text)
procedure findfiles(opt:integer,lsf:list of text,filters:string|text)
procedure findfiles(lsf:list of text,filters:string|text)
procedure findfiles(lsf:list of text)

Arguments
opt

Options (several options can be combined):

SYS_RECURS
Recursive search in subdirectories
SYS_NODIR
Do not report directories (only files)
SYS_DIRONLY Report only directories
SYS_REVORD
Reverse sort order
SYS_NOSORTDo not sort resulting list
lsf
Resulting list of file names
dirBase directory for the search (default: current directory)
filters File name filters (default: all files reported)
ExampleThe following prints the list of files with extension .mos and .bim of the current directory:
findfiles(lsf,"⁎.mos|⁎.bim")
writeln(lsf)

Further information
1. The filters argument consists in a list of patterns separated by the symbol ";": for each of thesepatterns the function executes a search from the specified dir directory. A pattern is composed of apath (using the usual operating system conventions) which last component may include wildcard
characters "⁎" (any text of any length), "?" (any single character) and "|" (logical "or"). For instance"bin/⁎.exe;models/⁎.mos|⁎.dat" will select all files with extension ".exe" in the "bin"directory as well as files with extension ".mos" and ".dat" in the "models" directory.
2. File name matching is achieved using function pathmatch and differences may be observed dependingon the operating system (e.g. file names are case sensitive under Posix systems but not under Windows).
3. Unless option SYS_NOSORT is used, the resulting list is sorted and duplicate entries are removed. Notealso that the provided list lsf is not reset: the result of the search is appended to this list.
Related topics
removefiles, getsysstat
ModulemmsystemFair Isaac Corporation Proprietary Information

528

Chapter 18: mmsystemfindtext
Purpose
Synopsis

Search for a string in a text or string.
function findtext(txt:text, toft:text, start:integer):integerfunction findtext(txt:text, tofs:string, start:integer):integerfunction findtext(str:string, tofs:string, start:integer):integer

Arguments
txt
str
toft
tofs
start

A text object
StringText to findString to findStarting position for the search

Return value
Index of the string or 0 if not found.
ExampleThe following:
writeln(findtext("abcdefgh","de",2))writeln(findtext("abcdefgh","de",5))produces this output:
40

Related topics
regmatch
ModulemmsystemFair Isaac Corporation Proprietary Information

529

Chapter 18: mmsystem

fmove
Purpose
Synopsis

Rename or move a file.
procedure fmove(namesrc:string|text,namedest:string|text)

Arguments
namesrc
The name of the file to be moved or renamed
namedest The destination name and/or path
Further information
This procedure renames the file namesrc to namedest. If the second name is a directory, the file is
moved into that directory; if it is an existing file it is first removed before the renaming. The provided
names may use extended notation.
Related topics
getsysstat
ModulemmsystemFair Isaac Corporation Proprietary Information

530

Chapter 18: mmsystemformattext
Purpose
SynopsisCreate a text from a format string and its parameters.
function formattext(fmt:string, a1, a2...):text
function formattext(fmt:string, l: list):text

Arguments
fmt
ailFormat string
Parameters of the format string
List of parameters of the format string

Return value
Formatted text.
ExampleThe following:
writeln(formattext("text1%8stext3", "text2"))
writeln(formattext("text1%-8stext3", "text2"))r:=789.123456
writeln(formattext("%1$r %1$4.2f%1$8.0f",r))produces this output:
text1
text2text3
text1text2
text3
789.123 789.12

Fair Isaac Corporation Proprietary Information

789

531

Chapter 18: mmsystem

Further information
1. This procedure behaves in a similar way as the sprintf function of the C language: the resulting text is
generated by inserting each of the parameters ai in the format string at locations identified by a marker.
This marker is of the form:%[index$][flags][width][.precision]conv

Where index (a non negative integer), flags (string of ’ ’, ’-’, ’+’, ’0’ and ’#’), width (positive
integer) and precision (non negative integer) are optional.
The index indicates which parameter to use for the conversion (first parameter has number 1), when it is
not specified the marker position is used instead (e.g. the third marker is used for the third parameter).
The flags essentially affect numerical conversions: with the flag ’0’ the value is zero padded; with ’-’
the value is left justified; with a space a blank is put before positive numbers and with ’+’ positive
numbers are preceded by the ’+’ sign.
The width defines a minimum width for the field.
The precision gives the minimum number of digits to appear for an integer conversion. With a floating
point value and a conversion ’a’, ’A’, ’e’, ’E’ or ’f’ it states the number of digits to appear after theradix and for a ’g’ conversion it is the maximum number of significant digits. The precision indicates a
maximum number of characters to display with textual conversions.
The conversion specifier conv is a letter indicating how to process the corresponding parameter and what
to ouput. Possible values for this character are:diouxX an integer value is output: the parameter must be an integer or a Boolean. The value isdisplayed as a decimal number (’d’ or ’i’), an octal number (’o’), an unsigned number (’u’)
or a hexadecimal number (’x’ or ’X’)
eEfgraAjy a real value is output: the parameter must be a real or an integer. If it is a real andparameter txtztol is true then any value smaller than parameter zerotol will be replaced 0.
When using the ’r’ conversion the optional part components of the marker are ignored and thevalue is converted using the current real printing format (according to the realfmt parameter,see setparam). The conversions ’e’ and ’E’ format the number as [-]d.ddde+/-dd;
conversion ’f’ uses a format of the form [-]ddd.ddd and conversion ’g’ selects format ’e’
or ’f’ depending on the value of the number. With ’a’ and ’A’ the value is converted to an
hexadecimal representation of the form [-]0xh.hhhp[+/-]ddd where ’h’ are hexadecimal
digits and ’d’ decimal digits. The conversions ’j’ and ’y’ produce a reversible textual
representation of the real number (i.e. converting the string back to real restores the exact
original value). The format ’j’ generates a decimal notation similar to the specification
ECMA-262 (e.g. "123.456") while the format ’y’ produces a scientific notation in all cases(e.g. "1.2345e2").
b’true’ or ’false’ is output: the parameter must be a Booleanca character is output: the parameter must be an integer that is interpreted as a Unicode codepointsa text string is output: the parameter must be a string or any type supporting conversion to textpa pointer expressed in hexadecimal is output: the parameter can be any referenced entity
2. To include the symbol ’%’ in the format string use the sequence ’%%’.
Related topics
textfmt, setparam
ModulemmsystemFair Isaac Corporation Proprietary Information

532

Chapter 18: mmsystemgetasnumber
Purpose
Synopsis

Convert a date, time or datetime into a number.
function getasnumber(d:date):integerfunction getasnumber(t:time):integerfunction getasnumber(dt:datetime):realArgumentsdt
dt

A date object
A time object
A datetime object

Return value
The numerical representation of the argument.
Further information
A date is converted to an integer Julian Day Number (number of days since 1/1/1970 at midnight). Thisfunction returns an integer number of milliseconds for a time and a real number of seconds for a
datetime. This number represents the number of seconds and milliseconds (as the fractional part of
the number) since 1/1/1970 at midnight.
ModulemmsystemFair Isaac Corporation Proprietary Information

533

Chapter 18: mmsystemgetchar
Purpose
Synopsis

Get a character in a string or text.
function getchar(txt:text, index:integer):integerfunction getchar(str:string, index:integer):integer

Argumentstxt
A text object
str
Stringindex Position of the character
Return value
Character code or -1 if the index is not valid.
Related topics
setcharModulemmsystemFair Isaac Corporation Proprietary Information

534

Chapter 18: mmsystemgetcwdPurpose
Synopsis

Get the current working directory.
function getcwd:string

Return value
The current working directory.
Further information
1. This function returns the current working directory, that is the directory where the model is being
executed and where files are looked for.
2. The returned value corresponds to getparam("workdir"). The current working directory can also bechanged via this control parameter (for instance setparam("workdir","../somedir").
ModulemmsystemFair Isaac Corporation Proprietary Information

535

Chapter 18: mmsystemgetdatePurpose
Synopsis

Get the date part of a datetime.
function getdate(dt:datetime):dateArgumentdt

A datetime object

Return value
A date object.
Related topics
gettime, getasnumber
ModulemmsystemFair Isaac Corporation Proprietary Information

536

Chapter 18: mmsystemgetdayPurpose
Synopsis

Get the day number in the month of a date or datetime.
function getday(d:date):integerfunction getday(dt:datetime):integer

Argumentsddt

A date object
A datetime object

Return value
Day number in the month.
Related topics
getyear, getmonth, getdaynum
ModulemmsystemFair Isaac Corporation Proprietary Information

537

Chapter 18: mmsystemgetdaynum
Purpose
Synopsis

Get the day number in the year of a date or datetime.
function getdaynum(d:date):integerfunction getdaynum(dt:datetime):integer

Argumentsddt

A date object
A datetime object

Return value
Day number in the year.
Examplewriteln(getdaynum(date(2010,2,1)))! displays: 32

Related topics
getdayModulemmsystemFair Isaac Corporation Proprietary Information

538

Chapter 18: mmsystemgetdays
Purpose
Synopsis

Get the number of days of a month.
function getdays(y:integer, m:integer):integerfunction getdays(d:date):integerfunction getdays(dt:datetime):integer

Arguments
y
m
d
dt

Year
Month
A date object
A datetime object

Return value
Number of days for the given month in the specified year.
Examplewriteln(getdays(2016,2))
Module! displays: 29

mmsystemFair Isaac Corporation Proprietary Information

539

Chapter 18: mmsystem

getdirsep
Purpose
Synopsis

Get the directory separator of the running operating system.
function getdirsep:string

Return value"/" on Posix systems and "\" on Windows.
Related topics
getpathsep
ModulemmsystemFair Isaac Corporation Proprietary Information

540

Chapter 18: mmsystemgetdsoparam
Purpose
Synopsis

Get the value of a control parameter.
function getdsoparam(name:string|text):text

Argument
name

Name of a control parameter (including the module name).

Return value
Current setting of the control parameter as a text.
Further information
1. This function is similar to getparam except that the control parameter name is searched at runtime. As
a consequence this identifier does not need to be a constant string but the execution is significantly
slower than getparam and it cannot be applied to package parameters.
2. The provided parameter name must include the module name (e.g. "mmsystem.datefmt") otherwise
the identifier is searched only in the list of Mosel parameters.
3. As opposed to getparam this procedure does not raise an error in case of failure (like parameter notfound): use getsysstat to detect error conditions.
Related topics
setdsoparam, getsysstat

Fair Isaac Corporation Proprietary Information

541

Chapter 18: mmsystemgetendparse, setendparse
Purpose
Synopsis

Get and set endparse property of a parser context.
function getendparse(pctx:parsectx):integer
procedure setendparse(pctx:parsectx, ep:integer)

Arguments
pctx
ep

A parser context
New endparse value

Return value
Current endparse value stored in the context.
Related topics
sys_endparse, getsepchar, gettrim, getqtype
ModulemmsystemFair Isaac Corporation Proprietary Information

542

Chapter 18: mmsystemgetenv
Purpose
Synopsis

Get the value of an environment variable of the operating system.
function getenv(name:string|text):stringArgument
name

Name of the environment variable

Return value
Value of the environment variable (an empty string if the variable is not defined).
Further information
This procedure is included in the published interface of mmsystem (see Section 18.5).
ExampleThe value of the environment variable PATH is retrieved as follows:
str:= getenv("PATH")

Related topics
setenvModulemmsystemFair Isaac Corporation Proprietary Information

543

Chapter 18: mmsystemgetfsize
Purpose
Synopsis

Get the size of a file.
function getfsize(filename:string|text):integer

Argument
filename Name (and path) of the file
Return value
The size of the file in bytes or -1 in case of error
Further information
The function returns -1 if the file cannot be found or accessed and MAX_INT if the size exceeds theinteger capacity (~2Gb).
Related topics
getsysstat
ModulemmsystemFair Isaac Corporation Proprietary Information

544

Chapter 18: mmsystemgetfstat, getflstat
Purpose
Synopsis

Get the status (type and access mode) of a file or directory.
function getfstat(filename:string|text):integerfunction getflstat(filename:string|text):integer

Argument
filename Name (and path) of the file or directory to check
Return value
Bit encoded type and mode of the given file or 0 if the file cannot be accessed.
ExampleThe following determines whether ftest is a directory and if it is writable:
fstat:= getfstat("ftest")
if bittest(fstat, SYS_TYP)=SYS_DIR
then writeln("ftest is a directory")
end-ifif bittest(fstat, SYS_WRITE)=SYS_WRITE
then writeln("ftest is writeable")
end-ifFurther information
1. The returned status type may be decoded using the constant mask SYS_TYP (the types are exclusive).
Possible values are:
SYS_DIR Directory
SYS_REG Regular file
SYS_LNK Symbolic link
SYS_OTH Special file (device, pipe...)
The access mode may be decoded using the constant mask SYS_MOD (the access modes are additive).
Possible values are:
SYS_READ Can be read
SYS_WRITE Can be modified
SYS_EXEC Is executable
2. The 2 versions of this function behave the same except for symbolic links: the first one (getfstat) reports
the properties of the linked file while the second (getflstat) reports a type SYS_LNK.
Related topics
readlink, getsysstat
ModulemmsystemFair Isaac Corporation Proprietary Information

545

Chapter 18: mmsystemgetftime
Purpose
Synopsis

Get time information of a file.
function getftime(filename:string|text,what:integer):realArguments
filename Name (and path) of the file
what
Information requested. Possible values:
SYS_FTIM_ACC Last access
SYS_FTIM_MOD Last modification
Return value
The time requested as the number of seconds elapsed since 1/1/1970 at midnight or 0 in case of error.
Related topics
getsysstat
ModulemmsystemFair Isaac Corporation Proprietary Information

546

Chapter 18: mmsystem

gethour
Purpose
Synopsis

Get the hour part of a time or datetime.
function gethour(t:time):integerfunction gethour(dt:datetime):integer

Argumentst
dt

A time object
A datetime object

Return value
Hour as an integer.
Related topics
getminute, getsecond, getmsec
ModulemmsystemFair Isaac Corporation Proprietary Information

547

Chapter 18: mmsystemgetminutePurpose
Synopsis

Get the minute part of a time or datetime.
function getminute(t:time):integerfunction getminute(dt:datetime):integer

Argumentst
dt

A time object
A datetime object

Return value
Minute as an integer.
Related topics
gethour, getsecond, getmsec
ModulemmsystemFair Isaac Corporation Proprietary Information

548

Chapter 18: mmsystem

getmonth
Purpose
Synopsis

Get the month number of a date or datetime.
function getmonth(d:date):integerfunction getmonth(dt:datetime):integer

Argumentsddt

A date object
A datetime object

Return value
Month number in the year.
Related topics
getyear, getday

Fair Isaac Corporation Proprietary Information549

Chapter 18: mmsystemgetmsec
Purpose
Synopsis

Get the millisecond part of a time or datetime.
function getmsec(t:time):integerfunction getmsec(dt:datetime):integer

Argumentst
dt

A time object
A datetime object

Return value
Millisecond as an integer.
Related topics
gethour, getminute, getsecond
ModulemmsystemFair Isaac Corporation Proprietary Information

550

Chapter 18: mmsystem

getoserror
Purpose
Synopsis

Get the system error code of the last command.
function getoserror:integer

Return value
A system error code or 0 if the last operation of the module was executed sucessfully.
Further information
This function reports the current system error code (corresponding to the C-variable errno on Posix and
the C-function GetLastError() on Windows): it can be used after getsysstat has returned a
non-zero status to get the actual system error (if the failure was actually due to a system error). This code
is system dependent but the corresponding error message might be retrieved using getoserrmsg.
Related topics
setoserror
ModulemmsystemFair Isaac Corporation Proprietary Information

551

Chapter 18: mmsystem

getoserrmsg
Purpose
Synopsis

Get the message associated to a system error code.
function getoserrmsg(ec:integer):text

Argumentec

A system error code

Return value
The message corresponding to the provided code or an empty string if the code is not known.
Further information
This function returns an explanatory message associated to the error code obtained from getoserror.
ModulemmsystemFair Isaac Corporation Proprietary Information

552

Chapter 18: mmsystemgetpathsep
Purpose
Synopsis

Get the path separator of the running operating system.
function getpathsep:string

Return value":" on Posix systems and ";" on Windows.
Related topics
getdirsep
ModulemmsystemFair Isaac Corporation Proprietary Information

553

Chapter 18: mmsystem

getsucc, setsucc
Purpose
Synopsis

Get and set succ (position of successor character) property of a text area.
function getsucc(ta:textarea):integer
procedure setsucc(ta:textarea, st:integer)

Argumentstast

A text area object
New succ value

Return value
Current succ value stored in the object.
Related topics
getstart
ModulemmsystemFair Isaac Corporation Proprietary Information

554

Chapter 18: mmsystem

getqtype, setqtype
Purpose
Synopsis

Get and set qtype property of a parser context.
function getqtype(pctx:parsectx):integer
procedure setqtype(pctx:parsectx, qt:integer)

Arguments
pctx
qt

A parser context
New qtype value

Return value
Current qtype value stored in the context.
Related topics
sys_qtype, getsepchar, gettrim, getendparse
ModulemmsystemFair Isaac Corporation Proprietary Information

555

Chapter 18: mmsystem

getsecond
Purpose
Synopsis

Get the second part of a time or datetime.
function getsecond(t:time):integerfunction getsecond(dt:datetime):integer

Argumentst
dt

A time object
A datetime object

Return value
Second as an integer.
Related topics
gethour, getminute, getmsec
ModulemmsystemFair Isaac Corporation Proprietary Information

556

Chapter 18: mmsystem

getsepchar, setsepchar
Purpose
Synopsis

Get and set sepchar property of a parser context.
function getsepchar(pctx:parsectx):integer
procedure setsepchar(pctx:parsectx, sc:integer)

Arguments
pctx
sc

A parser context
New sepchar value

Return value
Current sepchar value stored in the context.
Related topics
sys_sepchar, getendparse, gettrim, getqtype
ModulemmsystemFair Isaac Corporation Proprietary Information

557

Chapter 18: mmsystem

getsize
Purpose
Synopsis

Get the size of a text.
function getsize(txt:text):integerfunction getsize(ta:textarea):integer

Argumentstxt
ta

A text object
A text area object

Return value
The number of characters included in the text or text area.
ModulemmsystemFair Isaac Corporation Proprietary Information

558

Chapter 18: mmsystem

getstart, setstartPurpose
Synopsis

Get and set start property of a text area.
function getstart(ta:textarea):integer
procedure setstart(ta:textarea, st:integer)

Argumentstast

A text area object
New start value

Return value
Current start value stored in the object.
Related topics
getsucc
ModulemmsystemFair Isaac Corporation Proprietary Information

559

Chapter 18: mmsystem

getsysinfo
Purpose
Synopsis

Get information about the running operating system.
function getsysinfo:string
function getsysinfo(what:integer):string
function getsysinfo(I:Mosel):string
function getsysinfo(I:Mosel,what:integer):stringArguments
what

I

What information to collect:
SYS_NAME Name of the operating system
SYS_VER
Version name of the operating system
SYS_REL
Release number of the operating system
SYS_PROC Processor type
SYS_ARCH Processor architecture (32 or 64 bit)
SYS_NODE Computer name
SYS_RAM
Total amount of system memory (in megabytes)
A Mosel instance

Return value
A text string reporting the requested information.
ExampleThe following prints the computer name and its operating system version:
writeln("Node ",getsysinfo(SYS_NODE)," is running ",getsysinfo(SYS_NAME+SYS_REL))

Further information
1. Several information items can be obtained in a single call by summing up the option codes. In such acase, the resulting string consists in the different items separated by commas.
2. When the function is used without the what parameter, all information items are returned.
3. This function may also be used with a Mosel instance as its first parameter. In this case the returned
information relates to the system running this instance instead of the current system.
Related topics
mmjobsModulemmsystemFair Isaac Corporation Proprietary Information

560

Chapter 18: mmsystem

getsysstat
Purpose
Synopsis

Get the system status.
function getsysstat:integer

Return value
0 if the last operation of the module was executed sucessfully.
ExampleIn this example we attempt to delete the file randomfile. If this is unsuccessful, a warning message isdisplayed:fdelete("randomfile")
if getsysstat <> 0 thenwriteln("randomfile could not be deleted.")end-ifFurther information
This function should be used after every system call in order to check the status of the operation.
Related topics
getoserror, getoserrmsg
ModulemmsystemFair Isaac Corporation Proprietary Information

561

Chapter 18: mmsystem

gettime
Purpose
Synopsis

Get a time measure or the time part of a datetime.
function gettime:realfunction gettime(dt:datetime):time

Argumentdt

A datetime object

Return value
Time measure in seconds or a time object.
ExampleThe following prints the program execution time:
starttime:= gettime...
write("Time: ",gettime-starttime)! Get the start time
! Do something

Further information
1. The measure returned by this function corresponds to the elapsed time since the module has been
initialized (just before execution of the model starts).
2. The second form of this function is used to extract the time part of a datetime structure.
Related topics
getdate, getasnumber
ModulemmsystemFair Isaac Corporation Proprietary Information

562

Chapter 18: mmsystem

gettmpdir
Purpose
Synopsis

Get the temporary directory as a text object.
function gettmpdir:text

Return value
Temporary directory as a text object.
Further information
This function is equivalent to text(getparam("tmpdir")).
ModulemmsystemFair Isaac Corporation Proprietary Information

563

Chapter 18: mmsystem

gettrim, settrim
Purpose
Synopsis

Get and set trim property of a parser context.
function gettrim(pctx:parsectx):boolean
procedure settrim(pctx:parsectx, t:boolean)

Arguments
pctx
t

A parser context
New trim value

Return value
Current trim value stored in the context.
Related topics
sys_trim, getsepchar, getendparse, getqtype
ModulemmsystemFair Isaac Corporation Proprietary Information

564

Chapter 18: mmsystem

getweekday
Purpose
Synopsis

Compute the day of the week for a date or datetime.
function getweekday(d:date):integerfunction getweekday(dt:datetime):integer

Argumentsddt

A date object
A datetime object

Return value
The number of the day in the week (1-7).
Further information
The first day of the week (number 1) is Monday.
ModulemmsystemFair Isaac Corporation Proprietary Information

565

Chapter 18: mmsystemgetyear
Purpose
Synopsis

Get the year part of a date or datetime.
function getyear(d:date):integerfunction getyear(dt:datetime):integer

Argumentsddt

A date object
A datetime object

Return value
Year as an integer.
Related topics
getmonth, getday
ModulemmsystemFair Isaac Corporation Proprietary Information

566

Chapter 18: mmsysteminserttext
Purpose
Synopsis

Paste a text or string into a text.
procedure inserttext(txt:text, str:string, start:integer)
procedure inserttext(txt:text, src:text, start:integer)

Arguments
txt
src
str
start
ExampleA text object
A text object
A string
Insert position

The following:t:=text("abcdefgh")inserttext(t,"123",2)
writeln(t)inserttext(t,"456",8)
writeln(t)produces this output:
a123bcdefgh
a123bcd456efgh

Related topics
cuttext, deltext, pastetext, copytext
ModulemmsystemFair Isaac Corporation Proprietary Information

567

Chapter 18: mmsystemisvalid
Purpose
SynopsisCheck whether a date, time or datetime is valid.
function isvalid(d:date):booleanfunction isvalid(t:time):booleanfunction isvalid(dt:datetime):boolean

Argumentsdt
dt

A date object
A time object
A datetime object

Return value
True if the argument is valid.
Further information
A date is valid if its month number is in the range 1-12 and its day number is in the range 1-31 and iscompatible with its month number (for instance 2006-2-29 is not a valid date). A time is valid if it ispositive and smaller than an entire day. A datetime is valid if both its date part and its time part are
valid.
ModulemmsystemFair Isaac Corporation Proprietary Information

568

Chapter 18: mmsystem

jointext
Purpose
SynopsisMerge elements of a list or set into a text string.
function jointext(ls:list|set):text
function jointext(ls:list|set, mxe:integer):text
function jointext(ls:list|set, sep:string):text
function jointext(ls:list|set, sep:string, mxe:integer):text

Arguments
ls
sep
mxe

List or set to use as input
Separator string (default: ’,’)
Maximum number of elements to merge (default: 0 for no limit)

Return value
A text string consisting of the concatenation of set or list elements.
Further information
1. This function concatenates the elements of an input list or set to produce a text string. Items are
separated by the provided separator string that may be an empty string.
2. The argument mxe may be used to specify a maximum number of elements to process (the remaining
portion of the input data is ignored). If this limit is negative then the elements are taken from the end of
the collection (e.g. with -3 the last 3 elements of the collection are used), otherwise elements are takenfrom the beginning.
Related topics
splittext
ModulemmsystemFair Isaac Corporation Proprietary Information

569

Chapter 18: mmsystem

makedir
Purpose
SynopsisCreate a new directory in the given file system.
procedure makedir(dirname:string|text)

Argument
dirname The name and path of the directory to be createdRelated topics
removedir, makepath, getsysstat
ModulemmsystemFair Isaac Corporation Proprietary Information

570

Chapter 18: mmsystem

makepath
Purpose
SynopsisCreate a new directory including its parents if necessary.
procedure makepath(dirname:string|text)
procedure makepath(dirname:string|text,last_is_file:boolean)

Arguments
dirnameThe name and path of the directory to be createdlast_is_file If true, the last component of the path is ignored
Further information
1. This routine creates the directory dirname as well as intermediate directories in the path if necessary.
For instance, makepath("/tmp/dir1/dir2") will create "/tmp" then "/tmp/dir1" before"/tmp/dir1/dir2" if these directories are missing.
2. As opposed to makedir, this routine does not return an error condition if the path already exists.
3. The second form of this procedure can be used when the argument is a path to a file in order to create
the directory in which the file can be created. For instance, makepath("/tmp/dir1/myfile",true)
will create "/tmp/dir1" such that file /tmp/dir1/myfile" can be created.
Related topics
removedir, makedir, getsysstat
ModulemmsystemFair Isaac Corporation Proprietary Information

571

Chapter 18: mmsystem

newtarPurpose
SynopsisCreate a Unix tar archive from a list of files.
procedure newtar(opt:integer, tarfile:text, dir:text,
lsf:list of text|string)procedure newtar(tarfile:text, lsf:list of text|string)Arguments
opt

Options:

Do not store directories (only files)
Store only directories
Store all files in the root directory of the archive (i.e. do not preserve
directory structure)tarfile File name of the archive
dirBase directory (default: current directory)
List of files and directories to store in the archive (file names are relative to the dir directory)lsf
SYS_NODIRSYS_DIRONLY
SYS_FLAT

ExampleThe following creates an archive of the Xpress installation including only binary files:
findfiles(SYS_RECURS,lsf,getenv("XPRESSDIR"),"bin/⁎;lib/⁎;dso/⁎")newtar(0,"xpress.tar",getenv("XPRESSDIR"),lsf)

Further information
1. This implementation processes only regular files, symbolic links (on Posix systems) and directories:
other file types are silently ignored and not included in the archive.
2. By default file names are represented according the current system encoding in the archive. To select a
different encoding use the enc: file name prefix (see Section 2.16) on the archive name (e.g.
"enc:utf-8,myarc.tar").
3. File names including ".." are silently ignored unless option SYS_FLAT is used.
Related topics
tarlist, untar, newzip, getsysstat
ModulemmsystemFair Isaac Corporation Proprietary Information

572

Chapter 18: mmsystem

newzipPurpose
SynopsisCreate a Zip archive from a list of files.
procedure newzip(opt:integer, zipfile:text, dir:text,
lsf:list of text|string, password:text)
procedure newzip(opt:integer, zipfile:text, dir:text,
lsf:list of text|string)procedure newzip(zipfile:text, lsf:list of text|string)Arguments
opt

Options:

Do not store directories (only files)
Store only directories
Store all files in the root directory of the archive (i.e. do not preserve
directory structure)
zipfileFile name of the archive (that must be a physical file)
dirBase directory (default: current directory)
lsf
List of files and directories to store in the archive (file names are relative to the dir
directory)
password Password to generate en encrypted zip file
SYS_NODIRSYS_DIRONLY
SYS_FLAT

ExampleThe following creates an archive of the Xpress installation including only binary files:
findfiles(SYS_RECURS,lsf,getenv("XPRESSDIR"),"bin/⁎;lib/⁎;dso/⁎")newzip(0,"xpress.zip",getenv("XPRESSDIR"),lsf)

Further information
1. This implementation only supports the standard Zip format (only 32bit and basic encryption algorithm)
with symbolic links on Posix systems.
2. By default file names are represented according the current system encoding in the archive. To select a
different encoding use the enc: file name prefix (see Section 2.16) on the archive name (e.g.
"enc:utf-8,myarc.zip").
3. File names including ".." are silently ignored unless option SYS_FLAT is used.
Related topics
ziplist, unzip, newtar, getsysstat
ModulemmsystemFair Isaac Corporation Proprietary Information

573

Chapter 18: mmsystem

nextfield
Purpose
Synopsis

Advance to next field in a structured text string.
function nextfield(txt:text,start:integer,trim:boolean):booleanfunction nextfield(txt:text):booleanfunction nextfield(txt:text,pctx:parsectx):boolean

Arguments
txt
pctx
start
trim

A text object
A parser context
Starting position in the text (default value depends on which other arguments are used)
Whether to skip blank characters around separators

Return value
true if more data can be parsed.
ExampleThe following function returns the list of records of a text string using comma as the field separator
character:function split(t:text):list of text
declarations
pctx:parsectx
end-declarations
pctx.sepchar:=44 ! ','while(nextfield(t,pctx)) doreturned+=[parsetext(t,pctx)]
end-doend-function

Further information
1. When start is 0, this routine saves the position of the first character of the text string in the control
parameter sys_endparse and returns true.
2. When start is greater than 0 and the character located at position start is the separator character
sys_sepchar, the position start+1 is saved in control parameter sys_endparse and true isreturned. In all other cases false is returned.
3. This function returns false if the provided text txt is empty or the starting position start is not valid.
4. If argument trim is true, blank characters are skipped before and after the separator character. The
provided value is saved in parameter sys_trim when start is 0.
5. In the second form of the routine, parameters sys_endparse and sys_trim are used as default values
for arguments start and trim.
6. The version using a parser context works with the information contained in this context instead of the
global parameters (see Section 18.1.5).
Related topics
parseint, parsereal, parseextn, parsetext, getsysstat
ModulemmsystemFair Isaac Corporation Proprietary Information

574

Chapter 18: mmsystem

openpipe
Purpose
SynopsisStart an external process for bidirectional communication.
procedure openpipe(cmd:string|text)

Argument
cmd
ExampleThe command to be executed in the separate process

The following example uses an external program sort (we assume it writes a sorted copy of what it reads)
to display a sorted list of the content of set ToSort:
openpipe("sort")
forall(i in ToSort)
writeln(i)fclose(F_OUTPUT)
while(not iseof) do
readln(l)writeln(l)end-dofclose(F_INPUT)

Further information
1. Pipes required by this procedure are created using the pipe driver of this module (see Section 18.4.2). As
a consequence, the string provided as argument must be suitable for the driver (i.e. a program namefollowed by its options separated by spaces).
2. This procedure opens both an input and output streams that must be closed explicitly using fclose.
Note that the output stream must be closed first otherwise the program may lock up.
3. When Mosel is running in restricted mode (see Section 1.3.4), this procedure behaves like the systemprocedure.
4. In case of failure the procedure raises an IO error.
ModulemmsystemFair Isaac Corporation Proprietary Information

575

Chapter 18: mmsystemparseextn
Purpose
Synopsis

Initialise an object of a module type from a text.
procedure parseextn(txt:text,start:integer,e:mtype)procedure parseextn(txt:text,e:mtype)procedure parseextn(txt:text,pctx:parsectx,e:mtype)procedure parseextn(txt:text,ta:textarea,e:mtype)

Arguments
txt
pctx
ta
start
e
ExampleA text object
A parser context
A text area object
Starting position in the text (default value depends on which other arguments are used)
An object of an external typeThe following:
d:=date(SYS_NOW)
t:=text("1-Oct-2015")
setparam("datefmt", "%d-%N-%y")parseextn(t,1,d)
if getsysstat<>0 thenwriteln("Error")else
writeln("year:",d.year)
end-ifproduces this output:
year:2015

Further information
1. This function can only be used with types supporting initialisation from a string (like date or time for
instance). The parsing begins at the specified starting position and stops as soon as an invalid character
is found or when the end of the text is reached.
■■■Standard (initial two) versions: if start is not provided then the value of the control parameter
sys_endparse is used as starting position; the location where parsing stops is stored in theparameter sys_endparse.
Version using a parser context: the information contained in the parser context is used instead of the
global parameters (see Section 18.1.5); the context property endparse indicates the starting
position and is updated with the location where parsing stops.
Version using a textarea object: the routine uses the start property of the object (see Section
18.1.6) as the starting position but it does not store the position where parsing stops, in particular it
does not modify the parameter sys_endparse.

2. In case of error the system status is set with a non-zero value (see getsysstat).
Related topics
parseint, parsereal, parsetext, nextfield, sys_endparse
ModulemmsystemFair Isaac Corporation Proprietary Information

576

Chapter 18: mmsystemparseint
Purpose
Synopsis

Convert a text into an integer.
function parseint(txt:text,start:integer):integerfunction parseint(txt:text,start:integer,base:integer):integerfunction parseint(txt:text):integerfunction parseint(txt:text,pctx:parsectx):integerfunction parseint(txt:text,pctx:parsectx,base:integer):integerfunction parseint(txt:text,ta:textarea):integerfunction parseint(txt:text,ta:textarea,base:integer):integer

Arguments
txt
pctx
ta
start
base

A text object
A parser context
A text area object
Starting position in the text (default value depends on which other arguments are used)
Base to use for the conversion (between 2 and 36)

Return value
The integer represented by the string.
ExampleThe following:t:=text("a123.4b")
writeln(parseint(t,2))
writeln(getparam("sys_endparse"))produces this output:
123
5

Fair Isaac Corporation Proprietary Information

577

Chapter 18: mmsystem

Further information
1. The parsing begins at the specified starting position and stops as soon as an invalid character is found orwhen the end of the text is reached.
■■■Standard (initial three) versions: if start is not provided then the value of the control parameter
sys_endparse is used as starting position; the location where parsing stops is stored in theparameter sys_endparse.
Version using a parser context: the information contained in the parser context is used instead of the
global parameters (see Section 18.1.5); the context property endparse indicates the starting
position and is updated with the location where parsing stops.
Version using a textarea object: the routine uses the start property of the object (see Section
18.1.6) as the starting position but it does not store the position where parsing stops, in particular it
does not modify the parameter sys_endparse.

2. In case of error (no valid character found or overflow) the system status is set with a non-zero value (seegetsysstat) and, depending on the situation, 0, MAX_INT or -MAX_INT-1 is returned.
3. The optional base argument may be used if the text is not expressed in base 10. Valid values for thisparameter is 0 and 2 to 36. If base is zero or 16, the string may then include a ’0x’ prefix, and the number
will be read in base 16. Furthermore, if the base is 0, the text will be read in base 8 if the first character is
0 and in base 10 otherwise.
4. The base value may also be negative: in this case the input data is interpreted as an unsigned integer.
Related topics
parsereal, parseextn, parsetext, nextfield, sys_endparse
ModulemmsystemFair Isaac Corporation Proprietary Information

578

Chapter 18: mmsystemparsereal
Purpose
Synopsis

Convert a text into a real.
function parsereal(txt:text,start:integer):realfunction parsereal(txt:text):realfunction parsereal(txt:text,pctx:parsectx):realfunction parsereal(txt:text,ta:textarea):realArguments
txt
pctx
ta
start

A text object
A parser context
A text area object
Starting position in the text (default value depends on which other arguments are used)

Return value
The real represented by the string.
ExampleThe following:t:=text("a123.4b")
writeln(parsereal(t,2))
writeln(getparam("sys_endparse"))produces this output:
123.4
7

Further information
1. The parsing begins at the specified starting position and stops as soon as an invalid character is found orwhen the end of the text is reached.
■■■Standard (initial two) versions: if start is not provided then the value of the control parameter
sys_endparse is used as starting position; the location where parsing stops is stored in theparameter sys_endparse.
Version using a parser context: the information contained in the parser context is used instead of the
global parameters (see Section 18.1.5); the context property endparse indicates the starting
position and is updated with the location where parsing stops.
Version using a textarea object: the routine uses the start property of the object (see Section
18.1.6) as the starting position but it does not store the position where parsing stops, in particular it
does not modify the parameter sys_endparse.

2. If the string starts with the sequence "0x" or "OX" an hexadecimal representation of a floating pointvalue will be expected. This representation is of the form "[+/-]0xh.hhhp[+/-]ddd" where ’h’ arehexadecimal digits and ’d’ decimal digits.
3. In case of error (no valid character found or overflow) the system status is set with a non-zero value (seegetsysstat) and, depending on the situation, 0, MAX_REAL or -MAX_REAL is returned.
Related topics
parseint, parseextn, parsetext, nextfield, sys_endparse
ModulemmsystemFair Isaac Corporation Proprietary Information579

Chapter 18: mmsystemparsetext
Purpose
Synopsis

Extract a text from a text.
function parsetext(txt:text,start:integer):text
function parsetext(txt:text):text
function parsetext(txt:text,pctx:parsectx):text
function parsetext(txt:text,ta:textarea):text

Arguments
txt
pctx
ta
start

A text object
A parser context
A text area object
Starting position in the text (default value depends on which other arguments are used)

Return value
Decoded text.
ExampleThe following:t:=text("a123.4b")
setparam("sys_sepchar",46) ! '.'writeln(parsetext(t,2))
writeln(getparam("sys_endparse"))produces this output:
123
5

Fair Isaac Corporation Proprietary Information

580

Chapter 18: mmsystem

Further information
1. The behaviour of this routine depends on 2 control parameters: sys_sepchar (or context property
sepchar) defines a field separator that may mark the end of a non-quoted string and the parameter
sys_qtype (or context property qtype) specifies the convention to use for quoted strings: if thisparameter has value 0 (the default), Mosel quoting convention is used (both single and double quotes
may be employed and with double quotes escape sequences are allowed); with value -1 no quoting is
expected; with value 1, C/C++ quoting convention applies (only double quotes with escape sequences);with value 3, JSON quoting convention applies (only double quotes with escape sequences). Finally, withvalue 2, CSV convention is expected (double quotes and repetition of double quotes to escape thischaracter). The returned string is decoded: quotes are removed and escape sequences are replaced bytheir corresponding characters.
2. The parsing begins at the specified starting position and stops as soon as the separator character(sys_sepchar or context property sepchar respectively) is found or the quoted string is terminated.
■■■Standard (initial two) versions: if start is not provided then the value of the control parameter
sys_endparse is used as starting position; the location where parsing stops is stored in theparameter sys_endparse.
Version using a parser context: the information contained in the parser context is used instead of the
global parameters (see Section 18.1.5); the context property endparse indicates the starting
position and is updated with the location where parsing stops.
Version using a textarea object: the routine uses the start property of the object (see Section
18.1.6) as the starting position but it does not store the position where parsing stops, in particular it
does not modify the parameter sys_endparse.

3. In case of error, getsysstat will return a negative value. A positive value indicates that a quoted string
is unfinished (i.e. the end of the source text is reached although no matching quote has been found).
Related topics
parseint, parsereal, parseextn, nextfield, sys_sepchar, sys_qtype, sys_endparse
ModulemmsystemFair Isaac Corporation Proprietary Information

581

Chapter 18: mmsystem

pastetext
Purpose
Synopsis

Paste a text or string into a text.
procedure pastetext(txt:text, str:string, start:integer)
procedure pastetext(txt:text, src:text, start:integer)

Arguments
txt
src
str
start
ExampleA text object
A text object
A string
Paste position

The following:t:=text("abcdefgh")
pastetext(t,"123",2)
writeln(t)pastetext(t,"456",8)
writeln(t)produces this output:
a123efgha123efg456

Related topics
cuttext, inserttext, deltext, copytext
ModulemmsystemFair Isaac Corporation Proprietary Information

582

Chapter 18: mmsystem

pathmatch
Purpose
SynopsisCheck whether a file name matches a given pattern.
function pathmatch(filename:string|text,pattern:string|text):boolean

Arguments
filename The file name to evaluate
pattern
Matching pattern that may include ⁎ (any text of any length) or ? (any single character)
Return value
true if the file name matches the pattern.
ExampleThe following function identifies Mosel source file names:
function is_mosel_file(f:text):boolean
returned:=pathmatch(f,"⁎.mos")end-function

Further information
The comparison respects the operating environment conventions and behaviour may differ depending of
the operating system. In particular, under Posix systems comparisons are case sensitive; this is not thecase on Windows (i.e. file names are not case sensitive).
Related topics
regmatch
ModulemmsystemFair Isaac Corporation Proprietary Information

583

Chapter 18: mmsystempathsplit
Purpose
Synopsis

Split a path into its components.
function pathsplit(how:integer,path:text,rem:text):text
function pathsplit(how:integer,path:text):text

Arguments
how

path
rem

How to split the path:
SYS_DIR
Directory (i.e. part preceding the last directory separator)
SYS_FNAME File name (i.e. part following the last directory separator)
SYS_EXTN
File name extension (i.e. part following the last dot)
The path name to split
Remaining part of the path after the returned value has been removed

Return value
The requested part of the path.
ExampleThe following function returns the base name of a path (file name without directory and extension):function basename(f:text):text
returned:=pathsplit(SYS_FNAME,f)dummy:=pathsplit(SYS_EXTN,returned,returned)
end-function

Further information
Arguments path and rem can be the same object.
ModulemmsystemFair Isaac Corporation Proprietary Information

584

Chapter 18: mmsystem

qsort
Purpose
Synopsis

Sort a list or an array or (a subset of) the indices of an array.
procedure qsort(sense:boolean, lvals:list)
procedure qsort(sense:boolean, vals:array of integer|real|string)procedure qsort(sense:boolean, cvals:array|list of array, ndx:array)procedure qsort(sense:boolean, cvals:array|list of array, ndx:array,sel:set)procedure qsort(sense:boolean, cvals:array|list of array, lndx:list)
procedure qsort(sense:boolean, cvals:array|list of array, lndx:list,
sel:set)procedure qsort(sense:boolean, cmpfct:string|function, cmpctx:?, vals:array,ndx:array)procedure qsort(sense:boolean, cmpfct:string|function, cmpctx:?, vals:array,ndx:array, sel:set)procedure qsort(sense:boolean, cmpfct:string|function, cmpctx:?, vals:array,lndx:list)
procedure qsort(sense:boolean, cmpfct:string|function, cmpctx:?, vals:array,lndx:list, sel:set)

Arguments
sense

Sense of the sorting:

SYS_UP
Ascending order
SYS_DOWN Descending orderlvals
List to be sorted
vals
One-dimensional array to be sorted
cvals
One-dimensional array to be sorted or list of one-dimensional arrays
cmpfct The name of or a reference to a comparator function of the form function
cmpfct(cmpctx,e1,e2):integer that behaves as compare with e1 and e2 of the same
type as the array to sortcmpctx The value to be passed as the first argument to cmpfct (this parameter is not used by qsort)ndx
One-dimensional array of the same type and size as the indexing set of vals
lndx
List of the same type as the indexing set of vals
sel
Subset of the indexing set of vals
ExampleThe following example sorts an array of real numbers:
declarations
ar: array(1..10) of real
end-declarations
ar:: [1.2, -3, -8, 10.5, 4, 7, 2.9, -1, 0, 5]
qsort(true, ar)writeln("Sorted array: ", ar)

Fair Isaac Corporation Proprietary Information

585

Chapter 18: mmsystem

Further information
1. In the first two versions of the procedure (with two arguments, sense and vals or lvals) the input
array (list) vals (lvals) is overwritten by the resulting sorted array (list).
2. When an array ndx is provided, the resulting sorted array is returned in the argument ndx in the form of
its sorted index set. If a selection set sel of indices is provided, only the specified indices are processed.
3. When a list lndx is provided, the resulting sorted array is returned in the argument lndx in the form of alist of sorted indices. If a selection set sel of indices is provided, only the specified indices areprocessed.
4. When applied to a dynamic array this procedure processes all indices of the index set including those notreferring to an existing cell (a subset of the indexing set sel can be used to select only the existing
entries).
5. The second version of the routine can handle arrays of integers, reals and strings. Other versions also
accept module types supporting ordering (like text or date for instance).
6. When the parameter cvals is a list of arrays it is expected that all these arrays have one dimension andare all indiced by the same set. The list can contain up to 10 arrays. When performing the sorting theroutine will use the first array values as the primary sorting criteria and then the following array in case ofequality.
7. A comparator routine may also be provided in the form of user-defined function which name is cmpfct(the function must be declared public). The first parameter of this function is given via cmpctx that canbe of any scalar type (including a record), it is not used by the qsort algorithm but may be employed by
the comparator function to store data required for the comparison. The 2 other arguments, that are of thesame type as the array to sort, are the elements to compare: the function must return 0 if the 2 elements
are identical, -1 if the first element is smaller or 1 otherwise. When using this form there is no restriction
on the type of the array to sort.
ModulemmsystemFair Isaac Corporation Proprietary Information

586

Chapter 18: mmsystem

quote
Purpose
Synopsis

Quote and encode a text string.
function quote(txt:text,qtype:integer,sepchar:integer):text
function quote(txt:text):text

Argumentstxt
A text object
qtype
Quoting convention
sepchar Code of the separator character or 0
ExampleThe following statement:
writeln(quote('test CSV "quoted" string',2,44))
displays: "test CSV ""quoted"" string"

Further information
1. This function generates an encoded form of the provided text string according to the given quoting
convention qtype (see sys_qtype) and separator character sepchar. The provided text may bereturned unchanged if the selected convention does not require quotes and the text does not include any
special character or the specified separator character.
2. If argument sepchar is 0, quoting is enforced even if the selected quoting convention would not require
quotes.
3. In the second form of the routine, parameters sys_qtype and sys_sepchar are used as default values
for arguments qtype and sepchar.
Related topics
parsetext
ModulemmsystemFair Isaac Corporation Proprietary Information

587

Chapter 18: mmsystem

readlink
Purpose
Synopsis

Get the value of a symbolic link.
function readlink(string|txt:fname):text

Argument
fname A file nameReturn value
Linked file name or an empty string if the file cannot be accessed.
Further information
This function can be applied to a symbolic link to get its value. The file name itself is returned if theprovided file is not a symbolic link.
Related topics
getflstat, symlink, getsysstat

Fair Isaac Corporation Proprietary Information

588

Chapter 18: mmsystem

readtextline
Purpose
Synopsis

Read a line of text from the current input stream.
function readtextline(txt:text):integerfunction readtextline(txt:text,msize:integer):integer

Argumentstxt
A text object
msize Maximum number of bytes to read
Return value
Number of characters read or -1 if end of file.
ModulemmsystemFair Isaac Corporation Proprietary Information

589

Chapter 18: mmsystemregmatch
Purpose
Synopsis

Compare text strings using a regular expression.
function regmatch(src:text, regex:string):booleanfunction regmatch(src:text, regex:string, start:integer,
flags:integer):booleanfunction regmatch(src:text, regex:string, start:integer, flags:integer,
mp:array(range) of textarea):boolean

Arguments
src
regex
start
flags

mp

Text to process
Regular expression
Position where to start the search
Search options:
REG_EXTENDED Use Extended Regular Expression syntax (ERE), default is to interpret theexpression as a Basic Regular Expression (BRE)
REG_ICASE
Comparison is performed case insensitive (by default it is case sensitive)
REG_NEWLINE
The character newline (\n) is treated as the end of line (by default it ishandled as an ordinary symbol)
REG_NOTBOLThe beginning of the text string is not the beginning of a line
REG_NOTEOLThe end of the text string is not the end of a line
Matching regions as an array of text area objects

Return value
true if a match was found.
ExampleThe following example extracts the value of ’pars2’ from an input text consisting of lines of the form
name=value:declarations
m:array(range) of textarea
t:textend-declarations
t:="p1=10\npars2=234\nparam9=56\n"
if regmatch(t,'pars2=\(.⁎\)$',1,REG_NEWLINE,m) thenpars2:=parseint(t,m(1))
writeln(pars2)
end-ifFurther information
1. This function relies on the TRE library (see http://laurikari.net/tre). Please refer to the documentation ofthis library for a detailed description of the supported expression syntax.
2. When the mp argument is provided and the search is successful, the result of the processing is returned
via this array as textarea objects (see Section 18.1.6): the array cell 0 refers to the entire matchingregion and the following ones to each of the subexpressions.
Related topics
findtext, pathmatch, regreplace, sys_regcache

Fair Isaac Corporation Proprietary Information

590

Chapter 18: mmsystem

ModulemmsystemFair Isaac Corporation Proprietary Information

591

Chapter 18: mmsystem

regreplace
Purpose
Synopsis

Replace portions of a text string based on a regular expression.
function regreplace(src:text, regex:string, repl:string):integerfunction regreplace(src:text, regex:string, repl:string, start:integer,
flags:integer):integer

Arguments
src
regex
repl
start
flags

Text to process
Regular expression
Replacement string expression
Position where to start the search
Search options:
REG_EXTENDED Use Extended Regular Expression syntax (ERE), default is to interpret theexpression as a Basic Regular Expression (BRE)
REG_ICASE
Comparison is performed case insensitive (by default it is case sensitive)
REG_NEWLINE
The character newline (\n) is treated as the end of line (by default it ishandled as an ordinary symbol)
REG_NOTBOLThe beginning of the text string is not the beginning of a line
REG_NOTEOLThe end of the text string is not the end of a line
REG_ONCE
Stop after the first replacement (by default the entire input string is
processed)

Return value
The number of replacements performed.
ExampleThe following statement transforms dates expressed as year-month-day to dates in the form
day/month/year
nbr:=regreplace(t,'([[:digit:]]{4})-([01]?[[:digit:]])-([0-3]?[[:digit:]])','\3/\2/\1',1,REG_EXTENDED)

Further information
1. This function relies on the TRE library (see http://laurikari.net/tre). Please refer to the documentation ofthis library for a detailed description of the supported expression syntax.
2. In the replacement string repl the backslash character (’\’) has a special meaning: if followed byanother baskslash character it is replaced by a single backslash; if followed by a digit it is replaced by thecorresponding subexpression defined by the regular expression. The subexpression number 0
corresponds to the entire matching region.
Related topics
regmatch, sys_regcache
ModulemmsystemFair Isaac Corporation Proprietary Information

592

Chapter 18: mmsystemremovedir
Purpose
Synopsis

Remove a directory.
procedure removedir(dirname:string|text)

Argument
dirname The name and path of the directory to delete
Further information
For deletion of a directory to succeed, the given directory must be empty.
Related topics
fdelete, makedir, removefiles, getsysstat
ModulemmsystemFair Isaac Corporation Proprietary Information

593

Chapter 18: mmsystemremovefiles
Purpose
Synopsis

Remove files selected using file name patterns.
procedure removefiles(opt:integer, dir:text,filters:text)
procedure removefiles(filters:text)

Arguments
opt

Options (several options can be combined):

SYS_RECURS
Recursive search in subdirectories
SYS_NODIR
Do not remove directories (only files)
SYS_DIRONLY Remove only directories
dir
Base directory for the search (default: current directory)
filters File name filters (default: all files removed)
ExampleThe following deletes directory "mydir" including its content:removefiles(SYS_RECURS,"mydir","⁎")
removedir("mydir")Further information
1. The filters argument consists in a list of patterns separated by the symbol ";". A pattern iscomposed of a path (using the usual operating system conventions) which last component may include
wildcard characters "⁎" (any text of any length), "?" (any single character) and "|" (logical "or"). For
instance "bin/⁎.exe;models/⁎.mos|⁎.dat" will select all files with extension ".exe" in the"bin" directory as well as files with extension ".mos" and ".dat" in the "models" directory.
2. File name matching is achieved using function pathmatch and differences may be observed dependingon the operating system (e.g. file names are case sensitive under Posix systems but not under Windows).
Related topics
findfiles, fdelete, removedir, getsysstat
ModulemmsystemFair Isaac Corporation Proprietary Information

594

Chapter 18: mmsystemsetchar
Purpose
Synopsis

Set a character in a text.
procedure setchar(txt:text, index:integer, c:integer)

Arguments
txt
str
index
c

A text object
StringPosition of the character
Character code

Further information
If the index requested is after the end of the text, the text is expanded as necessary and the newly createdspace is padded with the character which code is the parameter sys_fillchar.
Related topics
getchar, sys_fillchar, pastetext
ModulemmsystemFair Isaac Corporation Proprietary Information

595

Chapter 18: mmsystemsetdatePurpose
Synopsis

Set the date part of a datetime.
procedure setdate(dt:datetime,d:date)Argumentsdt
dA datetime object
A date object

Related topics
settimeModulemmsystemFair Isaac Corporation Proprietary Information

596

Chapter 18: mmsystemsetdayPurpose
Synopsis

Set the day number of a date or datetime.
procedure setday(d:date,j:integer)
procedure setday(dt:datetime,j:integer)

Argumentsddt
jA date object
A datetime object
Day number

Related topics
setyear, setmonth
ModulemmsystemFair Isaac Corporation Proprietary Information

597

Chapter 18: mmsystemsetdsoparam
Purpose
Synopsis

Set the value of a control parameter.
proceduresetdsoparam(name:string|text,val:integer|string|text|real|boolean)

Arguments
namevalName of a control parameter (including the module name).
New value for the control parameter

Further information
1. This procedure is similar to setparam except that the control parameter name is searched at runtime.
As a consequence this identifier does not need to be a constant string but the execution is significantly
slower than setparam and it cannot be applied to package parameters.
2. The provided parameter name must include the module name (e.g. "mmsystem.datefmt") otherwise
the identifier is searched only in the list of Mosel parameters.
3. As opposed to setparam this procedure does not raise an error in case of failure (like parameter notfound or invalid value): use getsysstat to detect error conditions.
Related topics
getdsoparam, getsysstat

Fair Isaac Corporation Proprietary Information

598

Chapter 18: mmsystemsetenv
Purpose
Synopsis

Set the value of an environment variable of the operating system.
procedure setenv(name:string|text,value:string|text)

Arguments
name Name of the environment variablevalue New value for the environment variable
Further information
1. The environment variable is deleted if it is assigned an empty string.
2. Variables created or modified with this procedure can be retrieved using the getenv function and are
inherited by processes started by system or openpipe.
3. The effect of this procedure is local to the running model (i.e. system calls like the C function getenv will
not work for these variables). However, another module may access the environment maintained bymmsystem using the IMCI function getenv (see Section 18.5).
4. This procedure is included in the published interface of mmsystem (see Section 18.5).
Related topics
getenv, system, openpipe, getsysstat
ModulemmsystemFair Isaac Corporation Proprietary Information

599

Chapter 18: mmsystemsetoserror
Purpose
Synopsis

Set the current system error code.
procedure setoserror(ec:integer)

Argumentec

A system error code

Further information
This function sets the current system error code that can be retrieved using getoserror. As a side
effect of using this routine the status returned by getsysstat is 0 if the error code is also 0 and 1
otherwise.
ModulemmsystemFair Isaac Corporation Proprietary Information

600

Chapter 18: mmsystem

sethour
Purpose
Synopsis

Set the hour part of a time or datetime.
procedure sethour(t:time,h:integer)
procedure sethour(dt:datetime,h:integer)

ArgumentstdthA time object
A datetime object
Hour

Related topics
setminute, setsecond, setmsec

Fair Isaac Corporation Proprietary Information

601

Chapter 18: mmsystemsetminutePurpose
Synopsis

Set the minute part of a time or datetime.
procedure setminute(t:time,m:integer)
procedure setminute(dt:datetime,m:integer)

Argumentstdtm

A time object
A datetime object
MinuteRelated topics
sethour, setsecond, setmsec
ModulemmsystemFair Isaac Corporation Proprietary Information602

Chapter 18: mmsystem

setmonth
Purpose
Synopsis

Set the month number of a date or datetime.
procedure setmonth(d:date,m:integer)
procedure setmonth(dt:datetime,m:integer)

Argumentsddt
m

A date object
A datetime object
Month number

Related topics
setyear, setday

Fair Isaac Corporation Proprietary Information

603

Chapter 18: mmsystemsetmsec
Purpose
Synopsis

Set the millisecond part of a time or datetime.
procedure setmsec(t:time,ms:integer)
procedure setmsec(dt:datetime,ms:integer)

Argumentst
dt
ms

A time object
A datetime object
Millisecond

Related topics
sethour, setminute, setsecond
ModulemmsystemFair Isaac Corporation Proprietary Information

604

Chapter 18: mmsystemsetsecond
Purpose
Synopsis

Set the second part of a time or datetime.
procedure setsecond(t:time,s:integer)
procedure setsecond(dt:datetime,s:integer)

Argumentstdts

A time object
A datetime object
SecondRelated topics
sethour, setminute, setmsec
ModulemmsystemFair Isaac Corporation Proprietary Information

605

Chapter 18: mmsystemsettime
Purpose
Synopsis

Set the time part of a datetime.
procedure settime(dt:datetime,t:time)

Argumentsdt
t

A datetime object
A time object

Related topics
setdateModulemmsystemFair Isaac Corporation Proprietary Information

606

Chapter 18: mmsystemsetyear
Purpose
Synopsis

Set the year part of a date or datetime.
procedure setyear(d:date,y:integer)
procedure setyear(dt:datetime,y:integer)

Argumentsddt
yA date object
A datetime object
Year

Related topics
setmonth, setday
ModulemmsystemFair Isaac Corporation Proprietary Information

607

Chapter 18: mmsystem

sleep
Purpose
Synopsis

Suspend execution for a fixed amount of time.
procedure sleep(duration:int)

Argument
duration Sleep time in milliseconds
Further information
The model uses no CPU while it is suspended.
ModulemmsystemFair Isaac Corporation Proprietary Information

608

Chapter 18: mmsystem

splittext
Purpose
Synopsis

Split a text string.
function splittext(ts:text, sep:string):list of text
function splittext(ts:text, sep:string, mxe:integer):list of text
function splittext(qt:integer, ts:text, sep:string):list of text
function splittext(qt:integer, ts:text, sep:string, mxe:integer):list of
text

Arguments
qt
ts
sep
mxe

Quoting type (see parameter sys_qtype, default: -1 for no quoting)
Text string to process
Separator string
Maximum number of elements to collect (default: 0 for no limit)

Return value
The list of identified items.
ExampleThe following statements:
write(splittext("some/path/to/a.file","/",-2))
writeln(splittext(2,'cv1,"cv""2""",cv3',","))
result in this display: [some/path/to,a.file][cv1,cv"2",cv3]

Further information
1. This function splits the input text string ts using the string sep as the field delimiter and returns theidentified items as a list of texts. The argument mxe defines a maximum number of elements to put into
this result list. If this limit is reached while the input string has not been entirely processed the last added
item includes the remaining part of the input data as a single record.
2. When the quoting type is not specified or when it is set to -1 the separator string may be an empty string
and the maximum number of elements may take a negative value. With an empty separator the input text
is split into individual characters. If the maximum number of elements is negative the decomposition is
performed from the end of the string.
3. When quoting is active (i.e. qt is not -1) a parsing error may occur: in this case the system status it set
to a non-zero value (see getsysstat) and the parsing is interrupted (typically after an error the last item
added to the result list is not valid).
Related topics
jointext
ModulemmsystemFair Isaac Corporation Proprietary Information609

Chapter 18: mmsystemstartswith
Purpose
SynopsisCheck whether a text or string starts with a given string.
function startswith(txt:text|string, tofs:text|string):booleanfunction startswith(txt:text|string, tofs:text|string,
start:integer):boolean

Argumentstxt
A string or text object
tofs String to findstart Starting position for the search
Return value
true if the beginning of txt corresponds to tofs.
Related topics
endswith
ModulemmsystemFair Isaac Corporation Proprietary Information

610

Chapter 18: mmsystem

symlink
Purpose
SynopsisCreate a symbolic link.
procedure symlink(string|txt:target, string|txt:linkpath)

Arguments
targetValue of the link
linkpath File to create
Further information
This procedure works only on systems supporting symbolic links, in particular it cannot be executed on
Windows (i.e. on this platform getsysstat will always report a failure after calling this routine).
Related topics
readlink, getsysstat

Fair Isaac Corporation Proprietary Information

611

Chapter 18: mmsystemsystemPurpose
Synopsis

Execute an external program.
procedure system(command:string|text)
procedure system(command:string|text,...)
procedure system(command:string|text,args:list)

Arguments
command The command to be executedargs
List containing the arguments for the command
ExampleThe following displays the functionality of the mmsystem and mmjobs modules using the program
mosel:
system('mosel exam mmsystem"')system('mosel','exam','mmjobs')

Further information
1. The given program is executed directly: if the specified expression is a shell command, it is necessary tocall the shell explicitly. For instance to get a directory listing under Windows the command will be "cmd
/C dir".
2. Using this procedure should be avoided in applications that are to be run on different systems becausesuch a call is always system dependent and may not be portable.
3. The generated process inherits the current system environment plus the environment variables
modified/created using the setenv procedure.
4. On Windows the program to execute is located using the current process environment, as a consequence
any modification of the PATH environment variable or working directory has no effect on finding thisexecutable. The behaviour is different on Posix systems where the search for the program to execute is
performed from the subprocess environment.
5. The default output and error streams of the generated process are redirected to the corresponding Mosel
streams. The default input stream is closed.
6. This procedure is included in the published interface of mmsystem (see Section 18.5).
7. When Mosel is running in restricted mode (see Section 1.3.4), the restriction NoExec disables this routine
unless the environment variable MOSEL_EXECPATH is defined. This variable, used in a similar way as the
PATH environment variable, gives a list of paths than can still be used under the restriction. In addition to
directories, the definition of the variable may include paths to executables such that it may directly
specify a list of programs. It is also worth noting that no search is performed (i.e. executables must be
given with their full path) and that path expansion is performed a the time of loading mmsystem relative
to the Mosel initial working directory.
8. The command may be preceded by the prefix "enc:" to specify the encoding of the output streams (seeSection 2.16).
9. When using the second and third forms of the procedure the command and each element of the list ofarguments are taken individually. This can be helpful if the command or the arguments contain spaces or
special characters (they should be quoted appropriately when using the procedure with a single
argument).

Fair Isaac Corporation Proprietary Information

612

Chapter 18: mmsystem

Related topics
getsysstat
ModulemmsystemFair Isaac Corporation Proprietary Information

613

Chapter 18: mmsystemtarlistPurpose
Synopsis

Get the list of files included in a Unix tar archive.
procedure tarlist(opt:integer,tarfile:text,lsf:list of text,
filters:string)procedure tarlist(tarfile:text,lsf:list of text)

Arguments
opt

Options:

SYS_NODIR
Do not report directories (only files)
SYS_DIRONLY Report only directories
tarfile File name of the archivelsf
Resulting list of file names
filters File name filters (default: all files reported)
ExampleThe following prints the list of files included in the archive myfiles.tar:
tarlist("myfiles.tar",lsf)
writeln(lsf)

Further information
1. The filters argument has a similar structure as the corresponding argument of procedure
findfiles except that wildcard characters "⁎" and "?" may appear anywhere in a path. A file isreported if it matches any of the patterns of this list.
2. When evaluating the filters, file name matching is achieved using function pathmatch and differences
may be observed depending on the operating system (e.g. file names are case sensitive under Posix
systems but not under Windows).
3. This implementation processes only regular files and directories: other file types included in the archive(like links) are silently ignored.
4. By default file names are expected to be represented according the current system encoding in thearchive. To select a different encoding use the enc: file name prefix (see Section 2.16) on the archive
name (e.g. "enc:utf-8,myarc.tar").
Related topics
untar, newtar, ziplist, getsysstat
ModulemmsystemFair Isaac Corporation Proprietary Information

614

Chapter 18: mmsystem

textfmt
Purpose
SynopsisCreate a formatted text from a string, a text or a number.
function textfmt(str:string, len:integer):text
function textfmt(txt:text, len:integer):text
function textfmt(i:integer, len:integer):text
function textfmt(i:integer, len:integer, flag:integer, base:integer):text
function textfmt(r:real, len:integer):text
function textfmt(r:real, len:integer, dec:integer):text

Arguments
str
txt
i
r
len

flag
base
dec

String to be formatted
Text to be formatted
Integer to be formatted
Real to be formatted
Reserved length (may be exceeded if given string is longer, in this case the string is always left
justified).
<0
Left justified within reserved space>0
Right justified within reserved space0
Use defaults
Bit encoded options:1
Left padding with "0" (instead of space)2
Use capital letters for bases greater than 10
Encoding base (between 2 and 36)
Number of digits after the decimal point

Return value
Formatted text.
ExampleThe following:
writeln("text1", textfmt("text2",8), "text3")
writeln("text1", textfmt("text2",-8), "text3")
r:=789.123456
writeln(textfmt(r,0)," ", textfmt(r,4,2), textfmt(r,8,0))
produces this output:
text1
text2text3
text1text2
text3
789.123 789.12

789

Further information
1. If the resulting string is longer than the reserved space it is not cut but printed in its entirety, overflowing
the reserved space to the right.
2. When processing an integer specifying a base, the provided value is treated as an unsigned integer if thebase is negative.
Related topics
formattext

Fair Isaac Corporation Proprietary Information

615

Chapter 18: mmsystem

ModulemmsystemFair Isaac Corporation Proprietary Information

616

Chapter 18: mmsystem

tolower
Purpose
Synopsis

Generate the lowercase version of the provided text.
function tolower(t:text|string):text
function tolower(c:integer):integer

Return value
The lowercase version of the input string or a character code.
ArgumentstcText to convert
Character code

Further information
When this function is used with a text string, it returns a copy of its argument converted to lowercase.
When it is called with an integer, the returned value corresponds to the character code of the lowercase
version of the provided code. In both cases, the function will return an unmodified copy of its argument if
no conversion can be done.
Related topics
toupperModulemmsystemFair Isaac Corporation Proprietary Information

617

Chapter 18: mmsystem

toupper
Purpose
Synopsis

Generate the uppercase version of the provided text.
function toupper(t:text|string):text
function toupper(c:integer):integer

Return value
The uppercase version of the input string or a character code.
ArgumentstcText to convert
Character code

Further information
When this function is used with a text string, it returns a copy of its argument converted to uppercase.
When it is called with an integer, the returned value corresponds to the character code of the uppercase
version of the provided code. In both cases, the function will return an unmodified copy of its argument if
no conversion can be done.
Related topics
tolowerModulemmsystemFair Isaac Corporation Proprietary Information

618

Chapter 18: mmsystem

trim
Purpose
Synopsis

Remove blank characters at the beginning and/or end of a text string.
procedure trim(t:text)
procedure trim(t:text,where:boolean)

Argumentst
Text to trim
where Part of the text to trim:
SYS_LEFTSYS_RIGHT

Beginning of the string
End of the string

Further information
When the function is used with a single argument, both starting and ending blank characters are deleted.
ModulemmsystemFair Isaac Corporation Proprietary Information

619

Chapter 18: mmsystem

untar
Purpose
Synopsis

Extract files from a Unix tar archive.
procedure untar(opt:integer,tarfile:text,dir:text,
filters:string)procedure untar(tarfile:text,dir:text)
procedure untar(tarfile:text)

Arguments
opt

Options:

SYS_OVERWRT Replace existing files
SYS_NODIR
Do not extract directories (only files)
SYS_DIRONLY Extract only directories
SYS_FLAT
Extract files without directory structure
SYS_VERB
Report activity to the error stream
SYS_NOFAIL
Do not abort procedure if a file cannot be written
tarfile File name of the archive
dir
Destination path (default: current directory)
filters File name filters (default: all files extracted)
ExampleThe following extracts all files included in the archive myfiles.tar to directory mydir:
untar("myfiles.tar","mydir")Further information
1. The filters argument has a similar structure as the corresponding argument of procedure
findfiles except that wildcard characters "⁎" and "?" may appear anywhere in a path. A file isextracted if it matches any of the patterns of this list.
2. When evaluating the filters, file name matching is achieved using function pathmatch and differences
may be observed depending on the operating system (e.g. file names are case sensitive under Posix
systems but not under Windows).
3. This implementation processes only regular files, symbolic links (when supported by the system) anddirectories: other file types included in the archive are silently ignored.
4. By default file names are expected to be represented according the current system encoding in thearchive. To select a different encoding use the enc: file name prefix (see Section 2.16) on the archive
name (e.g. "enc:utf-8,myarc.tar").
Related topics
tarlist, newtar, unzip, getsysstat
ModulemmsystemFair Isaac Corporation Proprietary Information

620

Chapter 18: mmsystem

unzip
Purpose
Synopsis

Extract files from a Zip archive.
procedure unzip(opt:integer, zipfile:text, dir:text,
filters:string, password:text)
procedure unzip(opt:integer, zipfile:text, dir:text,
filters:string)procedure unzip(zipfile:text, dir:text)
procedure unzip(zipfile:text)

Arguments
opt

Options:

SYS_OVERWRT Replace existing files
SYS_NODIR
Do not extract directories (only files)
SYS_DIRONLY Extract only directories
SYS_FLAT
Extract files without directory structure
SYS_VERB
Report activity to the error stream
SYS_NOFAIL
Do not abort procedure if a file cannot be written
zipfileFile name of the archive (that must be a physical file)
dir
Destination path (default: current directory)
filters
File name filters (default: all files extracted)
password Password to access an encrypted archive
ExampleThe following extracts all files included in the archive myfiles.zip to directory mydir:
unzip("myfiles.zip","mydir")Further information
1. The filters argument has a similar structure as the corresponding argument of procedure
findfiles except that wildcard characters "⁎" and "?" may appear anywhere in a path. A file isextracted if it matches any of the patterns of this list.
2. When evaluating the filters, file name matching is achieved using function pathmatch and differences
may be observed depending on the operating system (e.g. file names are case sensitive under Posix
systems but not under Windows).
3. This implementation only supports the standard Zip format (only 32bit and basic encryption algorithm)
and symbolic links are silently ignored if the system does not support them.
4. By default file names are expected to be represented according the current system encoding in thearchive. To select a different encoding use the enc: file name prefix (see Section 2.16) on the archive
name (e.g. "enc:utf-8,myarc.zip").
Related topics
ziplist, newzip, untar, getsysstat
ModulemmsystemFair Isaac Corporation Proprietary Information

621

Chapter 18: mmsystemziplistPurpose
Synopsis

Get the list of files included in a Zip archive.
procedure ziplist(opt:integer, zipfile:text, lsf:list of text,
filters:string)procedure ziplist(zipfile:text, lsf:list of text)

Arguments
opt

Options:

SYS_NODIR
Do not report directories (only files)
SYS_DIRONLY Report only directories
zipfile File name of the archivelsf
Resulting list of file names
filters File name filters (default: all files reported)
ExampleThe following prints the list of files included in the archive myfiles.zip:
ziplist("myfiles.zip",lsf)
writeln(lsf)

Further information
1. The filters argument has a similar structure as the corresponding argument of procedure
findfiles except that wildcard characters "⁎" and "?" may appear anywhere in a path. A file isreported if it matches any of the patterns of this list.
2. When evaluating the filters, file name matching is achieved using function pathmatch and differences
may be observed depending on the operating system (e.g. file names are case sensitive under Posix
systems but not under Windows).
3. By default file names are expected to be represented according the current system encoding in thearchive. To select a different encoding use the enc: file name prefix (see Section 2.16) on the archive
name (e.g. "enc:utf-8,myarc.zip").
Related topics
unzip, newzip, tarlist, getsysstat
ModulemmsystemFair Isaac Corporation Proprietary Information

622

Chapter 18: mmsystem

18.4 I/O drivers
The mmsystem module provides two IO drivers: the first one allows to use a string or text object as a fileand the second connects a Mosel input or output stream to a program started in a different process.
Using this driver, it is possible to get the output of an external program (for instance the result of apreprocessor to feed the Mosel compiler) or implement a basic bidirectional inter process
communication thanks to the openpipe procedure (which relies on this IO driver).

18.4.1 Driver text
text:ident

This driver uses a model variable of type string or text as its input or output media. The ident
argument it requires is therefore the name of this variable that must be declared globally public to themodel or have been published with publish (such that it can always be found independently of thecompiler settings).String objects can only be accessed for reading while text entities can be used forboth reading and writing.
In the following example the constant string "T" is used as the initialization file for variable "A":declarations
public T="A:123"
A:integer
end-declarations
initializations from "text:T"A
end-initializations

18.4.2 Driver pipe
pipe:program [options...]

The file name for this driver is an external program with its options. Options are separated by spaces ortabulations and may be quoted using either single or double quotes. A quoted option may contain any
kind of character except the quote used to delimit the string.
When the system opens a pipe, a new process is started for executing the given program and default
input and output streams are directed to system pipes. If the file is open for reading (resp. writing), thedefault ouput stream (resp. input stream) of the new process becomes the current input stream (resp.
output stream) of the model. To locate the program to be executed, the system relies on the PATH
environment variable. Detection of error (typically the program cannot be found or is not executable)
differs depending on the operating system: under Windows, the error is reported immediately and thepipe is not open. With Posix systems, no error is reported but following IO operations fail.
When the file is closed, both input and output streams of the external process are closed then the system
waits for its termination: in order to avoid a lock up of the Mosel program one must make sure that theexternal program ends its execution when default input and output streams are closed.
Example: the following command could be used with Mosel Console for compiling the model
mymod.mos after it has been processed by the C preprocessor. Note that we have to provide an output
file name since the compiler cannot deduce it from the source file name.
For a Posix systems:
compile 'mmsystem.pipe:cpp mymod.mos' '' mymod.bim

For Windows (with MSVC):

Fair Isaac Corporation Proprietary Information

623

Chapter 18: mmsystemcompile 'mmsystem.pipe:cl /E mymod.mos' '' mymod.bim

When Mosel is running in restricted mode (see Section 1.3.4), this driver behaves like the systemprocedure.

18.5 Published library functions
The module mmsystem publishes its implementation of getenv, setenv and system as well as thefunctions gettxtsize, getcsttxtbuf, gettxtbuf and txtresize for text access via the service
IMCI for use by other modules (see the Mosel Native Interface Reference Manual for more detail about
services). The list of published functions is contained in the interface structure mmsystem_imci that isdefined in the module header file mmsystem.h.
From another module, the context of mmsystem and its communication interface can be obtained using
functions of the Mosel Native Interface as shown in the following example.
static XPRMnifct mm;
XPRMcontext mmctx;
XPRMdsolib dso;
mmsystem_imci mmsys;
void ⁎⁎sysctxref;
dso=mm->finddso("mmsystem");/⁎ Retrieve the mmsystem module⁎/
sysctxref=mm->getdsoctx(mmctx, dso, (void ⁎⁎)(&mmsys));/⁎ Get the module context and thecommunication interface of mmsystem ⁎/Typically, a module calling functions that are provided by mmsystem will include this module into its listof dependencies in order to make sure that mmsystem will be loaded by Mosel at the same time as thecalling module. The “dependency” service of the Mosel Native Interface has to be used to set the list of
module dependencies:
static const char ⁎deplist[]={"mmsystem",NULL}; /⁎ Module dependency list ⁎/static XPRMdsoserv tabserv[]={{XPRM_SRV_DEPLST, (void ⁎)deplist}};/⁎ Table of services ⁎/Using these functions a module may access and modify the environment of the calling model andexecute an external program with automatic redirection of default streams:
mmsys->setenv(ctx,⁎sysctxref,"MYVAR","A_VALUE");
rts=mmsys->system(ctx,⁎sysctxref,"myprogram arg1 arg2");

18.5.1 Description of the library functions
getcsttxtbuf

Get a reference to the constant character buffer of a text object.

p. 632getdateGet the date of a date object.

p. 628getdatetime

Get the date and time of a datetime object.

p. 630gettimeGet the time of a time object.

p. 626gettxtbuf

Get a reference to the character buffer of a text object.

p. 634gettxtsize

Get the size of a text object.

p. 633

Fair Isaac Corporation Proprietary Information

624

Chapter 18: mmsystemsetdateSet the date of a date object.

p. 629setdatetime

Set the date and time of a datetime object.

p. 631settimeSet the time of a time object.

p. 627txtresize

Resize a text object.

p. 635

Fair Isaac Corporation Proprietary Information

625

Chapter 18: mmsystem

gettime
Purpose
Synopsis

Get the time of a time object.
int gettime(XPRMctx ctx, void ⁎sysctx, void ⁎t, int ⁎h, int ⁎mi, int ⁎s,
int ⁎ms);

Arguments
ctx
sysctxth
mis
ms

Mosel’s execution context
Context of mmsystem
Reference to a time object
Reference to store the hours or NULL
Reference to store the minutes or NULL
Reference to store the seconds or NULL
Reference to store the milliseconds or NULL

Return value
0 if successful or -1 if t is NULL.
Further information
Provided references are set even if the function fails.
Related topics
settimeModulemmsystemFair Isaac Corporation Proprietary Information

626

Chapter 18: mmsystemsettime
Purpose
Synopsis

Set the time of a time object.
int settime(XPRMctx ctx, void ⁎sysctx, void ⁎t, int h, int mi, int s, int
ms);Arguments
ctx
sysctxth
mis
ms

Mosel’s execution context
Context of mmsystem
Reference to a time object
hours
minutesseconds
milliseconds

Return value
0 if successful or -1 if t is NULL.
Related topics
gettimeModulemmsystemFair Isaac Corporation Proprietary Information

627

Chapter 18: mmsystemgetdatePurpose
Synopsis

Get the date of a date object.
int getdate(XPRMctx ctx, void ⁎sysctx, void ⁎t, int ⁎y, int ⁎m, int ⁎d);Arguments
ctx
sysctxtymd

Mosel’s execution context
Context of mmsystem
Reference to a date object
Reference to store the years or NULL
Reference to store the months or NULL
Reference to store the days or NULL

Return value
0 if successful or -1 if t is NULL.
Further information
Provided references are set even if the function fails.
Related topics
setdateModulemmsystemFair Isaac Corporation Proprietary Information

628

Chapter 18: mmsystemsetdatePurpose
Synopsis

Set the date of a date object.
int setdate(XPRMctx ctx, void ⁎sysctx, void ⁎t, int y, int m, int d);Arguments
ctx
Mosel’s execution context
sysctx Context of mmsystemt
Reference to a date object
y
Years
m
Monthsddays
Return value
0 if successful or -1 if t is NULL.
Related topics
getdateModulemmsystemFair Isaac Corporation Proprietary Information

629

Chapter 18: mmsystemgetdatetime
Purpose
Synopsis

Get the date and time of a datetime object.
int getdatetime(XPRMctx ctx, void ⁎sysctx, void ⁎t, int ⁎y, int ⁎m, int ⁎d,int ⁎h, int ⁎mi, int ⁎s, int ⁎ms);

Arguments
ctx
sysctx
t
y
m
d
h
mi
s
ms

Mosel’s execution context
Context of mmsystem
Reference to a date object
Reference to store the years or NULL
Reference to store the months or NULL
Reference to store the days or NULL
Reference to store the hours or NULL
Reference to store the minutes or NULL
Reference to store the seconds or NULL
Reference to store the milliseconds or NULL

Return value
0 if successful or -1 if t is NULL.
Further information
Provided references are set even if the function fails.
Related topics
setdatetime
ModulemmsystemFair Isaac Corporation Proprietary Information

630

Chapter 18: mmsystemsetdatetime
Purpose
Synopsis

Set the date and time of a datetime object.
int setdatetime(XPRMctx ctx, void ⁎sysctx, void ⁎t, int y, int m, int d,
int h, int mi, int s, int ms);

Arguments
ctx
Mosel’s execution context
sysctx Context of mmsystemt
Reference to a date object
y
Years
m
Months
d
days
h
hours
mi
minutessseconds
ms
milliseconds
Return value
0 if successful or -1 if t is NULL.
Related topics
getdatetime
ModulemmsystemFair Isaac Corporation Proprietary Information

631

Chapter 18: mmsystemgetcsttxtbuf
Purpose
Synopsis

Get a reference to the constant character buffer of a text object.
const char ⁎getcsttxtbuf(XPRMctx ctx, void ⁎sysctx, void ⁎t);

Arguments
ctx
sysctxt

Mosel’s execution context
Context of mmsystem
Reference to a text object

Return value
A reference to the character buffer.
Further information
1. The buffer returned is terminated by the character 0 (like a C string), and it must not be modified (even if
the provided text object is not constant). The function gettxtbuf should be used instead when thebuffer of a non-constant text has to be altered.
2. Since the memory management of the module may move text buffers when allocating memory, thepointer returned by this function is only valid until the next memory allocation.
Related topics
gettxtsize, gettxtbuf
ModulemmsystemFair Isaac Corporation Proprietary Information

632

Chapter 18: mmsystem

gettxtsize
Purpose
Synopsis

Get the size of a text object.
int gettxtsize(XPRMctx ctx, void ⁎sysctx, void ⁎t);

Arguments
ctx
sysctxt

Mosel’s execution context
Context of mmsystem
Reference to a text object

Return value
The size of the character buffer (excluding the terminating 0 character).
Related topics
txtresize, gettxtbuf
ModulemmsystemFair Isaac Corporation Proprietary Information

633

Chapter 18: mmsystem

gettxtbuf
Purpose
Synopsis

Get a reference to the character buffer of a text object.
char ⁎gettxtbuf(XPRMctx ctx, void ⁎sysctx, void ⁎t);

Arguments
ctx
sysctxt

Mosel’s execution context
Context of mmsystem
Reference to a text object

Return value
A reference to the character buffer or NULL if the provided text object is constant.
Further information
1. The buffer returned is terminated by the character 0 (like a C string) and can be modified as long as thesize is not changed. If the length of the buffer has to be altered, use the function txtresize.
2. A NULL pointer will be returned if the provided text object is constant. Use getcsttxtbuf to retrieve thebuffer of a constant text.
3. Since the memory management of the module may move text buffers when allocating memory, thepointer returned by this function is only valid until the next memory allocation.
Related topics
txtresize, gettxtsize, getcsttxtbuf
ModulemmsystemFair Isaac Corporation Proprietary Information

634

Chapter 18: mmsystem

txtresize
Purpose
Synopsis

Resize and get a reference to the character buffer of a text object.
char ⁎txtresize(XPRMctx ctx, void ⁎sysctx, void ⁎t, int s);

Arguments
ctx
sysctxts

Mosel’s execution context
Context of mmsystem
Reference to a text object
New size of the buffer (terminating 0 is not counted)

Return value
A reference to the new character buffer or NULL in case of memory error or if the provided text object isconstant.
Further information
1. The buffer returned is terminated by the character 0 (like a C string) and can be modified as long as thesize is not changed.
2. Since the memory management of the module may move text buffers when allocating memory, thepointer returned by this function is only valid until the next memory allocation.
Related topics
gettxtsize
ModulemmsystemFair Isaac Corporation Proprietary Information

635

CHAPTER 19

mmxml
This module provides an XML parser and generator for the manipulation of XML documents from Mosel
models. To use this module, the following line must be included in the header of the Mosel model file:uses 'mmxml'

mmxml relies on the XML parser EXPAT by James Clark (http://www.libexpat.org) for loading documents.

19.1 Document representation in mmxml
19.1.1 Data model
The XML document is stored as a list of nodes. Different node types are used to represent the document
structure:■element node■text section■comment

■

CDATA

■

processing instruction

In addition to these usual node types, the type DATA is used for XML constructs not supported by mmxml(for instance a DOCTYPE declaration is recorded as a DATA section). Although they are not directly
recorded in the document tree, attributes are also stored as nodes of a dedicated type.
Each node is characterised by a name and a value. Nodes of type text, comment, CDATA and DATA have aconstant name. The name of a processing instruction is the processing instruction’s target and its value
the remaining part of the statement (e.g. the name of <?proc inst> is proc and its value is inst).
The value of comment and CDATA sections is the content of the section without its delimiters but thevalue of a DATA block includes the delimiters. Element nodes have also an ordered list of child nodes.
The value of an element node corresponds to the value of the first child text node (if any).
The root node is a special element node with no name, no parent and no successor that includes theentire document as its children.

Fair Isaac Corporation Proprietary Information

636

Chapter 19: mmxml

Example of an XML document with node types:<?xml version="1.0" encoding="iso-8859-1" standalone="no" ?><?xml-stylesheet type="text/css" href="examplestyle.css" ?><!DOCTYPE exampleList SYSTEM "examples.dtd" [<!ENTITY otherfile SYSTEM "anotherfile.xml">]>

XML header
Processing instruc.
DATA<!-- List of optimization application examples --><exampleList><!-- Example B3 --><model id="book_B_3"><modFile date="Mar.2002">
b3jobshop.mos</modFile><modData file="b3jobshop.dat" /><modData file="b3jobshop2.dat" /><modTitle>
Job shop scheduling</modTitle><modRating>3</modRating><modFeatures><![CDATA[dynamic array, range, exists, forall-do]]></modFeatures></model></exampleList>

Comment
Element node
Comment
Element node
Element node
Text node
Element node
Element node
Element node
Text node
Element node
Text node
Element node
CDATA

19.1.2 Paths in a document
Nodes can be retrieved using a path similar to a directory path used to locate a file. An XML path consists
in a list of location steps separated by the slash character ("/"): each step selects a set of nodes fromthe input set resulting from the preceding step (context nodes). The initial set of the path is either theroot node (absolute path) or some specified node (relative path).
A step is composed of an optional axis specifier followed by a node test and possibly completed by apredicate. The axis specifies the tree relationship between the nodes selected by the step and the context
node. The node test is either an element name (to select elements of the given name) or a node type (toselect nodes by their type). The predicate is a Boolean expression the truth value of which decides
whether a selected node is kept in the result set of the step.
Examples:/examples/chapter

all element nodes ’chapter’ under elements ’examples’/examples/chapter/model/modRating[number()>=4]/.. all ’model’ nodes under’examples/chapter’ for which element ’modRating’ has a value greater thanor equal to 4//⁎[@attribute1 and @attribute2=’value2’] all element nodes of the document having’attribute1’ defined and ’attribute2’ with value ’value2’/descendant::text() all text sections of the document.//mytag

Fair Isaac Corporation Proprietary Information

all element nodes named ’mytag’ starting from the current node637

Chapter 19: mmxml

19.1.2.1 Axis specifier
An axis specifier consists in an axis name followed the the symbol ::. The supported axes are:child

children of the context node (this is the default if no axis is given)parentparent of the context node

self

the context node itself

attributethe attributes of the context nodefollowing

following node of the context nodedescendant-or-self

the context node as well as all its descendants

descendant

all descendants of the context node

19.1.2.2 Node test
By default only element nodes are considered, the node test is used to select the nodes by their name.
The special name "⁎" will keep all element nodes. Alternatively, the test can be related to the type of thenodes; in this case all nodes are considered and the test is one of the following expressions:text()

to select text nodes

comment()

to select comment nodes

cdata()

to select CDATA nodes

data()

to select DATA nodes

processing-instruction() to select processing instruction nodes
to keep all nodes (independently of the type and name)node()

19.1.2.3 Abbreviated notation
Common combinations of axis-node tests have an abbreviated notation. The supported abbrevations are:.

is equivalent to self::node()..

is equivalent to parent::node()//(used in place of /) is the same as descendant-or-self::node()

19.1.2.4 Predicate
A predicate is a Boolean expression enclosed in square brakets. The expression evaluator supports
Boolean, text and numerical values (encoded as floating point numbers). Type conversions are implicit
and implied by the operators: for instance the additive operator "+" operates on numbers, as aconsequence its operands are systematically converted to numbers. Constant strings must be quoted
using either single or double quotes.
The notation @attname designates the attribute which name is "attname": if used where a Boolean
value is expected, it is true if the attribute is defined for the current node. Otherwise, this is the value ofthe attribute.

Fair Isaac Corporation Proprietary Information

638

Chapter 19: mmxml

Supported arithmetic operators include +, -, *, div (division on floating point numbers, not integral division
as in Mosel!), mod (modulo on floating point numbers). Boolean expressions can be composed using
and and or; the usual comparators <, <=, >=, >, =, <>(or !=) can be applied to numbers. Note that equality
testing (= and <>) is defined for all types. The following predefined functions can also be used in
expressions:
name()

name of the node

string()value of the node

number()value of the node as a number

boolean()value of the node as a Boolean

position()

position of the current node in the selected set (first node has
position 1)

not(boolexp)

true if ’boolexp’ is false, false otherwise

true()

value true

false()

value false

string-length()/getsize()

length of the node value

string-length(strexp)/getsize(strexp)
starts-with(strexp1,strexp2)
contains(strexp1,strexp2)

length of the text passed as parametertrue if text ’strexp1’ starts with text ’strexp2’

true if text ’strexp1’ contains text ’strexp2’

round(numexp)

rounded value of ’numexp’

floor(numexp)

floor value of ’numexp’

ceiling(numexp)/ceil(numexpr)
abs(numexp)

ceil value of ’numexp’

absolute value of ’numexp’

If the predicate [expr] is not a Boolean value, the whole expression is interpreted as[position()=expr].

19.1.3 JSON document as an XML tree
In addition to XML documents mmxml can also load and generate JSON documents represented as XML
trees such that the information contained in the document can be handled using the routines published bythis module. The procedure jsonload parses a JSON file that it maps to the internal XML representation
using the following conventions: every JSON syntactic entity is converted to an XML element the value of
which corresponds to the associated JSON value. The type of the value is identified via the attribute"jst" that can be "str" (string), "num" (numeric), "boo" (Boolean), "nul" (null object), "obj"(object) or "arr" (array). Names of object components can be mapped to either the name of the XML
element or to an attribute (the behaviour of the parser is selected via an option of jsonload).
For instance, consider the following JSON document:[{"name": "bob","age": 25,"student": true,"phone": [{ "type": "home", "number": "1234567900" },{ "type": "work", "number": "6789012345" }]}]Fair Isaac Corporation Proprietary Information

639

Chapter 19: mmxml

It will be represented by the following XML document when object member names are turned into XML
element names:<?xml version="1.0" encoding="iso-8859-1"?><jsv jst="arr"><jsv jst="obj"><name jst="str">bob</name><age jst="num">25</age><student jst="boo">true</student><phone jst="arr"><jsv jst="obj"><type jst="str">home</type><number jst="str">1234567900</number></jsv><jsv jst="obj"><type jst="str">work</type><number jst="str">6789012345</number></jsv></phone></jsv></jsv>

Note that with this representation the generated XML document is not necessarily valid XML (thismapping can for instance produce XML elements that have a number as name) and trying to export a
JSON document using the save procedure may produce a file that cannot be processed by an XML
parser. Using the second mode of operation avoids this problem: all elements are named "jsv" andobject names are represented by attributes. The resulting XML document is larger than the one producedwith the first mode:<?xml version="1.0" encoding="iso-8859-1"?><jsv jst="arr"><jsv jst="obj"><jsv jst="str" name="name">bob</jsv><jsv jst="num" name="age">25</jsv><jsv jst="boo" name="student">true</jsv><jsv jst="arr" name="phone"><jsv jst="obj"><jsv jst="str" name="type">home</jsv><jsv jst="str" name="number">1234567900</jsv></jsv><jsv jst="obj"><jsv jst="str" name="type">work</jsv><jsv jst="str" name="number">6789012345</jsv></jsv></jsv></jsv></jsv>

Assuming an XML tree has been built using the above conventions, the procedure jsonsave can beused to generate a JSON document. The XML document may combine the two representations describedabove and in most cases the jst attribute can be omitted. Therefore, jsonsave will produce the same
JSON document as the example shown at the start of this section from the following XML file:<?xml version="1.0" encoding="iso-8859-1"?>
<jsv>
<jsv>
<name>bob</name><jsv name="age">25</jsv><student>true</student><jsv name="phone"><jsv><type>home</type><jsv name="number" jst="str">1234567900</jsv></jsv>

Fair Isaac Corporation Proprietary Information

640

Chapter 19: mmxml<jsv><jsv name="type">work</jsv><jsv name="number" jst="str">6789012345</jsv></jsv></jsv></jsv></jsv>

19.2 New functionality for the Mosel language
19.2.1 The type xmldoc
The type xmldoc represents an XML document stored in the form of a tree. Each node of the tree is
identified by a node number (an integer) that is attached to the document (i.e. a node number cannot beshared by different documents and in two different documents the same number represents two different
nodes). The root node of the document has number 0: the content of the document is stored as thechildren of this root node. In addition to structural properties (e.g. name, value, successor, parent) nodes
have 2 formatting properties: vertical (setvspace) and horizontal (sethspace) spacing. These
indications are used when the document is saved in text form for controling how the resulting text has tobe organised (see save). The general formatting policy is defined by a set of document settings:
indentation mode (setindentmode), indentation skip (setindentskip) and line length(setlinelen). Also used when exporting the documents are the XML version (setxmlversion),standalone status (setstandalone) and encoding (setencoding).

19.3 Procedures and functions
addnodeAdd a node to a document tree.

p. 643

copynode

Copy a node.

p. 645delattr

Delete an attribute of an element node.

p. 646delnodeDelete a node in a document tree.

p. 647getattr

Get the value of an attribute.

p. 648getencoding

Get the character encoding of the document.

p. 650getfirstattr

Get the first attribute of an element node.

p. 653getfirstchildGet the first child of an element node.

p. 655gethspace

Get horizontal spacing of a node.

p. 663getindentmodeGet indent mode of the document.

p. 665getindentskip

Get the size of an indentation step.

p. 666getlastchildGet the last child of an element node.

p. 656getlinelen

Get the length of a line.

p. 667getmaxnodes

Get the number of nodes currently allocated for a document.

p. 668getnameGet the name of a node.

p. 651getnext

Get the successor of a node.

p. 654

getnodeGet the first node returned by a path specification.

p. 657

getnodesGet the list of nodes returned by a path specification.

p. 658Fair Isaac Corporation Proprietary Information

641

Chapter 19: mmxml

getparent

Get the parent of a node.

p. 659getsizeGet the size of a document.

p. 669getstandalone

Get the standalone flag of the document.

p. 661gettypeGet the type of a node.

p. 660getvalueGet the value of a node.

p. 652

getvspaceGet vertical spacing of a node.

p. 664getxmlversion

Get the XML version of the document.

p. 662jsonload

Load a JSON document.

p. 670jsonparse

Parse a JSON document.

p. 671

jsonsave

Save a JSON document.

p. 673load

Load an XML document.

p. 674save

Save an XML document.

p. 675

setattr

Set the value of an attribute.

p. 676setencoding

Set the character encoding of the document.

p. 677sethspace

Set horizontal spacing of a node.

p. 681

setindentmodeSet indent mode for the document.

p. 684setindentskip

Set the size of an indentation step.

p. 685setlinelen

Set the length of a line.

p. 686setmaxnodes

Set the number of allocated nodes for a document.

p. 678setnameSet the name of a node.

p. 679setstandalone

Set the standalone flag of the document.

p. 687

setvalue

Set the value of a node.

p. 680setvspaceSet vertical spacing of a node.

p. 683

setxmlversion

Set the XML version of the document.

p. 688testattr

Test existence of an attribute for a given element node.

p. 649xmlattr

Get an attribute during parsing of an element.

p. 689xmldecode

Decode a text string for XML.

p. 691

xmlencode

Encode a text string for XML.

p. 690xmlparse

Parse an XML document.

p. 692

Fair Isaac Corporation Proprietary Information

642

Chapter 19: mmxml

addnodePurpose
Synopsis

Add a node to a document tree.
function addnode(doc:xmldoc, n:integer, where:integer, type:integer,
name:string, value:text):integerfunction addnode(doc:xmldoc, n:integer, where:integer, type:integer,
nameval:string|text):integerfunction addnode(doc:xmldoc, n:integer, type:integer, name:string,value:text):integerfunction addnode(doc:xmldoc, n:integer, type:integer,
nameval:string|text):integerfunction addnode(doc:xmldoc, n:integer, type:integer):integerfunction addnode(doc:xmldoc, n:integer, name:string,value:text|string|boolean|integer|real):integer

Arguments
doc
n
where

type

Document to use
Node number where to attach the new node
How to attach the new node to the node n:
XML_FIRST
as the first element of the list where node n is located
XML_LAST
as the last element of the list where node n is located
XML_NEXT
after node n
XML_FIRSTCHILD as the first child of node n (node n must be an element)
XML_LASTCHILD
as the last child of node n (node n must be an element)
When the function is used without this parameter, XML_LASTCHILD is assumed.
Type of node to add:

XML_ELTan element
XML_TXTa text block
XML_CDATAa CDATA section
XML_COM
a comment
XML_DATA
non interpreted data
XML_PINST
processing instruction
When the function is used without this parameter, XML_ELT is assumed.
name
Name associated to the new node. Only element and processing instruction nodes have a
name
value
Value associated to the new node. An element node does not have any value: if thisparameter is provided for a node of this type, an additional text node with the specified value
is added as the first child of the new node
nameval If the type is XML_ELT or XML_PINST this parameter is used as the name of this node.
Otherwise it is the value of the new node
Return value
Number of the newly created node within the document.
ExampleThe following code extract appends a new node ’employee’ as last child to the node APAC. It shows how
to use diffrent versions of addnode for the creation of descendants of the new node.
declarations
DB: xmldoc

Fair Isaac Corporation Proprietary Information

643

Chapter 19: mmxml

APAC, NewPers, n, k: integer
end-declarations
APAC:= getnode(DB, "personnelList/region[@id='APAC']")! Append a new node to 'APAC' and set its attribute 'id':
NewPers:= addnode(DB, APAC, XML_LASTCHILD, XML_ELT, "employee")setattr(DB, NewPers, "id", "T432")! Create a comment:n:= addnode(DB, NewPers, XML_COM, "This is a new employee")! Add 2 nodes containing the specified text (nodes):n:= addnode(DB, NewPers, XML_ELT, "startDate", text(2012))
n:= addnode(DB, NewPers, XML_ELT, "name", "Tim")! Add an empty node, then set its contents:
n:= addnode(DB, NewPers, XML_ELT, "address")setvalue(DB, n, "Sydney")! Add an empty node, then create its contents as a text node:n:= addnode(DB, NewPers, XML_ELT, "language")k:= addnode(DB, n, XML_TXT, "English")
XML resulting from this code:<employee id="T432"><!--This is a new employee--><startDate>2012</startDate><name>Tim</name><address>Sydney</address><language>English</language></employee>
Further information
1. An element or processing instruction node must be named: trying to create a node of these types with anempty name will cause an error.
2. It is not possible to add attributes with this function. Use setattr for this purpose.
Related topics
copynode, delnode
Modulemmxml

Fair Isaac Corporation Proprietary Information

644

Chapter 19: mmxml

copynode
Purpose
Synopsis

Copy a node.
function copynode(src:xmldoc, s:integer, dst:xmldoc, d:integer,
where:integer):integer

Arguments
src
s
dst
d
where

Document of node to be copied
Number of the node to copy
Destination document
Node number where to attach the new node in the destination document
How to attach the copy of the source node to the node d:
XML_FIRST
XML_LAST
XML_NEXT
XML_FIRSTCHILD
XML_LASTCHILD

Exampleas the first element of the list where node d is locatedas the last element of the list where node d is locatedafter node das the first child of node d (node d must be an element)
as the last child of node d (node d must be an element)

The following code extract shows how to move (copy node, then delete original) and edit a node with allits descendants
declarations
DB: xmldoc
APAC, NewPers, Pers: integer
end-declarations! Retrieve destination region node
APAC:= getnode(DB, "personnelList/region[@id='APAC']")! Retrieve employee record (node) for 'Lisa'
Pers:=
getnode(DB, "personnelList/region/employee/name[string()='Lisa']/..")! Employee Lisa moves to Delhi: copy node & delete in original location
NewPers:= copynode(DB, Pers, DB, APAC, XML_LASTCHILD)
delnode(DB, Pers)! Update the 'address' information
setvalue(DB, getnode(DB, NewPers, "address"), "Delhi")

Further information
This routine copies the node as well as all of its descendants if it is an element node. Source anddestination documents may be the same.
Related topics
addnode, delnode
Modulemmxml

Fair Isaac Corporation Proprietary Information

645

Chapter 19: mmxml

delattr
Purpose
Synopsis

Delete an attribute of an element node.
procedure delattr(doc:xmldoc, n:integer, name:string)Arguments
doc
n
name
ExampleDocument to use
Element node to modify
Name of the attribute to remove

See testattr.

Further information
This routine has no effect if the element does not have any attribute of the specified name.
Related topics
setattrModulemmxml

Fair Isaac Corporation Proprietary Information

646

Chapter 19: mmxml

delnodePurpose
Synopsis

Delete a node in a document tree.
procedure delnode(doc:xmldoc, n:integer)

Arguments
docnExampleDocument to use
Number of the node to delete

See copynode.

Further information
This routine deletes the node as well as all of its descendants if it is an element node.
Related topics
addnode, copynode
Modulemmxml

Fair Isaac Corporation Proprietary Information

647

Chapter 19: mmxml

getattr
Purpose
Synopsis

Get the value of an attribute.
function getattr(doc:xmldoc, n:integer, name:string):text
function getboolattr(doc:xmldoc, n:integer, name:string):booleanfunction getintattr(doc:xmldoc, n:integer, name:string):integerfunction getrealattr(doc:xmldoc, n:integer, name:string):realfunction getstrattr(doc:xmldoc, n:integer, name:string):stringArguments
doc
n
name

Document to use
Node number (must be an element)
Name of the attribute

Return value
The value of the attribute or an empty string, 0 or false depending on the expected type.
ExampleThe following code extract prints the contents of ’name’ (leftbound in a 10 character space) and theattributes ’id’ of all ’employee’ nodes, and the ’id’ of their parent node.
declarations
DB: xmldoc
AllEmployees: list of integer
end-declarations
getnodes(DB, "personnelList/region/employee", AllEmployees)
forall(p in AllEmployees)
writeln(textfmt(getvalue(DB, getnode(DB, p, "name")), -10),"(ID: ", getattr(DB,p,"id"), ") ","region: ", getattr(DB, getparent(DB, p), "id"))
Output produced by this code will look as follows:
Lisa
James
Sarah

(ID: L234) region: EMEA
(ID: J876) region: APAC
(ID: S678) region: AM

Further information
1. Values of attributes are stored as text objects: the first version of the routine returns a reference to theobject containing the attribute value. Modifying this text will also alter the attribute value. Using one of
the alternative versions of this routine allows to avoid having to perform a type conversion. Note howeverthat no validation is performed and a conversion error will result in a 0 for a number and false for a
Boolean without raising any error.
2. A default value (empty string, 0 or false) is returned if the requested attribute is not defined. Use function
testattr to check whether a given node has a particular attribute.
Related topics
setattr, testattr, getfirstattr
Modulemmxml

Fair Isaac Corporation Proprietary Information

648

Chapter 19: mmxml

testattr
Purpose
Synopsis

Test existence of an attribute for a given element node.
function testattr(doc:xmldoc, n:integer, name:string):boolean

Arguments
doc
n
name

Document to use
Node number (must be an element)
Name of the attribute

Return value
true if the requested attribute is defined for the node.
ExampleThis example tests whether the attribute ’parttime’ is defined for an employee, and if this is the case theattribute gets deleted after printing the name of the employee.
declarations
DB: xmldoc
AllEmployees: list of integer
end-declarations
getnodes(DB, "personnelList/region/employee", AllEmployees)
forall(p in AllEmployees | testattr(DB, p, "parttime")) dowriteln(getvalue(DB, getnode(DB, p, "name")))delattr(DB, p, "parttime")
end-doRelated topics
setattr, getattr
Modulemmxml

Fair Isaac Corporation Proprietary Information

649

Chapter 19: mmxml

getencoding
Purpose
Synopsis

Get the character encoding of the document.
function getencoding(doc:xmldoc):stringArgument
doc

Document to use

Return value
Character encoding of the document
Related topics
getstandalone, getxmlversion
Modulemmxml

Fair Isaac Corporation Proprietary Information

650

Chapter 19: mmxml

getname
Purpose
Synopsis

Get the name of a node.
function getname(doc:xmldoc, n:integer):stringArguments
docnDocument to use
Node number

Return value
The name of the node depending on the node type:
XML_ELTname of the element section
XML_TXT"#text"
XML_CDATA"#cdata-section"
XML_COM"#comment"
XML_DATA"#data"XML_PINST
processing instruction target
XML_ATTR
name of the attribute
ExampleThe following example collects the names of all element nodes occurring in a document.
declarations
DB: xmldoc
NodeList: list of integer
NodeNames: set of string
end-declarations
getnodes(DB, "/descendant-or-self::node()", NodeList)
NodeNames:= union(r in NodeList | gettype(DB,r)=XML_ELT) {getname(DB,r)}writeln("Names of element nodes: ", NodeNames)

Further information
Only element, attribute and processing instruction nodes have a name, for all other node types the above
listed constant name is returned.
Related topics
gettype, getvalue, setname
Modulemmxml

Fair Isaac Corporation Proprietary Information

651

Chapter 19: mmxml

getvalue
Purpose
Synopsis

Get the value of a node.
function getvalue(doc:xmldoc, n:integer):text
function getboolvalue(doc:xmldoc, n:integer):booleanfunction getintvalue(doc:xmldoc, n:integer):integerfunction getrealvalue(doc:xmldoc, n:integer):realfunction getstrvalue(doc:xmldoc, n:integer):stringArguments
docnDocument to use
Node number

Return value
The value of the node.
ExampleThis code prints out the name of the employee with attribute id="T345".
declarations
DB: xmldoc
end-declarations
writeln("Person with id='T345': ", getvalue(DB, getnode(DB,"personnelList/region/employee[@id='T345']/name") ))Further information
1. Values of nodes are stored as text objects: the first version of the routine returns a reference to theobject containing the value. Modifying this text will also alter the node value. Using one of the alternative
versions of this routine allows to avoid having to perform a type conversion. Note however that novalidation is performed and a conversion error will result in a 0 for a number and false for a Boolean
without raising any error.
2. Element nodes have no value: the returned value corresponds to the value of the first child of type text of
this element (or an empty string if no such child can be found).
Related topics
gettype, getname, setvalue
Modulemmxml

Fair Isaac Corporation Proprietary Information

652

Chapter 19: mmxml

getfirstattr
Purpose
Synopsis

Get the first attribute of an element node.
function getfirstattr(doc:xmldoc, n:integer):integer

Arguments
docnDocument to use
Node number (must be an element)

Return value
The node number of the first attribute of the element node provided or -1 if there is no attribute.
ExampleThe following example displays all attributes of node e:
declarations
DB: xmldoc
a,e: integer
end-declarations
a:=getfirstattr(DB,e)while(a>0) do
writeln(getname(DB,a), "=", getvalue(DB,a))a:=getnext(DB,a)end-doFurther information
Attributes are represented by nodes of type XML_ATTR: all node-related routines can be applied toattribute nodes.
Related topics
getnext, getfirstchild, getlastchild, getparent
Modulemmxml

Fair Isaac Corporation Proprietary Information

653

Chapter 19: mmxml

getnext
Purpose
Synopsis

Get the successor of a node.
function getnext(doc:xmldoc, n:integer):integer

Arguments
docnDocument to use
Node number

Return value
The node number of the following node or -1 if the current node is the last of the list.
ExampleThis example enumerates all child nodes within a specific region and displays the ’id’ for all ’employee’nodes on a single line, adding a line break after the last name:declarations
DB: xmldoc
APAC, Pers: integer
end-declarations
APAC:= getnode(DB, "personnelList/region[@id='APAC']")
Pers:= getfirstchild(DB, APAC)
LastPers:= getlastchild(DB, APAC)
while(Pers>-1) do
if getname(DB, Pers)="employee" thenwrite(" ", getattr(DB,Pers,"id"))
end-ifif Pers=LastPers then writeln; end-if
Pers:= getnext(DB, Pers)
end-doFurther information
Node numbers returned by Mosel are not directly related to the order of nodes within the XML document(i.e. a larger node number does not imply that a node succeeds a node with a smaller number).
Related topics
getfirstattr, getfirstchild, getlastchild, getparent
Modulemmxml

Fair Isaac Corporation Proprietary Information

654

Chapter 19: mmxml

getfirstchild
Purpose
Synopsis

Get the first child of an element node.
function getfirstchild(doc:xmldoc, n:integer):integer

Arguments
docnDocument to use
Node number (must be an element)

Return value
The node number of the first child or -1 if there is no child.
ExampleSee getnext.

Related topics
getfirstattr, getnext, getlastchild, getparent
Modulemmxml

Fair Isaac Corporation Proprietary Information

655

Chapter 19: mmxml

getlastchild
Purpose
Synopsis

Get the last child of an element node.
function getlastchild(doc:xmldoc, n:integer):integer

Arguments
docnDocument to use
Node number (must be an element)

Return value
The node number of the last child or -1 if there is no child.
ExampleSee getnext.

Related topics
getfirstattr, getfirstchild, getnext, getparent
Modulemmxml

Fair Isaac Corporation Proprietary Information

656

Chapter 19: mmxml

getnodePurpose
Synopsis

Get the first node returned by a path specification.
function getnode(doc:xmldoc, n:integer, p:string|text):integerfunction getnode(doc:xmldoc, n:integer):integerfunction getnode(doc:xmldoc, p:string):integer

Arguments
docnpDocument to use
Base node number (0 when not provided)
Path to the node ("⁎" when not provided)

Return value
The node number of the first node selected by the path p; -1 if no node can be found.
ExampleThe following example shows different forms of the getnode function.
declarations
DB: xmldoc
Root, EMEA: integer
end-declarations! Get the first element that is not a comment or a processing instruction
Root:= getnode(DB,"⁎")! Same as: getnode(DB,0,"⁎")! Get the 'region' node with id=EMEA
EMEA:= getnode(DB, "personnelList/region[@id='EMEA']")! Check for employee record (node) for 'Sam' under 'EMEA'
if getnode(DB, EMEA, "employee/name[string()='Sam']/..")<0 thenwriteln("No employee called 'Sam' in EMEA")
end-ifFurther information
1. Refer to section 19.1.2 for a detailed description of the syntax and semantic of XML paths.
2. This function is the same as getfirstchild when used without path specification.
Related topics
getnodes, getfirstchild
Modulemmxml

Fair Isaac Corporation Proprietary Information

657

Chapter 19: mmxml

getnodesPurpose
Synopsis

Get the list of nodes returned by a path specification.
procedure getnodes(doc:xmldoc, n:integer, p:string|text, l:list of integer)
procedure getnodes(doc:xmldoc, p:string, l:list of integer)
procedure getnodes(doc:xmldoc, n:integer, l:list of integer)

Arguments
docnplExampleDocument to use
Base node number (0 when not provided)
Path to the node ("⁎" when not provided)
List where result is returned

Here are a number of examples how to retrieve nodes with specific properties:
declarations
DB: xmldoc
Employees, AllEmployees: list of integer
end-declarations! Get all employees in the Americas
getnodes(DB, "personnelList/region[@id='AM']/employee", Employees)! All employees who started before 2005
getnodes(DB, "personnelList/region/employee/startDate[number()<2005]/..",
Employees)! All employees whose names start with "J"getnodes(DB, "personnelList/region/employee", AllEmployees)
forall(n in AllEmployees) do
getnodes(DB, n, "./name[starts-with(string(),'J')]/..", Employees)
forall(p in Employees) save(DB, p, "")end-do! Employees speaking at least 3 languages (=have a third "language" entry)
getnodes(DB, "personnelList/region/employee/language[position()=3]/..",
Employees)

Further information
1. Refer to section 19.1.2 for a detailed description of the syntax and semantic of XML paths.
2. This function resets the list it receives as parameter: the provided list is returned empty if no node can befound.
Related topics
getnodeModulemmxml

Fair Isaac Corporation Proprietary Information

658

Chapter 19: mmxml

getparent
Purpose
Synopsis

Get the parent of a node.
function getparent(doc:xmldoc, n:integer):integer

Arguments
docnDocument to use
Node number

Return value
The node number of the parent node or -1 if n=0 (root node has no parent).
ExampleSee getattr.

Related topics
getfirstattr, getfirstchild, getlastchild, getnext
Modulemmxml

Fair Isaac Corporation Proprietary Information

659

Chapter 19: mmxml

gettype
Purpose
Synopsis

Get the type of a node.
function gettype(doc:xmldoc, n:integer):integer

Arguments
docnDocument to use
Node number

Return value
The type of the node:
XML_ELTan element
XML_TXTa text
XML_CDATAa CDATA section
XML_COM
a comment
XML_DATAa data section
XML_PINST
a processing instruction
XML_ATTRan attribute-1
if the node number is not valid
ExampleSee getname.

Further information
This function returns -1 if the provided node number is not valid: this feature can be used to verify thevalidity of a node number before using it with other functions.
Related topics
getname, getvalue
Modulemmxml

Fair Isaac Corporation Proprietary Information

660

Chapter 19: mmxml

getstandalone
Purpose
Synopsis

Get the standalone flag of the document.
function getstandalone(doc:xmldoc):integer

Argument
doc

Document to use

Return valueStandalone flag:-1
flag not specified
0
standalone=no1
standalone=yes
Further information
The value of this flag is not used by mmxml. This is just an information to be saved in the header of the
XML document. The default value for this flag is -1.
Related topics
getencoding, getxmlversion
Modulemmxml

Fair Isaac Corporation Proprietary Information

661

Chapter 19: mmxml

getxmlversion
Purpose
Synopsis

Get the XML version of the document.
function getxmlversion(doc:xmldoc):stringArgument
doc

Document to use

Return value
XML version as a text string
Further information
The XML version number is not used by mmxml. This is just an information to be saved in the header ofthe XML document. The default value for this option is 1.0.
Related topics
getencoding, getstandalone
Modulemmxml

Fair Isaac Corporation Proprietary Information

662

Chapter 19: mmxml

gethspace
Purpose
Synopsis

Get horizontal spacing of a node.
function gethspace(doc:xmldoc, n:integer):integer

Arguments
docnDocument to use
Node number

Return value
Number of spaces inserted before the node output
Further information
This spacing indicates the number of spaces to insert before displaying the node from the start of a newline when outputing the document. The horizontal spacing setting is only used when the indentation is inmanual mode (see setindentmode).
Related topics
getvspace, getindentmode
Modulemmxml

Fair Isaac Corporation Proprietary Information

663

Chapter 19: mmxml

getvspace
Purpose
Synopsis

Get vertical spacing of a node.
function getvspace(doc:xmldoc, n:integer):integer

Arguments
docnDocument to use
Node number

Return value
Number of carriage returns inserted before the node output
Further information
This spacing indicates the number of empty lines to insert before displaying the node when outputing the
document. The vertical spacing setting is only used when the indentation is in manual mode (seesetindentmode).
Related topics
gethspace, getindentmode
Modulemmxml

Fair Isaac Corporation Proprietary Information

664

Chapter 19: mmxml

getindentmodePurpose
Synopsis

Get indent mode of the document.
function getindentmode(doc:xmldoc):integer

Argument
doc

Document to use

Return value
Indent mode:
XML_AUTO
XML_NONE
XML_MANUAL

automatic indentation
no formatting
use vertical/horizontal spacing settings of each node

Related topics
setindentmode, getindentskip, getlinelen
Modulemmxml

Fair Isaac Corporation Proprietary Information

665

Chapter 19: mmxml

getindentskip
Purpose
Synopsis

Get the size of an indentation step.
function getindentskip(doc:xmldoc):integer

Argument
doc

Document to use

Return value
Number of spaces to add for each indentation
Related topics
setindentskip, getindentmode, getlinelen
Modulemmxml

Fair Isaac Corporation Proprietary Information

666

Chapter 19: mmxml

getlinelen
Purpose
Synopsis

Get the length of a line.
function getlinelen(doc:xmldoc):integer

Argument
doc

Document to use

Return value
Length of a line in characters for outputting the XML document
Related topics
setlinelen, getindentmode, getindentskip
Modulemmxml

Fair Isaac Corporation Proprietary Information

667

Chapter 19: mmxml

getmaxnodes
Purpose
Synopsis

Get the number of nodes currently allocated for a document.
function getmaxnodes(doc:xmldoc):integer

Argument
doc

Document to use

Return value
Number of nodes currently allocatedFurther information
This function returns the amount of memory (in number of nodes) currently allocated for a given
document. This amount may be larger than the amount actually in use.
Related topics
setmaxnodes, getsize
Modulemmxml

Fair Isaac Corporation Proprietary Information

668

Chapter 19: mmxml

getsize
Purpose
Synopsis

Get the size of a document.
function getsize(doc:xmldoc):integer

Argument
doc

Document to use

Return value
The number of nodes used by the document.
Related topics
getmaxnodes
Modulemmxml

Fair Isaac Corporation Proprietary Information

669

Chapter 19: mmxml

jsonloadPurpose
Synopsis

Load a JSON document.
procedure jsonload(doc:xmldoc, fname:text)
procedure jsonload(doc:xmldoc, fname:text, mode:integer)

Arguments
doc
Document to use
fname File name of the document to loadmode How to handle JSON object names:
0
Object names are converted to XML element names (default)
1
Object names are saved as the attribute "name"
Further information
1. This routine replaces the content of the provided document object with the JSON file given as second
argument. If the file cannot be accessed or if an error occurs during reading, the procedure generates an
IO error (which may be intercepted if the control parameter ioctrl is true).
2. The parser converts the original JSON document into an XML representation (See Section 19.1.3). Using
the version of the procedure without the mode argument is the same as using 0 for this parameter.
Related topics
jsonsave, jsonparse, load
Modulemmxml

Fair Isaac Corporation Proprietary Information

670

Chapter 19: mmxml

jsonparse
Purpose
Synopsis

Parse a JSON document.
function jsonparse(afct:array(range) of string|function,ctx:ctxtype):
integer

Arguments
afct

ctx

Event function table. Each entry of this array is the name of or a reference to the function to callwhen the corresponding event occurs. The expected events are (all of these entries are optional):
JSON_FCT_OPEN_OBJ
Opening of an object
JSON_FCT_CLOSE_OBJ Closing of an object
JSON_FCT_OPEN_ARR
Opening of an array
JSON_FCT_CLOSE_ARR Closing of an array
JSON_FCT_TEXT
A textual value
JSON_FCT_NUM
A numerical value
JSON_FCT_BOOL
A Boolean value
JSON_FCT_NULL
The null value
Value passed as firt argument of all event functions

Return value
0 if successful, 1 in case of parsing error or a non-zero value returned by an event function
ExampleThis example displays values of object members "name" and "age" of a JSON document:
declarations
afct:array(range) of strings_ctx=record
cnt:integer
end-record
c:s_ctx
end-declarations

public function setvalue_all(ctx:s_ctx,name:text,type:integer,val:text):integer
if name="name" or name="age" thenwriteln(name,":",val)
ctx.cnt+=1
end-ifend-function
afct(JSON_FCT_TEXT):="setvalue_all"fopen("mydoc.json",F_INPUT)
rts:=jsonparse(afct,c)fclose(F_INPUT)
writeln("line count:",c.cnt)

Fair Isaac Corporation Proprietary Information! A value as a text

671

Chapter 19: mmxml

Further information
1. This function is an alternative approach to jsonload for processing JSON documents: instead ofloading into memory the entire document this function calls a dedicated routine whenever it identifies a
JSON entity. For instance a specific function is called when an object is open and another one when it isclosed. It is up to the Mosel program to decide how to handle the document via these event handling
functions.
2. To each event type corresponds a specific function signature. These functions return an integer that
decides whether parsing should continue: a non-zero value will cause the parsing to cancel (this value isused as the return value of jsonparse). The expected function signatures are:
JSON_FCT_OPEN_OBJ

function open_object(ctx:ctxtype, name:text):integer

JSON_FCT_CLOSE_OBJ

function close_object(ctx:ctxtype):integer

JSON_FCT_OPEN_ARR

function open_array(ctx:ctxtype, name:text):integer

JSON_FCT_CLOSE_ARR

function close_array(ctx:ctxtype):integer

JSON_FCT_TEXT function text_val(ctx:ctxtype, name:text, type:integer,
val:text):integer
JSON_FCT_NUM

function num_val(ctx:ctxtype, name:text, val:real):integer

JSON_FCT_BOOL function bool_val(ctx:ctxtype, name:text,
val:boolean):integer
JSON_FCT_NULL

function null_val(ctx:ctxtype, name:text):integer

In addition to the pre-defined arguments these functions take a context as their first parameter. Thisvariable (that can be of any type) is provided to the jsonparse routine and can be used by the event
functions for storing progress information.
The name argument is not empty only when the value corresponds to an object member: in this case thisparameter is the label of this member. The type argument passed to the text_val function indicates thetype of the data (0 for null, 1 for text, 2 for numerical and 3 for Boolean): this function is used with thetextual representation of the value when the required type-specific function is not available. For instancethis function will be called with type=3 if a Boolean value has been read and the entry JSON_FCT_BOOL
is not defined in the function table.
3. An error message indicating the location of the error is displayed when the parsing fails or if an event
function returns a negative value (a positive value also interrupts parsing but no message is displayed).
Related topics
jsonload
Modulemmxml

Fair Isaac Corporation Proprietary Information

672

Chapter 19: mmxml

jsonsave
Purpose
Synopsis

Save a JSON document.
procedure jsonsave(doc:xmldoc, fname:text)

Arguments
doc
Document to savefname Destination file name
Further information
1. This routine generates a JSON file from the provided xmldoc object. It is assumed that the document isbuilt according to the JSON conventions (See Section 19.1.3). The result is undefined if the conventions
are not respected.
2. This procedure does not require that the elements of the tree are typed using the "jst" attribute: thetype is deduced from the value of the node when this attribute is missing. Moreover, both object member
naming conventions can be used: when outputing an object, the member name can be taken either fromthe element name or from the attribute "name". If both are available, the attribute takes precedence.
3. An IO error will be raised if the destination file cannot be accessed.
Related topics
jsonload, save
Modulemmxml

Fair Isaac Corporation Proprietary Information

673

Chapter 19: mmxml

load
Purpose
Synopsis

Load an XML document.
procedure load(doc:xmldoc, fname:text)

Arguments
doc
Document to use
fname File name of the document to load
ExampleThis code reads in a document and displays its contents on screen applying automatic formatting
instead of its original formatting.
declarations
DB: xmldoc
end-declarations! Reading data from an XML fileload(DB, "refexample.xml")! Set indentation mode for XML output (default after load: MANUAL)
setindentmode(DB, XML_AUTO)! Display document contents on screen
save(DB, "")Further information
This routine replaces the content of the provided document object with the XML file given as second
argument: all properties of the document are reset to their default value and the indentation mode is set
to XML_MANUAL (see setindentmode). Vertical and horizontal spacing of each loaded node are set inorder to preserve as much as possible the original formatting of the document. If the file cannot be
accessed or if an error occurs during reading, the procedure generates an IO error (which may beintercepted if the control parameter ioctrl is true).
Related topics
save, xmlparse, jsonload
Modulemmxml

Fair Isaac Corporation Proprietary Information

674

Chapter 19: mmxml

save
Purpose
Synopsis

Save an XML document.
procedure save(doc:xmldoc, fname:text)
procedure save(doc:xmldoc, n:integer, fname:text)

Arguments
doc
n
fname
ExampleDocument to save
Node number to use as root node (default: 0)
Destination file name

This example shows the two versions of this procedure.
declarations
DB: xmldoc
Pers: integer
end-declarations! Save XML document to file 'results.xml'
save(DB, "results.xml")! Display a subtree on screen
Pers:= getnode(DB, "personnelList/region/employee[@id='T345']")save(DB, Pers, "")Further information
1. This routine generates an XML file from the provided xmldoc object. The XML header is produced using
the properties defined with setencoding, setxmlversion and setstandalone. No header isemitted if either the encoding or the version is an empty string.
2. When providing an alternative root node, only the specified part of the document tree is exported without
any XML header.
3. The document is formatted according to the indentation mode and its associated settings (seesetindentmode); XML control characters are encoded (see xmlencode).
4. An IO error will be raised if the destination file cannot be accessed.
Related topics
load, save
Modulemmxml

Fair Isaac Corporation Proprietary Information

675

Chapter 19: mmxml

setattr
Purpose
Synopsis

Set the value of an attribute.
procedure setattr(doc:xmldoc, n:integer, name:string,v:text|string|boolean|integer|real)

Arguments
doc
n
name
v
ExampleDocument to use
Node number (must be an element)
Name of the attribute
New value for the attribute

See addnode.

Further information
1. Attribute values are stored as text objects: the versions of this procedure accepting other types performthe conversion implicitly.
2. Attributes are nodes of type XML_ATTR: procedure setvalue may also be used to change the value ofan attribute.
3. Setting an empty value to an attribute does not remove this attribute from the attribute list of the element.
Use delattr for this purpose.
Related topics
getattr, delattr
Modulemmxml

Fair Isaac Corporation Proprietary Information

676

Chapter 19: mmxml

setencoding
Purpose
Synopsis

Set the character encoding of the document.
procedure setencoding(doc:xmldoc, enc:string)Arguments
doc
encDocument to use
Name of the character encoding

Further information
The default character encoding is UTF-8.
Related topics
save, setstandalone, setxmlversion
Modulemmxml

Fair Isaac Corporation Proprietary Information

677

Chapter 19: mmxml

setmaxnodes
Purpose
Synopsis

Set the number of allocated nodes for a document.
procedure setmaxnodes(doc:xmldoc, m:integer)

Arguments
docmDocument to use
Number of nodes to reserve

Further information
This procedure sets the amount of memory reserved for a document. Normally, mmxml allocatesmemory on demand but using this procedure it is possible to allocate at once a larger block of memory topossibly speedup the loading of very large documents. If the requested amount is smaller than what isrequired to represent the document currently held in the doc object, the memory block is reduced asmuch as possible such that the document can still be stored.
Related topics
getmaxnodes
Modulemmxml

Fair Isaac Corporation Proprietary Information

678

Chapter 19: mmxml

setname
Purpose
Synopsis

Set the name of a node.
procedure setname(doc:xmldoc, n:integer,name:string)Arguments
doc
n
name

Document to use
Node number (must be an element or processing instruction)
New name for the node

Further information
Only element and processing instruction nodes can be modified with this routine; for all other node types
an error will be raised.
Related topics
setvalue
Modulemmxml

Fair Isaac Corporation Proprietary Information

679

Chapter 19: mmxml

setvalue
Purpose
Synopsis

Set the value of a node.
procedure setvalue(doc:xmldoc, n:integer,
v:text|string|integer|real|boolean)

Arguments
docnv
ExampleDocument to use
Node number
New value for the nodeSee copynode.

Further information
1. Node values are stored as text objects: the versions of this procedure accepting other types performthe conversion implicitly.
2. Element nodes have no value: this procedure will modify the value of the first child text node of theelement. If no such node exists, a new text node will be added to the beginning of the list of children.
Related topics
setnameModulemmxml

Fair Isaac Corporation Proprietary Information

680

Chapter 19: mmxml

sethspace
Purpose
Synopsis

Set horizontal spacing of a node.
procedure sethspace(doc:xmldoc, n:integer, s:integer)

Arguments
docns
ExampleDocument to use
Node number
Number of spaces to put before the node output

The following example reformats the XML document layout by adding an additional line before ’region’nodes and printing three consecutive tags within ’employee’ on a single line. The indentmode is set to’manual’ in order to apply the user formatting (instead of automatic or none).
declarations
DB: xmldoc
NodeList, Employees: list of integer
end-declarations! New line without indentation for Root
setvspace(DB, Root, 1)! Add extra line in between regions, keeping original indentation
getnodes(DB, "personnelList/region", NodeList)
forall(r in NodeList) setvspace(DB, r, 2)! Spacing/indentation for 'employee' taggetnodes(DB, "personnelList/region/employee", Employees)
forall(p in Employees) do
setvspace(DB, p, 1); sethspace(DB, p, 4)! Within 'employee', display up to 3 consecutive tags on a single line
getnodes(DB, p, "child::node()[position() mod 3=1]", NodeList)
forall(r in NodeList) do
setvspace(DB, r, 1); sethspace(DB, r, 6)
end-dogetnodes(DB, p, "child::node()[position() mod 3<>1]", NodeList)
forall(r in NodeList) do
setvspace(DB, r, 0); sethspace(DB, r, 1)
end-doend-do! Set indentation mode to 'manual' to use our own formatting for display
setindentmode(DB, XML_MANUAL)
save(DB, "")Further information
This spacing indicates the number of spaces to skip from the start of a new line before displaying thenode when outputing the document. The horizontal spacing setting is only used when the indentation isin manual mode (see setindentmode).

Fair Isaac Corporation Proprietary Information

681

Chapter 19: mmxml

Related topics
setvspace, setindentmode
Modulemmxml

Fair Isaac Corporation Proprietary Information

682

Chapter 19: mmxml

setvspace
Purpose
Synopsis

Set vertical spacing of a node.
procedure setvspace(doc:xmldoc, n:integer, s:integer)

Arguments
docns
ExampleDocument to use
Node number
Number of carriage return to put before the node output

See sethspace.

Further information
This spacing indicates the number of empty lines to add before displaying the node when outputing the
document. The vertical spacing setting is only used when the indentation is in manual mode (seesetindentmode).
Related topics
sethspace, setindentmode
Modulemmxml

Fair Isaac Corporation Proprietary Information

683

Chapter 19: mmxml

setindentmodePurpose
Synopsis

Set indent mode for the document.
procedure setindentmode(doc:xmldoc, imod:integer)

Arguments
doc
imod

Document to use
Indent mode:
XML_AUTO
XML_NONE
XML_MANUAL

Exampleautomatic indentation
no formatting
use vertical/horizontal spacing of each node

See sethspace.

Further information
This parameter specifies how the XML document must be formatted by the save routine. Automaticindentation can be tuned by redefining the indent skip (setindentskip) and line length (setlinelen).
If the indent mode is set to XML_NONE, the document is exported on a single line without formatting.
Finally, with manual indenting, each node is placed according to its horizontal/vertical spacing as
specified by setvspace and sethspace.
Related topics
save, setindentskip, setlinelen
Modulemmxml

Fair Isaac Corporation Proprietary Information

684

Chapter 19: mmxml

setindentskip
Purpose
Synopsis

Set the size of an indentation step.
procedure setindentskip(doc:xmldoc, skip:integer)

Arguments
doc
skip
ExampleDocument to use
Number of spaces to add for each indentation (at least 1; default is 2)

This code reads in a document and displays its contents on screen applying automatic formatting withsingle space indentation and increased line length.
declarations
DB: xmldoc
end-declarations! Reading data from an XML fileload(DB, "refexample.xml")! Set indentation mode for XML output (default after load: MANUAL)
setindentmode(DB, XML_AUTO)! Set smaller indentation skip than default
setindentskip(DB, 1)! Increase default line length
setlinelen(DB, 80)! Display document contents on screen
save(DB, "")Further information
When the document is formatted automatically (see setindentmode) the number of spaces specified
by this procedure is added to the current margin each time a new indent step is created.
Related topics
save, setindentmode, setlinelen
Modulemmxml

Fair Isaac Corporation Proprietary Information

685

Chapter 19: mmxml

setlinelen
Purpose
Synopsis

Set the length of a line.
procedure setlinelen(doc:xmldoc, len:integer)

Argumentsdoc
len
ExampleDocument to use
Length of a line in characters (at least 1; default is 70)

See setindentskip.

Further information
When outputing the document, a line break is inserted between nodes or while displaying a list of element
attributes whenever more than the specified number of characters has been written.
Related topics
save, setindentmode, setindentskip
Modulemmxml

Fair Isaac Corporation Proprietary Information

686

Chapter 19: mmxml

setstandalone
Purpose
Synopsis

Set the standalone flag of the document.
procedure setstandalone(doc:xmldoc, std:integer)

Arguments
doc
std

Document to use
Standalone flag:-1
flag not specified
0
standalone=no1
standalone=yes

Further information
The value of this flag is not used by mmxml. This is just an information to be saved in the header of the
XML document. The default value for this flag is -1.
Related topics
save, setencoding, setxmlversion
Modulemmxml

Fair Isaac Corporation Proprietary Information

687

Chapter 19: mmxml

setxmlversion
Purpose
Synopsis

Set the XML version of the document.
procedure setxmlversion(doc:xmldoc, xv:string)Arguments
doc
xv

Document to use
XML version

Further information
The XML version number is not used by mmxml. This is just an information to be saved in the header ofthe XML document. The default value for this option is 1.0.
Related topics
save, setencoding, setstandalone
Modulemmxml

Fair Isaac Corporation Proprietary Information

688

Chapter 19: mmxml

xmlattr
Purpose
Synopsis

Get an attribute during parsing of an element.
procedure xmlattr(ndx:integer, name:text, val:text)
procedure xmlattr(aname:string, val:text)

Arguments
ndx
name
val
aname

Attribute index
Attribute name (returned by the procedure)
Attribute value (returned by the procedure)
Attribute name (provided to the procedure)

Further information
1. This procedure can only be used from the open element function while parsing an XML document withthe xmlparse function.
2. With the first syntax, the attribute index ndx is returned by the procedure (both its name and value). This
index value must range between 1 and the last index as passed to the open element function. With thesecond syntax the name of the attribute to retrieve is given to the procedure. An empty string is returned
if this attribute is not defined for the current element.
Related topics
xmlparse
Modulemmxml

Fair Isaac Corporation Proprietary Information

689

Chapter 19: mmxml

xmlencode
Purpose
Synopsis

Encode a text string for XML.
function xmlencode(t:text):text

Argumentt

text to encode

Further information
Encode a text string for XML by replacing control characters (<, >, &, ’, ") by their encoded equivalent.
Related topics
xmldecode
Modulemmxml

Fair Isaac Corporation Proprietary Information

690

Chapter 19: mmxml

xmldecode
Purpose
Synopsis

Decode a text string for XML.
function xmldecode(t:text):text

Argumentt

text to decode

Further information
Decode a text string from XML by replacing encoded sequences (&lt; &gt; &amp; &apos; &quot;) by thecorresponding control characters.
Related topics
xmlencode
Modulemmxml

Fair Isaac Corporation Proprietary Information

691

Chapter 19: mmxml

xmlparse
Purpose
Synopsis

Parse an XML document.
function xmlparse(afct:array(range) ofstring|function,mode:integer,ctx:ctxtype): integer

Arguments
afct

mode
ctx

Event function table. Each entry of this array is the name of or a reference to the function to callwhen the corresponding event occurs. The expected events are (all of these entries are optional):
XML_FCT_DECL
Document declarations
XML_FCT_TXT
A text node (same value as ML_TEXT)
XML_FCT_CDATA
A CDATA node
XML_FCT_COM
A commentary node
XML_FCT_DATAA DATA node
XML_FCT_PINSTA processing instruction node
XML_FCT_OPEN_ELTOpening of a new element node
XML_FCT_CLOSE_ELT Closing of an element node
If 0, spaces are preserved and returned as text elements. Otherwise all text elements aretrimmed
Value passed as first argument of all event functions

Return value
0 if successful, 1 in case of parsing error or a non-zero value returned by an event function
ExampleThis example displays the structure of an XML document without loading it into memory.
! Display element name and update indentation
public function start_elt(spce:text,name:text,nba:integer):integer
writeln(spce,name)spce+=" "end-function! Update indentation when element closes
function end_elt(spce:text):integer
spce-=" "end-function
declarations
afct:array(range) of any
end-declarations
afct(XML_FCT_OPEN_ELT):="start_elt" ! define open elementafct(XML_FCT_CLOSE_ELT):=->end_elt ! define close element
fopen("mydocument.xml",F_INPUT)
rts:=xmlparse(afct,1,text(""))
fclose(F_INPUT)

Fair Isaac Corporation Proprietary Information

692

Chapter 19: mmxml

Further information
1. This function is an alternative approach to load for processing XML documents: instead of loading intomemory the entire document this function calls a dedicated routine whenever it identifies an XML entity.
For instance a specific function is called when an element is open and another one when it is closed. It is
up to the Mosel program to decide how to handle the document via these event handling functions.
2. To each event type corresponds a specific function signature. These functions return an integer that
decides whether parsing should continue: a non-zero value will cause the parsing to cancel (this value isused as the return value of xmlparse). The expected function signatures are:
XML_FCT_DECL function xmldecl(ctx:ctxtype, vers:text, enc:text,
std:integer):integer
XML_FCT_TXT

function text_node(ctx:ctxtype, type:integer,
data:text):integer

XML_FCT_CDATA function cdata_node(ctx:ctxtype, type:integer,
data:text):integer
XML_FCT_COM

function comment_node(ctx:ctxtype, type:integer,
data:text):integer

XML_FCT_DATA function data_node(ctx:ctxtype, type:integer,
data:text):integer
XML_FCT_PINST function processing_instr(ctx:ctxtype, target:text,
data:text):integer
XML_FCT_OPEN_ELT function open_element(ctx:ctxtype, name:text,
nba:integer):integer
XML_FCT_CLOSE_ELT

function close_element(ctx:ctxtype):integer

In addition to the pre-defined arguments these functions take a context as their first parameter. Thisvariable (that can be of any type) is provided to the xmlparse routine and can be used by the event
functions for storing progress information.
The type passed to the text node functions is the XML type corresponding to the function (namely
XML_TXT, XML_CDATA, XML_COM, XML_DATA).
The open_element function receives the name of the element as well as the number of defined attributes.
To retrieve these attributes xmlattr can be used.
3. An error message indicating the location of the error is displayed when the parsing fails or if an event
function returns a negative value (a positive value also interrupts parsing but no message is displayed).
Related topics
load
Modulemmxml

Fair Isaac Corporation Proprietary Information

693

CHAPTER 20

mmxnlp
The mmxnlp module provides access to nonlinear solvers, extending the capabilities provided by the
mmxprs and mmnl modules. In particular, this module allows existing linear or mixed integer (MIP)
models to be upgraded to include nonlinearities, without requiring unnecessary changes to theformulation. To use this module, the following line must be included in the header of the Mosel model file:uses 'mmxnlp'

Problem type and module hierarchy
Module mmxprs provides■

linear models and■mixed integer linear models.

Module mmnl adds support for■

convex quadratic models,■convex quadratic mixed integer models,■convex, quadratically constrained models, and■convex, quadratically constrained mixed integer models.

Module mmxnlp adds support for■

general nonlinear problems and■general nonlinear mixed integer problems.

If the mmxnlp module is used for a model which does not require a general nonlinear solver, this shouldbe equivalent to using the appropriate mmxprs or mmnl module directly.

20.1 New functionality for the Mosel language
20.1.1 The userfunc type
A nonlinear model may employ one or more black box evaluation functions, which can be used to provide
function evaluations to the solver. These are represented in mmxnlp by the new userfunc type. The
implementation of each userfunc must be described by calling one of:Fair Isaac Corporation Proprietary Information

694

Chapter 20: mmxnlp■

userfuncMosel: to declare that a user function is implemented as a Mosel function

Note that user functions returning multiple arguments are support by the mmxnlp module. The F
construction allows a userfunc to be included in any nonlinear (nlctr) expression, and groups eachoccurrence of the userfunc with its parameters . During the solve, the parameters (which are of type nlctr
themselves) will be evaluated at the current solution, and the real-valued results passed to the userfunc
implementation. The function userfuncinfo can be used to find out which parameters the system has
deduced it needs to pass to a particular userfunc.

20.1.2 The tolset typeThe module provides a large number of configurable tolerances for users of the Xpress NonLinear SLP
solver. A tolset describes a convergence tolerance set, which can be used for those nonlinear solvers
supporting variable-specific convergence tolerances. The elements of a tolerance set are defined byusing settol, and assigned to a variable or list of variables using settolset. For more details on
tolerance sets, please refer to the Xpress NonLinear Reference Manual.
■

XNLP_TOL_TC: The absolute closure tolerance■

XNLP_TOL_TA: The absolute delta tolerance■

XNLP_TOL_RA: The relative delta tolerance■

XNLP_TOL_TM: The absolute matrix tolerance■

XNLP_TOL_RM: The relative matrix tolerance■

XNLP_TOL_TI: The absolute impact tolerance■

XNLP_TOL_RI: The relative impact tolerance■

XNLP_TOL_TS: The relative slack impact tolerance■

XNLP_TOL_RS: The absolute slack impact tolerance

20.1.3 The mpproblem.xprs.xnlp problem type
When using the mmxnlp module, the type of the active Mosel problem is changed from mpproblem.xprs
to the extended type mpproblem.xprs.xnlp. This means that all of the routines presented in this section
operate in the context of the current Mosel problem.

20.2 mmxnlp and the other Mosel modules
mmxnlp is designed to provide seamless integration with other Mosel functionalities. However, thefundamentally different nature of nonlinear problems makes some compromises necessary; these arelisted in this section.

20.2.1 Overloaded functions
The following functionality is modified or extended by the mmxnlp module:■

Retrieval of solution values with getsol, both for variables and nonlinear constraints. A detailed
description of the behaviour of this function can be found in the documentation for the mmxprs andmmnl modules.

Fair Isaac Corporation Proprietary Information

695

Chapter 20: mmxnlp■

Functions implemented in the mmnl module are extended for nonlinear solvers:– setinitval, clearinitvals and copysoltoinit to manage initial values.
– Mathematical functions: abs, exp, ln, log, sqrt, cos, sin, tan, arccos, arcsin, arctan.
– Mosel constraint and constraint visibility functions: gettype, settype, ishidden andsethidden.

■

Functions implemented in the mmxprs module are extended for nonlinear solvers:– maximize and minimize to solve the problem.
– getprobstat to return the problem solution status.
– fixglobal for managing integer problems.
– Exporting the current status (for debugging purposes) with loadprob, writeprob andsavestate.

20.2.2 Module compatibility
The mmquad module is incompatible with the mmxnlp module, and should not be used together with it.
The mmxprs and mmnl modules are automatically loaded when using the mmxnlp module.
The mmnl module defines several discontinuous functions for use with decision variables (mpvar), which
are not supported by the mmxnlp module. These constructions should instead be modelled with integer
constraints. The functions are: round, ceil, floor, idiv and mod.
The following standard functionalities are not available for nonlinear problems:
■
■

■

■

■

Functions for working with a basis: loadbasis, readbasis and savebasis.
Logical constraints of the form logctr, and their operators: implies, indicator, or, xor andand.
Functions for working with multiple MIP solutions, the solution pool and the solution enumerator:
selectsol, XPRS_enumduplpol, XPRS_enummaxsol and XPRS_enumsols.
Functions for cut management, including model cuts and delayed rows: addcut, addcuts,
loadcuts, storecut, storecuts, delcuts, dropcuts, getcnlist and getcplist.
Functions for determining irreducible infeasible sets, and for repairing infeasibility: getiis,
getiissense, getiistype, isiisvalid, resetiis and repairinfeas and getinfeas.

20.3 Control parameters
When using mmxnlp, getparam and setparam are extended to additionally provide access to all thecontrol and problem parameters of the Xpress NonLinear SLP solver. The module also provides thefollowing controls of its own:
XNLP_AUTOELIM

When set to true, Mosel uses the model’s semantics to break down nonlinear
formulas and feed the information to the solver for nonlinear eliminations
and to detect network structures in the model.
p. 697XNLP_LOADASNLWhen set to true, quadratic expressions will be treated as being of general
nonlinear type. If they are known to be non-convex, the overhead ofattempting to treat the expression as convex initially is avoided.
p. 697

Fair Isaac Corporation Proprietary Information

696

Chapter 20: mmxnlp

XNLP_LOADNAMES

When set to true, names from the Mosel file will be passed to the underlying
solver to improve the readability of messages it generates. This is an alias
for XPRS_LOADNAMES.
p. 697XNLP_NLPSTATUS

The solution status of the problem. For a detailed description of this value,please see the documentation for the XSLP_NLPSTATUS attribute in the
Xpress NonLinear Reference Manual.
p. 698XNLP_SOLVER

Solver selection when available.

XNLP_VERBOSE

When set to true, informative messages from any underlying nonlinear solver
will be displayed. This is an alias for XPRS_VERBOSE.
p. 698

p. 698XNLP_AUTOELIM
Description

When set to true, Mosel uses the model’s semantics to break down nonlinear formulas and feed
the information to the solver for nonlinear eliminations and to detect network structures in themodel.

Type

Integer, read/write

Values0
1

Default value

1

ModulemmxnlpDisableEnableXNLP_LOADASNL
Description

When set to true, quadratic expressions will be treated as being of general nonlinear type. Ifthey are known to be non-convex, the overhead of attempting to treat the expression as convex
initially is avoided.

Type

Integer, read/write

Values0
1

Default value

0

ModulemmxnlpAssume that quadratic expressions are convex
Assume that quadratic expressions are non-convex

XNLP_LOADNAMES
Description

When set to true, names from the Mosel file will be passed to the underlying solver to improve
the readability of messages it generates. This is an alias for XPRS_LOADNAMES.

Type

Integer, read/write

Values0
1

Default value

0

ModulemmxnlpNames are not loaded into the solver
Names are loaded into the solver

Fair Isaac Corporation Proprietary Information

697

Chapter 20: mmxnlp

XNLP_NLPSTATUS
Description

The solution status of the problem. For a detailed description of this value, please see thedocumentation for the XSLP_NLPSTATUS attribute in the Xpress NonLinear Reference Manual.

Type

Integer, read only

Values

0
1
2
3
4
5
6

Default value

0

ModulemmxnlpOptimization unstarted
Locally optimal
OptimalLocally infeasible
Infeasible
Unbounded
UnfinishedXNLP_SOLVER
Description

Solver selection when available.

Type

Integer, read/write

Values-1
01

Default value-1

Modulemmxnlp

Determine automatically, based on problem characteristics and availability of solvers
Xpress NonLinear (SLP)
KnitroXNLP_VERBOSE
Description

When set to true, informative messages from any underlying nonlinear solver will be displayed.
This is an alias for XPRS_VERBOSE.

Type

Integer, read/write

Values0
1

Default value

0

ModulemmxnlpNo solver logging
Solver log is displayed

20.4 Procedures and functions
This section lists in alphabetical order the functions and procedures that are provided by the mmxnlp
module.
addmultistart

Fair Isaac Corporation Proprietary Information

Loads a single or a set of multistart job(s) into the multistart job pool. p. 700

698

Chapter 20: mmxnlp

chgdeltatype

Changes the type of a delta variable associated to an mpvar.

p. 701F

Include a user function in a nonlinear constraint.

p. 702

generateUFparallel

Generates a parallel version of a Mosel user function that is implemented asa Mosel package.
p. 704printmodelmemory

Print a summary of the current memory usage of the nonlinear module.
p. 705printmodelscaling

Print a summary of the scaling of the model, as loaded into the solver. p. 706

setcallback

Set nonlinear callback functions and procedures.

p. 707setcomplementary

Set two variables as being complementary.

p. 708setdefvar

Set a variable to be purely defined by a constriant.

p. 709setdetrow

Set the determining row for a variable.

p. 710setenforcedctr

Mark a nonlinear constraint as enforced.

p. 711

setinitsb

Provide the initial step bound for a variable.

p. 712

settolDefine a particular tolerance in a tolerance set.

p. 713settolset

Assigns a tolerance set to a variable, or list of variables.

p. 714userfuncinfo

Print the inferred prototype of the given user function.

p. 715userfuncMosel

Create a user function from a Mosel function.

p. 716validate

Print a summary of the feasibility of the current solution.

p. 717

Fair Isaac Corporation Proprietary Information

699

Chapter 20: mmxnlp

addmultistartPurpose
Synopsis

Loads a single or a set of multistart job(s) into the multistart job pool.
addmultistart(descr:string)
addmultistart(descr:string, controls:array(set of string) of real)addmultistart(descr:string, initvalues:array(set of mpvar) of real)addmultistart(descr:string, initvalues:array(set of mpvar) of real,controls: array(set of string) of real)addmultistart(descr:string, controls:array(set of string) of real,
initvalues:array(set of mpvar) of real)addmultistart(descr:string, preset:integer)
addmultistart(descr:string, preset:integer, cnt:integer)
addmultistart(descr:string, preset:integer, initvalues:array(set of mpvar)of real, controls:array(set of string) of real)addmultistart(descr:string, preset:integer, cnt:integer,
initvalues:array(set of mpvar) of real, controls:array(set of string)of real)Arguments
descr
controls
initvalues
presetcnt

Text description of the job. Used in reporting and in callbacks.
An array containing the controls to be set for the loaded multistart job.
An array containing initial values to be set for the loaded multistart job.
The multistart preset of jobs to be loaded. Please see the Xpress NonLinear Reference
Manual for the list of possible presets.
The upper bound on the number of jobs to be created, in case a preset is used.

Further information
Adds a job or a preset to the multistart job pool. Multistart jobs are automatically executed on the next
minimize/maximize command, unless the XSLP_MULTISTART control is set to 0. Please refer to theXpress NonLinear Reference Manual for a detailed description of multistart.
ModulemmxnlpFair Isaac Corporation Proprietary Information

700

Chapter 20: mmxnlp

chgdeltatype
Purpose
Synopsis

Changes the type of a delta variable associated to an mpvar.
procedure chgdeltatype(col:mpvar, type:integer, value:real)

Arguments
col
The column for which the delta is to be changed.
type The new type of the delta.
value Value associated to the new delta type.
Further information
Please refer to the Xpress NonLinear Reference Manual for more details about delta types.
Related topics
setinitval, setinitsb, setdetrow, setenforcedctr.
ModulemmxnlpFair Isaac Corporation Proprietary Information

701

Chapter 20: mmxnlp

F
Purpose
Synopsis

Include a user function in a nonlinear constraint.
function F(UF:userfunc, arg:linctr):nlctr
function F(UF:userfunc, arg:nlctr):nlctr
function F(UF:userfunc, arg:list of nlctr):nlctr
function F(UF:userfunc, arg:array(any sets) of nlctr):nlctr
function F(UF:userfunc, arg:list of nlctr, returnarg:integer):nlctr
function F(UF:userfunc, arg:array(any sets) of nlctr,
returnarg:integer):nlctr

ArgumentsUF
arg
returnarg

A user function of type userfunc
Argument to be passed to the user function
Return argument to be substituted into the formula for multivalued user functions

Return value
A nonlinear expression which may form part of any nlctr.
ExampleThe following example shows how to implement a negative cosine function.
model "SimpleUF"
uses "mmxnlp"
declarations
obj: nlctr
x: mpvar
MinusSine: userfunc
end-declarations! Creation and assignment of the user function
MinusSine := userfuncMosel("MinusSineImplementation")! which can then be embedded into any nonlinear expression
obj := F(MinusSine,x)
minimize(obj)public function MinusSineImplementation (x:real): real
returned := -sin(x)end-function
end-model

Further information
User functions allow extremely complex, recursive or non-algebraic expressions to be included in
nonlinear formulae. As such they may make use of simulators or other black box evaluators. The actual
parameters to a user function depend upon the way it is bound to the model by the F function. Please see
the chapter on user functions for more details. Each user function instance defined by the means of the Ffunction must share the same argument syntax structure, however the actual formula content may differ:e.g. if a function takes an array of nonlinear expressions as input arguments, each instance of thefunction corresponding to the same definition based on the same F instance must have the sameunderlying array structure, although the expressions stored in them may differ. If a separate F instance isused using the same function implementation, this rule does not apply. Also note, that for Mosel to beable to correctly cross reference the sets used in the definition of an array, the sets must be named.

Fair Isaac Corporation Proprietary Information702

Chapter 20: mmxnlp

Related topics
userfuncMosel.
ModulemmxnlpFair Isaac Corporation Proprietary Information

703

Chapter 20: mmxnlp

generateUFparallel
Purpose
Synopsis

Generates a parallel version of a Mosel user function that is implemented as a Mosel package.
procedure generateUFparallel(bimname:string, fctname:string)Arguments
bimname Path to the compiled Mosel package implementing the user function.
fctname The public user function inside the package.
Further information
Please refer to the Xpress NonLinear Reference Manual for more details about this functionality.
ModulemmxnlpFair Isaac Corporation Proprietary Information704

Chapter 20: mmxnlp

printmodelmemory
Purpose
Synopsis

Print a summary of the current memory usage of the nonlinear module.
procedure printmodelmemory

Further information
This procedure has no effect unless XNLP_VERBOSE is set. It is provided solely for the purpose of model
analysis and debugging.
Related topics
validate, printmodelscaling, userfuncinfo.
ModulemmxnlpFair Isaac Corporation Proprietary Information705

Chapter 20: mmxnlp

printmodelscaling
Purpose
Synopsis

Print a summary of the scaling of the model, as loaded into the solver.
procedure printmodelscaling

Further information
This procedure has no effect unless XNLP_VERBOSE is set. It is provided solely for the purpose of model
analysis and debugging.
Related topics
validate, printmodelmemory, userfuncinfo.
ModulemmxnlpFair Isaac Corporation Proprietary Information

706

Chapter 20: mmxnlp

setcallback
Purpose
Synopsis

Set nonlinear callback functions and procedures.
procedure setcallback(cbtype:integer, cb:string)Arguments
cbtype Type of the callback:cb

ModuleXSLP_CB_ITERSTARTSLP iteration start callback
XSLP_CB_ITERENDSLP iteration end callback
XSLP_CB_ITERVAR
Nonlinear variable convergence check callback
XSLP_CB_CASCADESTART Cascading start callback
XSLP_CB_CASCADEVAR
Variable cascaded callback
XSLP_CB_CASCADEEND
Cascading end callback
XSLP_CB_STARTSLP solve start callback
XSLP_CB_END
SLP solve end callback
XSLP_CB_PRENODE
MISLP node setup callback
XSLP_CB_INTSOLNew integer solution found callback
XSLP_CB_OPTNODEMISLP node solved and (SLP) optimal callback
XSLP_CB_CONSTRUCT
Construct start callback
XSLP_CB_MSJOBSTARTA new multistart job is about to be solved callback
XSLP_CB_MSJOBEND
A multistart job has been solved callback
XSLP_CB_MSWINNER
Winner multistart job callback
Name of the callback function/procedure; the parameters and the type of the return value (ifany) vary depending on the type of the callback:function cb:integerXSLP_CB_ITERSTART
function cb:integerXSLP_CB_ITEREND
function cb(var:mpvar) : integerXSLP_CB_ITERVAR
function cb:integerXSLP_CB_CASCADESTART
function cb(var:mpvar):integerXSLP_CB_CASCADEVAR
function cb:integerXSLP_CB_CASCADEEND
function cb:integerXSLP_CB_START
function cb:integerXSLP_CB_END
function cb:integerXSLP_CB_PRENODE
function cb:integerXSLP_CB_INTSOL
function cb:integerXSLP_CB_OPTNODE
function cb:integerXSLP_CB_CONSTRUCT
function cb(description:string):integer XSLP_CB_MSJOBSTART
function cb(description:string):integer XSLP_CB_MSJOBEND
function cb(description:string):integer XSLP_CB_MSWINNER

mmxnlpFair Isaac Corporation Proprietary Information

707

Chapter 20: mmxnlp

setcomplementary
Purpose
Synopsis

Set two variables as being complementary.
procedure setcomplementary(var1:mpvar, var2:mpvar)

Arguments
var1
var2

The first variable of the variable pair to be set as complementing
The first variable of the variable pair to be set as complementing

Further information
A complementing variable pair implements the constraint that is equivalent with the product of thevariables being zero. However, the solvers may be able to treat such constraints in a special, more
efficient ways, which may make a difference if the complementarity constraints are the problematic partof the model. Note that Knitro only allows non-overlapping complementary variables, and in the presenceof overlaps Xpress will default to use SLP. Complementary variables must have a lower bound of zero.
Related topics
setinitval, setinitsb, setdetrow, setenforcedctr.
ModulemmxnlpFair Isaac Corporation Proprietary Information

708

Chapter 20: mmxnlp

setdefvar
Purpose
Synopsis

Set a variable to be purely defined by a constriant.
procedure setdefvar(var:mpvar, row:linctr)
procedure setdefvar(var:mpvar, row:nlctr)

Argumentsvarrow

The variable being made defined by the constraint.
The constraint that defines the value of the variable.

Further information
The variable will be made free (its bounds removed) since it’s value is now defined by the contraint’svalue. Ideally, the variable should appear linearly in the constriant, in which case unless a circularreference is detected it will used for eliminate on in the nonlinear presolver. The purpose of the construct
is to break large nonliner expressions.
Related topics
setdetrow
ModulemmxnlpFair Isaac Corporation Proprietary Information709

Chapter 20: mmxnlp

setdetrow
Purpose
Synopsis

Set the determining row for a variable.
procedure setdetrow(var:mpvar, row:linctr)
procedure setdetrow(var:mpvar, row:nlctr)
procedure setdetrow(row:linctr, var:mpvar)
procedure setdetrow(row:nlctr, var:mpvar)

Argumentsvarrow

The variable for which the determining row is provided
The row that determines the value of the variable.

Further information
A row which is determining for a variable defines the value of that variable. This means that the variable
is a derived value which is calculated in another part of the model. Some solvers will use suchdesignations to refine their search, and in particular in sequential linear programming, a process calledcascading makes use of determining rows. Please refer to the Xpress NonLinear Reference Manual(chapter ’Cascading’) for more information.
Related topics
setinitval, setinitsb, setenforcedctr.
ModulemmxnlpFair Isaac Corporation Proprietary Information

710

Chapter 20: mmxnlp

setenforcedctr
Purpose
Synopsis

Mark a nonlinear constraint as enforced.
procedure setenforcedctr(row:nlctr)

Argumentrow

The constraint to be set enforced

Further information
A constraint which is marked as enforced will not have penalty error vectors introduced upon it by solvers
which use such techniques. This may be useful for constraints which are hard to satisfy.
Related topics
setinitval, setinitsb, setdetrow.
ModulemmxnlpFair Isaac Corporation Proprietary Information

711

Chapter 20: mmxnlp

setinitsb
Purpose
Synopsis

Provide the initial step bound for a variable.
procedure setinitsb(var:mpvar, value:real)

Argumentsvar
The variable for which the step bound is provided
value Value to be used as initial value
Further information
The initial step bounds define in turn the size of the initial trust region. Please refer to the Xpress
NonLinear Reference Manual for more information.
Related topics
setinitval, setdetrow, setenforcedctr.
ModulemmxnlpFair Isaac Corporation Proprietary Information

712

Chapter 20: mmxnlp

settolPurpose
SynopsisDefine a particular tolerance in a tolerance set.
procedure settol(tset:tolset, which:integer, value:real)

Arguments
tset The tolerance set to be modified
which The tolerance which is being definedvalue The new value of the tolerance
Further information
The tolerances which may be defined by this method are:XNLP_TOL_TC The absolute closure tolerance
XNLP_TOL_TA The absolute delta tolerance
XNLP_TOL_RA The relative delta tolerance
XNLP_TOL_TM The absolute matrix tolerance
XNLP_TOL_RM The relative matrix tolerance
XNLP_TOL_TI The absolute impact tolerance
XNLP_TOL_RI The relative impact tolerance
XNLP_TOL_TS The relative slack impact tolerance
XNLP_TOL_RS The absolute slack impact tolerance
Please refer to the Xpress NonLinear Reference Manual, and particularly the chapter ’Convergencecriteria’, for more information on these tolerances.
Related topics
setinitval, setinitsb, setdetrow, setenforcedctr.
ModulemmxnlpFair Isaac Corporation Proprietary Information

713

Chapter 20: mmxnlp

settolset
Purpose
Synopsis

Assigns a tolerance set to a variable, or list of variables.
procedure settolset(var:mpvar, tset:tolset)
procedure settolset(vars:list of mpvar, tset:tolset)

Arguments
var
vars
tset

Variable to which the tolerance set is to be assigned
List pf variable to which the tolerance set is to be assigned
The tolerance set to be assigned to the variable(s)Related topics
settol.
ModulemmxnlpFair Isaac Corporation Proprietary Information

714

Chapter 20: mmxnlp

userfuncinfo
Purpose
Synopsis

Print the inferred prototype of the given user function.
procedure userfuncinfo(UF:userfunc)

ArgumentUF

The user function to be analyzed

Further information
The type and signature of a user function are inferred from its use in calls to the F function in the current
model. This procedure has no effect unless XNLP_VERBOSE is set. It is provided solely for the purpose ofmodel analysis and debugging.
Related topics
validate, printmodelmemory, printmodelscaling.
ModulemmxnlpFair Isaac Corporation Proprietary Information

715

Chapter 20: mmxnlp

userfuncMosel
Purpose
SynopsisCreate a user function from a Mosel function.
function userfuncMosel(fctname:string):userfunc
function userfuncMosel(fctname:string, options:integer):userfunc

Arguments
fctname Name of the Mosel function to wrap
options Options describing special properties of the user function
Return value
A userfunc object that can be used in the F functions to be embedded in formulas.
Further information
User functions allow extremely complex, recursive or non-algebraic expressions to be included in
nonlinear formulae. As such they may make use of simulators or other black box evaluators. The actual
parameters to a user function depend upon the way it is bound to the model by the F function. Please see
the chapter on user functions for more details.
There is support for user functions providing their own derivatives. Currently, user functions taking anarray of nlctr and returning a single function values may provide their own derivatives. To mark afunction as returning it’s own derivatives, use option XNLP_DERIVATIVES or XNLP_DELTAS to indicatethat the solver should suggest perturbation values for the variables.
Related topics
F.
ModulemmxnlpFair Isaac Corporation Proprietary Information

716

Chapter 20: mmxnlp

validate
Purpose
Synopsis

Print a summary of the feasibility of the current solution.
procedure validate

Further information
This procedure has no effect unless XNLP_VERBOSE is set. It is provided solely for the purpose of model
analysis and debugging.
Related topics
printmodelmemory, printmodelscaling, userfuncinfo.
ModulemmxnlpFair Isaac Corporation Proprietary Information

717

Chapter 20: mmxnlp

20.5 Error codes issued by mmxnlp
1

Out of memory
The system has run out of memory.

2

No purchase authorization foundNo license found3

Failed to initialize XSLPCannot initialize the XPRS library. There may be a licensing problem

4

Unsupported XSLP version
The version of the ’XSLP’ library is incompatible with the current module. The Xpress installation
may be corrupt

5

Failed to create the XSLP problem object
Cannot create the XSLP optimizer problem. There may be a licensing problem

6

Unexpected mmxnlp user function signature
The provided user functions’ signature does not match any expected format.

7

Unexpected external token in mmxnlp
An unexpected external token found by the ’mmxnlp’ module. Please contact support.

8

Unsupported operator
The provided operator is not supported by ’mmxnlp’.

9

Failed to load problem
Could not load the problem into the optimizer.

10

Variable bound conflict in problem
Inconsistent bounds provided for the variable.

11

Failed to load user function
The user function could not be loaded into the optimizer.

12Error evaluating user function
Error while evaluation the user function. The user function likely to have returned an error code.

13

Unknown tolerance set
The provided tolerance set is invalid.

14

List tpype error in user function
The list provided to the user function is not valid for the function.

15

Failed to create save file
The savefile could not be created.

16

Error in optimization
An error has occured during optimization.

17

Cannot reoptimize using a different objective (use named linctr or nlctr)
The objective has unexpectedly changed

Fair Isaac Corporation Proprietary Information

718

Chapter 20: mmxnlp

18Internal error in mmxnlp. Please contact FICO support
An internal error has occurred. Please contact support.

20

Incompatible array definitions for user function arguments
The user function received incompatible arrays.

21

Non-Mosel user functions only take ’list of nlctr’ type arguments
User functions that are not implemented as a Mosel function can only take list of ’nlctr’ arguments(no arrays).

22

Invalid argument list for external function
The provided argument list is not valid for the external function.

23

Provided user function is not returning a single real
The provided user function was expected to return a single real value.

24

Provided user function is not returning an array indexed by integers
The provided user function was expected to return an array of reals indexed by integers.

25

User function must be loaded before it’s properties can be retrieved
The user function must be loaded before it’s properties are interrogated. Please use ’loadprob’ toload the model including the user function.

26

Unexpected variable found. Please reload problem first using ’loadprob’
An unexpected variable has been used. Please reload the problem to load the variable.

27

Operation only supported on the main problem (e.g. not inside multi-start callbacks)This operation is only supported in the main problem. It cannot be used on worker problems.

28

Math error while evaluating expression
A mathematical error has occurred while evaluating the expression.

Fair Isaac Corporation Proprietary Information

719

CHAPTER 21

mmxprsThe mmxprs module provides access to FICO⃝R Xpress Optimizer from within a Mosel model and as suchit requires the Xpress Optimizer library (XPRS) to be installed on the system. To use this module, thefollowing line must be included in the header of the Mosel model file:uses 'mmxprs'

A large number of optimization-related routines are provided, ranging from those for finding a solution to
the problem, to those for setting callbacks and cut manager functions. Whilst a description of their usage
is provided in this manual, further details relating to the usage of these may be found by consulting theXpress Optimizer Reference Manual.

21.1 New functionality for the Mosel language
21.1.1 The problem type mpproblem.xprs
This module exposes its functionality through an extension to the mpproblem problem type. As aconsequence, all routines presented here are executed in the context of the current problem. In particular,
the setting of a control parameter is applied only to the current problem and each problem has its own setof settings and solution information. However, when a new problem instance is created, the value of thecontrol parameters XPRS_colorder, XPRS_enummaxsol, XPRS_enumduplpol, XPRS_loadnames
and XPRS_verbose are initialised with the settings of the main problem.

21.1.2 The type basis
The module mmxprs defines the type basis to represent solution basis in the Mosel Language. This new
type is used to store a basis computed by the optimizer during its solution process (savebasis). A basis
can then be loaded again into the optimiser with loadbasis, inspected (by getting the basis status ofeach variable/constraint it includes with getbstat) or modified (by changing this basis status using
setbstat). The type basis supports assignment and test of equality. This comparison only checks
whether two basis contain the same information, it does not indicate whether the basis are equivalent.

21.1.3 The type mpsol
The type mpsol characterises a solution of an MP problem by associating a value to each decisionvariable (type mpvar) of the problem. Initialising such an object can be achieved by saving the current
solution found by the optimiser (savesol or savemipsol) or by building it one variable at a time(setsol). Various routines requiring solution information support the solution object. For instancegetsol may be used to evaluate an expression on a specific solution; loadmipsol and addmipsol
accept this object as input. A solution might be saved into a file using writesol and the resulting file

Fair Isaac Corporation Proprietary Information

720

Chapter 21: mmxprs

can be loaded into the optimiser with readsol. The type mpsol supports assignment and test ofequality.

21.1.4 The type boolvar
An entity of type boolvar is a pseudo boolean decision variable. This type supports operators and, orand not for building logical expressions and can be combined with ordinary Boolean variables. A logicalconstraint is specified either by associating a pseudo boolean variable to a logical expression using thefollowing syntax:
boolvar = logical_expression

or by forcing the truth value (i.e. true or false) of an expression as follows:
logical_expression = boolean

When a logical expression is used on its own as a statement it is implicitly turned into a constraint (forced
to true) and added to the constraint store.
Each boolvar is represented in the MIP problem by two binary variables (mpvar): one for the value
itself and another one for its negation. These decision variables can be accessed from the model using
the function getvar such that they can be used in linear constraints. The solution value of a boolvar isof type boolean and can be obtained using getsol.

21.1.5 The type logctr
The type logctr represents either a logical expression over linear constraints, a logicalexpession/constraint over pseudo boolean decision variables (boolvar) or an indicator constraint (seeindicator). Logical expressions can be built using standard operators (and, or, not) or with the helpof the dedicated functions implies and xor (for logical expressions over linear constraints only). These
logical constructs are handled like linear constraints: they are associated to the current problem, can be(re)defined via assignments and hidden using sethidden. Note however that logical constructs are notshown by exportprob although the mmxprs routine writeprob will report them.
If logical expressions over linear constraints are employed in a model, the loading of the problem into the
optimizer requires the use of the helper package "advmod":uses 'advmod'

This package is not necessary when a model uses only logical constraints over pseudo boolean variables
or indicator constraints directly.

21.2 Control parameters
This module extends the getparam function and the setparam procedure in order to access all thecontrol and problem parameters of Optimizer (for example the problem attribute LPSTATUS is mapped tothe mmxprs control parameter XPRS_lpstatus). In addition to these, the following control parameters
are also defined:
XPRS_colorder

Reorder matrix columns before loading the problem.

p. 722

XPRS_enumduplpol

Handling of duplicate solutions during an enumeration.

p. 723

XPRS_enummaxsol

Maximum number of solutions to be saved during an enumeration.

p. 722

Fair Isaac Corporation Proprietary Information

721

Chapter 21: mmxprs

XPRS_enumsols

Number of solutions found during the last enumeration.

p. 722

XPRS_fullversion

Optimizer version number.

p. 723

XPRS_loadnames

Enable/disable loading of MPS names into the Optimizer.

p. 723

XPRS_maxupdc

Size of the pool of matrix updates.

p. 723

XPRS_problem

Optimizer problem pointers.

p. 724

XPRS_probname

Read/set the problem name used by the Optimizer.

p. 724

XPRS_verbose

Enable/disable message printing by the Optimizer.

p. 724

Example:setparam("XPRS_verbose", true)! Turn on message printing
pstat:= getparam("XPRS_lpstatus")! Get the problem LP optimization statuswriteln("Best bound=", getparam("XPRS_bestbound")) ! Display the best bound value

XPRS_colorder
Description

Reorder matrix columns before loading the problem.

Type

Integer, read/write

Values0
1,3
2
4Default value

0

Modulemmxprs

Mosel implicit ordering
Reorder using a numeric criterion
Alphabetical order of the variable names (this requires the names to be available)
Random ordering

XPRS_enumsols
Description

Number of solutions found during the last enumeration. The value of this parameter is -1 is no
enumeration has been run.

Type

Integer, read only

Affects routines

maximize, minimize.

Modulemmxprs

XPRS_enummaxsol
Description

Maximum number of solutions to be saved during an enumeration.

Type

Integer, read/write

Default value

10

Affects routines

maximize, minimize.

ModulemmxprsFair Isaac Corporation Proprietary Information

722

Chapter 21: mmxprs

XPRS_enumduplpol
Description

Handling of duplicate solutions during an enumeration. Refer to the MSP control parameter
MSP_DUPLICATESOLUTIONSPOLICY for further information.

Type

Integer, read/write

Values0
1
2
3

Default value

3

Affects routines

maximize, minimize.

ModulemmxprsAll solutions kept
Continuous
Discrete and continuous separate
Discrete only

XPRS_fullversion
Description

The full Optimizer version number in the form major.minor.build (e.g."20.01.03").

Type

String, read only

Modulemmxprs

XPRS_loadnames
Description

Enable/disable loading of MPS names into the Optimizer.

Type

Boolean, read/write

Valuestrue Enable loading of names
false Disable loading of names

Default value

false

Affects routines

loadprob, maximize, minimize.

Modulemmxprs

XPRS_maxupdc
Description

By default any call to setcoeff is recorded only in the Mosel representation of the problem
and requires a full reload of the matrix when the problem is solved. When this parameter is
non-zero these changes to the problem are also reported to the matrix loaded into the optimiser
such that the following solving operation does not require a regeneration of the matrix (as longas the problem has not been updated by another operation). The value of the parameter is thenumber of changes to be sent to the optimiser at once, pending operations are executed before
solving the problem or exporting it via writeprob. They are also run whenever the parameteris updated.

Type

Integer, read/write

ValuesAny non-negative integer

Fair Isaac Corporation Proprietary Information

723

Chapter 21: mmxprs

Default value0

Affects routines

setcoeff, setmatcoeff, maximize, minimize.

Modulemmxprs

XPRS_problem
Description

The Optimizer problem (XPRSprob), MIP solution pool (XPRSmipsolpool) and MIP solution
enumerator (XPRSmipsolenum) pointers separated by spaces. This attribute is only requiredin applications using both Mosel and the Optimizer at the C level.

Type

String, read only

Modulemmxprs

XPRS_probname
Description

Read/set the problem name used by the Optimizer to build its working files (this name may
contain a full path). If set to the empty string (default value), a unique name with a path to thetemporary directory of the operating system is generated.

Type

String, read/write

Modulemmxprs

XPRS_verbose
Description

Enable/disable message printing by the Optimizer.

Type

Boolean, read/write

Valuestrue Enable message printing
false Disable message printing

Default value

false

Modulemmxprs21.3 Procedures and functions
This section lists in alphabetical order the functions and procedures that are provided by the mmxprs
module.
addmipsol

Add a MIP solution to the optimizer.

p. 728basisstability

Get basis stability information.

p. 729calcsolinfo

Calculates a property of an mpsol solution.

p. 730clearmipdir

Delete all defined MIP directives.

p. 731clearmodcut

Delete all defined model cuts.

p. 732

command

Execute an Optimizer command.

p. 733

Fair Isaac Corporation Proprietary Information

724

Chapter 21: mmxprs

copysoltoinit

Copy solution values to initial values of an NL problem.

p. 734crossoverlpsol

Crosses over a previously loaded LP solution to a basic solution.

p. 735

defdelayedrows

Define the set of constraints to be treated as delayed rows.

p. 736

defsecurevecs

Define the variables and constraints to be preserved.

p. 737

estimatemarginals

Estimate better marginal values for variables and constraints for degenerate
problems.
p. 738

fixglobal

Fix values of discrete entitites.

p. 739getbstatGet the status of a variable or constraint in a basis.

p. 740getcomputeallowed

Get whether Insight Compute Interface integration is allowed

p. 741

getdualray

Get a dual ray for an infeasible problem.

p. 742getiisCompute then get the Irreductible Infeasible Sets (IIS).

p. 743getiissense

Decode the sense part of an IIS bound type information.

p. 744getiistype

Decode the type part of an IIS bound type information.

p. 745getinfcause

Returns the variable or constraint causing infeasibility.

p. 746getinfeas

Returns sets of infeasible primal and dual variables.

p. 747getlb

Get the lower bound of a variable.

p. 748getloadedlinctrs

Get the linear constraints loaded into the optimiser.

p. 749getloadedmpvars

Get the decision variables loaded into the optimiser.

p. 750getmatcoeff

Get the coefficient of a variable or the constant term of a constraint directlyfrom the Optimizer.
p. 751getnameGet the name of a decision variable or constraint.

p. 752

getprimalray

Get a primal ray for an unbounded problem.

p. 753

getprobstat

Get the Optimizer problem status.

p. 754getrange

Get a range value for a variable or constraint.

p. 755getscale

Retrieves scaling information about the currently loaded problem.

p. 756

getsensrng

Get sensitivity ranges for objective function coefficients, RHS coefficients,
variable upper bounds or variable lower bounds.
p. 757

getsizeGet the size of a solution.

p. 758

getsolGet the solution value of an expression from a solution object.

p. 759getub

Get the upper bound of a variable.

p. 761

getvarGet the decision variable associated to a pseudo boolean.

p. 760getvars

Get the set of variables of a solution.

p. 762

hasfeature

Check if a specific feature is supported by the currently used license. p. 763

impliesCreate an implies expression.

p. 764indicator

Create an indicator constraint.

p. 765

Fair Isaac Corporation Proprietary Information

725

Chapter 21: mmxprs

isiisvalid

Check whether an IIS number exists.

p. 766

isintegral

Check whether a solution value is integral.

p. 767

loadbasis

Load a previously saved basis.

p. 768loadlpsol

Load an LP solution into the optimizer.

p. 769loadmipsol

Load a MIP solution into the optimizer.

p. 770loadprob

Load a problem into the optimizer.

p. 772maximize, minimize

Maximize/minimize the current problem.

p. 773

postsolve

Postsolve the current matrix.

p. 775readbasis

Read a basis from a file.

p. 776

readdirs

Read directives from a file.

p. 777readsol

Read a solution from a file.

p. 778refinemipsol

Executes the MIP solution refiner on an mpsol solution.

p. 779rejectintsol

Reject a PREINTSOL solution.

p. 780

repairinfeas

Relaxing bounds to repair infeasibility.

p. 781

resetbasis

Reset a basis.

p. 783

resetiis

Reset the search for IIS.

p. 784

resetsol

Reset a solution.

p. 785savebasis

Save the current basis.

p. 786

savemipsol

Save the current solution into the provided array or solution object.

p. 787savesol

Save the current solution into a solution object.

p. 788savestate

Save current state of the Optimizer to a file.

p. 789selectsol

Select one of the solutions found by solution enumerator.

p. 790setarchconsistency

Sets the optimizer architecture control.

p. 791

setbstat

Set the status of a variable or constraint in a basis.

p. 792

setcallback

Set optimizer callback functions and procedures.

p. 793setcbcutoff

Set cutoff for PREINTSOL callback.

p. 797setcomputeallowed

Set whether Insight Compute Interface integration is allowed

p. 796

setgndata

Update data for GAPNOTIFY callback.

p. 798setlb

Set the lower bound of a variable.

p. 799setmatcoeff

Set the coefficient of a variable or the constant term directly in the Optimizer.
p. 800setmipdir

Set a directive on a variable or Special Ordered Set.

p. 801

setmodcut

Mark a constraint as a model cut.

p. 802

setsolDefine the value associated to a decision variabe in a solution object. p. 803

Fair Isaac Corporation Proprietary Information

726

Chapter 21: mmxprs

setub

Set the upper bound of a variable.

p. 804

setucbdata

Update data for CHGBRANCH callback.

p. 805stopoptimize

Interrupt the optimizer algorithms.

p. 806

unloadprob

Unload the problem held in the optimizer.

p. 807uselastbarsol

Sets up the last barrier solve’s solution as the current one if one is available
p. 808

writebasis

Write the current basis to a file.

p. 809writedirs

Write current directives to a file.

p. 810

writeprob

Write the current problem to a file.

p. 811

writesolWrite a solution to a file.

p. 812xor

Create an exclusive or expression.

p. 813

xprsmemoryuse

Retrieve memory usage statistics.

p. 814

Fair Isaac Corporation Proprietary Information

727

Chapter 21: mmxprs

addmipsol
Purpose
Synopsis

Add a MIP solution to the optimizer.
procedure addmipsol(solid:string,s:array(set of mpvar) of real)procedure addmipsol(solid:string,ms:mpsol)Arguments
solid Identifier to be assigned to the solutions
An array containing the solutionms
A solution object
Further information
1. This function is used to provide the expectations of the modeler on the values of selected variables inpossible MIP solutions. It is different to loadmipsol in that it is not necessary to provide full, feasible
MIP solutions. The values provided will be used by the Optimizer to attempt to generate full MIP
solutions. The addmipsol function can therefore be used to trial the feasibility of certain variable value
assignments without the need to fix them in the problem formulation itself.
2. The solution value array s is created by assigning values to discrete variables in the problem, such ass(x):= 1 (where x is a decision variable of type mpvar). It is also possible to use a solution that has
previously been saved using the procedure savemipsol.
3. If the provided solution is found to be infeasible, a limited local search heuristic will be run in an attempt
to find a close feasible integer solution.
4. The current problem definition must be loaded into the Optimizer for addmipsol to have any effect. If
this has not recently been done, e.g., by calling maximize or minimize, the problem must be explicitly
loaded using loadprob.
5. The function returns immediately after passing the solution to the Optimizer. The solution is placed in apool until the optimizer is able to analyze the solution during a MIP solve.
6. The SOLNOTIFY callback function can be used to discover the outcome of a loaded solution, based on
the identifier assigned to the solution (see setcallback).
Related topics
savemipsol, loadmipsol.
ModulemmxprsFair Isaac Corporation Proprietary Information

728

Chapter 21: mmxprs

basisstability
Purpose
SynopsisGet basis stability information.
function basisstability(type:integer,norm:integer,scaled:boolean):realArguments
type

Which information to return. Possible values:0
Condition number of the basis
1
Stability measure for the solution relative to the current basis
2
Stability measure for the duals relative to the current basis
3
Stability measure for the right hand side relative to the current basis
4
Stability measure for the basic part of the objective relative to the current basis
norm
Which norm to use. Possible values:0
Use the infinity norm
1
Use the 1 norm
2
Use the Euclidian norm for vectors, and the Frobenius norm for matrices
scaled If false, work on the unscaled matrix

Return value
Basis stability information.
ModulemmxprsFair Isaac Corporation Proprietary Information

729

Chapter 21: mmxprs

calcsolinfo
Purpose
SynopsisCalculates a property of an mpsol solution.
function calcsolinfo(solution:mpsol, option:integer):mpsol

Arguments
solution The solution to be checked
optionWhich information to return. Possible values:
XPRS_SOLINFO_ABSPRIMALINFEAS
Calculate the maximum absolute primal
infeasibility
XPRS_SOLINFO_RELPRIMALINFEAS
Calculate the maximum relative primal
infeasibility
XPRS_SOLINFO_MAXMIPFRACTIONAL Calculate the maximum fractionality of theinteger variables
Related topics
refinemipsol.
ModulemmxprsFair Isaac Corporation Proprietary Information

730

Chapter 21: mmxprs

clearmipdir
Purpose
Synopsis

Delete all defined MIP directives.
procedure clearmipdir

Further information
This procedure clears the list of directives defined so far.
Related topics
setmipdir.
ModulemmxprsFair Isaac Corporation Proprietary Information

731

Chapter 21: mmxprs

clearmodcut
Purpose
Synopsis

Delete all defined model cuts.
procedure clearmodcut

Further information
This procedure clears the list of model cuts defined so far.
Related topics
setmodcut.
ModulemmxprsFair Isaac Corporation Proprietary Information732

Chapter 21: mmxprs

commandPurpose
Synopsis

Execute an Optimizer command or enter interactive mode of the Optimizer.
procedure command(cmd:string)procedure command

Argument
cmd
ExampleCommand or sequence of commands separated by "\n" character

Solve a MIP problem and then enter interactive mode:
command("minim\nglobal")commandFurther information
1. When used without parameter, this procedure enters an interactive mode of the Optimizer similar to theconsole mode: model execution is suspended and Optimizer commands can be typed directly. Model
execution resumes after command quit has been typed or the input stream has reached an end of file.
Using the alternate form of the procedure with an argument, one can send a command (or sequence ofcommands) to the Optimizer: this may be useful to execute commands for which there is no mmxprs
interface.
During the execution of this procedure, callbacks set up in the model are effective and the problem
solution status of mmxprs is updated upon termination. Note that, commands altering the problem must
be avoided (like readprob, change of name of the problem, etc.) in order to preserve consistency
between Mosel and Optimizer representations of the problem.
2. When Mosel is running in restricted mode (see Section 1.3.4), the restriction NoExec disables this routine.
ModulemmxprsFair Isaac Corporation Proprietary Information

733

Chapter 21: mmxprs

copysoltoinit
Purpose
Synopsis

Copy solution values to initial values of an NL problem.
procedure copysoltoinit(ms:mpsol)Argumentms

A solution object

Further information
1. This procedure copies the solution values of decision variables from the provided solution ms to theirinitial values for the next run. Doing so it overrides any previously set initial values for the involved
variables. However, the settings for decision variables that are not included in the solution ms remainunchanged.
2. This operation can only be performed on a non-linear problem described using the module mmnl.
Related topics
copysoltoinit, clearinitvals, setinitval.
ModulemmxprsFair Isaac Corporation Proprietary Information734

Chapter 21: mmxprs

crossoverlpsol
Purpose
Synopsis

Crosses over a previously loaded LP solution to a basic solution.
function crossoverlpsol:boolean

Return value
Operation status:
FALSE No valid starting solution provided prior to call using loadlpsol
TRUE Crossover called
Further information
This procedure calls the crossover procedure for an already loaded LP solution followed by the usual
simplex solve afterwards. The solution, solution status and all attributes are set up to match the solve
and are available the usual way.
Related topics
loadlpsol.
ModulemmxprsFair Isaac Corporation Proprietary Information735

Chapter 21: mmxprs

defdelayedrows
Purpose
SynopsisDefine the set of constraints to be treated as delayed rows.
procedure defdelayedrows(cset:set of linctr)

Argumentcset

Set of constraints to load or {} to reset a previous setting

Further information
This procedure stores a reference to the provided set that is used when the problem is loaded into the
optimizer. This set can be modified after the call to this procedure: the optimizer will use the current
content of the set at the time of loading the problem.
ModulemmxprsFair Isaac Corporation Proprietary Information736

Chapter 21: mmxprs

defsecurevecs
Purpose
SynopsisDefine the sets of variables and constraints that must not be removed by presolve.
procedure defsecurevecs(vset:set of mpvar,cset:set of linctr)

Arguments
vset
cset

Set of decision variables to preserve or {} to reset a previous setting
Set of constraints to preserve or {} to reset a previous setting

Further information
This procedure stores references to the provided sets that are used when the problem is loaded into the
optimizer. These sets can be modified after the call to this procedure: the optimizer will use the current
content of the sets at the time of loading the problem.
ModulemmxprsFair Isaac Corporation Proprietary Information

737

Chapter 21: mmxprs

estimatemarginals
Purpose
Synopsis

Estimate better marginal values for variables and constraints for degenerate problems.
procedure estimatemarginals(sbvars:array(vars: set of mpvar) of real)procedure estimatemarginals(dualslb:array(constriants: set of linctr) ofreal, dualsub:array(constriants: set of linctr) of real)procedure estimatemarginals(sbvars:array(vars: set of mpvar) of real,
efforlimit:integer, delta:real)procedure estimatemarginals(dualslb:array(constriants: set of linctr) ofreal, dualsub:array(constriants: set of linctr) of real,
effortlimit:integer)

Arguments
sbvarsAn array of reals that will be populated with the approximations for the marginal values.
The approximation is carried out for the variables included in the variables set.
An array of reals that will be populated with the approximations for the lower bounds fordualslb
the row marginal values. The approximation is carried out for the constraints in theconstraints set.
dualsub
An array of reals that will be populated with the approximations for the upper bounds forthe row marginal values. The approximation is carried out for the constraints in theconstraints set.
efforlimit Effort limit spent to approximate the effect of the move of a variable, expressed as an
upper limit of simplex iterations per variable.
delta
The size of the perturbation applied to force a movement in the variable.

Further information
1. This procedure can be used to estimate the marginal values of variables in degenerate problems. In
degenerate problems, the reduced costs and row duals do not always provide a good representation of
the effect on the objective when forcing a move in a variable. Also, in degenerate problems, the reduced
costs and row duals may depend on the final basis found, and multiple correct alternatives might exists.
This function attempts to identify better marginal values by simulating a move in the variables.
2. Prior to calling estimatemarginals, the current LP problem must have been solved to optimality and an
optimal basis must be available.
3. It is important to note that the procedure provides an estimate only.
4. This procedure relies on the XPRSstrongbranch and XPRSestimaterowdualranges functions,refer to the Xpress Optimizer Reference Manual for more information.
ModulemmxprsFair Isaac Corporation Proprietary Information

738

Chapter 21: mmxprs

fixglobal
Purpose
SynopsisFix values of discrete entitites according to the current solution.
procedure fixglobal
procedure fixglobal(options:integer)

Argument
options Options sent to the library routine XPRSfixglobals
ExampleSolve the MIP problem, reload the problem after solving, fix discrete entities to their solution values, andfinally solve the LP for the continous variables in order to be able to use getrange.
minimize(obj)
fixglobal
minimize(XPRS_LIN, obj)
writeln(getrange(XPRS_UPACT,x))

Further information
1. This procedure fixes the non-continuous variables to their value of the current solution. A call to thisfunction is required when performing sensitivity analysis on MIP problems using getrange.
2. The first form of the procedure corresponds to fixglobal(0).
Related topics
getrange.
ModulemmxprsFair Isaac Corporation Proprietary Information739

Chapter 21: mmxprs

getbstat
Purpose
Synopsis

Get the status of a variable or constraint in a basis.
function getbstat(b:basis,v:mpvar):integerfunction getbstat(b:basis,c:linctr):integer

Argumentsbv
c

A basisA decision variable
A linear constraint

Return value
Basis status. For a variable:-1
Variable is not in the basis
0
Variable is non-basic at lower bound, or superbasic at zero if the variable has no lower bound1
Variable is basic
2
Variable is non-basic at upper bound3
Variable is super-basic
For a constraint:-1
Constraint is not in the basis
0Slack, surplus or artificial is non-basic at lower bound1
Slack, surplus or artificial is basic
2
Slack or surplus is non-basic at upper bound3
Slack or surplus is super-basic
Related topics
savebasis, setbstat, resetbasis.
ModulemmxprsFair Isaac Corporation Proprietary Information

740

Chapter 21: mmxprs

getcomputeallowed
Purpose

SynopsisQuery in what circumstances the current Mosel instance can send optimizations to the Insight Compute
Interface.
function getcomputeallowed:integer

Return value
Value controlling in what circumstances solves may be sent to Insight Compute Interface. Will be one of
the following constants:
XPRS_ALLOW_COMPUTE_ALWAYS
Always allow solves to be sent to Compute.
XPRS_ALLOW_COMPUTE_NEVER
Never allow solves to be sent to Compute.
XPRS_ALLOW_COMPUTE_DEFAULT Allow solves to be sent to Compute only from non-OEM
applications.
Related topics
setcomputeallowed.
ModulemmxprsFair Isaac Corporation Proprietary Information

741

Chapter 21: mmxprs

getdualray
Purpose
Synopsis

Get a dual ray for an infeasible problem.
function getdualray(ray:array(set of linctr) of real):boolean

Argumentray

An array of reals over all constraints in the problem (as loaded) in which the dual ray is returned.

Return value
This procedure returns the dual ray found for the problem if the problem is found to be dual unbounded(thus primal infeasible) and one is available.
Further information
1. The return value of the function is true if a dual ray is available, and false otherwise.
2. The dimension and base set of the ray argument will be set up by the function.
Exampledeclarations
all_constraints : set of linctr
dual_ray : array(all_constraints) of real
end-declarations
if getprobstat <> XPRS_INF thenwriteln("Problem not infeasible.")else
HasRay := getdualray(dual_ray)
if HasRay thenwriteln("Dual ray:")
forall (c in all_constraints)
writeln(getname(c), " ", dual_ray(c))
elsewriteln("No dual ray was found")end-ifend-ifRelated topics
getprimalray
ModulemmxprsFair Isaac Corporation Proprietary Information

742

Chapter 21: mmxprs

getiisPurpose
Synopsis

Compute then get the Irreductible Infeasible Sets (IIS).
procedure getiis(vset:set of mpvar,cset:set of linctr)
procedure getiis(numiis:integer,vset:set of mpvar,cset:set of linctr)
procedure getiis(numiis:integer,ctrtype:array(linctr) of integer)
procedure getiis(numiis:integer,duals:array(linctr) of real)procedure getiis(numiis:integer,isolrow:array(linctr) of boolean)
procedure getiis(numiis:integer,bndtype:array(mpvar) of integer)
procedure getiis(numiis:integer,rdcs:array(mpvar) of real)procedure getiis(numiis:integer,isolcol:array(mpvar) of boolean)

Arguments
vset
cset
numiisctrtypeSet to return the decision variables of the IIS or {} if not required
Set to return the constraints of the IIS or {} if not required
Ordinal number of the IIS
Array to return the sense or type of rows in the IIS (XPRS_IIS_LEQ, XPRS_IIS_GEQ,
XPRS_IIS_EQ , XPRS_IIS_SOS1, XPRS_IIS_SOS2 or XPRS_IIS_INDIC)
duals
Array to return the dual multipliers associated with the rows of the IIS
isolrow Array to return the isolation status of the the rows of the IIS
bndtype Array to return the encoded sense and type of bounds in the IIS
rdcs
Array to return the dual multipliers associated with the bounds of the IIS
isolcol Array to return the isolation status of the the bounds of the IIS

Further information
1. This procedure computes the IIS and stores the result in the provided parameters. The first form of theroutine (numiis not specified) computes all IIS and returns the last set found.
2. The bndtype values have to be decoded using getiissense and getiistype. The first routine may
return XPRS_IIS_LEQ (upper bound), XPRS_IIS_GEQ (lower bound), XPRS_IIS_RNG (lower and upperbound) or XPRS_IIS_EQ (fixed bound). The second one may give XPRS_IIS_BIN (binary),
XPRS_IIS_INT (integer), XPRS_IIS_PINT (partial integer), XPRS_IIS_SEC (semi continuous) or
XPRS_IIS_SINT (semi continuous integer).
3. The sets passed to this procedure are reset before being used.
Related topics
resetiis, isiisvalid, getinfeas.
ModulemmxprsFair Isaac Corporation Proprietary Information

743

Chapter 21: mmxprs

getiissense
Purpose
Synopsis

Decode the sense part of an IIS bound type information.
function getiissense(i:bndtype):integer

Argument
bndtype A bound type as returned by getiis
Return value
Sense part of an IIS bound type.
Related topics
getiis, getiistype.
ModulemmxprsFair Isaac Corporation Proprietary Information

744

Chapter 21: mmxprs

getiistype
Purpose
Synopsis

Decode the type part of an IIS bound type information.
function getiistype(i:bndtype):integer

Argument
bndtype A bound type as returned by getiis
Return value
Type part of an IIS bound type.
Related topics
getiis, getiissense.
ModulemmxprsFair Isaac Corporation Proprietary Information

745

Chapter 21: mmxprs

getinfcause
Purpose
Synopsis

Returns the variable or constraint causing infeasibility.
procedure getinfcause(vars:set of mpvar,ctrs:set of linctr)

Arguments
vars
ctrs

Set to return the infeasible variable or {} if not required
Set to return infeasible constraint or {} if not required

Further information
1. This function can be used to get the variable or constraint responsible for an infeasibility detected either
during matrix generation (invalid bound) or when presolving the problem.
2. The sets passed to this procedure are reset before being used.
Related topics
getinfeas.
ModulemmxprsFair Isaac Corporation Proprietary Information

746

Chapter 21: mmxprs

getinfeas
Purpose
Synopsis

Returns sets of infeasible primal and dual variables.
procedure getinfeas(mx:set of mpvar,mslack:set of linctr,mdual:set oflinctr,mdj:set of mpvar)

Arguments
mx
mslackmdual
mdj

Set to return the infeasible variables or {} if not required
Set to return infeasible constraints or {} if not required
Set to return dual infeasible constraints or {} if not required
Set to return the dual infeasible variables or {} if not required

Related topics
getiis.
ModulemmxprsFair Isaac Corporation Proprietary Information

747

Chapter 21: mmxprs

getlb
Purpose
Synopsis

Get the lower bound of a variable.
function getlb(x:mpvar):realArgumentx

A decision variable

Return value
Lower bound of the variable.
Further information
This function returns the lower bound of a variable that is currently held by the Optimizer. The boundvalue may be changed directly in the Optimizer using setlb. Changes to the variable in Mosel are nottaken into account by this function unless the problem has been reloaded since (procedure loadprob).
Related topics
getub, setlb, setub.
ModulemmxprsFair Isaac Corporation Proprietary Information

748

Chapter 21: mmxprs

getloadedlinctrs
Purpose
Synopsis

Get the linear constraints loaded into the optimiser.
procedure getloadedlinctrs(sc:set of linctr)

Argumentsc

A set of linear constraints

Further information
The result of the operation is added to the current content of the provided set (i.e. the set is not cleared).
Related topics
getloadedmpvars
ModulemmxprsFair Isaac Corporation Proprietary Information

749

Chapter 21: mmxprs

getloadedmpvars
Purpose
Synopsis

Get the decision variables loaded into the optimiser.
procedure getloadedmpvars(sv:set of mpvar)

Argumentsv

A set of decision variables

Further information
The result of the operation is added to the current content of the provided set (i.e. the set is not cleared).
Related topics
getloadedlinctrs
ModulemmxprsFair Isaac Corporation Proprietary Information

750

Chapter 21: mmxprs

getmatcoeff
Purpose
Synopsis

Get the coefficient of a variable or the constant term of a constraint directly from the Optimizer.
function getmatcoeff(c:linctr, x:mpvar):realfunction getmatcoeff(c:linctr):realArgumentscx

A linear constraint
A decision variable

Return value
The coefficient of the varible or the constant term.
Further information
1. This function behaves like getcoeff except that it gets the information from the matrix loaded into the
Optimizer.
2. The routine will fail if no problem has been loaded into the Optimizer or if the constraint or the variable isnot part of the current matrix.
Related topics
getcoeff, setmatcoeff, maximize, minimize.

Fair Isaac Corporation Proprietary Information

751

Chapter 21: mmxprs

getname
Purpose
Synopsis

Get the name of a decision variable or constraint of the problem.
function getname(x:mpvar):string
function getname(c:linctr):string
function getname(nl:nlctr):stringArgumentsxcnl

A decision variable used in the problem
A constraint (or SOS) of the problem
A non linear constraint of the problem

Return value
Name of the given object.
Further information
1. This function returns the name of a decision variable or constraint of the problem that would be used for
matrix exportation. The parameter of this function must be part of the problem — for instance a hidden
constraint cannot be assigned a name.
2. This function requires that the matrix has been generated (e.g. by a call to exportprob or loadprob).
When used with a non linear constraint it is further required for the problem to be loaded into the
optimiser and the parameter XPRS_loadnames must be true.
ModulemmxprsFair Isaac Corporation Proprietary Information752

Chapter 21: mmxprs

getprimalray
Purpose
Synopsis

Get a primal ray for an unbounded problem.
function getprimalray(ray:array(set of mpvar) of real):boolean

Argumentray

An array of reals over all constraints in the problem (as loaded) in which the primal ray isreturned.

Return value
This procedure returns the primal ray found for the problem if the problem is found to be primal
unbounded (thus dual infeasible) and one is available.
Further information
1. The return value of the function is true if a primal ray is available, and false otherwise.
2. The dimension and base set of the ray argument will be set up by the function.
Exampledeclarations
all_variables : set of mpvar
primal_ray : array(all_variables) of real
end-declarations
if getprobstat <> XPRS_UNB thenwriteln("Problem is not unbounded.")else
HasRay := getprimalray(primal_ray)
if HasRay thenwriteln("Primal ray:")
forall (c in all_variables)
writeln(getname(c), " ", primalray(c))
elsewriteln("No primal ray was found")end-ifend-ifRelated topics
getdualray
ModulemmxprsFair Isaac Corporation Proprietary Information

753

Chapter 21: mmxprs

getprobstat
Purpose
Synopsis

Get the Optimizer problem status.
function getprobstat:integer

Return value
Status of the problem currently held in the Optimizer:
XPRS_OPT Solved to optimality
XPRS_UNF Unfinished
XPRS_INF Infeasible
XPRS_UNB Unbounded
XPRS_OTH Unsolved or objective worse than cutoff
ExampleThe following procedure displays the current problem status:
procedure print_status
declarations
status: string
end-declarations
case getprobstat of
XPRS_OPT: status:="Optimum found"
XPRS_UNF: status:="Unfinished"
XPRS_INF: status:="Infeasible"
XPRS_UNB: status:="Unbounded"
XPRS_OTH: status:="Failed"else status:="???"
end-case
writeln("Problem status: ", status)
end-procedure

Further information
More detailed information than what is provided by this function can be obtained with function
getparam, retrieving the problem attributes XPRS_presolvestate, XPRS_lpstatus, and
XPRS_mipstatus (see the Xpress Optimizer Reference Manual).
Related topics
getparam.
ModulemmxprsFair Isaac Corporation Proprietary Information754

Chapter 21: mmxprs

getrange
Purpose
Synopsis

Get a range value for a variable or constraint.
function getrange(w:integer, x:mpvar):realfunction getrange(w:integer, c:linctr):realArgumentsw

Which information to return. Possible values for a variable:
XPRS_UPACT For a variable which is at one of its bounds, the largest value which that boundcan take while the current basis remains optimal
XPRS_LOACT For a variable which is at one of its bounds, the smallest value which that boundcan take while the current basis remains optimal
XPRS_UUP
The change in objective value per unit increase in the variable activity, assuming
the the current basis remains optimal
XPRS_UDN
The change in objective value per unit decrease in the variable activity,
assuming the the current basis remains optimal
XPRS_UCOST The largest value which this variable’s objective coefficient can take while thecurrent basis remains optimal
XPRS_LCOST The smallest value which this variable’s objective coefficient can take while thecurrent basis remains optimal
Possible values for a constraint:xc

XPRS_UPACT The largest value which the constraint RHS can take while the current basis
remains optimal
XPRS_LOACT The smallest value which the constraint RHS can take while the current basis
remains optimal
XPRS_UUP
The change in objective value per unit increase in the constraint RHS, assuming
the the current basis remains optimal
XPRS_UDN
The change in objective value per unit decrease in the constraint RHS, assuming
the the current basis remains optimal
A variable of the problem
A constraint of the problem

Return value
Range information depending on the value of w.
Further information
This function returns ranging information to be used for sensitivity analysis after the problem has been
optimized. On MIP problems, discrete entities have to be “fixed” using the procedure fixglobal before
this function can be called.
Related topics
fixglobal.
ModulemmxprsFair Isaac Corporation Proprietary Information

755

Chapter 21: mmxprs

getscalePurpose
Synopsis

Retrieves scaling information about the currently loaded problem.
procedure getscale(options:integer, scaling:array(set of integer) ofinteger)

Arguments
options Bitmap, matrix data to include: +1 for coefficients, +2 for RHS and +4 for objective
scaling Array where scaling information is returned.
Further information
The indices of the returned array indicate buckets of powers of 10. For example, if scaling(3) is 11, thenthere are 11 elements in the range of [100, 1000]. The scaling array needs to be declared dynmaic.
ModulemmxprsFair Isaac Corporation Proprietary Information

756

Chapter 21: mmxprs

getsensrng
Purpose

Synopsis

Get sensitivity ranges for objective function coefficients, RHS coefficients, variable upper bounds orvariable lower bounds.
function getsensrng(w:integer, x:mpvar):realfunction getsensrng(w:integer, c:linctr):realArgumentswxc

Which information to return. Possible values:
XPRS_UP
Upper sensitivity range
XPRS_DN
Lower sensitivity range
XPRS_UP+XPRS_UBND Upper sensitivity range of the upper bound of the variable
XPRS_DN+XPRS_UBND Lower sensitivity range of the upper bound of the variable
XPRS_UP+XPRS_LBND Upper sensitivity range of the lower bound of the variable
XPRS_DN+XPRS_LBND Lower sensitivity range of the lower bound of the variable
A variable of the problem
A constraint of the problem

Return value
Sensivity range information depending on the value of w.
Further information
This function returns sensitivity ranges for RHS coefficients (if used with a constraint); and for objectivefunction coefficients, upper bounds or lower bounds (if used with a variable). getsensrng can be called
only if an optimal LP solution is available and the problem is not MIP presolved.
ModulemmxprsFair Isaac Corporation Proprietary Information

757

Chapter 21: mmxprs

getsize
Purpose
Synopsis

Get the size of a solution.
function getsize(ms:mpsol):integer

Argumentms

A solution object

Return value
The number of variables stored in the solution.
Related topics
getvars.
ModulemmxprsFair Isaac Corporation Proprietary Information

758

Chapter 21: mmxprs

getsolPurpose
Synopsis

Get the solution value of an expression from a solution object.
function getsol(ms:mpsol,v:mpvar):realfunction getsol(ms:mpsol,c:linctr):realfunction getsol(ms:mpsol,nl:nlctr):realfunction getsol(bv:boolvar):booleanfunction getsol(ms:mpsol,bv:boolvar):booleanfunction getsol(lc:logctr):booleanfunction getsol(ms:mpsol,lc:logctr):boolean

Arguments
ms
v
bv
c
nl
lc

A solution object
A decision variable
A pseudo boolean decision variable
A linear constraint
A non linear constraint
A logical constraint

Return value
Solution value or 0 (or false for a logical parameter).
Further information
This function returns an evaluation of an expression using the provided solution object as solution values
for the decision variables.
Related topics
setsol, savesol, savemipsol.
ModulemmxprsFair Isaac Corporation Proprietary Information759

Chapter 21: mmxprs

getvarPurpose
Synopsis

Get the decision variable associated to a pseudo boolean.
function getvar(bv:boolvar):mpvar

Argumentbv

A pseudo boolean decision variable

Return value
The decision variable associated to the given parameter.
Further information
Each pseudo boolean variable is associated to two decision variables of type mpvar. This function
makes it possible to retrieve these variables: it can be applied to both the variable itself (e.g.
getvar(bv)) and its negation (e.g. getvar(not bv)).
ModulemmxprsFair Isaac Corporation Proprietary Information

760

Chapter 21: mmxprs

getub
Purpose
Synopsis

Get the upper bound of a variable.
function getub(x:mpvar):realArgumentx

A decision variable

Return value
Upper bound of the variable.
Further information
The bound value may be changed directly in the optimizer using setub. Changes to the variable in Mosel
are not taken into account by this function unless the problem has been reloaded since (procedureloadprob).
Related topics
getlb, setlb, setub.
ModulemmxprsFair Isaac Corporation Proprietary Information

761

Chapter 21: mmxprs

getvars
Purpose
Synopsis

Get the set of variables of a solution.
procedure getvars(ms:mpsol,s:set of mpvar)

Argumentsmss

A solution object
A set of decision variables

Further information
This procedure returns in the parameter s the set of variables used by a solution object. Note that thisprocedure replaces the content of the set.
Related topics
getsize.
ModulemmxprsFair Isaac Corporation Proprietary Information

762

Chapter 21: mmxprs

hasfeature
Purpose
SynopsisCheck if a specific feature is supported by the currently used license.
function hasfeature(feature:string):boolean

Argument
feature The name of the feature to check, as it would appear in the Xpress license file
Return value
true if the requested feature is supported, false otherwise.
ModulemmxprsFair Isaac Corporation Proprietary Information

763

Chapter 21: mmxprs

implies
Purpose
SynopsisCreate an implies expression.
function implies(c1:log_or_linctr,c2:log_or_linctr):logctr

Argumentsc1
c2

A linear constraint (linctr) or logical expression (logctr)
A linear constraint (linctr) or logical expression (logctr)

Return value
A new logctr representing the expression.
ExampleThe following example shows several ways of stating the logical relation ’if x1 ≥ 10 then x1 + x2 ≥ 12 andnot x2 ≤ 5’. The implied constraint L is itself a logical constraint, built up by using the operators and andnot in combination with linear constraints.
declarations
R=1..2
C: array(range) of linctr
L: logctr
x: array(R) of mpvar
end-declarations! Linear constraints! Logical constraint! Decision variables

C(1):= x(1)>=10
C(2):= x(2)<=5
C(3):= x(1)+x(2)>=12! Define (temporary) linear ctrs

implies(C(1), C(3) and not C(2))
forall(j in 1..3) C(j):=0! State the implication! Delete the auxiliary ctrs

! The same implication constraint can be stated by:
implies(x(1)>=10, x(1)+x(2)>=12 and not x(2)<=5)! Or also by:
L:= x(1)+x(2)>=12 and not x(2)<=5 ! Define (temporary) logical ctr
implies(x(1)>=10, L)! State the implication
L:= 0! Delete the auxiliary ctr
Further information
1. This function creates a logctr constraint representing an implies condition: if c1 is valid then c2 isenforced.
2. The helper package ’advmod’ must be loaded if this function is used:
uses 'advmod'

Related topics
indicator, xor
ModulemmxprsFair Isaac Corporation Proprietary Information

764

Chapter 21: mmxprs

indicator
Purpose
SynopsisCreate an indicator constraint.
function indicator(type:integer,y:mpvar,ctr:linctr|nlctr):logctr

Arguments
type
y
ctr

The indicator type:-1
for indicator y=0 -> ctr
1
for indicator y=1 -> ctr
The variable associated to the constraint
An inequality constraint

Return value
A new logctr representing the indicator.
ExampleThis example shows how to define two indicator constraints. The second constraint labeled L is statedwith the help of an auxiliary linear constraint definition. This temporary constraint C needs to be deleted
from the problem after having been used in the definition of the indicator constraint. The notationb(1)=1 -> ... should be read as ’if b(1) takes the value 1 then ... must hold’declarations
R=1..2, S=1..3
C: linctr
L: logctr
x: array(S) of mpvar
b: array(R) of mpvar
end-declarations! Linear constraint! Logical (indicator) constraint! Decision variables! Indicator variables

forall(i in R)
b(i) is_binary! Indicator variables must be binaries

C:= x(2)+x(3)<=5! Constraint to transform into indicator ctr.

! Define 2 indicator constraints
indicator(1, b(1), x(1)+x(2)>=12)
L:= indicator(-1, b(2), C)
C:=0! b(1)=1 -> x(1)+x(2)>=12! b(2)=0 -> x(2)+x(3)<=5! Delete the auxiliary constraint definition

Related topics
implies, xor
ModulemmxprsFair Isaac Corporation Proprietary Information

765

Chapter 21: mmxprs

isiisvalid
Purpose
SynopsisCheck whether an IIS number exists.
function isiisvalid(numiis:integer):boolean

Argument
numiisOrdinal number of the IIS

Return value
true if numiis corresponds to an existing IIS.
Related topics
resetiis, getiis.
ModulemmxprsFair Isaac Corporation Proprietary Information

766

Chapter 21: mmxprs

isintegral
Purpose
SynopsisCheck whether a variable (or set of variables) solution value is integral.
function isintegral(x:mpvar):booleanfunction isintegral(s:set of mpvar):boolean

Argumentsxs

A decision variable
A set of decision variables

Return value
true if the variable (or all variables of the set) is integral.
Further information
This function checks whether the current solution value of a variable is integral with respect to thetolerance value of the optimizer (XPRS_MIPSOL). When used with a set, the function returns true if all
variables of the set satisfy the condition.
ModulemmxprsFair Isaac Corporation Proprietary Information

767

Chapter 21: mmxprs

loadbasis
Purpose
Synopsis

Load a previously saved basis.
procedure loadbasis(b:basis)

Argumentb
ExampleA basisThe following saves a basis, changes the problem, and then loads it into the Optimizer, reloading the oldbasis:
declarations
MinCost:linctr
mybasis:basis
end-declarations
savebasis(mybasis)...
loadprob(MinCost)
loadbasis(mybasis)

Further information
1. This procedure loads a basis into the optimizer that has previously been saved using procedure
savebasis or constructed using setbstat.
2. The problem must be loaded in the Optimzer for loadbasis to have any effect. If this has not recently
been carried out using maximize or minimize it must be explicitly loaded using loadprob.
Related topics
loadprob, savebasis, setbstat, getbstat, resetbasis.
ModulemmxprsFair Isaac Corporation Proprietary Information

768

Chapter 21: mmxprs

loadlpsol
Purpose
Synopsis

Load an LP solution into the optimizer.
procedure loadlpsol(x:array(set of mpvar) of real, slack:array(set oflinctr) of real, dual:array(set of linctr) of real, dj:array(set of
mpvar) of real)procedure loadlpsol(x:array(set of mpvar) of real, dual:array(set of linctr)
of real)procedure loadlpsol(x:array(set of mpvar) of real)

Arguments
x
slack
dual
dj

An array containing the primal solution
An array containing the constraint slacks
An array containing the dual multipliers
An array containing the reduced cost values

Related topics
crossoverlpsol.
ModulemmxprsFair Isaac Corporation Proprietary Information

769

Chapter 21: mmxprs

loadmipsol
Purpose
Synopsis

Load a MIP solution into the optimizer.
function loadmipsol(s:array(set of mpvar) of real):integerfunction loadmipsol(solnum:integer):integerfunction loadmipsol(ms:mpsol):integer

Argumentss
An array containing the solution
solnum Solution number (between 1 and XPRS_enumsols)ms
A solution object
Return value
Operation status:-1
Solution rejected because an error occurred
Solution accepted. When loading a solution before a MIP solve, the solution is always accepted.
0
It is placed in temporary storage until the MIP solve is started.
1
Solution rejected because it is infeasible
2
Solution rejected because it is cut off
3
Solution rejected because the LP reoptimization was interrupted
ExampleThe following saves a MIP solution, modifies the problem, and then loads it into the Optimizer, reloading
the MIP solution:
declarations
MinCost:linctr
mysol: array(set of mpvar) of real
result: integer
end-declarations
savemipsol(mysol)...
! Make some changes
loadprob(MinCost)
result:= loadmipsol(mysol)
if result<>0 then writeln("Loading MIP solution failed"); end-if
minimize(MinCost)

Fair Isaac Corporation Proprietary Information

770

Chapter 21: mmxprs

Further information
1. This function loads a MIP solution into the optimizer that has previously been saved using procedure
savemipsol or constructed by some external heuristic. In the latter case a value needs to be assigned
to each discrete variable in the problem, such as mysol(x):= 1 (where x is a decision variable of typempvar).
2. The values for the continuous variables in the s array are ignored and are calculated by fixing the integer
variables and reoptimizing.
3. The second form of the routine can be called after a search for n-best solutions has been performed by
the optimiser: the selected solution is used as input.
4. The current problem definition must be loaded into the Optimizer for loadmipsol to have any effect. If
this has not recently been done, e.g., by calling maximize or minimize, the problem must be explicitly
loaded using loadprob.
5. If the MIP solution is accepted by the Optimizer it causes the MIPABSCUTOFF control to be set
accordingly. The provided MIP solution may help guiding the MIP heuristics but the branch-and-boundsearch will start from the initial LP relaxation solution as usual.
Related topics
savemipsol, addmipsol.
ModulemmxprsFair Isaac Corporation Proprietary Information

771

Chapter 21: mmxprs

loadprob
Purpose
Synopsis

Load a problem into the optimizer.
procedure loadprob(obj:linctr)
procedure loadprob(obj:linctr, extravar:set of mpvar)
procedure loadprob(qobj:qexp)
procedure loadprob(qobj:qexp, extravar:set of mpvar)
procedure loadprob(nlobj:nlctr)
procedure loadprob(nlobj:nlctr, extravar:set of mpvar)
procedure loadprob(rbobj:robustctr)
procedure loadprob(rbobj:robustctr, extravar:set of mpvar)

Arguments
obj
qobj
nlobj
rbobj
extravar

Objective function constraint
Quadratic objective function (with module mmquad)
Non linear objective function (with module mmnl)
Robust objective function (with module mmrobust)
Extra variables to include

Further information
1. This procedure explicitly loads a problem into the optimizer. It gets called automatically by the
optimization procedures minimize and maximize if the problem has been modified in Mosel since thelast call to the optimizer. Nevertheless in some cases, namely before loading a basis, it may be necessary
to reload the problem explicitly using this procedure. The parameter extravar is a set of variables to be
included into the problem even if they do not appear in any constraint (i.e. they become empty columns in
the matrix).
2. Support for quadratic programming requires the module mmnl.
3. Support for general nonlinear programming requires the module mmxnlp.
4. Support for robust programming requires the module mmrobust.
Related topics
maximize, minimize.
ModulemmxprsFair Isaac Corporation Proprietary Information

772

Chapter 21: mmxprs

maximize, minimize
Purpose
SynopsisMaximize/minimize the current problem.
procedure maximize(alg:integer, obj:linctr)
procedure maximize(obj:linctr)
procedure maximize(alg:integer, qobj:qexp)
procedure maximize(qobj:qexp)
procedure maximize(alg:integer, nlobj:nlctr)
procedure maximize(nlobj:nlctr)
procedure maximize(rbobj:robustctr)
procedure maximize(alg:integer, rbobj:robustctr)

Arguments
alg

Algorithm choice:

XPRS_BAR
Newton-Barrier to solve LP
XPRS_DUAL
Dual simplex
XPRS_NET
Network solver
XPRS_LIN
Only solve LP ignoring all discrete entities
XPRS_PRI
Primal simplex
XPRS_ENUM
Start a search for the n-best MIP solutions
XPRS_LPSTOP Stop the MIP solution process after solving the first LP
XPRS_CONT
Continue a previously interrupted solution process
XPRS_LOCAL
Solve the linearization of the problem (mmxnlp only)
XPRS_COREPB Solve the linear part of the problem (mmxnlp only)
XPRS_TUNE
Enable the tuner
obj
Objective function constraint
qobj Quadratic objective function (with module mmquad)nlobj Non linear objective function (with module mmnl)
rbobj Robust objective function (with module mmrobust)
ExampleThe following maximizes Profit using the dual simplex algorithm and stops before thebranch-and-bound search:declarations
Profit:linctr
end-declarations
maximize(XPRS_DUAL+XPRS_LPSTOP, Profit)
The following minimizes MinCost using the Newton-Barrier algorithm and ignoring all discrete entities
declarations
MinCost:linctr
end-declarations
minimize(XPRS_BAR+XPRS_LIN, MinCost)

Fair Isaac Corporation Proprietary Information

773

Chapter 21: mmxprs

Further information
1. This procedure calls the Optimizer to maximize/minimize the current problem (excluding all hidden
constraints) using the given constraint as objective function. Optionally, the algorithm to be used can be
defined. By default, the branch-and-bound search is executed automatically if the problem contains any
discrete entities. Where appropriate, several algorithm choice parameters may be combined (using plus
signs).
2. If XPRS_LIN is specified, then the discreteness of all discrete entities is ignored, even during thepresolve procedure.
3. If XPRS_LPSTOP is specified, then just the LP at the top node is solved and no Branch-and-Bound searchis initiated. But the discreteness of the discrete entities is taken into account in presolving the LP at the
top node. Note also that getprobstat still returns information related to the MIP problem when thisoption is used although only an LP solve has been executed and the solution information returned by
getsol corresponds to the current LP solution. However, if the the MIP is solved to optimality during thiscall, the MIP optimal solution will be returned by getsol.
4. If XPRS_CONT is used after a solve has completed, the routine returns immediately without altering thecurrent problem status.
5. If XPRS_ENUM is specified, the optimiser starts a search for the n-best MIP solutions. The maximum
number of solutions to store may be specified using the XPRS_enummaxsol (default: 10). After the
execution of the enumeration, the number of solutions found during the search is returned by the control
parameter XPRS_enumsols. The procedure selectsol can then be used to select one of thesesolutions.
6. If XNLP_LOCAL is specified for a non-linear problem having been loaded using mmxnlp and which havebeen solved using XSLP, then the current linearization will be reoptimized.
7. If XPRS_TUNE is specified the problem will be tuned and then solved with the best control settings
identified by the tuner. For a user guide about the tuner, please refer to the documentation of the Xpress
Optimizer.
8. If XNLP_COREPB is specified for a non-linear problem having been loaded using mmxnlp, then only thelinear part of the problem will be loaded and optimized. This is usefull for checking if the linear part of the
problem is well posed.
9. Support for quadratic programming requires the module mmnl.
10. Support for general nonlinear programming requires the module mmxnlp.
11. Support for robust programming requires the module mmrobust.
Related topics
postsolve, loadprob, selectsol, XPRS_maxupdc.
ModulemmxprsFair Isaac Corporation Proprietary Information

774

Chapter 21: mmxprs

postsolve
Purpose
Synopsis

Postsolve the current matrix.
procedure postsolve

Further information
After an optimisation operation has been interrupted before its completion, the matrix held into the
optimiser remains in a presolved state. In this state direct matrix operations (like fixing bounds) cannot
be applied: this routine restores the problem in its original state that is just after it was loaded into the
optimiser. As an alternative to postsolving the matrix, the problem may be entirely reloaded using
loadprob.
Related topics
maximize, minimize.
ModulemmxprsFair Isaac Corporation Proprietary Information

775

Chapter 21: mmxprs

readbasis
Purpose
Synopsis

Read a basis from a file.
procedure readbasis(fname:string,options:string)Arguments
fname
Extended file nameoptions String of options
Further information
This procedure reads in a basis from a file by calling the function XPRSreadbasis of the Optimizer. Notethat basis save/read procedures can be used only if the constraint and variable names have been loaded
into the Optimizer (control parameter XPRS_loadnames set to true) and all constraints are named. For
more detail on the options and behavior of this procedure refer to the Xpress Optimizer Reference Manual.
Related topics
writebasis.
ModulemmxprsFair Isaac Corporation Proprietary Information

776

Chapter 21: mmxprs

readdirs
Purpose
Synopsis

Read directives from a file.
procedure readdirs(fname:string)Argument
fname Extended file name
Further information
This procedure reads in directives from a file by calling the function XPRSreaddirs of the Optimizer.
Note that directives save/read procedures can be used only if variable names have been loaded into the
Optimizer (parameter XPRS_loadnames set to true).
Related topics
writedirs.
ModulemmxprsFair Isaac Corporation Proprietary Information

777

Chapter 21: mmxprs

readsol
Purpose
Synopsis
Synopsis

Read a solution from a file.
procedure readsol(fname:string,options:string)procedure readsol(fname:string,options:string)procedure readsol(sol:array(mpvar) of real,fname:string,options:string)procedure readsol(sol:mpsol,fname:string,options:string)procedure readsol(sol:mpvar,fname:string,options:string)Arguments
fname
Extended file nameoptions String of options
sol
Object to load the solution into
Further information
This procedure reads in a solution from a file by calling the function XPRSreadslxsol of the Optimizer.
Note that solution save/read procedures can be used only if the constraint and variable names have been
loaded into the Optimizer (control parameter XPRS_loadnames set to true) and all constraints are
named. For more detail on the options and behavior of this procedure refer to the Xpress Optimizer
Reference Manual.
Related topics
writesol.
ModulemmxprsFair Isaac Corporation Proprietary Information

778

Chapter 21: mmxprs

refinemipsol
Purpose
Synopsis

Executes the MIP solution refiner on an mpsol solution.
function refinemipsol(solution:mpsol):mpsol
function refinemipsol(solution:mpsol, options:integer):mpsol

Arguments
solution The solution to be refined
options
Options passed to the solution refiner. Please refer to XPRSrefinemipsol for theavailable options
Related topics
calcsolinfo.
ModulemmxprsFair Isaac Corporation Proprietary Information

779

Chapter 21: mmxprs

rejectintsol
Purpose
Synopsis

Reject the solution provided to the PREINTSOL callback.
procedure rejectintsol

Further information
This procedure cannot be called from outside of the PREINTSOL callback.
Related topics
setcallback.
ModulemmxprsFair Isaac Corporation Proprietary Information

780

Chapter 21: mmxprs

repairinfeas
Purpose
Synopsis

Relaxing bounds to repair infeasibility.
procedure repairinfeas(alrp:array(linctr) of real, agrp:array(linctr) ofreal, albp:array(mpvar) of real, aubp:array(mpvar) of real)procedure repairinfeas(alrp:array(linctr) of real, agrp:array(linctr) ofreal, albp:array(mpvar) of real, aubp:array(mpvar) of real,
phs2:string, delta:real,optfg:string)procedure repairinfeas(flags:string, lrp:real, grp:real, lbp:real, ubp:real,delta:real)procedure repairinfeas(flags:string)procedure repairinfeas(alrp:array(linctr) of real, agrp:array(linctr) ofreal, albp:array(mpvar) of real, aubp:array(mpvar) ofreal,alrb:array(linctr) of real,agrb:array(linctr) ofreal,albb:array(mpvar) of real,aubb:array(mpvar) ofreal,phs2:string,delta:real,optfg:string)Arguments
alrp
agrp
albp
aubp
alrb

Array of preferences for relaxing the less or equal side of row
Array of preferences for relaxing the greater or equal side of row
Array of preferences for relaxing lower bounds
Array of preferences for relaxing upper bounds
Array of upper bounds to be imposed on the amount of relaxation allowed for the less or equalside of row
agrb Array of upper bounds to be imposed on the amount of relaxation allowed for the greater or
equal side of row
albb Array of upper bounds to be imposed on the amount of relaxation allowed for lower bounds
aubb Array of upper bounds to be imposed on the amount of relaxation allowed for upper bounds
phs2 A 1-character string controling the second phase optimization
lrp
Preference for relaxing the less or equal side of row
grp
Preference for relaxing the greater or equal side of row
lbp
Preference for relaxing lower bounds
ubp
Preference for relaxing upper bounds
delta Relaxation multiplier for the second phase-1
flags A 3-character string defining the p/o/g flags
optfg Flags to be passed to the optimizer

Fair Isaac Corporation Proprietary Information

781

Chapter 21: mmxprs

Further information
1. This routine is an interface to the Optimizer functions XPRSrepairweightedinfeas and
XPRSrepairinfeas. Please refer to the Xpress Optimizer Reference Manual for further details.
2. The 2 first forms call the Optimizer routine XPRSrepairweightedinfeas. Missing preferences aretreated as 0; the default value for phs2 is "d" and the default value for delta is 0.001.
3. The third and fourth forms call the Optimizer routine XPRSrepairinfeas. If flags is not specified(empty string), a default value of "cog" is used. If preferences and delta are not given, all preferences
are set to 1 and delta is 0.001.
4. The last form calls the Optimizer routine XPRSrepairweightedinfeasbounds, allowing to bound theamount of relaxation applied on a per row or bound basis. Only positive bounds are applied; a zero or
negative bound is ignored and the amount of relaxation allowed for the corresponding row or bound is
not limited. The effect of a zero bound on a row or bound would be equivalent with not relaxing it, and canbe achieved by setting its preference array value to zero instead, or not including it in the preference
arrays. The default value for phs2 is "d".
5. Negative preferences translate to quadratic penalties applied for the corresponding rows or bounds.
ModulemmxprsFair Isaac Corporation Proprietary Information

782

Chapter 21: mmxprs

resetbasis
Purpose
Synopsis

Reset a basis.
procedure resetbasis(b:basis)

Argumentb

A basisFurther information
This function clears the information stored in a basis object.
Related topics
loadbasis, savebasis, setbstat, resetbasis.
ModulemmxprsFair Isaac Corporation Proprietary Information

783

Chapter 21: mmxprs

resetiis
Purpose
Synopsis

Reset the search for IIS.
procedure resetiis

Further information
This procedure resets the search for IIS and clears all information already computed related to IIS.
Related topics
getiis.
ModulemmxprsFair Isaac Corporation Proprietary Information

784

Chapter 21: mmxprs

resetsol
Purpose
Synopsis

Reset a solution.
procedure resetsol(ms:mpsol)procedure resetsol(ms:mpsol,v:mpvar)
procedure resetsol(ms:mpsol,bv:boolvar)

Argumentsmsv
bv

A solution object
A decision variable
A pseudo boolean decision variable

Further information
When used with a single argument this procedure clears the information stored in the specified solution
object (this is equivalent to calling reset). With two arguments the designated entity is removed fromthe solution object (no operation is performed if the corresponding variable was not yet part of thesolution).
Related topics
setsol, savesol, savemipsol, getsize.
ModulemmxprsFair Isaac Corporation Proprietary Information

785

Chapter 21: mmxprs

savebasis
Purpose
Synopsis

Save the current basis.
procedure savebasis(b:basis)

Argumentb

A basisFurther information
This function saves the current basis into the provided basis object.
Related topics
loadbasis, setbstat, getbstat, resetbasis.
ModulemmxprsFair Isaac Corporation Proprietary Information

786

Chapter 21: mmxprs

savemipsol
Purpose
Synopsis

Save the current solution into the provided array or solution object.
procedure savemipsol(s:array(set of mpvar) of real)procedure savemipsol(ms:mpsol)Argumentssms

An array to return the solution
A solution object

Further information
1. This procedure saves the current solution into the provided array. The resulting datastructure may be
used as input for the loadmipsol function.
2. If the index set of the array is dynamic, the procedure may extend it in order to have all variables of the
problem. Otherwise the solution is saved only for the variables included in this set.
3. Only non-continuous variables are saved when this procedure is used with an mpsol argument. Usesavesol to save the values of all variables.
Related topics
loadmipsol, savesol.
ModulemmxprsFair Isaac Corporation Proprietary Information

787

Chapter 21: mmxprs

savesol
Purpose
Synopsis

Save the current solution into a solution object.
procedure savesol(ms:mpsol)Argumentms

A solution object

Further information
This procedure saves the current solution into the provided solution object. As opposed to thesavemipsol routine all variables are saved independently of their type.
Related topics
savemipsol.
ModulemmxprsFair Isaac Corporation Proprietary Information

788

Chapter 21: mmxprs

savestate
Purpose
Synopsis

Save current state of the Optimizer to a file.
procedure savestate(fname:string)Argument
fname Extended file name
Further information
The produced file (Optimizer SVF file format) can then be used as input to Optimizer console using
optimizer’s command RESTORE.
ModulemmxprsFair Isaac Corporation Proprietary Information

789

Chapter 21: mmxprs

selectsol
Purpose
Synopsis

Select one of the solutions found by solution enumerator.
procedure selectsol(solnum:integer)

Argument
solnumSolution number (between 1 and XPRS_enumsols)

Further information
1. This routine can be called after a search for n-best solutions has been performed by the optimizer in order
to select a particular solution.
2. Once a solution has been selected, the functions getsol (applied to decision variables) and getobjval
return values related to this solution.
ModulemmxprsFair Isaac Corporation Proprietary Information

790

Chapter 21: mmxprs

setarchconsistency
Purpose
Synopsis

Sets the value of the optimizer architecture control.
procedure setarchconsistency(controlvalue:integer)

Argument
controlvalue Value of the optimizer architecture control
Further information
Please refer to the Xpress Optimizer Reference Manual for more details.
ModulemmxprsFair Isaac Corporation Proprietary Information

791

Chapter 21: mmxprs

setbstat
Purpose
Synopsis

Set the status of a variable or constraint in a basis.
procedure setbstat(b:basis,v:mpvar,s:integer)
procedure setbstat(b:basis,c:linctr,s:integer)

Argumentsbv
cs

A basisA decision variable
A linear constraint
Basis status. For a variable:-1
Remove the variable from the basis
0
Variable is non-basic at lower bound, or superbasic at zero if the variable has nolower bound1
Variable is basic
2
Variable is non-basic at upper bound3
Variable is super-basic
For a constraint:-1
Remove the constraint from the basis
0Slack, surplus or artificial is non-basic at lower bound1
Slack, surplus or artificial is basic
2
Slack or surplus is non-basic at upper bound3
Slack or surplus is super-basic

Related topics
savebasis, getbstat, resetbasis.
ModulemmxprsFair Isaac Corporation Proprietary Information

792

Chapter 21: mmxprs

setcallback
Purpose
Synopsis

Set optimizer callback functions and procedures.
procedure setcallback(cbtype:integer, cb:string)procedure setcallback(cbtype:integer, pr:procedure|function)

Arguments
cbtype Type of the callback:
Simplex log callback
Cut log callback
Global log callback
Barrier log callback
User select node callback
User preprocess node callback
User optimal node callback
User infeasible node callback
User integer solution callback
User cut-off node callback
New node callback
Barrier iteration callback
Cut manager (branch-and-bound node) callback
User choose branching variable callback
Integer solution callback called before acceptation
Gap notify callback
Integer notify callback called each time a solution addedwith addmipsol is processed
XPRS_CB_PRESOLVE
A callback fired after presolve is performed
XPRS_CB_COMPUTERESTART A callback fired when a solve in compute mode had to berestarted
XPRS_CB_CHECKTIME
Check time callback
Name of the callback function/procedure (that must be public); the parameters and the type of
XPRS_CB_LPLOG
XPRS_CB_CUTLOG
XPRS_CB_GLOBALLOG
XPRS_CB_BARLOG
XPRS_CB_CHGNODE
XPRS_CB_PRENODE
XPRS_CB_OPTNODE
XPRS_CB_INFNODEXPRS_CB_INTSOLXPRS_CB_NODECUTOFFXPRS_CB_NEWNODEXPRS_CB_BARITER
XPRS_CB_CUTMGR
XPRS_CB_CHGBRANCHXPRS_CB_PREINTSOLXPRS_CB_GAPNOTIFY
XPRS_CB_SOLNOTIFY

cb

Fair Isaac Corporation Proprietary Information

793

Chapter 21: mmxprs

prExamplethe return value (if any) vary depending on the type of the callback:function cb:boolean
XPRS_CB_LPLOG
function cb:boolean
XPRS_CB_CUTLOG
function cb:boolean
XPRS_CB_GLOBALLOG
function cb:boolean
XPRS_CB_BARLOG
function cb(node:integer):integer
XPRS_CB_CHGNODE
function cb:boolean
XPRS_CB_PRENODE
function cb:boolean
XPRS_CB_OPTNODE
procedure cb
XPRS_CB_INFNODE
procedure cb
XPRS_CB_INTSOL
procedure cb(node:integer)
XPRS_CB_NODECUTOFF
procedure cb(parent:integer,new:integer,branch:integer)
XPRS_CB_NEWNODE
function cb:integer
XPRS_CB_BARITER
function cb:boolean
XPRS_CB_CUTMGR
procedure cb(e:integer,u:integer,d:real)
XPRS_CB_CHGBRANCH
procedure cb(isheur:boolean,cutoff:real)
XPRS_CB_PREINTSOL
procedure cb(rt:real,at:real,aot:real,abt:real) XPRS_CB_GAPNOTIFY
procedure cb(solid:string,status:integer)
XPRS_CB_SOLNOTIFY
procedure cb
XPRS_CB_PRESOLVE
procedure cb
XPRS_CB_COMPUTERESTART
function cb:boolean
XPRS_CB_CHECKTIME
A subroutine reference compatible with the corresponding callback (see above).

The following example defines a procedure to handle solution printing and sets it to be called wheneveran integer solution is found using the integer solution callback:public procedure printsol
declarations
objval:real
end-declarations
objval:= getparam("XPRS_lpobjval")
writeln("Solution value: ", objval)
end-procedure
setcallback(XPRS_CB_INTSOL, "printsol")

Fair Isaac Corporation Proprietary Information

794

Chapter 21: mmxprs

Further information
1. This procedure sets the optimizer callback functions and procedures. For a detailed description of thesecallbacks the user is referred to the Xpress Optimizer Reference Manual.
2. Passing an empty string ("") as the function name disables the corresponding callback.
3. The arguments of the Mosel subroutines implementing callback functions correspond to the arguments
documented in the Xpress Optimizer Reference Manual, with the exception of arguments that are used for
passing back information to the solver: these are replaced by the subroutine return values. For the logging
callbacks, the return value true interrupts the solving. For the PRENODE and OPTNODE callbacks thereturn value true declares the current node to be infeasible. The return value of the BARITER callback isthe selected barrier action (see XPRSaddcbbariteraction in the Xpress Optimizer Reference Manualfor details). The cut manager routine is called repeatedly at each node until it returns false.
4. Whilst the solution values can be accessed from Mosel in any callback function/procedure, all otherinformation such as the problem status or the value of the objective function must be obtained directlyfrom the Optimizer using function getparam.
5. The function setucbdata can be used to return information to the optimizer from the callback‘CHGBRANCH’.
6. The functions rejectintsol and setcbcutoff can be used to return information to the optimizer
from the callback ‘PREINTSOL’.
7. The function setgndata can be used to return information to the optimizer from the callback‘GAPNOTIFY’.
8. When the mmxnlp model is used, this function can also be used to set the callbacks relevant to non-linear
problems only. Please see the documentation of the mmxnlp module for the list of extra callbacks.
ModulemmxprsFair Isaac Corporation Proprietary Information

795

Chapter 21: mmxprs

setcomputeallowed
Purpose

Synopsis

Controls in what circumstances the current Mosel instance can send optimizations to the InsightCompute Interface.
procedure setcomputeallowed(allowed:integer)

Argument
allowed Value controlling in what circumstances solves may be sent to Insight Compute Interface.
Must be one of the following constants:
XPRS_ALLOW_COMPUTE_ALWAYS
Always allow solves to be sent to Compute.
XPRS_ALLOW_COMPUTE_NEVER
Never allow solves to be sent to Compute.
XPRS_ALLOW_COMPUTE_DEFAULT Allow solves to be sent to Compute only from
non-OEM applications.
Further information
1. This procedure affects all models running in the current Mosel instance.
2. If the user enables Insight 5 Compute Interface but the value passed to this function does not allow theInsight Compute Interface to be used, any solves will terminate with an immediate error. This function
can be used to prevent solves from being sent to Insight Compute but cannot be used to force solves tobe performed locally. The purpose of this function is to allow applications that do not want to support
Insight Compute Interface to prevent it being used.
Related topics
getcomputeallowed.
ModulemmxprsFair Isaac Corporation Proprietary Information

796

Chapter 21: mmxprs

setcbcutoff
Purpose
Synopsis

Set the cutoff to be returned to the Optimizer by the PREINTSOL callback.
procedure setcbcutoff(cutoff:real)

Argument
cutoff

New cutoff value for the current solution

Further information
This procedure cannot be called from outside of the PREINTSOL callback.
Related topics
setcallback.
ModulemmxprsFair Isaac Corporation Proprietary Information

797

Chapter 21: mmxprs

setgndata
Purpose
Synopsis

Update data to be returned to the Optimizer by the GAPNOTIFY callback.
procedure setgndata(what:integer, target:real)

Arguments
what

What target to update. Possible values:
XPRS_GN_RELTARGET
Relative gap
XPRS_GN_ABSTARGET
Absolute gap
XPRS_GN_ABSOBJTARGET
Absolute gap on objective
XPRS_GN_ABSBOUNDTARGET Absolute gap on boundtarget New target value

Further information
This procedure stores the provided information that will be returned to the optimizer when the callback
terminates. This procedure cannot be called from outside of the GAPNOTIFY callback.
Related topics
setcallback.
ModulemmxprsFair Isaac Corporation Proprietary Information

798

Chapter 21: mmxprs

setlb
Purpose
Synopsis

Set the lower bound of a variable.
procedure setlb(x:mpvar,r:real)

Argumentsxr

A decision variable
Lower bound value

Further information
This procedure changes the lower bound of a variable directly in the Optimizer, that is, the bound is
modified in the problem that is currently loaded in the Optimizer but does not get recorded in the problem
definition held in Mosel. If the problem has not yet been loaded into the Optimizer then the new boundvalue is ignored. Reloading the problem into the Optimizer after a call to setlb will reset the lower boundfor the variable to the value computed by Mosel, that is, the bound value resulting from setlb isoverwritten.
Related topics
getlb, getub, loadprob, setub.
ModulemmxprsFair Isaac Corporation Proprietary Information

799

Chapter 21: mmxprs

setmatcoeff
Purpose
Synopsis

Set the coefficient of a variable or the constant term directly in the Optimizer.
procedure setmatcoeff(c:linctr, x:mpvar, r:real)procedure setmatcoeff(c:linctr, r:real)

Argumentscxr

A linear constraint
A decision variable
Coefficient or constant term

Further information
1. This procedure behaves like setcoeff except that it updates only the matrix loaded into the Optimizer,
the problem representation of Mosel is not changed. Reloading the problem into the Optimizer will
restore the matrix to the Mosel representation of the problem.
2. The routine will fail if no problem has been loaded into the Optimizer or if the constraint or the variable isnot part of the current matrix.
3. After a call to this procedure the control parameter XPRS_maxupdc gets the value 1 if it was set to 0
before.
Related topics
setcoeff, setlb, setub, maximize, minimize, XPRS_maxupdc, getmatcoeff.

Fair Isaac Corporation Proprietary Information

800

Chapter 21: mmxprs

setmipdir
Purpose
Synopsis

Set a directive on a variable or Special Ordered Set.
procedure setmipdir(x:mpvar,t:integer,r:real)procedure setmipdir(x:mpvar,t:integer)
procedure setmipdir(c:linctr,t:integer,r:real)procedure setmipdir(c:linctr,t:integer)

Argumentsxcrt

A decision variable
A linear constraint (of type SOS)
A real value
Directive type, which may be one of:
XPRS_PR
XPRS_UPXPRS_DN
XPRS_PU
XPRS_PD
XPRS_BRr is a priority (integer value between 1 and 1000 where 1 is the highest priority, 1000
the lowest)
Force up first
Force down firstr is an up pseudo costr is a down pseudo cost
Force branching even if satisfied

Further information
This procedure sets a directive on a discrete entity. Note that the priority value is converted into an
integer. The directives are loaded into the Optimizer at the same time as the problem itself.
Related topics
clearmipdir, readdirs, writedirs.
ModulemmxprsFair Isaac Corporation Proprietary Information

801

Chapter 21: mmxprs

setmodcut
Purpose
Synopsis

Mark a constraint as a model cut.
procedure setmodcut(c:linctr)

Argumentc

A linear constraint

Further information
This procedure marks the given constraint as a model cut. The list of model cuts is sent to the Optimizer
when the matrix is loaded.
Related topics
clearmodcut.
ModulemmxprsFair Isaac Corporation Proprietary Information

802

Chapter 21: mmxprs

setsolPurpose
SynopsisDefine the value associated to a decision variabe in a solution object.
procedure setsol(ms:mpsol,v:mpvar,s:real)procedure setsol(ms:mpsol,bv:boolvar,t:boolean)

Arguments
ms
v
bv
s
t

A solution object
A decision variable
A pseudo boolean decision variable
The solution value as a real
The solution value as a boolean

Further information
1. This procedure associates a solution value to a decision variable in a solution object. If the variable isalready included in the solution, its value is replaced. Otherwise the solution is extended with the newvariable.
2. When the function is applied to a pseudo boolean variable, the values for the two decision variables
associated to the entity are updated (value and its negation).
Related topics
getsol, resetsol, savesol, savemipsol.
ModulemmxprsFair Isaac Corporation Proprietary Information

803

Chapter 21: mmxprs

setub
Purpose
Synopsis

Set the upper bound of a variable.
procedure setub(x:mpvar,r:real)

Argumentsxr

A decision variable
Upper bound value

Further information
This procedure changes the upper bound of a variable directly in the Optimizer, that is, the bound is
modified in the problem that is currently loaded in the Optimizer but does not get recorded in the problem
definition held in Mosel. If the problem has not yet been loaded into the Optimizer then the new boundvalue is ignored. Reloading the problem into the Optimizer after a call to setub will reset the upper boundfor the variable to the value computed by Mosel, that is, the bound value resulting from setub isoverwritten.
Related topics
getlb, getub, loadprob, setlb.
ModulemmxprsFair Isaac Corporation Proprietary Information

804

Chapter 21: mmxprs

setucbdata
Purpose
Synopsis

Update data to be returned to the Optimizer by the CHGBRANCH callback.
procedure setucbdata(x:mpvar, u:integer, e:real)procedure setucbdata(s:linctr, u:integer, e:real)procedure setucbdata(n:integer, u:integer, e:real)

Arguments
x
s
n
u

e

A decision variable
An SOS
A column or SOS number as provided by the optimizer
Direction for branching. Possible values:0
Upward branch made second (branch on column)
1
Upward branch made first (branch on column)
2
Upward branch made second (branch on SOS)
3
Upward branch made first (branch on SOS)
Estimated degradation at the node

Further information
This procedure stores the provided information that will be returned to the optimizer when the callback
terminates. This procedure cannot be called from outside of the CHGBRANCH callback.
Related topics
setcallback.
ModulemmxprsFair Isaac Corporation Proprietary Information

805

Chapter 21: mmxprs

stopoptimize
Purpose
SynopsisInterrupt the optimizer algorithms.
procedure stopoptimize(why:integer)

Argument
why

The reason for stopping. Possible reasons:
XPRS_STOP_TIMELIMIT
XPRS_STOP_CTRLC
XPRS_STOP_NODELIMIT
XPRS_STOP_ITERLIMIT
XPRS_STOP_MIPGAPXPRS_STOP_SOLLIMIT
XPRS_STOP_USER

Time limit hit
Control C hit
Node limit hit
Iteration limit hit
MIP gap is sufficiently small
Solution limit hit
User interrupt

Further information
This procedure can be called from any callback. It is ignored if used from outside an optimization
process.
ModulemmxprsFair Isaac Corporation Proprietary Information

806

Chapter 21: mmxprs

unloadprob
Purpose
Synopsis

Unload the problem held in the optimizer.
procedure unloadprob

Further information
1. This procedure "unloads" the optimizer by releasing all the resources it has allocated for its processing(internal representation, solution information, working files).
2. This procedure resets the control parameters XPRS_EXTRACOLS, XPRS_EXTRAROWS,
XPRS_EXTRAELEMS to their default values.
Related topics
maximize, minimize, loadprob.
ModulemmxprsFair Isaac Corporation Proprietary Information

807

Chapter 21: mmxprs

uselastbarsol
Purpose
Synopsis

Sets up the last barrier solve’s solution as the current one if one is available
function uselastbarsol:boolean

Return value
Operation status:
FALSE No barrier solution is available
TRUE The barrier solution is now the active solution
Further information
This fucntion allows to access the barrier solution before a crossover was performed. The solution,
solution status and objective are set up to match the barrier solution and are available the usual way.
ModulemmxprsFair Isaac Corporation Proprietary Information

808

Chapter 21: mmxprs

writebasis
Purpose
SynopsisWrite the current basis to a file.
procedure writebasis(fname:string,options:string)Arguments
fname
Extended file nameoptions String of options
Further information
This procedure writes the current basis to a file by calling the Optimizer function XPRSwritebasis.
Note that basis save/read procedures can be used only if the constraint and variable names have been
loaded into the Optimizer (parameter XPRS_loadnames set to true) and all constraints are named. For
more detail on the options and behavior of this procedure, refer to the Xpress Optimizer Reference Manual.
Related topics
readbasis.
ModulemmxprsFair Isaac Corporation Proprietary Information809

Chapter 21: mmxprs

writedirs
Purpose
SynopsisWrite current directives to a file.
procedure writedirs(fname:string)Argument
fname Extended file name
Further information
This procedure writes the current directives to a file using the Optimizer file format.
Related topics
clearmipdir, setmipdir, readdirs.
ModulemmxprsFair Isaac Corporation Proprietary Information

810

Chapter 21: mmxprs

writeprob
Purpose
SynopsisWrite the current problem to a file.
procedure writeprob(fname:string, options:string)procedure writeprob(fname:string, options:string, fnamed:string)Arguments
fname
Extended file name for the matrix
options String of format options (default: full precision)
fnamedExtended file name for the directives
ExampleLoad the current problem into the Optimizer and save it to an MPS file "mypb.mps" in hexadecimalformat (’x’) and to the file "mypb.lp" in LP format (’l’) using scrambled names (’s’):loadprob(myobj)
setparam("xprs_objsense",1) ! for 'minimize'writeprob("mypb.mps","x")writeprob("mypb.lp","ls")Further information
This procedure writes the current problem held in the Optimizer to a file by calling the Optimizer function
XPRSwriteprob and XPRSwritedirs if a file name for the directives is also specified. Note that thematrix written by this procedure may be different from the one produced by exportprob since it may
include the effects of presolve or cuts generated by the Optimizer. For more detail on the options andbehavior of this procedure, refer to the Xpress Optimizer Reference Manual.
Related topics
exportprob, writedirs.
ModulemmxprsFair Isaac Corporation Proprietary Information

811

Chapter 21: mmxprs

writesol
Purpose
SynopsisWrite a solution to a file.
procedure writesol(fname:string,options:string)procedure writesol(ms:mpsol,sname:string,fname:string,options:string)Arguments
fname
optionsms
sname

Extended file name
String of options
A solution object
Solution name

Further information
1. When using the first syntax this procedure writes the current solution to a file by calling the Optimizer
function XPRSwriteslxsol. For more detail on the options and behavior of this procedure, refer to theXpress Optimizer Reference Manual.
2. With the second syntax, the file is generated from a solution object. In this case, the solution name has tobe provided (default name is "solution") and the only supported option is "x" to output the numbers
in hexadecimal.
3. Solution save/read procedures can be used only if the constraint and variable names have been loaded
into the Optimizer (parameter XPRS_loadnames set to true) and all constraints are named.
Related topics
readsol.
ModulemmxprsFair Isaac Corporation Proprietary Information

812

Chapter 21: mmxprs

xor
Purpose
SynopsisCreate an exclusive or expression.
function xor(c1:log_or_linctr,c2:log_or_linctr):logctr

Argumentsc1
c2

A linear constraint (linctr) or logical expression (logctr)
A linear constraint (linctr) or logical expression (logctr)

Return value
A new logctr representing the expression.
ExampleThis example shows how to state an exclusive ’or’ constraint that expresses the disjunction between twotasks with start time sj and fixed duration Dj . A non-exclusive ’or’ relation can be stated by using the oroperator as shown in the last line (constraint L).
declarations
R=1..2
C: array(range) of linctr
L: logctr
s: array(R) of mpvar
D: array(R) of real
end-declarations! Linear constraints! Logical constraint! Decision variables (start times)! Data (durations)C(1):= s(1)+D(1)>=s(2)C(2):= s(2)+D(2)>=s(1)! Define (temporary) linear constraints

xor(C(1), C(2))
forall(j in 1..2) C(j):=0! State an exclusive 'or'
! Delete the auxiliary constraints! The same 'xor' constraint can be stated by:xor(s(1)+D(1)>=s(2), s(2)+D(2)>=s(1))! A non-exclusive 'or' relation is stated by using the 'or' operator:
L:= s(1)+D(1)>=s(2) or s(2)+D(2)>=s(1)Further information
1. This function creates a logctr constraint representing an exclusive or condition: either c1 or c2 is valid,
not both.
2. The helper package ’advmod’ must be loaded if this function is used:
uses 'advmod'

Related topics
indicator, implies
ModulemmxprsFair Isaac Corporation Proprietary Information

813

Chapter 21: mmxprs

xprsmemoryuse
Purpose
Synopsis

Retrieve memory usage statistics.
function xprsmemoryuse(what:string):realArgument
what

The information to retrieve. Possible values are "available", "current", "peak","system" and "total"

Return value
An amount of memory expressed in bytes or -1 if the provided identifier is not valid.
Further information
The provided identifier corresponds to an Optimizer problem attribute (e.g. "peak" refers to the attribute
XPRS_PEAKMEMORY). This argument is not case sensitive and the parameter name may be directly used
(e.g. "XPRS_TOTALMEMORY" is the same as "total").
Related topics
memoryuse
ModulemmxprsFair Isaac Corporation Proprietary Information

814

Chapter 21: mmxprs

21.4 Cut Pool Manager
This section contains the functions and procedures of the Xpress Optimizer cut manager. For a detailed
description of the cut manager and its functionality the user is referred to the Xpress Optimizer Reference
Manual. To run the cut manager from Mosel, it may be necessary to (re)set certain control parameters of
the optimizer. For example, switching off presolve and automatic cut generation, and reserving space forextra rows in the matrix may be useful:setparam("XPRS_presolve", 0);! Switch presolve off...
setparam("XPRS_presolveops", 2270); ! ...or use secure setting for presolve
setparam("XPRS_cutstrategy", 0);! Switch automatic cut generation off
setparam("XPRS_extrarows", 5000);! Reserve space for 5000 extra rows in! the matrix

The callback functions and procedures that are relevant to the cut manager are initialized with function
setcallback, in common with the other Optimizer callbacks.
It should be noted that cuts are not stored by Mosel but sent immediately to the Optimizer. Consequently,
if a problem is reloaded into the Optimizer, any previously defined cuts will be lost. In Mosel, cuts aredefined by specifying a linear expression (i.e. an unbounded constraint) and the operator sign
(inequality/equality). If instead of a linear expression a constraint is given, it will also be added to thesystem as an additional constraint.
addcut

Add a cut to the problem in the optimizer.

p. 816

addcuts

Add an array of cuts to the problem in the optimizer.

p. 817

delcuts

Delete cuts from the problem in the optimizer.

p. 818dropcuts

Drop a set of cuts from the cut pool.

p. 819getcnlist

Get the set of cuts active at the current node.

p. 820getcplist

Get a set of cut indices from the cut pool.

p. 821loadcuts

Load a set of cuts into the problem in the optimizer.

p. 822storecutStore a cut into the cut pool.

p. 823storecuts

Store an array of cuts into the cut pool.

p. 824

Fair Isaac Corporation Proprietary Information

815

Chapter 21: mmxprs

addcutPurpose
Synopsis

Add a cut to the problem in the optimizer.
procedure addcut(cuttype:integer, type:integer, linexp:linctr)

Arguments
cuttype Integer number for identification of the cuttype
Cut type (equation/inequality), which may be one of:
CT_GEQ
Inequality (greater or equal)
CT_LEQ
Inequality (less or equal)
CT_EQ
Equality
linexpLinear expression (= unbounded constraint)
Further information
This procedure adds a cut to the problem in the Optimizer. The cut is applied to the current node and allits descendants.
Related topics
addcuts, delcuts.
ModulemmxprsFair Isaac Corporation Proprietary Information

816

Chapter 21: mmxprs

addcuts
Purpose
Synopsis

Add an array of cuts to the problem in the optimizer.
procedure addcuts(cuttype:array(range) of integer, type:array(range) ofinteger, linexp:array(range) of linctr)

Arguments
cuttype Array of integer number for identification of the cuts
type
Array of cut types (equation/inequality):
CT_GEQ
Inequality (greater or equal)
CT_LEQ
Inequality (less or equal)
CT_EQ
Equality
linexpArray of linear expressions (= unbounded constraints)
Further information
This procedure adds an array of cuts to the problem in the Optimizer. The cuts are applied to the current
node and all its descendants. Note that the three arrays that are passed as parameters to this proceduremust have the same index set.
Related topics
addcut, delcuts.
ModulemmxprsFair Isaac Corporation Proprietary Information

817

Chapter 21: mmxprs

delcuts
Purpose
Synopsis

Delete cuts from the problem in the optimizer.
procedure delcuts(keepbasis:boolean, cuttype:integer,interpret:integer,delta:real, cuts:set of integer)
procedure delcuts(keepbasis:boolean, cuttype:integer, interpret:integer,delta:real)

Arguments
keepbasis

false
Cuts with non-basic slacks may be deleted
true
Ensures that the basis will be valid
cuttype
Integer number for identification of the cut(s)interpret The way in which the cut type is interpreted:-1
Delete all cuts
1
Treat cut types as numbers
2
Treat cut types as bitmaps (delete cut if any bit matches any bit set in
cuttype)
Treat cut types as bitmaps (delete cut if all bits match those set in cuttype)3
delta
Only delete cuts with an absolute slack value greater than delta. To delete all the cuts set
this parameter to a very small value (e.g. -MAX_REAL)
cuts
Set of cut indices, if not specified all cuts of type cuttype are deleted

Further information
This procedure deletes cuts from the problem loaded in the Optimizer. If a cut is ruled out by any of thegiven criteria it will not be deleted.
Related topics
addcut, addcuts.
ModulemmxprsFair Isaac Corporation Proprietary Information

818

Chapter 21: mmxprs

dropcuts
Purpose
Synopsis

Drop a set of cuts from the cut pool.
procedure dropcuts(cuttype:integer, interpret:integer, cuts:set of integer)
procedure dropcuts(cuttype:integer, interpret:integer)

Arguments
cuttype
Integer number for identification of the cut(s)interpret The way in which the cut type is interpreted:-1
Drop all cuts
1
Treat cut types as numbers
2
Treat cut types as bitmaps (delete cut if any bit matches any bit set in
cuttype)
Treat cut types as bitmaps (delete cut if all bits match those set in cuttype)3
cuts
Set of cut indices in the cut pool, if not specified all cuts of type cuttype are deleted
Further information
This procedure drops a set of cuts from the cut pool. Only those cuts which are not applied to active
nodes in the branch-and-bound tree will be deleted.
Related topics
storecut, storecuts.
ModulemmxprsFair Isaac Corporation Proprietary Information

819

Chapter 21: mmxprs

getcnlist
Purpose
Synopsis

Get the set of cuts active at the current node.
procedure getcnlist(cuttype:integer,interpret:integer, cuts:set of integer)

Arguments
cuttype
Integer number for identification of the cut(s), -1 to return all active cuts
interpret The way in which the cut type is interpreted:-1
Get all cuts
1
Treat cut types as numbers
2
Treat cut types as bitmaps (get cut if any bit matches any bit set in
cuttype)3
Treat cut types as bitmaps (get cut if all bits match those set in cuttype)cuts
Set of cut indices
Further information
This procedure gets the set of active cut indices at the current node in the Optimizer. The set of cut
indices is returned in the parameter cuts.
Related topics
getcplist.
ModulemmxprsFair Isaac Corporation Proprietary Information

820

Chapter 21: mmxprs

getcplist
Purpose
Synopsis

Get a set of cut indices from the cut pool.
procedure getcplist(cuttype:integer,interpret:integer,delta:real, cuts:setof integer,viol:array(range) of real)

Arguments
cuttype
Integer number for identification of the cut(s)interpret The way in which the cut type is interpreted:-1
Get all cuts
1
Treat cut types as numbers
2
Treat cut types as bitmaps (get cut if any bit matches any bit set in
cuttype)3
Treat cut types as bitmaps (get cut if all bits match those set in cuttype)
delta
Only return cuts with an absolute slack value greater than delta
cuts
Set of cut indices in the cut poolviol
Array where the slack variables for the cuts will be returned
Further information
This procedure gets a set of cut indices from the cut pool. The set of indices is returned in the parameter
cuts.
Related topics
getcnlist.
ModulemmxprsFair Isaac Corporation Proprietary Information

821

Chapter 21: mmxprs

loadcuts
Purpose
Synopsis

Load a set of cuts from the cut pool into the problem in the optimizer.
procedure loadcuts(cuttype:integer, interpret:integer, cuts:set of integer)
procedure loadcuts(cuttype:integer, interpret:integer)

Arguments
cuttype
Integer number for identification of the cut(s)interpret The way in which the cut type is interpreted:-1
Load all cuts
1
Treat cut types as numbers
2
Treat cut types as bitmaps (load cut if any bit matches any bit set in
cuttype)3
Treat cut types as bitmaps (load cut if all bits match those set in cuttype)cuts
Set of cut indices in the cut pool, if not specified all cuts of type cuttype are loaded
Further information
This procedure loads a set of cuts into the Optimizer. The cuts remain active at all descendant nodes.
Related topics
storecut, storecuts.
ModulemmxprsFair Isaac Corporation Proprietary Information

822

Chapter 21: mmxprs

storecut
Purpose
SynopsisStore a cut into the cut pool.
function storecut(nodupl:integer, cuttype:integer, type:integer,
linexp:linctr):integer

Arguments
noduplFlag indicating how to deal with duplicate entries:
0
No check1
Check for duplicates among cuts of the same cut type2
Check for duplicates among all cuts
cuttype Integer number for identification of the cuttype
Cut type (equation/inequality):
CT_GEQ
Inequality (greater or equal)
CT_LEQ
Inequality (less or equal)
CT_EQ
Equality
linexpLinear expression (= unbounded constraint)

Return value
Index number of the cut stored in the cut pool.
Further information
This function stores a cut into the cut pool without applying it to the problem at the current node. The cut
has to be loaded into the problem with procedure loadcuts in order to become active at the current
node.
Related topics
dropcuts, loadcuts, storecuts.
ModulemmxprsFair Isaac Corporation Proprietary Information

823

Chapter 21: mmxprs

storecuts
Purpose
SynopsisStore an array of cuts into the cut pool.
procedure storecuts(nodupl:integer, cuttype:array(range) of integer,
type:array(range) of integer,
linexp:array(range) of linctr,
ndx_a:array(range) of integer)
procedure storecuts(nodupl:integer, cuttype:array(range) of integer,
type:array(range) of integer,
linexp:array(range) of linctr,
ndx_s:set of integer)

Arguments
noduplFlag indicating how to deal with duplicate entries:
0
No check1
Check for duplicates among cuts of the same cut type2
Check for duplicates among all cuts
cuttype Array of integer number for identification of the cuts
type
Array of cut types (equation/inequality):
CT_GEQ
Inequality (greater or equal)
CT_LEQ
Inequality (less or equal)
CT_EQ
Equality
linexpArray of linear expressions (= unbounded constraints)
ndx_aInterval of index numbers of stored cuts
ndx_s
Set of index numbers of stored cuts

Further information
This function stores an array of cuts into the cut pool without applying them to the problem at the current
node. The cuts have to be loaded into the problem with procedure loadcuts in order to become activeat the current node. The cut manager returns the indices of the stored cuts in the form of an array ndx_a
or a set of integers ndx_s. Note that the four arrays that are passed as parameters to this proceduremust have the same index set.
Related topics
dropcuts, loadcuts, storecut.
ModulemmxprsFair Isaac Corporation Proprietary Information

824

CHAPTER 22

python3
The python3 Mosel module ("python3.dso") makes it possible to easily exchange data between Mosel andR
Python⃝and to execute Python scripts from within Mosel.
Python is an interpreted programming language for general-purpose programming that has also become
popular for scientific and numeric computing. The reference implementation (CPython) is available asFree Software under the terms of the Python Software Foundation License, which is compatible with the
GNU General Public License. "Python" is a registered trademark of the Python Software Foundation.
To use this module, the following line must be included in the header of the Mosel model file:uses "python3"

22.1 Introduction
This module implements functionality for exchanging data between a Mosel model and Python 3(CPython) and for calling Python 3 scripts.
The python3 module defines an I/O driver for exchanging data using the initializations from andinitializations to Mosel constructs.
It is the Mosel run-time library that loads and runs the Python interpreter, not the other way round.
The purpose of the module is to make the extensive scientific and numeric capabilities of Python
available from Mosel. This module does not implement an interactive Python shell. However, theinteraction of the Mosel model and the Python interpreter is similar to an interactive shell: transferring
data to Python and executing Python scripts changes the state of the interpreter.

22.1.1 Prerequisites
This module does not include Python binaries. In order to use Python you need a working installation of
Python 3 targeting the same platform as Mosel (you won’t be able to use, e.g., the Windows 32-bit versionof Python from the Windows 64-bit version of Mosel). The supported Python versions are 3.7 to 3.9.
Version 3.8.0 is not and cannot be supported, because of Python issue #37633. For Windows users it isrecommended to get the binaries from www.python.org. Advanced users, who want to use multiple
Python environments on a single machine, can download and install the Anaconda Python distribution
from www.anaconda.com. On recent versions of Mac OS, Python 3 should be pre-installed. Advanced
users can also install the binaries from the Python or Anaconda website or via Homebrew. On Linux,
Python 3 is usually part of your distribution and provided in a package called "python3" that can beinstalled via the package manager. Note that Python 3 is not part of the Red Hat 6 standard repository. In
order to use the latest Python release on Red Hat 6, we recommend to download the latest Anaconda
Python distribution for Linux from the Anaconda website. It is not recommended to compile Python fromsource.

Fair Isaac Corporation Proprietary Information

825

Chapter 22: python3

The Mosel module python3 tries to automatically locate the correct Python libraries on your system,
applying the following rules. If the environment variable PYTHONHOME is specified, it will load the librariesof the Python installation in that directory. Otherwise, it searches for the Python executable in the
directories specified in the PATH environment variable. If the Python executable has been found, themodule will try to load the libraries of the Python installation of that Python executable. If the libraries
could not be loaded with the help of the environment variables, then on Windows they are loaded from thelatest Python installation specified in the registry (keys: HKEY_CURRENT_USER andHKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.⁎\InstallPath). If the previous
steps failed, then the python3 module will load the most recent libraries from the standard library searchpaths. On Windows it looks for python3⁎.dll and python3.dll, on Linux for
libpython3.⁎[m].so and libpython3.so, and on Mac OSX for libpython3.⁎[m].dylib andlibpython3.dylib.
If you have multiple installations of Python, or if Python could not be located automatically, or if theinitialization of Python fails, you will need to set the environment variable PYTHONHOME to point to yourPython installation directory or set PATH to include the location of the Python executable.
Note that the loading of Python is not influenced by Mosel statements like
setparam("workdir",...) or setenv("PYTHONHOME",...) in the Mosel model that uses the
Python module since these don’t affect the process environment used for Python loading. The
environment variables must be set before launching the Mosel instance that serves for executing Python
scripts in order to influence the loading of Python.
As an example, if Python 3.x is installed on Windows in "C:\Program Files\Python3x" then thisdirectory is also the correct value for the PYTHONHOME environment variable or alternatively, add thisdirectory to the PATH environment variable.
The module supports the conversion between Mosel types and pandas and NumPy types. The supported
pandas versions are 0.25 to 1.3 and the supported NumPy versions are 1.16 to 1.21. NumPy 1.19.4 is notsupported on Windows, because of a problem in the Windows runtime (#1207405).

22.1.2 Windows Anaconda Setup
Set the PYTHONHOME system environment variable to the base directory of Anaconda or to the home
directory of a specific Anaconda environment, e.g., C:\ProgramData\Anaconda3\envs\py373. The
NumPy module that ships with Anaconda requires the Math Kernel Library (MKL). It is necessary to add%PYTHONHOME%\Library\bin

to the PATH system environment variable such that NumPy can find the DLLs of that library. If NumPy
cannot find the library, the import of NumPy and pandas will fail with an error message similar to:
Traceback ...
from . import _mklinit
ImportError: DLL load failed: The specified module could not be found.

If you change the system environment variables, then it is necessary to restart Workbench such that thechanges take effect. If you run an Insight 5 Execution Worker, setting the system environment variables
PYTHONHOME or PATH has no effect on the Insight app, because Insight does not pass those variables tothe Insight app. Section Xpress Insight 5 configuration provides information about how to set thosevariables in Insight.

22.1.3 Linux Anaconda Setup
Set the PYTHONHOME environment variable to the base directory of Anaconda or to the home directory ofa specific Anaconda environment, e.g., /opt/anaconda3/envs/py373. The pandas module that ships

Fair Isaac Corporation Proprietary Information

826

Chapter 22: python3

with Anaconda may require a version of the C++ standard library which is more recent than the one thatships with your operating system. The required library ships with Anaconda and the loading of that library
can be forced by adding$PYTHONHOME/lib/libstdc++.soto the LD_PRELOAD environment variable. If an incompatible version gets loaded, then the initializationof pandas will fail with an error message similar to:ImportError: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not foundIf you run an Insight 5 Execution Worker, setting the system environment variables PYTHONHOME or
LD_PRELOAD has no effect on the Insight app, because Insight does not pass those variables to theInsight app. Section Xpress Insight 5 configuration provides information about how to set those variables
in Insight.

22.1.4 Python initialization
The Python environment is automatically initialized at the point where a Mosel model uses for the firsttime any function that requires it. So we can have the following small example that just executes a
Python script:
model "Python script example"
uses "python3"
pyrun("my-python-script.py")
end-model

Alternatively it is possible to explicitly initialize Python using the pyinit function. If the initialization fails,
activate additional logging by setting the parameter pyinitverbose to true before initializing Python
and double check the values of your environment variables (see previous sections).
At the end of the model execution, the Python environment will automatically be released. It is also
possible to explicitly release the environment using pyunload. This can be useful for freeing resources
allocated by Python.
It is only possible to initialize one Python interpreter per Mosel instance. For that reason it is not possible
to initialize and use the Python interpreter in two models in parallel if both models are run in the same
Mosel instance. However, you can initialize and use multiple interpreters in concurrent models if eachmodel is run in a separate Mosel instance.

22.1.5 Data types
The types of data that can be exchanged with Python are the Mosel types boolean, integer, real,
string and text, plus arrays, lists and sets of these. Nested compositions are supported. Mosel lists
and sets are exported to Python lists and sets. Both, dense and sparse Mosel arrays are supported andby default they are mapped to dictionaries of the corresponding element type. If the pandas interface isinitialized, then arrays and lists of arrays can also be mapped to pandas Series and DataFrames.
Moreover, Mosel arrays can be initialized from NumPy ndarrays and Mosel scalars be initialized from
NumPy scalars (see pyinitpandas and pyusepandas for more details).
The following example shows how to invert a matrix with NumPy:
declarations
I, J: range
A, A_inverse: array(I, J) of real
end-declarations

Fair Isaac Corporation Proprietary Information

827

Chapter 22: python3
writeln("Run Python script that defines invert_matrix function.")pyinitpandas
pyrun("invert_matrix.py")
I := 0..2
J := 0..2
A :: [1,0,3,
0,1,2,
0,0,1]
writeln("Invert matrix with NumPy.")
pycall("invert_matrix", A_inverse, A)
writeln("Matrix A_inverse:")writeln("A_inverse: ", A_inverse)

At the beginning of this code snippet the pandas interface is initialized via a call to pyinitpandas. This
enables the conversion of Mosel arrays from and to pandas Series and from NumPy arrays from thispoint onwards—this statement will typically occur at the beginning of the program, but standard python3functionality can already be used before to it. After the pandas initialization a Python example script in a
separate file invert_matrix.py is executed, which defines the invert_matrix Python function.
This function is then invoked via the pycall procedure. The first parameter of this procedure is the
Python function name, the second one is the Mosel array that will be used for storing the result, and thelast parameter is the input parameter for the Python function. The Python function takes a pandas Series
with a two-dimensional MultiIndex as input and returns a two-dimensional NumPy ndarray:def invert_matrix(series):# Get pivot table of MultiIndex Series as DataFrame.
df = series.unstack()# Compute and return inverse matrix as NumPy ndarray.
return inv(df)

See the model invert-matrix.mos for a full example. At first, the function creates a pivot table of theMultiIndex Series, such that the resulting DataFrame looks like a two-dimensional matrix. This matrix-like
DataFrame is used as an input value for the NumPy inv function, which returns a two-dimensionalndarray, which is then passed to Mosel.
Note that sparse Mosel arrays are exported to sparse Python dictionaries or pandas Series. In thisexample, the Mosel matrix A is dense, hence the pandas Series is also dense, that is, for each index tuple(i, j) in the cross product of I and J the pandas Series has a value.
When initializing a Mosel array, list, or set from a Python type, the initialization of the Mosel type isadditive, which means that the elements of the Python type are added to the existing Mosel array, list, orset. In the example above, the pandas Series is dense such that all elements of the Mosel array will beoverwritten. However, if the pandas Series (or dictionary) is sparse and the Mosel array is non-zero, it isnecessary to manually clear its contents before initializing it with values from the sparse Python type. Inthat situation, the Mosel array should be cleared with reset. See Section 22.6.1 for an example with asparse array and reset: io_example.mos.

22.2 Xpress Insight 4 configuration
The python3 module can only be used when Mosel restrictions are disabled (MOSEL_RESTR=0). Whenthe restrictions are disabled, any executed Mosel and Python code have the same rights (in particular forfile system access) as the operating system user that runs the Insight Execution Worker. In order to use
the python3 module in an Insight app, it is necessary to relax the Mosel restrictions in the Insight
Execution Worker configuration file. On Windows, the default location of the worker configuration file is%XPRESSDIR%\bin\xprmsrv.cfg. After relaxing the Mosel restrictions, we strongly recommend that
the Insight administrator makes sure of the following points:

Fair Isaac Corporation Proprietary Information

828

Chapter 22: python3■ The operating system user that runs the Insight Execution Worker should only be granted theminimal rights that are necessary for running the Insight app.

■ Access to the workers should be protected by a password and additionally by IP filters (see theexample extract of the configuration file xprmsrv.cfg below).

■■

If the network is not trusted, the workers should only accept SSH connections: Set TCP_PORT=-1(configurable via xprmsrv.cfg) and use xssh instead of the xsrv protocol (Execution Worker
configuration in the Insight admin interface).
Only trusted users should be granted the right to upload trusted Insight apps to the Insight Server.

And the Insight app developer needs to address the following points:■ The app should not execute any untrusted Python scripts that an end user may have uploaded as anapp attachment (see pyrun function).

■ The app should not concatenate untrusted strings entered by the end user (e.g. Insight scalars orarrays) into a Python evaluation string, because this could allow an attacker to inject and executecustom Python code. For example, the first function input parameter of pycall, pyexec andpyget is a Python evaluation string. Note that it is safe to transfer untrusted data between Mosel
and Python variables. The developer just needs to avoid using untrusted strings directly in a Python
evaluation string parameter.

If the Insight Execution Worker runs on the same machine as the Insight Server, it is recommended tomodify the configuration settings in xprmsrv.cfg as follows:...
# INFO: It is recommended to replace +ALL by -ALL in XPRMSRV_ACCESS when MOSEL_RESTR=0.
XPRMSRV_ACCESS=+127.0.0.1 -ALL
[insight]# INFO: It is recommended to protect the worker with a password when MOSEL_RESTR=0.
PASS=my_password# IMPORTANT: Replace the existing MOSEL_RESTR line to disable the Mosel restrictions.
MOSEL_RESTR=0
PYTHONHOME=C:\ProgramData\Anaconda3
PATH=${PYTHONHOME}\Library\bin;${PATH}...

Restart the Execution Worker after changing the configuration file. Then log into the Insight admininterface, go to Execution Services, edit the Execution Worker, enter the password in the password edit
field and save the changes.
Depending on your system configuration, the PYTHONHOME environment variable is optional. The PATH
entry is only necessary for Anaconda on Windows. You can also specify the PYTHONHOME and PATH
environment variables as system environment variables. Note that it is not sufficient to specify them foryour personal user account, because the Insight service runs as a different user.

22.3 Xpress Insight 5 configuration
The python3 module can only be used when Mosel restrictions are disabled (MOSEL_RESTR=0). Whenthe restrictions are disabled, any executed Mosel and Python code have the same rights (in particular forfile system access) as the operating system user that runs the Insight Execution Worker. In order to use
the python3 module in an Insight Mosel app, it is necessary to relax the Mosel restrictions in the Insight
Execution Worker application.properties file. On Windows, the default location of the worker
properties file is
C:\ProgramData\FICO\XpressInsight\Worker\config\application.properties. To
disable the restrictions, add the following line:

Fair Isaac Corporation Proprietary Information

829

Chapter 22: python3
insight.worker.execution.environment.MOSEL_RESTR=0

After relaxing the Mosel restrictions, we strongly recommend that the Insight administrator makes sure of
the following points:■ The operating system user that runs the Insight Execution Worker should only be granted theminimal rights that are necessary for running the Insight app.

■

Only trusted users should be granted the right to upload trusted Insight apps to the Insight Server.

And the Insight app developer needs to address the following points:■ The app should not execute any untrusted Python scripts that an end user may have uploaded as anapp attachment (see pyrun function).

■ The app should not concatenate untrusted strings entered by the end user (e.g. Insight scalars orarrays) into a Python evaluation string, because this could allow an attacker to inject and executecustom Python code. For example, the first function input parameter of pycall, pyexec andpyget is a Python evaluation string. Note that it is safe to transfer untrusted data between Mosel
and Python variables. The developer just needs to avoid using untrusted strings directly in a Python
evaluation string parameter.

The Insight worker controls the environment variables under which the model runs. In particular, it clears
all environment variables except for a list of allowed variables related to Xpress. For this reason, it may benecessary to set certain environment variables in the worker application.properties file, such thatthe python3.dso Mosel module can find and use Python. For example:...
# MANDATORY: Replace the existing MOSEL_RESTR line to disable the Mosel restrictions.
insight.worker.execution.environment.MOSEL_RESTR=0# IMPORTANT: Use one of the following example blocks to configure a Python environment:# Windows: No configuration needed for using the latest Python.org#
installation that is registered in the Windows registry.
# Configuration for a specific installation from Python.org.
insight.worker.execution.environment.PATH=C:\\Program Files\\Python39# Alternative configuration for a specific installation from Python.org.
insight.worker.execution.environment.PYTHONHOME=C:\\Program Files\\Python39# Configuration for the base environment of Anaconda on Windows.
insight.worker.execution.environment.PYTHONHOME=C:\\ProgramData\\Anaconda3
insight.worker.execution.environment.PATH=\${insight.worker.execution.environment.PYTHONHOME}\\Library\\bin...

Restart the Execution Worker after changing the properties file.
Depending on your system configuration, the PYTHONHOME environment variable is optional. Adding${PYTHONHOME}\Library\bin to the PATH is only necessary for Anaconda on Windows. Note that it
is not sufficient to add these as either system or user environment variables as the worker only uses theenvironment variables configured in its application.properties file and the allowed Xpress related
variables.

22.4 Control parameters
The following parameters are defined by the module python3:

Fair Isaac Corporation Proprietary Information

830

Chapter 22: python3

pyinitverbose

Show additional log messages when initializing Python.

p. 831

pyusepandas

Enable and control pandas and NumPy conversion.

p. 831pyinitverbose
Description

Set this parameter to true to activate some additional logging of how the module looks for andfinds your Python environment. The log messages are written to the model’s output stream.

Type

Boolean, read/write

Default value

false

See also

pyinit, pyinitpandas

Modulepython3pyusepandas
Description

If this parameter is true, then the next usage of any Python functionality will trigger the
initialization of the pandas interface. When the interface is initialized, Mosel scalars can also be
initialized from NumPy scalars, arrays can also be initialized from NumPy ndarrays and pandas
Series, and lists of arrays can be initialized from pandas DataFrames. Once initialized, thepandas interface will remain initialized even after switching pyusepandas off. In particular, it
will still be possible to initialize Mosel types from pandas and NumPy types.
When converting data from Mosel to Python, the target type depends on the value of
pyusepandas: When the parameter is true, Mosel arrays and lists of arrays are converted topandas Series and DataFrames; when it is false, then Mosel arrays will be converted to
Python dictionaries. Mosel lists of arrays cannot be initialized to a Python type when thisparameter is disabled.

Type

Boolean, read/write

Default value

false

See also

pyinitpandas, Driver python

Modulepython322.5 Procedures and functions
The procedures and functions of the python3 module fail in case of Python compile-time or run-timeerrors.
pycallCall a Python object, e.g. a function, with optional input arguments andconvert the result to a Mosel variable.
p. 833pyexecExecute Python statements from a string.

p. 835pyget

Get the result of a Python expression as Mosel variable.

p. 836

pygetdf

Initialize a list of Mosel arrays from the columns of a pandas DataFrame.
p. 837pyinitInitialize the Python interpreter.

Fair Isaac Corporation Proprietary Informationp. 839831

Chapter 22: python3

pyinitpandas

Set pyusepandas parameter to true and initialize the pandas interface.
p. 840pyrun

Run a Python script and wait until it is finished.

p. 841pyset

Assign a Mosel value to a global Python variable.

p. 842

pysetdf

Convert a list of Mosel arrays to a pandas DataFrame.

p. 843pyunload

Release the Python interpreter and its resources.

p. 844

Fair Isaac Corporation Proprietary Information

832

Chapter 22: python3

pycallPurpose

SynopsisCall a Python object, e.g. a function, with optional input arguments and convert the result to a Mosel
variable.
procedure pycall(expr:string,result:array|set|list[, arg1...])
procedure pycallvoid(expr:string[, arg1...])
function pycallbool(expr:string[, arg1...]):booleanfunction pycallint(expr:string[, arg1...]):integerfunction pycallreal(expr:string[, arg1...]):realfunction pycallstr(expr:string[, arg1...]):string
function pycalltext(expr:string[, arg1...]):text

Arguments
expr
resultarg1, arg2,...

Global name of a callable Python object or Python expression that evaluates to a
callable object
Result Mosel array, set or list
Optional input arguments for the object call

Example 1
The following example calls the Python print and max functions. The Mosel input arguments areautomatically converted to Python objects and the return value of max is converted to a Mosel real.
pycallvoid("print", "Python objects:", true, 1, 2.2, [3,4], {5})writeln("max: ", pycallreal("max", [1.1, 7.7, 4.4]))
Example 2
The following example uses pandas to compute the mean value of two Mosel arrays. The Mosel input
arrays are passed as a single list of arrays with compatible array indices and are automatically converted
to a single pandas DataFrame. The return value of the mean function is a pandas Series and its elements
will be written to the Mosel Result array.
declarations
Input1, Input2, Result: array(range) of real
end-declarations
Input1 :: (0..4)[1, 2, 3, 4, 5]
Input2 :: (0..4)[7, -1, -3, 1, 2]
pyinitpandas
pyexec("def mean(df, axis): return df.mean(axis)")pycall("mean", Result, [Input1, Input2], 1)
writeln("mean: ", Result)
It is recommended to define small global wrapper functions like in this example, instead of calling
functions or methods with the help of an expression like "pandas.Series.mean". The global function
can be found directly without having to perform an expensive Python string evaluation to retrieve thecallable object.

Fair Isaac Corporation Proprietary Information

833

Chapter 22: python3

Further information
1. At first, the function interprets the expression string as a global Python object name and tries to access it
by getting it from the attributes of the Python __main__ module. If this fails, the expression is evaluatedby Python. Then the expression result object will be called with the optional input arguments. Finally, theresult of the object call is stored in or returned as a Mosel variable. This is equivalent to the Python
expression:
expr(arg1, ...)
It is a fatal error if the expression cannot be evaluated or if the object call or the type conversion between
Python and Mosel fails.
2. The first version of the pycall routine stores the result in an array, set or list. Its behavior is additive: itwrites the new elements to the existing Mosel array, set or list without clearing previously existingelements. Use reset to manually clear an array, set or list before calling this function.
3. See the I/O Driver python Section for further details about type conversions.
4. Do not concatenate untrusted strings from the end user into the expr string. See Section Xpress Insight
5 configuration for more information.
Related topics
pyexec, pyget, Driver python
Modulepython3Fair Isaac Corporation Proprietary Information

834

Chapter 22: python3

pyexecPurpose
Synopsis

Execute Python statements from a string.
procedure pyexec(code:string)Argumentcode
ExamplePython statements to execute

The following model runs Python statements from a string:model "Python script from string"uses "python3"
writeln("Python version:")pyexec("import platform; print(platform.python_version())")
end-model

Further information
1. This function compiles and runs a Python script from a string buffer and waits for its termination. It is a
fatal error if the compilation fails or if a Python run-time error occurs.
2. Use the I/O Driver python and the functions pyget and pyset to transfer data between Mosel andPython. Use pyget to evaluate a single expression with return value and use pycall to call a single
function with input arguments or return value.
3. Do not concatenate untrusted strings from the end user into the code string. See Section Xpress Insight
5 configuration for more information.
Related topics
pycall, pyget, pyrun, Driver python
Modulepython3Fair Isaac Corporation Proprietary Information

835

Chapter 22: python3

pyget
Purpose
Synopsis

Get the result of a Python expression as Mosel variable.
procedure pyget(expr:string,var:array|set|list)
function pygetbool(expr:string):booleanfunction pygetint(expr:string):integerfunction pygetreal(expr:string):realfunction pygetstr(expr:string):string
function pygettext(expr:string):text

Arguments
expr
var
ExamplePython expression to evaluate
Destination Mosel array, set or list

The following example evaluates a Python dictionary expression and writes the result to a Mosel array. Itthen retrieves a real value from Python:declarations
Arr: dynamic array(set of integer) of real
end-declarations
pyexec("import math")
Arr(0) := 0.1; Arr(1) := 1.1! Old array data
reset(Arr)! Clear old array data
pyget("{1: math.pi, 2: math.e}", Arr) ! Add new data to arraywriteln("Arr: ", Arr)writeln("pi: ", pygetreal("math.pi"))

Further information
1. At first, the function interprets the expression as a global variable name and tries to access the variable
by getting it from the attributes of the Python __main__ module. If this fails, the expression is evaluatedby Python and the result is written to or returned as a Mosel variable. It is a fatal error if the expression
evaluation or the type conversion fails.
2. The first version of the pyget routine is additive: it writes the new elements to the existing Mosel array,set or list without clearing previously existing elements. Use reset to manually clear an array, set or list
before calling this function.
3. See the I/O Driver python Section for further details about type conversions. Use pycall to call a single
function with input arguments or return value.
4. Do not concatenate untrusted strings from the end user into the expr string. See Section Xpress Insight
5 configuration for more information.
Related topics
pycall, pygetdf, pyset, Driver python
Modulepython3Fair Isaac Corporation Proprietary Information

836

Chapter 22: python3

pygetdf
Purpose
Synopsis

Initialize a list of Mosel arrays from the columns of a pandas DataFrame.
procedure pygetdf(expr:string,result:list of array)procedure pygetdf(expr:string,result:list of array,labels:list of string)Arguments
expr
resultlabelsExamplePython expression that evaluates to a pandas DataFrame
Mosel list of arrays to be initialized from pandas DataFrame
Labels of the pandas DataFrame columns used for initialization

In this example, two Mosel arrays with the same index sets are initialized from a DataFrame. With the firstcall to pygetdf, the arrays are initialized based on the order of the DataFrame columns, with the second
they are initialized using column labels.
declarations
I, J: set of integer
Numbers: dynamic array(I, J) of integer
Labels: dynamic array(I, J) of string
end-declarations
pyinitpandas
pyexec(`import pandas as pd
df = pd.DataFrame(
data=[[11, "eleven"], [23, "twenty-three"], [42, "forty-two"]],index=pd.MultiIndex.from_tuples([(1, 1), (2, 3), (4, 2)]),columns=["number", "label"])print(df)`)
pygetdf("df", [Numbers, Labels])
writeln("I: ", I, "\nJ: ", J)
writeln("Numbers: ", Numbers, "\nLabels:", Labels)

reset(Numbers); reset(Labels)
pygetdf("df", [Labels, Numbers], ["label", "number"])
writeln("Numbers: ", Numbers, "\nLabels: ", Labels)

Fair Isaac Corporation Proprietary Information

837

Chapter 22: python3

Further information
1. The first version of the procedure initializes the arrays based on the order of the DataFrame columns. The
second version uses column labels to select the DataFrame columns that are used for the initialization.
2. At first, the procedure interprets the expression as a global variable name and tries to access the variable
by getting it from the attributes of the Python __main__ module. If this fails, the expression is evaluatedby Python and the result is used for the Mosel array initialization. It is a fatal error if the expression
evaluation or the type conversion fails.
3. The initialization of the result arrays is additive: new elements are written to the existing arrays without
clearing previously existing elements. Use reset to manually clear the arrays before calling thisprocedure.
4. DataFrame conversion is supported in all module functions that accept lists of arrays. In particular, it is
supported by pycall and the I/O Driver python .
5. Do not concatenate untrusted strings from the end user into the expr string. See Section Xpress Insight
5 configuration for more information.
Related topics
pyget, pysetdf, pyinitpandas
Modulepython3Fair Isaac Corporation Proprietary Information

838

Chapter 22: python3

pyinitPurpose
Synopsis
ExampleInitialize the Python interpreter.
procedure pyinit
The following example initializes Python:pyinitFurther information
1. The use of this procedure is optional: Python is automatically initialized upon first use.
2. You can only initialize one Python interpreter per Mosel instance. The initialization will fail if you attempt
to initialize two interpreters in the same Mosel instance. Use pyunload to release the interpreter and its
resources. The interpreter cannot be reinitialized in the same Mosel instance after unloading it.
3. In order to use multiple interpreters in parallel, it is necessary to create a new Mosel instance for each
additional interpreter. Use the connect function from the mmjobs module to create a new instance.
4. If the initialization of Python fails, activate additional logging by setting the parameter pyinitverbose
to true before initializing Python, double check the values of your environment variables (see theIntroduction section) and check the Troubleshooting section.
Related topics
connect, pyinitverbose, pyinitpandas, pyunload
Modulepython3Fair Isaac Corporation Proprietary Information

839

Chapter 22: python3

pyinitpandas
Purpose
Synopsis
ExampleSet pyusepandas parameter to true and initialize the pandas interface.
procedure pyinitpandas
The following example first prints a Mosel array as Python dictionary and then initializes the pandas
interface and prints the array as pandas Series:
declarations
A: array(range) of real
end-declarations
A :: (-1..2)[-1.1, 0, 1.1, 2.2]
pycallvoid("print", "A as Python dict:\n", A)
pyinitpandas
pycallvoid("print", "A as pandas Series:\n", A)

Further information
1. This procedure is equivalent to the following two commands:
setparam("pyusepandas", true)
pyinitSee the documentation of pyusepandas and pyinit for further information. The I/O Driver python
section provides an overview of the additionally available type mappings after having initialized the
pandas interface.
2. At first, the procedure sets the parameter pyusepandas to true, then it initializes the Python interpreter if
it has not yet been initialized and finally it initializes the pandas interface if it has not yet been initialized.
Once initialized, the pandas functionality will continue to be available even after switching pyusepandas
off. See pyusepandas for more information.
Related topics
pyinit, pyinitverbose, pyunload, pyusepandas, Driver python
Modulepython3Fair Isaac Corporation Proprietary Information

840

Chapter 22: python3

pyrun
Purpose
Synopsis

Run a Python script and wait until it is finished.
procedure pyrun(filename:string)Argument
filename Regular file name of a Python script
ExampleThe following model runs a Python script:
model "Python script example"
uses "python3"
pyrun("my-python-script.py")
end-model

Further information
1. The function compiles and runs a Python script and waits for its termination. It is a fatal error if thecompilation fails or if a Python run-time error occurs.
2. Use the I/O Driver python and the functions pyget and pyset to transfer data between Mosel andPython.
3. Do not run untrusted scripts, e.g., scripts provided by the end user. See Section Xpress Insight 5
configuration for more information.
Related topics
pycall, pyexec, Driver python
Modulepython3Fair Isaac Corporation Proprietary Information

841

Chapter 22: python3

pyset
Purpose
Synopsis

Assign a Mosel value to a global Python variable.
procedure
pyset(varname:string,var:boolean|integer|real|string|text|array|list|set)

Arguments
varname Global Python variable namevar
Mosel value to be assigned to Python variable
ExampleThe following example writes a Mosel array to a Python dictionary and a Mosel list to a Python list:
declarations
MosArray: array(set of string) of real
end-declarations
pyset('py_list', [1, 2, 3])! Mosel list -> Python list.
pyexec('print("py_list:", py_list)')MosArray('e') := M_E; MosArray('pi') := M_PI
setparam('pyusepandas', false) ! Mosel array -> Python dictionary.
pyset('py_dict', MosArray)pyexec('print("py_dict:", py_dict)')
setparam('pyusepandas', true) ! Mosel array -> Pandas Series.
pyset('pd_series', MosArray)pyexec('print("pd_series:", pd_series, sep="\n")')Further information
1. The procedure creates or overwrites the global variable by writing the new value to the attributes of the
Python __main__ module. If the variable name is not a valid Python variable identifier the procedure will
succeed anyway and write the value to the module attributes using the name specified in varname.
2. The procedure replaces previously existing global variables. It does not update or add data to existing
Python structures.
3. See the I/O Driver python Section for more details about type conversions.
Related topics
pyget, pyexec, pysetdf, pyusepandas, Driver python
Modulepython3Fair Isaac Corporation Proprietary Information

842

Chapter 22: python3

pysetdf
Purpose
Synopsis

Convert a list of Mosel arrays to a pandas DataFrame.
procedure pysetdf(varname:string,input:list of array)procedure pysetdf(varname:string,input:list of array,labels:list of string)Arguments
varname Global Python variable name for the new DataFrame
input
Mosel list of arrays to be converted to the DataFramelabelsLabels for the DataFrame columns
ExampleIn this example, two Mosel arrays with the same index sets are converted to a DataFrame. With the firstcall to pysetdf, a DataFrame is created with integer column labels and the second creates a DataFrame
with string column labels.
declarations
I, J: set of integer
Numbers: dynamic array(I, J) of integer
Labels: dynamic array(I, J) of string
end-declarations
pyinitpandas
Numbers(1,1) := 11;
Numbers(2,3) := 23;
Numbers(4,2) := 42;

Labels(1,1) := "eleven"Labels(2,3) := "twenty-three"Labels(4,2) := "forty-two"writeln("Integer column labels:")
pysetdf("df", [Numbers, Labels])
pyexec("print(df)")
pysetdf("df", [Numbers, Labels], ["number", "label"])writeln("\nString column labels:")
pyexec("print(df)")
Further information
1. The first version of the procedure creates a new DataFrame with numbers as column labels and thesecond version uses the provided string column labels.
2. The procedure creates or overwrites the global variable by writing the new value to the attributes of the
Python __main__ module. If the variable name is not a valid Python variable identifier the procedure will
succeed anyway and write the value to the module attributes using the name specified in varname.
3. The procedure replaces previously existing global variables. It does not update or add data to existing
Python structures.
4. DataFrame conversion is supported in all module functions that accept lists of arrays. In particular, it is
supported by pycall and the I/O Driver python .
Related topics
pygetdf, pyset, pyinitpandas
Modulepython3Fair Isaac Corporation Proprietary Information

843

Chapter 22: python3

pyunloadPurpose
Synopsis
ExampleRelease the Python interpreter and its resources.
procedure pyunload
The following example releases the Python interpreter:
pyunload

Further information
1. The use of this procedure is optional: the Python interpreter is automatically released at the end of amodel execution. However, you may prefer to release it sooner to free resources allocated by Python.
2. After unloading the interpreter it cannot be reinitialized in the same Mosel instance. This is due to a bug
in Python’s finalization function and its extension modules. For example, NumPy and pandas do not work
after reinitializing the interpreter in the same process, i.e., in the same Mosel instance. See
https://docs.python.org/3/c-api/init.html#c.Py_FinalizeEx andhttps://github.com/numpy/numpy/issues/8097 for more details.
Related topics
pyinitModulepython3Fair Isaac Corporation Proprietary Information

844

Chapter 22: python3

22.6 I/O drivers
The python3 module provides a driver that is designed to be used in initializations blocks for both
reading data from and writing data to Python.

22.6.1 Driver python
python:optional_module_name

The driver can only be used in ‘initializations’ blocks. The optional string after the colon is the Python
module name to read the data from or write the data to. If a module name is provided, then the optional
item labels are understood as attribute names of the specified module. Initializing data to, for example,"python:client_data" will create a new module called client_data. To access that module in
Python, you need to import it like a normal Python module ("import client_data"). After importing
the module, the converted Mosel variables will be the attributes of the module, for example,
client_data.demand.
If no module name is provided, i.e. if the file name is "python:", then the driver behaves like pyset andpyget: When writing data to Python, the optional labels are understood as global variable names. The
driver creates or overwrites the global variables by writing the new values to the attributes of the Python__main__ module. If a variable name is not a valid Python variable identifier the driver will succeed
anyway and write the value to the module attributes using the name specified in the label. When reading
data from Python, the optional labels are understood as Python expressions. At first, the driver checks
whether an expression is a global variable and tries to access it by getting it from the attributes of the
Python __main__ module. If this fails, the expression is evaluated by Python and the result is written to
the Mosel variable.
The driver throws an I/O error if the expression evaluation or the type conversion fails. Use theparameters ioctrl (see setparam) and iostatus (see getparam) to catch I/O errors.
When initializing data from Mosel to Python, a possibly existing Python object with the same name will be
replaced by a new Python object with a Python object type that matches the type of the Mosel source
variable.
When initializing arrays, sets, or lists from Python to Mosel, the initialization behavior is additive: The
elements of the Python structures are added to the Mosel structures and existing elements in the Mosel
structures will not be deleted automatically. If, for example, the target Mosel array is dense and thesource Python dictionary or Series is sparse, then the Mosel array may contain old and new values after
initialization from Python. If the Mosel array is meant to contain only the values retrieved from the Python
dictionary, it is recommended to clear the array with reset before initializing it from Python.

22.6.1.1 Type mapping to Python■

Mosel boolean →– Python bool
– NumPy bool_ if element of pandas Series■

Mosel integer →– Python int– NumPy int64 if element of pandas Series■

Mosel real →– Python float

Fair Isaac Corporation Proprietary Information

845

Chapter 22: python3– NumPy float64 if element of pandas Series■■■■

Mosel string/text → Python str
Mosel set → Python set
Mosel list → Python list
Mosel array(I) →– If pyusepandas: pandas Series with one-dimensional index– If not pyusepandas: Python dictionary with scalar keys■

Mosel array(I, J, ...) →– If pyusepandas: pandas Series with multi-dimensional index– If not pyusepandas: Python dictionary with tuples of scalars as keys■

Mosel list of array →– If pyusepandas: pandas DataFrame with one- or multi-dimensional index– If not pyusepandas: not supported■

Mosel nested types → Python nested type■

Mosel records: not supported■

Other Mosel external types: not supported

22.6.1.2 Type mapping from Python
The NumPy and pandas types are only supported if the pandas interface is initialized.
■
■
■
■
■
■
■

Mosel boolean ← Python bool; NumPy bool_

Mosel int ← Python int, bool; NumPy integer, bool_

Mosel real ← Python float, int, bool; Numpy floating, integer, bool_

Mosel string/text ← String representation of Python object as returned by repr()

Mosel list ← Python list

Mosel set ← iterable types (e.g., set, generator expression, classes that implement __iter__())

Mosel array ←– pandas Series with one- or multi-dimensional index– NumPy ndarray with one or multiple dimensions– Python dictionary with scalar or tuple keys■

Mosel list of array ←– pandas DataFrame with one- or multi-dimensional index■

Mosel nested types ← Python nested type of supported subtypes■

Mosel records: not supported■

Other Mosel external types: not supported

Fair Isaac Corporation Proprietary Information

846

Chapter 22: python3

In the following example, a sparse array is transferred to Python and then the same array is reused for
retrieving data from a sparse Python dictionary.
model "Python I/O example"
uses "python3"
declarations
I = 1..4
A: dynamic array(I) of integer
end-declarations
A(1) := 1⁎2; A(3) := 3⁎2
initializations to "python:"
I as "MyRange"A
end-initializations
pyrun("io-example.py")
reset(A) ! Delete existing elements from array A.
initializations from "python:"A
end-initializations
writeln("Values initialized from Python:")writeln(" A= ", A)
end-model

The content of io-example.py:
print("Values initialized to Python:")print(" MyRange =", MyRange)
print(" A =", A)print("Modifying data in Python...")
A = {i: 2 ⁎ i for i in MyRange if i % 2 == 0}

Executing this model generates the following output:
Values initialized to Python:
MyRange = range(1, 5)
A = {1: 2, 3: 6}
Modifying data in Python...
Values initialized from Python:A= [(2,4),(4,8)]

22.7 TroubleshootingThis section describes some known issues and possible solutions.
■

Mosel: E-353: Module ‘python3’ disabled by restrictions.
This module does not handle Mosel restrictions, it will therefore fail to load if Mosel is run in
restricted mode. Section 22.3 provides information about configuring the security restrictions.

■

If the initialization of a Python extension module fails when it is imported from within Mosel, thenfirst check which Python environment is used from within Mosel (set pyinitverbose to true) andcheck whether the extension module is installed in that environment. If it is installed and can beimported from within the interactive shell of that environment, but fails when it is imported fromwithin Mosel, then check whether your environment is set up correctly: Windows Anaconda Setup,Linux Anaconda Setup.

Fair Isaac Corporation Proprietary Information

847

CHAPTER 23

R
The module r makes it possible to easily exchange data with R and execute R scripts or evaluate
expressions in the R language.
R is a free software environment for statistical computing and graphics. R is available as Free Software
under the terms of the Free Software Foundation’s GNU General Public License.
To use this module, the following line must be included in the header of the Mosel model file:uses 'r';

23.1 Introduction
This module implements functionality for exchanging data between a Mosel model and R and for calling
R functions from a Mosel model.
The r module also defines an I/O driver for exchanging data using the initializations from andinitializations to Mosel constructs.
It is the Mosel run-time library that loads and runs R, not vice versa.
The purpose of the module is to make the extensive data processing capabilities of R available within
Mosel. The interactive and graphing features of R are beyond the scope of this module as it does not
implement a full interactive R GUI. However, it is possible to use some of these to a limited extent.

23.1.1 Prerequisites
This module does not include R binaries. In order to use R you need a working installation of R, version
3.0 or newer and targeting the same platform as Mosel (you won’t be able to use, e.g., the Windows 32-bit
version of R from the Windows 64-bit version of Mosel). The most recent supported R version is 4.1.x. To
download R, please visit the R Project web site at www.r-project.org.
This module will try to load R from the directory specified by the R_HOME environment variable, if set, orfrom the default R installation locations otherwise.
More specifically Mosel looks for a file named R.dll in Windows, libR.so in Linux, and libR.dylib
in Mac OS X.
For Windows platforms, the default location is retrieved from the registry (from registry key
HKEY_LOCAL_MACHINE\Software\R-core\R\InstallationPath); it is/Library/Frameworks/R.framework/Resources for Mac OS X, /usr/lib/R for 32bit Linux, andeither /usr/lib64/R or /usr/lib/R for 64bit Linux.
If R_HOME and R_ARCH environment variables are defined, they are used to construct a path like
R_HOME/lib in Linux and like R_HOME\bin\R_ARCH in Windows (the default for R_ARCH is x64 or
i386 respectively for Windows 64-bit and Windows 32-bit).

Fair Isaac Corporation Proprietary Information

848

Chapter 23: R

If you have multiple installations of R, or if R is installed in a different location or not automatically found,
you will need to set the environment variable R_HOME to point to your R installation directory.
Note that the loading of R is not influenced by eventual Mosel statements like
setparam(’workdir’,...) or setenv(’R_HOME’,...) as these don’t affect the process’s
environment used for R loading. The environment variables or current path must eventually be set before
launching Mosel in order for this to influence R loading.
As an example, if R 3.2.3 is installed in "C:\Program Files\R\R-3.2.3\bin\..." in Windows
64-bit, then the correct value for the R_HOME environment variable (or registry key) is C:\Program
Files\R\R-3.2.3 (thus, without the bin subdirectory) and Mosel would try and load R.dll from
C:\Program Files\R\R-3.2.3\bin\x64\R.dll.

23.1.2 R initialization
The R environment is automatically initialized at the point where a Mosel model uses for the first time any
function that requires it. So we can have the following small example that just prints the R version (itprints the same output as if you typed R.version.string on an R console):model "r version example"
uses 'r';Rprint('R.version.string')
end-model

Alternatively it is possible to explicitly initialize R using the Rinit function. This can be useful in order toretrieve a status code or to specify non-default initialization options.
By default, R is initialized with the options "–slave –vanilla", so no site or user environment, profile, history
and workspace files are processed. Please refer to the R documentation for more details on these andother options (http://cran.r-project.org/doc/manuals/r-release/R-intro.html#Invoking-R).
Upon startup, only the "utils", "stats", and "methods" R packages are loaded by default. Other packages
can be loaded via R statements (using for example the library or require R functions) or a different
initial package list can be specified by setting the R_DEFAULT_PACKAGES environment variable (prior torunning Mosel).
As R is single-threaded, it is not possible to create more than one R session per model, nor to execute twomodels in parallel if both use R.

23.1.3 Memory limit on Windows
On Windows platforms, R has an internal mechanism that can limit the maximum amount of memory it
can use. The limit can be read or changed using the R memory.limit function; for example, the current
limit can be printed from Mosel withwriteln('R memory limit is ',Rgetreal("memory.limit()"),' MB')and the limit can be set, e.g. to 16 GB, with
Reval("memory.limit(16⁎1024)")Note that in versions of R prior to 3.6 the default value for this limit is different when R is executed as astandalone application rather than embedded in another application (including Mosel): in the first casethe limit is set to the amount of physical memory available whereas it is fixed to 2 GB for embedded
mode. Therefore, in order to allow R to use more than 2 GB of memory from Mosel on Windows it isnecessary to explicitly raise this limit as shown above. Starting with R version 3.6, by default there is no
memory limit anymore when R is executed in embedded mode.

Fair Isaac Corporation Proprietary Information

849

Chapter 23: R

23.1.4 Data types
The types of data that can be exchanged with R are the four Mosel elementary types boolean, integer,
real and string, plus arrays, lists and sets of these (nested compositions are not supported). Bothstatic and dynamic Mosel arrays are supported and mapped into R atomic vectors of the corresponding
type. Mosel lists and sets can also be exported into R vectors.
In general, there is no direct mapping of more complex R types such as factors or data.frames, with the
exception of the Rsetdf function, however these can be exchanged after conversion to basic types. For
example, a factor can be loaded into a Mosel array as an array of integers with:
Rgetarr("unclass(f)", intarray)or as an array of strings with:
Rgetarr("levels(f)[f]", strarray)

Note that the first is also equivalent to this simpler form:
Rgetarr("f", intarray)since this module ignores the factor’s "class" and "levels" attributes; similarly the second is equivalent tothe simpler:
Rgetarr("f", strarray)since the casting to string, performed within R, automatically takes into account the "levels" attribute.
To load a data.frame into Mosel, it should be converted to a matrix (for instance using as.matrix if thecolumn types allow that) or split into individual column vectors.
For the opposite operation, that is, exporting a Mosel array to R, note that, except for the Rsetdf function,
Mosel arrays are always exported as R (dense) atomic vectors. Any index that is not a 1-based integer
range is created in R as a named index. Index names, in R, are always strings, so for example, when the
Mosel array in the following example is converted to R, the index set J is kept as an unnamed integerindex, while I (which does not start with 1) and K (which has holes) are created as named indices.
model "array to r"
uses "r"declarations
I= 2..3
J= {1,2}
K= {1,3}a: array(I,J,K) of integer
end-declarationsa(2,1,1):=4Rset('aR',a)writeln("Array in R:")
Rprint("aR")
writeln("dimnames(aR):")
Rprint("dimnames(aR)")
end-model! Define some test data entry! Copy data to R
! Display data held in R
! Display R indices

Executing this model generates the following output:
Array in R:, , 1

Fair Isaac Corporation Proprietary Information

850

Chapter 23: R

2
3[,1] [,2]
4
0
0
0

, , 3
2
3

[,1] [,2]0000dimnames(aR):[[1]][1] "2" "3"
[[2]]
NULL
[[3]]
[1] "1" "3"Note how the first and last entry of dimnames, which correspond to indices I and K respectively, are set
to the list of index elements converted to strings; while the second entry is left to NULL since the index
set J is a 1-based integer index with contiguous elements.
Conversion to R data frames can be done using function Rsetdf. If this does not provide the required
data frame format or other complex R data structures are needed, then the conversion should be done in
the R realm and is outside of the scope of this guide. A few examples are shown below, but please referto the R documentation for further information.
Some common and useful R functions to convert vectors into data frames are e.g. data.frame(),as.data.frame(), and the functions from the reshape or reshape2 packages, just to name a few. Also
functions names() (for 1-dimensional vectors) or dimnames() (for any vectors) can be used to retrieve
the index names of a vector.
In the following example, a Mosel single-indexed demand array is converted to a 2-column R data frame:
the first column for the index and the second column for the value:model "dataframe"
uses "r"declarations
Locations = {12,34,56}
demand: dynamic array(Locations) of real
end-declarations
forall(l in Locations) demand(l):=l⁎100! Fill array with some data
Rset("demand", demand)
Rprint("table <- data.frame(Loc=names(demand),Dem=demand,row.names=NULL)")
end-modelThis is the resulting output:
1
2
3

Loc Dem
12 1200
34 3400
56 5600

Note that this is the same result that you would get, more simply, with Rsetdf("table", demand,["Loc","Dem"]).
Alternatively, calling data.frame just as data.frame(demand) without any other parameters would
create a data frame with a single column (for demand) and named rows, thus yielding:demandFair Isaac Corporation Proprietary Information

851

Chapter 23: R
12
34
56

1200
3400
5600

A bidimensional demand array such as:
declarations
Locations = {12,34,56}
C={"A","B"}demand: dynamic array(Locations,C) of real
end-declarations
demand(12,"A"):=1234
demand(56,"B"):=6789
Rset("demand", demand)using Rsetdf("df", demand, ["Loc","C", "Value"]) would yield:
1
2

Loc C Value
12 A 1234
56 B 6789

or it could be converted to a data frame via data.frame(Loc=dimnames(demand)[[1]],demand,row.names=NULL) which results in the following form:
1
2
3

Loc
A
B
12 1234
NA
34
NA
NA
56
NA 6789

Finally, for instance by calling function melt form the reshape2 package such as melt(demand,
varnames = c(’Loc’,’Prod’), value.name = ’Demand’), it is possible to obtain a data
frame with a column for each index plus a column with the array values like the following:
1
2
3
4
5
6

Loc Prod Demand
12
A
1234
34
A
NA
56
A
NA
12
B
NA
34
B
NA
56
B
6789

23.2 Example
The following example shows how to execute R statements and exchange data with the R workspace.
model "r example"
uses "r"declarations
CITIES = {"LONDON", "PARIS", "ROME"}ZONES = 1..4
mosarray, backarr, backarrio: array(ZONES, CITIES) of integer
backnum: real
end-declarations
setparam("Rverbose",true)! Enable showing R error messages! Reval evaluates arbitrary R statements
Reval("t<-Sys.time();now<-format(t, '%H:%M')")! Rprint also prints the result (via the R print function)
Rprint("paste('Hello from R at',now)")

Fair Isaac Corporation Proprietary Information

852

Chapter 23: R! Assign some Mosel scalars to R vars and show results
Rset("a_num", 1.2)
Reval("str(a_num)")Rset("a_chr", "word")
Reval("str(a_chr)")! The lvalue can be any R valid lvalue, e.g. the dim attributeRset("a_vec", 1..6)! a_vec is an R vector
Rset("dim(a_vec)", [2,3]) ! change its dimensions
writeln("a_vec")
Rprint("a_vec")! now it is a 2x3 matrix! Assign a Mosel array to an R variable
forall(i in ZONES, c in CITIES) mosarray(i,c):=i⁎10+getsize(c)Rset("arr", mosarray)! The R vector keeps index names
writeln("arr")
Rprint("arr")! Retrieve R variables
writeln("a_num is ", Rgetreal("a_num"))
writeln("a_chr is ", Rgetstr("a_chr"))
Rgetarr("arr", backarr)
writeln("arr is ", backarr)! Data can also be exchanged via the I/O driver
newnumber:=1.3
mosarray(1,"LONDON"):=1! Send data to R
initializations to "r.rws:"
newnumber as "a_num"
mosarray as "arr"end-initializations! Get data back from R
initializations from "r.rws:"
backnum as "a_num"
backarrio as "arr"end-initializations
writeln("backnum is ", backnum)
writeln("backarrio is ", backarrio)
end-model

23.3 Control parameters
The following parameters are defined by the module r:
Rcleanscript

R cleanup script to be run at the end of a session.

p. 854

Rinteractive

Control the R interactive flag.

p. 854

Rsessionmode

R session handling mode.

p. 855

Runloadscript

R unload script to be run at the end of a session.

p. 854

Rusemosstreams

Enable/disable R output redirection.

p. 854

Rverbose

Enable/disable R error messages.

p. 853

Rverbose
Description

Enables or disables the printing of error messages when errors occur during the evaluation of R
statements. When this parameter is set, two corresponding R options are set accordingly,

Fair Isaac Corporation Proprietary Information

853

Chapter 23: R

namely show.error.messages, which is set to the same value as this parameter, and warn
which is set to 1 or -1 when this parameter is set to true or false respectively.
Type

Boolean, read/write

Default value

false

Moduler

Rinteractive
Description

This has effects on eventual user prompts and confirmation requests from R, please refer to R
documentation (e.g. on "interactive()") for more details.

Type

Boolean, read/write

Default value

false

Moduler

Rusemosstreams
Description

By default R sends output to stdout and stderr. Using this parameter it is possible to redirect R
console output to Mosel streams instead. Note that the R notion of stdin connection is notaffected by this parameter.

Type

Boolean, read/write

Default value

true

Moduler

Rcleanscript
Description

This parameter can be used to specify the R statement(s) to be executed at the end of an R
session; its purpose should be to clear the R workspace. Note that this script is run only forsession modes 2 and 3.

Type

String, write only

Default value

remove all objects currently defined in the R workspace

Affects routines

Rfree.

Moduler

Runloadscript
Description

This parameter can be used to specify the R statement(s) to be executed at the end of an R
session; its purpose should be to free and unload all resources used by R. Note that this script
is run only for session mode 3 and after the Rcleanscript statement(s).

TypeString, write only

Default value

unload all packages and dynamic libraries

Affects routines

Rfree.

Moduler

Fair Isaac Corporation Proprietary Information

854

Chapter 23: R

Rsessionmode
Description

Specifies what actions are taken at the end of an R session.

Type

Integer, read/write

Values0
1
2
3

Default value

2

Notes

This parameter is useful mainly when multiple Mosel models that use R are executed within thesame process.
When an R session is ended, R does not allow the creation of further sessions, therefore R will
not be usable again within the same process.
Session mode 3, by unloading R, should enable the possibility to create new R sessions within
the same process, however it may not completely free all resources allocated by R.

Affects routines

Rfree.

Moduler

END: the R session is ended.
KEEP: the R session is kept alive and the current R workspace is preserved.
CLEAR: the R session is kept alive and the Rcleanscript is executed.
UNLOAD: both the Rcleanscript and Runloadscript are executed, then R is unloaded.

23.4 Procedures and functions
All R statements are evaluated in the R Global Environment, more often known as the user’s workspace.
In general, the procedures and functions of r do not fail in case of R parsing or evaluation errors but set
an internal status variable that can be read with Rerrcode. To make sure that an operation has been
performed correctly, it is recommended to check the value of this variable after each call.
Rclearerr

Clear the last error code and message.

p. 870

Rerrcode

Get the last error code.

p. 868Rerrmsg

Get the last error message.

p. 869

Reval

Evaluate R statements.

p. 856

Rfree

Terminate an R session.

p. 857

Rgetarr

Get the resulting array of an R expression.

p. 858RgetboolGet the boolean value of an R expression.

p. 859Rgetint

Get the integer value of an R expression.

p. 860Rgetreal

Get the real value of an R expression.

p. 861

Rgetstr

Get the string value of an R expression.

p. 862

Rinit

Initialize an R session.

p. 863RprintEvaluate R statements and print the result.

p. 864

Rset

Assign a Mosel value to an R object.

p. 865

RsetdfAssign a Mosel array to an R data.frame object.

p. 866

Rsource

Evaluate an R script file.

p. 867

Fair Isaac Corporation Proprietary Information

855

Chapter 23: R

Reval
Purpose
Synopsis

Evaluate R statements.
procedure Reval(cmd:string)Argument
cmd
ExampleStatements to evaluate

The following example loads the datasets package, calculates summary statistics of the attenu
dataset and prints results:
Reval('library(datasets); s<-summary(attenu)')
Rprint('s')

Further information
It is possible to evaluate multiple statements separating them with semicolons.
Related topics
Rprint.

Fair Isaac Corporation Proprietary Information

856

Chapter 23: R

Rfree
Purpose
Synopsis
ExampleTerminate an R session.
procedure Rfree
The following example terminates the R session:
Rfree

Further information
The use of this procedure is optional: R is automatically terminated at the end of a model execution.
However you may prefer to terminate it sooner to free resources allocated by R.
Related topics
Rinit.

Fair Isaac Corporation Proprietary Information

857

Chapter 23: R

Rgetarr
Purpose
Synopsis

Get the resulting array of an R expression.
procedure Rgetarr(cmd:string, arr:array)

Arguments
cmd
arr
ExampleStatements to evaluate
Destination Mosel array

The following example loads the R cars example dataset into the Mosel array cars:
declarations
cars:array(range, set of string) of integer
end-declarations
Rgetarr('as.matrix(datasets::cars)',cars)

Further information
1. If cmd contains more than one statement, the returned value is the result of the last one.
2. The Mosel array arr must have the same number of dimensions as the R array; NA entries in R areskipped and corresponding entries in arr are left unchanged (note that arr is not cleared before loading
R data).
3. Supported index types for the arr array are string and integer. In the case of strings, the R array musthave a valid names or dimnames attribute for the corresponding dimension; in the case of integers, the R
integer indices (1 to n) are used. All entries of the R array are converted to the same type as thedestination array within R.
Related topics
Rgetarr, Rgetint, Rgetreal, Rgetstr

Fair Isaac Corporation Proprietary Information

858

Chapter 23: R

Rgetbool
Purpose
Synopsis

Get the boolean value of an R expression.
function Rgetbool(cmd:string):boolean

Argument
cmd

Statements to evaluate

Return value
The result of the evaluation as a boolean.
ExampleThe following example checks if the R entity vec is atomic and sets the boolean variable boolvar
accordingly:
boolvar:=Rgetbool('is.atomic(vec)')

Further information
If cmd contains more than one statement, the returned value is the result of the last one. If the results is
NA, then false is returned. The returned value is first converted to logical within R.
Related topics
Rgetarr, Rgetint, Rgetreal, Rgetstr

Fair Isaac Corporation Proprietary Information

859

Chapter 23: R

Rgetint
Purpose
Synopsis

Get the integer value of an R expression.
function Rgetint(cmd:string):integer

Argument
cmd

Statements to evaluate

Return value
The result of the evaluation as an integer.
ExampleThe following example retrieves the length of the R entity vec into variable intvar:
intvar:=Rgetint('length(vec)')

Further information
If cmd contains more than one statement, the returned value is the result of the last one. If the results is
NA, then the R NA_Integer value (-231 ) is returned. The returned value is first converted to integer
within R.
Related topics
Rgetarr, Rgetbool, Rgetint, Rgetstr

Fair Isaac Corporation Proprietary Information

860

Chapter 23: R

Rgetreal
Purpose
Synopsis

Get the real value of an R expression.
function Rgetreal(cmd:string):realArgument
cmd

Statements to evaluate

Return value
The result of the evaluation as a real.
ExampleThe following example retrieves the mean of the speed/dist ratios for the cars dataset into the variablerealvar:realvar:=Rgetreal('mean(cars$speed/cars$dist)')Further information
If cmd contains more than one statement, the returned value is the result of the last one. If the results is
NA, then a NaN value is returned. The returned value is first converted to numeric within R.
Related topics
Rgetarr, Rgetbool, Rgetint, Rgetstr

Fair Isaac Corporation Proprietary Information

861

Chapter 23: R

Rgetstr
Purpose
Synopsis

Get the string value of an R expression.
function Rgetstr(cmd:string):stringArgument
cmd

Statements to evaluate

Return value
The result of the evaluation as a string.
ExampleThe following example retrieves the version string of R into the variable strvar:
strvar:=Rgetstr('R.version.string')

Further information
If cmd contains more than one statement, the returned value is the result of the last one. If the results is
NA, then the string "NA" is returned. The returned value is first converted to string within R.
Related topics
Rgetarr, Rgetbool, Rgetreal, Rgetstr

Fair Isaac Corporation Proprietary Information

862

Chapter 23: R

Rinit
Purpose
Synopsis

Initialize an R session.
function Rinit([args:string...]): integer

Argumentargs

List of R startup options (optional)

Return value
0 if the initialization was successful.
ExampleThe following example initializes R with default options:
initok:=Rinit
if initok<>0 then writeln('Failed to initialize R')
end-ifFurther information
The use of this function is optional: R is automatically initialized upon first use. Default R startup options
are "–slave", "–vanilla", so no site or user environment, profile, history and workspace files are processed.
Please refer to the R documentation for the exact meaning of these and other options(http://cran.r-project.org/doc/manuals/r-release/R-intro.html#Invoking-R).
Related topics
Rfree.

Fair Isaac Corporation Proprietary Information

863

Chapter 23: R

RprintPurpose
Synopsis

Evaluate R statements and print the result.
procedure Rprint(cmd:string)Argument
cmd
ExampleStatements to evaluate and print

The following example prints the R version number and summary statistics of the cars dataset:
Rprint("R.version.string")
Rprint('library(datasets); summary(cars)')

Further information
It is possible to evaluate multiple statements separating them with semicolons. The return value of thelast statement is printed using R’s own print function, thus with R style and formatting.
Related topics
Reval.

Fair Isaac Corporation Proprietary Information

864

Chapter 23: R

Rset
Purpose
Synopsis

Assign a Mosel value to an R object.
procedure Rset(dst:string, value:[set|array|list of]boolean|integer|real|string)Arguments
dst
An R variable namevalue The Mosel value to be assigned to dst
ExampleThe following example assigns values 1.2, "hello" and an array with numbers 1 to 6 to the R objects a_num,
a_string and a_vec respectively:
Rset('a_num', 1.2)
Rset('a_string', 'hello')
Rset("a_vec", 1..6)
Rset("dim(a_vec)", [2,3])! An R vector with real values 1 to 6
! Change its dimensions into a 2x3 matrix

Further information
1. A new temporary R entity is created from value and then assigned to dst, unless value is a scalar anddst is an existing R entity of the corresponding type, in which case dst is just set to the new value
2. Argument dst can represent any assignable expression (including subsetting and attributes).
3. The type of argument value can be any elementary Mosel type, or an array, list or set of these(compositions are not supported).
4. When value is an array, for each of the array’s dimensions, its index values are exported into thecorresponding R array’s names or dimnames attribute (after conversion to string) unless the indices areinteger values from 1 to that dimension size.
5. If value is a dynamic array, only the existing values are copied to R and the remaining array entries are
set to NA (Not Available).
Related topics
Reval, Rsetdf.

Fair Isaac Corporation Proprietary Information

865

Chapter 23: R

RsetdfPurpose
Synopsis
Synopsis

Assign a Mosel array to an R data.frame object.
procedure Rsetdf(dst:string, arr:array of boolean|integer|real|string)procedure Rsetdf(dst:string, arr:array of boolean|integer|real|string,
cname:list of string)Arguments
dst
An R variable namearr
The Mosel array to be assigned to dst
cname List of names to be assigned to the data.frame columns
ExampleThe following:
declarations
CITIES = {"LONDON", "NEW YORK", "ROME"}ZONES = 1..4
myarray: dynamic array(ZONES, CITIES) of integer
end-declarations
myarray(1,'LONDON') := 8
myarray(1,'ROME') := 3
myarray(2,'NEW YORK') := 9Rsetdf("a_df", myarray, ['Zone','City','Value'])
Rprint("a_df")
produces this output:
1
2
3

Zone
City Value1
LONDON
81ROME
3
2 NEW YORK
9

Further information
1. A new R data.frame is created from arr and assigned to dst
2. The argument dst can represent any assignable expression (including subsetting and attributes).
3. The R data.frame is constructed with n+1 columns (where n is the number of dimensions of arr): one
column for each of the array’s indices, plus one column for the array’s values; and one row for eachexisting value of the array.
4. Rows are numbered from 1 to the number of existing values of arr and column names are taken from thecname argument, when given.
5. Only the first n+1 strings from cname are used; if cname is shorter, then the right-most columns are left
unnamed.
Related topics
Reval, Rset.

Fair Isaac Corporation Proprietary Information

866

Chapter 23: R

Rsource
Purpose
Synopsis

Evaluate an R script file.
procedure Rsource(filename:string)Argument
filename Filename of the R script to evaluate
ExampleThe following example executes the myscript.R file:
Rsource('myscript.R')

Related topics
Reval.

Fair Isaac Corporation Proprietary Information

867

Chapter 23: R

Rerrcode
Purpose
Synopsis

Get the last error code.
function Rerrcode:integer

Return value
0 if the last operations were executed successfully.
ExampleThe following example prints an error message in case of errors in R evaluations:
Reval('missingfunction()')
if Rerrcode<>0 thenwriteln('Something went wrong: ', Rerrmsg)
Rclearerr
end-ifFurther information
The Rerrcode is set to non-zero values in case of errors, but not cleared after successful operations, so
it is possible to check it after several operations to verify that all executed without errors. To clear it, usefunction Rclearerr.
Related topics
Rclearerr, Rerrmsg.

Fair Isaac Corporation Proprietary Information

868

Chapter 23: R

Rerrmsg
Purpose
Synopsis

Get the last error message.
function Rerrmsg:string

Return value
The last error message in case of errors, or the empty string otherwise.
ExampleThe following example prints an error message in case of errors in R evaluations:
Reval('missingfunction()')
if Rerrcode<>0 thenwriteln('Something went wrong: ', Rerrmsg)
Rclearerr
end-ifFurther information
The message returned by this function is a top-level description of the error. It is possible to also retrieve
R own error message for example with Rgetstr("geterrmessage()").
Related topics
Rclearerr, Rerrcode.

Fair Isaac Corporation Proprietary Information

869

Chapter 23: R

Rclearerr
Purpose
Synopsis
ExampleClear the last error code and message.
procedure Rclearerr
The following example prints an error message in case of errors in R evaluations and subsequently clears
the error information:
Reval('missingfunction()')
if Rerrcode<>0 thenwriteln('Something went wrong: ', Rerrmsg)
Rclearerr
end-ifRelated topics
Rerrcode, Rerrmsg.

Fair Isaac Corporation Proprietary Information

870

Chapter 23: R

23.5 I/O drivers
In order to simplify access to R this module provides a driver that is designed to be used ininitializations blocks for both reading and writing data, providing the same functionalities as the
Rget and Rset functions.

23.5.1 Driver rws
rws:

The driver can only be used in ‘initializations’ blocks. It does not take any argument and provides accessto the R workspace.
In the block, each label entry is understood as one or more R statements. For ’from’ blocks, if the label
contains more than one statement, the value from the last one is returned. For ’to’ blocks, the label must
contain only one expression.
This driver requires an existing R session, therefore it is necessary to initialize R (either by calling function
Rinit or any of the other module functions that create an R session) before using it.
Example:initok:=Rinit
initializations to "r.rws:"
scalarvar as "val"arrayvar as "arr"end-initializations
initializations from "r.rws:"
backscalar as "val"backarr as "arr"end-initializations! Initialize R! Send data to R

! Get data from R

23.6 TroubleshootingThis section describes some known issues and possible solutions.
■ When running a model in Windows, a dialog is shown with title ’Unable to locate component’ andcontent ’The application has failed to start because Rlapack.dll was not found...’.
This may occur with Windows 2003. Please add your R binary directory (usually ’C:\Program
Files\R\R-3.x.x\bin\i386’ or ’C:\Program Files\R\R-3.x.x\bin\x64’ to the system PATH environment
variable.

■ When an R session is initialized in Windows, R installs a console handler to detect Ctrl-C events

which may prevent Mosel from properly detecting these same events itself.

■

In Linux, R may fail to load if the dynamic libraries in $R_HOME/lib cannot be found by the dynamic
linker. In this case, please add $R_HOME/lib to the LD_LIBRARY_PATH environment variable.

■ This module is not compatible with Mosel security restrictions, therefore it would fail to load if

Mosel is run in restricted mode.

■

On Mac OS X, if the R release being used is linking the Apple CoreFoundation library, then thismodule can only be successfully initialized from the main thread of the process in which Mosel isrunning (because the CoreFoundation library can only be loaded from the main thread of a process).
So, for example, the module would fail to load R from an mmjobs submodel. In this case, it ispossible to overcome this issue by setting the environment variable DYLD_INSERT_LIBRARIES to/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation

Fair Isaac Corporation Proprietary Information

871

Chapter 23: R(use the correct path to the CoreFoundation library on your system) before launching the Mosel
process, thus forcing an anticipated loading of the CoreFoundation library at process creation.

Fair Isaac Corporation Proprietary Information

872

CHAPTER 24

zlib
The zlib Mosel module is an interface to the zlib compression library by Jean-Loup Gailly and Mark Adler(http://zlib.net). Thanks to two IO drivers it makes possible the creation and use of compressed files from
Mosel models. As an additional feature this module also integrates the MiniZip library by Gilles Vollant(http://www.winimage.com/zLibDll/minizip.html) for supporting the ZIP archive format.

24.1 I/O drivers
The following two drivers behave the same: a stream open for reading is decompressed and a stream
open for writing is created compressed. Both drivers are also based on the same compression algorithm(deflate) but use different container formats. The last published driver (zip) can only be open for reading:it will be used to access a file stored in a zip archive. For more advanced use of ZIP archives please referto the dedicated routines proposed by the mmsystem module.

24.1.1 Driver gzip
gzip:filename

This driver handles files compressed using the gzip compression format: this corresponds to files
created using the gzip compression tool.
For instance the following statement decompresses the file "myfile.gz":
fcopy("zlib.gzip:myfile.gz","myfile")

24.1.2 Driver deflate
deflate:filename

This driver handles files compressed using the zlib compression format. This driver can read documents
compressed by gzip but compressed files it generates are not compatible with this tool.

24.1.3 Driver zip
zip:zipfile,filename

This driver handles archives using the ZIP format. It can be used only for reading files: the filename ofthis driver consists in two parts separated by a coma. The first part is the name of the archive to open(that must be a physical file) and the second one is the archive member name.
For instance the following statement compiles the file "main.mos" stored in the archive"myproject.zip":

Fair Isaac Corporation Proprietary Information

873

Chapter 24: zlib
compile("G","zlib.zip:myproject.zip,main.mos","tmp:main.bim")

Fair Isaac Corporation Proprietary Information

874

Appendix

APPENDIX A

Syntax diagrams for the Mosel language
A.1 Main structures and statements- ‘model’ ⟨Label⟩ · · ·⟨Model⟩ ::=
···  ⟨Directives⟩   ⟨Parameters⟩  ⟨Body⟩- ‘package’ Identifier · · ·⟨Package⟩ ::=···  ⟨Directives⟩   ⟨Parameters⟩   ⟨Body⟩⟨Label⟩ ::=-  String
 Identifier ‘end-model’ - ‘end-package’ -



 ‘,’

 ⟨Directives⟩ ::=-  ‘uses’  String 
 ‘,’



‘imports’  String 


‘,’


‘options’  Identifier 


‘,’


‘namespace’  Identifier 


‘,’


‘nssearch’  Identifier ‘nsgroup’ Identifier  ‘,’ ‘:’  String   ‘version’ Integer  ‘.’ Integer  ‘.’ Integer ⟨Parameters⟩ ::=- · · ·· · ·  Identifier ‘=’ ⟨Expression⟩   · · · String ‘:’  ‘integer’   ‘real’ ‘string’  ‘boolean’ · · · ‘end-parameters’ · · · ‘parameters’···

Fair Isaac Corporation Proprietary Information

876

Appendix A: Syntax diagrams for the Mosel language⟨Body⟩ ::=-  ⟨Declarations⟩⟨Requirements⟩
⟨Subroutine_decl⟩
⟨Subroutine_def⟩ ‘include’  String
 Identifier⟨Statement⟩


 






⟨Declarations⟩ ::=- · · · ‘declarations’ · · ····  ‘public’ 
· · ·  
Identifier ‘=’  ⟨Expression⟩  ‘public’  ⟨Type_descr⟩ ‘,’  Identifier  ‘:’  ⟨Type_descr⟩
 ‘shared’ ⟨Procedure_head⟩⟨Function_head⟩· · · ‘end-declarations’ ⟨Requirements⟩ ::=- · · ·  · · ·








‘,’
· · ·   Identifier  ‘:’ ⟨Type_descr⟩   · · ·⟨Procedure_head⟩⟨Function_head⟩· · · ‘end-requirements’ · · · ‘requirements’···⟨Type_descr⟩ ::=- · · ·
··· 








‘or’
 ⟨Type_name⟩  ‘range’  ‘dynamic’  ‘set’ ‘of’ ‘integer’  ‘set’ ‘of’  ⟨Type_descr⟩
 ‘dynamic’  ‘constant’  ‘dynamic’ ‘hashmap’‘list’ ‘of’ ⟨Type_descr⟩


‘and’
 Identifier ‘,’ ‘array’ ‘(’  ⟨Set_def⟩  ‘)’ ‘of’ ⟨Type_descr⟩






 ‘record’  ⟨Field_descr⟩  ‘end-record’‘procedure’  ⟨Form_params⟩  ‘:’ ⟨Type_name⟩‘function’  ⟨Form_params⟩  ‘public’⟨Field_descr⟩ ::=-  ‘public’

Fair Isaac Corporation Proprietary Information

 Identifier ‘:’ ⟨Type_descr⟩ 










877

Appendix A: Syntax diagrams for the Mosel language⟨Type_name⟩ ::=-  ‘integer’‘real’
 ‘string’ ‘boolean’ ‘mpvar’ ‘linctr’ Identifier








 ‘set’ ‘of’  ⟨Type_name⟩ ⟨Set_def⟩ ::=-  Identifier ‘:’  ‘constant’   ‘range’   Identifier ‘:’  ‘set’ ‘of’ ‘integer’ ⟨Type_name⟩⟨Set_expr⟩⟨Subroutine_decl⟩ ::=- ‘forward’ ⟨Procedure_head⟩  ⟨Function_head⟩ ⟨Subroutine_def⟩ ::=- ⟨Procedure_head⟩  ⟨Declarations⟩   ‘end-procedure’  ⟨Statement⟩  ⟨Function_head⟩  ⟨Declarations⟩   ‘end-function’  ⟨Statement⟩ ⟨Procedure_head⟩ ::=-  ‘public’ ‘procedure’ Identifier  ⟨Form_params⟩⟨Function_head⟩ ::=- · · · ‘function’ Identifier ···  ‘public’  ⟨Form_params⟩‘,’⟨Form_params⟩ ::=- ‘(’  ⟨Form_param⟩⟨Form_param⟩ ::=- · · ·· · · ‘,’  Identifier Identifier ‘:’

Fair Isaac Corporation Proprietary Information Identifier ‘:’ ‘:’ ⟨Type_name⟩  ‘...’ ‘)’ ⟨Type_name⟩‘range’ ‘set’ ‘of’ ‘integer’  ‘set’ ‘of’  ⟨Type_name⟩  ‘constant’ ‘,’ ‘array’ ‘(’  ⟨Set_def⟩  ‘)’ ‘of’ ⟨Type_name⟩ 



 ‘:’

878

Appendix A: Syntax diagrams for the Mosel language⟨Statement⟩ ::=- · · ···· ⟨Name_ref⟩  ‘:=’ ‘+=’
 ‘-=’

 ⟨Expression⟩




‘,’
Identifier ‘(’  ⟨Expression⟩  ‘)’ 



-


⟨Ctr_expr⟩
 ‘if’ ⟨Bool_expr⟩ ‘then’ ⟨Stat_list⟩ ⟨Elif_body⟩  ‘end-if’ ⟨Else_body⟩  ‘end-case’‘case’ ⟨Expression⟩ ‘of’ ⟨Case_list⟩  ⟨Else_body⟩  ‘forall’ ‘(’ ⟨Iterator_list⟩ ‘)’  ⟨Statement⟩  ⟨Label⟩  ⟨Do_block⟩  ‘while’ ‘(’ ⟨Bool_expr⟩ ‘)’  ⟨Statement⟩  ⟨Label⟩  ⟨Do_block⟩  ‘repeat’ ⟨Stat_list⟩ ‘until’ ⟨Bool_expr⟩ ⟨Label⟩ ‘next’  Integer  ⟨Label⟩‘break’  Integer  ⟨Label⟩‘,’ ⟨Name_ref⟩ ‘::’  ‘[’  ⟨Expression⟩  ‘]’‘,’ ‘(’  ⟨Expression⟩  ‘)’  ⟨With_block⟩ ⟨Label⟩ ⟨Init_block⟩‘return’⟨Elif_body⟩ ::=-  ‘elif’ ⟨Bool_expr⟩ ‘then’ ⟨Stat_list⟩
⟨Else_body⟩ ::=- ‘else’ ⟨Stat_list⟩ -




















⟨Case_body⟩ ::=-  ⟨Expression⟩ ‘:’  ⟨Statement⟩   ⟨Do_block⟩ ⟨With_block⟩ ::=- ‘with’ ⟨With_decl⟩ ::=-  ⟨With_body⟩ ⟨Name_ref⟩


‘and’
  Identifier  ‘,’  ⟨With_decl⟩  

Identifier ‘=’ ⟨Expression⟩‘,’ Identifier ‘(’  Identifier  ‘)’ ‘=’ ⟨Name_ref⟩

Fair Isaac Corporation Proprietary Information



879

Appendix A: Syntax diagrams for the Mosel language⟨With_body⟩ ::=- ‘do’   ⟨Statement⟩ ⟨Declarations⟩  ‘end-do’ ⟨Init_block⟩ ::=- ‘initializations’ ‘from’  ⟨String_expr⟩ · · · ‘to’  · · ·⟨Init_item⟩···   ‘as’ ⟨String_expr⟩ ⟨Init_item⟩‘,’ ‘[’  ⟨Init_item⟩  ‘]’ · · · ‘end-initializations’ ⟨Init_item⟩ ::=- Identifier ‘,’ ‘(’  ⟨Init_ﬁeldsel⟩‘evaluation of’ ⟨Expression⟩


 ‘)’


‘,’
 ‘(’  ⟨Init_ﬁeldsel⟩


 ‘)’

⟨Init_ﬁeldsel⟩ ::=- Identifier ⟨Do_block⟩ ::=- ‘do’ ⟨Stat_list⟩ ‘end-do’ ⟨Stat_list⟩ ::=-  ⟨Statement⟩

A.2 Expressions

Fair Isaac Corporation Proprietary Information














-

⟨Expression⟩ ::=-  ⟨Bool_expr⟩ ⟨Set_expr⟩ ⟨List_expr⟩
 ⟨Arith_expr⟩ ⟨String_expr⟩
 ⟨Array_expr⟩ ⟨NewRec_expr⟩ ⟨Ctr_expr⟩
 ⟨RefTo_expr⟩⟨Comparator⟩ ::=-  ‘<’ ‘<=’ ‘=’
 ‘<>’
 ‘>=’
 ‘>’












880

Appendix A: Syntax diagrams for the Mosel language⟨Bool_expr⟩ ::=- ⟨Bool_expr⟩ ‘and’  ⟨Bool_expr⟩ ‘or’ ‘and’  ‘(’ ⟨Iterator_list⟩ ‘)’ ⟨Bool_expr⟩ ‘or’  ‘in’ ⟨Set_expr⟩⟨Expression⟩  ‘not’ ⟨Is_expr⟩
⟨Expression⟩ ⟨Comparator⟩ ⟨Expression⟩‘not’ ⟨Bool_expr⟩
 ‘if’ ‘(’ ⟨Bool_expr⟩ ‘,’ ⟨Bool_expr⟩ ‘,’ ⟨Bool_expr⟩ ‘)’⟨Name_ref⟩‘true’
‘false’‘boolean’ ‘(’ ⟨Expression⟩ ‘)’‘(’ ⟨Bool_expr⟩ ‘)’⟨Is_expr⟩ ::=- ⟨Name_ref⟩ ‘is’  ‘not’⟨Set_expr⟩ ::=- ⟨List_expr⟩  ‘+’  ⟨List_expr⟩ ‘-’ ‘sum’ ‘(’ ⟨Iterator_list⟩ ‘)’ ⟨List_expr⟩
 ‘if’ ‘(’ ⟨Bool_expr⟩ ‘,’ ⟨List_expr⟩ ‘,’ ⟨List_expr⟩ ‘)’⟨Name_ref⟩‘[’ ‘]’‘,’‘[’  ⟨Expression⟩  ‘]’‘list’ ‘(’  ⟨List_expr⟩  ‘)’ ⟨Set_expr⟩ ‘(’ ⟨List_expr⟩ ‘)’

Fair Isaac Corporation Proprietary Information

⟨Type_name⟩  ‘array’  ‘set’   ‘of’ ⟨Type_name⟩ ‘list’ ‘range’‘record’‘procedure’‘function’⟨Set_expr⟩  ‘+’  ⟨Set_expr⟩ ‘-’  ‘⁎’ 
 ‘union’  ‘(’ ⟨Iterator_list⟩ ‘)’ ⟨Set_expr⟩
 ‘inter’  ‘if’ ‘(’ ⟨Bool_expr⟩ ‘,’ ⟨Set_expr⟩ ‘,’ ⟨Set_expr⟩ ‘)’⟨Name_ref⟩‘{’ ‘}’‘,’‘{’  ⟨Expression⟩  ‘}’⟨Arith_expr⟩ ‘..’ ⟨Arith_expr⟩‘set’ ‘(’  ⟨Set_expr⟩  ‘)’ ⟨List_expr⟩ ‘(’ ⟨Set_expr⟩ ‘)’⟨List_expr⟩ ::=- 

-











-

























881

Appendix A: Syntax diagrams for the Mosel language⟨Arith_expr⟩ ::=-  ⟨Arith_expr⟩⟨Arith_expr⟩  ‘+’
 ‘-’

 ‘⁎’

 ‘/’

 ‘div’  ‘mod’  ‘^’ ‘sum’  ‘(’ ⟨Iterator_list⟩ ‘)’ ⟨Arith_expr⟩ ‘prod’  ‘min’  ‘max’ ‘count’ ‘(’ ⟨Iterator_list⟩ ‘)’‘-’ ⟨Arith_expr⟩
 ‘if’ ‘(’ ⟨Bool_expr⟩ ‘,’ ⟨Arith_expr⟩ ‘,’ ⟨Arith_expr⟩ ‘)’⟨Name_ref⟩IntegerReal‘integer’ ‘(’ ⟨Expression⟩ ‘)’‘real’ ‘(’ ⟨Expression⟩ ‘)’‘(’ ⟨Arith_expr⟩ ‘)’⟨String_expr⟩ ::=- ⟨String_expr⟩  ‘+’  ⟨Expression⟩  ‘-’ ⟨Name_ref⟩String ‘string’ ‘(’ ⟨Expression⟩ ‘)’‘(’ ⟨String_expr⟩ ‘)’‘,’⟨NewRec_expr⟩ ::=- Identifier ‘(’  ‘.’ Identifier ‘:=’ ⟨Expression⟩⟨Array_expr⟩ ::=- ‘array’ ‘(’ ⟨Iterator_list⟩ ‘)’ ⟨Arith_expr⟩ ⟨Ctr_expr⟩ ::=- ⟨Arith_expr⟩   ‘<=’  ⟨Arith_expr⟩  ‘>=’  ‘=’ 
‘is_sos1’
‘is_sos2’ ⟨Name_ref⟩  ‘is_integer’ ‘is_binary’ ‘is_continuous’ ‘is_free’  ‘is_semcont’  ⟨Arith_expr⟩
 ‘is_semint’  ‘is_partint’ ‘(’ ⟨Ctr_expr⟩ ‘)’⟨RefTo_expr⟩ ::=- ‘->’ ⟨name_ref⟩ ‘(’ ⟨Expression⟩ ‘)’‘,’⟨Iterator_list⟩ ::=-  ⟨Iterator⟩

Fair Isaac Corporation Proprietary Information




















 ‘)’ -

-






882

Appendix A: Syntax diagrams for the Mosel language⟨Iterator⟩ ::=- ‘,’  Identifier ⟨Set_expr⟩ ⟨List_expr⟩ ‘in’  ⟨Set_expr⟩  ⟨List_expr⟩   ‘|’ ⟨Bool_expr⟩
Identifier ‘=’ ⟨Expression⟩  ‘|’ ⟨Bool_expr⟩ 

Identifier ‘as counter’⟨Name_ref⟩ ::=- Identifier  ⟨Dereferencing⟩⟨Dereferencing⟩ ::=-  ‘.’  Identifier 


‘set’


‘list’ ‘array’ ‘range’ ⟨Type_name⟩ ‘,’ ‘(’  ⟨Expression⟩  ‘)’









 -



A.3 Initializations data file format Identifier  ‘:’ ⟨Value⟩⟨Records⟩ ::= String⟨Value⟩ ::=- Identifier  String Integer



Real
 ‘true’ ‘false’



‘⁎’


‘?’
 ⟨Value_list⟩ ⟨Value_list⟩ ::=-  ‘[’  

Fair Isaac Corporation Proprietary Information‘[’ ‘]’ ‘(’  ⟨Value⟩


 ‘)’


-

 ⟨Value⟩



 ‘]’



883

APPENDIX B

Remote Invocation Protocol
A Mosel instance may be started remotely using either the connect procedure of the module mmjobs or
its equivalent routine of the XPRD library. From any of these environments one can compile, load and run
models as well as access files on the remote system. The remote invocation protocol also makes it
possible to control more precisely the execution of models (e.g. suspending execution or profiling) andquery information of a model (such as the value of entities) or the entire instance (e.g. to retrieve the listof available modules).
This protocol relies on two mechanisms:
1. the procedure setcontrol (available in mmjobs and XPRD) to (re)define Mosel instance control
parameters
2. the special remote file ’mcmd’ that only supports read access: the file name is interpreted as aquery and the retrieved data is the answer to this request

B.1 Instance control parameters
Mosel instance control parameters are either defined at the instance level or they apply to a specificmodel (see setcontrol). Some of the parameters serve for changing the behaviour of othercommands, others provide a means to execute some specific command.
The supported instance parameters are:■zerotol (real,instance): set the zero tolerance used for comparison and displaying real numbers(i.e. a real number smaller than the tolerance is treated as 0)■

realfmt (string,instance): set the C-format used to display reals■

flushdso (none,instance): unloads unused modules (i.e. calls XPRMflushdso)■

lang (string,instance): set the language of the instance■defaultnode (integer,instance): set the default node number used by the "rmt:" IO driver when
it is used without node reference (see Section 8.5.6)■

runmode (int,model): set the execution mode of a model (cannot be changed during the executionof the model):– 0: default– 1: debug– 2: profile– 3: tracing

Fair Isaac Corporation Proprietary Information

884

Appendix B: Remote Invocation Protocol■

dbgctrl (string,model): send a command to the debugger (model must be running in debugmode). See Section B.4■

dbgbrksub (int,model): toggle breaksub mode during a debugging session (default is 0)■

sdmax (int,instance): set the maximum depth of a call stack dump (default is 0)

B.2 mcmd pseudo file
The special remote file ’mcmd’ takes the form of an I/O driver where the file name is interpreted as aquery and the retrieved data is the answer to this request. Except for the dsostream command that canalso be open in write mode, ’mcmd’ only supports read access. A file name for this driver has thefollowing form:
mcmd:cmd[-opts][@mod[.submod]] cmdargs

cmd:

the operation to execute (e.g. ’eval’,’profres’...).

opts: options to change the format of the result. By default all data are sent using the Mosel binary
format ’bin:’. Adding option ’t’ switches to text format (still compatible with initialisations
blocks) and ’j’ will cause results to be sent as a JSON object (not compatible with initialisations
blocks). If option ’z’ is used the resulting file is compressed with gzip. A given command may
also support additional options (see ’lslib’). Except for the ’eval’ command, the result set
publishes always the same records that are either scalars of basic types or lists of basic types.
When a collection of values is returned a specific label indicating the dimension of the list
precedes the list.
mod: master model on which the operation will be performed.
submod: submodel. Only some operations can be applied to a submodel. Note that submodel ’0’ isthe master model itself (the first submodel has ID ’1’).
Supported commands:
covres (model)
Retrieve profiling results for test coverage. This command can only be called after the model has
been run in profiling mode (see Section B.3).
tottime:realRlines: range
lines: array(Rlines) of integer
iters: array(Rlines) of integer
Rfiles: range
files: array(Rfiles) of string
Rstarts:range
starts: array(Rstarts) of integer

dbgbrkp [ lndx [ cond|⁎ ] ] (model or submodel)
Breakpoint management. The model must be suspended. Without any parameters this command
returns the current list of breakpoints; the first parameter is interpreted as a line index and thesecond parameter is a logical expression (i.e. the breakpoint condition). With only one parameter,
the breakpoint on the corresponding line index is removed (no operation is performed if there wasno breakpoint). Use ’*’ to remove all breakpoints. With two parameters the corresponding
breakpoint is created (or modified). To set an unconditional breakpoint use ’*’ as the condition.
Note that breakpoints are attached to a model: even if several models running concurrently are
resulting from the same source file, setting a breakpoint for one model (instance) will have noeffect on the others.

Fair Isaac Corporation Proprietary Information

885

Appendix B: Remote Invocation Protocol
Rlndx: range
lndx: array(Rlndx) of integer
cond: array(Rlndx) of string

dbgflndx [ fctname|⁎ ] (model or submodel)
Line indices corresponding to a function name. This command returns the line indicescorresponding to the beginning (lndx) and end (elndx) of the requested function (several values
are returned when the routine is overloaded). The values of elndx are valid only if the model has
been compiled with option -G. Without any arguments or with argument ’*’, the command returns
all functions of the model. If option ’N’ is used, the arrays are sorted according to the function
names. With option ’L’ arrays are sorted following the line indices order.
Rsign: range
sign: array(Rsign) of string
lndx: array(Rsign) of integer
name: array(Rsign) of string
elndx: array(Rsign) of integer

dbglndx (model or submodel)
Retrieve the mapping of the line indices of a model/submodel. The model must be either
suspended or not running. The debugger interface works on line indices: each line index
corresponds to a file name and a line number in this file.
Rfiles: range
files: array(Rlines:range) of integer
Rlines: range
lines: array(Rfiles:range) of string

dbgstat (model or submodel)
Current execution status of a model. The model must be suspended. If no submodel is specified,statuses of all submodels are returned in addition to the master model (to get the status of themaster model only use submodel ’0’).
Rid: range
id:array(Rid) of integer
stat: array(Rid) of integer
stlev:array(Rid) of integer
lndx: array(Rid) of integer

dbgstlev [ stlev|⁎ [ maxlev ] ] (model or submodel)
Stack management. The model must be suspended. Without any arguments or with argument ’*’,
the command returns a stack dump (i.e. a list of line indices). If the argument is ≥ 0, it becomesthe current stack level. The optional argument ’maxlev’ defines the maximum number of levels toreturn (default:10). The stack level defines the context in which expression evaluations are
performed in the ’eval’ command.
Rid: range
id: array(Rid) of integer
stat:array(Rid) of integer
stlev:array(Rid) of integer
lndx:array(Rid) of integer

dsostream dsoname [specific parameters] (model or submodel)This command opens a stream to the specified module (this command supports both read andwrite mode). The module must implement the SRV_DSOSTRE service. The behaviour of thestream and the expected parameters depend on the implementation.
eval label:expression [ range ] (model or submodel)
Evaluate an expression in the context of the provided model/submodel. Execution of the model
must be completed or suspended. If option ’i’ is used, array indices are reported as order

Fair Isaac Corporation Proprietary Information

886

Appendix B: Remote Invocation Protocol

numbers instead of values. With option ’n’ array values are replaced by empty strings. The label"label" is used to identify the expresion in the result file: if it is ’.’ no label is generated (the data
result is directly sent to the result file), if it is omitted then the expression itself is used as the label,otherwise the provided string is the label. Several expressions may be evaluated in a single
request (in this case they must all be labelled).
It is possible to grab only a part of a collection (array, set or list) by specifying range information.
Ranges definitions take one of these two forms:■[ maxelt ]: get at most ’maxelt’ elements■[ skip maxelt ]: get at most ’maxelt’ entries after skipping ’skip’ elements

Several range definitions may be specified (separated by blanks): they are used when exploring
complex structures (e.g. a list of list). The structure and type of the result set depends on theexpression.
info (instance, model or submodel)This command reports all symbols defined by Mosel (if used without specifying any argument), a
module (the argument is the module name) or a model (the argument is a model or submodel ID).
In the case of a module, the command loads the module if it is not yet in memory. For a model (orpackage), it must have been loaded prior to this command since it is referenced by its ID and beeither not running or suspended. Information returned by the ’info’ command:
fmt:
integer
Rhdr:
range
hdr:
array(Rhdr) of string
Rdeps:
range
deps:
array(Rdeps) of integer
depsvers:array(Rdeps) of integer
depstyp: array(Rdeps) of integer
Rtyps:
range
typs:
array(Rtyps) of string
typscod: array(Rtyps) of integer
Rparms: range
parms:
array(Rparms) of stringparmsval:array(Rparms) of integer
parmsdesc:array(Rparms) of string
Rconsts: range
consts: array(Rconsts) of string
conststyp:array(Rconsts) of integer
Rcstint: range
cstint: array(Rcstint) of integer
Rcststr: range
cststr: array(Rcststr) of string
Rcstdbl: range
cstdbl: array(Rcstdbl) of realRvars:
range
vars:
array(Rvars) of string
varstyp: array(Rvars) of integer
varsopt: array(Rvars) of integer
Rarrndx: range
arrndx: array(Rarrndx) of string
Rfct:
range
fct:
array(Rfct) of string
fctsign: array(Rfct) of string
fcttyp: array(Rfct) of integer
Rdtyp:
range
dtyp:
array(Rdtyp:range) of string
dtyptyp: array(Rdtyp) of integer
Rrecsstart:range
recsstart:array(Rrecsstart) of integer
Rrecfield:range
recfield:array(Rrecfield) of string
recftype:array(Rrecfield) of integer
Riodrv: range
iodrv:
array(Riodrv) of string

Fair Isaac Corporation Proprietary Information

887

Appendix B: Remote Invocation Protocol
iodrvinfo:array(Riodrv) of string
Rannsident:range
annsident:array(Rannsidente) of string
Rannsstart:range
annsstart:array(Rannsstart) of integer
Ranns:
range
anns:
array(Ranns) of string

lsattr (model or submodel)
Return the list of available types attributes. The array ’attrsntyp’ gives the type supporting theattribute and ’attrsatyp’ is the type of the attribute.
Rattrs:range
attrs:
array(Rattrs) of string
attrsntyp: array(Rattrs) of integer
attrsatyp: array(Rattrs) of integer

lslib (instance)
Return the list of available packages and modules. If option ’p’ is used, packages are reported with
their full path.
Rpkgs: range
pkgs: array(Rpkgs) of string
Rdsos: range
dsos: array(Rdsos) of string

lsloc (model or submodel)This command is similar to ’info’ but it can only be applied to a suspended model: it reports all
local variables.
Rtyps:
range
typs:
array(Rtyps) of string
typscod: array(Rtyps) of integer
Rvars:
range
vars:
array(Rvars) of string
varstyp: array(Rvars) of integer
varsopt: array(Rvars) of integer
Rarrndx: range
arrndx: array(Rarrndx) of string

profrep [ srcpath ] (model)
Ask for generation of result files after a profiling or covering execution, the result of this operation
is a list of strings corresponding to the messages displayed by the commands profile orcover. This command can only be called after the model has been run in profiling or coveringmode (see Section B.3). The optional srcpath argument is a list of paths (conforming to theoperating system conventions) where the source files can be found. The option ’C’ implies thegeneration of the coverage files (e.g. ’file.mos.cov’), with option ’c’ the same files are produced
but without counting of lines (i.e. a line that is executed is marked with ’1’ instead of the actual
number of executions). The option ’P’ (the default) will generate the profiling files (e.g.
’file.mos.prof’), with option ’p’ timings are reported in percentage of the total amount of time
(instead of elapsed time).
msg:list of string

profres [ path ] (model)
Retrieve profiling results. This command can only be called after the model has been run inprofiling mode (see Section B.3). The path argument indicates which execution is requested:
several "executions" may be available when the model starts other models with ’mmjobs’ (thereturned data set includes the number of additional executions available via the nbsub field). For
instance the path 1.3 corresponds to the third "execution" started by the first "execution".

Fair Isaac Corporation Proprietary Information

888

Appendix B: Remote Invocation Protocol
tottime:real
nbsub: integer
nbnoprf:integer
Rlines: range
lines: array(Rlines) of integer
iters: array(Rlines) of integer
times: array(Rlines) of realelaps: array(Rlines) of real
Rfiles: range
files: array(Rfiles) of string
Rstarts:range
starts: array(Rstarts) of integer

B.3 Profiler interface
Profiling a model requires a bim file compiled with option ’-G’. The runmode has to be set to ’2’ before
starting the execution. After the end of the profiler run, calls to the command ’mcmd:profres’,’mcmd:profrep’ or ’mcmd:covres’ can be used for retrieving the results.

B.4 Debugger interface
The debugger can be started even if the flag ’-G’ has not been used for compilation but in this casemost commands will fail to return useful information. To run a debugging session the runmode of themodel must be set to ’1’ before starting its execution. If the model was compiled with ’-G’, theexecution is immediately suspended before the first statement of the model and a notification event issent.
During a debugging session changes of the model execution status are notified by specific events ofclass ’EVENT_DBG’ (32770). The value of these events is a 32bit integer (cast to a real): the first 16 bits
are a parameter (meaning depending on the reason) and the following 16 bits indicate the reason for the
notification:■

DBG_NOTIF_START (1«16): Submodel starting (the parameter is the submodel ID)■

DBG_NOTIF_END (2«16): Submodel ending (the parameter is the submodel ID)■

DBG_NOTIF_STOP (3«16): Execution suspended (the parameter is the VM status)

When an event ’DBG_NOTIF_STOP’ is received, the model (and its submodels) is in suspended stateand can be sent commands (see Section B.2). To continue execution a control parameter ’dbgctrl’has to be set. The possible values are (the operation applies to the master model unless a submodel
number ’num’ is given):■

C: continue■

E: end of execution, abort debugging session■

N [num]: continue to next statement■

S [num]: step into subroutine■

F [num]: continue up to end of subroutine■

T num lndx: continue up to the specified line number on submodel ’num’ (0 for master model)

Additionally, during the execution of a model running in debugging mode (but that is not suspended), thefollowing ’dbgctrl’ commands can be used:

Fair Isaac Corporation Proprietary Information

889

Appendix B: Remote Invocation Protocol■

B: suspend execution (e.g. consequence of ctrl-C)■

E: end of execution, abort debugging session

When the execution of the model is about to end (including after an error), it is suspended just before
exiting such that the user can look at the current status.

Fair Isaac Corporation Proprietary Information

890

APPENDIX C

Error messages
The Mosel error messages listed in the following are grouped according to the following categories:■

General errors: may occur either during compilation or when running a model.

■

Parser/compiler errors: raised during the model compilation.

■

Runtime errors: when running a model.

All messages are identified by their code number, preceded either by the letter E for error or W for warning.
Errors cause the compilation or execution of a model to fail, warnings simply indicate that there may besomething to look into without causing a failure or interruption.
This chapter documents the error mesages directly generated by Mosel, not the messages stemmingfrom Mosel modules or from other libraries used by modules.

C.1 General errors
These errors may occur either during compilation or when running a model.
E-1

Internal error in ‘location’ (errortype)
An unrecoverable error has been detected, Mosel exits. Please contact Xpress Support.

E-2

General error in ‘location’ (errortype)
An internal error has been detected but Mosel can recover. Please contact Xpress Support.

E-4

Not enough memory
Your system has not enough memory available to compile or execute a Mosel model.

E-21

I cannot open file ‘file’ for writing (driver_error)
Likely causes are an incorrect access path or write-protected files.

E-22

I cannot open file ‘file’ for reading (driver_error)
Likely causes are an incorrect access path or filename or not read-enabled files.

E-23

Error when writing to the file ‘file’ (driver_error)
The file could be opened for writing but an error occurred during writing (e.g. disk full).

E-24

Error when reading from the file ‘file’ (driver_error)
The file could be opened for reading but an error occurred while reading it.

E-25

Unfinished string
A string is not terminated, or different types of quotes are used to indicate start and end of astring.
Examples:Fair Isaac Corporation Proprietary Information

891

Appendix C: Error messages
writeln("mytext)

E-26

Identifier expected
May occur when reading data files: a label is missing or a numerical value has been foundwhere a string is expected.
Examples:declarations
D: range
end-declarations
initializations from "test.dat"D
end-initializations

Contents of test.dat:[1 2 3]The label D: is missing.
E-27

Number expected
May occur when reading data files: another data type has been found where a numerical value
is expected.
Examples:declarations
C: set of real
end-declarations
initializations from "test.dat"C
end-initializations

Contents of test.dat:
C: [1 2 c]c is not a number.
E-28

Digit expected for constant exponent
May occur when using scientific notation for real values.
Examples:b:= 2E -10

E must be immediately followed by a signed integer (i.e. no spaces).
E-29

Wrong file descriptor number for selection (num)fselect is used with an incorrect parameter value.

E-34

I cannot find IO driver ‘driver’
The system cannot locate the IO driver driver for opening a file. This may happen if the driver isprovided by a module not already loaded in memory. To avoid this problem the module nameshould be given with the driver name. For instance use "mmodbc.odbc" instead of "odbc"
alone.

E-35

Error when closing file ‘file’ (driver_error)
An error occurred while closing a file. Typically the last write operation for clearing buffers
failed.

E-36

Read error (file)I/O error during file reading.

Fair Isaac Corporation Proprietary Information

892

Appendix C: Error messages

E-37

Invalid character
Invalid character sequence found while reading a text file, non-conforming to the current
encoding. Possibly an incorrect encoding (Mosel default is UTF-8) has been specified foraccessing this file.

E-38

Unknown compiler flag(s) ‘flag’ ignored
Some of the flag(s) used with compile have not been recognized, please refer to the list
documented for compile.

E-39

Unknown BIM reader flag(s) ‘flag’ ignored
Some of the flag(s) used with load have not been recognized, please refer to the list
documented for load.

E-40

Unsupported encoding ‘encoding’ (ignored)
The encoding name specified after the marker !@encoding is unknown.

C.2 Parser/compiler errors
Whenever possible Mosel displays the location where an error has been detected during compilation in
the format (line_number/character_position_in_line).
E-100

Syntax error before token
The parser cannot continue to analyze the source file because it has encountered an
unexpected token. When the error is not an obvious syntax error, make sure you are not using
an identifier that has not been defined before.
Examples:token: )writeln(3 mod)mod must be followed by an integer (or a numerical expression evaluating to an
integer).
token: write
if i > 0
write("greater")end-ifthen has been omitted.
token: end
if i > 0 then write("greater") end-if

A semicolon must be added to indicate termination of the statement preceeding theend-if.
E-101

Incompatible types (type_of_problem)
We try to apply an operation to incompatible types. Check the types of the operands.
Examples:
type_of_problem: assignmenti:=0i:=1.5

The first assignment defines i as an integer, the second tries to re-assign it a realvalue: i needs to be explicitly declared as a real.
type_of_problem: cmp

Fair Isaac Corporation Proprietary Information

893

Appendix C: Error messages
12=1=2A truth value (the result of 12=1 is compared to a numerical value.
E-102

Incompatible types for parameters of ‘routine’A subroutine is called with the wrong parameter type. This message may also be displayed
instead of E-104 if a subroutine is called with the wrong number of parameters. (This is due tothe possibility to overload the definition of subroutines).
Examples:procedure myprint(a:integer)
writeln("a: ", a)end-procedure
myprint(1.5)

The subroutine myprint is called with a real-valued argument instead of an integer.
E-103

Incorrect number of subscripts for ‘array’(num1/num2)
An array is used with num2 subscripts instead of the number of subscripts num1 indicated at its
declaration.
Examples:‘array’(num1/num2): ‘A’(2/1)
declarations
A: array(1..5,range) of integer
end-declarations
writeln(A(3))

E-104

Incorrect number of parameters for ‘routine’(num1/num2)
Typically displayed if write or read are used without argument(s).

E-106

Division by zero detected
Explicit division by 0 (otherwise error only detected at runtime).

E-107

Math error detected on function ‘fct’
For example, a negative number is used with a fractional exponent.

E-108

Logical expression expected here
Something else than a logical condition is used in an if statement.

E-109

Trying to redefine ‘name’
Objects can only be defined once, changing their type is not possible.
Examples:i:=0
declarations
i: realend-declarations

i is already defined as an integer by the assignment.
E-111

Logical expression expected for operator ‘op’
Examples:
op: and
2+3 and true

E-112

Numeric expression expected for operator ‘op’
Examples:Fair Isaac Corporation Proprietary Information

894

Appendix C: Error messages

op: +12+{13}

op: *uses "mmxprs"
declarations
x:mpvarend-declarations
minimize(x⁎x)

Multiplication of decision variables of type mpvar is only possible if a suitable module(like mmnl) supporting non-linear expressions is loaded.
E-113

Wrong type for conversion
Mosel performs automatic conversions when required (for instance from an integer to a real) or
when explicitly requested by using the type name, e.g. integer(12.5). This error is raised
when an unsupported conversion is requested or when no implicit conversion can be applied.

E-114

Unknown type for constant ‘const’
A constant is defined but there is not enough information to deduce its type or the type impliedcannot be used for a constant (for instance a linear constraint).

E-115

Expression cannot be passed by reference
We try to use a constant where an identifier is expected. For instance, only non-constants canbe used in an initializations block.

E-118

Wrong logical operator
A logical opeartor is used with a type for which it is not defined.
Examples:if("abc" in "acd") then writeln("?"); end-if

The operator in is not defined for strings.
W-121

Statement with no effectA statement is used that has no effet, for example r += 0.

E-122

Control parameter ‘param’ unknown
The control parameters of Mosel are documented in the Mosel Reference manual underfunction getparam. All control parameters provided by a module, e.g. mmxprs, can be display
with the command EXAM, e.g. exam -p mmxprs. In IVE this information is displayed by themodule browser.

E-123‘identifier’ is not defined
identifier is used without or before declaring it. Check the spelling of the name. If identifier isdefined by a module, make sure that the corresponding module is loaded. If identifier is asubroutine that is defined later in the program, add a forward declaration at the beginning of
the model.

E-124

An expression cannot be used as a statement
An expression stands where a statement is expected. In this case, the expression is ignored —typically, a constraint has been stated and the constraint type is missing (i.e. >= or <= ...) or an
equality constraint occurs without decision variables, e.g. 2=1.
This error also appears when the return value of a function call is not retrieved.

E-125

Set expression expected
For instance when trying to compute the union between an integer constant and a set of
integers: union(12+{13})Fair Isaac Corporation Proprietary Information

895

Appendix C: Error messages

E-126

String expression expected
A string is expected here: for instance a file name for an initializations block.

E-127

A function cannot be of type ‘type’
Some types cannot be the return value of a function. Typically no function can return a decisionvariable (type mpvar).

E-128

Type ‘type’ has no field named ‘field’
Trying to access an unknown field in a record type.
Examples:declarations
myrec=record
i,j:integer
end-record
r:myrec
end-declarations
r.k:=0k is not a field of r.
E-129

Type ‘type’ is not a record
Trying to use a record dereference on an object that is not a record. For instance using i.j
with i defined as an integer.

E-130

A type definition cannot be local
It is not possible to declare a type in a procedure or function.

W-131

Array ‘identifier’ is not indexed by ranges: assignment may be incorrect
When performing an inline initialization (operator ::) on an array, it is recommended to list
indices if the indexing sets are not ranges. Indeed, since order of set elements is notguaranteed the values provided may not be assigned to the expected cells in the array.
Examples:declarations
a:array({3,2,1}) of integer
end-declarations! a::[3,2,1]!=> a(1)=3 a(2)=2 a(3)=1
a::([3,2,1])[3,2,1] !=> a(1)=1 a(2)=2 a(3)=3E-132

Set or list expression expected
Aggregate operators (like sum or forall) require sets or lists to describe the domains for theirloops.
Examples:declarations
i:integer
end-declarations
forall(i = 2) writeln(i)Since i is declared as an integer before the loop, the expression i=2 is a logicalexpression (it checks whether i is equal to 2) instead of an index definition.
W-144

Symbol ‘identifier’ implicitly declared
When a model is compiled with option -wi this message gets displayed for every symbol thatis not explicitly declared by the model.

E-147

Trying to interrupt a non existing loop
break or next is used outside of a loop.

E-148

Procedure/function ‘identifier’ declared but not defined
A procedure or functions is declared with forward, but no definition of the subroutine bodyhas been found or the subroutine body does not contain any statement.

Fair Isaac Corporation Proprietary Information

896

Appendix C: Error messages

E-149

Some requirements are not met
A package may declare requirements: these are symbols that must be declared by models
using this package. This error occurs when a model uses a package without providing thedefinitions for all the requirements.

E-150

End of file inside a commentary
A commentary (usually started with (!) is not terminated. This error may occur, for instance,with several nested commentaries.

E-151

Incompatible type for subscript num of ‘identifier’
The subscript counter num may be wrong if an incorrect number of subscripts is used.
Examples:declarations
A:array(1..2,3..4) of integer
end-declarations
writeln(A(1.3))

This prints the value 2 for num, although the second subscript is actually missing.
W-152

Empty set for a loop detected
This warning will be printed in a few cases where it is possible to detect an empty set duringcompilation.

E-153

Trying to assign the index ‘idx’
Loop indices cannot be re-assigned.
Examples:declarations
C: set of string
D: range
end-declarations
forall(d in D) d+=1
forall(c in C) if (c='a') then c:='A'; end-if

Both of these assignments will raise the error. To replace an element of the set C, theelement needs to be removed and the new element added to the set.
E-154

Unexpected end of file
May occur, for instance, if an expression at the end of the model file is incomplete and in
addition end-model is missing.

E-155

Empty ‘case’A case statement is used without defining any choices.

E-156‘identifier’ has no type
The type of identifier cannot be deduced. Typically, an undeclared object is assigned an empty
set.

E-157

Scalar expression expected
Examples:declarations
B={'a','b','c'}
end-declarations
case B of
1: writeln("stop")
end-case

The case statement can only be used with the basic types (integer, real, boolean,string).

Fair Isaac Corporation Proprietary Information

897

Appendix C: Error messages
D:: [1,2]

Declaration of arrays by assignment is only possible if the index set can be deduced(e.g. definition of an array of linear constraints in a loop).
E-159

Compiler option ‘option’ unknown
Valid compiler options include explterm and noimplicit. See section 2.3.3 for moredetails.

E-160

Definition of functions and procedures cannot be nested
May occur, for instance, if end-procedure or end-function is missing and the definition of
a second subroutine follows.

E-161

Expressions not allowed as procedure/function parameter
Occurs typically if the index set(s) of an array are defined directly in the procedure/function
prototype.
Examples:procedure myproc(F:array(1..5) of real)
writeln("something")
end-procedure

Replace either by array(range) or array(set of integer) or define A:=1..5
outside of the subroutine definition and use array(A)E-162

Non empty string expected here
This error is raised, for example, by uses ""E-163

Array declarations in the form of a list are not allowed as procedure/function parameter
Basic types may be given in the form of a list, but not arrays.
Examples:procedure myproc(F,G,H:array(range) of real, a,b,c:real)
writeln("something")
end-procedure

Separate declaration of every array is required:procedure myproc(F:array(range) of real, G:array(range) of real,
H:array(range) of real, a,b,c:real)

W-164

A local symbol cannot be made public
Examples:procedure myproc
declarations
public i:integer
end-declarations
i:=1
end-procedure

Any symbol declared in a subroutine is local and cannot be made public.
E-165

Declaration of ‘identifier’ hides a parameter
The name of a function/procedure parameter is re-used in a local declaration.
Examples:procedure myproc(D:array(range) of real)declarations
D: integer
end-declarations
writeln(D)end-procedure

Rename either the subroutine argument or the name used in the declaration.

Fair Isaac Corporation Proprietary Information

898

Appendix C: Error messages

W-166‘;’ missing at end of statement
If the option explterm is employed, then all statements must be terminated by a semicolon.

E-167

Operator ‘op’ not defined
A constructor for a type is used in a form that is not defined.
Examples:uses "complex"
c:=complex(1,2,3)

The module complex defines constructors for complex numbers from one or two reals,
but not from three.
E-168‘something’ expected here
Special case of “syntax error” (E-100) where the parser is able to provide a guess of what is
missing.
Examples:something: :=a: 3

The assignment is indicated by :=.
something: ofdeclarations
S: set integer
end-declarationsof has been omitted.
something: ..
declarations
A: array(1:2) of integer
end-declarations

Ranges are specified by ...
E-169‘identifier’ cannot be used as an index name (the identifier is already in use or declared)
Examples:i:=0
sum(i in 1..10)

The identifier i has to be replaced by a different name in one of these lines.
E-170‘=’ expects a scalar here (use ‘in’ for a set)Special case of syntax error (E-100).
Examples:sum(i = 1..10)

Replace = by in.
E-171

The [upper/lower] bound of a range is not an integer expression
Examples:declarations
A: array(1..2.5) of integer
end-declarations

Ranges are intervals of integers, so the upper bound of the index range must bechanged to either 2 or 3.
E-172

Only a reference to a public set is allowed here
All index sets of a public array must also be public.

Fair Isaac Corporation Proprietary Information

899

Appendix C: Error messages

E-173

Statement allowed in packages only
The block requirements can only be used in packages.

E-175

Index sets of array types must be named
User types defined as arrays must be indexed by named sets (i.e. declared separately). For
instance it is not allowed to use range or set of string as an index of such an array.

E-176

Only a public type is allowed here
If a user type depending on another user type is declared declared public, the secondary typemust also be public. For instance, assuming type T1 is private, it is not possible to declare T2
as a public T2=set of T1.

E-177

Incorrect number of initializers (n1/n2)
In an inline initialization (operator ::) the number of provided values to assign does not matchthe list of indices.

E-202

Integer constant expected
Versions numbers (stated by means of the version compiler directive) must consist in 1 to 3
numbers separated by dots (e.g. 1.2.3). This error is displayed if a version number does notconform to this syntax.

E-207

Problem reference/type expected here
The operator with is used with something that is not a problem.

E-208

There can be only one counter
The as counter declaration can appear only once in an iterator list.

E-209

Missing loop indices
Typically an iterator list contains only a counter declaration: it is necessary to provide at least
one index.

E-210

String starting at line line is unfinishedA multiline string is not correctly terminated with the matching end marker.

E-211

Invalid annotation syntax (ignored)
Malformed annotation that cannot be identified (e.g. containing .. or invalid characters—only
alphanumeric and underscore are allowed in annotation names).

E-212

Annotations: invalid path ‘name’
Some portion of the path forming an annotation identifier, e.g. cat1.cat2 is the path for the
annotation !@cat1.cat2.name, cannot be accessed.

E-213

Annotations: name ‘name’ not foundSome portion of the path forming an annotation identifier, e.g. cat1.cat2 is the path for the
annotation !@cat1.cat2.name, is not defined.

E-214

Annotations: trying to redefine ‘name’ (ignored)
An annotation can only be defined once.

E-215

Annotations: invalid definition string for ‘name’ (value)
Incorrect or incomplete annotation declaration in an @mc.def statement, such as duplicate or
missing property or value, use of an unknown keyword. Please refer to the list of permissible
declaration statements in Section 2.14.3.

E-217

Annotations: wrong value ‘value’ for ‘name’ (expecting: value2)
An annotation is assigned a value that does not correpond to the value type or set of values
that have been specified in its declaration (via @mc.def).

E-218

Annotations: missing chapter for ‘name’
moseldoc is trying to add a documentation entry under a chapter or section that has not (yet)been defined.

Fair Isaac Corporation Proprietary Information

900Appendix C: Error messages

C.2.1 Errors related to modules
E-302

The symbol ‘identifier’ from ‘module’ cannot be defined (redefinition)
Two different modules used by a model define the same symbol (incompatible definitions).

E-303

Wrong type for symbol ‘identifier’ from ‘module’Internal error in the definition of a user module (an unknown type is used): refer to the list of
type codes in the Native Interface reference manual.

W-306

Unknown operator ‘op’ (code num) in module ‘module’Internal error in the definition of a user module: refer to the list of operator codes in the Native
Interface reference manual.

E-307

Operator ‘op’ (code num) from module ‘module’ rejectedInternal error in the definition of a user module: an operator is not defined correctly.

E-308

Parameter string of a native routine corrupted
Internal error in the definition of a user module: refer to the list of parameter type codes in the
Native Interface reference manual.

W-309

Problem type ‘typ’ unknown: extension ‘ext’ ignored
A module declares a native type as a problem extension but the compiler cannot find the base
type. For instance the new type is named "myprob.pb" but "myprob" does not exist.

C.2.2 Errors related to packages
E-320

Package ‘package’ not foundA package has not been found in the module path (see section 2.3.1 for the search rules).

E-321‘file’ is not a package
Typically displayed if a model is used as a package (the source for the bim file starts with themodel keyword instead of package).

E-322

Wrong version for package ‘package’(using:num1.num2.num3/required:num4.num5.num6)
A model is compiled with package A depending on a package B. The bim file Mosel has loadedfor B is not compatible with the one used for compiling A (found version num1.num2.num3,
required version is num4.num5.num6).

E-323

Package ‘package’ imported several times
A package cannot be imported several times in a model. This error occurs usually when amodel uses packages A and B, and package B already includes A.

C.3 Runtime errors
Runtime errors are usually displayed without any information about where they have occurred. To obtainthe location of the error, use the flag g with the COMPILE, CLOAD, or EXECUTE command.

C.3.1 Initializations
E-30

Duplicate label ‘label’ at line num of file ‘file’ (ignored)
The same label is used repeatedly in a data file.
Examples:D: [1 2 3]
D: [1 2 4]

Fair Isaac Corporation Proprietary Information

901

Appendix C: Error messages

E-31

Error when reading label ‘label’ at (num1,num2) of file ‘file’
The data entry labeled label has not been read correctly. Usually this message is preceded by amore detailed one, e.g. E-24, E-27 or E-28.

E-32

Error when writing label ‘label’ at (num1,num2) of file ‘file’
The data entry labeled label has not been written correctly. Usually this message is preceded bya more detailed one, e.g. E-23.

E-33

Initialization with file ‘file’ failed for: list_of_identifier
Summary report at the end of an initializations section. Usually this message ispreceded by more detailed ones, e.g. E-27, E-28, E-30, E-31.

C.3.2 General runtime errors
E-51

Division by zero
Division by 0 resulting from the evaluation of an expression.

E-52

Math error performing function ‘identifier’
For example ln used with inadmissible argument, such as 0 or negative values.

E-72

Not a runnable model (main procedure not found)
Most likely, you are trying to execute a ’package’ as if it were a ’model’.

E-1000

Inconsistent range
Typically displayed if the lower bound specified for a range is greater than its upper bound.
Examples:D:=3..-1

E-1001

Conflicting types in set operation (op)A set operation can only be carried out between sets of the same type.
Examples:declarations
C: set of integer
D: range
end-declarations
C:={5,7}
D:=C

The inverse, C:=D, is correct because ranges are a special case of sets of integers.
E-1002

An index is out of range
An attempt is being made to access an array entry that lies outside of the index sets of the array.

E-1003Trying to modify a finalized or fixed set
Occurs, for instance, when it is attempted to re-assign a constant set or to add elements to a
fixed set.

E-1004Trying to access an uninitialized object (type_of_object)
Occurs typically in models that define subroutines.
Examples:
type_of_object: arrayforward procedure myprint
myprint
declarations
A:array(1..2,3..4) of integer
end-declarations

Fair Isaac Corporation Proprietary Information

902

Appendix C: Error messages
procedure myprint
writeln(A(1,2))
end-procedure

Move the declaration of A before the call of the subroutine
E-1005

Wrong type for “procedure”
Occurs when procedures settype or getvars are used with incorrect types.

E-1006

Null reference (internal_function)
This error is a special case of E-1004 when the problem is detected on an external type or scalar(e.g. accessing a record field on an object that has not been initialized).

E-1009Too many initializers
The number of data elements exceeds the maximum size of an array.
Examples:declarations
A:array(1..3) of integer
end-declarations
A::[1,2,3,4]

E-1010Trying to extend a unary constraint
Most types of unary constraints cannot be transformed into constraints on several variables.
Examples:declarations
x,y: mpvar
end-declarations
c:=x is_integerc+=yE-1011

Dense array too big
The model is trying to create a dense array with more than 4 billion cells, typically such an arrayshould have been declared as sparse (dynamic or hashmap). This error will be raised when thearray is allocated (after its declaration or when it is first accessed).

E-1013

Infeasible constraint
The simple cases of infeasible unnamed constraints that are detected at run time include:
Examples:declarations
x:mpvarend-declarations
i:=-1
if(i>=0,x,0)>=1! or:x-x>=1

E-1014

Conflicting types in array operation (op)An array operation (like assignment) can only be carried out between arrays of the same typeand structure.

E-1015Trying to modify a constant list
Occurs, for instance, when it is attempted to apply a destructive operation (like splittail) toa constant list.

E-1016Trying to get an element in an empty set
The function getfirst or getlast is applied to an empty set.

Fair Isaac Corporation Proprietary Information

903

Appendix C: Error messages

E-1017

Trying to get an element in an empty list
The function getfirst or getlast is applied to an empty list.

E-1018Invalid identifier ‘identifier’ for publish
The publish command has received an invalid identifier name (e.g. not a valid Mosel
identifier or the name is already in use as Mosel idientifier).

E-1100Empty problem
We are trying to generate or load an empty problem into a solver (i.e. no constraints; bounds do
not count as constraints).

E-1103

Too many matrix coefficients
Matrix size exceeds machine capacity: for 32bit versions the limit are 2billion (2 · 10E9)elements.

C.3.3 BIM reader
E-80‘file’ is not a BIM file
Trying to load a file that does not have the structure of a BIM file.

E-82

Wrong BIM format version (current:num1/required:num2) for file ‘file’
A BIM file is loaded with an incompatible version of Mosel: preferably the same versions should
be used for generating and running a BIM file.

E-83

BIM file ‘file’ corrupted
A BIM file has been corrupted, e.g. by saving it with a text editor.

E-84

File ‘file’: model cannot be renamed
A model file that is being executed cannot be re-loaded at the same time.

W-85

Trailing data at end of file ‘file’ ignored
At the end of a BIM file additional, unidentifiable data has been found (may be a sign of filecorruption).

E-88

BIM file ‘file’ corrupted
Incomplete or otherwise damaged BIM file.

E-90

Signature error (description)
During the generation of a BIM file, a problem with the signature has occurred.

E-91

Signature verification error (description)
While reading a BIM file, a problem with the signature has occurred (e.g. trying to checksignature for a file that is not signed; or the keys that have been employed don’t match).

E-92

Encryption error (description)
Problem with encryption during the generation of a BIM file (e.g. invalid or missing key).

E-93

Decryption error (description)
Problem with decryption while reading a BIM file (e.g. invalid or missing key).

C.3.4 Module manager errors
E-350

Module ‘module’ not foundA module has not been found in the module path (see section 2.3.1 for the search rules). Thismessage is also displayed, if a module depends on another library that has not been found (e.g.
module mmxprs has been found but Xpress Optimizer has not been installed or cannot belocated by the operating system).

Fair Isaac Corporation Proprietary Information

904

Appendix C: Error messages

E-351

File ‘file’ is not a Mosel DSO
Typically displayed if Mosel cannot find the module initialization function.

E-352

Module ‘module’ requires a more recent version of Mosel (unsupported interface)A module is not compatible with the Mosel version used to load it.

E-353

Module ‘module’ disabled by restrictions
Module module either does not implement restriction handling at all or it requires features thatare not authorized. See section 1.3.4 (restricted mode) and section 8.6.2 (Remote Launcher
configuration) to learn how to relax the restrictions.
Examples:
mmxprs will fail with the restriction setting NoTmp

E-354

Error when initializing module ‘module’
Usually preceded by an error message generated by the module. Please refer to the
documentation of the module for further detail.

E-355

Wrong version for module ‘module’(using:num1.num2.num3/required:num4.num5.num6)
A model is run with a version of a module that is different from the version that has been used
to compile the model (trying to run with version num1.num2.num3, required version isnum4.num5.num6).

E-358

Error when resetting module ‘module’A module cannot be executed (e.g. due to a lack of memory).

E-359

Driver ‘pkg.driver’ rejected (reason)
A module publishes an IO driver which name is invalid or that is missing some mandatory
function.

E-360

Control parameter ‘module.param’ unknown (setting ignored)
It is possible to set module parameters when running a model (using the RUN command for
instance): in the list of assignments, a control parameter cannot be found in the indicatedmodule.

E-361

Version number truncated (‘vernum’)
A version number (for module, model or package) consists in three positive numbers a.b.c. Thiserror is raised if one of these numbers is larger than 999.

E-362

The operating system failed to load file ‘file’ (‘description’)
The module file has been found but cannot be loaded by the system—there will typically besome system error message indicating the exact cause, such as wrong architecture (e.g. using
a library compiled for Windows under Linux or bitness mismatch) or missing additional files(e.g. tyring to use module matlab without having previously installed Matlab—see the manual
Xpress MATLAB Interface for further detail, or attempting to use mmoci without having installed
the Oracle Instant Client—see setup instructions in the whitepaper Using ODBC and otherdatabase interfaces with Mosel).

Fair Isaac Corporation Proprietary Information

905

APPENDIX D

Contacting FICO
FICO provides clients with support and services for all our products. Refer to the following sections formore information.

Product support
FICO offers technical support and services ranging from self-help tools to direct assistance with a FICO
technical support engineer. Support is available to all clients who have purchased a FICO product andhave an active support or maintenance contract. You can find support contact information and a link to
the Customer Self Service Portal (online support) on the Product Support home page(www.fico.com/en/product-support).
The FICO Customer Self Service Portal is a secure web portal that is available 24 hours a day, 7 days aweek from the Product Support home page. The portal allows you to open, review, update, and close
cases, as well as find solutions to common problems in the FICO Knowledge Base.
Please include ’Xpress’ in the subject line of your support queries.

Product education
FICO Product Education is the principal provider of product training for our clients and partners. Product
Education offers instructor-led classroom courses, web-based training, seminars, and training tools forboth new user enablement and ongoing performance support. For additional information, visit theProduct Education home page at www.fico.com/en/product-training or email
producteducation@fico.com.

Product documentation
FICO continually looks for new ways to improve and enhance the value of the products and services weprovide. If you have comments or suggestions regarding how we can improve this documentation, let us
know by sending your suggestions to techpubs@fico.com.
Please include your contact information (name, company, email address, and optionally, your phone
number) so we may reach you if we have questions.

Fair Isaac Corporation Proprietary Information

906

Contacting FICO

Sales and maintenanceIf you need information on other Xpress Optimization products, or you need to discuss maintenancecontracts or other sales-related items, contact FICO by:■

Phone: +1 (408) 535-1500 or +44 207 940 8718

■ Web: www.fico.com/optimization and use the available contact forms

Related services
Strategy Consulting: Included in your contract with FICO may be a specified amount of consulting time toassist you in using FICO Optimization Modeler to meet your business needs. Additional consulting time
can be arranged by contract.
Conferences and Seminars: FICO offers conferences and seminars on our products and services. For
announcements concerning these events, go to www.fico.com or contact your FICO accountrepresentative.

FICO Community
The FICO Community is a great resource to find the experts and information you need to collaborate,
support your business, and solve common business challenges. You can get informal technical support,
build relationships with local and remote professionals, and improve your business practices. For
additional information, visit the FICO Community (community.fico.com/welcome).

About FICO
FICO (NYSE:FICO) powers decisions that help people and businesses around the world prosper. Founded
in 1956 and based in Silicon Valley, the company is a pioneer in the use of predictive analytics and data
science to improve operational decisions. FICO holds more than 165 US and foreign patents ontechnologies that increase profitability, customer satisfaction, and growth for businesses in financial
services, telecommunications, health care, retail, and many other industries. Using FICO solutions,businesses in more than 100 countries do everything from protecting 2.6 billion payment cards fromfraud, to helping people get credit, to ensuring that millions of airplanes and rental cars are in the rightplace at the right time. Learn more at www.fico.com.

Fair Isaac Corporation Proprietary Information

907

IndexSymbols!, 15!), 15!@, 56(!, 15(!@, 56⁎, 33, 34+, 34, 35+, 16, 33, 34+=, 38,, 16-, 34, 35-, 16, 33, 34-=, 38->, 37., 638.., 34, 638..., 48/, 33//, 638::, 39:=, 38;, 16;, 16, 37=, 35=, 35, 36@, 56_, 15, 68_c, 68
Numbers
1, 7182, 7183, 7184, 7185, 7186, 718
7, 7188, 7189, 718
10, 718
11, 718
12, 718
13, 718
14, 718
15, 718
16, 718
17, 718
18, 719
20, 719
21, 719
22, 719

Fair Isaac Corporation Proprietary Information

23, 719
24, 71925, 719
26, 71927, 71928, 719A
abs, 72, 322, 639
absolute value, 72, 322
access mode, 545
activity, 111
robust constraint, 421, 424
addarray of cuts, 815, 817
cut, 815, 816
image, 470, 476, 477
addcut, 816
addcuts, 817
addmipsol, 728
addmonths, 518
addmultistart, 700
addnode, 643
aggregate operator, 32
alias, 39, 252, 257
define, 252, 259
delete, 252, 255
list, 252, 258
and, 16, 32, 35, 721
annotated identifiers, 395, 402
annotation, 55
category, 55
current category, 56
documentation, 63, 67
global, 57
multi-line, 56
name, 56
predefined categories, 56
property, 57
annual discount, 188, 189
anonymous constraint, 40
any, 26
appendfile, 107
arccos, 322
arcsin, 322
arctan, 73, 322
argc, 184
argument
number of, 183, 184
argument value, 183, 185
arguments, 47908

Indexargv, 185
arithmetic expression, 33
array, 24
automatic, 37
compare, 35
create a cell, 85
declaration, 24
delete a cell, 93
dereference, 28
get value, 395, 404
in/output, 188, 190
array, 16, 32, 37
as, 16
asproc, 74
assert, 75
assign R object, 855, 865, 866
assignment, 37
additive, 38
constraints, 38
subtractive, 38
asymmetric ciphers, 436
asynchronous HTTP request, 202
attributedelete, 641, 646
get first, 641, 653
get value, 641, 648
set value, 642, 676
test existence, 642, 649
attribute, 638
autofinal, 125, 168
axis specifier, 637, 638
B
base64, 464
basic type, 22basis
load, 726, 768
read, 726, 776
reset, 726, 783
save, 726, 786
status, 725, 726, 740, 792
write, 727, 809
basis, 720
basis stability, 724, 729
basisstability, 729
BCONDITION, 6
best bound, 722
BIM, 1, 3
documentation enabled, 63
encryption, 3
signed, 3bimprefix, 125, 168bin, 60
bitflip, 76
bitneg, 77
bitset, 78
bitshift, 79
bittest, 80
bitval, 81
bitwiseFair Isaac Corporation Proprietary Information

body

and, 80
not, 77or, 78shift, 79value, 81
xor, 76model, 17boolean, 16, 22, 31, 639
Boolean expression, 35
BREAK, 6
break, 16, 46
BREAKPOINTS, 7
BREAKSUB, 7
buffer size, 340, 359
ByteBuffer, 245
C
calcsolinfo, 730
call Python function, 831, 833
call Python object, 831, 833
callback, 699, 707, 726, 793
callfunc, 396
callfunclsa, 396
callproc, 397
callproclsa, 397
canceltimer, 288
cardinality, 422
cascading, 710
case, 16, 44
case-insensitive, 6case-sensitive, 16
casting, 31
cb, 60
CDATA, 636
cdata, 638
ceil, 82, 322
ceiling, 639
certificate
client, 438
server, 439
certificate file, 438
character encoding, 60, 641, 642, 650, 677
chgdeltatype, 701
child, 638
child model, 289
cipher algortihm, 436
classevent, 287
clear error
R, 855, 870
clearaliases, 255
clearinitvals, 324
clearmipdir, 731
clearmodcut, 732
clearqexpstat, 392
client certificate, 438
client private key, 439
clone, 265
close

909

Indexfile, 61, 101
stream, 101
coefficient, 112set, 162
color, 486
column order, 721, 722
command
Optimizer, 733
system, 517, 612
command, 733
command line interpreter, 1commands
shortening, 10comment, 8, 15, 42, 636
sign, 109skip, 109
comment, 638
commentary
multi-line, 15communication interface, 387, 624
comparator, 35
compare, 83
compareic, 519
comparison tolerance, 35, 168
compilemodel, 3compile, 262
compiled, 17compiler annotations, 56
compiler directives, 17
compiler library, 1
compiler options, 19
concatenation, 34
list, 35
condition, 33
configuration directory, 437
path, 441
configuration file, 316
connect, 342, 344, 362, 366
connect, 253connection
number, 340, 360
connection template, 249
connector, 28
conntmpl, 249
constant, 26
compile time, 27
definition, 26
run time, 27
constant, 16, 23
constants, 71
constraint, 22
activity, 111
anonymous, 40
coefficient, 112, 113
dual, 114
hide, 163
name, 40, 166
ranging information, 725, 755
right hand side, 36

Fair Isaac Corporation Proprietary Information

sensitivity ranges, 725, 757
set coefficient, 162
set of variables, 138
set type, 171
slack, 131
test hidden, 143
type, 36, 136, 421, 429
contains, 639
context, 387, 624
problem, 50
context node, 637
CONTINUE, 7
control parameter, 20
documentation, 67
get, 124, 515, 541
local set, 148
Mosel instance, 884
restore, 159set, 167, 517, 598
convergence tolerance, 695
conversion
basic type, 31
copy
file, 515, 526
copynode, 645
copysoltoinit, 325, 734
copytext, 520
cos, 84, 322
count, 16, 32
counter, 16
coverage, 5createdirectory, 516, 570, 571
create, 25, 26, 85
cross recursion, 49
crossoverlpsol, 735
crypt, 464
csrc, 186
csv, 434
CT_BIN, 136, 171
CT_CARD, 429
CT_CONT, 136, 171
CT_EQ, 136, 171, 330, 333, 429, 431
CT_FREE, 136, 171
CT_GEQ, 136, 171, 330, 333, 429, 431
CT_INT, 136, 171
CT_LEQ, 136, 171, 330, 333, 429, 431
CT_PINT, 136, 171
CT_RNG, 136
CT_SCEN, 429
CT_SEC, 136, 171
CT_SINT, 136, 171
CT_SOS1, 136, 171
CT_SOS2, 136, 171
CT_UNB, 136, 171, 330, 333, 429, 431
currentdate, 86
currenttime, 87
cut
add, 815, 816
add array, 815, 817

910

Indexdelete, 815, 818
drop, 815, 819
get active, 815, 820
list from cut pool, 815, 821
load, 822
store, 815, 823
store array, 815, 824
cutelt, 88
cutfirst, 89
cuthead, 90
cutlast, 91
cuttail, 92
cuttext, 521
D
DATA, 636
data
initialization, 40
input, 188, 190
local, 47
output, 188, 190
read, 157
save, 42
sharing, 248
data, 638
data frame, 855, 866
databaseconnect, 342, 344, 362, 366
disconnect, 363, 369
logoff, 342, 345
transaction, 362, 363, 365, 379
datablock, 94
date, 86
date, 509
datefmt, 511
datetime, 510
datetimefmt, 512
debug mode
OCI, 340
ODBC, 360
debugger, 6
declaration, 17, 21
forward, 49
implicit, 39
list, 23
record, 25
set, 23
union, 26
declarations, 16, 21
declarative, 17
decrypt
private key, 442, 449
public key, 442, 448
defaultnode, 249
defdelayedrows, 736
deflate, 873
defsecurevecs, 737
delattr, 646
delayed rows, 725, 736
delcell, 93

Fair Isaac Corporation Proprietary Informationdelcookies, 204delcuts, 818
DELETE, 7
deletecut, 815, 818
directives, 724, 731
directory, 517, 593
file, 515, 527
model cuts, 724, 732
delnode, 647
delta variable, 699, 701deltext, 522
dense, 341, 361
dependency
module, 387, 624
service, 387, 624
deploy executable, 62
deploy.dso, 183
descendant, 638
descendant-or-self, 638
detach, 264
determining row, 699, 710
difference, 35
list, 35
set, 34
string, 34
digital signature, see electronic signature, seeelectronic signature
directive, 726, 801delete, 724, 731
directives
read, 726, 777
write, 727, 810
directory, 515, 535
access mode, 545
create, 516, 570, 571
delete, 517, 593
new, 516, 570, 571
remove, 517, 593
status, 545
disc, 189
disconnect, 342, 345, 363, 369
disconnect, 254
diskdata, 190, 192
DISPLAY, 7
display
info, 7model, 7
models, 8
div, 16, 33
division
integral, 33
remainder, 33
do, 16doc, 56, 63
doc.annot, 67
doc.cparam, 67
documentation
enable, 63
target location, 65

911Indexdocumentation annotations, 63
DOWN, 7draw
arrow, 470, 473
ellipse, 470, 474, 475
line, 470, 478, 481
pie, 479
point, 480
polyline, 470, 478, 481
rectangle, 470, 482
text, 470, 483, 484
dropcut, 815, 819
dropcuts, 819
dropnextevent, 299
DSO, 8dual value, 114
dumpcallstack, 95
dynamic, 16, 24
dynamic arrayof variables, 25
dynamic shared object
version, 8
Dynamic Shared Objects manager, 1dynonly, 19EE-1, 891
E-100, 893
E-1000, 902
E-1001, 902
E-1002, 902
E-1003, 902
E-1004, 902
E-1005, 903
E-1006, 903
E-1009, 903
E-101, 893
E-1010, 903
E-1011, 903
E-1013, 903
E-1014, 903
E-1015, 903
E-1016, 903
E-1017, 904
E-1018, 904
E-102, 894
E-103, 894
E-104, 894
E-106, 894
E-107, 894
E-108, 894
E-109, 894
E-1100, 904
E-1103, 904
E-111, 894
E-112, 894
E-113, 895
E-114, 895
E-115, 895

Fair Isaac Corporation Proprietary Information

E-118, 895
E-122, 895
E-123, 895
E-124, 895
E-125, 895
E-126, 896
E-127, 896
E-128, 896
E-129, 896
E-130, 896
E-132, 896
E-147, 896
E-148, 896
E-149, 897
E-150, 897
E-151, 897
E-153, 897
E-154, 897
E-155, 897
E-156, 897
E-157, 897
E-159, 898
E-160, 898
E-161, 898
E-162, 898
E-163, 898
E-165, 898
E-167, 899
E-168, 899
E-169, 899
E-170, 899
E-171, 899
E-172, 899
E-173, 900
E-175, 900
E-176, 900
E-177, 900
E-2, 891
E-202, 900
E-207, 900
E-208, 900
E-209, 900
E-21, 891
E-210, 900
E-211, 900
E-212, 900
E-213, 900
E-214, 900
E-215, 900
E-217, 900
E-218, 900
E-22, 891
E-23, 891
E-24, 891
E-25, 891
E-26, 892
E-27, 892
E-28, 892
E-29, 892
E-30, 901

912

IndexE-302, 901
E-303, 901
E-307, 901
E-308, 901
E-31, 902
E-32, 902
E-320, 901
E-321, 901
E-322, 901
E-323, 901
E-33, 902
E-34, 892
E-35, 892
E-350, 904
E-351, 905
E-352, 905
E-353, 905
E-354, 905
E-355, 905
E-358, 905
E-359, 905
E-36, 892
E-360, 905
E-361, 905
E-362, 905
E-37, 893
E-38, 893
E-39, 893
E-4, 891
E-40, 893
E-51, 902
E-52, 902
E-72, 902
E-80, 904
E-82, 904
E-83, 904
E-84, 904
E-88, 904
E-90, 904
E-91, 904
E-92, 904
E-93, 904
electronic signature, 436
create, 442, 454
verify, 442, 455
element node, 636
elementary type, 22
elif, 16, 44
else, 16, 44
enc:, 60
encoding, 60
encrypt
private key, 442, 450
public key, 442, 451
encryption
BIM, 3encryption key, 436
end, 16
end-case, 44
end-declarations, 21

Fair Isaac Corporation Proprietary Information

end-function, 48
end-if, 44
end-model, 17
end-package, 17
end-procedure, 48
endswith, 523
enumerate
quadratic terms, 393
environment
current, 316
process, 316
environment variable, 543, 599
MOSEL_BIM, 18, 315
MOSEL_DSO, 18, 315
MOSEL_EXECPATH, 315, 612
MOSEL_RESTR, 11, 316
MOSEL_ROPATH, 11, 315
MOSEL_RWPATH, 11, 315
MOSEL_SDMAX, 2
MOSEL_SSL, 441
MOSEL_TMP, 61, 315
eof, 141
EP_HEX, 99, 385
EP_MAX, 99, 385
EP_MIN, 99, 385
EP_MPS, 99, 385
EP_STRIP, 99, 385
EPROP_CONST, 417
EPROP_DENSE, 417
EPROP_DYNAMIC, 417
EPROP_GENSET, 417
EPROP_HASHMAP, 417
EPROP_PRIV, 417
EPROP_PUBLIC, 417
EPROP_RANGE, 417
EPROP_SPARSE, 417
EPROP_VAR, 417
erase, 524
error
detection, 17
ODBC, 357
error code
R, 855, 868
error control
IO, 107, 125, 168
Maths, 168error message
R, 855, 869
error stream, 101, 107, 108
escape sequence, 33
escape sequences, 34estimatemarginals, 738
ETC_APPEND, 190
ETC_AUTONDX, 190
ETC_CSV, 190
ETC_DATAFRAME, 190
ETC_DENSE, 190
ETC_EMPTYNDX, 190
ETC_IN, 190
ETC_NOQ, 190

913

IndexETC_NOZEROS, 190
ETC_OUT, 190
ETC_SGLQ, 190
ETC_SKIPH, 190
ETC_SPARSE, 190
ETC_TRANS, 190
evaluate Python expression, 831, 836
evaluate R script, 855, 867
evaluate R statement, 855, 856
evaluation, 16even number, 146
Event, 287
eventclass, 287, 305
drop next, 287, 299
get next, 287, 298
null, 287, 301
peek next, 287, 308
queue, 287, 300
send, 287, 289
sender group ID, 287, 303
sender ID, 287, 302
sender user ID, 287, 304
value, 287, 307
wait for, 287, 293
event class, 287
wait for, 287, 295
event queue, 247
event value, 287
EVENT_END, 272
EVENT_HTTPEND, 202
EVENT_HTTPNEW, 234, 239
EVENT_TIMER, 290
excel, 433
exe, 186
execution environment, 313, 316
exists, 96
exit, 97
exit code
model, 261, 281
exp, 98, 322
expandpath, 525
explterm, 16, 19
exponential function, 98, 322
exportproblem, 99
quadratic problem, 384, 385
EXPORTPROB, 7
exportprob, 99, 385
expression, 28
linear constraint, 36
list, 34
print, 110, 181
set, 34
set type, 171, 323, 333, 421, 431
string, 33
terminator, 16
type, 29
extended syntax, 358, 360

Fair Isaac Corporation Proprietary Information

FF, 702
F_APPEND, 107
F_BINARY, 107
F_ERROR, 101, 107, 117, 120
F_INPUT, 101, 107, 117, 120
F_LINBUF, 107
F_OUTPUT, 101, 107, 117, 120
F_SILENT, 107
F_TEXT, 107
failure, 342, 362
false, 16, 22, 639
fclose, 61, 101
fcopy, 526
fctasproc, 19
fdelete, 527
fflush, 61, 102
fileaccess mode, 545
append, 107close, 101
compressed, 873
copy, 515, 526
delete, 515, 527
ID, 117
in/output, 188, 190
inclusion, 20, 94
initialization, 41
IO, 61
move, 515, 530
name, 120
open, 107
read, 61, 157
rename, 515, 530
select, 108
size, 544
status, 545
time, 546
write, 110, 181
file extension, 3
file name prefix
file inclusion, 3
files
BIM, 17
finalizeset, 103
finalize, 24, 103
findidentifier, 395, 398
findcookie, 205
findfiles, 528
findfirst, 104
findident, 398
findlast, 105
findtext, 529
findxsrvs, 260
FINISH, 7
fix
variable, 739
fixglobal, 739

914

Indexfloor, 106, 322, 639
flush buffer, 102
fmax, 322
fmin, 322
fmove, 530
following, 638
fopen, 61, 107
forall, 16, 45
format string, 176
formattext, 531
forward, 16, 49
free
info table, 389, 392
from, 16
fselect, 61, 108
fskipline, 61, 107, 109
fsrvdelay, 251
fsrvnbiter, 251
fsrvport, 250
functioncall, 395, 396
return value, 47
type, 47
function, 16function call, 29
fwrite, 110
fwrite_, 68
fwriteln, 110
fwriteln_, 68
GgenerateUFparallel, 704
get
active cuts, 815, 820
cuts from cut pool, 815, 821
get pandas DataFrame, 831, 837
get Python variable, 831, 836, 845
get R array, 855, 858
get R boolean, 855, 859
get R integer, 855, 860
get R real, 855, 861
get R string, 855, 862
getact, 111, 424
getaliases, 258
getallidents, 400
getallparams, 401
getannidents, 285, 402
getannotations, 286, 403
getarrval, 404
getasnumber, 533
getattr, 648
getbanner, 256
getboolattr, 641, 648
getboolvalue, 642, 652
getbstat, 740
getchar, 534
getclass, 305
getcnlist, 820
getcode, 405
getcoeff, 112

Fair Isaac Corporation Proprietary Information

getcoeffs, 113
getcomputeallowed, 741
getcplist, 821
getcsttxtbuf, 632
getcwd, 535
getdate, 536, 628
getdatetime, 630
getday, 537
getdaynum, 538
getdays, 539
getdirsep, 540
getdsoparam, 541
getdsoprop, 273
getdsopropnum, 273
getdual, 114
getdualray, 742
getelt, 115
geteltype, 116, 406
getencoding, 650
getendparse, 542
getenv, 543
getexitcode, 281
getfid, 61, 117
getfirst, 118
getfirstattr, 653
getfirstchild, 655
getflstat, 545
getfname, 120
getfromgid, 303
getfromid, 302
getfromuid, 304
getfsize, 544
getfstat, 545
getftime, 546
getgid, 274
gethead, 119
gethostalias, 257
gethour, 547
gethspace, 663
getid, 275
getiis, 743
getiissense, 744
getiistype, 745
getindentmode, 665
getindentskip, 666
getindices, 407
getinfcause, 746
getinfeas, 747
getintattr, 641, 648
getintvalue, 642, 652
getlast, 121
getlastchild, 656
getlb, 748
getlinelen, 667
getloadedlinctrs, 749
getloadedmpvars, 750
getmatcoeff, 751
getmaxnodes, 668
getminute, 548
getmodprop, 276

915

Indexgetmodpropnum, 276
getmonth, 549
getmsec, 550
getmsg, 408
getname, 651, 752
getnbargs, 409
getnbdim, 122getnext, 654
getnextevent, 298
getnode, 277, 657
getnodes, 658
getnominal, 428
getobjval, 123
getoserrmsg, 552
getoserror, 551
getparam, 107, 124, 339, 358, 437, 510, 721, 754
getparent, 659
getpathsep, 553
getprimalray, 753
getprobstat, 754
getqexpnextterm, 393
getqexpsol, 390
getqexpstat, 391
getqtype, 555
getrange, 755
getrcost, 127
getreadcnt, 128
getrealattr, 641, 648
getrealvalue, 642, 652
getrettype, 410
getreverse, 129
getrmtid, 278
getscale, 756
getsecond, 556
getsensrng, 757
getsepchar, 557
getsignature, 411
getsize, 130, 558, 639, 669, 758
getslack, 131
getsol, 132, 327, 386, 390, 423, 759
getstandalone, 661
getstart, 559
getstatus, 279, 412
getstrattr, 641, 648
getstruct, 133
getstrvalue, 642, 652
getsucc, 554
getsysinfo, 560
getsysstat, 561
gettail, 135
gettime, 562, 626
gettimer, 306
gettmpdir, 563
gettrim, 564
gettxtbuf, 634
gettxtsize, 633
gettype, 136, 330, 429, 660
gettypeid, 137
getub, 761
getuid, 280

Fair Isaac Corporation Proprietary Information

getvalue, 307, 652
getvar, 760
getvars, 138, 762
getvspace, 664
getweekday, 565
getxmlversion, 662
getyear, 566
GID
event sender, 287, 303
model, 261, 274, 287, 292
wait for, 287, 295
graph, 466
graphical interface, 2gzip, 873
H
hasfeature, 763
hashmap, 16, 24
hex, 464
hidden constraint, 143, 163, 322, 323, 328, 329
robust constraint, 421, 425, 427
hmac, 465
horizontal spacing, 641, 642, 663, 681
host alias, see alias, see alias
http driver, 244
HTTP request
asynchronous mode, 202delete, 203, 207get, 203, 208
head, 203, 210
patch, 203, 211
post, 203, 212
put, 203, 213
status code, 203, 214
synchronous mode, 202
HTTP server, 194
start, 222, 239
stop, 222, 240
HTTP_ACCEPTED, 201
http_async, 195
HTTP_BAD_REQUEST, 201
http_browser, 195
http_cookies, 196
HTTP_CREATED, 201
http_defpage, 196
http_defport, 196
http_expire, 196
HTTP_FORBIDDEN, 201
http_freeasync, 197
http_keephdr, 197
http_listen, 197
http_maxasync, 199
http_maxconn, 197
http_maxcontime, 198
http_maxreq, 198
http_maxreqtime, 198
HTTP_METHOD_NOT_ALLOWED, 201
HTTP_NO_CONTENT, 201
HTTP_NOT_ACCEPTABLE, 201
HTTP_NOT_FOUND, 201916

IndexHTTP_OK, 201
HTTP_PAYMENT_REQUIRED, 201
http_port, 199
http_proxy, 199
HTTP_PROXY_AUTHENTICATION_REQUIRED, 201
http_proxyport, 199
HTTP_REQUEST_TIMEOUT, 201
HTTP_RESET_CONTENT, 201
http_srvconfig, 200
http_startwb, 200
HTTP_UNAUTHORIZED, 201
HTTP_SKIP_EMPTYCOL, 242
HTTP_SKIP_EMPTYUNION, 242
httpcancel, 206
httpdel, 207
httpget, 208
httpgetheader, 209
httphead, 210
httppatch, 211
httppending, 223
httppost, 212
httpput, 213
httpqueueinfo, 224
httpreason, 214
httpreply, 225
httpreplycode, 226
httpreplyjson, 227
httpreqconstat, 228
httpreqcookies, 229
httpreqfile, 230
httpreqfrom, 231
httpreqheader, 232
httpreqlabel, 233
httpreqpop, 234
httpreqpush, 235
httpreqpushlim, 236
httpreqstat, 237
httpreqtype, 238
https_cacerts, 438
https_ciphers, 438
https_cltcrt, 438
https_cltkey, 439
https_defport, 200
https_listen, 201
https_port, 201
https_srvcrt, 439
https_srvkey, 439
https_trustsrv, 440
httpstartsrv, 239
httpstopsrv, 240
I
I/O driver, 59
bin:, 60
cb:, 60
default, 59
deploy.csrc:, 62, 186
deploy.exe:, 62, 186
mem:, 59mmetc.diskdata:, 192

Fair Isaac Corporation Proprietary Information

ID

mmhttp.url:, 244
mmjava.java:, 245
mmjava.jraw:, 246
mmjobs.mempipe:, 311
mmjobs.rcmd:, 312
mmjobs.rmt:, 313
mmjobs.shmem:, 311
mmjobs.xsrv:, 312
mmjobs.xssh:, 312
mmoci.oci:, 352
mmodbc.odbc:, 382
mmsheet.csv:, 434
mmsheet.excel:, 433
mmsheet.xls:, 434
mmsheet.xlsx:, 434
mmssl.base64:, 464
mmssl.crypt:, 464
mmssl.hex:, 464
mmssl.hmac:, 465
mmsystem.pipe:, 623
mmsystem.text:, 623
null:, 59
python3.python:, 845
r.rws:, 871
raw:, 60
sysfd:, 60
tee:, 60
tmp:, 59
zlib.deflate:, 873
zlib.gzip:, 873
zlib.zip:, 873

event sender, 287, 302
file, 117
model, 261, 275
stream, 117
identifier, 15
find, 395, 398
if, 16, 29, 43
IIS, see irreducible infeasible set, see irreducible
infeasible set, see irreducible infeasible set
reset search, 726, 784
IMCI, 387, 624
implies, 764
imports, 16, 17
in, 16, 35
include, 16, 20
indent mode, 641, 642, 665, 684
indent skip, 641, 642, 666, 685
indexing set, 24
indicator, 765
indicator constraint, 721, 725, 765
INFINITY, 142, 144, 165
INFINITY, 71
INFO, 7
info
quadratic expression, 389, 391
initial step bound, 699, 712
initial value, 320
copy solution, 322, 325, 725, 734

917

Indexdelete, 322, 324
set, 323, 326
initialisation vector, 464
size, 456
initialisations, 16
initializations, 16
initialize pandas interface, 832, 840
initialize Python, 831, 839
initialize R, 855, 863
inititer, 413
inline initialization, 39
input file, 188, 190
input stream, 101, 107, 108, 245, 261, 267
read, 157
test eof, 141
InputStream, 245
inserttext, 567
instancebanner, 252, 256
connect, 252, 253
disconnect, 252, 254
instance control parameter, 884
integerread, 342, 347, 363, 376
integer, 16, 22, 31
integrality check, 767
inter, 16, 32, 34
inter-module communication, 387, 624
interfaceinter-module communication, 387, 624
interpreted, 17intersection, 34
IO
error, 107, 125, 168
status, 107, 125
switching between streams, 61
IO driver, see I/O driver
ioctrl, 107, 125, 168
iostatus, 107, 125
irreducible infeasible set, 725, 726, 743, 766
is, 16, 35
is_binary, 16, 36
is_continuous, 16, 36
is_free, 16, 36
is_integer, 16, 36
is_partint, 16, 36
is_semcont, 16, 36
is_semint, 16, 36
is_sos1, 16, 36
is_sos2, 16, 36
isdefined, 139
isdynamic, 140
iseof, 141
isfinite, 142
ishidden, 143, 328, 425
isiisvalid, 766
isinf, 144
isintegral, 767
isnan, 145
isodd, 146

Fair Isaac Corporation Proprietary Information

isqueueempty, 300
isvalid, 568
item
number read, 125
ITER_BOUND, 413
ITER_DONE, 414
ITER_READY, 414, 416
ITER_BOUND, 412
ITER_DONE, 412
ITER_FREE, 412
ITER_READY, 412
iterator, 32
index tuple, 395, 407
initialise, 395, 413
next, 395, 414
set indices, 395, 416
status, 395, 412
iterator, 394
JJava

IO drivers, 245
java, 245
jobid, 250
jointext, 569
jraw, 245
JSON_FCT_BOOL, 671
JSON_FCT_CLOSE_ARR, 671
JSON_FCT_CLOSE_OBJ, 671
JSON_FCT_NULL, 671
JSON_FCT_NUM, 671
JSON_FCT_OPEN_ARR, 671
JSON_FCT_OPEN_OBJ, 671
JSON_FCT_TEXT, 671
jsonload, 670
jsonparse, 671
jsonread, 241jsonsave, 673
jsonwrite, 242
K
keepalive, 250
keepassert, 19, 75
key, 464
key derivation, 464
key size, 442, 457
keyword
SQL, 357
keywords, 10, 16
Llang, 125
language, 15
largest value, 151
legend, 466
lengthstring, 340, 359
library
Run Time, 1
linctr, 16, 22, 320, 322, 383, 384, 387, 419

918

Indexline breaking, 16line control directive, 21
line length, 641, 642, 667, 686
lines
number affected, 339, 341, 358, 361
number transferred, 339, 341, 358, 361
LIST, 7
list, 23compare, 35
constant, 34
finalize, 103
find element, 104, 105
first element, 89, 118
head, 119
last element, 91, 121remove elements, 90, 92
reverse, 129, 160
size, 130
split, 173, 174
tail, 135
list, 16, 34
ln, 147, 322
load
basis, 726, 768
cut, 822
module, 17
package, 17, 18
problem, 726, 772
load, 265, 674
load document, 642, 670, 674
loadbasis, 768
loadcookies, 215
loadcuts, 822
loadlpsol, 769
loadmipsol, 770
loadprob, 383, 772
localedir, 125, 168
localsetparam, 148
location step, 637
log, 149, 322
logarithm
base 10, 149, 322
natural, 147, 322
logctr, 721, 765
logical and, 35
logical expression, 721
exclusive or, 727, 813
implication, 725, 764
logical negation, 36
logical or, 35
loop, 45loop statement, 37
lower bound, 725, 748
set, 726, 799
LP format, 7
maximization, 99
minimization, 99
LP solutionload, 726, 769
save, 726, 788

Fair Isaac Corporation Proprietary Information

LP status, 721
LSATTR, 7
LSLIBS, 8
LSMODS, 8
M
M_E, 71
M_PI, 71
makedir, 570
makepath, 571
makesos1, 36, 150
makesos2, 36, 150
marginal values, 725, 738
mathctrl, 168
Mathserror, 168
matrixcolumn order, 721, 722
matrix output, 7max, 16, 32, 33
MAX_INT, 71
MAX_REAL, 71
maximize, 383, 773
maximum value, 33, 151
maxlist, 151
mc, 56
mc.def, 57
mc.flush, 57
mc.set, 58
mem, 59
memory pipe, 311
memory usage, 152, 261, 276, 727, 814
memoryuse, 152
mempipe, 311
message catalog, 68, 70
message digest, 437, 440, 442, 453
size, 442, 458
message domain, 69
message printing, 339, 342, 358, 362
Optimizer, 722, 724
message translation, 68
min, 16, 32, 33
minimize, 383, 773
minimum value, 33, 153
minlist, 153
MIP solution
add, 724, 728
load, 726, 770
save, 726, 787
mksetcookie, 243
mmetc.dso, 188
mmhttp.dso, 194
mmjobs.dso, 247
mmnl.dso, 320
mmoci.dso, 334
mmodbc.dso, 353
mmquad.dso, 383
mmreflect.dso, 394
mmrobust.dso, 418
mmsheet.dso, 432

919

Indexmmssl
configuration directory, 437
mmssl.dso, 436
MMSVGDISPLAY, 469
MMSVGTGZ, 470
mmsystem.dso, 509
mmxml.dso, 636
mmxnlp.dso, 694
mmxprs.dso, 720
mod, 16, 33
MODEL, 8
Model, 261
model
active, 8body, 17
clone, 265
compile, 261, 262
coverage, 5debug, 6
exit code, 261, 281
GID, 261, 274, 287, 292
handling multiple, 247
ID, 261, 275load, 261, 265
memory usage, 152, 261, 276
name, 8pause execution, 495
profile, 4properties, 261, 276
reset, 261, 283
run, 3, 261, 272
sequence number, 8
size, 8source, 1
status, 261, 279
stop, 261, 282
structure, 17
trace, 10
UID, 261, 280, 287, 291
unload, 261, 284
version, 8
web service, 194
model, 8, 16, 17
model cut, 726, 802
delete, 724, 732
model management, 261
model manager, 1
model parameter, 20
model_version, 125
modelname, 125
module, 1
dependency, 387, 624
memory usage, 152
module structureadvantages, 2
modules, 15monthnames, 512
Mosel, 252
mosel, 1
debugger, 6

Fair Isaac Corporation Proprietary Information

invocation, 2
restricted mode, 11
Mosel compiler, 1
Mosel Console, 1
Mosel instance, see instance, 560
Mosel Remote Launcher, 313
MOSEL_BIM, 18, 315
MOSEL_DSO, 18, 315
MOSEL_EXECPATH, 315, 612
MOSEL_RESTR, 11, 316
MOSEL_ROPATH, 11, 315
MOSEL_RWPATH, 11, 315
MOSEL_SDMAX, 2
MOSEL_SSL, 441
MOSEL_TMP, 61, 315
moseldoc, 67
movefile, 515, 530
MP type, 22
mpproblem, 50
MPS format, 7, 99
mpsol
reset, 726, 785
mpsol, 720
mpvar, 16, 22, 320, 383, 387
msgdigest, 453
msgsign, 454
msgverify, 455
multiple models, 247
multiple problems, 50
multistart job, 698, 700
N
namescramble, 99, 385
variable, 752
name, 639
names
loading, 722, 723
namespace, 16
NAN, 142, 145, 165
NAN, 71
nbread, 125, 157
new line, 33
newmuid, 154
newtar, 572
newzip, 573
NEXT, 8
next, 16, 46
nextcell, 414
nextfield, 574
nlctr, 320, 322
noautofinal, 19
NoDB, 11node, 641, 657, 658
add, 641, 643
copy, 641, 645
delete, 641, 647
get first child, 641, 655
get last child, 641, 656

920

Indexget name, 641, 651
get next, 641, 654
get parent, 642, 659
get type, 642, 660
get value, 642, 652
set name, 642, 679
set value, 642, 680
node, 638
node test, 637, 638
nodenumber, 249
NoExec, 11
noimplicit, 19, 39
nominal value, 421, 428, 430
non-relational, 341, 361
nonlinearcomplementary variables, 699, 708
feasibility, 699, 717
memory usage, 699, 705
scaling, 699, 706
tolerance, 699, 713
nonlinear constraint
enforced, 699, 711
hide, 323, 329
name, 323, 332
set type, 323, 333
solution, 322, 327
test hidden, 322, 328
type, 322, 330
NoRead, 11
not, 16, 36, 639, 721
not in, 35
NoTmp, 11
NoWrite, 11
nsgroup, 16
nssearch, 16
null, 59
nullevent, 301
numberconnection, 340, 360
lines, 339, 341, 358, 361
number, 639
NumPy conversion, 831
Oobject group, 466
objective value, 123
OCI
debug mode, 340
IO driver, 352
oci, 352
OCIautocommit, 339
OCIautondx, 339
OCIbufsize, 340
OCIcolsize, 340
OCIcommit, 350
OCIconnection, 340, 344
OCIdebug, 340
OCIexecute, 346
OCIfirstndx, 341
OCIlogoff, 345

Fair Isaac Corporation Proprietary Information

OCIlogon, 344
OCIndxcol, 341
OCIreadinteger, 347
OCIreadreal, 348
OCIreadstring, 349
OCIrollback, 351
OCIrowcnt, 341
OCIrowxfr, 341
OCIsuccess, 342
OCItruncsize, 342
OCIverbose, 342
ODBC
debug mode, 360
odd number, 146of, 16
open
file, 107
stream, 107
openpipe, 575
operation
elementary, 37
operator, 28
arithmetic, 33
ealuation order, 29
optimization
direction, 7
Optimizer
loading names, 722, 723
message printing, 722, 724
problem name, 724
problem pointer, 724
version number, 723
optimizer problem status, 725, 754
OPTION, 8
options, 16, 17
or, 16, 32, 35, 721
output file, 188, 190
output stream, 101, 107, 108, 245, 261, 267
flush, 102
write, 110, 181
OutputStream, 245
P
package, 53
annotation declaration, 58
structure, 17
package, 16, 17
pandas conversion, 831
parameter, 20, 124, 148, 159, 167, 515, 517, 541, 598
parameters, 17parameters, 16parent, 638
parent model, 289
parentnumber, 250
parseextn, 576
parseint, 577
parser context, 510
parser parameter, 125parser_date, 125parser_file, 125921

Indexparser_line, 125parser_time, 125parser_UTCdate, 125parser_UTCtime, 125parser_version, 125parsereal, 579
parsetext, 580
passphrase, 436
pastetext, 582
pathmatch, 583
pathsplit, 584
pause
model execution, 495
peeknextevent, 308
PEM format, 436
piecewise linear segment, 331
pipeflush, 309
pipenotify, 310
plot
add, 470, 472
PO, see Portable Object
Portable Object, 69
Portable Object Template, 69
position, 639
postsolve, 775
POT, see Portable Object Template
predicate, 637, 638
primal solution, 132
PRINT, 9print, 110, 181
problem, 99
quadratic problem, 384, 385
R, 855, 864
printing, 339, 342, 358, 362
printing format, 125, 168
printmodelmemory, 705
printmodelscaling, 706
private key, 436
private key file, 441
private symbol, 52
problem, 7
export, 99
handling multiple, 50
load, 726, 772
main, 50
maximize, 726, 773
postsolve, 726, 775
print, 99
status, 725, 754
unload, 727, 807
write, 727, 811
problem context, 50
problem name
Optimizer, 724
problem pointerOptimizer, 724
problem type, 50
extensions, 50
procedural, 17
procedure, 40

Fair Isaac Corporation Proprietary Information

body, 47
call, 395, 397
procedure, 16
procedures
passing of formal parameters, 48
variable number of parameters, 48
processing instruction, 636
processing-instruction, 638
prod, 16, 32, 33
product, 33
profiler, 4public, 16, 52
public key, 436, 437
publish, 155pwlin, 331pws, 331
pycall, 833
pycallbool, 831, 833
pycallint, 831, 833
pycallreal, 831, 833
pycallstr, 831, 833
pycalltext, 831, 833
pycallvoid, 831, 833
pyexec, 835
pyget, 836
pygetbool, 831, 836
pygetdf, 837
pygetint, 831, 836
pygetreal, 831, 836
pygetstr, 831, 836
pygettext, 831, 836
pyinit, 839
pyinitpandas, 840
pyinitverbose, 831
pyrun, 841
pyset, 842
pysetdf, 843
python3.dso, 825
pyunload, 844
pyusepandas, 831
Q
QCQP, see Quadratically Constrained Quadratic
Programming
qexp, 383, 384
qsort, 585
quadratic expression
enumerate terms, 393
get info, 389, 391
solution, 384, 386
quadratic problem
export, 384, 385
print, 384, 385
Quadratically Constrained Quadratic Programming,
321
QUIT, 9quote, 33
quote, 587
R
r.dso, 848

922

Indexrandom, 156
random data file, 442, 460
random number, 156, 169, 442, 459
range, 23
first element, 89, 118
last element, 91, 121
range, 16, 34
range set, 34
ranging information, 725, 755
raw, 60
Rcleanscript, 854
Rclearerr, 870
rcmd, 312
readbasis, 726, 776
directives, 726, 777
integer value, 342, 347, 363, 376
number of items, 125real value, 343, 348, 363, 377
string, 343, 349, 363, 378
write, 727, 809
read, 61, 107, 125, 157
readbasis, 776
readcnt, 125, 128, 168
readdirs, 777
readlink, 588
readln, 61, 107, 157
readsol, 778
readtextline, 589
realprinting format, 125, 168
read, 343, 348, 363, 377
real, 16, 22, 31, 322
realfmt, 125, 168
recloc, 125, 168
record, 25
compare, 35
dereference, 28
initialization, 31
record, 16
recursion, 47
reduced cost value, 127
reference to, 37
refinemipsol, 779
reflecterror, 394
REG_EXTENDED, 590, 592
REG_ICASE, 590, 592
REG_NEWLINE, 590, 592
REG_NOTBOL, 590, 592
REG_NOTEOL, 590, 592
REG_ONCE, 592
regmatch, 590
regreplace, 592
rejectintsol, 780
release Python, 832, 844
remote command driver, 312
remote driver, 313
remote invocation protocol, 884
remote launcher, 313
removeFair Isaac Corporation Proprietary Information

directory, 517, 593
removedir, 593
removefiles, 594
renamefile, 515, 530
repairinfeas, 781
repeat, 16, 45
reqqueue, 194
requestclient IP, 222, 231
connection status, 222, 228
data file, 222, 230
header, 222, 232
label, 222, 233
status, 222, 237
type, 222, 238
requirement, 53
requirements, 16
Rerrcode, 868
Rerrmsg, 869
reset, 158
reset, 158, 283
resetbasis, 783
resetiis, 784
resetmodpar, 268
resetsol, 785
restoreparam, 159
restrict, 125
restricted mode, 11
restrictions, 11
return, 16, 48
returned, 47
Reval, 856
reverse, 160
Rfree, 857
Rgetarr, 858
Rgetbool, 859
Rgetint, 860
Rgetreal, 861
Rgetstr, 862
Rinit, 863
Rinteractive, 854rmt, 313
robctr, 418
robust_check_feas_original_problem, 421
robust_check_feas_uncertainty_set, 420
robust_uncertain_overlap, 420
robustctr, 418, 419, 426
root node, 636
round, 161, 322, 639
rounding, 82, 106, 161, 322
Rprint, 864
RSA cryptographic system, 436
RSA key
check private, 442, 446
fingerprint, 442, 443
load, 442, 447
save, 442, 452
size, 442, 445
RSA key pair, 437, 442, 444

923

Index

RSAfingerprint, 443
RSAgenkey, 444
RSAgetkeysize, 445
RSAisprivate, 446
RSAloadkey, 447
RSAprivdecrypt, 449
RSAprivencrypt, 450
RSApubdecrypt, 448
RSApubencrypt, 451
RSAsavekey, 452
Rsessionmode, 855
Rset, 865
Rsetdf, 866
Rsource, 867
run, 272
run Python script, 832, 841
run Python script from string, 831, 835
Runloadscript, 854
running time, 516, 562
runparams, 125
Rusemosstreams, 854
Rverbose, 853
S
salt, 465
savebasis, 726, 786
Optimizer status, 726, 789
save, 675
save document, 642, 673, 675
savebasis, 786
savecookies, 216
savemipsol, 787
savesol, 788
savestate, 789
scenario, 426
secure vectors, 737
selectfile, 108
stream, 108
selection statement, 37, 43
selectsol, 790
self, 638
send, 289
sensitivity ranges, 725, 757
servertrust, 440
server certificate, 439
server private key, 439
serviceinter-module communication, 387, 624
module dependency, 387, 624
set, 23
callback, 699, 707, 726, 793
compare, 35
finalize, 103
fixed, 24
in/output, 188, 190
size, 130
set, 16, 34

Fair Isaac Corporation Proprietary Information

set pandas DataFrame, 832, 843
set Python variable, 832, 842
setarchconsistency, 791
setarrval, 415
setattr, 676
setbstat, 792
setcallback, 707, 793
setcbcutoff, 797
setchar, 595
setcoeff, 162
setcomplementary, 708
setcomputeallowed, 796
setcontrol, 269
setcookie, 217
setdate, 596, 629
setdatetime, 631
setday, 597
setdefstream, 267
setdefvar, 709
setdetrow, 710
setdsoparam, 598
setencoding, 677
setendparse, 542
setenforcedctr, 711
setenv, 599
setgid, 292
setgndata, 798
sethidden, 163, 329, 427
sethostalias, 259
sethour, 601
sethspace, 681
setindentmode, 684
setindentskip, 685
setindices, 416
setinitsb, 712
setinitval, 326
setioerr, 164
setlb, 799
setlinelen, 686
setmatcoeff, 800
setmatherr, 165
setmaxnodes, 678
setminute, 602
setmipdir, 801
setmodcut, 802
setmodpar, 270
setmonth, 603
setmsec, 604
setname, 166, 332, 679
setnominal, 430
setoserror, 600
setparam, 167, 339, 358, 437, 510, 721
setqtype, 555
setrandseed, 169
setrange, 170
setsecond, 605
setsepchar, 557
setsol, 803
setstandalone, 687
setstart, 559

924

Indexsetsucc, 554
settime, 606, 627
settimer, 290
settol, 713
settolset, 714
settrim, 564
settype, 171, 333, 431
setub, 804
setucbdata, 805
setuid, 291
setvalue, 680
setvspace, 683
setworkdir, 271
setxmlversion, 688
setyear, 607
shared, 16, 22, 248
shared memory driver, 311
sharingstatus, 125, 248
shmem, 311
sign, 322
signatureelectronic, 436
sin, 172, 322
sizearray, 130
file, 544
list, 130
set, 130skip
comment, 109
slack value, 131
sleep, 608
smallest value, 153
solution value, 132, 384, 386
nonlinear constraint, 322, 327
robust constraint, 421, 423
uncertain, 421, 423
sorting, 517, 585
SOS, 150
declaration, 36
set type, 171
type, 136
special ordered set, 150
splithead, 173
splittail, 174
splittext, 609
SQL commandexecute, 342, 346, 363, 370
update, 363, 381
SQL parameters
define, 363, 372
get value, 363, 373
SQL query
dataframe, 362, 368
SQLautocommit, 358
SQLautondx, 359
SQLbufsize, 359
SQLcolsize, 359
SQLcolumns, 364
SQLcommit, 365

Fair Isaac Corporation Proprietary Information

SQLconnect, 366
SQLconnection, 360, 367
SQLdataframe, 368
SQLdebug, 360
SQLdisconnect, 369
SQLdm, 360
SQLexecute, 370
SQLextn, 360
SQLfirstndx, 361
SQLgetparam, 373
SQLindices, 374
SQLndxcol, 361
SQLparam, 372
SQLprimarykeys, 375
SQLreadinteger, 376
SQLreadreal, 377
SQLreadstring, 378
SQLrollback, 379
SQLrowcnt, 361
SQLrowxfr, 361
SQLsuccess, 362
SQLtables, 380
SQLtruncsize, 362
SQLupdate, 381
SQLverbose, 362
sqrt, 175, 322
square root, 175, 322
sshcmd, 251
ssl_cipher, 440
ssl_digest, 440
ssl_dir, 441
ssl_privkey, 441
sslivsize, 456
sslkeysize, 457
sslmdsize, 458
sslrandom, 459
sslrandomdata, 460
stack dump, 2, 95
standalone flag, 642, 661, 687
start value, see initial value, see initial value
starts-with, 639
startswith, 610
statement, 37
separator, 37
status, 342, 362
directory, 545
file, 545
IO, 107, 125
model, 261, 279
problem, 725, 754
save, 726, 789
system, 516, 561
STEP, 9stop, 282
stopoptimize, 806
storearray of cuts, 815, 824
cut, 815, 823
storecut, 823
storecuts, 824

925

Indexstreamclose, 101
ID, 117
input, 261, 267
open, 107
output, 261, 267
select, 108
strfmt, 176
stringformatted, 176
get substring, 177
maximum length, 340, 359
read, 343, 349, 363, 378
string, 16, 22, 31, 639
string expression
compare, 35
string-length, 639
STRUCT_ARRAY, 133
STRUCT_CONST, 133
STRUCT_LIST, 133
STRUCT_NATTYPE, 133
STRUCT_PROBLEM, 133
STRUCT_RECORD, 133
STRUCT_REF, 133
STRUCT_ROUTINE, 133
STRUCT_SET, 133
STRUCT_UNION, 133
STRUCT_USRTYPE, 133
stylesheet, 470, 471, 490, 494, 502, 506
submodel, 247
subproblem, 50
subroutine, 47
number of arguments, 395, 409
return type, 395, 410
signature, 395, 411
subroutine reference, 25
subset, 35
substr, 177
success, 342, 362
suffix notation, 9, 50
sum, 16, 32, 33
summation, 33
superset, 35
SVF file format, 789
SVG, 466
SVG_BLACK, 467
SVG_BLUE, 467
SVG_BROWN, 467
SVG_COLOR, 467
SVG_CURRENT, 467
SVG_CYAN, 467
SVG_DECORATION, 467
SVG_FILL, 467
SVG_FILLOPACITY, 467
SVG_FONT, 467
SVG_FONTFAMILY, 467
SVG_FONTSIZE, 467
SVG_FONTSTYLE, 467
SVG_FONTWEIGHT, 467
SVG_GOLD, 467

Fair Isaac Corporation Proprietary Information

SVG_GRAY, 467
SVG_GREEN, 467
SVG_LIME, 467
SVG_MAGENTA, 467
SVG_NONE, 467
SVG_OPACITY, 467
SVG_ORANGE, 467
SVG_PINK, 467
SVG_PURPLE, 467
SVG_RED, 467
SVG_SILVER, 467
SVG_STROKE, 467
SVG_STROKEDASH, 467
SVG_STROKEOPACITY, 467
SVG_STROKEWIDTH, 467
SVG_TEXTANCHOR, 467
SVG_WHITE, 467
SVG_YELLOW, 467
svgaddarrow, 473
svgaddcircle, 474
svgaddellipse, 475
svgaddfile, 476
svgaddgroup, 472
svgaddimage, 477
svgaddline, 478
svgaddpie, 479
svgaddpoint, 480
svgaddpolygon, 481
svgaddrectangle, 482
svgaddtext, 483
svgaddxmltext, 484
svgclosing, 485
svgcolor, 486
svgdelobj, 487
svgerase, 488
svggetgraphstyle, 489
svggetgraphstylesheet, 490
svggetgraphviewbox, 491
svggetlastobj, 492
svggetstyle, 493
svggetstylesheet, 494
svgpause, 495
svgrefresh, 496
svgsave, 497
svgsetgraphlabels, 498
svgsetgraphpointsize, 499
svgsetgraphscale, 500
svgsetgraphstyle, 501
svgsetgraphstylesheet, 502
svgsetgraphviewbox, 503
svgsetreffreq, 504
svgsetstyle, 505
svgsetstylesheet, 506
svgshowgraphaxes, 507
svgwaitclose, 508
symboldeclaration, 47
import, 17
SYMBOLS, 8
symlink, 611

926

Indexsymmetric cipher, 440
symmetric ciphers, 436
symmetric cypher
initialisation vector, 456
key size, 442, 457
synchronization mechanism, 247
syntax, 15
sys_endparse, 513
sys_fillchar, 513
SYS_MOD, 545
SYS_NOW, 509, 510
sys_pid, 513
sys_qtype, 513
sys_regcache, 514
sys_sepchar, 514
sys_trim, 514
sys_txtmem, 514
SYS_TYP, 545
SYS_ARCH, 560
SYS_DIR, 545, 584
SYS_DIRONLY, 528, 572, 573, 594, 614, 620–622
SYS_DOWN, 585
SYS_EXEC, 545
SYS_EXTN, 584
SYS_FLAT, 572, 573, 620, 621
SYS_FNAME, 584
SYS_LEFT, 619
SYS_LNK, 545
SYS_NAME, 560
SYS_NODE, 560
SYS_NODIR, 528, 572, 573, 594, 614, 620–622
SYS_NOFAIL, 620, 621
SYS_NOSORT, 528
SYS_OTH, 545
SYS_OVERWRT, 620, 621
SYS_PROC, 560
SYS_RAM, 560
SYS_READ, 545
SYS_RECURS, 528, 594
SYS_REG, 545
SYS_REL, 560
SYS_REVORD, 528
SYS_RIGHT, 619
SYS_UP, 585
SYS_VER, 560
SYS_VERB, 620, 621
SYS_WRITE, 545
sysfd, 60
system, 612
system command, 517, 612
system information, 516, 560
system status, 516, 561
Ttable of symbols, 52
tagpriv, 19tan, 322
tarlist, 614
tcpping, 218
tee, 60

Fair Isaac Corporation Proprietary Information

temporary directory, 61
term
enumerate, 393
terminate R, 855, 857
termination, 97
test
eof, 141
hidden constraint, 143
hidden nonlinear constraint, 322, 328
testattr, 649
testtype, 417
text, 509, 638
text section, 636
textfmt, 615
then, 16
time, 87
file, 546
time, 509
time measure, 516, 562
timefmt, 511
timestamp, 178
timestamp, 178
tmp, 59
tmpdir, 125
to, 16
tolerance
zero, 35, 125, 168
tolerance set, 699, 714
tolower, 617
tolset, 695
toupper, 618
trace, 10transaction
commit, 342, 350
rollback, 343, 351
trigonometric functions, 73, 84, 172, 322
trim, 619
true, 16, 22, 31, 639
txtresize, 635
txtztol, 125, 168
typeconstraint, 136, 171
conversion, 31
element, 116
ID, 29, 137
identification number, 29
nonlinear constraint, 322, 323, 330, 333
problem, 50
SOS, 136, 171
structure, 133variable, 36, 136, 171
U
UID

event sender, 287, 304
model, 261, 280, 287, 291
wait for, 287, 295
uncertain, 418
uncertainctr, 418
unconstrained, 36927

IndexUNDISPLAY, 9
union, 26, 34
compare, 35
dereference, 28
set type, 85
union, 16, 32, 34
unique identifier, 154
unload, 284
unloadprob, 807
unpublish, 179
untar, 620
until, 16, 45
unzip, 621
UP, 9upper bound, 725, 761
set, 727, 804
url, 244
URL encoding, 203, 219
urlencode, 219
uselastbarsol, 808
user comment, 8user function, 694, 699, 702
info, 699, 715
Mosel, 699, 716
parallel, 699, 704
user graph, 466
add file, 470, 476, 477
add plot, 470, 472
axes labels, 471, 498
closing, 470, 485
color, 486
delete object, 470, 487
draw arrow, 470, 473
draw circle, 470, 474
draw ellipse, 470, 475
draw line, 470, 478
draw pie, 479
draw point, 480
draw polygon, 470, 481
draw rectangle, 470, 482
draw text, 470, 483, 484
erase, 470, 488
get object, 470, 492
get style, 470, 490, 494
get style property, 470, 489, 493
get viewbox, 470, 491
model termination, 471, 508
point size, 471, 499
refresh, 471, 496
refresh frequency, 471, 504
save, 471, 497
scaling, 471, 500
set style, 471, 502, 506
set style property, 471, 501, 505
view box, 471, 503
user type, 27
definition, 27
userfunc, 694
userfuncinfo, 715
userfuncMosel, 716

Fair Isaac Corporation Proprietary Information

uses, 16, 17
UTC, 125, 168
Vvalidate, 717
value
event, 287
variable, 22check intregrality, 767
environment, 543, 599
fix, 739
initial value, 320, 323, 326
lower bound, 725, 748
name, 752
ranging information, 725, 755
reduced cost, 127
sensitivity ranges, 725, 757
set coefficient, 162
set lower bound, 726, 799
set type, 171
set upper bound, 727, 804
solution, 132
type, 136
upper bound, 725, 761
version, 8, 16, 17versionnum, 180versionstr, 180vertical spacing, 642, 664, 683
viewbox, 470, 491
VIMA, 1visual environment, 2W
W-121, 895
W-131, 896
W-144, 896
W-152, 897
W-164, 898
W-166, 899
W-306, 901
W-309, 901
W-85, 904
wait, 293
waitexpired, 294
waitfor, 295
waitforend, 297
WDOnly, 11
WHERE, 9while, 16, 45
with, 16, 46, 50
workdir, 125, 168
working directory, 61, 261, 271, 515, 535
write
directives, 727, 810
problem, 727, 811
write, 61, 107, 181, 387
write_, 68
writebasis, 809
writedirs, 810
writeln, 61, 107, 181, 387

928

Indexwriteln_, 68
writeprob, 811
writesol, 812
X
X509 certificate, 437
compatibility, 442, 461
create, 442, 463
information, 442, 462
x509check, 461
x509getinfo, 462
x509newcrt, 463
xbim, 19
xls, 434
xlsx, 434XML
decode, 642, 691
encode, 642, 690
XML document, 641
XML document structure, 636
XML node number, 641
XML node type, 636
XML path, 637
xml version, 642, 662, 688
XML_ATTR, 651, 660
XML_AUTO, 665, 684
XML_CDATA, 643, 651, 660
XML_COM, 643, 651, 660
XML_DATA, 643, 651, 660
XML_ELT, 643, 651, 660
XML_FCT_CDATA, 692
XML_FCT_CLOSE_ELT, 692
XML_FCT_COM, 692
XML_FCT_DATA, 692
XML_FCT_DECL, 692
XML_FCT_OPEN_ELT, 692
XML_FCT_PINST, 692
XML_FCT_TXT, 692
XML_FIRST, 643, 645
XML_FIRSTCHILD, 643, 645
XML_LAST, 643, 645
XML_LASTCHILD, 643, 645
XML_MANUAL, 665, 684
XML_NEXT, 643, 645
XML_NONE, 665, 684
XML_PINST, 643, 651, 660
XML_TXT, 643, 651, 660
xmlattr, 689
xmldecode, 691
xmldoc, 641
xmlencode, 690
xmlparse, 692
XNLP_AUTOELIM, 697
XNLP_LOADASNL, 697
XNLP_LOADNAMES, 697
XNLP_NLPSTATUS, 698
XNLP_SOLVER, 698
XNLP_TOL_RA, 695
XNLP_TOL_RI, 695
XNLP_TOL_RM, 695

Fair Isaac Corporation Proprietary Information

XNLP_TOL_RS, 695
XNLP_TOL_TA, 695
XNLP_TOL_TC, 695
XNLP_TOL_TI, 695
XNLP_TOL_TM, 695
XNLP_TOL_TS, 695
XNLP_VERBOSE, 698
xor, 813
Xpress Optimizer, 2
Xpress Workbench, 2
xprmsrv, 313
XPRS_colorder, 722
XPRS_enumduplpol, 723
XPRS_enummaxsol, 722
XPRS_enumsols, 722
XPRS_fullversion, 723
XPRS_loadnames, 723
XPRS_maxupdc, 723
XPRS_problem, 724
XPRS_probname, 724
XPRS_verbose, 724
XPRS_BAR, 773
XPRS_BR, 801
XPRS_CB_BARITER, 793
XPRS_CB_BARLOG, 793
XPRS_CB_CHECKTIME, 793
XPRS_CB_CHGBRANCH, 793
XPRS_CB_CHGNODE, 793
XPRS_CB_COMPUTERESTART, 793
XPRS_CB_CUTLOG, 793
XPRS_CB_CUTMGR, 793
XPRS_CB_GAPNOTIFY, 793
XPRS_CB_GLOBALLOG, 793
XPRS_CB_INFNODE, 793
XPRS_CB_INTSOL, 793
XPRS_CB_LPLOG, 793
XPRS_CB_NEWNODE, 793
XPRS_CB_NODECUTOFF, 793
XPRS_CB_OPTNODE, 793
XPRS_CB_PREINTSOL, 793
XPRS_CB_PRENODE, 793
XPRS_CB_PRESOLVE, 793
XPRS_CB_SOLNOTIFY, 793
XPRS_CONT, 773
XPRS_COREPB, 773
XPRS_DN, 757, 801
XPRS_DUAL, 773
XPRS_ENUM, 773
XPRS_INF, 754
XPRS_LBND, 757
XPRS_LCOST, 755
XPRS_LIN, 773
XPRS_LOACT, 755
XPRS_LOCAL, 773
XPRS_LPSTOP, 773
XPRS_NET, 773
XPRS_OPT, 754
XPRS_OTH, 754
XPRS_PD, 801
XPRS_PR, 801929

Index

XPRS_PRI, 773
XPRS_PU, 801
XPRS_STOP_CTRLC, 806
XPRS_STOP_ITERLIMIT, 806
XPRS_STOP_MIPGAP, 806
XPRS_STOP_NODELIMIT, 806
XPRS_STOP_SOLLIMIT, 806
XPRS_STOP_TIMELIMIT, 806
XPRS_STOP_USER, 806
XPRS_TUNE, 773
XPRS_UBND, 757
XPRS_UCOST, 755
XPRS_UDN, 755
XPRS_UNB, 754
XPRS_UNF, 754
XPRS_UP, 757, 801
XPRS_UPACT, 755
XPRS_UUP, 755
xprsmemoryuse, 814
XSLP_CB_CASCADEEND, 707
XSLP_CB_CASCADESTART, 707
XSLP_CB_CASCADEVAR, 707
XSLP_CB_CONSTRUCT, 707
XSLP_CB_END, 707
XSLP_CB_INTSOL, 707
XSLP_CB_ITEREND, 707
XSLP_CB_ITERSTART, 707
XSLP_CB_ITERVAR, 707
XSLP_CB_MSJOBEND, 707
XSLP_CB_MSJOBSTART, 707
XSLP_CB_MSWINNER, 707
XSLP_CB_OPTNODE, 707
XSLP_CB_PRENODE, 707
XSLP_CB_START, 707
xsrv, 312
xssh, 312
Z
zero tolerance, 35, 125, 168
zerotol, 125, 168zip, 873
ziplist, 622
zlib.dso, 873

Fair Isaac Corporation Proprietary Information

930