Index: simhalt.cc =================================================================== --- simhalt.cc (.../upstream/r5788) (revision 114) +++ simhalt.cc (.../tags/rrc-test0005) (revision 114) @@ -1741,6 +1741,10 @@ // this allows for separate high speed and normal service vector_tpl *warray = waren[wtyp->get_catg_index()]; +#ifdef ROUTECOST_CHOOSE_CLASS + uint16 aggregate_weight = WEIGHT_WAIT; +#endif + if (warray && !warray->empty()) { // da wir schon an der aktuellem haltestelle halten // startet die schleife ab 1, d.h. dem naechsten halt @@ -1755,6 +1759,47 @@ } else if( plan_halt.is_bound() ) { +#ifdef ROUTECOST_CHOOSE_CLASS + aggregate_weight += WEIGHT_HALT; + + // test that cost for the halt by this schedule is less than or equal to cost recorded in the connection (fastest time) + const connection_t *c = lookup_connection(plan_halt, wtyp->get_catg_index()); + if (c != NULL) { + // TODO: introduce some margin, or trend-adaptive logic. + if (aggregate_weight > c->weight) { + // the vehicle is slower, skip loading for the halt. + +#ifdef ROUTECOST_CHOOSE_CLASS_DEBUG + for (uint j=1; jget_aktuell()) % count; + if (plan_halt == haltestelle_t::get_halt(welt, fpl->eintrag[wrap_j].pos, sp)) { + // already processed. + goto _debug_skip_info; + } + } + printf("INFO: skip loading due to class-choosing: fpl=%u+%u/%u, here=%u(%s), plan_halt=%u(%s): weight: %u > %u\n", + fpl->get_aktuell(), i, fpl->get_count(), + self.get_id(), get_name(), plan_halt.get_id(), plan_halt->get_name(), + aggregate_weight, c->weight); + _debug_skip_info: +#endif + continue; + } + } + else { + // no suitable connection found, rebuilding is late? or any other reason? + // or category based un-acception. + // skip cost based class-choosing. +#ifdef ROUTECOST_CHOOSE_CLASS_DEBUG + if (plan_halt->is_enabled(wtyp)) { + printf("ASSERT: no connection found: here=%u(%s), plan_halt=%u(%s)\n", + self.get_id(), get_name(), + plan_halt.get_id(), plan_halt->get_name()); + } +#endif + } +#endif + // The random offset will ensure that all goods have an equal chance to be loaded. sint32 offset = simrand(warray->get_count()); for( uint32 i=0; iget_count(); i++ ) { Index: simhalt.h =================================================================== --- simhalt.h (.../upstream/r5788) (revision 114) +++ simhalt.h (.../tags/rrc-test0005) (revision 114) @@ -362,6 +362,25 @@ // returns the matchin warenziele vector_tpl const& get_connections(uint8 const catg_index) const { return connections[catg_index]; } +#ifdef ROUTECOST_CHOOSE_CLASS + const connection_t * lookup_connection(const halthandle_t h, uint8 const catg_index) { + /* TODO: do binary search for larger connection list. + each connection list is sorted by ID of halthandle. + see connection_t and rebuild_connections(). + if the list is small enough, cost of binary search might be too much expensive, so, linear search is better for the case. + */ + FOR(vector_tpl, const& c, connections[catg_index]) { + if (c.halt == h) { + return &c; + } + else if (c.halt.get_id() >= h.get_id()) { + break; + } + } + return NULL; + } +#endif + const slist_tpl& get_fab_list() const { return fab_list; } /**