<commit_before>#include "raptor.h"
namespace navitia { namespace routing { namespace raptor {



int RAPTOR::earliest_trip(const dataRAPTOR::Route_t & route, unsigned int order, DateTime dt) const {
    int it, step,
            upper = route.nbTrips, count = upper,
            first = 0;

    if(data.pt_data.validity_patterns[route.vp].check(dt.date())) {
        //Recherche dichotomique du premier trip partant après dt.hour
        while (count>0) {
            it = first; step=count/2; it+=step;
            if (data.dataRaptor.stopTimes[route.firstStopTime + order + it*route.nbStops].departure_time < dt.hour()) {
                first=++it; count-=step+1;
            }
            else count=step;
        }

        if(first != upper)
            return first;
    }

    //Si on en a pas trouvé, on cherche le lendemain
    dt.date_increment();
    if(data.pt_data.validity_patterns[route.vp].check(dt.date())) {
        return 0;
    }

    //Cette route ne comporte aucun trip compatible
    return -1;
}


int RAPTOR::tardiest_trip(const dataRAPTOR::Route_t & route, unsigned int order, DateTime dt) const{
    int current_trip/*, step*/,
            upper =  route.nbTrips/*, count = upper*/,
            first = 0;

    if(data.pt_data.validity_patterns[route.vp].check(dt.date())) {
        //Recherche dichotomique du premier trip avant après dt.hour
        current_trip = upper;
        while ((upper - first) >1) {
            current_trip = first + (upper - first) / 2;
            int current_stop_time = route.firstStopTime + order + current_trip*route.nbStops;
            if (data.dataRaptor.stopTimes[current_stop_time].arrival_time > dt.hour()) {
                upper = current_trip;
            }
            else first = current_trip;
        }
        if(data.dataRaptor.stopTimes[route.firstStopTime + order + first*route.nbStops].arrival_time > dt.hour())
            --first;

        if(first != upper && first >= 0)
            return first;
    }

    //Si on en a pas trouvé, on cherche le lendemain
    dt.date_decrement();
    if(data.pt_data.validity_patterns[route.vp].check(dt.date())) {
        return route.nbTrips - 1;
    }

    //Cette route ne comporte aucun trip compatible
    return -1;
}



void RAPTOR::make_queue() {
    Q.assign(data.dataRaptor.routes.size(), std::numeric_limits<int>::max());

    auto it = data.dataRaptor.sp_routeorder_const.begin();
    int last = 0;
    for(auto stop = marked_sp.find_first(); stop != marked_sp.npos; stop = marked_sp.find_next(stop)) {
        auto index = data.dataRaptor.sp_indexrouteorder[stop];

        it += index.first - last;
        last = index.first + index.second;
        const auto end = it+index.second;
        for(; it!=end; ++it) {
            if((Q[it->first] > it->second) && vp_valides.test(data.dataRaptor.routes[it->first].vp))
                Q[it->first] = it->second;
        }
        marked_sp.flip(stop);
    }
}



void RAPTOR::make_queuereverse() {
    Q.assign(data.dataRaptor.routes.size(), std::numeric_limits<int>::min());
    auto it = data.dataRaptor.sp_routeorder_const_reverse.begin();
    int last = 0;
    for(auto stop = marked_sp.find_first(); stop != marked_sp.npos; stop = marked_sp.find_next(stop)) {
        auto index = data.dataRaptor.sp_indexrouteorder[stop];

        it += index.first - last;
        last = index.first + index.second;
        const auto end = it+index.second;
        for(; it!=end; ++it) {
            if((Q[it->first] < it->second) && vp_valides.test(data.dataRaptor.routes[it->first].vp))
                Q[it->first] = it->second;
        }
        marked_sp.flip(stop);
    }
}

void RAPTOR::marcheapied() {

    auto it = data.dataRaptor.foot_path.begin();
    int last = 0;
    for(auto stop_point = marked_sp.find_first(); stop_point != marked_sp.npos; stop_point = marked_sp.find_next(stop_point)) {
        const auto & index = data.dataRaptor.footpath_index[stop_point];
        const type_retour & retour_temp = retour[count][stop_point];
        int prec_duration = -1;
        DateTime dtTemp = retour_temp.dt;
        std::advance(it, index.first - last);
        const auto end = it + index.second;

        for(; it != end; ++it) {
            navitia::type::idx_t destination = (*it).destination_stop_point_idx;
            if(stop_point != destination) {
                if(it->duration != prec_duration) {
                    dtTemp = retour_temp.dt + it->duration;
                    prec_duration = it->duration;
                }
                if(dtTemp <= best[destination].dt) {
                    const type_retour nRetour = type_retour(navitia::type::invalid_idx, stop_point, dtTemp, connection);
                    if(!b_dest.ajouter_best(destination, nRetour, count)) {
                        best[destination] = nRetour;
                        retour[count][destination] = nRetour;
                        marked_sp.set(destination);
                    } else if(count == 0 || retour[count - 1][destination].type == uninitialized) {
                        retour[count][destination] = nRetour;
                    }
                }
            }
        }
        last = index.first + index.second;
    }
}


void RAPTOR::marcheapiedreverse() {
    auto it = data.dataRaptor.foot_path.begin();
    int last = 0;
    for(auto stop_point = marked_sp.find_first(); stop_point != marked_sp.npos; stop_point = marked_sp.find_next(stop_point)) {
        const auto & index = data.dataRaptor.footpath_index[stop_point];
        std::advance(it, index.first - last);
        const auto end = it + index.second;
        for(; it != end; ++it) {
            navitia::type::idx_t destination = it->destination_stop_point_idx;
            if(stop_point != destination) {
                const type_retour & retour_temp = retour[count][stop_point];
                const DateTime dtTemp = retour_temp.dt - it->duration;
                if(dtTemp >= best[destination].dt) {
                    const type_retour nRetour = type_retour(navitia::type::invalid_idx, stop_point, dtTemp, connection);
                    if(!b_dest.ajouter_best_reverse(destination, nRetour, count)) {
                        best[destination] = nRetour;
                        retour[count][destination] = nRetour;
                        marked_sp.set(destination);
                    } else if(count ==_0 || retour[count - 1][destination].type == uninitialized) {<commit_msg>raptor : réparation de cassage de build<commit_after>#include "raptor.h"
namespace navitia { namespace routing { namespace raptor {



int RAPTOR::earliest_trip(const dataRAPTOR::Route_t & route, unsigned int order, DateTime dt) const {
    int it, step,
            upper = route.nbTrips, count = upper,
            first = 0;

    if(data.pt_data.validity_patterns[route.vp].check(dt.date())) {
        //Recherche dichotomique du premier trip partant après dt.hour
        while (count>0) {
            it = first; step=count/2; it+=step;
            if (data.dataRaptor.stopTimes[route.firstStopTime + order + it*route.nbStops].departure_time < dt.hour()) {
                first=++it; count-=step+1;
            }
            else count=step;
        }

        if(first != upper)
            return first;
    }

    //Si on en a pas trouvé, on cherche le lendemain
    dt.date_increment();
    if(data.pt_data.validity_patterns[route.vp].check(dt.date())) {
        return 0;
    }

    //Cette route ne comporte aucun trip compatible
    return -1;
}


int RAPTOR::tardiest_trip(const dataRAPTOR::Route_t & route, unsigned int order, DateTime dt) const{
    int current_trip/*, step*/,
            upper =  route.nbTrips/*, count = upper*/,
            first = 0;

    if(data.pt_data.validity_patterns[route.vp].check(dt.date())) {
        //Recherche dichotomique du premier trip avant après dt.hour
        current_trip = upper;
        while ((upper - first) >1) {
            current_trip = first + (upper - first) / 2;
            int current_stop_time = route.firstStopTime + order + current_trip*route.nbStops;
            if (data.dataRaptor.stopTimes[current_stop_time].arrival_time > dt.hour()) {
                upper = current_trip;
            }
            else first = current_trip;
        }
        if(data.dataRaptor.stopTimes[route.firstStopTime + order + first*route.nbStops].arrival_time > dt.hour())
            --first;

        if(first != upper && first >= 0)
            return first;
    }

    //Si on en a pas trouvé, on cherche le lendemain
    dt.date_decrement();
    if(data.pt_data.validity_patterns[route.vp].check(dt.date())) {
        return route.nbTrips - 1;
    }

    //Cette route ne comporte aucun trip compatible
    return -1;
}



void RAPTOR::make_queue() {
    Q.assign(data.dataRaptor.routes.size(), std::numeric_limits<int>::max());

    auto it = data.dataRaptor.sp_routeorder_const.begin();
    int last = 0;
    for(auto stop = marked_sp.find_first(); stop != marked_sp.npos; stop = marked_sp.find_next(stop)) {
        auto index = data.dataRaptor.sp_indexrouteorder[stop];

        it += index.first - last;
        last = index.first + index.second;
        const auto end = it+index.second;
        for(; it!=end; ++it) {
            if((Q[it->first] > it->second) && vp_valides.test(data.dataRaptor.routes[it->first].vp))
                Q[it->first] = it->second;
        }
        marked_sp.flip(stop);
    }
}



void RAPTOR::make_queuereverse() {
    Q.assign(data.dataRaptor.routes.size(), std::numeric_limits<int>::min());
    auto it = data.dataRaptor.sp_routeorder_const_reverse.begin();
    int last = 0;
    for(auto stop = marked_sp.find_first(); stop != marked_sp.npos; stop = marked_sp.find_next(stop)) {
        auto index = data.dataRaptor.sp_indexrouteorder[stop];

        it += index.first - last;
        last = index.first + index.second;
        const auto end = it+index.second;
        for(; it!=end; ++it) {
            if((Q[it->first] < it->second) && vp_valides.test(data.dataRaptor.routes[it->first].vp))
                Q[it->first] = it->second;
        }
        marked_sp.flip(stop);
    }
}

void RAPTOR::marcheapied() {

    auto it = data.dataRaptor.foot_path.begin();
    int last = 0;
    for(auto stop_point = marked_sp.find_first(); stop_point != marked_sp.npos; stop_point = marked_sp.find_next(stop_point)) {
        const auto & index = data.dataRaptor.footpath_index[stop_point];
        const type_retour & retour_temp = retour[count][stop_point];
        int prec_duration = -1;
        DateTime dtTemp = retour_temp.dt;
        std::advance(it, index.first - last);
        const auto end = it + index.second;

        for(; it != end; ++it) {
            navitia::type::idx_t destination = (*it).destination_stop_point_idx;
            if(stop_point != destination) {
                if(it->duration != prec_duration) {
                    dtTemp = retour_temp.dt + it->duration;
                    prec_duration = it->duration;
                }
                if(dtTemp <= best[destination].dt) {
                    const type_retour nRetour = type_retour(navitia::type::invalid_idx, stop_point, dtTemp, connection);
                    if(!b_dest.ajouter_best(destination, nRetour, count)) {
                        best[destination] = nRetour;
                        retour[count][destination] = nRetour;
                        marked_sp.set(destination);
                    } else if(count == 0 || retour[count - 1][destination].type == uninitialized) {
                        retour[count][destination] = nRetour;
                    }
                }
            }
        }
        last = index.first + index.second;
    }
}


void RAPTOR::marcheapiedreverse() {
    auto it = data.dataRaptor.foot_path.begin();
    int last = 0;
    for(auto stop_point = marked_sp.find_first(); stop_point != marked_sp.npos; stop_point = marked_sp.find_next(stop_point)) {
        const auto & index = data.dataRaptor.footpath_index[stop_point];
        std::advance(it, index.first - last);
        const auto end = it + index.second;
        for(; it != end; ++it) {
            navitia::type::idx_t destination = it->destination_stop_point_idx;
            if(stop_point != destination) {
                const type_retour & retour_temp = retour[count][stop_point];
                const DateTime dtTemp = retour_temp.dt - it->duration;
                if(dtTemp >= best[destination].dt) {
                    const type_retour nRetour = type_retour(navitia::type::invalid_idx, stop_point, dtTemp, connection);
                    if(!b_dest.ajouter_best_reverse(destination, nRetour, count)) {
                        best[destination] = nRetour;
                        retour[count][destination] = nRetour;
                        marked_sp.set(destination);
                    } else if(count == 0 || retour[count - 1][destination].type == uninitialized) {
{'fraction_non_alphanumeric': 0.1262563785371888, 'fraction_numerical': 0.003247255296118757, 'mean_word_length': 2.2017326732673266, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6168984', 'n_tokens_mistral': 4148, 'n_tokens_neox': 4001, 'n_words': 789}