Commit 41e6c3f7 authored by Johannes Leins's avatar Johannes Leins
Browse files

put list of measures into cell

parent 1271d1cd
Pipeline #26545 passed with stage
in 51 seconds
......@@ -26,8 +26,12 @@ Cell::Cell(const Point& coord, const Point& climCoord, double coverRatio, Measur
interpolRatioByClimCoord[climCoord] = 1.0;
this->measure = measure;
setMeasure(measure);
if(!measure) {
vector<int> timing;
// empty timing vector => no disturbance
measure = new Measure(Constants::ID_DISTURBANCE_NONE, timing);
}
addMeasure(measure);
}
Point Cell::getClimCoord() {
......@@ -38,17 +42,28 @@ Point Cell::getCoord() {
return coord;
}
Measure* Cell::getMeasure() {
return measure;
Measure* Cell::getMeasure(int measureID) {
if(measureID < 0 || measureByID.find(measureID) == measureByID.end()) {
return measureByID[activeMeasureID];
}
return measureByID[measureID];
}
void Cell::setMeasure(Measure *measure) {
if(!measure) {
vector<int> timing;
// empty timing vector => no disturbance
measure = new Measure(Constants::ID_DISTURBANCE_NONE, timing);
void Cell::addMeasure(Measure *measure) {
if(measure) {
activeMeasureID = measure->getID();
measureByID[activeMeasureID] = measure;
}
}
void Cell::clearMeasures() {
measureByID.clear();
}
void Cell::setActiveMeasure(unsigned int measureID) {
if(measureByID.find(measureID) != measureByID.end()) {
this->activeMeasureID = measureID;
}
this->measure = measure;
}
void Cell::setInterpolRatio(Point climCoordInterpol, float ratio) {
......@@ -60,8 +75,8 @@ double Cell::getCoverRatio() {
return coverRatio;
}
int Cell::getLastDisturbanceTimestep() {
return measure->getLastUse();
int Cell::getLastDisturbanceTimestep(int measureID) {
return getMeasure(measureID)->getLastUse();
}
bool Cell::operator< (const Cell &ob) const
......
......@@ -28,7 +28,8 @@
class Cell {
private:
Point coord, climCoord;
Measure* measure;
unordered_map<unsigned int, Measure*> measureByID;
unsigned int activeMeasureID;
double coverRatio;
unordered_map<Point,float> interpolRatioByClimCoord;
public:
......@@ -36,10 +37,12 @@ public:
Point getClimCoord();
Point getCoord();
double getCoverRatio();
Measure* getMeasure();
void setMeasure(Measure *measure = NULL);
void addMeasure(Measure *measure = NULL);
void clearMeasures();
Measure* getMeasure(int measureID = -1);
void setActiveMeasure(unsigned int measureID);
void setInterpolRatio(Point climCoordInterpol, float ratio);
int getLastDisturbanceTimestep();
int getLastDisturbanceTimestep(int measureID = 0);
bool operator< (const Cell &ob) const;
bool operator== (const Cell &ob) const;
......
......@@ -46,7 +46,7 @@ namespace Constants
extern const int BASE_YEAR(1970);
extern const int DAYS_PER_YEAR(364);
extern const std::string NAME_DISTURBANCE_NONE("none");
extern const int ID_DISTURBANCE_NONE(0);
extern const unsigned int ID_DISTURBANCE_NONE(0);
extern const std::unordered_map<GlobalModel,std::string> GLOBAL_CLIMATE_MODEL_NAMES_BY_ENUM({
{CCCma, "CCCma-CanESM2"},
{CNRM, "CNRM-CERFACS-CNRM-CM5"},
......@@ -176,7 +176,6 @@ namespace Constants
Point(20,34),Point(21,34),Point(22,34),Point(23,34),Point(24,34),Point(25,34),Point(26,34),Point(27,34),
Point(21,35),Point(22,35),Point(23,35),Point(24,35),Point(25,35),Point(26,35),Point(29,35),Point(30,35),Point(31,35)
});
extern Benchmark BENCHMARK();
}
......
......@@ -123,7 +123,7 @@ namespace Constants
extern const int BASE_YEAR;
extern const int DAYS_PER_YEAR;
extern const std::string NAME_DISTURBANCE_NONE;
extern const int ID_DISTURBANCE_NONE;
extern const unsigned int ID_DISTURBANCE_NONE;
extern const std::unordered_map<GlobalModel,std::string> GLOBAL_CLIMATE_MODEL_NAMES_BY_ENUM;
extern const std::unordered_map<ReprConcPath,std::string> RCP_NAMES_BY_ENUM;
extern const std::string CLIMATE_MODEL_REGION;
......
......@@ -57,7 +57,7 @@ public:
class Measure {
private:
int ID;
unsigned int ID;
int duration; // duration of each use in days
......@@ -88,19 +88,19 @@ private:
double mownRatio;
Measure(int ID, bool relativeTiming, int durationDays = 0, UsageType typeOfUse = MOWING,
Measure(unsigned int ID, bool relativeTiming, int durationDays = 0, UsageType typeOfUse = MOWING,
int typeOfStrips = 0, MowingPatternType mowingPatternType = NONE, int widthOfStrips = 0,
double stockingRate = 0, bool fertilizerUsed = true,
bool mandatory = false, double payment = 0, bool insideOutMown = false, int cuttingHeight = 5);
public:
Measure(int ID, int weekOfFirstUse = 21, int deltaSecondUse = 6, int deltaThirdUse =
Measure(unsigned int ID, int weekOfFirstUse = 21, int deltaSecondUse = 6, int deltaThirdUse =
6, int deltaFourthUse = 0, int durationWeeks = 0, UsageType typeOfUse = MOWING,
int typeOfStrips = 0, MowingPatternType mowingPatternType = NONE, int widthOfStrips = 0,
double stockingRate = 0, bool fertilizerUsed = true,
bool mandatory = false, double payment = 0, bool insideOutMown = false, int cuttingHeight = 5);
Measure(int ID, vector<int> daysOfUse, bool relativeTiming = false, int durationDays = 0, UsageType typeOfUse = MOWING,
Measure(unsigned int ID, vector<int> daysOfUse, bool relativeTiming = false, int durationDays = 0, UsageType typeOfUse = MOWING,
int typeOfStrips = 0, MowingPatternType mowingPatternType = NONE, int widthOfStrips = 0,
double stockingRate = 0, bool fertilizerUsed = true,
bool mandatory = false, double payment = 0, bool insideOutMown = false, int cuttingHeight = 5);
......@@ -122,7 +122,7 @@ public:
double getMownRatio();
int getCuttingHeight();
bool isInsideOutMown();
int getID();
unsigned int getID();
};
#endif
......
......@@ -153,24 +153,28 @@ Climate* Environment::getClimate() {
Measure* Environment::getMeasure(Point coord) {
vector<int> timing;
Measure* measure = new Measure(Constants::ID_DISTURBANCE_NONE, timing);
if(uniformDisturbances && fixedDisturbanceCoords.find(coord) == fixedDisturbanceCoords.end()) {
auto itMeasuresAtCoord = activeMeasures.find(coord);
if(itMeasuresAtCoord != activeMeasures.end()) {
auto itMeasures = itMeasuresAtCoord->second.find(uniformDisturbanceID);
if(itMeasures != itMeasuresAtCoord->second.end()) {
measure = itMeasures->second;
}
}
} else {
Benchmark::getInstance().mark(1000101);
if(activeCellsByCoord.find(coord) != activeCellsByCoord.end()) {
bool uniformUnfixed = uniformDisturbances && fixedDisturbanceCoords.find(coord) == fixedDisturbanceCoords.end();
Benchmark::getInstance().mark(1000110);
if(activeCellsByCoord.find(coord) != activeCellsByCoord.end()) {
Benchmark::getInstance().mark(1000111);
if(uniformUnfixed) {
measure = activeCellsByCoord[coord]->getMeasure(uniformDisturbanceID);
}else{
measure = activeCellsByCoord[coord]->getMeasure();
}
else if(cellsByCoord.find(coord) != cellsByCoord.end()) {
Benchmark::getInstance().stop(1000111);
}
else if(cellsByCoord.find(coord) != cellsByCoord.end()) {
Benchmark::getInstance().mark(1000112);
if(uniformUnfixed) {
measure = cellsByCoord[coord]->getMeasure(uniformDisturbanceID);
}else{
measure = cellsByCoord[coord]->getMeasure();
}
Benchmark::getInstance().stop(1000101);
Benchmark::getInstance().stop(1000112);
}
Benchmark::getInstance().stop(1000110);
return measure;
}
......@@ -200,40 +204,51 @@ void Environment::setDisturbanceAt(Point coord, int disturbanceID) {
if(uniformDisturbances) {
fixedDisturbanceCoords.insert(coord);
}
auto itMeasuresAtCoord = measures.find(coord);
if(itMeasuresAtCoord != measures.end()) {
auto itMeasures = itMeasuresAtCoord->second.find(disturbanceID);
if(itMeasures != itMeasuresAtCoord->second.end()) {
Benchmark::getInstance().mark(1011001);
cellsByCoord[coord]->setMeasure(itMeasures->second);
Benchmark::getInstance().stop(1011001);
}
Benchmark::getInstance().mark(1011001);
if(activeCellsByCoord.find(coord) != activeCellsByCoord.end()) {
activeCellsByCoord[coord]->setActiveMeasure(disturbanceID);
} else {
cellsByCoord[coord]->setActiveMeasure(disturbanceID);
}
Benchmark::getInstance().stop(1011001);
//// auto itMeasuresAtCoord = measures.find(coord);
// if(measures.find(coord) != measures.end()) {
//// auto itMeasures = itMeasuresAtCoord->second.find(disturbanceID);
// if(measures[coord].find(disturbanceID) != measures[coord].end()) {
// Benchmark::getInstance().mark(1011001);
// Measure* measure = measures[coord][disturbanceID];
// if(activeMeasures.find(coord) != activeMeasures.end()) {
// activeCellsByCoord[coord]->setMeasure(measure);
// } else {
// cellsByCoord[coord]->setMeasure(measure);
// }
// Benchmark::getInstance().stop(1011001);
// }
// }
}
int Environment::getDisturbanceAt(Point coord) {
unsigned int Environment::getDisturbanceAt(Point coord) {
if(uniformDisturbances && fixedDisturbanceCoords.find(coord) == fixedDisturbanceCoords.end()) {
return uniformDisturbanceID;
}
Benchmark::getInstance().mark(1000104);
int distID = cellsByCoord[coord]->getMeasure()->getID();
Benchmark::getInstance().mark(1000104);
return distID;
if(activeCellsByCoord.find(coord) != activeCellsByCoord.end()) {
return activeCellsByCoord[coord]->getMeasure()->getID();
}
return cellsByCoord[coord]->getMeasure()->getID();
}
void Environment::clearDisturbances() {
uniformDisturbances = false;
uniformDisturbanceID = Constants::ID_DISTURBANCE_NONE;
fixedDisturbanceCoords.clear();
measures.clear();
activeMeasures.clear();
activeNeighborhoods.clear();
activeCellsByCoord.clear();
for(auto cellAt : cellsByCoord) {
cellAt.second->setMeasure(); // sets empty measure
cellAt.second->clearMeasures();
}
}
bool Environment::addDisturbance(Point coord, int disturbanceID, unordered_map<int, vector<int>> disturbancesTimingByYear) {
bool Environment::addDisturbance(Point coord, unsigned int disturbanceID, unordered_map<int, vector<int>> disturbancesTimingByYear) {
vector<int> timing;
// empty timing vector => no disturbance
Measure* measure = new Measure(Constants::ID_DISTURBANCE_NONE, timing);
......@@ -263,13 +278,7 @@ bool Environment::addDisturbance(Point coord, int disturbanceID, unordered_map<i
measure = new Measure(disturbanceID, timing, relativeTiming);
}
}
unordered_map<int, Measure*> measuresAtCoord;
auto itMeasuresAtCoord = measures.find(coord);
if(itMeasuresAtCoord != measures.end()) {
measuresAtCoord = itMeasuresAtCoord->second;
}
measuresAtCoord[disturbanceID] = measure;
measures[coord] = measuresAtCoord;
cellsByCoord[coord]->addMeasure(measure);
return measure->hasSchedule();
// TODO next line apparently only required in old version without setDisturbanceAt --> remove at some point?
// cellsByCoord[coord]->setMeasure(measure);
......@@ -399,7 +408,6 @@ void Environment::addActiveNeighbor(int key, Point activeNeighbor) {
Benchmark::getInstance().mark(1000105);
if(activeNeighborhood.find(activeNeighbor) == activeNeighborhood.end()) {
activeNeighborhood[activeNeighbor] = neighborhoods[key].at(activeNeighbor);
activeMeasures[activeNeighbor] = measures.at(activeNeighbor);
activeCellsByCoord[activeNeighbor] = cellsByCoord.at(activeNeighbor);
}
Benchmark::getInstance().stop(1000105);
......@@ -409,7 +417,6 @@ void Environment::addActiveNeighbor(int key, Point activeNeighbor) {
void Environment::removeActiveNeighbor(int key, Point activeNeighbor) {
activeNeighborhoods[key].erase(activeNeighbor);
if(activeNeighborhoods[key].size() == 0) {
activeMeasures.erase(activeNeighbor);
activeCellsByCoord.erase(activeNeighbor);
}
}
......@@ -428,7 +435,6 @@ void Environment::addActiveNeighbors(int key, unordered_set<Point> activeNeighbo
if(activeNeighborhoods[key].find(activeNeighbor) == activeNeighborhoods[key].end()) {
Benchmark::getInstance().mark(1013221);
activeNeighborhoods[key][activeNeighbor] = neighborhoods[key].at(activeNeighbor);
activeMeasures[activeNeighbor] = measures.at(activeNeighbor);
activeCellsByCoord[activeNeighbor] = cellsByCoord.at(activeNeighbor);
Benchmark::getInstance().stop(1013221);
}
......
......@@ -56,8 +56,6 @@ private:
bool uniformDisturbances = false;
int uniformDisturbanceID;
unordered_set<Point> fixedDisturbanceCoords;
unordered_map<Point, unordered_map<int, Measure*>> measures;
unordered_map<Point, unordered_map<int, Measure*>> activeMeasures;
unsigned int habitatWidth, climateCellWidth; // in m
int timestep, indexTime;
int initialTimestep, deltaTimesteps;
......@@ -119,7 +117,7 @@ public:
float getValue(ClimateVariable climVar, Point coord);
bool addDisturbance(Point coord, int disturbanceID, unordered_map<int, vector<int>> disturbancesTimingByYear = unordered_map<int, vector<int>>());
bool addDisturbance(Point coord, unsigned int disturbanceID, unordered_map<int, vector<int>> disturbancesTimingByYear = unordered_map<int, vector<int>>());
void addActiveNeighbor(int key, Point activeNeighbor);
......@@ -135,7 +133,7 @@ public:
void setDisturbanceAt(Point coord, int disturbanceID);
int getDisturbanceAt(Point coord);
unsigned int getDisturbanceAt(Point coord);
void clearDisturbances();
......
......@@ -20,7 +20,7 @@
#include "Disturbance.h"
Measure::Measure(int ID, bool relativeTiming, int durationDays, UsageType typeOfUse,
Measure::Measure(unsigned int ID, bool relativeTiming, int durationDays, UsageType typeOfUse,
int typeOfStrips, MowingPatternType mowingPatternType,
int widthOfStrips, double stockingRate, bool fertilizerUsed,
bool mandatory, double payment, bool insideOutMown, int cuttingHeight)
......@@ -49,7 +49,7 @@ Measure::Measure(int ID, bool relativeTiming, int durationDays, UsageType typeOf
}
}
Measure::Measure(int ID, vector<int> daysOfUse, bool relativeTiming, int durationDays, UsageType typeOfUse,
Measure::Measure(unsigned int ID, vector<int> daysOfUse, bool relativeTiming, int durationDays, UsageType typeOfUse,
int typeOfStrips, MowingPatternType mowingPatternType,
int widthOfStrips, double stockingRate, bool fertilizerUsed,
bool mandatory, double payment, bool insideOutMown, int cuttingHeight)
......@@ -58,7 +58,7 @@ Measure::Measure(int ID, vector<int> daysOfUse, bool relativeTiming, int duratio
timing.insert(daysOfUse.begin(), daysOfUse.end());
}
Measure::Measure(int ID, int weekOfFirstUse, int deltaSecondUse, int deltaThirdUse, int deltaFourthUse, int durationWeeks, UsageType typeOfUse, int typeOfStrips, MowingPatternType mowingPatternType,
Measure::Measure(unsigned int ID, int weekOfFirstUse, int deltaSecondUse, int deltaThirdUse, int deltaFourthUse, int durationWeeks, UsageType typeOfUse, int typeOfStrips, MowingPatternType mowingPatternType,
int widthOfStrips, double stockingRate, bool fertilizerUsed, bool mandatory, double payment, bool insideOutMown, int cuttingHeight)
: Measure(ID, true, durationWeeks * 7, typeOfUse, typeOfStrips, mowingPatternType, widthOfStrips, stockingRate, fertilizerUsed, mandatory, payment, insideOutMown, cuttingHeight)
{
......@@ -163,6 +163,6 @@ double Measure::getMownRatio() {
return mownRatio;
}
int Measure::getID() {
unsigned int Measure::getID() {
return ID;
}
......@@ -107,12 +107,12 @@ unsigned int climScenIdxEnd = climateScenarios.size();
double carryingCapacity = 25; // per sqm
vector<bool> disturbed = {false, true};
vector<int> seeds = {3, 5, 7, 11, 13, 17, 19, 23, 29, 31};
set<int> disturbanceIDs;
unordered_map<int, string> disturbanceNameByID;
unordered_map<int, string> disturbanceSchemeNameByID;
int baseSchemeID;
map<Point, int> baseDisturbanceScheme;
unordered_map<int, map<Point, int>> disturbanceSchemes;
set<unsigned int> disturbanceIDs;
unordered_map<unsigned int, string> disturbanceNameByID;
unordered_map<unsigned int, string> disturbanceSchemeNameByID;
unsigned int baseSchemeID;
map<Point, unsigned int> baseDisturbanceScheme;
unordered_map<unsigned int, map<Point, unsigned int>> disturbanceSchemes;
vector<StrategyClimate*> climateStrategies;
unordered_map<ClimateVariable, StrategyClimate*> loadedClimateData;
unordered_set<StrategyClimateNetCDF*> baseNetCDFClimateData;
......@@ -281,88 +281,6 @@ void updateClimate() {
}
}
void updateDisturbances() {
baseDisturbanceScheme.clear();
unordered_set<Point> fixedCells;
baseSchemeID = tools::strToHash("base");
int baseDistID = 0;
if(uniformDisturbances || disturbanceAppType == 0) {
baseSchemeID = Constants::ID_DISTURBANCE_NONE;
baseDistID = Constants::ID_DISTURBANCE_NONE;
}
disturbanceSchemes[baseSchemeID] = map<Point, int>({{Point(), baseDistID}});
for(auto coord : grasslandCoords) {
baseDisturbanceScheme[coord] = Constants::ID_DISTURBANCE_NONE;
if(handlerScheme->isFixedAt(coord)) {
fixedCells.insert(coord);
}
}
if(disturbanceAppType == 0 || handlerDisturbances->isEmpty()) {
return;
}
if(uniformDisturbances) {
unsigned int iDist = 0;
for(auto distID : disturbanceIDs) {
if(distID == Constants::ID_DISTURBANCE_NONE) {
continue;
}
if(disturbanceAppType == 1 && iDist == 0) {
disturbanceSchemes.clear();
baseSchemeID = distID;
for(auto coord : grasslandCoords) {
if((!soloPops || currSoloCoord == coord) && fixedCells.find(coord) != fixedCells.end()) {
baseDisturbanceScheme[coord] = tools::strToHash(handlerScheme->getDisturbanceNameAt(coord));
} else {
baseDisturbanceScheme[coord] = distID;
}
}
}
map<Point, int> distByCoord({{Point(), distID}});
for(auto coord : fixedCells) {
distByCoord[coord] = tools::strToHash(handlerScheme->getDisturbanceNameAt(coord));
}
disturbanceSchemes[distID] = distByCoord;
disturbanceSchemeNameByID[distID] = disturbanceNameByID.at(distID);
iDist++;
}
return;
}
if(!handlerScheme->isValid() || handlerScheme->isEmpty()) {
return;
}
unordered_set<Point> unfixedCells;
for(auto coord : grasslandCoords) {
int distID = tools::strToHash(handlerScheme->getDisturbanceNameAt(coord, environment->getRandGenGlobal()));
baseDisturbanceScheme[coord] = distID;
if(prognosis && !handlerScheme->isFixedAt(coord)) {
unfixedCells.emplace(coord);
}
}
for(auto distID : disturbanceIDs) {
for(auto coord : unfixedCells) {
if(distID == baseDisturbanceScheme[coord]) {
continue;
}
string key = "";
if(disturbanceAppType != BASE_IMMIGRATION && disturbanceAppType != IMMOBILE) {
key.append(std::to_string(coord.getX() + 1));
key.append("_");
key.append(std::to_string(coord.getY() + 1));
key.append("_");
}
key.append(disturbanceNameByID[distID]);
int keyID = tools::strToHash(key);
map<Point, int> disturbanceScheme;
if(disturbanceSchemes.find(keyID) != disturbanceSchemes.end()) {
disturbanceScheme = disturbanceSchemes.at(keyID);
}
disturbanceScheme[coord] = distID;
disturbanceSchemes[keyID] = disturbanceScheme;
}
}
}
// END: functions called by function initEnvironment()
// BEGIN: functions called by function outputRun()
......@@ -537,7 +455,7 @@ bool handleDisturbances() {
baseSchemeID = Constants::ID_DISTURBANCE_NONE;
baseDistID = Constants::ID_DISTURBANCE_NONE;
}
disturbanceSchemes[baseSchemeID] = map<Point, int>({{Point(), baseDistID}});
disturbanceSchemes[baseSchemeID] = map<Point, unsigned int>({{Point(), baseDistID}});
disturbanceSchemeNameByID[baseSchemeID] = baseSchemeName;
for(auto coord : grasslandCoords) {
baseDisturbanceScheme[coord] = Constants::ID_DISTURBANCE_NONE;
......@@ -559,7 +477,7 @@ bool handleDisturbances() {
unordered_set<string> loadedDisturbanceNames = handlerDisturbances->getDisturbanceNames();
for(auto loadedDistName : loadedDisturbanceNames) {
// int distID = tools::strToHash(loadedDistName);
int distID = tools::strToHash(loadedDistName);
unsigned int distID = tools::strToHash(loadedDistName);
disturbanceIDs.emplace(distID);
disturbanceNameByID[distID] = loadedDistName;
}
......@@ -579,6 +497,7 @@ bool handleDisturbances() {
}
if(disturbanceAppType == 1 && iDist == 0) {
disturbanceSchemes.clear();
disturbanceSchemeNameByID.clear();
baseSchemeID = distID;
for(auto coord : grasslandCoords) {
if((!soloPops || currSoloCoord == coord) && fixedCells.find(coord) != fixedCells.end()) {
......@@ -588,7 +507,7 @@ bool handleDisturbances() {
}
}
}
map<Point, int> distByCoord({{Point(), distID}});
map<Point, unsigned int> distByCoord({{Point(), distID}});
for(auto coord : fixedCells) {
distByCoord[coord] = tools::strToHash(handlerScheme->getDisturbanceNameAt(coord));
}
......@@ -618,6 +537,15 @@ bool handleDisturbances() {
unfixedCells.emplace(coord);
}
}
if(unfixedCells.size() == 0) {
disturbanceSchemes.clear();
disturbanceSchemeNameByID.clear();
baseSchemeName = "fixed";
baseSchemeID = tools::strToHash(baseSchemeName);
disturbanceSchemes[baseSchemeID] = baseDisturbanceScheme;
disturbanceSchemeNameByID[baseSchemeID] = baseSchemeName;
return true;
}
for(auto distID : disturbanceIDs) {
for(auto coord : unfixedCells) {
if(distID == baseDisturbanceScheme[coord]) {
......@@ -631,8 +559,8 @@ bool handleDisturbances() {
key.append("_");
}
key.append(disturbanceNameByID[distID]);
int keyID = tools::strToHash(key);
map<Point, int> disturbanceScheme;
unsigned int keyID = tools::strToHash(key);
map<Point, unsigned int> disturbanceScheme;
if(disturbanceSchemes.find(keyID) != disturbanceSchemes.end()) {
disturbanceScheme = disturbanceSchemes.at(keyID);
}
......@@ -1720,13 +1648,15 @@ int batchRun() {
}
nAlivePrev[currDisturbanceSchemeID] = 0;
Benchmark::getInstance().mark(1012000);
for(auto pairCoordDist : disturbanceScheme.second) {
Point currSchemeCoord = pairCoordDist.first;
int newDisturbanceID = pairCoordDist.second;
if(!uniformDisturbances) {
lastSchemeCoords.insert(currSchemeCoord);
if(disturbanceSchemes.size() > 1) {
for(auto pairCoordDist : disturbanceScheme.second) {
Point currSchemeCoord = pairCoordDist.first;
int newDisturbanceID = pairCoordDist.second;
if(!uniformDisturbances) {
lastSchemeCoords.insert(currSchemeCoord);
}
environment->setDisturbanceAt(currSchemeCoord, newDisturbanceID);
}
environment->setDisturbanceAt(currSchemeCoord, newDisturbanceID);
}
Benchmark::getInstance().stop(1012000);
unordered_map<Point, Population*> activeNeighborhood = environment->getActiveNeighborhood(currDisturbanceSchemeID);
......
......@@ -113,7 +113,7 @@ namespace tools{
return 0.5 * (std::erfc((mean - x) / (SD * sqrt(2.0)) ));
}
inline int strToHash(string str) {
inline unsigned int strToHash(string str) {
std::hash<std::string> hasher;
return hasher(str);
}
......
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