Skip to content

Commit 0189ae9

Browse files
committed
lb greedy acceptable loss
1 parent 8cec5e3 commit 0189ae9

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

include/nigiri/routing/raptor/raptor.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ struct raptor {
8787
a.fill(kInvalid);
8888
return a;
8989
}();
90+
static constexpr auto LbGreedyAcceptableLoss = 1.42;
9091

9192
static bool is_better(auto a, auto b) { return kFwd ? a < b : a > b; }
9293
static bool is_better_or_eq(auto a, auto b) { return kFwd ? a <= b : a >= b; }
@@ -170,6 +171,7 @@ struct raptor {
170171
if constexpr (LbGreedy) {
171172
utl::fill(state_.route_lb_, kUnreachable);
172173
utl::fill(state_.rt_transport_lb_, kUnreachable);
174+
start_lb_ = kUnreachable;
173175
}
174176
}
175177

@@ -186,6 +188,11 @@ struct raptor {
186188
round_times_[0U][to_idx(l)][v] =
187189
get_best(unix_to_delta(base(), t), round_times_[0U][to_idx(l)][v]);
188190
state_.station_mark_.set(to_idx(l), true);
191+
if constexpr (LbGreedy) {
192+
start_lb_ = std::min(
193+
start_lb_,
194+
static_cast<std::uint16_t>(lb_[to_idx(l)] * LbGreedyAcceptableLoss));
195+
}
189196
}
190197

191198
void execute(unixtime_t const start_time,
@@ -218,7 +225,9 @@ struct raptor {
218225
any_marked = true;
219226
state_.route_mark_.set(to_idx(r), true);
220227
if constexpr (LbGreedy) {
221-
state_.route_lb_[r] = lb_[i];
228+
state_.route_lb_[r] = std::min(
229+
start_lb_,
230+
static_cast<std::uint16_t>(lb_[i] * LbGreedyAcceptableLoss));
222231
}
223232
}
224233
if constexpr (Rt) {
@@ -227,7 +236,9 @@ struct raptor {
227236
any_marked = true;
228237
state_.rt_transport_mark_.set(to_idx(rt_t), true);
229238
if constexpr (LbGreedy) {
230-
state_.rt_transport_lb_[rt_t] = lb_[i];
239+
state_.rt_transport_lb_[rt_t] = std::min(
240+
start_lb_,
241+
static_cast<std::uint16_t>(lb_[i] * LbGreedyAcceptableLoss));
231242
}
232243
}
233244
}
@@ -1287,6 +1298,7 @@ struct raptor {
12871298
bool require_car_transport_;
12881299
bool is_wheelchair_;
12891300
transfer_time_settings transfer_time_settings_;
1301+
std::uint16_t start_lb_;
12901302
};
12911303

12921304
} // namespace nigiri::routing

0 commit comments

Comments
 (0)