FICO Xpress Optimization mosjvm Module for MoselIntroduction The mosjvm module allows you to create...

26
Reference manual FICO R Xpress Optimization mosjvm Module for Mosel Reference Manual Release 8.3 Last update 17 July, 2017 www.fico.com Make every decision count TM

Transcript of FICO Xpress Optimization mosjvm Module for MoselIntroduction The mosjvm module allows you to create...

Page 1: FICO Xpress Optimization mosjvm Module for MoselIntroduction The mosjvm module allows you to create a Java virtual machine within the same process running Mosel, and call static Java

Reference manual

FICO R© Xpress Optimization mosjvm Module for Mosel

Reference Manual

Release 8.3

Last update 17 July, 2017

www.fico.com Make every decision countTM

Page 2: FICO Xpress Optimization mosjvm Module for MoselIntroduction The mosjvm module allows you to create a Java virtual machine within the same process running Mosel, and call static Java

This material is the confidential, proprietary, and unpublished property of Fair Isaac Corporation.Receipt or possession of this material does not convey rights to divulge, reproduce, use, or allowothers to use it without the specific written authorization of Fair Isaac Corporation and use mustconform strictly to the license agreement.

The information in this document is subject to change without notice. If you find any problems inthis documentation, please report them to us in writing. Neither Fair Isaac Corporation nor itsaffiliates warrant that this documentation is error-free, nor are there any other warranties withrespect to the documentation except as may be provided in the license agreement.

©2017 Fair Isaac Corporation. All rights reserved. Permission to use this software and itsdocumentation is governed by the software license agreement between the licensee and Fair IsaacCorporation (or its affiliate). Portions of the program may contain copyright of various authors andmay be licensed under certain third-party licenses identified in the software, documentation, orboth.

In no event shall Fair Isaac Corporation 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 thissoftware and its documentation, even if Fair Isaac Corporation or its affiliates have been advised ofthe possibility of such damage. The rights and allocation of risk between the licensee and Fair IsaacCorporation (or its affiliates) are governed by the respective identified licenses in the software,documentation, or both.

Fair Isaac Corporation and its affiliates specifically disclaim any warranties, including, but not limitedto, the implied warranties of merchantability and fitness for a particular purpose. The software andaccompanying documentation, if any, provided hereunder is provided solely to users licensed underthe Fair Isaac Software License Agreement. Fair Isaac Corporation and its affiliates have noobligation to provide maintenance, support, updates, enhancements, or modifications except asrequired to licensed users under the Fair Isaac Software License Agreement.

FICO and Fair Isaac are trademarks or registered trademarks of Fair Isaac Corporation in the UnitedStates and may be trademarks or registered trademarks of Fair Isaac Corporation in other countries.Other product and company names herein may be trademarks of their respective owners.

FICO R© Xpress Optimization

Deliverable Version: A

Last Revised: 17 July, 2017

Version 8.3

Page 3: FICO Xpress Optimization mosjvm Module for MoselIntroduction The mosjvm module allows you to create a Java virtual machine within the same process running Mosel, and call static Java

Contents

1 Introduction 1

2 Usage 22.1 Calling Java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22.2 Starting Java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32.3 Classpath . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32.4 Exception handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

3 Limitations 53.1 No complex return types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53.2 Arguments passed by value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53.3 Standard output streams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53.4 Working directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53.5 Static methods only . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53.6 JVM shut down . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63.7 Incompatible with com.dashoptimization.XPRM . . . . . . . . . . . . . . . . . . . . . . 63.8 Incompatible with other JVMs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63.9 Supported Java version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63.10 Window and Linux only . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63.11 ThreadLocal values not supported . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63.12 Not supported in FICO Analytic Cloud . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63.13 System.exit may not be called . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

4 Use in Mosel Restricted Mode 7

5 Examples 95.1 Passing values to a Java method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95.2 Calling a void Java method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95.3 Passing an array to a Java method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

6 Procedures and functions 11jvmcallint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12jvmcallreal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13jvmcallstr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14jvmcalltext . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15jvmcallvoid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

