# Loop(Classroom1, m_count, h_count, t_count, l_count, loopsize)
File "/Users/maninder/git/TrialScheduler/TrialScheduler/main.py", line 27, in Loop
Loop(Classroom1, m_count, h_count, t_count, l_count, loopsize)
File "/Users/maninder/git/TrialScheduler/TrialScheduler/main.py", line 27, in Loop
Loop(Classroom1, m_count, h_count, t_count, l_count, loopsize)
File "/Users/maninder/git/TrialScheduler/TrialScheduler/main.py", line 27, in Loop #
编码:
from CProfessor import Professor
from CCourse import Course
from CClassroom import Classroom
import copy
def Loop(Classroom1, m_count, h_count, t_count, l_count, loopsize):
for i in range(0, loopsize):
Mutated = Classroom()
#Mutated = Classroom1.CopyOfClassroom(Mutated)
Mutated = copy.deepcopy(Classroom1)#Modification
Mutated.Mutate()
HardConstraintClassroomMet = Classroom1.ComputeHardConstraint()
HardConstraintMutatedMet = Mutated.ComputeHardConstraint()
if HardConstraintClassroomMet == False and HardConstraintMutatedMet == False:
h_count + 1
t_count + 1
Classroom1.Mutate()
continue
if Mutated.FitnessValue() > Classroom1.FitnessValue():
m_count + 1
t_count + 1
Classroom1 = Mutated
if Classroom1.ComputeHardConstraint() == False:
l_count + 1
temp = l_count*loopsize
print "Unable to meet hard consraints in %d" % temp
Loop(Classroom1, m_count, h_count, t_count, l_count, loopsize)
Professor0 = Professor(ProfessorId = 0, PreferedStartTime = 8, PreferedEndTime = 11)
Professor1 = Professor(ProfessorId = 1, PreferedStartTime = 10, PreferedEndTime = 13.75)
Professor2 = Professor(ProfessorId = 2, PreferedStartTime = 4, PreferedEndTime = 7.75)
# intializing Courses
Course0 = Course(CourseId = 0, ProfessorId = 0, CourseSlot = 0, CourseType ="UnderGraduate")
Course1 = Course(CourseId = 1, ProfessorId = 4, CourseSlot = 1) # we decided to leave this
coursetype to be emmpty and it is set none in the Course class
Course2 = Course(CourseId = 2, ProfessorId = 1, CourseSlot = 2, CourseType ="UnderGraduate")
Course3 = Course(CourseId = 3, ProfessorId = 4, CourseSlot = 3)
Course4 = Course(CourseId = 4, ProfessorId = 1, CourseSlot = 4, CourseType ="UnderGraduate")
Course5 = Course(CourseId = 5, ProfessorId = 4, CourseSlot = 5)
Course6 = Course(CourseId = 6, ProfessorId = 2, CourseSlot = 6, CourseType ="Graduate")
Course7 = Course(CourseId = 7, ProfessorId = 2, CourseSlot = 7, CourseType ="UnderGraduate")
# intializing
Classroom1 = Classroom(FirstCourseStartTime = 8, LastCourseEndTime = 7.75)
# Add all courses to Classroom1
Classroom1.AddCourse(Course0)
Classroom1.AddCourse(Course1)
Classroom1.AddCourse(Course2)
Classroom1.AddCourse(Course3)
Classroom1.AddCourse(Course4)
Classroom1.AddCourse(Course5)
Classroom1.AddCourse(Course6)
Classroom1.AddCourse(Course7)
# Add Professors to the classroom.
Classroom1.AddProfessor(Professor0)
Classroom1.AddProfessor(Professor1)
Classroom1.AddProfessor(Professor2)
m_count = 0 # mutations caused by grea
h_count = 0
t_count = 0
l_count = 0
loopsize = 10000
Loop(Classroom1, m_count, h_count, t_count, l_count, loopsize)
"""
Printing out the results:
"""
print '\n'
print "Mutation caused by greater fitness value %d" % m_count
print "Mutation caused by Hard Constraint Violations %d" % h_count
print "Number of Mutations before Converging" % t_count
Classroom1.PrintClassroom()