//! Checks if a solution has been found /*! * \return bool true if complete */ public bool isComplete() { if (cancel) { return(true); } if (set.isEmpty()) { return(true); } else { return(false); } }
//! Checks if a solution has been found /*! * \return bool true if complete * This function will tell the scheduler if a solutin has been found * evaluation function */ public bool isComplete() { return(set.isEmpty()); }
//! Calculates a schedule from the defined problem /*! * \pram ScheduleProblemInterface defined problem with contactwindows * Greedy approach earliest job first. */ public void CalculateSchedule(ScheduleProblemInterface problem) { set = problem.getContactWindows(); ContactWindowsVector set1 = new ContactWindowsVector(); ContactWindowsVector set2 = new ContactWindowsVector(); List <string> staName = set.getStationNames(); //while set is not empty do while (!isComplete()) { //loop through all Stations for (int i = 0; i < staName.Count(); i++) { int pos = -1; double earliest = 9999.99; int priority = 4; //loop through all Contacts and find the item that finisches //first and has the highest priority. for (int k = 0; k < set.Count(); k++) { if (set.getAt(k).getStationName() == staName[i]) { if (set.getAt(k).getStopTime().getEpoch() < earliest && (int)set.getAt(k).getPriority() <= priority) { pos = k; earliest = set.getAt(k).getStopTime().getEpoch(); priority = (int)set.getAt(k).getPriority(); } } } //update Progress Bar on Main Form if (Properties.Settings.Default.global_MaxPerf == false) { System.Windows.Forms.Application.DoEvents(); } if (f != null) { f.incrementProgressBar(); } //the found earliest job is added to set1 if its empty //or no other contact in set1 is conflicting with it //if there is a conflict add this element to set2 //Then the element is deleted from set1 if (pos > -1) { if (set1.isEmpty()) { set1.add(set.getAt(pos)); set.deleteAt(pos); } else { bool found = false; for (int k = 0; k < set1.Count(); k++) { if (set.getAt(pos).checkConflikt(set1.getAt(k))) { if (set.getAt(pos).getSatName() == set1.getAt(k).getSatName()) { set2.add(set.getAt(pos)); set.deleteAt(pos); found = true; break; } } } if (!found) { set1.add(set.getAt(pos)); set.deleteAt(pos); } } } } } for (int i = 0; i < set1.Count(); i++) { set1.getAt(i).setSheduled(); } for (int i = 0; i < set2.Count(); i++) { set2.getAt(i).unShedule(); } set.add(set1); set.add(set2); schedule = set; solveConflictsByPriority(); if (f != null) { f.resetProgressBar(); } }