7 Parameters 17jvmcallstatus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17jvmexceptiontype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17jvmexceptionmsg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17jvmloadverbose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18jvmdebug . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18jvmxms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18jvmxmx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

Fair Isaac Corporation Confidential and Proprietary Information i

Page 4: FICO Xpress Optimization mosjvm Module for MoselIntroduction The mosjvm module allows you to create a Java virtual machine within the same process running Mosel, and call static Java

Contents

Appendix 20

A Contacting FICO 20Product support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20Product education . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20Product documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20Sales and maintenance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21Related services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21About FICO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

Index 22

Fair Isaac Corporation Confidential and Proprietary Information ii

Page 5: FICO Xpress Optimization mosjvm Module for MoselIntroduction The mosjvm module allows you to create a Java virtual machine within the same process running Mosel, and call static Java

CHAPTER 1

Introduction

The mosjvm module allows you to create a Java virtual machine within the same process runningMosel, and call static Java methods from within a Mosel model. For example:

javaReturnString :=jvmcallstr(’com.fico.testpackage.TestClass.myTestFunction’, functionArg1, functionArg2,

functionArg3)

writeln("2+5=",jvmcallint(’com.fico.testpackage.SimpleMathOperations.addTwoValues’, 2, 5))

In this way, you can interact with pre-existing Java libraries from your Mosel model. However,please note that there are some drawbacks to instantiating a Java virtual machine in the sameprocess as the Mosel virtual machine, and developers are advised to consider other approaches(for example: deploying your Java classes to a Tomcat webserver and interacting with them usingstandard webservice requests) before building a solution based upon mosjvm.

The developer is advised to read the later chapter which goes into some detail about thelimitations of this module. But the most major limitations to be aware of are:

� This module is only available for Windows and Linux.

� This module can not be used within the FICO Analytic Cloud.

� Java 8 must be installed on the machine running the model.

Fair Isaac Corporation Confidential and Proprietary Information 1

Page 6: FICO Xpress Optimization mosjvm Module for MoselIntroduction The mosjvm module allows you to create a Java virtual machine within the same process running Mosel, and call static Java

CHAPTER 2

Usage

2.1 Calling Java

Add uses ’mosjvm’ to the top of your model then you can call any static Java method by passingits full class and method name to one fo the jvmcall<type> functions, where <type> representsthe return type of the function, for example:

model myModeluses ’mosjvm’

writeln(’Integer return value=’, jvmcallint(’com.fico.MyClassName.myIntMethod’))writeln(’String return value=’, jvmcallstr(’com.fico.MyClassName.myStringMethod’))writeln(’Real return value with two parameters=’,

jvmcallreal(’com.fico.MyClassName.myRealMethod’, 5.7, true))end-model

You can call jvmcallvoid if your Java method doesn’t return anything. Any number of methodarguments may be specified, from the following types:

� boolean (translates to Java type: boolean)

� integer (translates to Java type: int)

� real (translates to Java type: double)

� string (translates to Java type: java.lang.String)

� text (translates to Java type: java.lang.String)

� array of boolean (translates to Java type: boolean[])

� array of integer (translates to Java type: int[])

� array of real (translates to Java type: double[])

� array of string (translates to Java type: java.lang.String[])

� array of text (translates to Java type: java.lang.String[])

Where an argument is an array, it must be indexed by a Mosel range starting from 0, e.g.:

model myModelAruses ’mosjvm’declarations

MyArray: array(range) of stringend-declarations

Fair Isaac Corporation Confidential and Proprietary Information 2

Page 7: FICO Xpress Optimization mosjvm Module for MoselIntroduction The mosjvm module allows you to create a Java virtual machine within the same process running Mosel, and call static Java

Usage

MyArray(0) := "zero"MyArray(1) := "one"MyArray(2) := "two"

jvmcallvoid("com.fico.MyClassName.myMethodTakingArrayOfString", MyArray)end-model

2.2 Starting Java

