コード例 #1
0
def main():
    domain = [(4, 10)]*(len(all_nodes)*2+2)
     
    # genetic alg 
    optimal_solution1 = genetic_alg_general.genetic_alg_general(domain, count_cross)
    print optimal_solution1
    draw_solution(optimal_solution1[1])
     
    # simulated annealing
    optimal_solution2 = simulated_annealing_general.simulated_annealing(domain, count_cross)
    print optimal_solution2
    draw_solution(optimal_solution2[0])
def main():
    # random search optimization
    optimal_vec = optimal_assign()
    print_solution(optimal_vec)
    
    num_slots = len(top_choices)
    domain = [(0,len(game_groups)-1)]*num_slots
    
    # ************* try genetic optimization ****************#
    
    genetic_optimal_vec = genetic_alg_general.genetic_alg_general(domain, assign_cost)[1]
    print_solution(genetic_optimal_vec)
      
    # ************ try simulated annealing ****************#
    sa_optimal_vec, optimal_cost = simulated_annealing_general.simulated_annealing(domain, assign_cost)
    print optimal_cost
    print_solution(sa_optimal_vec)
コード例 #3
0
def main():
    # random search optimization
    optimal_vec = optimal_assign()
    print_solution(optimal_vec)

    num_slots = len(top_choices)
    domain = [(0, len(game_groups) - 1)] * num_slots

    # ************* try genetic optimization ****************#

    genetic_optimal_vec = genetic_alg_general.genetic_alg_general(
        domain, assign_cost)[1]
    print_solution(genetic_optimal_vec)

    # ************ try simulated annealing ****************#
    sa_optimal_vec, optimal_cost = simulated_annealing_general.simulated_annealing(
        domain, assign_cost)
    print optimal_cost
    print_solution(sa_optimal_vec)