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


Python Configuration.get_num_classes方法代码示例

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


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

示例1: get_room_by_id

# 需要导入模块: from configuration import Configuration [as 别名]
# 或者: from configuration.Configuration import get_num_classes [as 别名]
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
Input: config file
Expected output: 2
This is testing the get_professor_by_id() function
Input: t_class.professor
Expected output: (Professor IDs) 2 and 3
This is testing the print_professor() function
Input: prof
Expected output: (2, Red) (3, Philip)
"""
t_class = config.get_class_by_course(2)
开发者ID:bpross,项目名称:MyCourses-Scheduler,代码行数:33,代码来源:config_test.py

示例2: __init__

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

#.........这里部分代码省略.........
                #Class is not found
                else:
                    search_chromosome = None
            
            return search_chromosome

    def algorithm(self):
        """
        Runs the schedule algorithm. Flow of algorithm:
            read in data
            initialize chromosome
            get_overall_fitness
            while overall fitness != 1.0
              get crossover points
              perform crossover
              get mutation size
              perform mutations
              get overall fitness

            return schedule
        """
        #Loads the config for the rooms/classes
        self.get_config()
        #Creates the first chromosome
        self.init_chromosomes()
        print "BOOBS"
        self.get_overall_fitness()
        #Seeds the random with system time
        random.seed()
        generations = 1
        print "TEST!!!"
        while self.get_overall_fitness() < 1.0 and generations <= 12500:
            #Get random points for crossover
            start_crossover = random.randint(0,self.config.get_num_classes())
            end_crossover = random.randint(0,self.config.get_num_classes())

            #Checks to see which crossover point is greater, Dont want to go
            #From a greater value to lesser value
            if start_crossover <= end_crossover:
                self.perform_crossover(start_crossover,end_crossover)
            else:
                self.perform_crossover(end_crossover, start_crossover)

            #Gets random mutation size and performs mutations
            self.mutation_size = random.randint(0,len(self.chromo_list))
            self.perform_mutations()
            generations += 1

            #Updates the console with Number of Generations and Perfect Chromos
            print_string_generation = "Generations: " + str(generations)
            print_string_best = " Overall Fitness: " + str(self.get_overall_fitness())
            PrintStatic(print_string_generation + print_string_best)

        print "\nDone! Took " + str(generations) + " Generations"

    def print_chromosomes(self):
        """
        Prints the chromo_list to console
        """
        count = 0
        while count < len(self.chromo_list):
            #Gets the list at counter
            chromo_list = self.chromo_list[count]
            if type(chromo_list) is ListType:
                len_list = len(chromo_list)
                if len_list > 1:
开发者ID:bpross,项目名称:MyCourses-Scheduler,代码行数:70,代码来源:schedule.py


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