The first time a jvmcall<type> function is called from a model in a Mosel process, mosjvm willload and initialize a Java virtual machine. This Java virtual machine will then be used by allsubsequent jvmcall<type> functions called by models in this process—if your Java functionsmodify any static fields, those modified values will be read by subsequent calls, possibly fromdifferent models. If you are using mosjvm from multiple submodels within the same Moselinstance, your Java code will need to be threadsafe.

By default, mosjvm will look for the Java Runtime Environment in the following locations:

� The folder specified by the MOSJVM_JAVA_HOME environment variable, if set

� The folder specified by the JAVA_HOME environment variable, if set

� Relative to the location of a java executable found in a folder on the PATH environmentvariable

� In some common install locations

To force mosjvm to use a specific installation of Java, set the environment variableMOSJVM_JAVA_HOME before starting Mosel.

2.3 Classpath

By default, mosjvm will look for your Java classes using a classpath determined as follows:

� The classpath specified by the MOSJVM_CLASSPATH environment variable, if set

� Otherwise, the classpath specified by the CLASSPATH environment variable, if set

� Otherwise, the current working directory of the Mosel process

2.4 Exception handling

When an error occurs within a Java method, the Java Virtual Machine will throw an exception.From Mosel, you can check whether your last call to Java threw an exception by looking at thejvmcallstatus parameter; a non-zero value indicates an exception. When jvmcallstatus isnon-zero, the jvmexceptiontype parameter will hold the class name of the exception (e.g.java.io.FileNotFoundException) and the jvmexceptionmsg parameter will contain theexception’s text. For example:

model myModelExcuses ’mosjvm’

jvmcallvoid(’com.fico.MyClassName.parseMyInputFile’, ’inputfile.dat’)if getparam(’jvmcallstatus’)<>0 then

Fair Isaac Corporation Confidential and Proprietary Information 3

Page 8: FICO Xpress Optimization mosjvm Module for MoselIntroduction The mosjvm module allows you to create a Java virtual machine within the same process running Mosel, and call static Java

Usage

setioerr(’Encountered Java error of type: ’+ getparam(’jvmexceptiontype’)+", message: "+getparam(’jvmexceptionmsg’))end-if

end-model

If you set the parameter jvmdebug to ’true’, the stack trace of any exceptions thrown by your callsto Java will be written to the Mosel model’s error stream.

Fair Isaac Corporation Confidential and Proprietary Information 4

Page 9: FICO Xpress Optimization mosjvm Module for MoselIntroduction The mosjvm module allows you to create a Java virtual machine within the same process running Mosel, and call static Java

CHAPTER 3

Limitations

3.1 No complex return types

Java methods can only return values of basic types back to Mosel: boolean, integer, real, stringand text. If you need to return a large data-set then your options would be to format it in somestandard format (e.g. CSV, XML, JSON), and return it as ’text’ then use Mosel’s standard modulesto parse it, or to write it to a file that can be read later by the Mosel model.

3.2 Arguments passed by value

Method arguments are input-only—so when you make changes to an array from within a Javafunction, this does not affect the array in the Mosel model. Similarly when you pass a Mosel textobject, it becomes a Java String and cannot be modified from Java.

3.3 Standard output streams

If you send output to the Java stream System.out within a Java method called through mosjvm,the output will be sent to the Mosel model’s standard output stream. However, if the Java virtualmachine generates output from a different thread, this will not be captured by any Mosel stream.

Similarly, output you send to System.err will go to the the Mosel model’s error stream. If anotherthread generates output to System.err, it will be sent to the Mosel instance’s error stream.

3.4 Working directories

The initial working directory of the Java virtual machine will be the working directory of theMosel process; this may be different from the working directories of the Mosel models (controlledby the workdir parameter). When passing filenames between the Mosel and Java environments,it is recommended to always use absolute paths.

3.5 Static methods only

mosjvm can only be used to call static methods. It is not possible to call instance methods orreference a Java object directly from a Mosel model.

Fair Isaac Corporation Confidential and Proprietary Information 5

Page 10: FICO Xpress Optimization mosjvm Module for MoselIntroduction The mosjvm module allows you to create a Java virtual machine within the same process running Mosel, and call static Java

Limitations

3.6 JVM shut down

