from ttp_loader import ttp_loader import PoblationalSearch.Operators.crossover as crossover import PoblationalSearch.Operators.mutation as mutation import PoblationalSearch.Operators.selection as selection problem = ttp_loader('TTP/eil51_n50_uncorr_01.ttp') tsp = { 'ind_size': problem.dimension, 'p_size': 64, 'generations': 0, 'agent': TSPCoAgent, 'selection_op': selection.matting_restriction(hamming_distance, 2), 'mutation_op': mutation.tsp_mutation(mutation.perm_mutation()), 'crossover_op': crossover.perm_crossover(problem.dimension), 'distance': hamming_distance, 'radious': 2 } W = problem.capacity item_w = [it[1] for it in problem.items] kp = { 'ind_size': problem.n_items, 'p_size': 64, 'generations': 0, 'agent': KPCoAgent, 'selection_op': selection.matting_restriction(hamming_distance, 2), 'mutation_op': mutation.kp_mutation(W, item_w, mutation.bin_mutation()), 'crossover_op': crossover.kp_crossover(W, item_w, crossover.simple_crossover()),
'crossover_rate': 0.7, 'crossover_op': crossover.multipoint_crossover(2) } #rga = GeneticAlgorithm(**binary_GA).execute() #print(rga.best_ind[-1]) permutation_GA = { 'function': dummy, 'ind_size': 10, 'p_size': p_size, 'generations': generations, 'agent': PermutationAgent, 'selection_op': selection.elitist_tournament(), 'mutation_op': mutation.flip_mutation(), 'crossover_rate': 0.7, 'crossover_op': crossover.perm_crossover(10) } #pga = GeneticAlgorithm(**permutation_GA).execute() #print(pga.best_ind[-1]) evolution_strategy = { 'function': ackley, 'ind_size': 5, 'p_size': p_size, 'generations': generations, 'selection_op': selection.random_selection(), 'mutation_op': mutation.e_strategy_mutation(), 'recombination_op': crossover.real_crossover(5, 'exogenous'), 'marriage_size': 2, 'agent_args': { '_min': -32.768,