nl_param_random: Create random parameter sets within parameter ranges

Description Usage Arguments Details Value Examples

Description

Create parameter sets with Latin Hypercube sampling or monte carlo

Usage

1
2
3
4
5

Arguments

n

Number of parameter sets

...

Parameters with ranges (numeric vectors) or a data frame with parameters as columns or a list of parameter values

FUN

A function with parameters n and k, returns a matrix with k columns and numeric double values in range from 0 to 1

Details

nl_param_lhs returns n parameter value sets with LHC sampling. It uses lhs::randomLHS function and requires lhs package.

nl_param_mc returns n parameter value sets with random parameters.

nl_param_random returns n parameter value sets with custom defined method.

Value

A data frame with parameter value sets

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
experiment <- nl_experiment(
  model_file = "models/Sample Models/Biology/Flocking.nlogo",
  setup_commands = c("setup", "repeat 100 [go]"),
  iterations = 5,

  param_values = nl_param_lhs(
    n = 100,                           # create 100 parameter value sets
    world_size = 50,
    population = 80,
    vision = 6,
    min_separation = c(0, 4),
    max_align_turn = c(0, 20)
  ),
  mapping = c(
    min_separation = "minimum-separation",
    max_align_turn = "max-align-turn"),

  step_measures = measures(
    converged = "1 -
    (standard-deviation [dx] of turtles +
    standard-deviation [dy] of turtles) / 2",
    mean_crowding =
      "mean [count flockmates + 1] of turtles"
  ),
  eval_criteria = criteria(
    c_converged = mean(step$converged),
    c_mcrowding = mean(step$mean_crowding)
  ),

  repetitions = 10,                        # repeat simulations 10 times
  random_seed = 1:10,

  eval_aggregate_fun = mean                # aggregate over repetitions
)

# custom sampling method must return a n x k matrix:
nl_param_random(
 n = 5,
 foo = c(1, 2),
 bar = c(100, 200),
 baz = 4,
 FUN = function(n, k) matrix(runif(n*k), ncol = k)
)

bergant/nlexperiment documentation built on May 12, 2019, 3:05 p.m.