In normal usage, once the Java virtual machine has started up, it will not be shut down until theMosel process exits.

3.7 Incompatible with com.dashoptimization.XPRM

If you are calling Mosel using the Mosel Java Library classes in the com.dashoptimizationpackage, you cannot use the mosjvm module.

3.8 Incompatible with other JVMs

The mosjvm module can only interact with a Java virtual machine that it itself has started. If thereis already a Java virtual machine running in the Mosel process, attempting to use the mosjvmmodule will result in an error.

3.9 Supported Java version

The mosjvm module is only supported with Oracle or OpenJDK Java 8. It has not been tested withother versions of Java.

3.10 Window and Linux only

The mosjvm module is only available with Windows and Linux versions of Xpress. It is notavailable for other platforms.

3.11 ThreadLocal values not supported

Every Java call made using the mosjvm module occurs in a separate Java thread that is terminatedafter the Java method completes. This means that you cannot use ThreadLocal objects to sharevalues between multiple jvmcall<type> invocations from the same model. If you are runningmultiple models within the Mosel instance and need to store some per-model data in the Javaruntime, it’s recommended you store them in a static ConcurrentHashMap field, using the value ofthe Mosel modelname or modelnumber parameter as a key, and make an extra call at the end ofyour model to clean up any stored data for this model.

3.12 Not supported in FICO Analytic Cloud

The use of mosjvm is not supported by applications running within the FICO Analytic Cloud.

3.13 System.exit may not be called

Calling System.exit from the JVM started by mosjvm will not work; an exception will be thrown.

Fair Isaac Corporation Confidential and Proprietary Information 6

Page 11: FICO Xpress Optimization mosjvm Module for MoselIntroduction The mosjvm module allows you to create a Java virtual machine within the same process running Mosel, and call static Java

CHAPTER 4

Use in Mosel Restricted Mode

When Mosel is run in restricted mode, the JVM will be started with a security manager that willtry to match the Mosel security model. For example, if the Mosel WDOnly restriction is present,you will be prevented from reading from or writing to any files outside of the Mosel instance’sworking directory.

The JVM will always be able to read from the Java installation directory, and any configured Javaextension directories, regardless of the Mosel restrictions level.

When the NoExec restriction is present, the use of Java is subject to several additional restrictions:

� Other processes may not be started from Java.

� Native libraries may not be loaded by the Java Virtual Machine, except for those installedwithin the Java installation directory.

� The JVM’s classpath shall only be read from the environment variable MOSJVM_CLASSPATH.

� The environment variable MOSJVM_ALLOW must contain a whitespace-separated list of theclasses that can be called using a jvmcall<type> function.

When any Mosel security restriction is present (i.e. MOSEL_RESTR is non-zero), the JVM willadditionally be restricted as follows:

� The JVM may not open any GUI windows.

� System.setSecurityManager may not be called.

� Direct access to file descriptors is disabled.

� Access to the printing API is disabled.

� Access to the audio API is disabled.

� Access to the reflection API is disabled.

� Access to the preferences backing store is disabled.

� Code may not add additional classes with package names starting java. or sun.

� Java code may not set cookie handlers, proxy selectors, response caches or change thedefault authenticator.

� Java code may not set SSL hostname verifiers or change the default SSL context.

� Creation of sockets is disabled.

� Access to private credentials is disabled.

Fair Isaac Corporation Confidential and Proprietary Information 7

Page 12: FICO Xpress Optimization mosjvm Module for MoselIntroduction The mosjvm module allows you to create a Java virtual machine within the same process running Mosel, and call static Java

Use in Mosel Restricted Mode

� Access to Kerberos delegation is disabled.

The above list is not intended to be exhaustive; the permissions required to perform Javaoperations are sometimes non-obvious. When building a solution that will use mosjvm in anenvironment where Mosel security restrictions are in place, it is recommended that the developerperforms testing with the required Mosel security restrictions as early as possible.

Fair Isaac Corporation Confidential and Proprietary Information 8

Page 13: FICO Xpress Optimization mosjvm Module for MoselIntroduction The mosjvm module allows you to create a Java virtual machine within the same process running Mosel, and call static Java

