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
26c10a34
Commit
26c10a34
authored
Mar 24, 2021
by
patrick.lambert
Browse files
new version to run Java from R
parent
7fd22080
Changes
1
Hide whitespace changes
Inline
Side-by-side
exploration/NEA_sensitivity_analysis/tryFromJava.R
View file @
26c10a34
library
(
rJava
)
library
(
rJava
)
# see J4R
#library(yaml)
library
(
dplyr
)
library
(
tidyverse
)
rm
(
list
=
ls
())
rm
(
list
=
ls
())
# # parameters and prios=rs of parameters to be fitted
# inputData = yaml.load_file("ABC_seq_2param_3stats_NewAfterSA.yaml")
...
...
@@ -20,36 +20,101 @@ rm(list=ls())
# parametersNames = unlist(parametersNames)
## to have the same working diretory as GR3D
# GR3D arguments -----------------------------------------
## to have the same working directory as GR3D
setwd
(
"../.."
)
# path to outputs
outputDir
=
"simus/"
#outputDir = "simus/"
outputFileName
=
paste0
(
"SA/"
,
seed
)
jarfile
=
"target/GR3D-3.2-SNAPSHOT.jar"
simDuration
=
48
simBegin
=
1
timeStepDuration
=
1
timeStepDuration
=
1
seed
=
1
parametersNames
=
c
(
"processes.processesEachStep.8.tempMinRep"
,
"processes.processesEachStep.8.ratioS95_S50"
,
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 -------------------------------------
.jinit
(
classpath
=
jarfile
,
force.init
=
TRUE
)
# modification of xlm parameters -----------------------
parametersNames
=
c
(
"processes.processesEachStep.10.tempMinRep"
,
"processes.processesEachStep.10.ratioS95_S50"
,
"processes.processesEachStep.6.pHomingAfterEquil"
)
thetas
=
c
(
10
,
2
,
0.7
)
# run the GR3D with update xlm parameters --------------------------------------------
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"
)
.jcall
(
"analysis.EasyRun"
,
"V"
,
"runSimulation"
,
arguments
,
outputFileName
,
.jarray
(
parametersNames
),
.jarray
(
thetas
))
outputFile
=
paste0
(
"SA/"
,
seed
)
.jinit
(
classpath
=
jarfile
,
force.init
=
TRUE
)
.jcall
(
"miscellaneous.EasyRun"
,
"V"
,
"runSimulation"
,
arguments
,
outputFile
,
.jarray
(
parametersNames
),
.jarray
(
thetas
))
.jcall
(
"miscellaneous.EasyRun"
,
"[D"
,
"getValuesFromEnvironement"
,
"getMeanLastPercOfAut"
)
.jcall
(
"miscellaneous.EasyRun"
,
"[D"
,
"getValuesFromAquanismGroup"
,
"getRangeDistribution"
)
# truc = .jcall("miscellaneous.EasyRun","Ljava/util/List;",
# call GR3D method to get model outputs ----------------------------------------------
#TODO export [char] and then data.frame(toto) %>% type_convert()
# ----------------------------------------------------------------------------------#
# 1. northern limit and distribution centroid ----
# only basins with more than 50 recruits in average in the last 10 years (colonised basins)
# compute only in SPRING
# access through getRangeDistribution in DiadromousFishGroup ==== NOT CORRECT
# range[1] = latitude of the median distribution ( 50 % of effectives are northern)
# range[2] = southern limit latitude of the fish distribution
#range = .jcall("miscellaneous.EasyRun","[D","getValuesFromAquaNismsGroup","getRangeDistribution")
.jcall
(
"analysis.EasyRun"
,
"D"
,
"getSingleValueFromAquanismGroupProcess"
,
"processes.processesAtEnd.0.getLogLikelihood"
);
# ------------------------------------------------------------ #
# 2. log-likelihood ----
# the proportion of reproductions leading to a recruitment > 50 over the 1920-1950 period was used
# as a proxy of predicted probability of presecen in a basin.
# Then a log-likelihood of a binomial distribution is computed
# access through computeLikelihood in DiadromousFishGroup
# see getProbOfNonNulRecruitmentDuringLastYears in BasinNetwork
# ------------------------------------------------------------ #
# 3. proportion of first-time spawners
# annual % of first-time spawners according to latitude (or basin_id)
# between 1920-1950
# then in R: annual slope of the linear regression
# and average over the period
# mean (+sd) and slpe after
# access through AnalyseSpawnerRun in [processesAtEnd]
# ------------------------------------------------------------ #
# 4. Mean age of the spawner for male and female ----
# annual mean age in each basin,
# then in R: average per year,
# and average over the period (1920 and 1950)
# ------------------------------------------------------------ #
# 5. number of metapopulation based on the exchange matrix ----
# annual exchange matrix between 1920 and 1950
# then in R: compute average matrix over the period,
# run metapopulationIdentification
# moyenne sur les bassins versants des moyennes sur la peride des moyennes des flux
# access through species.IdentifyPopulation in processesAtEnd
toto
<-
.jcall
(
"analysis.EasyRun"
,
"Ljava/util/List;"
,
"getAListFromAquanismGroupProcess"
,
"processes.processesAtEnd.1.getRecords"
)
as.list
(
toto
)
.jcall
(
"miscellaneous.EasyRun"
,
"[D"
,
"getValuesFromEnvironment"
,
"getMeanLastPercOfAut"
)
# truc = .jcall("analysis.EasyRun","Ljava/util/List;",
# "getAListFromAquanismGroupProcess","processes.processesAtEnd.1.getRecords")
#
# trucMieux = .jcast(truc, "ljava/util/ArrayList", convert.array = FALSE)
...
...
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