当前位置: 首页>>代码示例>>Python>>正文


Python Configuration.get_room_by_id方法代码示例

本文整理汇总了Python中configuration.Configuration.get_room_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Configuration.get_room_by_id方法的具体用法?Python Configuration.get_room_by_id怎么用?Python Configuration.get_room_by_id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在configuration.Configuration的用法示例。


在下文中一共展示了Configuration.get_room_by_id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_num_rooms

# 需要导入模块: from configuration import Configuration [as 别名]
# 或者: from configuration.Configuration import get_room_by_id [as 别名]
This is testing the get_num_rooms() function in configuration.py
It checks to see if the correct number of rooms is returned
Input: config file (3 rooms)
Expected output: 3
"""
num = config.get_num_rooms()
print num


"""
This is testing the get_room_by_id() function in configuration.py
It checks to see if the correct room name, seat number, and lab is returned 
Input: config file (ID: 2)
Expected output: Unknown
"""
room = config.get_room_by_id(2)
print str(room.name) + " " + str(room.seat_num) + " " + str(room.lab)


"""
This is testing the get_num_classes() function in configuration.py
It checks to see if the correct number of classes is returned 
Input: config file(26 classes)
Expected output: 26 
"""
num = config.get_num_classes()
print num


"""
This is testing the get_class_by_course() function
开发者ID:bpross,项目名称:MyCourses-Scheduler,代码行数:33,代码来源:config_test.py

示例2: __init__

# 需要导入模块: from configuration import Configuration [as 别名]
# 或者: from configuration.Configuration import get_room_by_id [as 别名]

#.........这里部分代码省略.........
                self.hash_map[classes] = temp_index
 
            #Places class in schedule
            while total_duration < classes.duration\
                      and temp_index < len(self.chromo_list):
                    new_chromo = self.insert_chromosome(Chromosome(),\
                                                        temp_index)
                    self.number_chromosomes += 1
                    #Checks to see if the class is already in the hashmap,
                    #if not Class object is added with value being location
                    #in list Only adds when the class starts
                    #Assigns the class to the new chromosome
                    new_chromo._class = classes
                    self.calculate_fitness(new_chromo,temp_index)
                    total_duration += 1
                    temp_index += 1
            
    
    def calculate_fitness(self,chromo,index):
        """
        Calculates the fitness of a chromosome
        @param chromo: chromosome to calculate fitness for
        @param index: index in self.chromo_list of the chromosome
        """
        #Incase chromosome has been scheduled before
        chromo.fitness = 0
        
        hold_index = index
        
        #Figure out which room you are in
        data_tuple = self.get_room_day_numbers(hold_index)
        room_id = data_tuple[1]
        #Get Room object
        room = self.config.get_room_by_id(room_id)

        course = chromo._class
        #Course might not overlap at current position, but could if duration is
        #longer than 1, this checks for that
        if not chromo.overlap:
            if course.duration > 1:
                count = 0
                while count < (course.duration):
                    index += 1
                    if index < len(self.chromo_list):
                        check_list = self.chromo_list[index]
                        if check_list:
                            chromo.overlap = True
                    count += 1

        #Class does not overlap EVER
        if not chromo.overlap:
            chromo.fitness += 1

        #Room is able to fit the class
        if course.get_room_size() <= room.get_seat_num():
            chromo.fitness += 1

        #Course needs lab and room has lab
        if course.needs_lab():
            if room.lab_status():
                chromo.fitness += 1

        #Course doesnt need lab and room doesnt have lab
        if not course.needs_lab():
            if not room.lab_status():
                chromo.fitness += 1
开发者ID:bpross,项目名称:MyCourses-Scheduler,代码行数:70,代码来源:schedule.py


注:本文中的configuration.Configuration.get_room_by_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。