Commit 4718ef61 authored by Lambert Patrick's avatar Lambert Patrick
Browse files

Remove Duo

parent 5ff97121
......@@ -5,6 +5,7 @@ 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;
......@@ -28,61 +29,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
......@@ -115,14 +116,13 @@ public class DisperseAndMigrateToRiverWithMultiNomDistriAndDeathBasin extends Di
//List<DiadromousFish> newFish = new ArrayList<DiadromousFish>();
// 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);
//Basin deathBasin = new Basin(-1, "deathBasin", 0, 0, 0, 0);
//List<Duo<DiadromousFish, Basin>> fishesToMove = new ArrayList<Duo<DiadromousFish, Basin>>();
for (SeaBasin departure : group.getEnvironment().getSeaBasins()) {
RiverBasin homingDestination = (RiverBasin) bn.getAssociatedRiverBasin(departure);
List<DiadromousFish> fishes = departure.getFishs(group);
if (fishes != null) {
//for (DiadromousFish fish : fishes) {
......@@ -131,7 +131,7 @@ public class DisperseAndMigrateToRiverWithMultiNomDistriAndDeathBasin extends Di
DiadromousFish fish=fishIterator.next();
// verify that fish is in a sea basin
//assert fish.getPosition().getType() == Basin.TypeBassin.SEA;
if (fish.isMature()) {
// fish with homing
amountWithHoming = Miscellaneous.binomialForSuperIndividual(group.getPilot(), fish.getAmount(), pHoming); // seuil par d�faut fix� � 50
......@@ -156,17 +156,18 @@ public class DisperseAndMigrateToRiverWithMultiNomDistriAndDeathBasin extends Di
accBasOfFish.add(duo);
}
// We fill the weight table
double totalWeight = 0.;
double probToGo = 0.;
long amountToGo = 0;
// TODO manage the case when AccBasOfFish is empty
/*// 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();
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()
......@@ -177,28 +178,40 @@ public class DisperseAndMigrateToRiverWithMultiNomDistriAndDeathBasin extends Di
}
accBasin.setSecond(accBasinWeight);
totalWeight += accBasinWeight;
}*/
Map<RiverBasin, Double> basinWeightsFromDeparture = new TreeMap<RiverBasin, Double>();
for (Entry<RiverBasin, Double> entry : basinWeightsPerBasin.get(departure).entrySet()) {
double accBasinWeight = 1. / (1. + Math.exp(-(entry.getValue() + weightFishLength)));
// put weight to 0 for unused basins
if (group.isThereBasinToUpdate()){
if (time.getYear(group.getPilot()) >= group.getYearOfTheUpdate()
&& group.getPattractive(entry.getKey().getName()) == 0){
//TODO use correctely getPaccessible
accBasinWeight = 0 ;
}
}
totalWeight += accBasinWeight;
basinWeightsFromDeparture.put (entry.getKey(),accBasinWeight );
}
// add the deathBasin in the list
// sum the deathBasin weight in the list
//accBasOfFish.add(new Duo<Basin, Double>(deathBasin, weightOfDeathBasin));
totalWeight = totalWeight + weightOfDeathBasin;
// compute sequentially the prob to go into a basin
for (Duo<Basin, Double> accBasin : accBasOfFish) {
Basin b = accBasin.getFirst();
Double weight = accBasin.getSecond();
for (Entry<RiverBasin, Double> entry : basinWeightsPerBasin.get(departure).entrySet()) {
RiverBasin strayerDestination = entry.getKey();
Double weight = entry.getValue();
probToGo = weight / totalWeight;
amountToGo = Miscellaneous.binomialForSuperIndividual(group.getPilot(), strayedAmount, probToGo);
if (amountToGo > 0) {
if (b.getId() != -1) {
RiverBasin strayerDestination = (RiverBasin) bn.getAssociatedRiverBasin(b);
//RiverBasin strayerDestination = (RiverBasin) bn.getAssociatedRiverBasin(b);
strayerDestination.addFish(fish.duplicateWithNewPositionAndAmount(group.getPilot(), strayerDestination, amountToGo), group);
}
//else{
//TODO add to the cemetery
//deadFish.add(fish.duplicateWithNewPositionAndAmount(accBasin, amountToGo));
//}
}
totalWeight -= weight;
strayedAmount -= amountToGo;
......@@ -220,7 +233,7 @@ public class DisperseAndMigrateToRiverWithMultiNomDistriAndDeathBasin extends Di
/*else {
deadFish.add(fish);
}*/
fishIterator.remove();
}
}
......
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