Skip to content
martinssonj edited this page Oct 8, 2012 · 2 revisions

This example is an extension of the relative parameter definition example. Say, the result of a calculation should be exported in order to be plotted, or analyzed statistically. The export can easily be handled, using InPUT. This example shows how a parameterized calculation is being repeated 100 times and exported to an output result space.

Reading in the first DesignSpace

IDesignSpace ds = new DesignSpace("relativeSpace.xml");

Generating random values according to the DesignSpace and making calculations

Object[][] results = new Object[10][100];

IDesign design;
	for (int i = 0; i < results.length; i++) {
		for (int j = 0; j < results[i].length; j++) {
			esign = ds.nextDesign("someId"); 	//Generating random values

			double a = design.getValue("a");
			double b = design.getValue("b");

			results[i][j] = (a / b) - 1; 		//Calculation
			System.out.println(results[i][j]);
		}
	}

Changing DesignSpace

Creating a new DesignSpace according to the array of results Creating a Design from the DesignSpace and fill with the results from the calculations

IDesignSpace resultSpace = new DesignSpace("resultSpace.xml"); 		
IDesign resultDesign = resultSpace.nextEmptyDesign("someResult"); 	
resultDesign.setValue("y", results);								

Export the output design to an xml

resultDesign.export(new XMLFileExporter("randomDesignResults.xml"));//Exporting results to a XML-file

Examplecode can be found at se.miun.itm.input.example.result.ResultExample.java.