vpr/src/route/router_lookahead_map.cpp
/* returns a cost entry that represents the medial of all recorded entries */
returns a cost entry that represents the medial of all recorded entries
returns a cost entry that represents the medial of all recorded entries
Cost_Entry Expansion_Cost_Entry::get_median_entry() {
    int num_bins = 10;
    Cost_Entry min_del_entry;
    Cost_Entry max_del_entry;
    for (auto entry : this->cost_vector) {
        if (min_del_entry.delay < 0 || entry.delay < min_del_entry.delay) {
            min_del_entry = entry;
        }
        if (max_del_entry.delay < 0 || entry.delay > max_del_entry.delay) {
            max_del_entry = entry;
        }
    }
    float delay_diff = max_del_entry.delay - min_del_entry.delay;
    float bin_size = delay_diff / (float)num_bins;
    std::vector<std::vector<Cost_Entry> > entry_bins(num_bins, std::vector<Cost_Entry>());
    for (auto entry : this->cost_vector) {
        float bin_num = floor((entry.delay - min_del_entry.delay) / bin_size);
        VTR_ASSERT(vtr::nint(bin_num) >= 0 && vtr::nint(bin_num) <= num_bins);
        if (vtr::nint(bin_num) == num_bins) {
            bin_num -= 1;
        }
        entry_bins[vtr::nint(bin_num)].push_back(entry);
    }
    int largest_bin = 0;
    int largest_size = 0;
    for (int ibin = 0; ibin < num_bins; ibin++) {
        if (entry_bins[ibin].size() > (unsigned)largest_size) {
            largest_bin = ibin;
            largest_size = (unsigned)entry_bins[ibin].size();
        }
    }
    Cost_Entry representative_entry = entry_bins[largest_bin][0];
    return representative_entry;
}
Cost_Entry Expansion_Cost_Entry :: get_median_entry ( ) { int num_bins = 10 ; Cost_Entry min_del_entry ; Cost_Entry max_del_entry ; for ( auto entry : this -> cost_vector ) { if ( min_del_entry . delay < 0 || entry . delay < min_del_entry . delay ) { min_del_entry = entry ; } if ( max_del_entry . delay < 0 || entry . delay > max_del_entry . delay ) { max_del_entry = entry ; } } float delay_diff = max_del_entry . delay - min_del_entry . delay ; float bin_size = delay_diff / ( float ) num_bins ; std :: vector < std :: vector < Cost_Entry > > entry_bins ( num_bins , std :: vector < Cost_Entry > ( ) ) ; for ( auto entry : this -> cost_vector ) { float bin_num = floor ( ( entry . delay - min_del_entry . delay ) / bin_size ) ; VTR_ASSERT ( vtr :: nint ( bin_num ) >= 0 && vtr :: nint ( bin_num ) <= num_bins ) ; if ( vtr :: nint ( bin_num ) == num_bins ) { bin_num -= 1 ; } entry_bins [ vtr :: nint ( bin_num ) ] . push_back ( entry ) ; } int largest_bin = 0 ; int largest_size = 0 ; for ( int ibin = 0 ; ibin < num_bins ; ibin ++ ) { if ( entry_bins [ ibin ] . size ( ) > ( unsigned ) largest_size ) { largest_bin = ibin ; largest_size = ( unsigned ) entry_bins [ ibin ] . size ( ) ; } } Cost_Entry representative_entry = entry_bins [ largest_bin ] [ 0 ] ; return representative_entry ; }
returns a cost entry that represents the medial of all recorded entries
returns a cost entry that represents the medial of all recorded entries
/* find median by binning the delays of all entries and then chosing the bin
     * with the largest number of entries */ /* find entries with smallest and largest delays */ /* get the bin size */ /* sort the cost entries into bins */ /* largest entry will otherwise have an out-of-bounds bin number */ /* find the bin with the largest number of elements */ /* get the representative delay of the largest bin */