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

Add a flag to check if there is a matrix in the input #298

Merged
merged 1 commit into from
Feb 4, 2020
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: 3 additions & 1 deletion src/structures/vroom/input/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Input::Input(unsigned amount_size)
_geometry(false),
_has_jobs(false),
_has_shipments(false),
_has_custom_matrix(false),
_all_locations_have_coords(true),
_amount_size(amount_size),
_zero(_amount_size) {
Expand Down Expand Up @@ -223,6 +224,7 @@ void Input::add_vehicle(const Vehicle& vehicle) {
}

void Input::set_matrix(Matrix<Cost>&& m) {
_has_custom_matrix = true;
_matrix = std::move(m);
}

Expand Down Expand Up @@ -397,7 +399,7 @@ Solution Input::solve(unsigned exploration_level,
"Route geometry request with missing coordinates.");
}

if (_matrix.size() < 2) {
if (!_has_custom_matrix) {
// Call to routing engine if matrix not already provided.
assert(_routing_wrapper);
_matrix = _routing_wrapper->get_matrix(_locations);
Expand Down
1 change: 1 addition & 0 deletions src/structures/vroom/input/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Input {
bool _geometry;
bool _has_jobs;
bool _has_shipments;
bool _has_custom_matrix;
Matrix<Cost> _matrix;
std::vector<Location> _locations;
std::unordered_map<Location, Index> _locations_to_index;
Expand Down