Commit f0b9e4b7 authored by patrick.lambert's avatar patrick.lambert
Browse files

bugs at excution fixed

parent 8d3b1696
......@@ -283,6 +283,12 @@
<!--<species.WriteEffectiveAndBiomassImportFluxes> <synchronisationMode>ASYNCHRONOUS</synchronisationMode> <exportSeason>SPRING</exportSeason>
<fileNameOutput>effectiveBiomassFluxesBeforeReproduction</fileNameOutput> </species.WriteEffectiveAndBiomassImportFluxes> -->
<species.AnalyseSpawnerFeatures>
<synchronisationMode>ASYNCHRONOUS</synchronisationMode>
<analysisSeason>SPRING</analysisSeason>
<memorySize>30</memorySize>
</species.AnalyseSpawnerFeatures>
<species.ReproduceAndSurviveAfterReproductionWithDiagnose>
<synchronisationMode>ASYNCHRONOUS</synchronisationMode>
<reproductionSeason>SPRING</reproductionSeason>
......@@ -307,12 +313,10 @@
<species.AnalyseFishDistribution>
<synchronisationMode>ASYNCHRONOUS</synchronisationMode>
<fishDistributionAnalysisSeason>SPRING</fishDistributionAnalysisSeason>
<fishDistributionAnalysisStartYear>1820</fishDistributionAnalysisStartYear>
<fishDistributionAnalysisEndYear>1850</fishDistributionAnalysisEndYear>
<analysisSeason>SPRING</analysisSeason>
<minimumRecruitsForPopulatedBasin>50</minimumRecruitsForPopulatedBasin>
</species.AnalyseFishDistribution>
<species.MigrateFromRiverToInshore>
<synchronisationMode>ASYNCHRONOUS</synchronisationMode>
<migrationSeasonToReachInshore>SPRING</migrationSeasonToReachInshore>
......
......@@ -81,14 +81,19 @@ public class EasyRun {
+ "-env data/input/northeastamerica/RIOBNneaBasins_Rjava.xml "
+ "-observers data/input/northeastamerica/RIO_obs_empty.xml").split("\\ ");
String[] parameterNames = new String[] { "processes.processesEachStep.8.tempMinRep",
"processes.processesEachStep.8.ratioS95_S50", "processes.processesEachStep.6.pHomingAfterEquil" };
String[] parameterNames = new String[] { "processes.processesEachStep.9.tempMinRep",
"processes.processesEachStep.9.ratioS95_S50", "processes.processesEachStep.6.pHomingAfterEquil" };
double[] parameterValues = new double[] { 10, 2, 0.7 };
runSimulation(batchArguments, "tsointsoin", parameterNames, parameterValues);
double[][] distributionResults = getValuesFromAquanismGroupProcess("processes.processesEachStep.9.exportToR");
double[][] spawnerRunResults = getValuesFromAquanismGroupProcess("processes.processesEachStep.8.exportToR");
for (double[] result : spawnerRunResults) {
System.out.println(Arrays.toString(result));
}
double[][] distributionResults = getValuesFromAquanismGroupProcess("processes.processesEachStep.10.exportToR");
for (double[] result : distributionResults) {
System.out.println(Arrays.toString(result));
}
......
......@@ -27,6 +27,7 @@ import com.thoughtworks.xstream.io.xml.DomDriver;
import environment.RIOBasinNetwork;
import environment.RiverBasin;
import environment.Time.Season;
import fr.cemagref.simaqualife.kernel.processes.AquaNismsGroupProcess;
import fr.cemagref.simaqualife.pilot.Pilot;
import miscellaneous.TreeMapForCentile;
......@@ -37,6 +38,8 @@ import observer.ObservableRecord;
*/
public class AnalyseFishDistribution extends AquaNismsGroupProcess<DiadromousFish, DiadromousFishGroup> {
private Season analysisSeason = Season.SPRING;
/**
* The minimum number of recruits to consider a basin as populated
*
......@@ -71,62 +74,64 @@ public class AnalyseFishDistribution extends AquaNismsGroupProcess<DiadromousFis
if (records == null)
initTransientParameters(group.getPilot());
// initialise the distribution range
double southernEdge = northernLimit;
double northernEdge = southernLimit;
int southernId = -1;
int northernId = -1;
String southernName = "";
String northernName = "";
// initialise for centroid
TreeMapForCentile latitudeEffective = new TreeMapForCentile();
TreeMapForCentile latitudePresence = new TreeMapForCentile();
for (RiverBasin riverBasin : group.getEnvironment().getRiverBasins()) {
if (riverBasin.getLastRecruitments().getMean() > minimumRecruitsForPopulatedBasin) {
// the river basin is consdered populated
// NOTE : recruiit number is calulated after thermal tolerance impact
// (which is intreaged in the stock-recruitment relationship)
// southern edge
if (riverBasin.getLatitude() < southernEdge) {
// the basin is the new southern edge
southernEdge = riverBasin.getLatitude();
southernId = riverBasin.getBasin_id();
southernName = riverBasin.getName();
}
// northern edge
if (riverBasin.getLatitude() > southernEdge) {
// the basin is the new northern edge
northernEdge = riverBasin.getLatitude();
northernId = riverBasin.getBasin_id();
northernName = riverBasin.getName();
if (group.getEnvironment().getTime().getSeason(group.getPilot()) == analysisSeason) {
// initialise the distribution range
double southernEdge = northernLimit;
double northernEdge = southernLimit;
int southernId = -1;
int northernId = -1;
String southernName = "";
String northernName = "";
// initialise for centroid
TreeMapForCentile latitudeEffective = new TreeMapForCentile();
TreeMapForCentile latitudePresence = new TreeMapForCentile();
for (RiverBasin riverBasin : group.getEnvironment().getRiverBasins()) {
if (riverBasin.getLastRecruitments().getMean() > minimumRecruitsForPopulatedBasin) {
// the river basin is consdered populated
// NOTE : recruiit number is calulated after thermal tolerance impact
// (which is intreaged in the stock-recruitment relationship)
// southern edge
if (riverBasin.getLatitude() < southernEdge) {
// the basin is the new southern edge
southernEdge = riverBasin.getLatitude();
southernId = riverBasin.getBasin_id();
southernName = riverBasin.getName();
}
// northern edge
if (riverBasin.getLatitude() > southernEdge) {
// the basin is the new northern edge
northernEdge = riverBasin.getLatitude();
northernId = riverBasin.getBasin_id();
northernName = riverBasin.getName();
}
// for distribution centroide computation
latitudePresence.putWithAdding(riverBasin.getLatitude(), 1L);
long effective = ((Double) riverBasin.getLastSpawnerNumbersBeforeReproduction().getMean()).longValue();
latitudeEffective.putWithAdding(riverBasin.getLatitude(), effective);
}
// for distribution centroide computation
latitudePresence.putWithAdding(riverBasin.getLatitude(), 1L);
long effective = ((Double) riverBasin.getLastSpawnerNumbersBeforeReproduction().getMean()).longValue();
latitudeEffective.putWithAdding(riverBasin.getLatitude(), effective);
}
}
// if the universe is empty
if (southernEdge == northernLimit & northernEdge == southernLimit) {
southernEdge = (northernLimit + southernLimit) / 2.;
northernEdge = southernEdge;
}
// if the universe is empty
if (southernEdge == northernLimit & northernEdge == southernLimit) {
southernEdge = (northernLimit + southernLimit) / 2.;
northernEdge = southernEdge;
}
// distribution centroids computation
double basinCentroid = latitudePresence.calculateMedian();
double effectiveCentroid = latitudeEffective.calculateMedian();
// distribution centroids computation
double basinCentroid = latitudePresence.calculateMedian();
double effectiveCentroid = latitudeEffective.calculateMedian();
// add a record
FishDistributionRecord record = new FishDistributionRecord(southernId, southernName, southernEdge, northernId,
northernName, northernEdge, basinCentroid, effectiveCentroid);
// add a record
FishDistributionRecord record = new FishDistributionRecord(southernId, southernName, southernEdge, northernId,
northernName, northernEdge, basinCentroid, effectiveCentroid);
records.add(record);
records.add(record);
}
}
......
......@@ -27,6 +27,7 @@ import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;
import environment.RiverBasin;
import environment.Time.Season;
import fr.cemagref.simaqualife.kernel.processes.AquaNismsGroupProcess;
import fr.cemagref.simaqualife.pilot.Pilot;
import miscellaneous.QueueMemory;
......@@ -38,6 +39,7 @@ import species.DiadromousFish.Gender;
public class AnalyseSpawnerFeatures extends AquaNismsGroupProcess<DiadromousFish, DiadromousFishGroup> {
private int memorySize = 30;
private Season analysisSeason = Season.SPRING;
private transient Map<Integer, QueueMemory<Double>> femaleAgeMemories;
private transient Map<Integer, QueueMemory<Double>> maleAgeMemories;
......@@ -56,47 +58,62 @@ public class AnalyseSpawnerFeatures extends AquaNismsGroupProcess<DiadromousFish
// first passage
if (femaleAgeMemories == null) {
femaleAgeMemories = new HashMap<Integer, QueueMemory<Double>>();
maleAgeMemories = new HashMap<Integer, QueueMemory<Double>>();
primiparousMemories = new HashMap<Integer, QueueMemory<Double>>();
for (RiverBasin riverBasin : group.getEnvironment().getRiverBasins()) {
femaleAgeMemories.put(riverBasin.getId(), new QueueMemory<>(memorySize));
femaleAgeMemories.put(riverBasin.getBasin_id(), new QueueMemory<>(memorySize));
maleAgeMemories.put(riverBasin.getBasin_id(), new QueueMemory<>(memorySize));
primiparousMemories.put(riverBasin.getBasin_id(), new QueueMemory<>(memorySize));
}
}
for (RiverBasin riverBasin : group.getEnvironment().getRiverBasins()) {
if (group.getEnvironment().getTime().getSeason(group.getPilot()) == analysisSeason) {
for (RiverBasin riverBasin : group.getEnvironment().getRiverBasins()) {
if (riverBasin.getFishs(group) != null) {
if (riverBasin.getFishs(group) != null) {
double meanAgeForFemale = 0.;
double nbAgeForFemale = 0.;
double meanAgeForFemale = 0.;
double nbAgeForFemale = 0.;
double meanAgeForMale = 0.;
double nbAgeForMale = 0.;
double meanAgeForMale = 0.;
double nbAgeForMale = 0.;
double nbOfSpawners = 0.;
double nbOfPrimiparous = 0.;
double nbOfSpawners = 0.;
double nbOfPrimiparous = 0.;
for (DiadromousFish fish : riverBasin.getFishs(group)) {
if (fish.isMature()) {
for (DiadromousFish fish : riverBasin.getFishs(group)) {
if (fish.isMature()) {
// mean age
if (fish.getGender() == Gender.FEMALE) {
meanAgeForFemale += fish.getAge() * fish.getAmount();
nbAgeForFemale += fish.getAmount();
} else if (fish.getGender() == Gender.MALE) {
meanAgeForMale += fish.getAge() * fish.getAmount();
nbAgeForMale += fish.getAmount();
}
// mean age
if (fish.getGender() == Gender.FEMALE) {
meanAgeForFemale += fish.getAge() * fish.getAmount();
nbAgeForFemale += fish.getAmount();
} else if (fish.getGender() == Gender.MALE) {
meanAgeForMale += fish.getAge() * fish.getAmount();
nbAgeForMale += fish.getAmount();
}
// primiparous
nbOfSpawners += fish.getAmount();
if (fish.getNumberOfReproduction() == 0)
nbOfPrimiparous += fish.getAmount();
// primiparous
nbOfSpawners += fish.getAmount();
if (fish.getNumberOfReproduction() == 0)
nbOfPrimiparous += fish.getAmount();
}
}
// add value in the queues
if (nbAgeForFemale > 0.)
femaleAgeMemories.get(riverBasin.getBasin_id()).push(meanAgeForFemale / nbAgeForFemale);
else
femaleAgeMemories.get(riverBasin.getBasin_id()).push(Double.NaN);
if (nbAgeForMale > 0.)
maleAgeMemories.get(riverBasin.getBasin_id()).push(meanAgeForMale / nbAgeForMale);
else
maleAgeMemories.get(riverBasin.getBasin_id()).push(Double.NaN);
if (nbOfSpawners > 0.)
primiparousMemories.get(riverBasin.getBasin_id()).push(nbOfPrimiparous / nbOfSpawners);
else
primiparousMemories.get(riverBasin.getBasin_id()).push(Double.NaN);
}
// add value in the quues
femaleAgeMemories.get(riverBasin.getBasin_id()).add(meanAgeForFemale / nbAgeForFemale);
maleAgeMemories.get(riverBasin.getBasin_id()).add(meanAgeForMale / nbAgeForMale);
primiparousMemories.get(riverBasin.getBasin_id()).add(nbOfPrimiparous / nbOfSpawners);
}
}
}
......
......@@ -126,7 +126,7 @@ public class ReproduceAndSurviveAfterReproductionWithDiagnose extends AquaNismsG
// before the party !!!!
double fluxBefore = riverBasin.getSpawnerNumberPerGroup(group);
riverBasin.getLastSpawnerNumbersBeforeReproduction().add(fluxBefore);
riverBasin.getLastSpawnerNumbersBeforeReproduction().push(fluxBefore);
double b, c, alpha, beta, amountPerSuperIndividual, S95, S50;
double numberOfFemaleSpawners = 0.;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment