Giter VIP home page Giter VIP logo

nlexperiment's People

Contributors

bergant avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

bachl stjordanis

nlexperiment's Issues

Mac support?

nlexperiment looks supremely promising. However, I am getting errors that make me think it may be lacking minimum features to support macs and unix. Is this true? Do you have plans to expand nlexperiment to mac and unix?

Thanks!

Include "step" always in output

Hi, first of all, thank you for a really cool package!

I have just I minor suggestion: At the moment, the definition of agent_reports or eval_criteria causes the output not to include the step_measures. I would find it much more convenient to always include all defined measures at all levels in the output. This can be easily done by changing two lines of "nlrun.R". I have made the changes in a fork (https://github.com/bachl/nlexperiment/blob/master/R/nlrun.R) and can provide a pull request, if this is more convenient for you.

Best,
Marko

Error when trying to optimize Netlogo model

Hi,
I would like to use nlexperiment to fit a Netlogo model to data. I am able to run the model, do a sensitivity analysis etc. but as soon as I tried to use optim or nmkb I run into troubles with my own model. The example at the website does work.
When I am trying to fit my own code (I was testing so it is a fairly simple Netlogo-model for an infection going through a population) to some fake data, I run into troubles as I get the following error message for which I do not know what to do:

[1] "Java-Object{Nothing named EXPERIMENT$PARAM_SETS has been defined. at position 37 in }"
Error in RNetLogo::NLCommand(sprintf("set %s %s", nl_param, param_value)) :

Thanks,

Egil Fischer

My R-code looks as follows:
`fit.data
'# time inf cur
'# 1 0 0.010000000 0.00000000
'# 2 2 0.038478868 0.01276641
'# 3 5 0.199355083 0.10651282
'# 4 7 0.327192178 0.26911589
'# 5 10 0.285740281 0.56237504
'# 6 12 0.198824897 0.70756273
'# 7 15 0.100935272 0.83857641
'# 8 17 0.061902226 0.88654818
'# 9 20 0.029060006 0.92569697
'# 10 30 0.002204088 0.95704138

nl_netlogo_path("C:/Program Files/NetLogo 6.0/app")
NLStart(nl.path = "C:/Program Files/NetLogo 6.0/app", nl.jarname = "netlogo-6.0.0.jar", gui = F)

experiment <- nl_experiment(
model_file = "D:/SURFdrive/Rekenclusters/TestModel/epiDEM.nlogo",

setup_commands = c("setup", "repeat 1 [go]" ),

iterations = 30,

param_values = list(
initial_people = 100,
infection_chance = seq(from = 0, to = 30, by = 10),
average_recovery_time = seq(from = 100, to = 400, by = 100)
),

step_measures = measures(
infected = "count turtles with [infected?]",
cured = "count turtles with [cured?]"
),

eval_criteria = criteria(
c_infected = sum((step$infected[step$step_id == round(times/10)] - (fit.data$inf100))^2),
c_cured = sum((step$cured[step$step_id == round(times/10)] - (fit.data$cur
100))^2)
),

repetitions = 2,                 # repeat simulations 10 times

eval_aggregate_fun = sum, # aggregate over repetitions

eval_mutate = criteria( # evaluation criterium
eval_value =
sqrt(c_infected + c_cured)
)
)

result <- nl_run(experiment, print_progress = T, parallel = F,gui = F)
'#works fine

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

'# the following command produces the error.
o_result <- optim(
par = (param_range$upper + param_range$lower)/2,
nl_eval_run,
experiment = experiment,
criteria = "eval_value",
call_back = trace$add,
parallel = FALSE, cluster = cl,
method = "L-BFGS-B",
lower = param_range$lower,
upper = param_range$upper,
control = list(maxit = 200, trace = 1))

tr <- trace$get()
nl_eval_close(cl)
`
Some additional info:
Netlogo = version 6.0.0
OS = Windows 7

R.version
_
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 3
minor 4.0
year 2017
month 04
day 21
svn rev 72570
language R
version.string R version 3.4.0 (2017-04-21)
nickname You Stupid Darkness

Not working with NetLogo versions >= 6.1.0

I re-ran some older code which worked (and still works) just fine with NetLogo 6.0.4. As I had to download NetLogo anyway, I got the latest version (6.1.1). The example from the manual

nl_netlogo_path("/Applications/NetLogo 6.1.1/Java/") 
experiment <- nl_experiment(
  model_file = "/Applications/NetLogo 6.1.1/models/Sample Models/Earth Science/Fire.nlogo", 
  while_condition = "any? turtles",
  param_values = list(density = c(57, 59, 61)),
  random_seed = 1,
  step_measures = measures(
    percent_burned = "(burned-trees / initial-trees) * 100"
  )
)
result <- nl_run(experiment)  

resulted in the error

[1] "Java-Object{java.lang.IllegalStateException: unknown NetLogo version: NetLogo 6.1.1}"

I did not investigate the issue any further, because NetLogo 6.0.4 works fine for me.

> sessionInfo()
R version 3.6.2 (2019-12-12)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Catalina 10.15.3

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

locale:
[1] de_DE.UTF-8/de_DE.UTF-8/de_DE.UTF-8/C/de_DE.UTF-8/de_DE.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] nlexperiment_0.2.2.9000

loaded via a namespace (and not attached):
 [1] igraph_1.2.4.2   Rcpp_1.0.3       rstudioapi_0.11  magrittr_1.5     tidyselect_1.0.0 munsell_0.5.0   
 [7] colorspace_1.4-1 R6_2.4.1         rlang_0.4.4      stringr_1.4.0    plyr_1.8.5       dplyr_0.8.4     
[13] tools_3.6.2      grid_3.6.2       packrat_0.5.0    gtable_0.3.0     lazyeval_0.2.2   assertthat_0.2.1
[19] tibble_2.1.3     lifecycle_0.1.0  crayon_1.3.4     RNetLogo_1.0-4   rJava_0.9-11     farver_2.0.3    
[25] reshape2_1.4.3   purrr_0.3.3      ggplot2_3.2.1    glue_1.3.1       labeling_0.3     stringi_1.4.6   
[31] compiler_3.6.2   pillar_1.4.3     scales_1.1.0     pkgconfig_2.0.3 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.