Commit 3a1bbc49 authored by Poulet Camille's avatar Poulet Camille
Browse files

Correction Temperature Effect on Survival

parent 3f1bc7ea
...@@ -287,9 +287,9 @@ ...@@ -287,9 +287,9 @@
<species.Survive> <species.Survive>
<synchronisationMode>ASYNCHRONOUS</synchronisationMode> <synchronisationMode>ASYNCHRONOUS</synchronisationMode>
<tempMinMortGenInRiv>10.0</tempMinMortGenInRiv> <tempMinSurvivalSpawnerInRiv>10.0</tempMinSurvivalSpawnerInRiv>
<tempMaxMortGenInRiv>23.0</tempMaxMortGenInRiv> <tempMaxSurvivalSpawnerInRiv>23.0</tempMaxSurvivalSpawnerInRiv>
<tempOptMortGenInRiv>20.0</tempOptMortGenInRiv> <!-- <tempOptSurvivalSpawnerInRiv>20.0</tempOptSurvivalSpawnerInRiv> -->
<survivalProbOptGenInRiv>1.0</survivalProbOptGenInRiv> <survivalProbOptGenInRiv>1.0</survivalProbOptGenInRiv>
<mortalityRateInRiver>0.4</mortalityRateInRiver> <mortalityRateInRiver>0.4</mortalityRateInRiver>
<mortalityRateInSea>0.4</mortalityRateInSea> <mortalityRateInSea>0.4</mortalityRateInSea>
......
...@@ -6,41 +6,51 @@ import umontreal.iro.lecuyer.randvar.UniformGen; ...@@ -6,41 +6,51 @@ import umontreal.iro.lecuyer.randvar.UniformGen;
public class Miscellaneous { public class Miscellaneous {
public static long binomialForSuperIndividual(Pilot pilot, long amount, double succesProba, long threshold) { public static long binomialForSuperIndividual(Pilot pilot, long amount, double succesProba, long threshold) {
long amountWithSuccess; long amountWithSuccess;
if (amount > threshold) { // use a normal approximation for huge amount if (amount > threshold) { // use a normal approximation for huge amount
/* double p=-1.; /* double p=-1.;
while (p<0 | p>1){ while (p<0 | p>1){
p = genAleaNormal.nextDouble() * p = genAleaNormal.nextDouble() *
Math.sqrt(succesProba * (1 - succesProba) /amount) + succesProba; Math.sqrt(succesProba * (1 - succesProba) /amount) + succesProba;
} }
amountWithSuccess = (long) Math.round(p* amount);*/ amountWithSuccess = (long) Math.round(p* amount);*/
amountWithSuccess = -1; amountWithSuccess = -1;
while (amountWithSuccess < 0 | amountWithSuccess > amount) { while (amountWithSuccess < 0 | amountWithSuccess > amount) {
amountWithSuccess = Math.round(NormalGen.nextDouble(pilot.getRandomStream(), 0., 1.) * Math.sqrt(succesProba * (1 - succesProba) * amount) amountWithSuccess = Math.round(NormalGen.nextDouble(pilot.getRandomStream(), 0., 1.) * Math.sqrt(succesProba * (1 - succesProba) * amount)
+ succesProba * amount); + succesProba * amount);
} }
} else { } else {
amountWithSuccess = 0; amountWithSuccess = 0;
for (long i = 0; i < amount; i++) { for (long i = 0; i < amount; i++) {
if (UniformGen.nextDouble(pilot.getRandomStream(), 0, 1) < succesProba) { if (UniformGen.nextDouble(pilot.getRandomStream(), 0, 1) < succesProba) {
amountWithSuccess++; amountWithSuccess++;
} }
} }
} }
return amountWithSuccess; return amountWithSuccess;
} }
public static long binomialForSuperIndividual(Pilot pilot, long amount, double succesProba) { public static long binomialForSuperIndividual(Pilot pilot, long amount, double succesProba) {
return binomialForSuperIndividual(pilot, amount, succesProba, 50); return binomialForSuperIndividual(pilot, amount, succesProba, 50);
} }
static public double temperatureEffect(double T, double Tmin, double Topt, double Tmax) { static public double temperatureEffect(double T, double Tmin, double Topt, double Tmax) {
if (T <= Tmin || T >= Tmax) { if (T <= Tmin || T >= Tmax) {
return 0; return 0;
} else { } else {
return (T - Tmin) * (T - Tmax) / ((T - Tmin) * (T - Tmax) - ((T - Topt) * (T-Topt))); return (T - Tmin) * (T - Tmax) / ((T - Tmin) * (T - Tmax) - ((T - Topt) * (T-Topt)));
} }
} }
static public double rectangularTemperatureEffect(double T, double Tmin, double Tmax) {
if (T <= Tmin || T >= Tmax) {
return 0;
} else {
return 1;
}
}
} }
...@@ -19,9 +19,9 @@ import org.openide.util.lookup.ServiceProvider; ...@@ -19,9 +19,9 @@ import org.openide.util.lookup.ServiceProvider;
@ServiceProvider(service = AquaNismsGroupProcess.class) @ServiceProvider(service = AquaNismsGroupProcess.class)
public class Survive extends AquaNismsGroupProcess<DiadromousFish, DiadromousFishGroup> { public class Survive extends AquaNismsGroupProcess<DiadromousFish, DiadromousFishGroup> {
public double tempMinMortGenInRiv = 10.; public double tempMinSurvivalSpawnerInRiv = 10.;
public double tempMaxMortGenInRiv = 23.; // DEFINIR TROIS AUTRES POUR MORTALITE public double tempMaxSurvivalSpawnerInRiv = 23.; // DEFINIR TROIS AUTRES POUR MORTALITE
public double tempOptMortGenInRiv = 20.; public double tempOptSurvivalSpawnerInRiv = 20.;
public double survivalProbOptGenInRiv = 1.; public double survivalProbOptGenInRiv = 1.;
public double mortalityRateInRiver = 0.4; public double mortalityRateInRiver = 0.4;
...@@ -43,7 +43,8 @@ public class Survive extends AquaNismsGroupProcess<DiadromousFish, DiadromousFis ...@@ -43,7 +43,8 @@ public class Survive extends AquaNismsGroupProcess<DiadromousFish, DiadromousFis
survivalProbability = 1.; survivalProbability = 1.;
//Survive //Survive
if(fish.getPosition().getType() == TypeBassin.RIVER && fish.isMature()){ if(fish.getPosition().getType() == TypeBassin.RIVER && fish.isMature()){
double tempEffectSurv = Miscellaneous.temperatureEffect(fish.getPosition().getCurrentTemperature(group.getPilot()), tempMinMortGenInRiv, tempOptMortGenInRiv, tempMaxMortGenInRiv); //double tempEffectSurv = Miscellaneous.temperatureEffect(fish.getPosition().getCurrentTemperature(group.getPilot()), tempMinSurvivalSpawnerInRiv, tempOptSurvivalSpawnerInRiv, tempMaxSurvivalSpawnerInRiv);
double tempEffectSurv = Miscellaneous.rectangularTemperatureEffect(fish.getPosition().getCurrentTemperature(group.getPilot()), tempMinSurvivalSpawnerInRiv, tempMaxSurvivalSpawnerInRiv);
if (tempEffectSurv == 0.){ if (tempEffectSurv == 0.){
survivalProbability = 0.; survivalProbability = 0.;
//System.out.println("le poisson situ� dans le bassin " + fish.getPosition().getName() + " en " + Time.getSeason() +" a un coeff de mortalit� de " + fish.getMortalityRateInRiver() + " mais � cause de la temp�rature une prob de survie de " + survivalProbability); //System.out.println("le poisson situ� dans le bassin " + fish.getPosition().getName() + " en " + Time.getSeason() +" a un coeff de mortalit� de " + fish.getMortalityRateInRiver() + " mais � cause de la temp�rature une prob de survie de " + survivalProbability);
......
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