Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
openmole
market
Commits
9154a071
Commit
9154a071
authored
Mar 06, 2020
by
Romain Reuillon
Browse files
Adapt GAMA example to the new GAMATask
parent
2f0ba210
Changes
1
Hide whitespace changes
Inline
Side-by-side
gama/PredatorPrey.oms
View file @
9154a071
// 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)
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment