Conversation
src/loader/gtfs/load_timetable.cc
Outdated
| tt.location_areas_ = sorted_loc_area; | ||
| tt.route_location_seq_ = sorted_route_loc_seq; | ||
|
|
||
| tt.permutate_locations(first_idx); |
There was a problem hiding this comment.
has to be in init_finish (and probably better optional)
| static vector<location_idx_t> mapping_vec; | ||
|
|
||
| vector<location_idx_t> create_mapping_vec(vector<location_idx_t> vec) | ||
| static vector<location_idx_t> create_mapping_vec(vector<location_idx_t> vec) |
There was a problem hiding this comment.
move to .cc file
(if in header, then use inline instead of static but if not a template and not performance sensitive -> move to .cc file)
| static vector<location_idx_t> mapping_vec; | ||
|
|
||
| static vector<location_idx_t> create_mapping_vec(vector<location_idx_t> vec) | ||
| { |
|
|
||
|
|
||
| template<typename T> | ||
| T apply_permutation_vec(T input) |
| return result_vec; | ||
| } | ||
|
|
||
| static void build_permutation_vec(vecvec<location_idx_t, route_idx_t> order, uint32_t first_idx) |
There was a problem hiding this comment.
src/loader/permutate_locations.cc
Outdated
| vector<location_idx_t> permutation_; | ||
| static vector<location_idx_t> mapping_vec; |
src/loader/init_finish.cc
Outdated
| } | ||
| if (opt.permutate_loc_) { | ||
| auto first_idx_size_t = special_stations_names.size(); | ||
| uint32_t first_idx = static_cast<uint32_t>(first_idx_size_t); |
There was a problem hiding this comment.
| uint32_t first_idx = static_cast<uint32_t>(first_idx_size_t); | |
| auto const first_idx = static_cast<std::uint32_t>(first_idx_size_t); |
src/loader/gtfs/load_timetable.cc
Outdated
| auto const progress_tracker = utl::get_active_progress_tracker(); | ||
| auto timezones = tz_map{}; | ||
| auto agencies = read_agencies(tt, timezones, load(kAgencyFile).data()); | ||
| // stops = hash_map<string(id), location_idx_t> |
include/nigiri/timetable.h
Outdated
| auto sorted_loc_routes = apply_permutation_vec(location_routes_); | ||
| auto sorted_names = apply_permutation_vec(locations_.names_); | ||
| auto sorted_ids = apply_permutation_vec(locations_.ids_); | ||
| auto sorted_coords = apply_permutation_vec(locations_.coordinates_); | ||
| auto sorted_src = apply_permutation_vec(locations_.src_); | ||
| auto sorted_transfertime = apply_permutation_vec(locations_.transfer_time_); | ||
| auto sorted_types = apply_permutation_vec(locations_.types_); | ||
| auto sorted_timezones = | ||
| apply_permutation_vec(locations_.location_timezones_); | ||
| auto sorted_parents = | ||
| apply_permutation_and_mapping_vec(locations_.parents_); | ||
| auto sorted_equivalences = | ||
| apply_permutation_multimap(locations_.equivalences_); | ||
| auto sorted_children = apply_permutation_multimap(locations_.children_); | ||
| auto sorted_pre_footpaths_out = apply_permutation_multimap_foot( | ||
| locations_.preprocessing_footpaths_out_); | ||
| auto sorted_pre_footpaths_in = | ||
| apply_permutation_multimap_foot(locations_.preprocessing_footpaths_in_); | ||
| auto sorted_loc_area = apply_permutation_vec(location_areas_); | ||
| auto sorted_route_loc_seq = | ||
| apply_permutation_to_route_loc_seq(route_location_seq_); | ||
|
|
||
| locations_.location_id_to_idx_ = std::move(sorted_loc_id_to_idx); | ||
| locations_.names_ = std::move(sorted_names); | ||
| locations_.ids_ = std::move(sorted_ids); | ||
| locations_.coordinates_ = std::move(sorted_coords); | ||
| locations_.src_ = std::move(sorted_src); | ||
| locations_.transfer_time_ = std::move(sorted_transfertime); | ||
| locations_.types_ = std::move(sorted_types); | ||
| locations_.location_timezones_ = std::move(sorted_timezones); | ||
| locations_.parents_ = std::move(sorted_parents); | ||
| locations_.equivalences_ = std::move(sorted_equivalences); | ||
| locations_.children_ = std::move(sorted_children); | ||
| locations_.preprocessing_footpaths_out_ = | ||
| std::move(sorted_pre_footpaths_out); | ||
| locations_.preprocessing_footpaths_in_ = std::move(sorted_pre_footpaths_in); | ||
| location_areas_ = std::move(sorted_loc_area); | ||
| route_location_seq_ = std::move(sorted_route_loc_seq); | ||
| location_routes_ = std::move(sorted_loc_routes); |
There was a problem hiding this comment.
why variables and not just assignments?
include/nigiri/timetable.h
Outdated
| vector<location_idx_t> location_permutation = | ||
| build_permutation_vec(location_routes_, first_idx); | ||
|
|
||
| vector<std::pair<location_id, location_idx_t>> unsorted; |
There was a problem hiding this comment.
AAA style mentioned in https://github.com/motis-project/motis/blob/master/docs/STYLE.md
|
|
||
| template <typename T> | ||
| inline T apply_permutation_vec(T const& input) { | ||
| T sorted; |
There was a problem hiding this comment.
| T sorted; | |
| auto sorted = T{}; |
| inline T apply_permutation_vec(T const& input) { | ||
| T sorted; | ||
| for (auto i = 0U; i < input.size(); ++i) { | ||
| auto temp = input.at(permutation_[i]); |
There was a problem hiding this comment.
| auto temp = input.at(permutation_[i]); | |
| auto temp = input[permutation_[i]]; |
no check necessary
| vecvec<route_idx_t, stop::value_type> apply_permutation_to_route_loc_seq( | ||
| vecvec<route_idx_t, stop::value_type> const& input); | ||
|
|
||
| vector_map<location_idx_t, location_idx_t> apply_permutation_and_mapping_vec( | ||
| vector_map<location_idx_t, location_idx_t> const& input); | ||
|
|
||
| mutable_fws_multimap<location_idx_t, location_idx_t> apply_permutation_multimap( | ||
| mutable_fws_multimap<location_idx_t, location_idx_t> const& input); | ||
|
|
||
| mutable_fws_multimap<location_idx_t, footpath> apply_permutation_multimap_foot( | ||
| mutable_fws_multimap<location_idx_t, footpath> const& input); |
There was a problem hiding this comment.
why in header? only used locally in .cc file
| vecvec<location_idx_t, route_idx_t> const& order, uint32_t const first_idx); | ||
|
|
||
| template <typename T> | ||
| inline T apply_permutation_vec(T const& input) { |
There was a problem hiding this comment.
why in header? only used locally in .cc file
include/nigiri/timetable.h
Outdated
| void write(std::filesystem::path const&) const; | ||
| static cista::wrapped<timetable> read(std::filesystem::path const&); | ||
|
|
||
| void permutate_locations(uint32_t first_idx) { |
There was a problem hiding this comment.
can be a separate function in a separate file
permutate_locations.h: permutate_locations(timetable&);
permutate_locations.cc: permutate_locations(timetable&) { ... }
init_finish() { ... permutate_locations(tt); }
| bool adjust_footpaths_{true}; | ||
| bool merge_dupes_intra_src_{true}; | ||
| bool merge_dupes_inter_src_{true}; | ||
| bool permutate_loc_{true}; |
There was a problem hiding this comment.
does it have any downsides? if no, no option needed
include/nigiri/loader/init_finish.h
Outdated
| bool adjust_footpaths = false, | ||
| bool merge_dupes_intra_src = false, | ||
| bool merge_dupes_inter_src = false, | ||
| bool permutate_loc = false, |
There was a problem hiding this comment.
does it have any downsides? if no, no option needed?
| #include "nigiri/timetable.h" | ||
| #include "nigiri/types.h" | ||
|
|
||
| #include <algorithm> |
There was a problem hiding this comment.
include order (common -> specific)
src/loader/init_finish.cc
Outdated
| if (opt.permutate_loc_) { | ||
| auto first_idx_size_t = special_stations_names.size(); | ||
| auto const first_idx = static_cast<std::uint32_t>(first_idx_size_t); | ||
| permutate_locations(tt, first_idx); |
There was a problem hiding this comment.
first idx can be a constant? it's a detail anyway, no need to have it do the caller?
src/loader/permutate_locations.cc
Outdated
| for (auto i = 0U; i < n; ++i) { | ||
| result[permutation[i].v_] = location_idx_t{i}; | ||
| } | ||
| vector<location_idx_t> mapping_vec; |
There was a problem hiding this comment.
left side = auto
please fix the remaining places also
| vector<location_idx_t> mapping_vec; | |
| auto mapping_vec = vector<location_idx_t>{}; |
src/loader/permutate_locations.cc
Outdated
|
|
||
| namespace nigiri { | ||
|
|
||
| auto create_mapping_vec(vector<location_idx_t> const& permutation) { |
There was a problem hiding this comment.
| auto create_mapping_vec(vector<location_idx_t> const& permutation) { | |
| std::vector<location_idx_t> create_mapping_vec(vector<location_idx_t> const& permutation) { |
explicit return types = better readability
src/loader/permutate_locations.cc
Outdated
| vector<location_idx_t> mapping_vec) { | ||
| vector_map<location_idx_t, location_idx_t> sorted; | ||
| for (auto i = 0U; i < input.size(); ++i) { | ||
| auto temp = input.at(permutation[i]); |
There was a problem hiding this comment.
| auto temp = input.at(permutation[i]); | |
| auto temp = input[permutation[i]]; |
we should be 100% sure that permutation[i] is within bounds, right?
src/loader/permutate_locations.cc
Outdated
|
|
||
| auto apply_permutation_and_mapping_vec( | ||
| vector_map<location_idx_t, location_idx_t> const& input, | ||
| vector<location_idx_t> permutation, |
There was a problem hiding this comment.
| vector<location_idx_t> permutation, | |
| vector<location_idx_t> permutation, |
never pass vectors by value if you don't actually need a copy. why copy here?
applies everywhere!
549a8d9 to
5d5eb32
Compare
a4efa76 to
116082c
Compare


Sortiert die locations in timetable, anhand der Anzahl der Routen pro location.