CHAPTER 5

Examples

5.1 Passing values to a Java method

This example demonstrates calling a Java method and returning a value to Mosel.

model MosJvmExample1uses "mosjvm"

parametersSRC_VALUE=5

end-parameters

writeln(SRC_VALUE, "*2=",jvmcallint("com.fico.examples.MathOperations.multiply", SRC_VALUE, 2))

if getparam("jvmcallstatus")<>0 thensetmatherr("Java exception: "+ getparam("jvmexceptiontype"))

end-if

end-model

Where the MathOperations class is defined as follows:

package com.fico.examples;

public class MathOperations {public static int multiply(int v1,int v2) {

return v1*v2;}

}

5.2 Calling a void Java method

This example demonstrates calling a Java method and displaying a value to the Mosel outputstream.

model MosJvmExample2uses "mosjvm"

parametersSRC_VALUE=5

end-parameters

jvmcallvoid("com.fico.examples.MathOperations.multiplyAndDisplay", SRC_VALUE, 2)if getparam("jvmcallstatus")<>0 then

setmatherr("Java exception: "+ getparam("jvmexceptiontype"))end-if

Fair Isaac Corporation Confidential and Proprietary Information 9

Page 14: FICO Xpress Optimization mosjvm Module for MoselIntroduction The mosjvm module allows you to create a Java virtual machine within the same process running Mosel, and call static Java

Examples

end-model

Where the MathOperations class is defined as follows:

package com.fico.examples;

public class MathOperations {public static void multiplyAndDisplay(int v1,int v2) {

System.out.println("The result of "+v1+"*"+v2+" is "+(v1*v2));}

}

5.3 Passing an array to a Java method

This example demonstrates passing an array to a Java method and returning a value to Mosel.

model MosJvmExample3uses "mosjvm"

declarationsMyData: array(range) of realresult: real

end-declarations

! Create some dataforall(x in 0..5000) MyData(x) := x*5

! Calculate sumresult := jvmcallreal("com.fico.examples.MathOperations.sumOfArray", MyData)if getparam("jvmcallstatus")<>0 then

setmatherr("Java exception: "+ getparam("jvmexceptiontype"))end-if

! Print resultwriteln("Sum of values = ", result)

end-model

Where the MathOperations class is defined as follows:

package com.fico.examples;

public class MathOperations {public static double sumOfArray(double[] values) {

double tot = 0;for (double v : values) {

tot += v;}return tot;

}}

Fair Isaac Corporation Confidential and Proprietary Information 10

Page 15: FICO Xpress Optimization mosjvm Module for MoselIntroduction The mosjvm module allows you to create a Java virtual machine within the same process running Mosel, and call static Java

CHAPTER 6

Procedures and functions

jvmcallint Call a public static int function in a Java class. p. 12

jvmcallreal Call a public static double function in a Java class. p. 13

jvmcallstr Call a public static String function in a Java class. p. 14

jvmcalltext Call a public static String function in a Java class, returning a text p. 15

jvmcallvoid Call a public static void function in a Java class. p. 16

Fair Isaac Corporation Confidential and Proprietary Information 11

Page 16: FICO Xpress Optimization mosjvm Module for MoselIntroduction The mosjvm module allows you to create a Java virtual machine within the same process running Mosel, and call static Java

Procedures and functions

jvmcallint

PurposeCall a public static int function in a Java class.

Synopsisfunction jvmcallint(qualifiedmethodname:string) : integerfunction jvmcallint(qualifiedmethodname:string, ...) : integer

Argumentsqualifiedmethodname The name of the method, including class and package name, e.g.

"com.fico.examples.MathOperations.multiply"... Following the method name, specify zero or more values to pass as

arguments to the Java method.

Further information

1. mosjvm will look in the class for a method with the given argument types that is declared asreturning an int. If such a method cannot be found, the model will terminate with a runtimeerror.

2. The types of value that may be passed as method arguments are discussed earlier in this guide.

3. If mosjvm has not yet loaded the Java Virtual Machine into the Mosel process, it will be loaded bythis function. If Java cannot be found or an error occurs loading it, the model will terminate witha runtime error.

