nl_eval_run: Evaluate experiment with specific parameters

Description Usage Arguments Details Examples

Description

Function nl_eval_run runs experiment as with nl_run but requires started NetLogo instance with loaded model.

Function nl_eval_init starts NetLogo instance and loads the NetLogo model. When using parallel version it initializes several processes and returns cluster objects

Function nl_eval_close stops NetLogo instance

Function nl_get_eval_fun returns a function wich calls nl_eval_run but does not need additional parameters.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
nl_eval_run(param_set, experiment, criteria = NULL, print_progress = FALSE,
  call_back = NULL, parallel = FALSE, cluster = NULL,
  param_names = NULL)

nl_eval_init(experiment, parallel = FALSE, max_cores = NULL)

nl_eval_close(parallel = FALSE, cluster = NULL)

nl_get_eval_fun(experiment, param_names, parallel = FALSE, cluster = NULL,
  criteria, call_back = NULL)

Arguments

param_set

parameter set (a list of parameters with values)

experiment

NetLogo experiment object (see nl_experiment)

criteria

Which experiment evaluation criteria to be returned

print_progress

print evaluation progress

call_back

A call-back function for tracing result in optimization processes

parallel

If TRUE nl_eval_init returns cluster object which should be passed to nl_eval_run and nl_eval_close.

cluster

Required for parallel execution (nl_eval_init returns cluster object)

param_names

parameter names for parameter set

max_cores

If not defined all available cores are used.

Details

Use nl_eval_run when parameter set depend on previous evaluation (parameter fitting / callibration / optimization methods). It can use the same experiment object as nl_run function. Evaluation criteria should be defined. (see nl_experiment or nl_set_measures).

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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
## Not run: 

  experiment <- nl_experiment(
    model_file = "models/Sample Models/Biology/Flocking.nlogo",

    setup_commands = c("setup", "repeat 100 [go]"),
    iterations = 5,

    param_values = list(
      world_size = 50,
      population = 80,
      vision = 6,
      min_separation = seq(from = 0, to = 4, by = 0.5),
      max_align_turn = seq(from = 0, to = 20, by = 2.5)
    ),
    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

    eval_aggregate_fun = mean,        # aggregate over repetitions

    eval_mutate = criteria(           # evaluation criterium
      eval_value =
        sqrt((c_mcrowding - 8)^2 + 400*(c_converged - 1)^2)
    )
 )

 library(dfoptim)

 cl <- nl_eval_init(experiment, parallel = TRUE)
 trace <- nl_eval_tracer(verbose = FALSE)
 param_range <- nl_get_param_range(experiment)
 set.seed(1)

 o_result <- nmkb(
   par = (param_range$upper + param_range$lower)/2,
   fn = nl_eval_run,
     experiment = experiment,
     criteria = "eval_value",
     call_back = trace$add,
     parallel = TRUE, cluster = cl,
     param_names = names(param_range$lower),
   lower = param_range$lower,
   upper = param_range$upper,
   control = list(maxfeval = 200)
 )
 nl_eval_close(parallel = TRUE, cl)

## End(Not run)

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