Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine trsp handler class #2698

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ milestone for 3.7.1
* [#2689](https://github.com/pgRouting/pgrouting/pull/2689) When point is a
vertex, the withPoints family do not return results.

**C/C++ code enhancemet**

* TRSP family

### pgRouting 3.7.0 Release Notes

To see all issues & pull requests closed by this release see the [Git closed
Expand Down
4 changes: 4 additions & 0 deletions doc/src/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ milestone for 3.7.1
* `#2689 <https://github.com/pgRouting/pgrouting/pull/2689>`__ When point is a
vertex, the withPoints family do not return results.

.. rubric:: C/C++ code enhancemet

* TRSP family

pgRouting 3.7.0 Release Notes
-------------------------------------------------------------------------------

Expand Down
92 changes: 21 additions & 71 deletions include/trsp/trspHandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace trsp {



class Pgr_trspHandler : public pgrouting::Pgr_messages {
class TrspHandler : public pgrouting::Pgr_messages {
/**
* Used in the priority queue
*/
Expand Down Expand Up @@ -101,104 +101,54 @@ class Pgr_trspHandler : public pgrouting::Pgr_messages {


public:
Pgr_trspHandler(
TrspHandler(
std::vector<Edge_t> &edges,
const std::vector<Edge_t> &new_edges,
const bool directed,
const std::vector<Rule> &ruleList);
Pgr_trspHandler(

TrspHandler(
std::vector<Edge_t> &edges,
const bool directed,
const std::vector<Rule> &ruleList);
Pgr_trspHandler(
Edge_t *edges,
const size_t edge_count,
const bool directed,
const std::vector<Rule> &ruleList);
Pgr_trspHandler(
Edge_t *edges,
const size_t edge_count,
const std::vector<Edge_t> &new_edges,
const bool directed,
const std::vector<Rule> &ruleList);


Pgr_trspHandler(void) = delete;
~Pgr_trspHandler(void) = default;


Path process(
const int64_t start_vertex,
const int64_t end_vertex);

std::deque<Path> process(
const std::map<int64_t,
std::set<int64_t>> &combinations);

std::deque<Path> process(
const std::vector<int64_t> sources,
const std::vector<int64_t> targets);
~TrspHandler(void) = default;

std::deque<Path> process(const std::map<int64_t, std::set<int64_t>>&);

void clear();

private:
void construct_graph(const std::vector<Edge_t>&, const bool);
void construct_graph(
Edge_t *edges,
const size_t edge_count,
const bool directed);
void construct_graph(const std::vector<Edge_t>&, const std::vector<Edge_t>&, const bool);

void add_point_edges(
const std::vector<Edge_t> &new_edges,
const bool directed);

int initialize_restrictions(
const std::vector<Rule> &ruleList);
int initialize_restrictions(const std::vector<Rule>&);

void initialize_que();

Path process_trsp(
size_t edge_count);
Path process(const int64_t, const int64_t);

Path process_trsp(size_t edge_count);

EdgeInfo dijkstra_exploration();

void explore(int64_t, const EdgeInfo, bool);

void explore(
int64_t cur_node,
const EdgeInfo cur_edge,
bool isStart);
double getRestrictionCost(int64_t, const EdgeInfo&, bool);

double getRestrictionCost(
int64_t cur_node,
const EdgeInfo &new_edge,
bool isStart);
bool addEdge(Edge_t edgeIn, bool);
bool addEdge(Edge_t, bool);

void connectStartEdge(
size_t firstEdge_idx,
size_t secondEdge_idx);
void connectStartEdge(size_t, size_t);

void connectEndEdge(
size_t firstEdge_idx,
size_t secondEdge_idx);
void connectEndEdge(size_t, size_t);

double construct_path(int64_t ed_id, Position pos);
double construct_path(int64_t, Position);

void renumber_edges(Edge_t*, const size_t);
void renumber_edges(Edge_t*, const size_t, std::vector<Edge_t>&);
void renumber_edges(std::vector<Edge_t>&);
void renumber_edges(std::vector<Edge_t>&, std::vector<Edge_t>&);

void add_to_que(
double cost,
size_t e_idx,
bool isStart);
void add_to_que(double, size_t, bool);

double get_tot_cost(
double cost,
size_t edge_idx,
bool isStart);
double get_tot_cost(double, size_t, bool);

private:
std::vector<EdgeInfo> m_edges;
Expand Down Expand Up @@ -226,7 +176,7 @@ class Pgr_trspHandler : public pgrouting::Pgr_messages {
/*
* Used in dijkstra_exploration
*/
int64_t current_node;
int64_t m_current_node;

Path m_path;

Expand All @@ -238,7 +188,7 @@ class Pgr_trspHandler : public pgrouting::Pgr_messages {
/*
* priority queue
*/
std::priority_queue<PDP, std::vector<PDP>, std::greater<PDP> > que;
std::priority_queue<PDP, std::vector<PDP>, std::greater<PDP>> m_que;
};


Expand Down
Loading
Loading