metavar='S', type=int, help='Number of steps per epoch.', default=60) args = parser.parse_args() """ For graceful ending """ end = False signal.signal(signal.SIGINT, signal_handler) # Create the evironment num_of_agents = args.N env = Lake(filepath='map_2.csv', number_of_agents=num_of_agents, action_type="complete", init_pos=np.array([[11, 12]]), importance_map_path='importance_map_2.csv') """ --- HYPERPARAMETERS --- """ gamma = 0.95 num_of_epochs = args.E steps_per_episode = args.S epsilon = 0.99 lr = 1e-4 n_actions = 8 input_dims = env.render().shape eps_min = 0.005 eps_dec = (epsilon - eps_min) / (num_of_epochs * 0.4) mem_size = 10000
parser.add_argument('--agents', metavar='agents', type=int, help='Num of agents', default=2) args = parser.parse_args() r = args.R cxpb = args.cxpb mutpb = args.mutpb NUM_OF_AGENTS = args.agents # Creation of the environment # print(" ---- OPTIMIZING MAP NUMBER {} ----".format(r)) env = Lake(filepath='map_{}.csv'.format(r), number_of_agents=NUM_OF_AGENTS, action_type="complete", init_pos=init_points, importance_map_path='importance_map_{}.csv'.format(r), num_of_moves=30*r) IND_SIZE = 8 # Number of actions # # Creation of the algorithm. Maximization like. # creator.create('FitnessMax', base.Fitness, weights=(1.0,)) creator.create('Individual', list, fitness=creator.FitnessMax) toolbox = base.Toolbox() # Generate a random action set toolbox.register("indices", np.random.randint, 0, 8, size=NUM_OF_AGENTS * r * 30)
# mutpb = args.mutpb r = 2 cxpb = 0.7 mutpb = 0.3 NUM_OF_AGENTS = 1 # Creation of the environment # print(" ---- OPTIMIZING MAP NUMBER {} ----".format(r)) env = Lake( filepath='map_{}.csv'.format(r), number_of_agents=NUM_OF_AGENTS, action_type="complete", init_pos=init_points, # para el caso multi agente #init_pos=init_points[r - 1][np.newaxis], importance_map_path='importance_map_{}.csv'.format(r), num_of_moves=50) IND_SIZE = 8 # Number of actions # # Creation of the multi-objective problem # # First objective: NHPP # Second objective: distance creator.create('FitnessMax', base.Fitness, weights=(1.0, -1.0)) creator.create('Individual', list, fitness=creator.FitnessMax) toolbox = base.Toolbox()
args = parser.parse_args() """ For graceful ending """ end = False signal.signal(signal.SIGINT, signal_handler) """ Directory """ now = datetime.now() directory = now.strftime( "./other_results/GENERALIZATION_TRAINING_DDQL_%d_%m_%Y_%H_%M_%S") os.makedirs(directory) r = args.R env = Lake(filepath='map_{}.csv'.format(r), number_of_agents=1, action_type="complete", init_pos=init_points[r - 1][np.newaxis], importance_map_path='importance_map_{}.csv'.format(r), num_of_moves=30 * r) """ --- HYPERPARAMETERS --- """ gamma = 0.95 num_of_epochs = args.E steps_per_episode = 30 * r epsilon = 0.99 lr = 1e-4 n_actions = 8 input_dims = env.render().shape eps_min = 0.005 eps_dec = (epsilon - eps_min) / (num_of_epochs * 0.5) mem_size = 10000
help='Recycle the population in the first case', default=None) args = parser.parse_args() r = args.R cxpb = args.cxpb mutpb = args.mutpb # Creation of the environment # print(" ---- OPTIMIZING MAP NUMBER {} ----".format(r)) env = Lake(filepath='map_{}.csv'.format(r), number_of_agents=1, action_type="complete", init_pos=init_points[r - 1][np.newaxis], importance_map_path='importance_map_{}.csv'.format(r), num_of_moves=30 * r) env2 = Lake(filepath='map_{}.csv'.format(r), number_of_agents=1, action_type="complete", init_pos=init_points[r - 1][np.newaxis], importance_map_path='alt_importance_map_{}.csv'.format(r), num_of_moves=30 * r) IND_SIZE = 8 # Number of actions # # Creation of the algorithm. Maximization like. # creator.create('FitnessMax', base.Fitness, weights=(1.0, )) creator.create('Individual', list, fitness=creator.FitnessMax)