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
18ff1042
Commit
18ff1042
authored
Feb 23, 2021
by
patrick.lambert
Browse files
attent to intafe R with GR3D simuation in Java
parent
9feb3aff
Changes
4
Hide whitespace changes
Inline
Side-by-side
data/input/northeastamerica/fishRIOBasin_Sapidissima_Rjava.xml
View file @
18ff1042
...
...
@@ -333,6 +333,16 @@
<exportSeason>
SPRING
</exportSeason>
<fileNameOutput>
biomassFluxes
</fileNameOutput>
</species.WriteBiomassFluxes>
<species.IdentifyPopulation>
<synchronisationMode>
ASYNCHRONOUS
</synchronisationMode>
<consoleDisplay>
false
</consoleDisplay>
<years>
<long>
1813
</long>
</years>
<fluxesSeason>
SPRING
</fluxesSeason>
<fileNameOutput>
effectiveFluxes
</fileNameOutput>
</species.IdentifyPopulation>
</processesAtEnd>
</processes>
<useCemetery>
false
</useCemetery>
...
...
exploration/NEA_sensitivity_analysis/tryFrom
Rougier
.R
→
exploration/NEA_sensitivity_analysis/tryFrom
Java
.R
View file @
18ff1042
...
...
@@ -32,13 +32,11 @@ timeStepDuration =1
seed
=
1
parametersNames
=
c
(
"processes.processesEachStep.8.tempMinRep"
,
"processes.processesEachStep.8.ratioS95_S50"
,
"processes.processesEachStep.6.pHomingAfterEquil"
)
thetas
=
c
(
10
,
2
,
0.7
)
arguments
=
c
(
''
,
'-simDuration'
,
simDuration
,
'-simBegin'
,
simBegin
,
'-timeStepDuration'
,
timeStepDuration
,
'-RNGStatusIndex'
,
format
(
seed
,
scientific
=
FALSE
),
...
...
@@ -46,12 +44,21 @@ arguments = c('','-simDuration',simDuration, '-simBegin',simBegin,
'-env'
,
"data/input/northeastamerica/RIOBNneaBasins_Rjava.xml"
,
'-observers'
,
"data/input/northeastamerica/RIO_obs_empty.xml"
)
outputFile
=
paste0
(
"Avirer"
,
seed
)
.jinit
(
classpath
=
""
,
force.init
=
TRUE
)
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;",
# "getAListFromAquanismGroupProcess","processes.processesAtEnd.1.getRecords")
#
# trucMieux = .jcast(truc, "ljava/util/ArrayList", convert.array = FALSE)
#
# i <- .jnew("java/lang/Integer", as.integer(10))
# print(i)
# print(.jsimplify(i))
# .jcall(trucMieux, "java/lang/Object", "get", i)
#
# with(trucMieux, {get(0)})
# ArrayList = J("java.util.ArrayList")
# .jclassPath()
src/main/java/miscellaneous/EasyRun.java
View file @
18ff1042
/*
* Copyright (C) 20
14 d
umoulin
*
* Copyright (C) 20
21 lambert D
umoulin
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
...
...
@@ -17,6 +17,7 @@
package
miscellaneous
;
import
java.util.Arrays
;
import
java.util.List
;
import
fr.cemagref.simaqualife.extensions.pilot.BatchRunner
;
import
fr.cemagref.simaqualife.pilot.Pilot
;
...
...
@@ -25,7 +26,6 @@ public class EasyRun {
static
Pilot
pilot
;
public
static
void
runSimulation
(
String
[]
batchArgs
,
String
outputfilename
,
String
[]
paramNames
,
double
[]
paramValues
)
throws
Exception
{
...
...
@@ -55,13 +55,18 @@ public class EasyRun {
}
public
static
double
[]
getValuesFromEnvironement
(
String
outputName
)
throws
Exception
{
return
(
double
[])
ReflectUtils
.
getValueFromPath
(
pilot
.
getAquaticWorld
().
getEnvironment
(),
outputName
);
public
static
double
[]
getValuesFromEnvironement
(
String
targetName
)
throws
Exception
{
return
(
double
[])
ReflectUtils
.
getValueFromPath
(
pilot
.
getAquaticWorld
().
getEnvironment
(),
targetName
);
}
public
static
double
[]
getValuesFromAquanismGroup
(
String
targetName
)
throws
Exception
{
return
(
double
[])
ReflectUtils
.
getValueFromPath
(
pilot
.
getAquaticWorld
().
getAquaNismsGroupsList
().
get
(
0
),
targetName
);
}
public
static
double
[]
getValues
FromAquanismGroup
(
String
outputName
)
throws
Exception
{
return
(
double
[]
)
ReflectUtils
.
getValueFromPath
(
pilot
.
getAquaticWorld
().
getAquaNismsGroupsList
().
get
(
0
),
outputName
);
public
static
List
getAList
FromAquanismGroup
Process
(
String
targetPath
)
throws
Exception
{
return
(
List
)
ReflectUtils
.
getValueFromPath
(
pilot
.
getAquaticWorld
().
getAquaNismsGroupsList
().
get
(
0
),
targetPath
);
}
...
...
@@ -78,6 +83,10 @@ public class EasyRun {
runSimulation
(
batchArguments
,
"tsointsoin"
,
parameterNames
,
parameterValues
);
List
truc
=
getAListFromAquanismGroupProcess
(
"processes.processesAtEnd.1.getRecords"
);
System
.
out
.
println
(
truc
.
get
(
0
).
toString
());
// System.out.println(getAListFromAquanismGroupProcess("processes.processesAtEnd.1.getRecords"));
System
.
out
.
println
(
Arrays
.
toString
(
getValuesFromEnvironement
(
"getMeanLastPercOfAut"
)));
System
.
out
.
println
(
Arrays
.
toString
(
getValuesFromAquanismGroup
(
"getRangeDistribution"
)));
...
...
src/main/java/species/IdentifyPopulation.java
View file @
18ff1042
...
...
@@ -23,12 +23,13 @@ import java.io.BufferedWriter;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.List
;
import
com.thoughtworks.xstream.XStream
;
import
com.thoughtworks.xstream.io.xml.DomDriver
;
import
environment.RIOBasinNetwork
;
import
environment.RiverBasin
;
import
environment.Time
;
import
environment.Time.Season
;
...
...
@@ -39,17 +40,76 @@ import fr.cemagref.simaqualife.kernel.processes.AquaNismsGroupProcess;
*/
public
class
IdentifyPopulation
extends
AquaNismsGroupProcess
<
DiadromousFish
,
DiadromousFishGroup
>
{
/**
*
*/
public
class
Record
implements
Serializable
{
long
year
;
String
migrationBasin
;
String
originBasin
;
long
effective
;
public
Record
(
long
year
,
String
migrationBasin
,
String
originBasin
,
long
effective
)
{
super
();
this
.
year
=
year
;
this
.
migrationBasin
=
migrationBasin
;
this
.
originBasin
=
originBasin
;
this
.
effective
=
effective
;
}
@Override
public
String
toString
()
{
return
"["
+
this
.
year
+
"; "
+
this
.
migrationBasin
+
"; "
+
this
.
originBasin
+
"; "
+
this
.
effective
+
"]"
;
}
/**
* @return the year
*/
public
long
getYear
()
{
return
this
.
year
;
}
/**
* @return the migrationBasin
*/
public
String
getMigrationBasin
()
{
return
this
.
migrationBasin
;
}
/**
* @return the originBasin
*/
public
String
getOriginBasin
()
{
return
this
.
originBasin
;
}
/**
* @return the effective
*/
public
long
getEffective
()
{
return
this
.
effective
;
}
}
private
boolean
consoleDisplay
=
false
;
private
List
<
Long
>
years
;
private
Season
fluxesSeason
=
Season
.
SPRING
;
private
String
fileNameOutput
=
"data/output/fluxes"
;
private
String
fileNameOutput
=
"effectiveFluxes"
;
private
transient
List
<
Record
>
records
;
private
transient
BufferedWriter
bW
;
private
String
sep
;
private
transient
String
sep
;
// @Observable(description = "fluxes")
// private transient long[] fluxes;
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
((
new
XStream
(
new
DomDriver
())).
toXML
(
new
IdentifyPopulation
()));
}
...
...
@@ -64,18 +124,13 @@ public class IdentifyPopulation extends AquaNismsGroupProcess<DiadromousFish, Di
public
void
doProcess
(
DiadromousFishGroup
group
)
{
if
(
bW
==
null
)
{
if
(
fileNameOutput
!=
null
)
{
sep
=
"
;
"
;
sep
=
"
,
"
;
try
{
new
File
(
group
.
getOutputPath
()
+
fileNameOutput
).
getParentFile
().
mkdirs
();
bW
=
new
BufferedWriter
(
new
FileWriter
(
new
File
(
group
.
getOutputPath
()
+
fileNameOutput
+
group
.
getSimulationId
()
+
".csv"
)));
// BasinNetworkReal nbr= (BasinNetworkReal) pilot.getAquaticWorld().getEnvironment();
RIOBasinNetwork
nbr
=
group
.
getEnvironment
();
bW
.
write
(
"year"
+
sep
+
"migrationBasin"
);
for
(
String
basinName
:
nbr
.
getRiverBasinNames
())
{
bW
.
write
(
sep
+
basinName
);
}
bW
.
write
(
"year"
+
sep
+
"migrationBasin"
+
sep
+
"originBasin"
+
sep
+
"effective"
);
bW
.
write
(
"\n"
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
...
...
@@ -87,20 +142,33 @@ public class IdentifyPopulation extends AquaNismsGroupProcess<DiadromousFish, Di
String
[]
basinNames
=
group
.
getEnvironment
().
getRiverBasinNames
();
// put in hasmap
if
(
records
==
null
)
records
=
new
ArrayList
<
Record
>();
for
(
RiverBasin
basin
:
group
.
getEnvironment
().
getRiverBasins
())
{
for
(
RiverBasin
originBasin
:
group
.
getEnvironment
().
getRiverBasins
())
{
long
effective
=
Math
.
round
(
basin
.
getSpawnerOrigins
().
getMeans
().
get
(
originBasin
.
getName
()));
records
.
add
(
new
Record
(
time
.
getYear
(
group
.
getPilot
()),
basin
.
getName
(),
originBasin
.
getName
(),
effective
));
}
}
// write in file
if
(
fileNameOutput
!=
null
)
{
try
{
for
(
RiverBasin
b
asin
:
group
.
getEnvironment
().
getRiverBasins
())
{
bW
.
write
(
time
.
getYear
(
group
.
getPilot
())
+
sep
+
basin
.
getName
());
for
(
String
basinName
:
b
asinName
s
)
{
bW
.
write
(
sep
+
Math
.
round
(
basin
.
getSpawnerOrigins
().
getMeans
().
get
(
basinName
))
);
for
(
RiverBasin
migrationB
asin
:
group
.
getEnvironment
().
getRiverBasins
())
{
for
(
String
originBasinName
:
basinNames
)
{
bW
.
write
(
time
.
getYear
(
group
.
getPilot
())
+
sep
+
migrationBasin
.
getName
()
+
sep
+
originBasinName
);
bW
.
write
(
sep
+
Math
.
round
(
migrationBasin
.
getSpawnerOrigins
().
getMeans
().
get
(
originB
asinName
)));
bW
.
write
(
"\n"
);
}
bW
.
write
(
"\n"
);
}
bW
.
flush
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
// display in console
if
(
consoleDisplay
)
{
System
.
out
.
print
(
"MIGRATION"
+
"\t"
);
for
(
String
basinName
:
basinNames
)
{
...
...
@@ -128,4 +196,13 @@ public class IdentifyPopulation extends AquaNismsGroupProcess<DiadromousFish, Di
}
}
}
/**
* @return the records
*/
public
List
<
Record
>
getRecords
()
{
return
this
.
records
;
}
}
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