Commit cb58b96f authored by Lambert Patrick's avatar Lambert Patrick
Browse files

calculation of dispersal corrected

but could differ from Rougier's coding
parent f1a0aa4c
package species; package species;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.ListIterator; import java.util.ListIterator;
import java.util.Map; import java.util.Map;
...@@ -193,41 +192,45 @@ public class DisperseAndMigrateToRiverWithMultiNomDistriAndDeathBasin extends Di ...@@ -193,41 +192,45 @@ public class DisperseAndMigrateToRiverWithMultiNomDistriAndDeathBasin extends Di
totalWeight = totalWeight + weightOfDeathBasin; totalWeight = totalWeight + weightOfDeathBasin;
// Afficher le contenu du MAP // Afficher le contenu du MAP
System.out.println(departure.getName() + ": " + totalWeight); /*
System.out.println("strayedAmount before: " + strayedAmount); * System.out.println(departure.getName() + ": " + totalWeight);
Iterator<RiverBasin> iterateur = basinWeightsFromDeparture.keySet().iterator(); * System.out.println("strayedAmount before: " + strayedAmount); Iterator<RiverBasin>
// Parcourir les clés et afficher les entrées de chaque clé; * iterateur = basinWeightsFromDeparture.keySet().iterator(); while
while (iterateur.hasNext()) { * (iterateur.hasNext()) { RiverBasin key = iterateur.next();
RiverBasin key = iterateur.next(); * System.out.println(key.getName() + " dist = " +
System.out.println(key.getName() + " dist = " + departure.getNeighboursDistances().get(key) * departure.getNeighboursDistances().get(key) + "=>" +
+ "=>" + (basinWeightsFromDeparture.get(key))); * (basinWeightsFromDeparture.get(key))); }
} */
// compute sequentially the prob to go into a basin // compute sequentially the prob to go into a basin
for (Entry<RiverBasin, Double> entry : basinWeightsPerBasin.get(departure).entrySet()) {
long remainingStrayedAmount = strayedAmount;
for (Entry<RiverBasin, Double> entry : basinWeightsFromDeparture.entrySet()) {
RiverBasin strayerDestination = entry.getKey(); RiverBasin strayerDestination = entry.getKey();
Double weight = entry.getValue(); Double weight = entry.getValue();
probToGo = weight / totalWeight; probToGo = weight / totalWeight;
// amountToGo = Miscellaneous.binomialForSuperIndividual(group.getPilot(), // amountToGo = Miscellaneous.binomialForSuperIndividual(group.getPilot(),
// strayedAmount, probToGo); // strayedAmount, probToGo);
amountToGo = aleaGen.getSuccessNumber(strayedAmount, probToGo);
amountToGo = Math.min(remainingStrayedAmount,
aleaGen.getSuccessNumber(strayedAmount, probToGo));
if (amountToGo > 0) { if (amountToGo > 0) {
strayerDestination.addFish(fish.duplicateWithNewPositionAndAmount(group.getPilot(), strayerDestination.addFish(fish.duplicateWithNewPositionAndAmount(group.getPilot(),
strayerDestination, amountToGo), group); strayerDestination, amountToGo), group);
remainingStrayedAmount -= amountToGo;
System.out.println(strayerDestination.getName() + "<-" + amountToGo);
} }
totalWeight -= weight; if (remainingStrayedAmount == 0) {
strayedAmount -= amountToGo;
if (strayedAmount <= 0) {
// CHECK if it occurs and for which basins // CHECK if it occurs and for which basins
break; break;
} }
} }
} }
System.out.println("strayedAmount after: " + strayedAmount); // System.out.println("strayedAmount after: " + strayedAmount);
System.out.println(); // System.out.println();
// update fish with homing // update fish with homing
if (homingAmount > 0) { if (homingAmount > 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