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
ee4e12dc
Commit
ee4e12dc
authored
Apr 21, 2021
by
patrick.lambert
Browse files
easyRun in java
parent
4372effe
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/analysis/EasyRun.java
View file @
ee4e12dc
...
...
@@ -26,7 +26,7 @@ public class EasyRun {
static
Pilot
pilot
;
public
static
void
runSimulation
(
String
[]
batchArgs
,
String
[]
paramName
s
,
double
[]
paramValues
)
throws
Exception
{
public
static
void
runSimulation
(
String
[]
batchArgs
,
String
[]
paramName
aANG
,
double
[]
paramValues
ANG
)
throws
Exception
{
try
{
pilot
=
new
Pilot
();
...
...
@@ -35,12 +35,10 @@ public class EasyRun {
runner
.
parseArgs
(
batchArgs
,
false
,
true
,
false
);
pilot
.
load
();
// update the simulation parameters
// ReflectUtils.setFieldValueFromPath(pilot.getAquaticWorld().getAquaNismsGroupsList().get(0),
// "processes.processesAtEnd.0.fileNameOutput", outputfilename);
for
(
int
i
=
0
;
i
<
paramNames
.
length
;
i
++)
{
ReflectUtils
.
setFieldValueFromPath
(
pilot
.
getAquaticWorld
().
getAquaNismsGroupsList
().
get
(
0
),
paramNames
[
i
],
paramValues
[
i
]);
// update the simulation parameters in AquaNismGroup
for
(
int
i
=
0
;
i
<
paramNameaANG
.
length
;
i
++)
{
ReflectUtils
.
setFieldValueFromPath
(
pilot
.
getAquaticWorld
().
getAquaNismsGroupsList
().
get
(
0
),
paramNameaANG
[
i
],
paramValuesANG
[
i
]);
}
// run the simulation
pilot
.
run
();
...
...
@@ -54,6 +52,40 @@ public class EasyRun {
}
public
static
void
runSimulation
(
String
[]
batchArgs
,
String
[]
paramNameaANG
,
double
[]
paramValuesANG
,
String
[]
paramNameaENV
,
String
[]
paramValuesENV
)
throws
Exception
{
// TODO parse string to other type if needed
try
{
pilot
=
new
Pilot
();
BatchRunner
runner
=
new
BatchRunner
(
pilot
);
pilot
.
init
();
runner
.
parseArgs
(
batchArgs
,
false
,
true
,
false
);
pilot
.
load
();
// update the simulation parameters in AquaNismGroup
for
(
int
i
=
0
;
i
<
paramNameaANG
.
length
;
i
++)
{
ReflectUtils
.
setFieldValueFromPath
(
pilot
.
getAquaticWorld
().
getAquaNismsGroupsList
().
get
(
0
),
paramNameaANG
[
i
],
paramValuesANG
[
i
]);
}
// update the simulation parameters in Environment
for
(
int
i
=
0
;
i
<
paramNameaENV
.
length
;
i
++)
{
ReflectUtils
.
setFieldValueFromPath
(
pilot
.
getAquaticWorld
().
getEnvironment
(),
paramNameaENV
[
i
],
paramValuesENV
[
i
]);
}
// run the simulation
pilot
.
run
();
// For forcing resources releasing (like shp files)
System
.
gc
();
}
catch
(
Throwable
e
)
{
System
.
out
.
println
(
e
.
getMessage
());
e
.
printStackTrace
();
}
}
public
static
double
[]
getValuesFromEnvironment
(
String
targetName
)
throws
Exception
{
return
(
double
[])
ReflectUtils
.
getValueFromPath
(
pilot
.
getAquaticWorld
().
getEnvironment
(),
targetName
);
}
...
...
@@ -85,20 +117,28 @@ public class EasyRun {
public
static
void
main
(
String
[]
args
)
throws
Exception
{
String
[]
batchArguments
=
(
"-simDuration 150 -simBegin 1 -timeStepDuration 1 -RNGStatusIndex 1 "
+
"-groups data/input/northeastamerica/fishRIOBasin_Sapidissima_Rjava.xml "
+
"-env data/input/northeastamerica/RIOBNneaBasins_Rjava.xml "
// blank are important
String
[]
batchArguments
=
(
"-simDuration 40 -simBegin 1 -timeStepDuration 1 -RNGStatusIndex 1 "
+
"-groups data/input/northeastamerica/fishRIOBasin_Sapidissima_Rjava.xml"
+
" "
+
"-env data/input/northeastamerica/RIOBNneaBasins_Rjava.xml"
+
" "
+
"-observers data/input/northeastamerica/RIO_obs_empty.xml"
).
split
(
"\\ "
);
String
[]
parameterNames
=
new
String
[]
{
"processes.processesEachStep.10.tempMinRep"
,
"processes.processesEachStep.10.ratioS95_S50"
,
"processes.processesEachStep.6.pHomingAfterEquil"
};
double
[]
parameterValues
=
new
double
[]
{
10
,
2
,
0.7
};
//
String[] parameterNames = new String[] { "processes.processesEachStep.10.tempMinRep",
//
"processes.processesEachStep.10.ratioS95_S50", "processes.processesEachStep.6.pHomingAfterEquil" };
//
//
double[] parameterValues = new double[] { 10, 2, 0.7 };
runSimulation
(
batchArguments
,
parameterNames
,
parameterValues
);
// =====================================================
System
.
out
.
println
(
"WITHOUT ALLEE EFFECT"
);
String
[]
parameterNamesANG
=
new
String
[]
{
"processes.processesEachStep.11.Soffset"
};
double
[]
parameterValuesANG
=
new
double
[]
{
0
.
};
// runSimulation(batchArguments, parameterNamesANG, parameterValuesANG);
String
[]
parameterNamesENV
=
new
String
[]
{
"simulationName"
};
String
[]
parameterValuesENV
=
new
String
[]
{
"noAllee"
};
runSimulation
(
batchArguments
,
parameterNamesANG
,
parameterValuesANG
,
parameterNamesENV
,
parameterValuesENV
);
System
.
out
.
println
(
"\n== AnalyseSpawnerFeatures =="
);
String
[][]
spawnerRunResults
=
getValuesFromAquanismGroupProcess
(
"processes.processesEachStep.
8
.exportToR"
);
String
[][]
spawnerRunResults
=
getValuesFromAquanismGroupProcess
(
"processes.processesEachStep.
9
.exportToR"
);
for
(
String
[]
record
:
spawnerRunResults
)
{
for
(
String
value
:
record
)
System
.
out
.
print
(
value
+
"\t"
);
...
...
@@ -106,7 +146,7 @@ public class EasyRun {
}
System
.
out
.
println
(
"\n== AnalyseFishDistribution =="
);
String
[][]
distributionResults
=
getValuesFromAquanismGroupProcess
(
"processes.processesEachStep.
9
.exportToR"
);
String
[][]
distributionResults
=
getValuesFromAquanismGroupProcess
(
"processes.processesEachStep.
10
.exportToR"
);
for
(
String
[]
record
:
distributionResults
)
{
for
(
String
value
:
record
)
System
.
out
.
print
(
value
+
"\t"
);
...
...
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