Commit 95309b5b authored by Lambert Patrick's avatar Lambert Patrick
Browse files

with calibration statistic for male and female

parent 5837b920
package environment;
import org.jfree.data.time.MovingAverage;
import java.util.Hashtable;
import java.util.Map;
import miscellaneous.QueueMemory;
import miscellaneous.QueueMemoryMap;
......@@ -8,6 +9,7 @@ import fr.cemagref.observation.kernel.Observable;
import fr.cemagref.observation.kernel.ObservablesHandler;
import fr.cemagref.simaqualife.pilot.Pilot;
import species.DiadromousFish;
import species.DiadromousFish.Gender;
import species.DiadromousFishGroup;
/**
......@@ -35,7 +37,7 @@ public class RiverBasin extends Basin {
private QueueMemory<Double> lastRecsOverProdCaps;
private QueueMemory<Double> lastPercentagesOfAutochtones;
private QueueMemory<Double> numberOfNonNulRecruitmentDuringLastYears; // Prob of non nul recruitment during the last "memorySize" years... if 10 non nul recruitment during the last 10 year, p=0.999... if 8 non nul recruitment during the last 10 years, p = 0.8... if 0 recruitment, p = 0.001
private QueueMemory<Double> femaleSpawnersForFirstTimeMeanAges;
private Map<DiadromousFish.Gender, QueueMemory<Double>> spawnersForFirstTimeMeanAges;;
private QueueMemory<Double> numberOfNonNulRecruitmentForFinalProbOfPres;
private double nativeSpawnerMortality; // mortality coefficient between recruitement and spawning for fish born in this basin
......@@ -98,7 +100,11 @@ public class RiverBasin extends Basin {
this.lastRecsOverProdCaps = new QueueMemory<Double>(memorySize);
this.lastPercentagesOfAutochtones = new QueueMemory<Double>(memorySize);
this.numberOfNonNulRecruitmentDuringLastYears = new QueueMemory<Double>(memorySize);
this.femaleSpawnersForFirstTimeMeanAges = new QueueMemory<Double>(memorySize);
this.spawnersForFirstTimeMeanAges = new Hashtable<DiadromousFish.Gender, QueueMemory<Double>>();
this.spawnersForFirstTimeMeanAges.put( DiadromousFish.Gender.FEMALE, new QueueMemory<Double>(memorySize) );
this.spawnersForFirstTimeMeanAges.put( DiadromousFish.Gender.MALE, new QueueMemory<Double>(memorySize) );
this.numberOfNonNulRecruitmentForFinalProbOfPres = new QueueMemory<Double>(memorySizeLongQueue);
if (cobservable == null) {
......@@ -189,8 +195,12 @@ public class RiverBasin extends Basin {
return numberOfNonNulRecruitmentDuringLastYears;
}
public QueueMemory<Double> getFemaleSpawnersForFirstTimeMeanAges() {
return femaleSpawnersForFirstTimeMeanAges;
/*public QueueMemory<Double> getFemaleSpawnersForFirstTimeMeanAges() {
return spawnersForFirstTimeMeanAges.get(Gender.FEMALE);
}*/
public QueueMemory<Double> getSpawnersForFirstTimeMeanAges(DiadromousFish.Gender gender) {
return spawnersForFirstTimeMeanAges.get(gender);
}
public QueueMemory<Double> getNumberOfNonNulRecruitmentForFinalProbOfPres(){
......
......@@ -46,8 +46,8 @@ public class DiadromousFishGroup extends AquaNismsGroup< DiadromousFish, BasinNe
public Color color = Color.RED;
/**
* ????
* @unit
* distance maximum of dispersion
* @unit km
*/
public double dMaxDisp = 300.;
......@@ -60,7 +60,7 @@ public class DiadromousFishGroup extends AquaNismsGroup< DiadromousFish, BasinNe
public String fileNameInputForInitialObservation = "data/input/reality/Obs1900.csv";
/**
* centile to calucale the range of species distribution
* centile to calcucale the range of species distribution
* @unit
*/
public double centileForRange = 0.95;
......@@ -491,6 +491,7 @@ public BufferedWriter getbWForFluxes() {
return tempMinRep;
}
@Observable(description = "Nb of SI")
public int getNbSI() {
int nbSI = 0;
......@@ -501,6 +502,7 @@ public BufferedWriter getbWForFluxes() {
return nbSI;
}
@Observable(description = "Sizes mean of SI")
public double getSizesMeanOfSI() {
double totalEffective = 0;
......@@ -518,6 +520,7 @@ public BufferedWriter getbWForFluxes() {
else
return Double.NaN;
}
@Observable(description = "# of SI with ind < 10")
public double getNbLittleSI() {
......@@ -533,6 +536,7 @@ public BufferedWriter getbWForFluxes() {
return nb;
}
public double getMeanLengthOfMatureFish(){
double sumOfLength = 0.;
double numberOfMatureFish = 0.;
......@@ -618,20 +622,33 @@ public NutrientRoutine getNutrientRoutine() {
// ================================================================
// statictis for calibration
// ================================================================
@Observable(description="Spawners For First Time Summary Statistic")
@Observable(description="Female spawners For First Time Summary Statistic")
public double computeFemaleSpawnerForFirstTimeSummaryStatistic() {
double sum = 0;
//TODO move TARGET to the right place
double TARGET = 5.0;
for (RiverBasin riverBasin : getEnvironment().getRiverBasins()) {
if (riverBasin.getFemaleSpawnersForFirstTimeMeanAges().getMeanWithoutZero() > 0.) {
double val = riverBasin.getFemaleSpawnersForFirstTimeMeanAges().getMeanWithoutZero() - TARGET;
if (riverBasin.getSpawnersForFirstTimeMeanAges(Gender.FEMALE).getMeanWithoutZero() > 0.) {
double val = riverBasin.getSpawnersForFirstTimeMeanAges(Gender.FEMALE).getMeanWithoutZero() - TARGET;
sum += val * val;
}
}
return sum;
}
@Observable(description="Male spawners For First Time Summary Statistic")
public double computeMaleSpawnerForFirstTimeSummaryStatistic() {
double sum = 0;
//TODO move TARGET to the right place
double TARGET = 5.0;
for (RiverBasin riverBasin : getEnvironment().getRiverBasins()) {
if (riverBasin.getSpawnersForFirstTimeMeanAges(Gender.MALE).getMeanWithoutZero() > 0.) {
double val = riverBasin.getSpawnersForFirstTimeMeanAges(Gender.MALE).getMeanWithoutZero() - TARGET;
sum += val * val;
}
}
return sum;
}
@Observable(description = "Likelihood Summary stat")
public double computeLikelihood() throws IOException {
......
......@@ -219,9 +219,9 @@ public class ReproduceAndSurviveAfterReproduction extends AquaNismsGroupProcess<
// keep the number of spawners for the firt time in the basin
if (numberOfSpawnerForFirstTime>0){
riverBasin.getFemaleSpawnersForFirstTimeMeanAges().push(spawnersForFirstTimeAgesSum/numberOfSpawnerForFirstTime);
riverBasin.getSpawnersForFirstTimeMeanAges(Gender.FEMALE).push(spawnersForFirstTimeAgesSum/numberOfSpawnerForFirstTime);
}else{
riverBasin.getFemaleSpawnersForFirstTimeMeanAges().push(0.);
riverBasin.getSpawnersForFirstTimeMeanAges(Gender.FEMALE).push(0.);
}
//System.out.println("nb spawners in basin " + riverBasin.getName() + " : " + numberOfGenitors);
......
......@@ -102,8 +102,12 @@ public class ReproduceAndSurviveAfterReproductionWithDiagnose extends AquaNismsG
double numberOfFemaleSpawners = 0.;
double numberOfMaleSpawners = 0.;
double numberOfAutochtones = 0.;
double numberOfFemaleSpawnerForFirstTime = 0.;
double femaleSpawnersForFirstTimeAgesSum = 0.;
double numberOfMaleSpawnerForFirstTime = 0.;
double maleSpawnersForFirstTimeAgesSum = 0.;
long survivalAmount;
double muRecruitment = 0.;
//double weightOfGenitors = 0.;
......@@ -179,14 +183,18 @@ public class ReproduceAndSurviveAfterReproductionWithDiagnose extends AquaNismsG
// number of spawners per gender
if (fish.getGender() == Gender.FEMALE) {
//System.out.println(fish.getAge() + " -> "+ fish.getLength() + " ("+fish.getStage()+")");
numberOfFemaleSpawners += fish.getAmount() ; // on ajoute a chaque fois le fish.getAmount (CcumSum)
if (fish.getNumberOfReproduction() < 1) {
numberOfFemaleSpawnerForFirstTime++;
femaleSpawnersForFirstTimeAgesSum += fish.getAge();
}
numberOfFemaleSpawners += fish.getAmount() ; // on ajoute a chaque fois le fish.getAmount (CcumSum)
}
else if (fish.getGender() == Gender.MALE) {
numberOfMaleSpawners += fish.getAmount() ; // on ajoute a chaque fois le fish.getAmount (CcumSum)
if (fish.getNumberOfReproduction() < 1) {
numberOfMaleSpawnerForFirstTime++;
maleSpawnersForFirstTimeAgesSum += fish.getAge();
}
}
// spawner per origine
......@@ -333,12 +341,17 @@ public class ReproduceAndSurviveAfterReproductionWithDiagnose extends AquaNismsG
riverBasin.getLastPercentagesOfAutochtones().push(numberOfAutochtones * 100 / numberOfFemaleSpawners);
// keep the number of spawners for the first time in the basin
if (numberOfFemaleSpawnerForFirstTime>0){
riverBasin.getFemaleSpawnersForFirstTimeMeanAges().push(femaleSpawnersForFirstTimeAgesSum/numberOfFemaleSpawnerForFirstTime);
}else{
riverBasin.getFemaleSpawnersForFirstTimeMeanAges().push(0.);
}
if (numberOfFemaleSpawnerForFirstTime>0)
riverBasin.getSpawnersForFirstTimeMeanAges(Gender.FEMALE).push(femaleSpawnersForFirstTimeAgesSum/numberOfFemaleSpawnerForFirstTime);
else
riverBasin.getSpawnersForFirstTimeMeanAges(Gender.FEMALE).push(0.);
if (numberOfMaleSpawnerForFirstTime>0)
riverBasin.getSpawnersForFirstTimeMeanAges(Gender.MALE).push(maleSpawnersForFirstTimeAgesSum/numberOfMaleSpawnerForFirstTime);
else
riverBasin.getSpawnersForFirstTimeMeanAges(Gender.MALE).push(0.);
//TODO the same with male
//System.out.println("nb spawners in basin " + riverBasin.getName() + " : " + numberOfGenitors);
//System.out.println("nb recruit in basin " + riverBasin.getName() + " : " + numberOfRecruit);
......
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