Commit 6042839e authored by Romain Reuillon's avatar Romain Reuillon
Browse files

[Doc] enh: use new syntax for direct sampling

parent 8e800ccf
......@@ -21,11 +21,11 @@
@br @hl.code("""
val exploration =
DirectSampling(
evaluation = myModel on env,
evaluation = myModel,
sampling = mySampling
)
val ex = exploration start""")
val ex = (exploration on env) start""")
@p Using the ex and the env variables you can follow the progress of the execution by using the commands: print(ex) and print(env). To cancel the execution you should use: ex.cancel.
......
......@@ -126,7 +126,7 @@ val hello = ScalaTask("val j = myopenmoleplugin.Hello.world(i)") set (
)
DirectSampling(
evaluation = hello hook ToStringHook(),
evaluation = hello,
sampling = i in (0 to 2)
)
) hook ToStringHook()
""", header = "object myopenmoleplugin { object Hello {} }")
......@@ -121,8 +121,8 @@ generating a new pair. OpenMOLE implements the @hl.code("ZipWithIndexSampling")
DirectSampling(
sampling = file in (workDirectory / "dir") withName name,
evaluation = (t hook ToStringHook())
)""", name = "zip with name sampling")
evaluation = t
) hook ToStringHook()""", name = "zip with name sampling")
@p If you need to go through several levels of files you may use a sampling like this one:
......@@ -144,9 +144,8 @@ generating a new pair. OpenMOLE implements the @hl.code("ZipWithIndexSampling")
sampling =
(dir in (workDirectory / "test") withName dirName) x
(file in dir withName fileName),
evaluation = t hook ToStringHook()
)
""", name = "multilevel file sampling")
evaluation = t
) hook ToStringHook()""", name = "multilevel file sampling")
@h3{Take, filter, sample samplings}
......@@ -233,8 +232,8 @@ Some sampling combinations generates higher level samplings such as @hl.code("re
DirectSampling(
sampling = (f1 x f2) bootstrap (5, 10),
evaluation = stat hook ToStringHook()
)
evaluation = stat
) hook ToStringHook()
""", name = "bootstrap example sampling")
......
......@@ -51,9 +51,9 @@ val myModel =
// Define the exploration of myModel for various i values sampled in the file.
val exploration = DirectSampling(
evaluation = myModel hook ToStringHook() ,
evaluation = myModel,
sampling = s
)
) hook ToStringHook()
exploration
......
......@@ -101,10 +101,10 @@ val average =
val exploration =
DirectSampling(
evaluation = myModel hook ToStringHook(),
evaluation = myModel,
sampling = i in (0 to 10 by 1),
aggregation = average hook ToStringHook()
)
aggregation = average
) hook ToStringHook()
exploration""", name="concrete example of direct sampling")
......
......@@ -28,9 +28,9 @@ val my_model = EmptyTask() set( (inputs, outputs) += my_input)
val exploration =
DirectSampling(
evaluation = my_model hook ToStringHook(),
evaluation = my_model,
sampling= (my_input in (UniformDistribution[Double](max=20) take 100)).map(x => x -10)
)
) hook ToStringHook()
exploration""", name = "uniform sampling example")
......
......@@ -23,9 +23,9 @@ Let's consider this simple workflow:
val h = ToStringHook()
DirectSampling(
evaluation = (hello hook h),
evaluation = hello,
sampling = i in (0 to 9)
)""", name = "plug a hook")
) hook h""", name = "plug a hook")
@br
......
......@@ -192,9 +192,9 @@ val copy = CopyFileHook(resultFile, outputPath)
DirectSampling(
sampling = parameter in (0 to 100),
evaluation = writeTask hook copy,
evaluation = writeTask,
condition = !outputPath.exists || outputPath.isEmpty
)""")
) hook copy""")
......
......@@ -99,11 +99,11 @@ OpenMOLE makes the inclusion of your own Java code in a workflow simple. Since t
val csvHook = AppendToCSVFileHook(workDirectory / "result.csv")
DirectSampling(
evaluation = javaTask hook csvHook,
evaluation = javaTask,
sampling =
(arg1 in (0.0 to 10.0 by 1.0)) x
(arg2 in (0.0 until 10.0 by 1.0))
)""")
) hook csvHook""")
@p
This workflow will call the function @i{hello} with both arguments varying from 0 to 10 and save the results in a CSV file. Variables @i{arg1} and @i{arg2} are specified in the task output so that they are also written to the CSV file by the hook (see @aa("Hooks", href := DocumentationPages.hook.file))
......@@ -169,9 +169,9 @@ OpenMOLE makes the inclusion of your own Java code in a workflow simple. Since t
)
DirectSampling(
evaluation = javaTask hook copyHook,
evaluation = javaTask,
sampling = proto1 in (0 to 10)
)""")
) hook copyHook""")
@p
For this example to work you should create a file named "input.txt" in the work directory of your project.
......
......@@ -193,14 +193,13 @@ $netlogo
$csvHook
DirectSampling(
evaluation = fireTask hook csvHook,
evaluation = fireTask,
sampling = sampling
)""", name = "netlogo full workflow")
) hook csvHook""", name = "netlogo full workflow")
At the end of the execution, you will find the output values in a file called @i{result.csv}.
@h2{Headless NetLogo model}
The Netlogo combines a GUI created by the user, in which he can define parameters and run functions, which the source code in itself.
......@@ -296,9 +295,6 @@ used directly in OpenMOLE.
@h2{Tutorials}
@p More examples of working with NetLogo models can be found in specific tutorials.
......
......@@ -103,6 +103,6 @@ Your OpenMOLE script would look like that:
// It says: explore the lines and run a model execution for each one, save the outputs, all that on the cluster
// (results are not brought back to the local computer yet).
DirectSampling(
evaluation = my_model_execution on env hook catch_output,
evaluation = my_model_execution,
sampling = all_the_lines
)""")
) on env hook catch_output""")
......@@ -88,9 +88,9 @@ val hello = ScalaTask("val j = myopenmoleplugin.Hello.world(i)") set (
)
DirectSampling(
evaluation = hello hook ToStringHook(),
evaluation = hello,
sampling = i in (0 to 2)
)
) hook ToStringHook()
""", header = "object myopenmoleplugin { object Hello {} }")
@h2("Workflow example")
......@@ -115,8 +115,8 @@ val sum = ScalaTask("val result = multiplied.sum") set (
DirectSampling (
evaluation = expensive,
sampling = element in List(8.0, 9.0, 10.0),
aggregation = sum hook ToStringHook()
)""")
aggregation = sum
) hook ToStringHook()""")
@p
The execution of this workflow can be distributed using OpenMOLE's environments. Check the page dedicated to @a("environments", href := DocumentationPages.scale.file) to learn more on this process.
......
......@@ -344,9 +344,8 @@ DirectSampling(
sampling =
(dataFile in (workDirectory / "data") withName dataFileName) x
(i in (0 to 3)),
evaluation =
container hook CopyFileHook(resultFile, workDirectory / "results/$${dataFileName.dropRight(4)}_$${i}.csv")
)
evaluation = container
) hook CopyFileHook(resultFile, workDirectory / "results/$${dataFileName.dropRight(4)}_$${i}.csv")
""")
......
......@@ -38,9 +38,9 @@ val copy = CopyFileHook(output, workDirectory / "hello${arg}.txt")
val env = LocalEnvironment(4)
DirectSampling(
evaluation = pythonTask hook copy on env by 2,
evaluation = pythonTask,
sampling = arg in (0 to 10)
)""")
) hook copy on env by 2""")
@p Notions from OpenMOLE are reused in this example. If you're not too familiar with @a("Environments", href := DocumentationPages.scale.file), @a("Groupings", href := DocumentationPages.scale.file + "#Grouping"), @a("Hooks", href := DocumentationPages.hook.file) or @a("Samplings", href := DocumentationPages.directSampling.file), check the relevant sections of the documentation.
......
......@@ -34,9 +34,9 @@ val env = LocalEnvironment(10)
// Make the model run on the the local environment
DirectSampling(
evaluation = model on env hook ToStringHook(),
evaluation = model,
sampling = i in (0.0 to 100.0 by 1.0)
)""")
) on env hook ToStringHook()""")
@p You do not need to install anything or perform any kind of configuration on the target execution environment for
OpenMOLE to work. It reuses the infrastructure in place. You will however be required to provide the authentication
......@@ -58,9 +58,9 @@ $tasks
// Make the model run on the the local environment
DirectSampling(
evaluation = model on env by 100 hook ToStringHook(),
evaluation = model,
sampling = i in (0.0 to 1000.0 by 1.0)
)
) on env by 100 hook ToStringHook()
""", header = """
val env = LocalEnvironment(10)
""")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment