# Create objectiveFunction function obj_function = MaxGroupDiff(problem['adj_matrix'], problem['Gmax'] - problem['Gmin']) # Create ACO instance colony = antco.ACO(n_ants=n_ants, graph=problem['adj_matrix'], heuristic=None, objective=obj_function, iterations=iterations, graph_type=graph_type, evaporation=evaporation, alpha=alpha, beta=beta, pheromone_init=pheromone_init, path_limits=path_limits, pheromone_update=pheromone_update, n_jobs=n_jobs, seed=seed, tol=tol, Q=Q, R=R, scaleScores=antco.tools.MinMaxScaler(max_val=1.0, max_historic=True)) # Pre-process ACO instance antco.preproc.apply(colony, accessory_node=True) #antco.preproc.apply(colony, scale_heuristic={'min_val': 0.0, 'max_val': 1.0}) # Run algorithm
generations=generations, tournsize=tournsize, hof=elite, n_jobs=ea_n_jobs, genetic_objective_args={'cost_matrix': distance_matrix}) # Create ACO instance colony = antco.ACO(n_ants=n_ants, graph=adjacency_matrix, heuristic=-1 * distance_matrix, objective=obj_function, iterations=iterations, graph_type=graph_type, evaporation=evaporation, alpha=alpha, beta=beta, pheromone_init=pheromone_init, path_limits=(n_nodes - 1, n_nodes), tol=tol, pheromone_update=pheromone_update, n_jobs=n_jobs, seed=seed, scaleScores=antco.tools.MinMaxScaler(max_val=2.0, max_historic=True)) # Pre-process ACO instance antco.preproc.apply(colony, scale_heuristic={'min_val': 0.0, 'max_val': 1.0}) # Run algorithm print(f'\nNumber of cities: {n_nodes}\n') start = time.time()
'strategy': 'acs', 'decay': 0.1, 'graph_type': graph_type, 'weight': 1.0 } aco_obj = MinDistance(distance_matrix, objective) # Create ACO instance colony = antco.ACO(n_ants=n_ants, graph=adjacency_matrix, heuristic=(-1 * distance_matrix), objective=aco_obj, iterations=iterations, graph_type=graph_type, evaporation=evaporation, alpha=alpha, beta=beta, pheromone_init=pheromone_init, path_limits=(n_nodes - 1, n_nodes), pheromone_update=pheromone_update, n_jobs=n_jobs, seed=seed, tol=tol, Q=0.5) antco.preproc.apply(colony, scale_heuristic={'min_val': 0.0, 'max_val': 1.0}) # Run algorithm print(f'\nNumber of cities: {n_nodes}\n') start = time.time() report = antco.algorithm.antColonySystem(colony) end = time.time()