Related topicsjvmcallstatus, jvmdebug

Fair Isaac Corporation Confidential and Proprietary Information 12

Page 17: FICO Xpress Optimization mosjvm Module for MoselIntroduction The mosjvm module allows you to create a Java virtual machine within the same process running Mosel, and call static Java

Procedures and functions

jvmcallreal

PurposeCall a public static double function in a Java class.

Synopsisfunction jvmcallreal(qualifiedmethodname:string) : realfunction jvmcallreal(qualifiedmethodname:string, ...) : real

Argumentsqualifiedmethodname The name of the method, including class and package name, e.g.

"com.fico.examples.MathOperations.multiply"... Following the method name, specify zero or more values to pass as

arguments to the Java method.

Further information

1. mosjvm will look in the class for a method with the given argument types that is declared asreturning a double. If such a method cannot be found, the model will terminate with a runtimeerror.

2. The types of value that may be passed as method arguments are discussed earlier in this guide.

3. If mosjvm has not yet loaded the Java Virtual Machine into the Mosel process, it will be loaded bythis function. If Java cannot be found or an error occurs loading it, the model will terminate witha runtime error.

Related topicsjvmcallstatus, jvmdebug

Fair Isaac Corporation Confidential and Proprietary Information 13

Page 18: FICO Xpress Optimization mosjvm Module for MoselIntroduction The mosjvm module allows you to create a Java virtual machine within the same process running Mosel, and call static Java

Procedures and functions

jvmcallstr

PurposeCall a public static String function in a Java class.

Synopsisfunction jvmcallstr(qualifiedmethodname:string) : stringfunction jvmcallstr(qualifiedmethodname:string, ...) : string

Argumentsqualifiedmethodname The name of the method, including class and package name, e.g.

"com.fico.examples.MathOperations.multiply"... Following the method name, specify zero or more values to pass as

arguments to the Java method.

Further information

1. mosjvm will look in the class for a method with the given argument types that is declared asreturning a java.lang.String. If such a method cannot be found, the model will terminate witha runtime error.

2. The types of value that may be passed as method arguments are discussed earlier in this guide.

3. If mosjvm has not yet loaded the Java Virtual Machine into the Mosel process, it will be loaded bythis function. If Java cannot be found or an error occurs loading it, the model will terminate witha runtime error.

Related topicsjvmcallstatus, jvmdebug, jvmcalltext

Fair Isaac Corporation Confidential and Proprietary Information 14

Page 19: FICO Xpress Optimization mosjvm Module for MoselIntroduction The mosjvm module allows you to create a Java virtual machine within the same process running Mosel, and call static Java

Procedures and functions

jvmcalltext

PurposeCall a public static String function in a Java class, returning the value into Mosel as a text value.

Synopsisfunction jvmcalltext(qualifiedmethodname:string) : textfunction jvmcalltext(qualifiedmethodname:string, ...) : text

Argumentsqualifiedmethodname The name of the method, including class and package name, e.g.

"com.fico.examples.MathOperations.multiply"... Following the method name, specify zero or more values to pass as

arguments to the Java method.

Further information

1. mosjvm will look in the class for a method with the given argument types that is declared asreturning a java.lang.String. If such a method cannot be found, the model will terminate witha runtime error.

2. The types of value that may be passed as method arguments are discussed earlier in this guide.

3. If mosjvm has not yet loaded the Java Virtual Machine into the Mosel process, it will be loaded bythis function. If Java cannot be found or an error occurs loading it, the model will terminate witha runtime error.

Related topicsjvmcallstatus, jvmdebug, jvmcallstr

Fair Isaac Corporation Confidential and Proprietary Information 15

Page 20: FICO Xpress Optimization mosjvm Module for MoselIntroduction The mosjvm module allows you to create a Java virtual machine within the same process running Mosel, and call static Java

Procedures and functions

jvmcallvoid

PurposeCall a public static void function in a Java class.

Synopsisprocedure jvmcallvoid(qualifiedmethodname:string)procedure jvmcallvoid(qualifiedmethodname:string, ...)

