Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
SimAquaLife
GR3D
Commits
54962b4b
Commit
54962b4b
authored
Apr 23, 2021
by
patrick.lambert
Browse files
last version
parent
ecd192a5
Changes
1
Hide whitespace changes
Inline
Side-by-side
exploration/NEA_sensitivity_analysis/tryFromJava.R
View file @
54962b4b
...
...
@@ -5,14 +5,14 @@ library(tidyverse)
library
(
jdx
)
library
(
tictoc
)
rm
(
list
=
ls
())
rm
(
list
=
ls
())
## to have the same working directory as GR3D
#setwd("~/Documents/workspace/GR3D/exploration/NEA_sensitivity_analysis")
setwd
(
"../.."
)
source
(
"exploration/GR3D_Rdescription/GR3Dmetapopulation.R"
)
# ====================================== LOCAL FUNCTIONS =====================================
convertFromSALtoR
=
function
(
java_out
){
require
(
jdx
)
...
...
@@ -81,7 +81,10 @@ exploreEasyRun = function(){
mutate
(
year
=
0
)
%>%
rename
(
originBasin
=
natalBasin
)
%>%
identyMetapopulation
(
.
,
threshold
=
.95
,
verbose
=
FALSE
)
nbMetapopulation
=
metapopulations
$
metapopulation
%>%
distinct
(
metapop
)
%>%
summarise
(
n
=
n
())
nbMetapopulation
=
metapopulations
$
metapopulation
%>%
distinct
(
metapop
)
%>%
summarise
(
n
=
n
())
%>%
unlist
(
use.names
=
FALSE
)
return
(
tibble
(
northern_basin_id
=
range
$
northern_basin_id
,
effective_centroid_latitude
=
range
$
effective_centroid_latitude
,
...
...
@@ -95,36 +98,37 @@ exploreEasyRun = function(){
# GR3D arguments -----------------------------------------
jarfile
=
"target/GR3D-3.2-SNAPSHOT.jar"
simDuration
=
150
simBegin
=
1
timeStepDuration
=
1
seed
=
1
#'-q',
arguments
=
c
(
'-simDuration'
,
simDuration
,
'-simBegin'
,
simBegin
,
'-timeStepDuration'
,
timeStepDuration
,
'-RNGStatusIndex'
,
format
(
seed
,
scientific
=
FALSE
),
'-groups'
,
"data/input/northeastamerica/fishRIOBasin_Sapidissima_Rjava.xml"
,
'-env'
,
"data/input/northeastamerica/RIOBNneaBasins_Rjava.xml"
,
'-observers'
,
"data/input/northeastamerica/RIO_obs_empty.xml"
)
#'
jarfile = "target/GR3D-3.2-SNAPSHOT.jar"
#'
simDuration = 150
#'
simBegin = 1
#'
timeStepDuration = 1
#'
#'
seed = 1
#'
#'-q',
#'
arguments = c('-simDuration', simDuration, '-simBegin',simBegin,
#'
'-timeStepDuration', timeStepDuration,
#'
'-RNGStatusIndex', format(seed,scientific = FALSE),
#'
'-groups',"data/input/northeastamerica/fishRIOBasin_Sapidissima_Rjava.xml",
#'
'-env',"data/input/northeastamerica/RIOBNneaBasins_Rjava.xml",
#'
'-observers',"data/input/northeastamerica/RIO_obs_empty.xml")
# -----------------------------------------------------
# initializes the Java Virtual Machine -------------------------------------
jarfile
=
"target/GR3D-3.2-SNAPSHOT.jar"
.jinit
(
NULL
,
force.init
=
TRUE
)
.jinit
(
classpath
=
jarfile
,
force.init
=
TRUE
)
.jclassPath
()
# modification of xlm parameters -----------------------
parametersNamesANG
=
c
(
"processes.processesEachStep.11.Soffset"
)
thetasANG
=
c
(
-1
)
parametersNamesENV
=
c
(
"simulationName"
)
thetasENV
=
c
(
"Allee"
)
#
parametersNamesANG = c("processes.processesEachStep.11.Soffset")
#
thetasANG = c(-1)
#
#
parametersNamesENV = c("simulationName")
#
thetasENV = c("Allee")
# run the GR3D with updated parameter values in processes --------------------------------------------
runEasyRun
(
arguments
,
parametersNamesANG
,
thetasANG
,
parametersNamesENV
,
thetasENV
)
#
runEasyRun(arguments, parametersNamesANG,thetasANG, parametersNamesENV, thetasENV )
# .jcall("analysis.EasyRun", "V", "runSimulation", arguments,
# .jarray(parametersNamesANG), .jarray(thetasANG),
...
...
@@ -133,8 +137,6 @@ runEasyRun(arguments, parametersNamesANG,thetasANG, parametersNamesENV, thetasEN
# call GR3D method to get model outputs ----------------------------------------------
#
runSimulation
=
function
(
simulationParameter
)
{
arguments
=
c
(
'-simDuration'
,
600
,
'-simBegin'
,
2
,
...
...
@@ -158,17 +160,6 @@ runSimulation = function(simulationParameter) {
#============================
listeSimulation
<-
list
(
list
(
replicat
=
1
,
parametersNamesANG
=
c
(
"processes.processesEachStep.11.Soffset"
),
thetasANG
=
c
(
-1
),
parametersNamesENV
=
c
(
"simulationName"
),
thetasENV
=
c
(
"Allee"
)),
list
(
replicat
=
1
,
parametersNamesANG
=
c
(
"processes.processesEachStep.11.Soffset"
),
thetasANG
=
c
(
0
),
parametersNamesENV
=
c
(
"simulationName"
),
thetasENV
=
c
(
"no Allee"
)))
listeSimulation
<-
list
(
list
(
replicat
=
1
,
parametersNamesANG
=
c
(
"processes.processesEachStep.11.Soffset"
,
"processes.processesEachStep.6.pHomingAfterEquil"
),
...
...
@@ -193,9 +184,12 @@ listeSimulation <- list(list(replicat = 1,
list
(
replicat
=
1
,
parametersNamesANG
=
c
(
"processes.processesEachStep.11.Soffset"
,
"processes.processesEachStep.6.pHomingAfterEquil"
),
thetasANG
=
c
(
0
,
0.
9
7
),
thetasANG
=
c
(
0
,
0.7
5
),
parametersNamesENV
=
c
(
"simulationName"
),
thetasENV
=
c
(
"noAllee_lowHoming"
))
)
tic
()
resSimulation
=
lapply
(
listeSimulation
,
runSimulation
)
toc
()
lapply
(
listeSimulation
,
runSimulation
)
\ No newline at end of file
save
(
listeSimulation
,
resSimulation
,
file
=
'simulation.Rdata'
)
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