private double calculateLSLocalSolutionValue(ArrayList acList) { double lsSolutionValue = 0; foreach (ACourse ac in acList) { ATeacher at = ac.MyATeacher; foreach (AbstractSoftConstraint sc in at.MySoftConstraints) { lsSolutionValue = lsSolutionValue + sc.evaluateSC(); } if (!ac.IsHTCourse)//?? check this for AEP soft constraints { foreach (AbstractSoftConstraint sc in ac.MySoftConstraints) { lsSolutionValue = lsSolutionValue + sc.evaluateSC(); } AEduProgram aep = (AEduProgram)ac.MyAEduProgram; foreach (AbstractSoftConstraint sc in aep.MySoftConstraints) { lsSolutionValue = lsSolutionValue + sc.evaluateSC(); } } } return(lsSolutionValue); }
public override double evaluateSC() { AEduProgram aep = (AEduProgram)_theObj; int mySC_MaxHoursDaily = (int)_myArgs[0]; string groupName = (string)_myArgs[1]; double myWeight = (double)_myArgs[2]; /// int numOfIncludedDaysPerWeek = AGlobal.NUM_OF_INCLUDED_DAYS_PER_WEEK; int numOfTermsPerDay = AGlobal.NUM_OF_INCLUDED_TERMS_PER_DAY; int numOfSlotsPerRoom = numOfIncludedDaysPerWeek * numOfTermsPerDay; int[] lessonsDaily = new int[numOfIncludedDaysPerWeek]; foreach (ACourse ac in aep.MyCourses) { if (ac.GroupName == groupName || ac.GroupName == "" || ac.GroupName == null) { if (ac.MyFixedLessonNodes != null) { foreach (ALessonNode aln in ac.MyFixedLessonNodes) { int tsIndex = aln.CurrPosition; if (tsIndex > 0) { int indexCol = (int)Math.Floor((decimal)((tsIndex - 1) % numOfSlotsPerRoom) / numOfTermsPerDay); lessonsDaily[indexCol]++; } } } if (ac.MyAllLessonNodesForAllocation != null) { foreach (ALessonNode aln in ac.MyAllLessonNodesForAllocation) { int tsIndex = aln.CurrPosition; if (tsIndex > 0) { int indexCol = (int)Math.Floor((decimal)((tsIndex - 1) % numOfSlotsPerRoom) / numOfTermsPerDay); lessonsDaily[indexCol]++; } } } } } double res = 0; foreach (int n in lessonsDaily) { if (n > mySC_MaxHoursDaily) { res = res + myWeight; } } return(res); }
public ACourse(AEduProgram myAEduProgram, ATeacher myATeacher, string groupName, bool[] myBoolPosTS, string name) { _name = name; _myAEduProgram = myAEduProgram; _myATeacher = myATeacher; _groupName = groupName; _myAllLessonNodesForAllocation = new ArrayList(); _myBoolPosTS = myBoolPosTS; _numOfPossTSAtStart = AGlobal.getNumOfPossTS(_myBoolPosTS); _mySoftConstraints = new ArrayList(); }
public override double evaluateSC() { AEduProgram aep = (AEduProgram)_theObj; int mySC_MaxDaysPerWeek = (int)_myArgs[0]; string groupName = (string)_myArgs[1]; double myWeight = (double)_myArgs[2]; /// int numOfIncludedDaysPerWeek = AGlobal.NUM_OF_INCLUDED_DAYS_PER_WEEK; int numOfTermsPerDay = AGlobal.NUM_OF_INCLUDED_TERMS_PER_DAY; int numOfSlotsPerRoom = numOfIncludedDaysPerWeek * numOfTermsPerDay; bool[] occupDaysBool = new bool[numOfIncludedDaysPerWeek]; foreach (ACourse ac in aep.MyCourses) { if (ac.GroupName == groupName || ac.GroupName == "" || ac.GroupName == null) { if (ac.MyFixedLessonNodes != null) { foreach (ALessonNode aln in ac.MyFixedLessonNodes) { int tsIndex = aln.CurrPosition; if (tsIndex > 0) { int indexCol = (int)Math.Floor((decimal)((tsIndex - 1) % numOfSlotsPerRoom) / numOfTermsPerDay); occupDaysBool[indexCol] = true; } } } if (ac.MyAllLessonNodesForAllocation != null) { foreach (ALessonNode aln in ac.MyAllLessonNodesForAllocation) { int tsIndex = aln.CurrPosition; if (tsIndex > 0) { int indexCol = (int)Math.Floor((decimal)((tsIndex - 1) % numOfSlotsPerRoom) / numOfTermsPerDay); occupDaysBool[indexCol] = true; } } } } } int usedDays = 0; for (int j = 0; j < numOfIncludedDaysPerWeek; j++) { if (occupDaysBool[j]) { usedDays++; } } if (usedDays > mySC_MaxDaysPerWeek) { return(myWeight); } return(0); }
public override double evaluateSC() { AEduProgram aep = (AEduProgram)_theObj; int mySC_PreferredStartTimePeriod = (int)_myArgs[0]; string groupName = (string)_myArgs[1]; double myWeight = (double)_myArgs[2]; /// int numOfIncludedDaysPerWeek = AGlobal.NUM_OF_INCLUDED_DAYS_PER_WEEK; int numOfTermsPerDay = AGlobal.NUM_OF_INCLUDED_TERMS_PER_DAY; int numOfSlotsPerRoom = numOfIncludedDaysPerWeek * numOfTermsPerDay; bool[,] occupTSBool = new bool[numOfTermsPerDay, numOfIncludedDaysPerWeek]; foreach (ACourse ac in aep.MyCourses) { if (ac.GroupName == groupName || ac.GroupName == "" || ac.GroupName == null) { if (ac.MyFixedLessonNodes != null) { foreach (ALessonNode aln in ac.MyFixedLessonNodes) { int tsIndex = aln.CurrPosition; if (tsIndex > 0) { int indexRow = (tsIndex - 1) % numOfTermsPerDay; int indexCol = (int)Math.Floor((decimal)((tsIndex - 1) % numOfSlotsPerRoom) / numOfTermsPerDay); occupTSBool[indexRow, indexCol] = true; } } } if (ac.MyAllLessonNodesForAllocation != null) { foreach (ALessonNode aln in ac.MyAllLessonNodesForAllocation) { int tsIndex = aln.CurrPosition; if (tsIndex > 0) { int indexRow = (tsIndex - 1) % numOfTermsPerDay; int indexCol = (int)Math.Floor((decimal)((tsIndex - 1) % numOfSlotsPerRoom) / numOfTermsPerDay); occupTSBool[indexRow, indexCol] = true; } } } } } double result = 0.0; for (int j = 0; j < numOfIncludedDaysPerWeek; j++) { for (int k = 0; k < numOfTermsPerDay; k++) { if (occupTSBool[k, j] == true) { if (mySC_PreferredStartTimePeriod != (k + 1)) { result += myWeight; } break; } } } return(result); }
public override double evaluateSC() { AEduProgram aep = (AEduProgram)_theObj; int mySC_MaxHoursContinuously = (int)_myArgs[0]; string groupName = (string)_myArgs[1]; double myWeight = (double)_myArgs[2]; /// int numOfIncludedDaysPerWeek = AGlobal.NUM_OF_INCLUDED_DAYS_PER_WEEK; int numOfTermsPerDay = AGlobal.NUM_OF_INCLUDED_TERMS_PER_DAY; int numOfSlotsPerRoom = numOfIncludedDaysPerWeek * numOfTermsPerDay; bool[,] occupTSBool = new bool[numOfTermsPerDay, numOfIncludedDaysPerWeek]; foreach (ACourse ac in aep.MyCourses) { if (ac.GroupName == groupName || ac.GroupName == "" || ac.GroupName == null) { if (ac.MyFixedLessonNodes != null) { foreach (ALessonNode aln in ac.MyFixedLessonNodes) { int tsIndex = aln.CurrPosition; if (tsIndex > 0) { int indexRow = (tsIndex - 1) % numOfTermsPerDay; int indexCol = (int)Math.Floor((decimal)((tsIndex - 1) % numOfSlotsPerRoom) / numOfTermsPerDay); occupTSBool[indexRow, indexCol] = true; } } } if (ac.MyAllLessonNodesForAllocation != null) { foreach (ALessonNode aln in ac.MyAllLessonNodesForAllocation) { int tsIndex = aln.CurrPosition; if (tsIndex > 0) { int indexRow = (tsIndex - 1) % numOfTermsPerDay; int indexCol = (int)Math.Floor((decimal)((tsIndex - 1) % numOfSlotsPerRoom) / numOfTermsPerDay); occupTSBool[indexRow, indexCol] = true; } } } } } for (int j = 0; j < occupTSBool.GetLength(1); j++) { int hoursCont = 0; bool blockCheckStarted = false; int lastRowIndex = 0; for (int k = 0; k < occupTSBool.GetLength(0); k++) { if (occupTSBool[k, j] == true) { if (!blockCheckStarted) { blockCheckStarted = true; lastRowIndex = k; hoursCont = 1; } else { lastRowIndex = k; hoursCont++; } } else { if (blockCheckStarted) { if (hoursCont > mySC_MaxHoursContinuously) { return(myWeight); } hoursCont = 0; } } } //end of column if (hoursCont > mySC_MaxHoursContinuously) { return(myWeight); } } return(0); }
public override double evaluateSC() { AEduProgram aep = (AEduProgram)_theObj; int mySC_GapIndicator = (int)_myArgs[0]; string groupName = (string)_myArgs[1]; double myWeight =(double)_myArgs[2]; /// int numOfIncludedDaysPerWeek = AGlobal.NUM_OF_INCLUDED_DAYS_PER_WEEK; int numOfTermsPerDay = AGlobal.NUM_OF_INCLUDED_TERMS_PER_DAY; int numOfSlotsPerRoom = numOfIncludedDaysPerWeek * numOfTermsPerDay; bool[,] occupTSBool = new bool[numOfTermsPerDay, numOfIncludedDaysPerWeek]; foreach (ACourse ac in aep.MyCourses) { if (ac.GroupName == groupName || ac.GroupName == "" || ac.GroupName == null) { if (ac.MyFixedLessonNodes != null) { foreach (ALessonNode aln in ac.MyFixedLessonNodes) { int tsIndex = aln.CurrPosition; if (tsIndex > 0) { int indexRow = (tsIndex - 1) % numOfTermsPerDay; int indexCol = (int)Math.Floor((decimal)((tsIndex - 1) % numOfSlotsPerRoom) / numOfTermsPerDay); occupTSBool[indexRow, indexCol] = true; } } } if (ac.MyAllLessonNodesForAllocation != null) { foreach (ALessonNode aln in ac.MyAllLessonNodesForAllocation) { int tsIndex = aln.CurrPosition; if (tsIndex > 0) { int indexRow = (tsIndex - 1) % numOfTermsPerDay; int indexCol = (int)Math.Floor((decimal)((tsIndex - 1) % numOfSlotsPerRoom) / numOfTermsPerDay); occupTSBool[indexRow, indexCol] = true; } } } } } int numOfGaps = 0; int gapSize = 0; for (int j = 0; j < numOfIncludedDaysPerWeek; j++) { bool blockStarted = false; bool gapStarted = false; gapSize = 0; for (int k = 0; k < numOfTermsPerDay; k++) { if (occupTSBool[k, j] == true) { if (!blockStarted) { blockStarted = true; } if (gapStarted) { //if (gapSize < 4) numOfGaps++; //here if (gapSize <= mySC_GapIndicator) numOfGaps++; gapSize = 0; gapStarted = false; } } else { if (blockStarted) { gapStarted = true; gapSize++; blockStarted = false; } else if (gapStarted) { gapSize++; } } } } return numOfGaps * myWeight; }