Skip to content

Commit

Permalink
RSL: Broken Transfer List + Details (#394)
Browse files Browse the repository at this point in the history
  • Loading branch information
pablohoch authored Sep 28, 2023
1 parent 6278db1 commit 78fee80
Show file tree
Hide file tree
Showing 74 changed files with 3,467 additions and 1,008 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/unix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ jobs:
- preset: clang-tidy
skipui: true
skiptests: true
- preset: linux-sanitizer
skipui: true
#- preset: linux-sanitizer
# skipui: true
- preset: linux-debug
skipui: true
emulator: valgrind --leak-check=full --error-exitcode=1
Expand Down
2 changes: 2 additions & 0 deletions base/core/include/motis/core/schedule/trip.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ struct trip {
mcd::vector<uint32_t> stop_seq_numbers_;
boost::uuids::uuid uuid_{};
bool unscheduled_{false};
ptr<connection_info const> original_first_connection_info_{};
service_class original_first_clasz_{service_class::OTHER};
};

} // namespace motis
4 changes: 2 additions & 2 deletions base/loader/include/motis/loader/graph_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ struct graph_builder {

full_trip_id get_full_trip_id(Service const* s, int day, int section_idx = 0);

std::optional<merged_trips_idx> create_merged_trips(Service const* s,
int day_idx);
std::optional<merged_trips_idx> create_merged_trips(
Service const* s, int day_idx, light_connection const* first_lcon);

trip* register_service(Service const* s, int day_idx, bool allow_duplicates);

Expand Down
14 changes: 11 additions & 3 deletions base/loader/src/graph_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,13 @@ full_trip_id graph_builder::get_full_trip_id(Service const* s, int day,
}

std::optional<merged_trips_idx> graph_builder::create_merged_trips(
Service const* s, int day_idx) {
Service const* s, int day_idx, light_connection const* first_lcon) {
auto const trp = register_service(s, day_idx, false);
if (trp != nullptr) {
if (first_lcon != nullptr) {
trp->original_first_connection_info_ = first_lcon->full_con_->con_info_;
trp->original_first_clasz_ = first_lcon->full_con_->clasz_;
}
return static_cast<motis::merged_trips_idx>(
push_mem(sched_.merged_trips_, mcd::vector<ptr<trip>>({trp})));
} else {
Expand Down Expand Up @@ -159,7 +163,8 @@ trip* graph_builder::register_service(Service const* s, int day_idx,
s->seq_numbers() == nullptr ? mcd::vector<uint32_t>{}
: mcd::to_vec(*s->seq_numbers()),
boost::uuids::nil_uuid(),
s->schedule_relationship() == ScheduleRelationship_UNSCHEDULED))
s->schedule_relationship() == ScheduleRelationship_UNSCHEDULED,
nullptr, service_class::OTHER))
.get();
sched_.trips_.emplace_back(stored->id_.primary_, stored);
added_full_trip_ids_[ftid] = stored->trip_idx_;
Expand Down Expand Up @@ -267,7 +272,10 @@ void graph_builder::add_route_services(
continue;
}

auto const created_merged_trips_idx = create_merged_trips(s, day);
auto const first_lcon = !lcons.empty() ? &lcons.front() : nullptr;

auto const created_merged_trips_idx =
create_merged_trips(s, day, first_lcon);
if (!created_merged_trips_idx) {
// duplicate trip id
continue;
Expand Down
17 changes: 16 additions & 1 deletion base/loader/src/rule_service_graph_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "motis/core/common/logging.h"
#include "motis/core/schedule/price.h"
#include "motis/core/schedule/trip.h"
#include "motis/core/access/connection_access.h"
#include "motis/core/access/trip_iterator.h"
#include "motis/loader/util.h"

Expand Down Expand Up @@ -496,6 +497,13 @@ struct rule_service_route_builder {
auto trp = single_trips_.at(std::make_pair(s, day_idx));
trp->edges_ = edges;
trp->lcon_idx_ = lcon_idx;
if (!edges->empty()) {
auto const& first_lcon =
edges->front()->m_.route_edge_.conns_.at(lcon_idx);
trp->original_first_connection_info_ =
&access::get_connection_info(gb_.sched_, first_lcon, trp);
trp->original_first_clasz_ = first_lcon.full_con_->clasz_;
}
++lcon_idx;
}
}
Expand Down Expand Up @@ -636,7 +644,14 @@ struct rule_service_route_builder {
push_mem(gb_.sched_.trip_mem_, ftid, "", edges_ptr, lcon_idx,
static_cast<trip_idx_t>(gb_.sched_.trip_mem_.size()),
trip_debug{}, mcd::vector<uint32_t>{});
auto const trip_ptr = gb_.sched_.trip_mem_.back().get();
auto trip_ptr = gb_.sched_.trip_mem_.back().get();

auto const& first_lcon =
route_edges.front()->m_.route_edge_.conns_.at(lcon_idx);
trip_ptr->original_first_connection_info_ =
first_lcon.full_con_->con_info_;
trip_ptr->original_first_clasz_ = first_lcon.full_con_->clasz_;

if (gb_.check_trip(trip_ptr)) {
route_trips.push_back(trip_ptr);
}
Expand Down
44 changes: 38 additions & 6 deletions docs/api/paths.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@
type: motis.MotisSuccess
description: Universe was destroyed (or marked for destruction if still in use).

/paxmon/filter/groups:
/paxmon/filter_groups:
summary: List passenger groups with filter and sort options
tags:
- rsl
Expand Down Expand Up @@ -352,14 +352,32 @@
type: motis.paxmon.PaxMonGetGroupsResponse
description: Information about the requested passenger groups

/paxmon/get_interchanges:
summary: List monitored interchanges at a station
/paxmon/transfers_at_station:
summary: List monitored transfers at a station
tags:
- rsl
input: motis.paxmon.PaxMonGetInterchangesRequest
input: motis.paxmon.PaxMonTransfersAtStationRequest
output:
type: motis.paxmon.PaxMonGetInterchangesResponse
description: Information about the requested interchanges
type: motis.paxmon.PaxMonTransfersAtStationResponse
description: Information about the requested transfers

/paxmon/broken_transfers:
summary: List broken transfers
tags:
- rsl
input: motis.paxmon.PaxMonBrokenTransfersRequest
output:
type: motis.paxmon.PaxMonBrokenTransfersResponse
description: A list of monitored broken transfers

/paxmon/transfer_details:
summary: Transfer information
tags:
- rsl
input: motis.paxmon.PaxMonTransferDetailsRequest
output:
type: motis.paxmon.PaxMonTransferDetailsResponse
description: Information about the transfer

/paxmon/group_statistics:
summary: Passenger group statistics
Expand Down Expand Up @@ -536,6 +554,20 @@
type: motis.paxmon.PaxMonMetricsResponse
description: Metrics

/paxmon/revise_compact_journey:
summary: Compact journey to real-time connection
description: |
Convert compact journeys into connections (`motis.Connection`),
updated with real-time information.
Requires the `revise` module.
tags:
- rsl
input: motis.paxmon.PaxMonReviseCompactJourneyRequest
output:
type: motis.paxmon.PaxMonReviseCompactJourneyResponse
description: Connections with real-time information

/ppr/profiles:
summary: List available pedestrian routing profiles
tags:
Expand Down
2 changes: 2 additions & 0 deletions docs/api/schemas/motis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,8 @@ ApiDescription:
fields:
methods:
description: TODO
version:
description: TODO
MsgContent:
description: TODO
DestinationType:
Expand Down
50 changes: 45 additions & 5 deletions docs/api/schemas/motis/intermodal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,54 @@ IntermodalRoutingRequest:
start:
description: TODO
start_modes:
description: TODO
description: The transport modes allowed at the start.
destination:
description: TODO
destination_modes:
description: TODO
description: The transport modes allowed at the destination.
search_type:
description: TODO
description: |
The set of optimization criteria to use.
Possible values include:
- `Default`: Optimize travel time and number of transfers.
This computes the Pareto set using multi-criteria optimization.
- `Accessibility`: Same as `Default` but including an additional
accessibility criterion.
- `SingleCriterion`: Optimizes a weighted sum where every transfer
adds 20 minutes.
- `SingleCriterionNoIntercity`: Same as `SingleCriterion` but
excluding all long distance (intercity) trains.
Note that not all routers support all search types.
examples:
- "Default"
search_dir:
description: TODO
description: |
The search direction.
This defines whether the algorithm searches from departure to arrival
(forward in time) or from arrival to departure (backward in time).
Thus, `start` is either specifying the source (`search_dir=Forward`)
or the destination (`search_dir=Backward`).
Possible values:
- `Forward`: The `start` parameter specifies the departure of the journey.
The destination parameter specifies the arrival of the journey.
- `Backward`: The `start` parameter specifies the arrival of the journey.
The destination parameter specifies the departure of the journey.
router:
description: TODO
description: |
The public transport routing endpoint to use.
Set to an empty string to use the default router (based on the
configuration parameter `intermodal.router`).
To override the default router, set it to the desired endpoint,
e.g. `/routing` or `/tripbased`.
Note that not all routers support all features such as
intermodal routing or real-time updates.
examples:
- ""
- "/routing"
11 changes: 11 additions & 0 deletions docs/api/schemas/motis/lookup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ LookupScheduleInfoResponse:
description: First loaded day (unix timestamp)
end:
description: Last loaded day (unix timestamp)
schedules:
description: TODO
TableType:
description: TODO
LookupStationEventsRequest:
Expand Down Expand Up @@ -184,3 +186,12 @@ LookupStationLocationResponse:
fields:
position:
description: TODO
LookupSchedule:
description: TODO
fields:
tag:
description: TODO
hash:
description: TODO
created:
description: TODO
15 changes: 9 additions & 6 deletions docs/api/schemas/motis/paxforecast.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ MeasureRecipients:
`time`). Does not include passengers in a trip that is currently waiting
at the station.
LoadLevel:
description: TODO
description: The expected train occupancy level.
TripLoadInfoMeasure:
description: >
This measure type is deprecated. Use `TripLoadRecommendationMeasure` instead.
Expand Down Expand Up @@ -68,12 +68,12 @@ TripRecommendationMeasure:
recommended_trip:
description: TODO
TripWithLoadLevel:
description: TODO
description: A trip with an associated expected occupancy level.
fields:
trip:
description: TODO
level:
description: TODO
description: The expected train occupancy level.
TripLoadRecommendationMeasure:
description: |
Simulate an announcement that a trip is overcrowded and recommend
Expand All @@ -93,11 +93,14 @@ TripLoadRecommendationMeasure:
description: >
Time at which the announcement is made (unix timestamp).
planned_destinations:
description: TODO
description: |
A list of planned destination stations (station ids).
full_trips:
description: TODO
description: |
A list of overcrowded trips that should not be used.
recommended_trips:
description: TODO
description: |
A list of recommended alternatives.
RtUpdateMeasure:
description: |
Simulate a real-time update.
Expand Down
Loading

0 comments on commit 78fee80

Please sign in to comment.