Commit 2ec99465 authored by patrick.lambert's avatar patrick.lambert
Browse files

with an abstract mother class

parent 81e30271
package environment;
import java.util.Map;
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> {
protected int memorySize; // size of all the queues
protected int memorySizeLongQueue; // size of all longer queues
protected double cVthresholdForFinalStates = 5.;
protected double RecruitmentThresholdForFsAndKappa = 50.;
protected long yearOfTheBegin = 1800;
protected transient double[][] distanceGrid;
protected transient Time time;
@InitTransientParameters
public void initTransientParameters(Pilot pilot) {
time = new Time();
}
public abstract Basin getAssociatedRiverBasin(Basin basin);
public abstract Basin getAssociatedInshoreBasin(Basin basin);
public abstract Basin getAssociatedOffshoreBasin(Basin basin);
public abstract Map<Basin, Double> getNeighboursWithDistance(Basin basin);
public abstract Basin[] getBasins();
public abstract RiverBasin getRiverBasin(String basinName);
public abstract InshoreBasin getInshoreBasin(String riverBasinName);
public abstract RiverBasin[] getRiverBasins();
public abstract InshoreBasin[] getInshoreBasins();
public abstract String[] getRiverBasinNames();
public int[] getFinalStates() {
// TODO ask to Nicolas to be able to use ReflectUtils with arguments
RiverBasin[] riverBasins = getRiverBasins();
int[] finalStates = new int[riverBasins.length];
for (int i = 0; i < riverBasins.length; i++) {
RiverBasin riverBasin = riverBasins[i];
double roundedCV = Math.round(riverBasin.getLastRecruitments().getCoefficientVariation() * 10000.) / 100.;
if (roundedCV == 0.) {
finalStates[i] = 0;
} else if (roundedCV < this.cVthresholdForFinalStates) {
finalStates[i] = 2;
} else {
finalStates[i] = 1;
}
}
return finalStates;
}
public int[] getFinalStatesWithStochasticity() {
// TODO ask to Nicolas to be able to use ReflectUtils with arguments
RiverBasin[] riverBasins = getRiverBasins();
int[] finalStates = new int[riverBasins.length];
for (int i = 0; i < riverBasins.length; i++) {
RiverBasin riverBasin = riverBasins[i];
double roundedCV = Math.round(riverBasin.getLastRecruitmentExpectations().getCoefficientVariation() * 10000.) / 100.;
if (roundedCV == 0.) {
finalStates[i] = 0;
} else if (roundedCV < this.cVthresholdForFinalStates) {
finalStates[i] = 2;
} else {
finalStates[i] = 1;
}
}
return finalStates;
}
public int[] getFinalStatesForKappa() {
// TODO ask to Nicolas to be able to use ReflectUtils with arguments
RiverBasin[] riverBasins = getRiverBasins();
int[] finalStatesForKappa = new int[riverBasins.length];
for (int i = 0; i < riverBasins.length; i++) {
RiverBasin riverBasin = riverBasins[i];
if (riverBasin.getLastRecruitments().getMean() <= RecruitmentThresholdForFsAndKappa) {
finalStatesForKappa[i] = 0;
} else {
finalStatesForKappa[i] = 1;
}
}
return finalStatesForKappa;
}
public double[] getMeanLastRecruitments() {
RiverBasin[] riverBasins = getRiverBasins();
double[] data = new double[riverBasins.length];
for (int i = 0; i < riverBasins.length; i++) {
data[i] = riverBasins[i].getLastRecruitments().getMean();
}
return data;
}
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) {
data[i] = 0.001;
} 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());
}
}
return data;
}
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();
}
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];
for (int i = 0; i < riverBasins.length; i++) {
data[i] = riverBasins[i].getLastRecruitmentExpectations().getMean();
}
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];
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];
for (int i = 0; i < riverBasins.length; i++) {
data[i] = riverBasins[i].getLastPercentagesOfAutochtones().getMean();
}
return data;
}
public long[] getYearsOfFirstNonNulRep() {
RiverBasin[] riverBasins = getRiverBasins();
long[] data = new long[riverBasins.length];
for (int i = 0; i < riverBasins.length; i++) {
data[i] = riverBasins[i].getYearOfFirstNonNulRep();
}
return data;
}
public long[] getYearsOfLastNulRep() {
RiverBasin[] riverBasins = getRiverBasins();
long[] data = new long[riverBasins.length];
for (int i = 0; i < riverBasins.length; i++) {
data[i] = riverBasins[i].getYearOfLastNulRep();
}
return data;
}
/**
* @return the yearOfTheBegin
*/
public long getYearOfTheBegin() {
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) {
// 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