Argumentsqualifiedmethodname The name of the method, including class and package name, e.g.

"com.fico.examples.MathOperations.multiply"... Following the method name, specify zero or more values to pass as

arguments to the Java method.

Further information

1. mosjvm will look in the class for a method with the given argument types that is declared as void.If such a method cannot be found, the model will terminate with a runtime error.

2. The types of value that may be passed as method arguments are discussed earlier in this guide.

3. If mosjvm has not yet loaded the Java Virtual Machine into the Mosel process, it will be loaded bythis procedure. If Java cannot be found or an error occurs loading it, the model will terminatewith a runtime error.

Related topicsjvmcallstatus, jvmdebug

Fair Isaac Corporation Confidential and Proprietary Information 16

Page 21: FICO Xpress Optimization mosjvm Module for MoselIntroduction The mosjvm module allows you to create a Java virtual machine within the same process running Mosel, and call static Java

CHAPTER 7

Parameters

Via the getparam function and the setparam procedure it is possible to access the followingcontrol parameters of module mosjvm :

jvmcallstatus Status of last call into JVM p. 17

jvmdebug Display stack trace of Java exceptions p. 18

jvmexceptionmsg Message of exception thrown by JVM p. 17

jvmexceptiontype Classname of exception thrown by JVM p. 17

jvmloadverbose Activate additional logging when Java is loaded p. 18

jvmxms Initial JVM heap size p. 18

jvmxmx Maximum JVM heap size p. 18

jvmcallstatus

Description Will be nonzero if the last call to a Java method threw an exception, zero otherwise.

Type Integer, read only

jvmexceptiontype

Description If the last call to a Java method threw an exception, this parameter will hold theexception class name (e.g. java.io.FileNotFoundexception). Otherwise, it will be anempty string.

Type String, read only

jvmexceptionmsg

Description If the last call to a Java method threw an exception, this parameter will hold theexception message string (i.e. result of calling Exception.getMessage()). Otherwise, itwill be an empty string.

Type String, read only

Fair Isaac Corporation Confidential and Proprietary Information 17

Page 22: FICO Xpress Optimization mosjvm Module for MoselIntroduction The mosjvm module allows you to create a Java virtual machine within the same process running Mosel, and call static Java

Parameters

jvmloadverbose

Description Set to ’true’ to activate some additional logging of how mosjvm looks for and finds yourinstallation of Java, to the model’s error stream.

Type Boolean, read/write

Default value false

Note This can give useful information if it is not clear which Java mosjvm is loading, or if itcannot find your installation of Java.

Note This parameter will only have effect if set before the JVM is loaded into the Moselprocess.

jvmdebug

Description When set to ’true’, if an exception is thrown by a Java method called by mosjvm, theexception stack trace will be output to the Mosel error stream.

Type Boolean, read/write

Default value false

Note This can be useful when debugging Java exceptions that are thrown by methods you callfrom Mosel.

jvmxms

Description Allows you to set the initial amount of memory used by the JVM’s heap. For moredetails, please consult the Java documentation for the command-line flag -Xms

Type String, read/write

Default value 64m

Note This parameter will only have effect if set before the JVM is loaded into the Moselprocess.

jvmxmx

Description Allows you to set the maximum amount of memory available to the JVM’s heap. Formore details, please consult the Java documentation for the command-line flag -Xmx

Type String, read/write

Default value 512m

Fair Isaac Corporation Confidential and Proprietary Information 18

Page 23: FICO Xpress Optimization mosjvm Module for MoselIntroduction The mosjvm module allows you to create a Java virtual machine within the same process running Mosel, and call static Java

Parameters

Note This parameter will only have effect if set before the JVM is loaded into the Moselprocess.

Fair Isaac Corporation Confidential and Proprietary Information 19

Page 24: FICO Xpress Optimization mosjvm Module for MoselIntroduction The mosjvm module allows you to create a Java virtual machine within the same process running Mosel, and call static Java

APPENDIX A

Contacting FICO

FICO provides clients with support and services for all our products. Refer to the followingsections for more information.

