MoleTask, ExplorationTask and ScalaTask chaining

tasks

(Julien Perret) #1

Hey,

I’m trying to write a simple example of ExplorationTask and ScalaTask chaining.

The idea is that you have a first exploration and a first scala task and then a second exploration on the results of the first task and a second scala task.

My first workflow looks like this (took me a little while to understand I had to remember to forward the outputs of the first task):

First Workflow
// Declare the variables
val d = Val[Double]
val x = Val[Double]
// Define the tasks
val t1 = ScalaTask("d = d * 2") set ( inputs += d, outputs += d )
val t2 = ScalaTask("d = d + x") set ( inputs += (d,x), outputs += d )
// Define the exploration strategies
val exploration = ExplorationTask( d in (0.0 to 99.0 by 10.0) )
val exploration2 = ExplorationTask( x in (0.0 to 9.0 by 1.0) ) set ((inputs,outputs) += d)
// Run
exploration -< (t1 -- (exploration2 -< (t2 hook ToStringHook())))

By the way, if you have a better way of doing this, I’ll take it!
Then, I thought I would try to make it cleaner by using a MoleTask:

Second Workflow
// Declare the variables
val d = Val[Double]
val x = Val[Double]
// Define the tasks
val t1 = ScalaTask("d = d * 2") set ( inputs += d, outputs += d )
val t2 = ScalaTask("d = d + x") set ( inputs += (d,x), outputs += d )
// Define the exploration strategies
val exploration = ExplorationTask( d in (0.0 to 99.0 by 10.0) )
val exploration2 = ExplorationTask( x in (0.0 to 9.0 by 1.0) ) set ((inputs,outputs) += d)
val moleTask = MoleTask(exploration2 -< (t2 hook ToStringHook()))
// Run
exploration -< (t1 -- moleTask)

Unfortunately, this doesn’t print anything. What did I miss?
Thanks!


#2

For the first one, something like that should work (100% untested code here):

// Declare the variables
val d = Val[Double]
val x = Val[Double]
// Define the tasks
val t1 = ScalaTask("d = d * 2") set ( inputs += d, outputs += d )
val t2 = ScalaTask("d = d + x") set ( inputs += (d,x), outputs += d )

// Define the exploration strategies
DirectSampling (
  sampling = d in (0.0 to 99.0 by 10.0),
  evaluation = 
    t1 -- DirectSampling (
       sampling = x in (0.0 to 9.0 by 1.0),
       evaluation = t2 hook ToStringHook()
    )
)

For the second you are just missing a hook :pick:.


(Julien Perret) #3

That is definitely better, thanks!