Skip to content
Snippets Groups Projects
Commit ab18eab4 authored by Romain BERNARD's avatar Romain BERNARD
Browse files

WIP transit solutions container

parent 746fb6ac
No related branches found
No related tags found
1 merge request!1Transit algorithm implementation
......@@ -34,4 +34,6 @@ add_executable(GreedyAlgorithm
src/ShortestPath/Transit/TransitShortestPathPrecompute.h
src/ShortestPath/Transit/TransitAlgorithmState.cpp
src/ShortestPath/Transit/TransitAlgorithmState.h
src/ShortestPath/Transit/TransitShortestPathContainer.cpp
src/ShortestPath/Transit/TransitShortestPathContainer.h
)
//
// Created by romain on 13/03/24.
//
#include "TransitShortestPathContainer.h"
//
// Created by romain on 13/03/24.
//
#ifndef GREEDYALGORITHM_TRANSITSHORTESTPATHCONTAINER_H
#define GREEDYALGORITHM_TRANSITSHORTESTPATHCONTAINER_H
#include <vector>
#include "TransitShortestPath.h"
class TransitShortestPathContainer {
private:
std::vector<std::pair<int, std::vector<TransitShortestPath>>> container; //Node vector -> Pair<Instant, ShortestPath[Node]>
public:
void addShortestPathCollection(int startNodeIndex, std::pair<int, std::vector<TransitShortestPath>> shortestPathList);
void addShortestPathCollection(int startNodeIndex, int startingInstant, std::vector<TransitAlgorithmState>> algorithmResultStates);
std::pair<int, std::vector<TransitShortestPath>> getShortestPathsFromTime(int startNodeIndex, int );
};
#endif //GREEDYALGORITHM_TRANSITSHORTESTPATHCONTAINER_H
......@@ -74,6 +74,23 @@ public:
}
}
/**
* Compares the states available to get to a given node index and returns the best by comparing their time of arrival.
* If equivalent solutions wrt time exist, the one with the lowest amount of connections required will be returned
* @param nodeIndex The node we try to get to
* @return
*/
TransitAlgorithmState getBestSolution(int nodeIndex) {
TransitAlgorithmState currentBestSol = solutionVector.at(nodeIndex).at(0);
for(size_t i = 1; i < solutionVector.at(nodeIndex).size(); ++i) {
if(solutionVector.at(nodeIndex).at(i).getInstant() < currentBestSol.getInstant()) {
currentBestSol = solutionVector.at(nodeIndex).at(i);
}
}
return currentBestSol;
}
void pushEmptyState(int nodeIndex)
{
TransitAlgorithmState newState = TransitAlgorithmState(nodeIndex);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment