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

with listoperator for disperse

parent f42f10fb
package species;
import java.util.TreeMap;
import java.util.Map.Entry;
import java.util.Map;
import environment.Basin;
import environment.BasinNetwork;
import environment.RiverBasin;
import environment.SeaBasin;
import fr.cemagref.simaqualife.kernel.processes.AquaNismsGroupProcess;
import fr.cemagref.simaqualife.kernel.util.TransientParameters.InitTransientParameters;
import fr.cemagref.simaqualife.pilot.Pilot;
......@@ -72,9 +73,9 @@ public class DisperseAndMigrateToRiverBasic extends AquaNismsGroupProcess<Diadro
* <key> SeaBasin
* <value>
* <key> RiverBasin
* <value> weight to calculate probaility to disperse
* <value> part of weight independant of fish size used to calculate probability to disperse
*/
protected transient Map<Basin,Map<Basin,Double>> accessibleBasinsPerBasin;
protected transient Map<SeaBasin,Map<RiverBasin,Double>> basinWeightsPerBasin;
/**
* a map associtaing a sea bassin with the distance for each river bassin
......@@ -83,7 +84,7 @@ public class DisperseAndMigrateToRiverBasic extends AquaNismsGroupProcess<Diadro
* <key> RiverBasin
* <value> distance between the river Basin and the river basin associated with the sea basin
*/
protected transient Map<Basin,Map<Basin,Double>> distanceBasinsPerBasin;
protected transient Map<SeaBasin,Map<RiverBasin,Double>> basinDistancesPerBasin;
@Override
......@@ -92,23 +93,34 @@ public class DisperseAndMigrateToRiverBasic extends AquaNismsGroupProcess<Diadro
super.initTransientParameters(pilot);
// calcul les poids des bassins voisins qui ne d�pendent pas des poissons pour chaque SeaBassin
BasinNetwork bn = (BasinNetwork) pilot.getAquaticWorld().getEnvironment();
accessibleBasinsPerBasin = new TreeMap<Basin, Map<Basin,Double>>();
distanceBasinsPerBasin = new TreeMap<Basin, Map<Basin,Double>>();
basinWeightsPerBasin = new TreeMap<SeaBasin, Map<RiverBasin,Double>>();
basinDistancesPerBasin = new TreeMap<SeaBasin, Map<RiverBasin,Double>>();
for (Basin seaBas : bn.getSeaBasins()){
// compoute the distance with between seaBas and all the river basins
Map<Basin,Double> mapDist = bn.getNeighboursWithDistance(seaBas);
distanceBasinsPerBasin.put(seaBas, mapDist);
for (SeaBasin seaBasin : bn.getSeaBasins()){
// prepare the distance matrix with riverBasin as key
Map<RiverBasin,Double> mapDist = new TreeMap<RiverBasin, Double>();
for (Entry<Basin,Double> entry : bn.getNeighboursWithDistance(seaBasin).entrySet() ) {
mapDist.put((RiverBasin) bn.getAssociatedRiverBasin(entry.getKey()), entry.getValue());
}
// fill basin Distances Per Basin
basinDistancesPerBasin.put(seaBasin, mapDist);
// Compute the weight of each river basin
Map<Basin,Double> accessibleBasins = bn.getNeighboursWithDistance(seaBas);
for (Basin bas : accessibleBasins.keySet()){
double weight = alpha0Rep
- alpha1Rep * ((accessibleBasins.get(bas)-meanInterDistance)/standardDeviationInterDistance)
+ alpha3Rep*((((RiverBasin) bn.getAssociatedRiverBasin(bas)).getAttractiveSurface()-meanBvSurface)/standardDeviationBvSurface);
accessibleBasins.put(bas, weight);
}
accessibleBasinsPerBasin.put(seaBas, accessibleBasins);
//Map<Basin,Double> accessibleBasins = bn.getNeighboursWithDistance(seaBas);
Map<RiverBasin,Double> mapWeights = new TreeMap<RiverBasin, Double>();
for (Entry<Basin,Double> entry : bn.getNeighboursWithDistance(seaBasin).entrySet() ) {
mapWeights.put((RiverBasin) bn.getAssociatedRiverBasin(entry.getKey()), entry.getValue());
}
//replace the value by the weight
for (Entry<RiverBasin, Double> entry : mapWeights.entrySet()) {
double weight = alpha0Rep
- alpha1Rep * ((entry.getValue() - meanInterDistance) / standardDeviationInterDistance)
+ alpha3Rep* ((entry.getKey().getSurface() - meanBvSurface) / standardDeviationBvSurface);
mapWeights.put(entry.getKey(), weight);
}
basinWeightsPerBasin.put(seaBasin, mapWeights);
}
}
......
......@@ -3,11 +3,14 @@ package species;
import java.util.ArrayList;
import java.util.TreeMap;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Map.Entry;
import environment.Basin;
import environment.BasinNetwork;
import environment.RiverBasin;
import environment.SeaBasin;
import environment.Time;
import environment.Time.Season;
import fr.cemagref.simaqualife.kernel.processes.AquaNismsGroupProcess;
......@@ -32,53 +35,71 @@ public class DisperseAndMigrateToRiverStandardization extends AquaNismsGroupProc
private double alpha2Rep = 0.;
private double alpha3Rep = 0.;
private transient Map<Basin,Map<Basin,Double>> accessibleBasinsPerBasin;
private transient Map<Basin,Map<Basin,Double>> distanceBasinsPerBasin;
private transient Map<SeaBasin,Map<RiverBasin,Double>> basinWeightsPerBasin;
private transient Map<SeaBasin,Map<RiverBasin,Double>> basinDistancesPerBasin;
//private transient ObservablesHandler cObservable;
@Override
@InitTransientParameters
public void initTransientParameters(Pilot pilot) {
super.initTransientParameters(pilot);
super.initTransientParameters(pilot);
// calcul les poids des bassins voisins qui ne d�pendent pas des poissons pour chaque SeaBassin
BasinNetwork bn = (BasinNetwork) pilot.getAquaticWorld().getEnvironment();
accessibleBasinsPerBasin = new TreeMap<Basin, Map<Basin,Double>>();
distanceBasinsPerBasin = new TreeMap<Basin, Map<Basin,Double>>();
// calcul les poids des bassins voisins qui ne d�pendent pas des poissons pour chaque SeaBassin
for (Basin seaBas : bn.getSeaBasins()){
Map<Basin,Double> mapDist = bn.getNeighboursWithDistance(seaBas);
distanceBasinsPerBasin.put(seaBas, mapDist);
basinDistancesPerBasin = new TreeMap<SeaBasin, Map<RiverBasin,Double>>();
basinWeightsPerBasin = new TreeMap<SeaBasin, Map<RiverBasin,Double>>();
for (SeaBasin seaBasin : bn.getSeaBasins()){
// prepare the distance matrix with riverBasin as key
Map<RiverBasin,Double> mapDist = new TreeMap<RiverBasin, Double>();
for (Entry<Basin,Double> entry : bn.getNeighboursWithDistance(seaBasin).entrySet() ) {
mapDist.put((RiverBasin) bn.getAssociatedRiverBasin(entry.getKey()), entry.getValue());
}
// Compute the mean and standard deviation of the distance between seaBas and the other basin
// fill basin Distances Per Basin
basinDistancesPerBasin.put(seaBasin, mapDist);
// fill basin Weights Per Basin
// compute the mean and standard deviation of the distance between seaBas and the other basin
double sumOfDistance = 0.;
double sumOfSquareDistance = 0.;
double sumOfSurface = 0.;
double sumOfSquareSurface = 0.;
for (Basin bas : mapDist.keySet()){
sumOfDistance += mapDist.get(bas);
sumOfSquareDistance += Math.pow(mapDist.get(bas),2);
sumOfSurface += ((RiverBasin) bn.getAssociatedRiverBasin(bas)).getSurface();
sumOfSquareSurface += Math.pow(((RiverBasin) bn.getAssociatedRiverBasin(bas)).getSurface(), 2);
for (Entry<RiverBasin, Double> entry : mapDist.entrySet()) {
sumOfDistance += entry.getValue() ;
sumOfSquareDistance += entry.getValue() * entry.getValue();
double basinSurface = entry.getKey().getSurface();
sumOfSurface += basinSurface;
sumOfSquareSurface += basinSurface * basinSurface;
}
double meanOfInterBasinDistance = sumOfDistance / mapDist.size();
double meanOfSquareInterBasinDistance = sumOfSquareDistance / mapDist.size();
double standardDeviationOfInterBasinDistance = Math.pow((meanOfSquareInterBasinDistance - Math.pow(meanOfInterBasinDistance, 2)) , 0.5);
double standardDeviationOfInterBasinDistance = Math.pow(meanOfSquareInterBasinDistance - (meanOfInterBasinDistance * meanOfInterBasinDistance) , 0.5);
double meanOfBasinsSurface = sumOfSurface / mapDist.size();
double meanOfSquareBasinsSurface = sumOfSquareSurface / mapDist.size();
double standardDeviationOfBasinsSurface = Math.pow((meanOfSquareBasinsSurface - Math.pow(meanOfBasinsSurface, 2)) , 0.5);
double standardDeviationOfBasinsSurface = Math.pow(meanOfSquareBasinsSurface - (meanOfBasinsSurface * meanOfBasinsSurface) , 0.5);
// Compute the weight of each basin
Map<Basin,Double> accessibleBasins = bn.getNeighboursWithDistance(seaBas);
for (Basin bas : accessibleBasins.keySet()){
// compute the weight of each basin
//Map<Basin,Double> accessibleBasins = bn.getNeighboursWithDistance(seaBasin);
Map<RiverBasin,Double> mapWeights = new TreeMap<RiverBasin, Double>();
for (Entry<Basin,Double> entry : bn.getNeighboursWithDistance(seaBasin).entrySet() ) {
mapWeights.put((RiverBasin) bn.getAssociatedRiverBasin(entry.getKey()), entry.getValue());
}
//replace the value by the weight
for (Entry<RiverBasin, Double> entry : mapWeights.entrySet()) {
double weight = alpha0Rep
- alpha1Rep * ((accessibleBasins.get(bas) - meanOfInterBasinDistance)/standardDeviationOfInterBasinDistance)
+ alpha3Rep*((((RiverBasin) bn.getAssociatedRiverBasin(bas)).getSurface() - meanOfBasinsSurface) / standardDeviationOfBasinsSurface);
accessibleBasins.put(bas, weight);
- alpha1Rep * ((entry.getValue() - meanOfInterBasinDistance) / standardDeviationOfInterBasinDistance)
+ alpha3Rep* ((entry.getKey().getSurface() - meanOfBasinsSurface) / standardDeviationOfBasinsSurface);
mapWeights.put(entry.getKey(), weight);
}
accessibleBasinsPerBasin.put(seaBas, accessibleBasins);
basinWeightsPerBasin.put(seaBasin, mapWeights);
}
}
......@@ -89,96 +110,111 @@ public class DisperseAndMigrateToRiverStandardization extends AquaNismsGroupProc
@Override
public void doProcess(DiadromousFishGroup group) {
if (group.getEnvironment().getTime().getSeason(group.getPilot()) == riverMigrationSeason ){
BasinNetwork bn = group.getEnvironment();
double dMaxDispFish = 0.;
long amountWithHoming, strayedAmount;
long homingAmount, strayedAmount;
double meanLengthOfMatureFishes = group.getMeanLengthOfMatureFish();
double standardDeviationOfMatureFishesLength = group.getStandardDeviationOfMatureFishLength();
Map<Basin,Double> distBasOfFish;
List<DiadromousFish> deadFish = new ArrayList<DiadromousFish>();
List<DiadromousFish> newFish = new ArrayList<DiadromousFish>();
for (DiadromousFish fish : group.getAquaNismsList() ) {
if (fish.isMature()) {
// fish with homing
amountWithHoming = Miscellaneous.binomialForSuperIndividual(group.getPilot(), fish.getAmount(), pHoming); // seuil par d�faut fix� � 50
// strayed fish
strayedAmount = fish.getAmount() - amountWithHoming;
if (strayedAmount != 0) {
// On r�cup�re les info du poids des bassin par rapport � la position du poisson
Map<Basin,Double> accBasOfFish= new TreeMap<Basin, Double>(accessibleBasinsPerBasin.get(fish.getPosition()));
//accBasOfFish = accessibleBasinsPerBasin.get(fish.getPosition());
// On retire certains bassins si on consid�re une distance max de dispersion
distBasOfFish = distanceBasinsPerBasin.get(fish.getPosition());
if (group.getdMaxDisp() != 0){
// TODO pourquoi distbasoffish peut �tre nul ?
if (distBasOfFish != null){
for (SeaBasin departure : bn.getSeaBasins()) {
// distance from departure basin to destination basin
Map<RiverBasin,Double> distanceBasinFromDeparture = basinDistancesPerBasin.get(departure);
RiverBasin homingDestination = (RiverBasin) bn.getAssociatedRiverBasin(departure);
ListIterator<DiadromousFish> fishIterator = departure.getFishs(group) .listIterator();
while (fishIterator.hasNext()) {
DiadromousFish fish = fishIterator.next();
//for (DiadromousFish fish : group.getAquaNismsList() ) {
if (fish.isMature()) {
// fish with homing
homingAmount = Miscellaneous.binomialForSuperIndividual(group.getPilot(), fish.getAmount(), pHoming); // seuil par d�faut fix� � 50
// strayed fish
strayedAmount = fish.getAmount() - homingAmount;
if (strayedAmount != 0) {
// accessible basin from the departure basin. depend of the size of the fish
Map<RiverBasin,Double> wForAccessibleBasins = new TreeMap<RiverBasin, Double>(basinWeightsPerBasin.get(departure));
// remove basins too far
if (group.getdMaxDisp() != 0){
dMaxDispFish = (group.getdMaxDisp()/group.getLinfVonBert(fish))*fish.getLength();
// load accessible basins
for (Basin surroundingBasin : distBasOfFish.keySet()){
Double distance = distBasOfFish.get(surroundingBasin);
for (Basin surroundingBasin : distanceBasinFromDeparture.keySet()){
double distance = distanceBasinFromDeparture.get(surroundingBasin);
//System.out.println("pour le poisson " + fish.hashCode() + " situ� dans le bassin " + basin.getName() + " et n� dans le bassin " + fish.getBirthBasin().getName());
//System.out.println("la distance vaut " + distance + " pour le bassin " + surroundingBasin.getName());
if (distance >= dMaxDispFish) {
accBasOfFish.remove(surroundingBasin);
wForAccessibleBasins.remove(surroundingBasin);
}
}
}
}
}
}
// We fill the weight table
double totalWeight = 0.;
double probToGo = 0.;
long amountToGo = 0;
// TODO Qu'est ce qui se passe si AccBasOfFish est vide... �a beug pas mais c'est pas tr�s clair... donc � v�rifier
for (Basin accBasin : accBasOfFish.keySet()){
double accBasinWeightLogit = accBasOfFish.get(accBasin) + alpha2Rep*((fish.getLength() - meanLengthOfMatureFishes) / standardDeviationOfMatureFishesLength);
double accBasinWeight = 1 / (1 + Math.exp(- accBasinWeightLogit));
accBasOfFish.put(accBasin, accBasinWeight);
totalWeight += accBasinWeight;
}
// We fill the weight table
double totalWeight = 0.;
double probToGo = 0.;
long amountToGo = 0;
// TODO Qu'est ce qui se passe si AccBasOfFish est vide... �a beug pas mais c'est pas tr�s clair... donc � v�rifier
for (RiverBasin destination : wForAccessibleBasins.keySet()){
double accBasinWeightLogit = wForAccessibleBasins.get(destination) + alpha2Rep*((fish.getLength() - meanLengthOfMatureFishes) / standardDeviationOfMatureFishesLength);
double accBasinWeight = 1 / (1 + Math.exp(- accBasinWeightLogit));
wForAccessibleBasins.put(destination, accBasinWeight);
totalWeight += accBasinWeight;
}
// compute sequentially the prob to go into a basin
for (Basin accBasin : accBasOfFish.keySet()){
probToGo = accBasOfFish.get(accBasin) / totalWeight;
amountToGo = Miscellaneous.binomialForSuperIndividual(group.getPilot(), strayedAmount, probToGo);
// compute sequentially the prob to go into a basin
for (RiverBasin destination : wForAccessibleBasins.keySet()){
probToGo = wForAccessibleBasins.get(destination) / totalWeight;
amountToGo = Miscellaneous.binomialForSuperIndividual(group.getPilot(), strayedAmount, probToGo);
if (amountToGo > 0){
newFish.add(fish.duplicateWithNewPositionAndAmount(group.getPilot(), bn.getAssociatedRiverBasin(accBasin), amountToGo));
}
if (amountToGo > 0){
// add a "duplicated" fish in the destination basin
DiadromousFish duplicatedFish = fish.duplicateWithNewPositionAndAmount(group.getPilot(), destination, amountToGo);
destination.addFish(duplicatedFish, group);
//newFish.add(fish.duplicateWithNewPositionAndAmount(group.getPilot(), bn.getAssociatedRiverBasin(accBasin), amountToGo));
}
totalWeight -= accBasOfFish.get(accBasin);
strayedAmount -= amountToGo;
totalWeight -= wForAccessibleBasins.get(destination);
strayedAmount -= amountToGo;
}
}
}
// update fish with homing
if (amountWithHoming > 0){
fish.setAmount(amountWithHoming);
// retour soit dans le bassin de naissance pour les semelpares
// soit dans le dernier bassin de reproduction pour les it�ropares
fish.moveTo(group.getPilot(), bn.getAssociatedRiverBasin(fish.getPosition()), group);
} else {
deadFish.add(fish);
// move still alive fish with homing
if (homingAmount > 0){
fish.setAmount(homingAmount);
// retour soit dans le bassin de naissance pour les semelpares
// soit dans le dernier bassin de reproduction pour les it�ropares
//fish.moveTo(group.getPilot(), bn.getAssociatedRiverBasin(fish.getPosition()), group);
fish.setPosition(homingDestination);
}/* else {
deadFish.add(fish);
}*/
// remove from the list of departure basin
fishIterator.remove();
}
}
}
/*
for (DiadromousFish fish : deadFish){
group.removeAquaNism(fish);
}
for (DiadromousFish fish : newFish){
group.addAquaNism(fish);
}
*/
}
}
}
......@@ -2,13 +2,19 @@ package species;
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;
import environment.Basin;
import environment.BasinNetwork;
import environment.RiverBasin;
import environment.SeaBasin;
import environment.Time;
import environment.Time.Season;
import fr.cemagref.simaqualife.kernel.processes.AquaNismsGroupProcess;
import fr.cemagref.simaqualife.pilot.Pilot;
import miscellaneous.Miscellaneous;
import org.openide.util.lookup.ServiceProvider;
......@@ -24,61 +30,61 @@ import miscellaneous.Duo;
@ServiceProvider(service = AquaNismsGroupProcess.class)
public class DisperseAndMigrateToRiverWithMultiNomDistriAndDeathBasin extends DisperseAndMigrateToRiverBasic {
/**
* the season when fish migrate to the river to reproduce
* @unit
*/
private Season riverMigrationSeason = Season.SPRING;
/**
* the homing probalilty during the installation of new populations ( to reach kind of equilibrium)
* @unit
*/
private double pHomingForReachEquil = 1.0;
/**
* the homing probalilty after the installation of new populations ( after reaching an equilibrium)
* @unit
*/
private double pHomingAfterEquil = 0.8;
/**
* Number of year for newly created populations to be installed ( to reach an equilibrium)
* @unit
*/
private long NbYearForInstallPop = 50;
/** the coefficient associated with the fish size in the logistic function used to calculate the probability to disperse
* @unit -
*/
private double alpha2Rep = 0.;
/**
* the mean length used to standardize the fish length in the logistic function that calculates the probability to disperse
* @unit -
*/
private double meanSpawnersLengthAtRepro = 45.;
/**
* the length standard deviation used to standardize the fish length in the logistic function that calculates the probability to disperse
* @unit -
*/
private double standardDeviationOfSpawnersLengthAtRepro = 2.; // for standard core values...
/**
* the weigth of the death bassin ( for strayers that do not find a catcment) used to calculate the probability to disperse
* @unit
*/
private double weightOfDeathBasin = 0.2;
/**
* a bollean to kill of the strayers (used to determine if a catchment is a souce or a sink) the year given by yearOfTheKilling
* @unit
*/
private boolean killStrayers;
/**
* the year when the strayers are killed (used to determine if a catchment is a souce or a sink) if killStrayers is true
* @unit
......@@ -90,6 +96,14 @@ public class DisperseAndMigrateToRiverWithMultiNomDistriAndDeathBasin extends Di
.toXML(new DisperseAndMigrateToRiverWithMultiNomDistriAndDeathBasin()));
}
@Override
public void initTransientParameters(Pilot pilot) {
// TODO Auto-generated method stub
super.initTransientParameters(pilot);
}
@Override
public void doProcess(DiadromousFishGroup group) {
Time time = group.getEnvironment().getTime();
......@@ -97,7 +111,7 @@ public class DisperseAndMigrateToRiverWithMultiNomDistriAndDeathBasin extends Di
if (time.getSeason(group.getPilot()) == riverMigrationSeason) {
BasinNetwork bn = group.getEnvironment();
long amountWithHoming, strayedAmount;
long homingAmount, strayedAmount;
// probability of homing
double pHoming;
......@@ -107,113 +121,120 @@ public class DisperseAndMigrateToRiverWithMultiNomDistriAndDeathBasin extends Di
pHoming = pHomingAfterEquil;
}
List<DiadromousFish> deadFish = new ArrayList<DiadromousFish>();
List<DiadromousFish> newFish = new ArrayList<DiadromousFish>();
//List<DiadromousFish> deadFish = new ArrayList<DiadromousFish>();
//List<DiadromousFish> newFish = new ArrayList<DiadromousFish>();
//List<Duo<DiadromousFish, Basin>> fishesToMove = new ArrayList<Duo<DiadromousFish, Basin>>();
// creation of the death basin (for the lost strayers)
//TODO move as a transient field
Basin deathBasin = new Basin(-1, "deathBasin", 0, 0, 0, 0);
List<Duo<DiadromousFish, Basin>> fishesToMove = new ArrayList<Duo<DiadromousFish, Basin>>();
for (Basin basin : group.getEnvironment().getSeaBasins()) {
for (SeaBasin departure : group.getEnvironment().getSeaBasins()) {
List<DiadromousFish> fishes = basin.getFishs(group);
RiverBasin homingDestination = (RiverBasin) bn.getAssociatedRiverBasin(departure);
List<DiadromousFish> fishes = departure.getFishs(group);
if (fishes != null) {
for (DiadromousFish fish : fishes) {
// verify that fish is in a sea basin
assert fish.getPosition().getType() == Basin.TypeBassin.SEA;
ListIterator<DiadromousFish> fishIterator = fishes .listIterator();
while (fishIterator.hasNext()) {
DiadromousFish fish = fishIterator.next();
//for (DiadromousFish fish : fishes) {
if (fish.isMature()) {
// fish with homing
amountWithHoming = Miscellaneous.binomialForSuperIndividual(group.getPilot(), fish.getAmount(), pHoming); // seuil par d�faut fix� � 50
homingAmount = Miscellaneous.binomialForSuperIndividual(group.getPilot(), fish.getAmount(), pHoming); // seuil par d�faut fix� � 50
// strayed fish
if (killStrayers == true && time.getYear(group.getPilot()) >= yearOfTheKillings) {
strayedAmount = 0;
}
else {
strayedAmount = fish.getAmount() - amountWithHoming;
strayedAmount = fish.getAmount() - homingAmount;
}
// influence of the fish length on the probability to disperse
// manage strayed fish
if (strayedAmount != 0) {
// calcula the weight associated with the fish length in the probabaility to disperse
// calculate the weight associated with the fish length in the probabaility to disperse
double weightFishLength = -(alpha2Rep * ((fish.getLength() - meanSpawnersLengthAtRepro) / standardDeviationOfSpawnersLengthAtRepro));
// upload the weights associated with features of the catchment (accessibility and attractivity)
List<Duo<Basin, Double>> accBasOfFish = new ArrayList<Duo<Basin, Double>>();
for (Map.Entry<Basin, Double> entry : accessibleBasinsPerBasin.get(fish.getPosition()).entrySet()) {
Duo<Basin, Double> duo = new Duo<Basin, Double>(entry.getKey(), entry.getValue());
accBasOfFish.add(duo);
}
Map<RiverBasin, Double> basinWeightswithDeathWeight = new TreeMap<RiverBasin,Double>();
// We fill the weight table
double totalWeight = 0.;
double probToGo = 0.;
long amountToGo = 0;
// TODO manage the case when AccBasOfFish is empty
for (Duo<Basin, Double> accBasin : accBasOfFish) {
// total weight for the basin
Basin b = accBasin.getFirst();
Double weight = accBasin.getSecond();
//for (Duo<Basin, Double> accBasin : accBasOfFish) {
for (Entry<RiverBasin, Double> entry : basinWeightsPerBasin.get(departure).entrySet()) {
// total weight for the basins
RiverBasin destination = entry.getKey();
double weight = entry.getValue();
double accBasinWeight = 1 / (1 + Math.exp(-(weight + weightFishLength)));
// put weight to 0 for unused basins
if (group.isThereBasinToUpdate()){
if (time.getYear(group.getPilot()) >= group.getYearOfTheUpdate()
&& group.getPattractive(b.getName()) == 0){
&& group.getPattractive(destination.getName()) == 0){
//TODO use correctely getPaccessible
accBasinWeight = 0 ;
}
}