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
4ddfe864
Commit
4ddfe864
authored
Apr 13, 2021
by
patrick.lambert
Browse files
survival after reproduction as a independant process
parent
0a4a44d8
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
data/input/northeastamerica/fishRIOBasin_Sapidissima_Rjava.xml
View file @
4ddfe864
...
...
@@ -296,7 +296,7 @@
<minimumRecruitsForPopulatedBasin>
50
</minimumRecruitsForPopulatedBasin>
</analysis.AnalyseFishDistribution>
<species.Reproduce
AndSurviveAfterReproduction
WithDiagnose>
<species.ReproduceWithDiagnose>
<synchronisationMode>
ASYNCHRONOUS
</synchronisationMode>
<reproductionSeason>
SPRING
</reproductionSeason>
<tempMinRep>
10
</tempMinRep>
...
...
@@ -312,13 +312,17 @@
<proportionOfFemaleAtBirth>
0.5
</proportionOfFemaleAtBirth>
<initialLength>
2.8
</initialLength>
<sigmaRecruitment>
0.2
</sigmaRecruitment>
<survivalRateAfterReproduction>
0.1
</survivalRateAfterReproduction>
<maxNumberOfSuperIndividualPerReproduction>
100.0
</maxNumberOfSuperIndividualPerReproduction>
<withDiagnose>
false
</withDiagnose>
<displayFluxesOnConsole>
false
</displayFluxesOnConsole>
</species.Reproduce
AndSurviveAfterReproduction
WithDiagnose>
</species.ReproduceWithDiagnose>
<species.SurviveAfterReproduction>
<synchronisationMode>
ASYNCHRONOUS
</synchronisationMode>
<afterReproductionSeason>
SPRING
</afterReproductionSeason>
<survivalRateAfterReproduction>
0.1
</survivalRateAfterReproduction>
</species.SurviveAfterReproduction>
<species.MigrateFromRiverToInshore>
<synchronisationMode>
ASYNCHRONOUS
</synchronisationMode>
...
...
src/main/java/species/ReproduceWithDiagnose.java
0 → 100644
View file @
4ddfe864
This diff is collapsed.
Click to expand it.
src/main/java/species/SurviveAfterReproduction.java
0 → 100644
View file @
4ddfe864
package
species
;
import
java.util.Hashtable
;
import
java.util.List
;
import
java.util.ListIterator
;
import
java.util.Map
;
import
org.openide.util.lookup.ServiceProvider
;
import
com.thoughtworks.xstream.XStream
;
import
com.thoughtworks.xstream.io.xml.DomDriver
;
import
environment.RiverBasin
;
import
environment.Time
;
import
environment.Time.Season
;
import
fr.cemagref.simaqualife.kernel.processes.AquaNismsGroupProcess
;
import
fr.cemagref.simaqualife.kernel.util.TransientParameters.InitTransientParameters
;
import
fr.cemagref.simaqualife.pilot.Pilot
;
import
miscellaneous.BinomialForSuperIndividualGen
;
import
species.DiadromousFish.SpawnerOrigin
;
import
umontreal.iro.lecuyer.probdist.NormalDist
;
import
umontreal.iro.lecuyer.randvar.NormalGen
;
@ServiceProvider
(
service
=
AquaNismsGroupProcess
.
class
)
public
class
SurviveAfterReproduction
extends
AquaNismsGroupProcess
<
DiadromousFish
,
DiadromousFishGroup
>
{
private
Season
afterReproductionSeason
=
Season
.
SUMMER
;
private
double
survivalRateAfterReproduction
=
0.1
;
private
transient
NormalGen
genNormal
;
/**
* the random numbers generator for binomial draws
*
* @unit --
*/
private
transient
BinomialForSuperIndividualGen
aleaGen
;
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
((
new
XStream
(
new
DomDriver
())).
toXML
(
new
SurviveAfterReproduction
()));
}
@Override
@InitTransientParameters
public
void
initTransientParameters
(
Pilot
pilot
)
{
super
.
initTransientParameters
(
pilot
);
genNormal
=
new
NormalGen
(
pilot
.
getRandomStream
(),
new
NormalDist
(
0
.,
1
.));
aleaGen
=
new
BinomialForSuperIndividualGen
(
pilot
.
getRandomStream
());
}
@Override
public
void
doProcess
(
DiadromousFishGroup
group
)
{
Time
time
=
group
.
getEnvironment
().
getTime
();
if
(
time
.
getSeason
(
group
.
getPilot
())
==
afterReproductionSeason
)
{
for
(
RiverBasin
riverBasin
:
group
.
getEnvironment
().
getRiverBasins
())
{
long
survivalAmount
;
List
<
DiadromousFish
>
fishInBasin
=
riverBasin
.
getFishs
(
group
);
if
(
fishInBasin
!=
null
)
{
// Initiate the total fluxes for this basin
Map
<
SpawnerOrigin
,
Map
<
String
,
Double
>>
totalInputFluxes
=
new
Hashtable
<
SpawnerOrigin
,
Map
<
String
,
Double
>>();
// On
totalInputFluxes
.
put
(
SpawnerOrigin
.
AUTOCHTONOUS
,
new
Hashtable
<
String
,
Double
>());
totalInputFluxes
.
put
(
SpawnerOrigin
.
ALLOCHTONOUS
,
new
Hashtable
<
String
,
Double
>());
for
(
SpawnerOrigin
origin
:
totalInputFluxes
.
keySet
())
{
for
(
String
nutrient
:
group
.
getNutrientRoutine
().
getNutrientsOfInterest
())
{
totalInputFluxes
.
get
(
origin
).
put
(
nutrient
,
0
.);
// ON MET A JOUR NOTRE map
}
totalInputFluxes
.
get
(
origin
).
put
(
"biomass"
,
0
.);
}
// iterate on the fish
ListIterator
<
DiadromousFish
>
fishIterator
=
fishInBasin
.
listIterator
();
while
(
fishIterator
.
hasNext
())
{
DiadromousFish
fish
=
fishIterator
.
next
();
if
(
fish
.
isMature
())
{
// origin of the spwaner
SpawnerOrigin
spawnerOrigin
=
(
fish
.
getBirthBasin
()
==
riverBasin
?
SpawnerOrigin
.
AUTOCHTONOUS
:
SpawnerOrigin
.
ALLOCHTONOUS
);
// survival amount of fish
double
biomass
=
0
.;
survivalAmount
=
aleaGen
.
getSuccessNumber
(
fish
.
getAmount
(),
survivalRateAfterReproduction
);
// at least one fish in the SI survive, the other die
if
(
survivalAmount
>
0
)
{
// ---------------------------------------------------------- start of nutrient routine
// nutrient fluxes for one fish surviving after spawning (fish.getAmount):
// excretion + gametes
Map
<
String
,
Double
>
aFluxAfterSurvival
=
group
.
getNutrientRoutine
()
.
computeNutrientsInputForSurvivalAfterSpawning
(
fish
);
// nutrient fluxes for one fish dying after spawning (fish.getAmount):
// carcasses + excretion + gametes
Map
<
String
,
Double
>
aFluxForDeadFish
=
group
.
getNutrientRoutine
()
.
computeNutrientsInputForDeathAfterSpawning
(
fish
);
for
(
String
nutrient
:
aFluxAfterSurvival
.
keySet
())
{
// For all survival fish in the SI
group
.
getNutrientRoutine
().
getNutrientImportFluxesCollection
().
put
(
time
.
getYear
(
group
.
getPilot
()),
nutrient
,
fish
.
getBirthBasin
().
getName
(),
riverBasin
.
getName
(),
aFluxAfterSurvival
.
get
(
nutrient
)
*
survivalAmount
);
// For all dead fish in the SI
group
.
getNutrientRoutine
().
getNutrientImportFluxesCollection
().
put
(
time
.
getYear
(
group
.
getPilot
()),
nutrient
,
fish
.
getBirthBasin
().
getName
(),
riverBasin
.
getName
(),
aFluxForDeadFish
.
get
(
nutrient
)
*
(
fish
.
getAmount
()
-
survivalAmount
));
}
// take into account the fish origine
for
(
String
nutrient
:
aFluxAfterSurvival
.
keySet
())
{
// For all survival fish
totalInputFluxes
.
get
(
spawnerOrigin
).
put
(
nutrient
,
totalInputFluxes
.
get
(
spawnerOrigin
).
get
(
nutrient
)
+
aFluxAfterSurvival
.
get
(
nutrient
)
*
survivalAmount
);
// For all dead fish
totalInputFluxes
.
get
(
spawnerOrigin
).
put
(
nutrient
,
totalInputFluxes
.
get
(
spawnerOrigin
).
get
(
nutrient
)
+
aFluxForDeadFish
.
get
(
nutrient
)
*
(
fish
.
getAmount
()
-
survivalAmount
));
}
// compute biomass for dead fish
biomass
=
group
.
getNutrientRoutine
().
getWeight
(
fish
)
*
(
fish
.
getAmount
()
-
survivalAmount
);
totalInputFluxes
.
get
(
spawnerOrigin
).
put
(
"biomass"
,
totalInputFluxes
.
get
(
spawnerOrigin
).
get
(
"biomass"
)
+
biomass
);
// ------------------------------------------------------ end of nutrient routine
// update the amount of individual in the super-individual
fish
.
setAmount
(
survivalAmount
);
}
else
{
// the superindividual dies !!!
// ------------------------------------------------------ start of nutrient routine
// nutrient fluxes for one fish dying after spawning (fish.getAmount):
// carcasses + excretion + gametes
Map
<
String
,
Double
>
aFluxForDeadFish
=
group
.
getNutrientRoutine
()
.
computeNutrientsInputForDeathAfterSpawning
(
fish
);
//
for
(
String
nutrient
:
aFluxForDeadFish
.
keySet
())
{
group
.
getNutrientRoutine
().
getNutrientImportFluxesCollection
().
put
(
time
.
getYear
(
group
.
getPilot
()),
nutrient
,
fish
.
getBirthBasin
().
getName
(),
riverBasin
.
getName
(),
aFluxForDeadFish
.
get
(
nutrient
)
*
(
fish
.
getAmount
()
-
survivalAmount
));
}
biomass
=
group
.
getNutrientRoutine
().
getWeight
(
fish
)
*
(
fish
.
getAmount
());
totalInputFluxes
.
get
(
spawnerOrigin
).
put
(
"biomass"
,
totalInputFluxes
.
get
(
spawnerOrigin
).
get
(
"biomass"
)
+
biomass
);
// ------------------------------------------------------ end of nutrient routine
// remove fish because fish is dead
fishIterator
.
remove
();
}
}
}
}
}
}
}
}
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