Product support

FICO offers technical support and services ranging from self-help tools to direct assistance with aFICO technical support engineer. Support is available to all clients who have purchased a FICOproduct and have an active support or maintenance contract. You can find support contactinformation on the Product Support home page (www.fico.com/support).

On the Product Support home page, you can also register for credentials to log on to FICO OnlineSupport, our web-based support tool to access Product Support 24x7 from anywhere in the world.Using FICO Online Support, you can enter cases online, track them through resolution, findarticles in the FICO Knowledge Base, and query known issues.

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, andtraining tools for both new user enablement and ongoing performance support. For additionalinformation, visit the Product Education homepage at www.fico.com/en/product-training oremail [email protected].

Product documentation

FICO continually looks for new ways to improve and enhance the value of the products andservices we provide. If you have comments or suggestions regarding how we can improve thisdocumentation, let us know by sending your suggestions to [email protected].

Fair Isaac Corporation Confidential and Proprietary Information 20

Page 25: FICO Xpress Optimization mosjvm Module for MoselIntroduction The mosjvm module allows you to create a Java virtual machine within the same process running Mosel, and call static Java

Contacting FICO

Sales and maintenance

USA, CANADA AND ALL AMERICAS

Email: [email protected]

WORLDWIDE

Email: [email protected]

Tel: +44 207 940 8718Fax: +44 870 420 3601

Xpress Optimization, FICOFICO HouseInternational SquareStarley WayBirmingham B37 7GNUK

Related services

Strategy Consulting: Included in your contract with FICO may be a specified amount ofconsulting time to assist 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.

About FICO

FICO (NYSE:FICO) delivers superior predictive analytics solutions that drive smarter decisions. Thecompany’s groundbreaking use of mathematics to predict consumer behavior has transformedentire industries and revolutionized the way risk is managed and products are marketed. FICO’sinnovative solutions include the FICO® Score—the standard measure of consumer credit risk inthe United States—along with industry-leading solutions for managing credit accounts,identifying and minimizing the impact of fraud, and customizing consumer offers with pinpointaccuracy. Most of the world’s top banks, as well as leading insurers, retailers, pharmaceuticalcompanies, and government agencies, rely on FICO solutions to accelerate growth, control risk,boost profits, and meet regulatory and competitive demands. FICO also helps millions ofindividuals manage their personal credit health through www.myfico.com. Learn more atwww.fico.com. FICO: Make every decision countTM.

Fair Isaac Corporation Confidential and Proprietary Information 21

Page 26: FICO Xpress Optimization mosjvm Module for MoselIntroduction The mosjvm module allows you to create a Java virtual machine within the same process running Mosel, and call static Java

Index

Aargument types, 2arguments, 9, 10arrays, 2, 5, 10

Ccall status, 17CLASSPATH, 3

DDMP, 6double function call, 13

Eexception class, 17exceptions, 3

FFAC, 6FICO Analytic Cloud, 6

Hheap size

initial, 18maximum, 18

Iint function call, 12

JJava search path, 3JAVA_HOME, 3JVM, 6jvmcall<type>, 2jvmcallint, 12jvmcallreal, 13jvmcallstatus, 3jvmcallstatus, 17jvmcallstr, 14jvmcalltext, 15jvmcallvoid, 16jvmdebug, 3jvmdebug, 18jvmexceptionmsg, 3jvmexceptionmsg, 17jvmexceptiontype, 3jvmexceptiontype, 17jvmloadverbose, 18jvmxms, 18jvmxmx, 18

LLinux, 6

logging, 18

MMOSEL_RESTR, 7MOSEL_RESTR, 7MOSJVM_CLASSPATH, 3MOSJVM_JAVA_HOME, 3

Rrestrictions, 7return types, 5

Sstack trace, 18String function call, 14, 15supported platforms, 6System.err, 5System.exit, 6System.out, 5

TThreadLocal, 6threads, 6

Uunload, 6

Vvoid function call, 16

WWindows, 6workdir, 5working directory, 5

XXPRM, 6

Fair Isaac Corporation Confidential and Proprietary Information 22