FICO
FICO Xpress Optimization Examples Repository
FICO Optimization Community FICO Xpress Optimization Home
Back to examples browserPrevious exampleNext example

Passing an array from a Mosel model to a Java method

Description
Demonstrates constructing an array of reals in a Mosel model, then passing this to a Java method which returns the sum of the values, and finally displaying the returned sum from Mosel. You must compile the Java file before running the example - e.g. javac PassArray.java

mosjvm_passingarrays.zip[download all files]

Source Files
By clicking on a file name, a preview is opened at the bottom of this page.
passarray.mos[download]
PassArray.java[download]





PassArray.java

/**
 * Example Java class, containing a method that returns a value based on an array passed to it
 *
 * @author  J.Farmer, (c) Fair Isaac Corporation, 2016
 **/
public class PassArray {
	public static double sumValues(double[] values) {
		double sum = 0;
		for (int i=0;i<values.length;i++) {
			sum += values[i];
		}
		return sum;
	}
}
Back to examples browserPrevious exampleNext example