def init_evolution_algo(self): """Agent's GE algorithm operation defination.""" # Genetic algorithm parameters self.operation_threshold = 50 self.genome_storage = [] # Grammatical Evolution part from ponyge.algorithm.parameters import Parameters parameter = Parameters() parameter_list = ['--parameters', '../..,nm.txt'] # Comment when different results is desired. # Else set this for testing purpose # parameter.params['RANDOM_SEED'] = name # # np.random.randint(1, 99999999) # Set GE runtime parameters parameter.params['POPULATION_SIZE'] = self.operation_threshold // 2 parameter.set_params(parameter_list) self.parameter = parameter # Initialize the genome individual = initialisation(self.parameter, 1) individual = evaluate_fitness(individual, self.parameter) # Assign the genome to the agent self.individual = individual # Fitness self.beta = 0.9 self.diversity_fitness = self.individual[0].fitness self.individual[0].fitness = 0 self.generation = 0
def __init__(self, name, model): """Initialize the agent.""" super().__init__(name, model) self.location = () self.direction = model.random.rand() * (2 * np.pi) self.speed = 2 self.radius = 3 self.results = "db" # This can take 2 values. db or file # self.exchange_time = model.random.randint(2, 4) # This doesn't help. Maybe only perform genetic operations when # an agents meet 10% of its total population # """ self.operation_threshold = 2 self.genome_storage = [] # Define a BTContruct object self.bt = BTConstruct(None, self) # self.blackboard = Blackboard() # self.blackboard.shared_content = dict() self.shared_content = dict() # self.shared_content = dict( self.carryable = False self.beta = 0.0001 self.food_collected = 0 # Grammatical Evolution part from ponyge.algorithm.parameters import Parameters parameter = Parameters() parameter_list = ['--parameters', '../..,' + model.parm] # Comment when different results is desired. # Else set this for testing purpose # parameter.params['RANDOM_SEED'] = name # # np.random.randint(1, 99999999) parameter.params['POPULATION_SIZE'] = self.operation_threshold // 2 parameter.set_params(parameter_list) self.parameter = parameter individual = initialisation(self.parameter, 1) individual = evaluate_fitness(individual, self.parameter) self.individual = individual self.bt.xmlstring = self.individual[0].phenotype self.bt.construct() self.diversity_fitness = self.individual[0].fitness self.delayed_reward = 0 # Location history self.location_history = set() self.timestamp = 0 self.step_count = 0 self.fitness_name = True
def __init__(self, name, model): super().__init__(name, model) self.location = () self.direction = model.random.rand() * (2 * np.pi) self.speed = 2 self.radius = 3 # self.exchange_time = model.random.randint(2, 4) # This doesn't help. Maybe only perform genetic operations when # an agents meet 10% of its total population # """ self.operation_threshold = 50 self.genome_storage = [] # Define a BTContruct object # self.mapper = BTConstruct(None, None) # Grammatical Evolution part from ponyge.algorithm.parameters import Parameters parameter = Parameters() # list_params_files = ['string_match.txt', 'regression.txt', 'classification.txt'] # parameter_list = ['--parameters', 'string_match_dist.txt'] parameter_list = ['--parameters', '../,test_swarm.txt'] parameter.params['RANDOM_SEED'] = 1234 # np.random.randint(1, 99999999) parameter.params['POPULATION_SIZE'] = self.operation_threshold // 2 parameter.set_params(parameter_list) self.parameter = parameter individual = initialisation(self.parameter, 1) individual = evaluate_fitness(individual, self.parameter) # self.mapper.xmlstring = self.individual.phenotype self.individual = individual if self.name == 4: self.individual[0].fitness = 150
def __init__(self, name, model): super().__init__(name, model) self.location = () self.direction = model.random.rand() * (2 * np.pi) self.speed = 2 self.radius = 3 # self.exchange_time = model.random.randint(2, 4) # This doesn't help. Maybe only perform genetic operations when # an agents meet 10% of its total population # """ self.operation_threshold = 2 self.genome_storage = [] # Define a BTContruct object self.bt = BTConstruct(None, self) self.blackboard = Blackboard() self.blackboard.shared_content = dict() self.shared_content = dict() # Grammatical Evolution part from ponyge.algorithm.parameters import Parameters parameter = Parameters() parameter_list = ['--parameters', 'swarm.txt'] # Comment when different results is desired. # Else set this for testing purpose parameter.params['RANDOM_SEED'] = name # np.random.randint(1, 99999999) parameter.params['POPULATION_SIZE'] = self.operation_threshold // 2 parameter.set_params(parameter_list) self.parameter = parameter individual = initialisation(self.parameter, 1) individual = evaluate_fitness(individual, self.parameter) self.individual = individual self.bt.xmlstring = self.individual[0].phenotype self.bt.construct()
def __init__(self, name, model): super().__init__(name, model) self.location = () self.direction = model.random.rand() * (2 * np.pi) self.speed = 2 self.radius = 3 self.operation_threshold = 2 self.genome_storage = [] # Define a BTContruct object self.bt = BTConstruct(None, self) self.blackboard = Blackboard() self.blackboard.shared_content = dict() # Grammatical Evolution part from ponyge.algorithm.parameters import Parameters parameter = Parameters() parameter_list = ['--parameters', 'swarm.txt'] parameter.params['POPULATION_SIZE'] = self.operation_threshold // 2 parameter.params['RANDOM_SEED'] = model.seed parameter.set_params(parameter_list) self.parameter = parameter individual = initialisation(self.parameter, 1) self.individual = individual self.bt.xmlstring = self.individual[0].phenotype self.bt.construct() self.output = py_trees.display.ascii_tree(self.bt.behaviour_tree.root) # Location history self.location_history = set() self.timestamp = 0