Commit 9154a071 authored by Romain Reuillon's avatar Romain Reuillon
Browse files

Adapt GAMA example to the new GAMATask

parent 2f0ba210
// Declare the variable
val numberOfPreys = Val[Int]
val numberOfPreysAvg = Val[Double]
val numberOfPreys = Val[Double]
val nbPreysInit = Val[Int]
val seed = Val[Int]
val seed = Val[Long]
// Gama task
// The first argument is the gaml
// The second argument of the GamaTask is the gama experiment name
// The third argument is the number of steps
val gama =
GamaTask(workDirectory / "predatorPrey.gaml", "prey_predatorExp", maxStep = 10) set (
gamaInputs += (nbPreysInit, "nb_preys_init"),
gamaSeed := seed,
gamaOutputs += ("nb_preys", numberOfPreys)
GAMATask(workDirectory / "predatorPrey.gaml", "prey_predatorExp", finalStep = 100, seed = seed) set (
inputs += (nbPreysInit mapped "nb_preys_init"),
outputs += (numberOfPreys mapped "Number of preys")
)
// Compute the average among the simulations
val average =
ScalaTask("val numberOfPreysAvg = numberOfPreys.map(_.toDouble).average") set (
inputs += numberOfPreys.toArray,
outputs += numberOfPreysAvg,
(inputs, outputs) += nbPreysInit
)
//Store the results
val csvHook = CSVHook(workDirectory / "result.csv", nbPreysInit, numberOfPreysAvg)
// Explore and replicate the model
DirectSampling(
evaluation = Replication(gama, seed, 10, aggregation = average hook csvHook),
sampling = nbPreysInit in (0 to 200 by 10)
)
evaluation =
Replication(
evaluation = gama,
seed = seed,
replications = 10,
aggregation = Seq(numberOfPreys aggregate average)) hook(workDirectory / "result.csv"),
sampling = nbPreysInit in (0 to 200 by 50)
)
Markdown is supported
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