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

bugs at excution fixed

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