Mercurial > repos > siwaa > redelac_stics_s
comparison redelacSticsSimulator.R @ 4:70ae7516e925 draft
"planemo upload for repository https://forgemia.inra.fr/redelac/redelac-toolbox/-/tree/94d9549470e1fe96ae832b04bea58b2f1c5663fc/tools/REDELACSticsSimulator commit 94d9549470e1fe96ae832b04bea58b2f1c5663fc-dirty"
author | siwaa |
---|---|
date | Tue, 27 Jun 2023 06:47:30 +0000 |
parents | f262814e48a3 |
children | 41f652e6616f |
comparison
equal
deleted
inserted
replaced
3:f262814e48a3 | 4:70ae7516e925 |
---|---|
6 | 6 |
7 workspace <- paste0(getwd(), "/WS") | 7 workspace <- paste0(getwd(), "/WS") |
8 javastics_path <- getwd() | 8 javastics_path <- getwd() |
9 default_config_path <- paste0(javastics_path, "/config") | 9 default_config_path <- paste0(javastics_path, "/config") |
10 | 10 |
11 # copy of the var.mod and rap.mod into the config folder | |
12 # generalizing maybe should be inside a config folder | |
13 | |
14 #file.copy(from = file.path(workspace, "var.mod"), | |
15 # to = file.path(default_config_path, "var.mod"), | |
16 # overwrite = TRUE) | |
17 #file.copy(from = file.path(workspace, "rap.mod"), | |
18 # to = file.path(default_config_path, "rap.mod"), | |
19 # overwrite = TRUE) | |
20 | |
21 txt_path <- paste0(getwd(), "/WS/txt_files") | 11 txt_path <- paste0(getwd(), "/WS/txt_files") |
22 #dir.create(txt_path,recursive = T) | |
23 | |
24 #gen_usms_xml2txt(javastics = javastics_path, | |
25 # workspace = workspace, | |
26 # out_dir = txt_path, | |
27 # check = FALSE) | |
28 | 12 |
29 print("==================================") | 13 print("==================================") |
30 | 14 |
31 print(paste0("Cores=", detectCores())) | 15 print(paste0("Cores=", detectCores())) |
32 print(paste0("javastics=", javastics_path)) | 16 print(paste0("javastics=", javastics_path)) |
33 print(paste0("ws=", workspace)) | 17 print(paste0("ws=", workspace)) |
34 print(paste0("out_dir=", txt_path)) | 18 print(paste0("out_dir=", txt_path)) |
35 | 19 |
36 print("==================================") | 20 print("==================================") |
37 | |
38 | 21 |
39 # List of successive USMs | 22 # List of successive USMs |
40 successive_usms_file <- ("successionPlan.csv") | 23 successive_usms_file <- ("successionPlan.csv") |
41 successive_usms_tab <- read.csv(file = file.path(workspace, successive_usms_file), sep =";") | 24 successive_usms_tab <- read.csv(file = file.path(workspace, successive_usms_file), sep =";") |
42 | 25 |
49 | 32 |
50 #result <- foreach(i=1:nrow(successive_usms_tab), | 33 #result <- foreach(i=1:nrow(successive_usms_tab), |
51 # .packages = c("SticsRFiles", "SticsOnR") ) %dopar% { | 34 # .packages = c("SticsRFiles", "SticsOnR") ) %dopar% { |
52 for(i in 1:nrow(successive_usms_tab)) { | 35 for(i in 1:nrow(successive_usms_tab)) { |
53 | 36 |
54 print(paste("coucou ", i)) | |
55 nusms <- as.numeric(successive_usms_tab[i,2]) | 37 nusms <- as.numeric(successive_usms_tab[i,2]) |
56 print(paste0("coco ", nusms)) | |
57 | 38 |
58 vec <- as.character(successive_usms_tab[i,c(3:(2+nusms))]) | 39 vec <- as.character(successive_usms_tab[i,c(3:(2+nusms))]) |
59 | 40 |
60 list_successive_usms <- list(vec) | 41 list_successive_usms <- list(vec) |
61 | 42 |
63 stics_exe = paste0(javastics_path,"/bin/stics_modulo"), | 44 stics_exe = paste0(javastics_path,"/bin/stics_modulo"), |
64 workspace = txt_path, | 45 workspace = txt_path, |
65 verbose = TRUE, | 46 verbose = TRUE, |
66 successive = list_successive_usms) | 47 successive = list_successive_usms) |
67 list_usms <- vec | 48 list_usms <- vec |
68 | 49 |
69 result = append(result, stics_wrapper(model_options = sim_options, situation = list_usms)) | 50 singleResult = stics_wrapper(model_options = sim_options, situation = list_usms) |
51 | |
52 result = append(result, list(singleResult)) | |
70 } | 53 } |
71 | 54 |
72 #stopCluster(cl) | 55 #stopCluster(cl) |
73 | 56 |
74 for (i in 1:nrow(successive_usms_tab)) { #i=1 | 57 for (i in 1:nrow(successive_usms_tab)) { #i=1 |
75 if (i == 1) { | 58 if (i == 1) { |
76 simPCP <- result[[i]] | 59 simPCP <- result[[i]] |
77 } else { | 60 } else { |