diff --git a/src/GridGenerator/StreetPointFinder/JunctionReader.cpp b/src/GridGenerator/StreetPointFinder/JunctionReader.cpp deleted file mode 100644 index 3e813247e78f76055b5660dc086643427f027cdf..0000000000000000000000000000000000000000 --- a/src/GridGenerator/StreetPointFinder/JunctionReader.cpp +++ /dev/null @@ -1,64 +0,0 @@ -#include "JunctionReader.h" - -#include <fstream> -#include <iostream> - - -JunctionInReader::JunctionInReader(std::vector<uint> inCells, std::vector<uint> outCells, std::vector<int> carCanNotEnterThisOutCell) : - inCells{ inCells }, outCells{ outCells }, carCanNotEnterThisOutCell{ carCanNotEnterThisOutCell } -{} - -void JunctionReader::readJunctions(std::string filename, StreetPointFinder streetPointFinder) -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "StreetPointFinder::readJunctions( " << filename << " )" << "\n"; - - std::ifstream file; - file.open(filename.c_str()); - if (!file.is_open()) std::cerr << "File not found" << std::endl; - this->streetPointFinder = streetPointFinder; - - uint numberOfJunctions; - file >> numberOfJunctions; - - int streetIndex; - char startOrEnd; - - for (uint i = 0; i < numberOfJunctions; i++) { - std::vector<uint> inCells, outCells; - std::vector<int> carCanNotEnterThisOutCell; - - //inCells - for (uint i = 0; i < 4; i++) { - file >> streetIndex >> startOrEnd; - if (streetIndex >= 0) - inCells.push_back(getCellIndex(streetIndex, startOrEnd)); - } - - //outCells - for (uint i = 0; i < 4; i++) { - file >> streetIndex >> startOrEnd; - if (streetIndex >= 0) { - outCells.push_back(getCellIndex(streetIndex, startOrEnd)); - carCanNotEnterThisOutCell.push_back(getCellIndex(streetIndex, startOrEnd)); - }else if(streetIndex == -2) //allow u-turn - carCanNotEnterThisOutCell.push_back(-2); - } - - //make Junction - junctions.push_back(JunctionInReader(inCells, outCells, carCanNotEnterThisOutCell)); - } -} - - -unsigned int JunctionReader::getCellIndex(unsigned int streetIndex, char startOrEnd) -{ - uint i = 0; - unsigned int cellIndex = 0; - while (i < streetIndex) { - cellIndex += streetPointFinder.streets[i].numberOfCells; - ++i; - } - if (startOrEnd == 's') return cellIndex; - return cellIndex + streetPointFinder.streets[streetIndex].numberOfCells - 1; -} - diff --git a/src/GridGenerator/StreetPointFinder/JunctionReader.h b/src/GridGenerator/StreetPointFinder/JunctionReader.h deleted file mode 100644 index 027bfed7033b431eeffbca1ec64a46768171cb93..0000000000000000000000000000000000000000 --- a/src/GridGenerator/StreetPointFinder/JunctionReader.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef JUNCTIOREADER_H -#define JUNCTIONREADER_H - -#include <vector> - -#include "Core/DataTypes.h" -#include "Core/Logger/Logger.h" - -#include "StreetPointFinder.h" - -#include <VirtualFluidsDefinitions.h> - -struct VF_PUBLIC JunctionInReader -{ - std::vector<uint> inCells; - std::vector<uint> outCells; - std::vector<int> carCanNotEnterThisOutCell; - - JunctionInReader(std::vector<uint> inCells, std::vector<uint> outCells, std::vector<int> carCanNotEnterThisOutCell); -}; - - -struct VF_PUBLIC JunctionReader -{ - std::vector<JunctionInReader> junctions; - StreetPointFinder streetPointFinder; - - void readJunctions(std::string filename, StreetPointFinder streetPointFinder); - - -private: - unsigned int getCellIndex(unsigned int streetIndex, char startOrEnd); -}; -#endif diff --git a/src/GridGenerator/StreetPointFinder/SinkReader.cpp b/src/GridGenerator/StreetPointFinder/SinkReader.cpp deleted file mode 100644 index dfe1967509a62ebb848af7e1e001be04009b9ac1..0000000000000000000000000000000000000000 --- a/src/GridGenerator/StreetPointFinder/SinkReader.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include "SinkReader.h" - -#include <fstream> -#include <iostream> - -SinkInReader::SinkInReader(uint sinkIndex, float sinkBlockedPossibility) : - sinkIndex{ sinkIndex }, sinkBlockedPossibility{ sinkBlockedPossibility } -{} - -void SinkReader::readSinks(std::string filename, StreetPointFinder streetPointFinder) -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "StreetPointFinder::readSinks( " << filename << " )" << "\n"; - - this->streetPointFinder = streetPointFinder; - - std::ifstream file; - file.open(filename.c_str()); - if (!file.is_open()) std::cerr << "File not found" << std::endl; - - uint numberOfSinks; - file >> numberOfSinks; - - uint streetIndex; - char startOrEnd; - float sinkBlockedPossibility; - - - for (uint i = 0; i < numberOfSinks; i++) { - file >> streetIndex >> startOrEnd >> sinkBlockedPossibility; - sinks.push_back(SinkInReader(getCellIndex(streetIndex, startOrEnd), sinkBlockedPossibility)); - } -} - -unsigned int SinkReader::getCellIndex(unsigned int streetIndex, char startOrEnd) -{ - uint i = 0; - unsigned int cellIndex = 0; - while (i < streetIndex) { - cellIndex += streetPointFinder.streets[i].numberOfCells; - ++i; - } - if (startOrEnd == 's') { - return cellIndex; - } - return cellIndex + streetPointFinder.streets[streetIndex].numberOfCells - 1; -} diff --git a/src/GridGenerator/StreetPointFinder/SinkReader.h b/src/GridGenerator/StreetPointFinder/SinkReader.h deleted file mode 100644 index e4db88dc51683bdf0b20706374b2795840b7a7c3..0000000000000000000000000000000000000000 --- a/src/GridGenerator/StreetPointFinder/SinkReader.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef SINKREADER_H -#define SINKREADER_H - -#include <vector> - -#include "Core/DataTypes.h" -#include "Core/Logger/Logger.h" - -#include "StreetPointFinder.h" - -#include <VirtualFluidsDefinitions.h> - -struct VF_PUBLIC SinkInReader{ - uint sinkIndex; - float sinkBlockedPossibility; - SinkInReader(uint sinkIndex, float sinkBlockedPossibility); -}; - -struct VF_PUBLIC SinkReader -{ - std::vector<SinkInReader> sinks; - StreetPointFinder streetPointFinder; - - void readSinks(std::string filename, StreetPointFinder streetPointFinder); - -private: - unsigned int getCellIndex(unsigned int streetIndex, char startOrEnd); -}; - - -#endif \ No newline at end of file diff --git a/src/GridGenerator/StreetPointFinder/SourceReader.cpp b/src/GridGenerator/StreetPointFinder/SourceReader.cpp deleted file mode 100644 index 25c67f36e40f35e840de78f174fd81174c51f22f..0000000000000000000000000000000000000000 --- a/src/GridGenerator/StreetPointFinder/SourceReader.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "SourceReader.h" - -#include <fstream> -#include <iostream> - -SourceInReader::SourceInReader(unsigned int sourceIndex, float sourcePossibility): - sourceIndex{sourceIndex}, sourcePossibility{sourcePossibility} -{} - - -void SourceReader::readSources(std::string filename, StreetPointFinder streetPointFinder) -{ - *logging::out << logging::Logger::INFO_INTERMEDIATE << "StreetPointFinder::readSources( " << filename << " )" << "\n"; - - this->streetPointFinder = streetPointFinder; - - std::ifstream file; - file.open(filename.c_str()); - if (!file.is_open()) std::cerr << "File not found" << std::endl; - - uint numberOfSources; - file >> numberOfSources; - - uint streetIndex; - char startOrEnd; - float sourcePossibility; - - - for (uint i = 0; i < numberOfSources; i++) { - file >> streetIndex >> startOrEnd >> sourcePossibility; - sources.push_back(SourceInReader(getCellIndex(streetIndex, startOrEnd), sourcePossibility)); - } -} - - -unsigned int SourceReader::getCellIndex(unsigned int streetIndex, char startOrEnd) -{ - uint i = 0; - unsigned int cellIndex = 0; - while (i < streetIndex) { - cellIndex += streetPointFinder.streets[i].numberOfCells; - ++i; - } - if (startOrEnd == 's') { - return cellIndex; - } - return cellIndex + streetPointFinder.streets[streetIndex].numberOfCells - 1; -} diff --git a/src/GridGenerator/StreetPointFinder/SourceReader.h b/src/GridGenerator/StreetPointFinder/SourceReader.h deleted file mode 100644 index c4816e636c66f10e6772f6d411ea35b54400e381..0000000000000000000000000000000000000000 --- a/src/GridGenerator/StreetPointFinder/SourceReader.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef SOURCEREADER_H -#define SOURCEREADER_H - -#include <vector> - -#include "Core/DataTypes.h" -#include "Core/Logger/Logger.h" - -#include "StreetPointFinder.h" - -#include <VirtualFluidsDefinitions.h> - -struct VF_PUBLIC SourceInReader { - unsigned int sourceIndex; - float sourcePossibility; - SourceInReader(unsigned int sourceIndex, float sourcePossibility); -}; - -struct VF_PUBLIC SourceReader -{ - std::vector<SourceInReader> sources; - StreetPointFinder streetPointFinder; - - void readSources(std::string filename, StreetPointFinder streetPointFinder); - -private: - unsigned int getCellIndex(unsigned int streetIndex, char startOrEnd); -}; - - -#endif \ No newline at end of file diff --git a/src/GridGenerator/StreetPointFinder/StreetPointFinder.cpp b/src/GridGenerator/StreetPointFinder/StreetPointFinder.cpp index 8b522fa5b6182486961a48f52a218249274ebae5..be7000ea792bbb7257a1757c407886471f591e31 100644 --- a/src/GridGenerator/StreetPointFinder/StreetPointFinder.cpp +++ b/src/GridGenerator/StreetPointFinder/StreetPointFinder.cpp @@ -298,7 +298,7 @@ void StreetPointFinder::writeVTK(std::string filename, const std::vector<int>& c } } - ////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////// file.close(); diff --git a/src/GridGenerator/StreetPointFinder/StreetPointFinder.h b/src/GridGenerator/StreetPointFinder/StreetPointFinder.h index e8099f2098b05bde892df3aa4a4861d7ac76d6bc..03e547209ee73e12de9631943dff6641a0521807 100644 --- a/src/GridGenerator/StreetPointFinder/StreetPointFinder.h +++ b/src/GridGenerator/StreetPointFinder/StreetPointFinder.h @@ -28,7 +28,7 @@ struct VF_PUBLIC Street std::vector<uint> matrixIndicesLB; std::vector<uint> sparseIndicesLB; - // The constructor expect start and end for cells + // The constructor expect star and end for cells Street( real xStartCell, real yStartCell, real xEndCell, real yEndCell, real dx ); real getCoordinateX( int cellIndex ); diff --git a/src/Traffic/Output/ConcentrationByPosition.cpp b/src/Traffic/ConcentrationByPosition.cpp similarity index 100% rename from src/Traffic/Output/ConcentrationByPosition.cpp rename to src/Traffic/ConcentrationByPosition.cpp diff --git a/src/Traffic/Output/ConcentrationByPosition.h b/src/Traffic/ConcentrationByPosition.h similarity index 100% rename from src/Traffic/Output/ConcentrationByPosition.h rename to src/Traffic/ConcentrationByPosition.h diff --git a/src/Traffic/Output/ConcentrationOutwriter.h b/src/Traffic/ConcentrationOutwriter.h similarity index 100% rename from src/Traffic/Output/ConcentrationOutwriter.h rename to src/Traffic/ConcentrationOutwriter.h diff --git a/src/Traffic/Junction/Junction.h b/src/Traffic/Junction.h similarity index 90% rename from src/Traffic/Junction/Junction.h rename to src/Traffic/Junction.h index 4772f3b5c5c465bdbd1edeb9b0c3e4b966bb669e..a41175e6f8891f3c32cf70eca020d58db9e4e7dd 100644 --- a/src/Traffic/Junction/Junction.h +++ b/src/Traffic/Junction.h @@ -14,8 +14,6 @@ public: virtual void checkOutCellIndices(unsigned int roadLength) = 0; - virtual void setCellIndexForNoUTurn(std::vector<int> carCanNotEnterThisOutCell) = 0; - virtual bool acceptsCar(unsigned int cellIndex) = 0; //determines if a car can enter the junction virtual void registerCar(unsigned int cellIndex, unsigned int numberOfCellsAlreadyMoved, unsigned int speed) = 0; //registers all cars entering the junction virtual void calculateTimeStep(OneWayRoadSSJ& road) = 0; diff --git a/src/Traffic/Junction/JunctionData.h b/src/Traffic/Junction/JunctionData.h deleted file mode 100644 index b4f92abacff22b0b9a555e52aa56d7d9a484c5e7..0000000000000000000000000000000000000000 --- a/src/Traffic/Junction/JunctionData.h +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once -#include <VirtualFluidsDefinitions.h> - -#include <vector> -#include <memory> -#include "Utilities\RandomHelper.h" - -struct VF_PUBLIC JunctionData -{ -public: - std::vector<unsigned int> inCellIndices; - std::vector<unsigned int> outCellIndices; - std::vector<int> carCanNotEnterThisOutCell; //no such inCell: -2 - - std::vector<unsigned int> freeOutCells; - - std::vector<bool> carCanEnter; - std::vector<int> carsOnJunction; - std::vector<unsigned int> alreadyMoved; - - std::mt19937 engine = RandomHelper::make_engine(); - uniform_int_distribution<unsigned int> distInt2{ 0, 1 }; - uniform_int_distribution<unsigned int> distInt3{ 0, 2 }; - uniform_int_distribution<unsigned int> distInt4{ 0, 3 }; -}; - diff --git a/src/Traffic/JunctionData.h b/src/Traffic/JunctionData.h new file mode 100644 index 0000000000000000000000000000000000000000..e7853947f8b1beeed3a1cb030aa1f34042be956e --- /dev/null +++ b/src/Traffic/JunctionData.h @@ -0,0 +1,13 @@ +#pragma once +#include <VirtualFluidsDefinitions.h> + +#include <vector> +#include <memory> + +struct VF_PUBLIC JunctionData +{ +public: + std::vector<unsigned int> inCellIndices; + std::vector<unsigned int> outCellIndices; +}; + diff --git a/src/Traffic/Junction/JunctionSimple.cpp b/src/Traffic/JunctionSimple.cpp similarity index 50% rename from src/Traffic/Junction/JunctionSimple.cpp rename to src/Traffic/JunctionSimple.cpp index 6b1e789c64966b73bbc1e5cd639d2bf545426191..eb8b4c3a75fe3d07d5dbf8b184ca1ec98ff7cd4c 100644 --- a/src/Traffic/Junction/JunctionSimple.cpp +++ b/src/Traffic/JunctionSimple.cpp @@ -2,52 +2,42 @@ -JunctionSimple::JunctionSimple(const vector<unsigned int> &inCellIndices, const vector<unsigned int> &outCellIndices) +JunctionSimple::JunctionSimple(const vector<unsigned int> &inCellIndices, const vector<unsigned int> &outCellIndices) : + engine{ random_device{}() } { data.inCellIndices = inCellIndices; data.outCellIndices = outCellIndices; unsigned int inRoads = inCellIndices.size(); - data.carCanEnter.resize(inRoads); - fill(data.carCanEnter.begin(), data.carCanEnter.end(), true); + carCanEnter.resize(inRoads); + fill(carCanEnter.begin(), carCanEnter.end(), true); - data.carsOnJunction.resize(inRoads); - fill(data.carsOnJunction.begin(), data.carsOnJunction.end(), -1); + carsOnJunction.resize(inRoads); + fill(carsOnJunction.begin(), carsOnJunction.end(), -1); - data.alreadyMoved.resize(inRoads); - fill(data.alreadyMoved.begin(), data.alreadyMoved.end(), 0); + alreadyMoved.resize(inRoads); + fill(alreadyMoved.begin(), alreadyMoved.end(), 0); } -void JunctionSimple::setCellIndexForNoUTurn(std::vector<int> carCanNotEnterThisOutCell) +JunctionSimple::~JunctionSimple() { - try { - - if (data.inCellIndices.size() != carCanNotEnterThisOutCell.size()) throw invalidInput_error("The Vector carCanNotEnterThisOutCell and inCellIndices have to be the same size."); - data.carCanNotEnterThisOutCell = carCanNotEnterThisOutCell; - - } - catch (const exception& e) { - cerr << e.what() << endl; - cin.get(); - exit(EXIT_FAILURE); - } } bool JunctionSimple::acceptsCar(unsigned int cellIndex) { - return data.carCanEnter[getInCellsVectorIndex(cellIndex)]; + return carCanEnter[getInCellsVectorIndex(cellIndex)]; } void JunctionSimple::registerCar(unsigned int cellIndex, unsigned int numberOfCellsAlreadyMoved, unsigned int speed) { unsigned int index = getInCellsVectorIndex(cellIndex); - data.carsOnJunction[index] = speed; - data.carCanEnter[index] = false; - data.alreadyMoved[index] = numberOfCellsAlreadyMoved; + carsOnJunction[index] = speed; + carCanEnter[index] = false; + alreadyMoved[index] = numberOfCellsAlreadyMoved; } @@ -65,7 +55,7 @@ unsigned int JunctionSimple::getInCellsVectorIndex(unsigned int cellIndex) } catch (const exception& e) { cerr << e.what() << endl; - cin.get(); + cin.get(); exit(EXIT_FAILURE); } } @@ -73,14 +63,14 @@ unsigned int JunctionSimple::getInCellsVectorIndex(unsigned int cellIndex) void JunctionSimple::updateJunction() { - data.freeOutCells = data.outCellIndices; + freeOutCells = data.outCellIndices; } void JunctionSimple::calculateTimeStep(OneWayRoadSSJ& road) { index = 0; - for (int carSpeed : data.carsOnJunction) { + for (int carSpeed : carsOnJunction) { if (carSpeed >= 0) { //check if there is a car on the junction @@ -88,31 +78,29 @@ void JunctionSimple::calculateTimeStep(OneWayRoadSSJ& road) cerr << "speed on junction was 0" << endl; else applyRules(carSpeed, index, road); - data.alreadyMoved[index] = 0; + alreadyMoved[index] = 0; } - ++index; + ++ index; } } -void JunctionSimple::applyRules(int & carSpeed, const int & index, OneWayRoadSSJ& road) +void JunctionSimple::applyRules(int & carSpeed,const int & index, OneWayRoadSSJ& road) { - remainingDistance = static_cast<unsigned int>(carSpeed) - data.alreadyMoved[index]; + remainingDistance = static_cast<unsigned int>(carSpeed) - alreadyMoved[index]; - if (remainingDistance > 0) { - outCell = chooseOutCell(index); - if (outCell >= 0) { - breakCar(outCell, carSpeed, remainingDistance, road); + if (remainingDistance > 0 && freeOutCells.size() > 0) { + outCell = chooseOutCell(); + breakCar(outCell, carSpeed, remainingDistance, road); - if (remainingDistance > 0) - moveCar(outCell, carSpeed, index, road); - else - data.carsOnJunction[index] = 1; - return; - } + if (remainingDistance > 0) + moveCar(carSpeed, index, road); + else + carsOnJunction[index] = 1; } - data.carsOnJunction[index] = 1; + else + carsOnJunction[index] = 1; } @@ -123,54 +111,32 @@ void JunctionSimple::breakCar(unsigned int outCellIndex, int &speed, unsigned in speed = speed - remainingDistance + gap; remainingDistance = gap; } + } -void JunctionSimple::moveCar(unsigned int outCell, int & carSpeed, const int & index, OneWayRoadSSJ& road) +void JunctionSimple::moveCar(int & carSpeed, const int & index, OneWayRoadSSJ& road) { road.moveJunctionCar(outCell, remainingDistance, carSpeed); - data.carsOnJunction[index] = -1; - data.carCanEnter[index] = true; + carsOnJunction[index] = -1; + carCanEnter[index] = true; } -int JunctionSimple::chooseOutCell(const int & index) +unsigned int JunctionSimple::chooseOutCell() { - vector<unsigned int> freeOutCellsTemp; + uniform_int_distribution<unsigned int> distFloat(0, freeOutCells.size() - 1); + random = distFloat(engine); - if (data.carCanNotEnterThisOutCell.size() > 0 && data.carCanNotEnterThisOutCell[index]) { - for (unsigned int cell : data.freeOutCells) { - if (cell != data.carCanNotEnterThisOutCell[index]) - freeOutCellsTemp.push_back(cell); - } - } - else - freeOutCellsTemp = data.freeOutCells; - - - switch (freeOutCellsTemp.size()) { - case 0: - return -1; - case 1: - random = 0; - break; - case 2: - random = data.distInt2(data.engine); - break; - case 3: - random = data.distInt3(data.engine); - break; - case 4: - random = data.distInt4(data.engine); - break; - } - - outCell = freeOutCellsTemp[random]; - data.freeOutCells.erase(std::remove(data.freeOutCells.begin(), data.freeOutCells.end(), outCell), data.freeOutCells.end()); + outCell = freeOutCells[random]; + freeOutCells.erase(freeOutCells.begin() + random); return outCell; } + + + const vector<unsigned int>& JunctionSimple::getInCellIndices() const { return data.inCellIndices; @@ -192,7 +158,7 @@ void JunctionSimple::dispJunction(const unsigned int index, unsigned int roadLen const unsigned int JunctionSimple::getNumCarsOnJunction() const { unsigned int num = 0; - for (auto car : data.carsOnJunction) { + for (auto car : carsOnJunction) { if (car >= 0) ++num; } @@ -202,7 +168,7 @@ const unsigned int JunctionSimple::getNumCarsOnJunction() const void JunctionSimple::checkOutCellIndices(unsigned int roadLength) { - try { + try { for (unsigned int cell : data.outCellIndices) if (cell >= roadLength) throw invalidInput_error("The indices of incoming cells to a junction are greater than the roadLength."); } diff --git a/src/Traffic/Junction/JunctionSimple.h b/src/Traffic/JunctionSimple.h similarity index 76% rename from src/Traffic/Junction/JunctionSimple.h rename to src/Traffic/JunctionSimple.h index cf455de6fe83df0c25b39828ee6595b35c66b078..242724463bf9f6c65babf5677d4712eb45844724 100644 --- a/src/Traffic/Junction/JunctionSimple.h +++ b/src/Traffic/JunctionSimple.h @@ -4,10 +4,9 @@ #include <vector> #include <iostream> #include <random> -#include <algorithm> -#include "Utilities/invalidInput_error.h" -#include "Utilities/VectorHelper.h" +#include "invalidInput_error.h" +#include "VectorHelper.h" #include "Junction.h" #include "OneWayRoadSSJ.h" @@ -20,11 +19,17 @@ class VF_PUBLIC JunctionSimple : private: JunctionData data; + vector<unsigned int> freeOutCells; + + vector<bool> carCanEnter; + vector<int> carsOnJunction; + vector<unsigned int> alreadyMoved; + + mt19937 engine; + public: JunctionSimple(const vector<unsigned int> &inCellIndices, const vector<unsigned int> &outCellIndices); - ~JunctionSimple() {}; - - virtual void setCellIndexForNoUTurn(vector<int> carCanNotEnterThisOutCell); + ~JunctionSimple(); virtual bool acceptsCar(unsigned int cellIndex); //determines if a car can enter the junction virtual void registerCar(unsigned int cellIndex, unsigned int numberOfCellsAlreadyMoved, unsigned int speed); //registers all cars entering the junction @@ -36,21 +41,20 @@ public: virtual void dispJunction(const unsigned int index, unsigned int roadLength) const; virtual const unsigned int getNumCarsOnJunction() const; - virtual void checkOutCellIndices(unsigned int roadLength); + virtual void checkOutCellIndices(unsigned int roadLength); private: unsigned int getInCellsVectorIndex(unsigned int cellIndex); void applyRules(int &carSpeed,const int &index, OneWayRoadSSJ& road); void breakCar(unsigned int outCellIndex, int &speed, unsigned int &remainingDistance, OneWayRoadSSJ& road); - void moveCar(unsigned int outCell, int & carSpeed, const int & index, OneWayRoadSSJ& road); - int chooseOutCell(const int & index); - + void moveCar(int & carSpeed, const int & index, OneWayRoadSSJ& road); + unsigned int chooseOutCell(); private: //variables for temporaray calculations unsigned int remainingDistance; - int outCell; + unsigned int outCell; unsigned int random; unsigned int gap; int index; diff --git a/src/Traffic/OneWayRoad.cpp b/src/Traffic/OneWayRoad.cpp index 8a7b6d4639370a276f40d047b1f0fb2c92c29d07..12ffa09e7400408961e82d422ef86ee96c62ac02 100644 --- a/src/Traffic/OneWayRoad.cpp +++ b/src/Traffic/OneWayRoad.cpp @@ -13,9 +13,8 @@ OneWayRoad::OneWayRoad(unique_ptr<RoadNetworkData> road, const float dawdlePossi pcurrent = &this->road->current; pnext = &(this->road->next); - checkCurrentForSafetyDistance(); - initDawdle(dawdlePossibility); + initResults(); } @@ -29,8 +28,10 @@ OneWayRoad::~OneWayRoad() void OneWayRoad::initResults() { - results.resize(road->roadLength, vector<int>(1)); - VectorHelper::fillVector(results, -10); + if (saveResults) { + results.resize(road->roadLength, vector<int>(1)); + VectorHelper::fillVector(results, -10); + } } @@ -81,10 +82,7 @@ void OneWayRoad::setConcentrationOutwriter(unique_ptr<ConcentrationOutwriter> wr void OneWayRoad::setSaveResults(bool saveResults) { - if (saveResults) { - this->saveResults = true; - initResults(); - } + saveResults = true; } @@ -130,7 +128,7 @@ void OneWayRoad::initResultsForCalculation() void OneWayRoad::loopTroughTimesteps() { - for (unsigned int step = 1; step < timeSteps + 1; step++) { + for (int step = 1; step < timeSteps + 1; step++) { calculateTimestep(step); } } @@ -298,13 +296,9 @@ void OneWayRoad::writeResultsToFile() const } catch (const exception& e) { cerr << e.what() << endl; - cin.get(); - exit(EXIT_FAILURE); } catch (...) { cerr << "unknown exception while writing to file" << endl; - cin.get(); - exit(EXIT_FAILURE); } } @@ -330,27 +324,6 @@ void OneWayRoad::dispResults() VectorHelper::dispVectorColour(results); } - -void OneWayRoad::checkCurrentForSafetyDistance() -{ - if (road->safetyDistance > 0) { - unsigned int neighbor; - for (unsigned int i = 0; i < road->roadLength; i++) { - if ((*pcurrent)[i] > -1) { - neighbor = road->neighbors[i]; - for (unsigned int j = 1; j <= road->safetyDistance; j++) { - if ((*pcurrent)[neighbor] > -1) { - std::cerr << "timestep 0: safetyDistance was violated: carIndex: " << i << std::endl; - break; - } - neighbor = road->neighbors[neighbor]; - } - } - } - } -} - - void OneWayRoad::visualizeSafetyDistanceForConsole() { if (road->safetyDistance != 0) { @@ -399,4 +372,5 @@ void OneWayRoad::visualizeVehicleLengthForVTK() } } } + } \ No newline at end of file diff --git a/src/Traffic/OneWayRoad.h b/src/Traffic/OneWayRoad.h index ff4e4baf1d17385403b015787f4b7671969b4776..a9879f3bbbaf1ce938541e932993ce18cab83e26 100644 --- a/src/Traffic/OneWayRoad.h +++ b/src/Traffic/OneWayRoad.h @@ -9,11 +9,11 @@ #include <iomanip> //formatting output streams #include <windows.h> //for colourful console output -#include "Utilities/invalidInput_error.h" -#include "Utilities/VectorHelper.h" -#include "Utilities/RandomHelper.h" -#include "RoadNetwork/RoadNetworkData.h" -#include "Output/ConcentrationOutwriter.h" +#include "invalidInput_error.h" +#include "VectorHelper.h" +#include "RandomHelper.h" +#include "RoadNetworkData.h" +#include "ConcentrationOutwriter.h" using namespace std; @@ -87,8 +87,7 @@ protected: void breakCar(unsigned int carIndex, unsigned int &speed); void dawdleCar(unsigned int carIndex, unsigned int &speed); virtual void moveCar(unsigned int carIndex, unsigned int speed); - - void checkCurrentForSafetyDistance(); + virtual void visualizeSafetyDistanceForConsole(); protected: diff --git a/src/Traffic/OneWayRoadSSJ.cpp b/src/Traffic/OneWayRoadSSJ.cpp index 5fa6c52f32c27b118e99c0ea65cf8b37234d685e..b4b6bcb03f18dfd875dc31ec8f85692d0f8cdfcf 100644 --- a/src/Traffic/OneWayRoadSSJ.cpp +++ b/src/Traffic/OneWayRoadSSJ.cpp @@ -7,9 +7,8 @@ OneWayRoadSSJ::OneWayRoadSSJ(unique_ptr<RoadNetworkData> road, const float dawdl pcurrent = &this->road->current; pnext = &(this->road->next); - checkCurrentForSafetyDistance(); - initDawdle(dawdlePossibility); + initResults(); } OneWayRoadSSJ::OneWayRoadSSJ() @@ -29,9 +28,8 @@ void OneWayRoadSSJ::calculateTimestep(unsigned int step) VectorHelper::fillVector(*pnext, -1); vector<unsigned int> cars = findCarIndicesInCurrent(); - for (auto &car : cars) { + for (auto &car : cars) applyRules(car); - } for (auto &junction : road->junctions) { junction->updateJunction(); @@ -94,6 +92,7 @@ unsigned int OneWayRoadSSJ::iterateNeighborsInMove(unsigned int ¤tCell, un else break; } + return numberOfCellsMoved; } @@ -228,8 +227,9 @@ void OneWayRoadSSJ::visualizeSafetyDistanceForConsole() { neighbor = road->neighbors[i]; for (unsigned int j = 1; j <= road->safetyDistance; j++) { //junction or sink - if (neighbor <= -1000) + if (neighbor <= -1000) { break; + } if (results[neighbor][step] > -1) { cerr << "safetyDistance was violated: timestep: " << step << "\t carIndex: " << i << endl; break; @@ -245,33 +245,6 @@ void OneWayRoadSSJ::visualizeSafetyDistanceForConsole() { } - -void OneWayRoadSSJ::visualizeVehicleLengthForVTK() -{ - road->currentWithLongVehicles = *pcurrent; - - if (road->safetyDistance != 0) { - for (unsigned int i = 0; i < road->roadLength; i++) { - if ((*pcurrent)[i] > -1) { - int neighbor = road->neighbors[i]; - for (unsigned int j = 1; j <= road->safetyDistance; j++) { - if (neighbor <= -1000) - break; - if ((*pcurrent)[neighbor] > -1) { - cerr << "safetyDistance was violated: timestep: " << currentStep << "\t carIndex: " << i << endl; - break; - } - else - (road->currentWithLongVehicles)[neighbor] = (*pcurrent)[i]; - neighbor = road->neighbors[neighbor]; - } - } - } - } -} - - - void OneWayRoadSSJ::dispJunctionsAtCell(unsigned int index) const { for (auto& junc : road->junctions) { diff --git a/src/Traffic/OneWayRoadSSJ.h b/src/Traffic/OneWayRoadSSJ.h index 36d6c83c76389940056a32982994f3ae54c3c1f9..755a0bae8ba4a4e86fb90ad9a8675d839e5b5bc1 100644 --- a/src/Traffic/OneWayRoadSSJ.h +++ b/src/Traffic/OneWayRoadSSJ.h @@ -20,7 +20,6 @@ public: virtual void dispResults(); virtual const unsigned int getNumberOfCars() const; //only use for testing - virtual void visualizeVehicleLengthForVTK(); private: diff --git a/src/Traffic/Output/package.include b/src/Traffic/Output/package.include deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/src/Traffic/Utilities/RandomHelper.cpp b/src/Traffic/RandomHelper.cpp similarity index 100% rename from src/Traffic/Utilities/RandomHelper.cpp rename to src/Traffic/RandomHelper.cpp diff --git a/src/Traffic/Utilities/RandomHelper.h b/src/Traffic/RandomHelper.h similarity index 100% rename from src/Traffic/Utilities/RandomHelper.h rename to src/Traffic/RandomHelper.h diff --git a/src/Traffic/RoadNetwork/RoadMaker.cpp b/src/Traffic/RoadMaker.cpp similarity index 92% rename from src/Traffic/RoadNetwork/RoadMaker.cpp rename to src/Traffic/RoadMaker.cpp index 3c07976ba015df8cc8f7013a7661c7fa0545d503..a1a958c26d42c2e38febf9d2c859bfbf3e7e66f5 100644 --- a/src/Traffic/RoadNetwork/RoadMaker.cpp +++ b/src/Traffic/RoadMaker.cpp @@ -269,3 +269,21 @@ unsigned int RoadMaker::getMaxVelocity() return maxVelocity; } +void RoadMaker::checkCurrentForSafetyDistance() +{ + if (safetyDistance > 0) { + unsigned int neighbor; + for (unsigned int i = 0; i < roadLength; i++) { + if (current[i] > -1) { + neighbor = neighbors[i]; + for (unsigned int j = 1; j <= safetyDistance; j++) { + if ((current)[neighbor] > -1) { + std::cerr << "timestep 0: safetyDistance was violated: carIndex: " << i << std::endl; + break; + } + neighbor = neighbors[neighbor]; + } + } + } + } +} diff --git a/src/Traffic/RoadNetwork/RoadMaker.h b/src/Traffic/RoadMaker.h similarity index 96% rename from src/Traffic/RoadNetwork/RoadMaker.h rename to src/Traffic/RoadMaker.h index da6a9b722a54e43f20963504a1b12549cf3c2c15..29515c000844890e7dee7a27678d3fe9ee8a8c47 100644 --- a/src/Traffic/RoadNetwork/RoadMaker.h +++ b/src/Traffic/RoadMaker.h @@ -1,7 +1,7 @@ #pragma once #include <random> #include "RoadNetworkData.h" -#include "Utilities/RandomHelper.h" +#include "RandomHelper.h" #include <VirtualFluidsDefinitions.h> struct VF_PUBLIC RoadMaker : @@ -23,6 +23,8 @@ public: void setNeighbor(unsigned int index, unsigned int neighbor); // don't use it for setting sinks or junctions! + void checkCurrentForSafetyDistance(); + unsigned int getMaxVelocity(); private: diff --git a/src/Traffic/RoadNetwork/package.include b/src/Traffic/RoadNetwork/package.include deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/src/Traffic/RoadNetwork/RoadNetworkData.h b/src/Traffic/RoadNetworkData.h similarity index 79% rename from src/Traffic/RoadNetwork/RoadNetworkData.h rename to src/Traffic/RoadNetworkData.h index 64aa228eaac5ea11794ee7581189443706981dd9..a175d1df8c42cfcb4bb55350ce067a72344ec2c5 100644 --- a/src/Traffic/RoadNetwork/RoadNetworkData.h +++ b/src/Traffic/RoadNetworkData.h @@ -2,14 +2,14 @@ #include <memory> #include <vector> -#include "Utilities/VectorHelper.h" -#include "Utilities/invalidInput_error.h" +#include "VectorHelper.h" +#include "invalidInput_error.h" #include <VirtualFluidsDefinitions.h> -#include "Source/Source.h" -#include "Sink/Sink.h" -#include "Junction/Junction.h" +#include "Source.h" +#include "Sink.h" +#include "Junction.h" struct VF_PUBLIC RoadNetworkData diff --git a/src/Traffic/Junction/package.include b/src/Traffic/Sink.cpp similarity index 100% rename from src/Traffic/Junction/package.include rename to src/Traffic/Sink.cpp diff --git a/src/Traffic/Sink/Sink.h b/src/Traffic/Sink.h similarity index 100% rename from src/Traffic/Sink/Sink.h rename to src/Traffic/Sink.h diff --git a/src/Traffic/Sink/package.include b/src/Traffic/Sink/package.include deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/src/Traffic/Sink/SinkData.h b/src/Traffic/SinkData.h similarity index 100% rename from src/Traffic/Sink/SinkData.h rename to src/Traffic/SinkData.h diff --git a/src/Traffic/Sink/SinkSimple.cpp b/src/Traffic/SinkSimple.cpp similarity index 100% rename from src/Traffic/Sink/SinkSimple.cpp rename to src/Traffic/SinkSimple.cpp diff --git a/src/Traffic/Sink/SinkSimple.h b/src/Traffic/SinkSimple.h similarity index 86% rename from src/Traffic/Sink/SinkSimple.h rename to src/Traffic/SinkSimple.h index 583587d911bb46bc73234e070b92ce9cef17bedb..409c316b772be71957f6ef1c5ccbdeff5abc8c77 100644 --- a/src/Traffic/Sink/SinkSimple.h +++ b/src/Traffic/SinkSimple.h @@ -5,9 +5,9 @@ #include <iostream> #include <random> -#include "Utilities/RandomHelper.h" +#include "RandomHelper.h" #include "Sink.h" -#include "Utilities/invalidInput_error.h" +#include "invalidInput_error.h" using namespace std; diff --git a/src/Traffic/Source.cpp b/src/Traffic/Source.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1cc1a2393f4ec21ad892d4c8f67f53185b5457ab --- /dev/null +++ b/src/Traffic/Source.cpp @@ -0,0 +1 @@ +#include "Source.h" diff --git a/src/Traffic/Source/Source.h b/src/Traffic/Source.h similarity index 100% rename from src/Traffic/Source/Source.h rename to src/Traffic/Source.h diff --git a/src/Traffic/Source/package.include b/src/Traffic/Source/package.include deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/src/Traffic/Source/SourceData.h b/src/Traffic/SourceData.h similarity index 100% rename from src/Traffic/Source/SourceData.h rename to src/Traffic/SourceData.h diff --git a/src/Traffic/Source/SourceTerm.cpp b/src/Traffic/SourceTerm.cpp similarity index 100% rename from src/Traffic/Source/SourceTerm.cpp rename to src/Traffic/SourceTerm.cpp diff --git a/src/Traffic/Source/SourceTerm.h b/src/Traffic/SourceTerm.h similarity index 100% rename from src/Traffic/Source/SourceTerm.h rename to src/Traffic/SourceTerm.h diff --git a/src/Traffic/Utilities/package.include b/src/Traffic/Utilities/package.include deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/src/Traffic/Utilities/VectorHelper.cpp b/src/Traffic/VectorHelper.cpp similarity index 100% rename from src/Traffic/Utilities/VectorHelper.cpp rename to src/Traffic/VectorHelper.cpp diff --git a/src/Traffic/Utilities/VectorHelper.h b/src/Traffic/VectorHelper.h similarity index 100% rename from src/Traffic/Utilities/VectorHelper.h rename to src/Traffic/VectorHelper.h diff --git a/src/Traffic/Utilities/invalidInput_error.cpp b/src/Traffic/invalidInput_error.cpp similarity index 100% rename from src/Traffic/Utilities/invalidInput_error.cpp rename to src/Traffic/invalidInput_error.cpp diff --git a/src/Traffic/Utilities/invalidInput_error.h b/src/Traffic/invalidInput_error.h similarity index 100% rename from src/Traffic/Utilities/invalidInput_error.h rename to src/Traffic/invalidInput_error.h diff --git a/targets/apps/LBM/Basel/resources/Junctions.txt b/targets/apps/LBM/Basel/resources/Junctions.txt deleted file mode 100644 index 624178339b54652b30b8f194afde2f16868daa80..0000000000000000000000000000000000000000 --- a/targets/apps/LBM/Basel/resources/Junctions.txt +++ /dev/null @@ -1,5 +0,0 @@ -2 -1 e 6 e 7 e 4 e -5 s 2 s 3 s 9 s -0 e 5 e -1 a -1 a -8 s 1 s -1 a -1 a \ No newline at end of file diff --git a/targets/apps/LBM/Basel/resources/Sinks.txt b/targets/apps/LBM/Basel/resources/Sinks.txt deleted file mode 100644 index 86f4f3be8dd799810025266be9853af1efffac28..0000000000000000000000000000000000000000 --- a/targets/apps/LBM/Basel/resources/Sinks.txt +++ /dev/null @@ -1,5 +0,0 @@ -4 -2 e 0 -3 e 0 -9 e 0 -8 e 0 diff --git a/targets/apps/LBM/Basel/resources/Sources.txt b/targets/apps/LBM/Basel/resources/Sources.txt deleted file mode 100644 index 7ad46f19d67e0369dd4429e132650da8b1b28d52..0000000000000000000000000000000000000000 --- a/targets/apps/LBM/Basel/resources/Sources.txt +++ /dev/null @@ -1,5 +0,0 @@ -4 -6 s 0.1 -7 s 0.1 -4 s 0.1 -0 s 0.1 \ No newline at end of file diff --git a/targets/apps/LBM/TrafficTest/TrafficTest.cpp b/targets/apps/LBM/TrafficTest/TrafficTest.cpp index 7f04d647036258da091284ac06024d58cc2bcd64..acffce233bd0d49feb645ec29bfef7e99ac92e0f 100644 --- a/targets/apps/LBM/TrafficTest/TrafficTest.cpp +++ b/targets/apps/LBM/TrafficTest/TrafficTest.cpp @@ -2,22 +2,17 @@ #include <vector> #include <memory> -#include "Core/DataTypes.h" - #include "GridGenerator/StreetPointFinder/StreetPointFinder.h" -#include "GridGenerator/StreetPointFinder/JunctionReader.h" -#include "GridGenerator/StreetPointFinder/SourceReader.h" -#include "GridGenerator/StreetPointFinder/SinkReader.h" -#include "Traffic/RoadNetwork/RoadMaker.h" +#include "Traffic/RoadMaker.h" #include "Traffic/OneWayRoad.h" #include "Traffic/OneWayRoadSSJ.h" -#include "Traffic/Source/SourceTerm.h" -#include "Traffic/Junction/Junction.h" -#include "Traffic/Junction/JunctionSimple.h" -#include "Traffic/Sink/Sink.h" -#include "Traffic/Sink/SinkSimple.h" -#include "Traffic/Output/ConcentrationByPosition.h" +#include "Traffic/SourceTerm.h" +#include "Traffic/Junction.h" +#include "Traffic/JunctionSimple.h" +#include "Traffic/Sink.h" +#include "Traffic/SinkSimple.h" +#include "Traffic/ConcentrationByPosition.h" //using namespace std; @@ -36,13 +31,15 @@ int main() //Variables - int numberOfTimesteps = 10; - float vehicleDensity = 0.005; + int numberOfTimesteps = 100; + float vehicleDensity = 0.05; const unsigned int maxVelocity = 5; float dawdlePossibility = 0.5;//typical value: 0.2 unsigned int vehicleLength = 7; - + + + //StreetPointFinder @@ -51,53 +48,31 @@ int main() finder.readStreets("C:/Users/hiwi/BaselDokumente/VirtualFluidsGPU/git/targets/apps/LBM/streetTest/resources/ExampleStreets.txt"); finder.writeVTK("C:/Users/hiwi/Desktop/Basel_Ergebnisse/ExampleStreets.vtk"); - JunctionReader junctionReader; - junctionReader.readJunctions("C:/Users/hiwi/BaselDokumente/VirtualFluidsGPU/git/targets/apps/LBM/Basel/resources/Junctions.txt", finder); - SinkReader sinkReader; - sinkReader.readSinks("C:/Users/hiwi/BaselDokumente/VirtualFluidsGPU/git/targets/apps/LBM/Basel/resources/Sinks.txt", finder); - SourceReader sourceReader; - sourceReader.readSources("C:/Users/hiwi/BaselDokumente/VirtualFluidsGPU/git/targets/apps/LBM/Basel/resources/Sources.txt", finder); - ////RandomRoad + //One RandomRoad { - unsigned int roadLength = 0; - for (unsigned int i = 0; i < finder.streets.size(); i++) { - roadLength += finder.streets[i].numberOfCells; - } - - - auto roadNetwork = std::make_unique<RoadMaker>(roadLength, maxVelocity, vehicleLength, vehicleDensity); + std::cout << "OneWay random" << std::endl; - vector< unique_ptr<Source> > sources; - for (uint i = 0; i < sourceReader.sources.size(); i++) - sources.push_back(make_unique <SourceTerm>(sourceReader.sources[i].sourceIndex, sourceReader.sources[i].sourcePossibility, roadNetwork->getMaxVelocity())); - roadNetwork->setSources(move(sources)); - vector< unique_ptr<Sink> > sinks; - for (uint i = 0; i < sinkReader.sinks.size(); i++) - sinks.push_back(make_unique <SinkSimple>(sinkReader.sinks[i].sinkIndex, sinkReader.sinks[i].sinkBlockedPossibility)); - roadNetwork->setSinks(move(sinks)); - - - vector <unique_ptr<Junction> > junctions; - for (uint i = 0; i < junctionReader.junctions.size(); i++) { - junctions.push_back(make_unique <JunctionSimple>(junctionReader.junctions[i].inCells, junctionReader.junctions[i].outCells)); - junctions[i]->setCellIndexForNoUTurn(junctionReader.junctions[i].carCanNotEnterThisOutCell); + unsigned int roadLength = 0; + for (unsigned int i = 0; i < 2; i++) { + roadLength += finder.streets[i].numberOfCells; } - roadNetwork->setJunctions(move(junctions)); - auto simulator = std::make_shared<OneWayRoadSSJ>(move(roadNetwork), dawdlePossibility); + auto roadNetwork = std::make_unique<RoadMaker>(roadLength, maxVelocity, vehicleLength, vehicleDensity); + auto simulator = std::make_shared<OneWayRoad>(move(roadNetwork), dawdlePossibility); simulator->initCalculation(numberOfTimesteps); + //unique_ptr<ConcentrationOutwriter> writer = make_unique<ConcentrationByPosition>(ConcentrationByPosition(simulator->getRoadLength())); + //simulator->setConcentrationOutwriter(move(writer)); + - unique_ptr<ConcentrationOutwriter> writer = make_unique<ConcentrationByPosition>(ConcentrationByPosition(simulator->getRoadLength())); - simulator->setConcentrationOutwriter(move(writer)); std::string outputPath("C:/Users/hiwi/Desktop/Basel_Ergebnisse/"); @@ -110,8 +85,10 @@ int main() simulator->visualizeVehicleLengthForVTK(); finder.writeVTK(outputPath + outputFilename + "_" + std::to_string(step) + ".vtk", cars); } + std::cout << std::endl << std::endl; + } @@ -130,52 +107,6 @@ int main() - ////JunctionTest - //{ - // auto roadNetwork = std::make_unique<RoadMaker>(fiveCars, maxVelocity, vehicleLength); - - // vector <unsigned int> in4 = { 9 }; - // vector<unsigned int> out4 = { 10 }; - // std::unique_ptr<Junction> j = std::make_unique<JunctionSimple>(in4, out4); - // j->setCellIndexForNoUTurn({ 10 }); - // roadNetwork->addJunction(j); - - // std::shared_ptr<OneWayRoadSSJ> simulator = std::make_shared<OneWayRoadSSJ>(move(roadNetwork), dawdlePossibility); - // simulator->setSaveResults(true); - // simulator->initCalculation(numberOfTimesteps); - - // for (int step = 1; step < numberOfTimesteps + 1; step++) { - // simulator->calculateTimestep(step); - // } - - // std::cout << "Number of Cars: " << simulator->getNumberOfCars() << std::endl; - // simulator->dispResults(); - //} - - //{ - // dawdlePossibility = 0; - // vector<int> car = { -1,-1,-1,4,-1,-1,-1,-1,-1 }; - - // unique_ptr<RoadMaker> r = make_unique<RoadMaker>(car, 5, 2); - - // vector <unsigned int> in = { 4 }; - // vector <unsigned int> out = { 5 }; - // unique_ptr<Junction> j = make_unique<JunctionSimple>(JunctionSimple(in, out)); - // r->addJunction(j); - - // shared_ptr<OneWayRoadSSJ> simulator = make_shared<OneWayRoadSSJ>(move(r), dawdlePossibility); - // simulator->setSaveResults(true); - // simulator->initCalculation(1); - - // simulator->calculateTimestep(1); - - // bool success = false; - // if (simulator->getSpeedAtPosition(7) == 5) success = true; - // std::cout << success << std::endl; - // simulator->dispResults(); - //} - - ////OneWay random //{ // std::cout << "OneWay random" << std::endl; @@ -336,5 +267,10 @@ int main() + //junctionTest(maxVelocity, vehicleLength); + + //junctionTestCrossRoads(maxVelocity, vehicleLength); + + std::cin.get(); }