我是 Python 新手。我收到一条错误消息,显示“未定义的变量”。我想不通。代码中的语句如下:
Classroom1 = Classroom(FirstCourseStartTime = 8, LastCourseEndTime = 7.75)
m_count = 0
h_count = 0
t_count = 0
l_count = 0
loopsize = 10000
Loop(Classroom1, m_count, h_count, t_count, l_count, loopsize)
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.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)