remove attention on unaccessible locations as we filter them beforehand
This commit is contained in:
committed by
Huyen Chau Nguyen
parent
a40b3a98dc
commit
6eeadddd4d
@@ -115,6 +115,37 @@ template <class DataFacadeT> class RoundTripPlugin final : public BasePlugin
|
||||
return 400;
|
||||
}
|
||||
|
||||
auto number_of_locations = phantom_node_vector.size();
|
||||
const auto maxint = std::numeric_limits<int>::max();
|
||||
|
||||
//////////////////////////////////// DELETE UNACCESSIBLE LOCATIONS /////////////////////////////////////////
|
||||
|
||||
if (*std::max_element(result_table->begin(), result_table->end()) == maxint) {
|
||||
const int half = number_of_locations / 2;
|
||||
std::vector<int> to_delete;
|
||||
|
||||
for (int i = number_of_locations - 1; i >= 0; --i) {
|
||||
// if the location is unaccessible by most of the other locations, remember the location
|
||||
if (std::count(result_table->begin() + i * number_of_locations, result_table->begin() + (i+1) * number_of_locations, maxint) > half) {
|
||||
to_delete.push_back(i);
|
||||
}
|
||||
}
|
||||
//delete all unaccessible locations
|
||||
for (int k = 0; k < to_delete.size(); ++k) {
|
||||
// delete its row
|
||||
result_table->erase(result_table->begin() + to_delete[k] * number_of_locations, result_table->begin() + (to_delete[k]+1) * number_of_locations);
|
||||
--number_of_locations;
|
||||
// delete its column
|
||||
for (int j = 0; j < number_of_locations; ++j) {
|
||||
result_table->erase(result_table->begin() + j * number_of_locations + to_delete[k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
//todo: delete
|
||||
if (*std::max_element(result_table->begin(), result_table->end()) == maxint) {
|
||||
SimpleLogger().Write() << "SOMETHING WENT WRONG";
|
||||
}
|
||||
|
||||
// compute TSP round trip
|
||||
InternalRouteResult min_route;
|
||||
std::vector<int> min_loc_permutation(phantom_node_vector.size(), -1);
|
||||
|
||||
@@ -115,6 +115,37 @@ template <class DataFacadeT> class RoundTripPluginBF final : public BasePlugin
|
||||
return 400;
|
||||
}
|
||||
|
||||
auto number_of_locations = phantom_node_vector.size();
|
||||
const auto maxint = std::numeric_limits<int>::max();
|
||||
|
||||
//////////////////////////////////// DELETE UNACCESSIBLE LOCATIONS /////////////////////////////////////////
|
||||
|
||||
if (*std::max_element(result_table->begin(), result_table->end()) == maxint) {
|
||||
const int half = number_of_locations / 2;
|
||||
std::vector<int> to_delete;
|
||||
|
||||
for (int i = number_of_locations - 1; i >= 0; --i) {
|
||||
// if the location is unaccessible by most of the other locations, remember the location
|
||||
if (std::count(result_table->begin() + i * number_of_locations, result_table->begin() + (i+1) * number_of_locations, maxint) > half) {
|
||||
to_delete.push_back(i);
|
||||
}
|
||||
}
|
||||
//delete all unaccessible locations
|
||||
for (int k = 0; k < to_delete.size(); ++k) {
|
||||
// delete its row
|
||||
result_table->erase(result_table->begin() + to_delete[k] * number_of_locations, result_table->begin() + (to_delete[k]+1) * number_of_locations);
|
||||
--number_of_locations;
|
||||
// delete its column
|
||||
for (int j = 0; j < number_of_locations; ++j) {
|
||||
result_table->erase(result_table->begin() + j * number_of_locations + to_delete[k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
//todo: delete
|
||||
if (*std::max_element(result_table->begin(), result_table->end()) == maxint) {
|
||||
SimpleLogger().Write() << "SOMETHING WENT WRONG";
|
||||
}
|
||||
|
||||
// compute TSP round trip
|
||||
InternalRouteResult min_route;
|
||||
std::vector<int> min_loc_permutation(phantom_node_vector.size(), -1);
|
||||
|
||||
@@ -115,6 +115,37 @@ template <class DataFacadeT> class RoundTripPluginFI final : public BasePlugin
|
||||
return 400;
|
||||
}
|
||||
|
||||
auto number_of_locations = phantom_node_vector.size();
|
||||
const auto maxint = std::numeric_limits<int>::max();
|
||||
|
||||
//////////////////////////////////// DELETE UNACCESSIBLE LOCATIONS /////////////////////////////////////////
|
||||
|
||||
if (*std::max_element(result_table->begin(), result_table->end()) == maxint) {
|
||||
const int half = number_of_locations / 2;
|
||||
std::vector<int> to_delete;
|
||||
|
||||
for (int i = number_of_locations - 1; i >= 0; --i) {
|
||||
// if the location is unaccessible by most of the other locations, remember the location
|
||||
if (std::count(result_table->begin() + i * number_of_locations, result_table->begin() + (i+1) * number_of_locations, maxint) > half) {
|
||||
to_delete.push_back(i);
|
||||
}
|
||||
}
|
||||
//delete all unaccessible locations
|
||||
for (int k = 0; k < to_delete.size(); ++k) {
|
||||
// delete its row
|
||||
result_table->erase(result_table->begin() + to_delete[k] * number_of_locations, result_table->begin() + (to_delete[k]+1) * number_of_locations);
|
||||
--number_of_locations;
|
||||
// delete its column
|
||||
for (int j = 0; j < number_of_locations; ++j) {
|
||||
result_table->erase(result_table->begin() + j * number_of_locations + to_delete[k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
//todo: delete
|
||||
if (*std::max_element(result_table->begin(), result_table->end()) == maxint) {
|
||||
SimpleLogger().Write() << "SOMETHING WENT WRONG";
|
||||
}
|
||||
|
||||
// compute TSP round trip
|
||||
InternalRouteResult min_route;
|
||||
std::vector<int> min_loc_permutation(phantom_node_vector.size(), -1);
|
||||
|
||||
@@ -43,6 +43,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "../util/string_util.hpp"
|
||||
#include "../util/timing_util.hpp"
|
||||
#include "../util/simple_logger.hpp"
|
||||
#include "../tools/tsp_logs.hpp"
|
||||
|
||||
#include <osrm/json_container.hpp>
|
||||
|
||||
@@ -115,9 +116,40 @@ template <class DataFacadeT> class RoundTripPluginNN final : public BasePlugin
|
||||
return 400;
|
||||
}
|
||||
|
||||
auto number_of_locations = phantom_node_vector.size();
|
||||
const auto maxint = std::numeric_limits<int>::max();
|
||||
|
||||
//////////////////////////////////// DELETE UNACCESSIBLE LOCATIONS /////////////////////////////////////////
|
||||
|
||||
if (*std::max_element(result_table->begin(), result_table->end()) == maxint) {
|
||||
const int half = number_of_locations / 2;
|
||||
std::vector<int> to_delete;
|
||||
|
||||
for (int i = number_of_locations - 1; i >= 0; --i) {
|
||||
// if the location is unaccessible by most of the other locations, remember the location
|
||||
if (std::count(result_table->begin() + i * number_of_locations, result_table->begin() + (i+1) * number_of_locations, maxint) > half) {
|
||||
to_delete.push_back(i);
|
||||
}
|
||||
}
|
||||
//delete all unaccessible locations
|
||||
for (int k = 0; k < to_delete.size(); ++k) {
|
||||
// delete its row
|
||||
result_table->erase(result_table->begin() + to_delete[k] * number_of_locations, result_table->begin() + (to_delete[k]+1) * number_of_locations);
|
||||
--number_of_locations;
|
||||
// delete its column
|
||||
for (int j = 0; j < number_of_locations; ++j) {
|
||||
result_table->erase(result_table->begin() + j * number_of_locations + to_delete[k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
//todo: delete
|
||||
if (*std::max_element(result_table->begin(), result_table->end()) == maxint) {
|
||||
SimpleLogger().Write() << "SOMETHING WENT WRONG";
|
||||
}
|
||||
|
||||
// compute TSP round trip
|
||||
InternalRouteResult min_route;
|
||||
std::vector<int> min_loc_permutation(phantom_node_vector.size(), -1);
|
||||
std::vector<int> min_loc_permutation(number_of_locations, -1);
|
||||
TIMER_STOP(tsp_pre);
|
||||
|
||||
//######################### NEAREST NEIGHBOUR ###############################//
|
||||
|
||||
Reference in New Issue
Block a user