本文整理匯總了Python中Class.getSize方法的典型用法代碼示例。如果您正苦於以下問題:Python Class.getSize方法的具體用法?Python Class.getSize怎麽用?Python Class.getSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Class
的用法示例。
在下文中一共展示了Class.getSize方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: cost
# 需要導入模塊: import Class [as 別名]
# 或者: from Class import getSize [as 別名]
def cost(): # minimize this
result = 0
for droppedClass in droppedClasses:
result += droppedClass.getSize()
for room in rooms:
for key,Class in room.getClasses().items():
overflow = (Class.getSize() - room.getSize()) * (Class.getLength() + 1)
result += max(0, overflow) # add the number of students that don't fit, if any
return result
'''
示例2: numConflicts
# 需要導入模塊: import Class [as 別名]
# 或者: from Class import getSize [as 別名]
def numConflicts(): # meaningful objective function
result = 0
for droppedClass in droppedClasses:
result += droppedClass.getSize()
for room in rooms:
for key,Class in room.getClasses().items():
overflow = (Class.getSize() - room.getSize()) * Class.getLength()
result += max(0, overflow) # add the number of students that don't fit, if any
return result
#pre class cost
'''
示例3: swap
# 需要導入模塊: import Class [as 別名]
# 或者: from Class import getSize [as 別名]
swap((slotOrder1[slotIndex], roomOrder1[roomIndex]), (slotOrder2[slotIndex], roomOrder2[roomIndex]))
else:
currentCost = newCost # take it
if(currentCost < currentMin):
currentMin = currentCost
currentMinVector = copy.deepcopy(schedule)
'''
# modify temp
temp *= tempLoss
# heartbeat
# print(schedule)
# printSchedule(rooms)
print(currentCost, " : ", temp)
t1 = time.time()
printSchedule(rooms)
print(currentCost)
print("num conflicts: " + str(numConflicts()))
print("num dropped classes: " + str(len(droppedClasses)))
print("time: " + str(t1-t0))
for Class in droppedClasses:
print(str(Class.getSize()) + " : " + str(Class.getLength()))
print("Lowest value reached (for debugging/testing):")
print(currentMin)
print("DONE!")