void RRSchedule::init2DEmpty(DoubleVector &_invect, int row, int col) { _invect.clear(); _invect.resize(row); for (int i = 0; i < row; i++) allocate1D(_invect[i], col); }
void intArray() { int *buf; int i; buf = allocate1D(512); for(i = 0; i < 512; i++) buf[i] = i; printArray(buf); }
bool RRSchedule::add_timeslot() /* When timeslot is full; log information and begin fill up new timeslot */ { // Add courts to timeslot timeslots.push_back(courts); // Reset the courts allocate1D(courts, max_courts*2); // If timeslots are full, add to the week schedule // Note: Week0 may be smaller due to manager meeting if ((timeslots.size() == max_times) or (week0 and (timeslots.size() + skip_first == max_times))) return add_week(); else // Otherwise update strength and continue on update_total_team_waits(); return true; }
//////////////////////////////////////////////////////////////////////////////////////////////// ///// ********** PUBLIC METHODS //////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////// RRSchedule::RRSchedule(int _max_weeks, int _max_times, int _max_courts, int _max_teams, char* _FILENAME, int SKIP_FIRST) { max_weeks = _max_weeks; max_times = _max_times; max_courts = _max_courts; max_teams = _max_teams; skip_first = SKIP_FIRST; FILENAME = _FILENAME; week0 = (skip_first > 0); // Check if special considerations need to be made for the first week (allowing a meeting) min_per_night = (max_courts * max_times * 2) / max_teams; w0_min_per_night = (max_courts * (max_times-skip_first) * 2) / max_teams; max_per_night = (max_courts * max_times * 2) / max_teams + ( ((max_courts * max_times * 2) % max_teams) != 0); w0_max_per_night = (max_courts * (max_times - skip_first) * 2) / max_teams + ( ((max_courts * (max_times - skip_first) * 2) % max_teams) != 0); MAX_PLAYED_GAP = 1; // <= Gap between min times played and max times played if (max_per_night > 2) then: { MAX_WAIT_TIME = min_per_night; // <= Max time a team can wait each night } else { MAX_WAIT_TIME = min_per_night; } MAX_WAIT_GAP = 1; //*max_times ; // /2; // <= Gap between min team wait time and max team wait time MAX_TIMESLOT_GAP = 2 ; //max_weeks / 2; // <= Gap between count of min timeslot vs. max timeslot appearances TIMESLOT_FUDGE = 0; // *max_per_night; // Allow teams to play in a timeslot # over "ideal" max_per_time = (max_weeks * max_courts * 2) / max_teams + ( ((max_weeks * max_courts * 2) % max_teams) != 0) + TIMESLOT_FUDGE; // std::cout << "**" <<std:endl; fullSolution = false; total_wait_time = 0; init1D(this_week_played, max_teams); allocate1D(courts, max_courts*2); init1D(total_played, max_teams); init1D(total_waiting_by_team, max_teams); init2D(opponent_counts, max_teams, max_teams); allocate2D(timeslots, max_times, max_courts*2); allocate2D(matchups, max_weeks * max_times * max_courts, 2); init2D(this_week_matchups, (max_times-skip_first)*max_courts, 2); init2D(timeslots_played, max_teams, max_times); init2D(courts_played, max_teams, max_courts); allocate2D(timePermutes, FACTS[max_times], max_times); compute_permutations(); allocate2D(total_this_week_played,max_weeks, max_teams); allocate3D(weeks, max_weeks, max_times, max_courts*2); // clear old file std::ofstream outputfile; outputfile.open(FILENAME); outputfile.close(); }