diff --git a/src/ShortestPath/Transit/TransitAlgorithmState.h b/src/ShortestPath/Transit/TransitAlgorithmState.h index adbc5a3b77765dd19222a12c331035d3c6b17b1a..29ad87aac2b855ac3e36983c3cce386bf93207d0 100644 --- a/src/ShortestPath/Transit/TransitAlgorithmState.h +++ b/src/ShortestPath/Transit/TransitAlgorithmState.h @@ -16,6 +16,7 @@ private: int _instant; int _passageIndex; std::vector<LineStop> _connections; + int _precedingNodeIndex; public: TransitAlgorithmState(int currentNode, int currentInstant, int currentPassageIndex) { @@ -29,9 +30,11 @@ public: _nodeIndex = baseState.getNodeIndex(); _instant = baseState.getInstant(); _passageIndex = baseState.getPassageIndex(); - _connections.reserve(2); + _precedingNodeIndex = baseState.getPrecedingNodeIndex(); //Copy old connections + _connections.clear(); + _connections.reserve(2); for(auto& lineStop : baseState.getConnections()) { _connections.emplace_back(lineStop); } @@ -43,9 +46,11 @@ public: _nodeIndex = baseState.getNodeIndex(); _instant = baseState.getInstant(); _passageIndex = baseState.getPassageIndex(); - _connections.reserve(2); + _precedingNodeIndex = baseState.getPrecedingNodeIndex(); //Copy old connections + _connections.clear(); + _connections.reserve(2); for(auto& lineStop : baseState.getConnections()) { _connections.emplace_back(lineStop); } @@ -182,18 +187,6 @@ public: } TransitAlgorithmState& operator=(const TransitAlgorithmState& baseState) = default; -// TransitAlgorithmState& operator=(const TransitAlgorithmState& baseState) { -// _nodeIndex = baseState.getNodeIndex(); -// _instant = baseState.getInstant(); -// _passageIndex = baseState.getPassageIndex(); -// //Copy old connections -// _connections.clear(); -// for(auto& lineStop : baseState.getConnections()) { -// _connections.emplace_back(lineStop); -// } -// -// return *this; -// } [[nodiscard]] std::string toString() const { std::string res = "Node: " + std::to_string(_nodeIndex) + ", Instant: " + std::to_string(_instant); diff --git a/src/ShortestPath/Transit/TransitShortestPathPrecompute.cpp b/src/ShortestPath/Transit/TransitShortestPathPrecompute.cpp index 27db781ee7bb413475692dcd4acf2271d5d9a2ff..9759db5904907e33bcb9efdd9bd3a0edd67120b8 100644 --- a/src/ShortestPath/Transit/TransitShortestPathPrecompute.cpp +++ b/src/ShortestPath/Transit/TransitShortestPathPrecompute.cpp @@ -30,8 +30,7 @@ TransitStateContainer TransitShortestPathPrecompute::executeAlgorithm(const Grap currentState = statePriorityQueue.top(); statePriorityQueue.pop(); if(!solutionsContainer.strictlyDominates(currentState)) { - DEBUG_MSG("\n\nComparing state " + currentState.toString() + " and \n" + solutionsContainer.getBestSolution(currentState.getNodeIndex(), currentState.getNbConnections()).toString()); - DEBUG_MSG("State isn't dominated, trying to extend it"); + DEBUG_MSG("\n\nComparing state " + currentState.toString() + " and " + solutionsContainer.getBestSolution(currentState.getNodeIndex(), currentState.getNbConnections()).toString()); for (auto& lineStop : graph.getPTLinesSet(currentState.getNodeIndex())) { int nextNode = lineStop.getNextNodeIndex(); diff --git a/src/instance/graph/Line.h b/src/instance/graph/Line.h index 05dd6579dc2ea789f34badfe657d9d3262bc5df8..c9bc6f73b0c39cfad62dbbcc9739019a187e14bb 100644 --- a/src/instance/graph/Line.h +++ b/src/instance/graph/Line.h @@ -17,9 +17,7 @@ private: std::vector<int> _nodes; //index according to Graph::_nodes, sorted according to line order (start -> terminus) std::vector<std::vector<int>> _timetables; //list of list of timestamps for each node start order (size of _timetables must remain constant throughout the whole vector public: - Line(){ - _lineID = ""; - } + Line() = default; [[nodiscard]] const std::string &getLineId() const; void setLineId(const std::string &lineId); @@ -63,14 +61,6 @@ public: bool operator!=(const Line &rhs) const { return _lineID != rhs.getLineId(); } - -// Line& operator=(const Line &rhs) { -// _lineID = rhs.getLineId(); -// _nodes = rhs.getNodes(); -// _timetables = rhs.getTimetables(); -// return *this; -// } - }; #include "Node.h"