def run(self, max_size=10, variable_size=True, diversify=False, view=config.default_view, **kwargs): """ Runs the evolutionary algorithm. Parameters ---------- max_size : int Maximum size of a solution, e.g., the maximum number of reactions or genes to knock-out or swap. variable_size : boolean If true, the solution size can change meaning that the combination of knockouts can have different sizes up to max_size. Otherwise it only produces knockout solutions with a fixed number of knockouts. diversify : bool It true, the generator will not be allowed to generate repeated candidates in the initial population. view : cameo.parallel.SequentialView, cameo.parallel.MultiprocessingView A view for single or multiprocessing. Returns ------- TargetOptimizationResult The result of the optimization. """ if kwargs.get('seed', None) is None: kwargs['seed'] = int(time.time()) self.heuristic_method.observer = self.observers log_level = simulation_logger.level simulation_logger.setLevel(logging.CRITICAL) if diversify: generator = diversify_function(generators.set_generator) else: generator = generators.set_generator with EvaluatorWrapper(view, self._evaluator) as evaluator: super(TargetOptimization, self).run(distance_function=set_distance_function, representation=self.representation, evaluator=evaluator, generator=generator, max_size=max_size, **kwargs) simulation_logger.setLevel(log_level) return TargetOptimizationResult(model=self.model, heuristic_method=self.heuristic_method, simulation_method=self.simulation_method, simulation_kwargs=self._simulation_kwargs, solutions=self.heuristic_method.archive, objective_function=self.objective_function, target_type=self._target_type, decoder=self._decoder, evaluator=self._evaluator, seed=kwargs['seed'], metadata=self.metadata, view=view)