def initialize(self): """ Randomly initialize the island populations @return: The initialized islands @rtype: list(list(Individual)) """ self._logger.info('Initializing the islands') islands = [] # TODO (JLD): Use _global_popsize where appropriate self._global_popsize = self._islands * self._pop_size # Randomly initialize each sub-population for k in xrange(self._islands): pop = [] for i in xrange(self._pop_size): ind = Individual() ind.id = i x_set = [None]*self._ndim for j in xrange(self._ndim): x_set[j] = self._rnd.uniform(self._lower_bound[j], self._upper_bound[j]) ind.x = x_set pop.append(ind) islands.append(pop) return islands
def parse_true_pareto_front(pareto_front_file): """ Parse the true pareto front @param pareto_front_file: The true pareto front file to parse @type pareto_front_file: str @return: The true pareto front as a list of Individuals @rtype: list(Individual) """ pareto_front = None if pareto_front_file != '': with open(pareto_front_file) as pf_file: pareto_front_dict = json.load(pf_file) pareto_front = [] for ind_dict in pareto_front_dict: ind = Individual() ind.from_dict(ind_dict) pareto_front.append(ind) return pareto_front
def initialize(self): """ Randomly initialize a population @return: The initialize population @rtype: list(Individual) """ self._logger.info('Initializing the population') pop = [] # Randomly initialize the population for i in xrange(self._pop_size): ind = Individual() ind.id = i x_set = [None]*self._ndim for j in xrange(self._ndim): x_set[j] = self._rnd.uniform(self._lower_bound[j], self._upper_bound[j]) ind.x = x_set pop.append(ind) return pop