| 62 | } |
| 63 | |
| 64 | void ManipulateTableForFSE(const std::size_t source_id, |
| 65 | const std::size_t destination_id, |
| 66 | util::DistTableWrapper<EdgeDuration> &result_table) |
| 67 | { |
| 68 | // ****************** Change Table ************************* |
| 69 | // The following code manipulates the table and produces the new table for |
| 70 | // Trip with Fixed Start and End (TFSE). In the example the source is a |
| 71 | // and destination is c. The new table forces the roundtrip to start at |
| 72 | // source and end at destination by virtually squashing them together. |
| 73 | // This way the brute force and the farthest insertion algorithms don't |
| 74 | // have to be modified, and instead we can just pass a modified table to |
| 75 | // return a non-roundtrip "optimal" route from a start node to an end node. |
| 76 | |
| 77 | // Original Table // New Table |
| 78 | // a b c d e // a b c d e |
| 79 | // a 0 15 36 34 30 // a 0 15 10000 34 30 |
| 80 | // b 15 0 25 30 34 // b 10000 0 25 30 34 |
| 81 | // c 36 25 0 18 32 // c 0 10000 0 10000 10000 |
| 82 | // d 34 30 18 0 15 // d 10000 30 18 0 15 |
| 83 | // e 30 34 32 15 0 // e 10000 34 32 15 0 |
| 84 | |
| 85 | // change parameters.source column |
| 86 | // set any node to source to impossibly high numbers so it will never |
| 87 | // try to use any node->source in the middle of the "optimal path" |
| 88 | for (std::size_t i = 0; i < result_table.GetNumberOfNodes(); i++) |
| 89 | { |
| 90 | if (i == source_id) |
| 91 | continue; |
| 92 | result_table.SetValue(i, source_id, INVALID_EDGE_DURATION); |
| 93 | } |
| 94 | |
| 95 | // change parameters.destination row |
| 96 | // set destination to anywhere else to impossibly high numbers so it will |
| 97 | // never try to use destination->any node in the middle of the "optimal path" |
| 98 | for (std::size_t i = 0; i < result_table.GetNumberOfNodes(); i++) |
| 99 | { |
| 100 | if (i == destination_id) |
| 101 | continue; |
| 102 | result_table.SetValue(destination_id, i, INVALID_EDGE_DURATION); |
| 103 | } |
| 104 | |
| 105 | // set destination->source to zero so roundtrip treats source and |
| 106 | // destination as one location |
| 107 | result_table.SetValue(destination_id, source_id, {0}); |
| 108 | |
| 109 | // set source->destination as very high number so algorithm is forced |
| 110 | // to find another path to get to destination |
| 111 | result_table.SetValue(source_id, destination_id, INVALID_EDGE_DURATION); |
| 112 | |
| 113 | //********* End of changes to table ************************************* |
| 114 | } |
| 115 | |
| 116 | void ManipulateTableForNonRoundtripFS(const std::size_t source_id, |
| 117 | util::DistTableWrapper<EdgeDuration> &result_table) |
no test coverage detected