Commit 093f66ba authored by Lambert Patrick's avatar Lambert Patrick
Browse files

typing correction

parent e2596ee1
package environment;
import fr.cemagref.simaqualife.kernel.AquaNismsGroup;
import fr.cemagref.simaqualife.kernel.spatial.Environment;
import fr.cemagref.simaqualife.kernel.util.TransientParameters.InitTransientParameters;
import fr.cemagref.simaqualife.pilot.Pilot;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import fr.cemagref.simaqualife.kernel.AquaNismsGroup;
import fr.cemagref.simaqualife.kernel.spatial.Environment;
import fr.cemagref.simaqualife.kernel.util.TransientParameters.InitTransientParameters;
import fr.cemagref.simaqualife.pilot.Pilot;
import species.DiadromousFish;
public abstract class BasinNetwork extends Environment<Basin, DiadromousFish> {
......@@ -27,6 +27,7 @@ public abstract class BasinNetwork extends Environment<Basin, DiadromousFish> {
protected transient Time time;
@InitTransientParameters
public void initTransientParameters(Pilot pilot) {
time = new Time();
......@@ -37,33 +38,39 @@ public abstract class BasinNetwork extends Environment<Basin, DiadromousFish> {
return (id % nbBasin);
}
public int getColumn(int id) {
return ((id - (id % nbBasin)) / nbBasin);
}
public int getId(int i, int j) {
return (j * nbBasin + i);
}
public Basin getAssociatedRiverBasin(Basin basin) {
int i = getRow(basin.getId());
return (grid[getId(i, 0)]);
}
public Basin getAssociatedSeaBasin(Basin basin) {
int i = getRow(basin.getId());
return (grid[getId(i, 1)]);
}
public Basin getAssociatedOffshoreBasin(Basin basin) {
int i = getRow(basin.getId());
return (grid[getId(i, 2)]);
}
@Override
public List<Basin> getNeighbours(Basin basin) {
int j = getColumn(basin.getId());
if (j == 0) //that means for a river basin
if (j == 0) // that means for a river basin
{
return null;
} else {
......@@ -79,9 +86,10 @@ public abstract class BasinNetwork extends Environment<Basin, DiadromousFish> {
}
}
public Map<Basin, Double> getNeighboursWithDistance(Basin basin) {
int j = getColumn(basin.getId());
if (j == 0) //that means for a river basin
if (j == 0) // that means for a river basin
{
return null;
} else {
......@@ -90,22 +98,49 @@ public abstract class BasinNetwork extends Environment<Basin, DiadromousFish> {
for (int k = 0; k < nbBasin; k++) {
if (k != i) {
neighbours.put(grid[getId(k, j)],
distanceGrid[i][k]);
neighbours.put(grid[getId(k, j)], distanceGrid[i][k]);
}
}
return neighbours;
}
}
public int getNbBasin() {
return nbBasin;
}
public Basin[] getBasins() {
return grid;
}
public RiverBasin getRiverBasin(String basinName) {
RiverBasin basin = null;
for (int i = 0; i < nbBasin; i++) {
basin = (RiverBasin) grid[i];
if (basin.getName().equals(basinName))
break;
}
return basin;
}
public SeaBasin getSeaBasin(String riverBasinName) {
RiverBasin riverBasin = null;
SeaBasin seaBasin = null;
for (int i = 0; i < nbBasin; i++) {
riverBasin = (RiverBasin) grid[i];
if (riverBasin.getName().equals(riverBasinName)) {
seaBasin = (SeaBasin) grid[nbBasin + i];
break;
}
}
return seaBasin;
}
public RiverBasin[] getRiverBasins() {
RiverBasin[] riverGrid = new RiverBasin[nbBasin];
......@@ -116,6 +151,7 @@ public abstract class BasinNetwork extends Environment<Basin, DiadromousFish> {
return riverGrid;
}
public SeaBasin[] getSeaBasins() {
SeaBasin[] seaGrid = new SeaBasin[nbBasin];
......@@ -126,6 +162,7 @@ public abstract class BasinNetwork extends Environment<Basin, DiadromousFish> {
return seaGrid;
}
public String[] getRiverBasinNames() {
RiverBasin[] riverBasins = getRiverBasins();
String[] names = new String[riverBasins.length];
......@@ -135,6 +172,7 @@ public abstract class BasinNetwork extends Environment<Basin, DiadromousFish> {
return names;
}
public int[] getFinalStates() {
// TODO ask to Nicolas to be able to use ReflectUtils with arguments
......@@ -154,6 +192,7 @@ public abstract class BasinNetwork extends Environment<Basin, DiadromousFish> {
return finalStates;
}
public int[] getFinalStatesWithStochasticity() {
// TODO ask to Nicolas to be able to use ReflectUtils with arguments
......@@ -173,6 +212,7 @@ public abstract class BasinNetwork extends Environment<Basin, DiadromousFish> {
return finalStates;
}
public int[] getFinalStatesForKappa() {
// TODO ask to Nicolas to be able to use ReflectUtils with arguments
......@@ -189,6 +229,7 @@ public abstract class BasinNetwork extends Environment<Basin, DiadromousFish> {
return finalStatesForKappa;
}
public double[] getMeanLastRecruitments() {
RiverBasin[] riverBasins = getRiverBasins();
double[] data = new double[riverBasins.length];
......@@ -198,36 +239,44 @@ public abstract class BasinNetwork extends Environment<Basin, DiadromousFish> {
return data;
}
public double[] getProbOfNonNulRecruitmentDuringLastYears(){
public double[] getProbOfNonNulRecruitmentDuringLastYears() {
RiverBasin[] riverBasins = getRiverBasins();
double[] data = new double[riverBasins.length];
for (int i = 0; i < riverBasins.length; i++) {
if (riverBasins[i].getNumberOfNonNulRecruitmentDuringLastYears().getSum() < 1.0){
if (riverBasins[i].getNumberOfNonNulRecruitmentDuringLastYears().getSum() < 1.0) {
data[i] = 0.001;
}else if(riverBasins[i].getNumberOfNonNulRecruitmentDuringLastYears().getSum() > (riverBasins[i].getNumberOfNonNulRecruitmentDuringLastYears().size()-1)){
} else if (riverBasins[i].getNumberOfNonNulRecruitmentDuringLastYears()
.getSum() > (riverBasins[i].getNumberOfNonNulRecruitmentDuringLastYears().size() - 1)) {
data[i] = 0.999;
}else{
data[i] = riverBasins[i].getNumberOfNonNulRecruitmentDuringLastYears().getSum() / (riverBasins[i].getNumberOfNonNulRecruitmentDuringLastYears().size());
} else {
data[i] = riverBasins[i].getNumberOfNonNulRecruitmentDuringLastYears().getSum()
/ (riverBasins[i].getNumberOfNonNulRecruitmentDuringLastYears().size());
}
}
return data;
}
public double[] getFinalProbabilityOfPresence(){ // function computed for obtain probability of presence in 2100 for the allis shad case study
public double[] getFinalProbabilityOfPresence() { // function computed for obtain probability of presence in 2100
// for the allis shad case study
RiverBasin[] riverBasins = getRiverBasins();
double[] data = new double[riverBasins.length];
for (int i = 0; i < riverBasins.length; i++) {
data[i] = riverBasins[i].getNumberOfNonNulRecruitmentForFinalProbOfPres().getSum() / riverBasins[i].getNumberOfNonNulRecruitmentForFinalProbOfPres().size();
data[i] = riverBasins[i].getNumberOfNonNulRecruitmentForFinalProbOfPres().getSum()
/ riverBasins[i].getNumberOfNonNulRecruitmentForFinalProbOfPres().size();
}
return data;
}
public double getMeanLastRecruitmentsBV2() {
RiverBasin[] riverBasins = getRiverBasins();
double data = riverBasins[1].getLastRecruitments().getMean();
return data;
}
public double[] getMeanLastRecruitmentExpectations() {
RiverBasin[] riverBasins = getRiverBasins();
double[] data = new double[riverBasins.length];
......@@ -237,17 +286,19 @@ public abstract class BasinNetwork extends Environment<Basin, DiadromousFish> {
return data;
}
public double[] getGeoMeansLastRecsOverProdCaps() {
// TODO ask to Nicolas to be able to use ReflectUtils with arguments
RiverBasin[] riverBasins = getRiverBasins();
double [] geoMeans = new double [riverBasins.length];
double[] geoMeans = new double[riverBasins.length];
for (int i = 0; i < riverBasins.length; i++) {
geoMeans[i] = riverBasins[i].getLastRecsOverProdCaps().getGeometricMean();
}
return geoMeans;
}
public double[] getMeanLastPercOfAut() { // give the mean of the last % of autochtone spawners
RiverBasin[] riverBasins = getRiverBasins();
double[] data = new double[riverBasins.length];
......@@ -257,6 +308,7 @@ public abstract class BasinNetwork extends Environment<Basin, DiadromousFish> {
return data;
}
public long[] getYearsOfFirstNonNulRep() {
RiverBasin[] riverBasins = getRiverBasins();
long[] data = new long[riverBasins.length];
......@@ -266,6 +318,7 @@ public abstract class BasinNetwork extends Environment<Basin, DiadromousFish> {
return data;
}
public long[] getYearsOfLastNulRep() {
RiverBasin[] riverBasins = getRiverBasins();
long[] data = new long[riverBasins.length];
......@@ -283,36 +336,37 @@ public abstract class BasinNetwork extends Environment<Basin, DiadromousFish> {
return yearOfTheBegin;
}
@Override
public void addAquaNism(DiadromousFish fish, AquaNismsGroup group) {
// TODO Auto-generated method stub
}
@Override
public void moveAquaNism(DiadromousFish fish, AquaNismsGroup group,
Basin destination) {
public void moveAquaNism(DiadromousFish fish, AquaNismsGroup group, Basin destination) {
// TODO Auto-generated method stub
}
@Override
public void removeAquaNism(DiadromousFish fish, AquaNismsGroup group) {
// TODO Auto-generated method stub
}
public abstract Map<String, Double[]> getTemperaturesBasin(long year);
public abstract String getTemperatureCatchmentFile();
/**
* @return the time
*/
public Time getTime() {
return time;
}
}
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