You can program tasks in Scala using the ScalaTask
. For instance the following workflow sums all the elements of an array using a ScalaTask
and displays the results. Similarly, you could use such a task to generate some model parameter values or perform some data analysis. To get more details on the hook part you can check the doc on hooks.
val array = Val[Array[Double]]
val result = Val[Double]
val sum = ScalaTask("val result = array.sum") set (
inputs += array,
outputs += result,
array := Array(8.0, 9.0, 10.0)
)
(sum hook ToStringHook())
You can embed you own Scala/Java code and libraries in OpenMOLE using an OpenMOLE Plugin.
Multiple ScalaTasks can be joined to compose a workflow. Lets imagine that you want to perform an expensive computation on every element of an array. For the sake of simplicity, the "expensive computation" is here a multiplication by 2.
val element = Val[Double]
val multiplied = Val[Double]
val result = Val[Double]
val expensive = ScalaTask("val multiplied = element * 2") set (
inputs += element,
outputs += multiplied
)
val exploration = ExplorationTask(element in List(8.0, 9.0, 10.0))
val sum = ScalaTask("val result = multiplied.sum") set (
inputs += multiplied.toArray,
outputs += result
)
exploration -< expensive >- (sum hook ToStringHook())
The execution of this workflow can be distributed using OpenMOLE's environments. Check the page dedicated to environments to learn more on this process.