當前位置: 首頁>>代碼示例>>Python>>正文


Python Class.getSize方法代碼示例

本文整理匯總了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
    
    '''
開發者ID:tupl,項目名稱:classOpt,代碼行數:15,代碼來源:ICS169Proj.py

示例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
    '''
開發者ID:tupl,項目名稱:classOpt,代碼行數:16,代碼來源:ICS169Proj.py

示例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!")
開發者ID:tupl,項目名稱:classOpt,代碼行數:32,代碼來源:ICS169Proj.py


注:本文中的Class.getSize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。