コード例 #1
0
void RRSchedule::allocate3D(TripleVector & _invect, int row, int col, int depth)
{
    _invect.clear();
    _invect.reserve(row);
    for (int i = 0; i < row; i++)
    {
        allocate2D(_invect[i], col, depth);
    }
}
コード例 #2
0
bool RRSchedule::sort_times_new(DoubleVector &_week)
{
    int minScore = max_teams * 100 * max_times;
    int score;
    Vector team_waits_now;
    DoubleVector bestWeek;
    Vector bestWaits;
    TripleVector potentialWeeks;
    
    //print_DoubleVector(_week);
    
    // Loop through all permutations of timeslots
    for (DoubleVector::const_iterator permute = timePermutes.begin(); permute != timePermutes.end(); ++permute)
    {
        DoubleVector testWeek = reconfigureWeek(_week, *permute);
        
        // Score the week based on total team waiting time
        score = compute_week_fitness(testWeek);
        
        // If the score is an improvement, keep that permutation
        if (score < minScore)
        {
            potentialWeeks.clear();
            potentialWeeks.push_back(testWeek);
            //bestWeek = testWeek;
            minScore = score;
            //std::cout << "Week Score (Sorted): " << score << std::endl;
        }
        else if (score == minScore)
        {
            potentialWeeks.push_back(testWeek);
        }
    }
    
    int randSelect = rand() % potentialWeeks.size();
    bestWeek = potentialWeeks[randSelect];
    
    //std::cout << "Random Selection: " << potentialWeeks.size() << "," << randSelect << std::endl;
    
    // Ugh, sorry; Hard overwrite the timeslots with the best version of the week
    timeslots = bestWeek;
    return true;
    
}