Generate evolutions.
556746
@Override
    public void create() {
        if (!environment.isProd()) {
            config.serverConfigs().forEach((key, serverConfig) -> {
                String evolutionScript = generateEvolutionScript(servers.get(key));
                if (evolutionScript != null) {
                    File evolutions = environment.getFile("conf/evolutions/" + key + "/1.sql");
                    try {
                        String content = "";
                        if (evolutions.exists()) {
                            content = new String(Files.readAllBytes(evolutions.toPath()), "utf-8");
                        }

                        if (content.isEmpty() || content.startsWith("# --- Created by Ebean DDL")) {
                            environment.getFile("conf/evolutions/" + key).mkdirs();
                            if (!content.equals(evolutionScript)) {
                                Files.write(evolutions.toPath(), evolutionScript.getBytes("utf-8"));
                            }
                        }
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }
                }
            });
        }
    }
1221942
def _run_evolve(ssm_file, cnv_file, work_dir, data):
    
    exe = os.path.join(os.path.dirname(sys.executable), "evolve.py")
    assert os.path.exists(exe), "Could not find evolve script for PhyloWGS runs."
    out_dir = os.path.join(work_dir, "evolve")
    out_file = os.path.join(out_dir, "top_k_trees")
    if not utils.file_uptodate(out_file, cnv_file):
        with file_transaction(data, out_dir) as tx_out_dir:
            with utils.chdir(tx_out_dir):
                cmd = [sys.executable, exe, "-r", "42", ssm_file, cnv_file]
                do.run(cmd, "Run PhyloWGS evolution")
    return out_file
1351682
def smeft_evolve(C_in, scale_in, scale_out, newphys=True, **kwargs):
    """"""
    sol = _smeft_evolve(C_in, scale_in, scale_out, newphys=newphys, **kwargs)
    return C_array2dict(sol.y[:, -1].view(complex))
1258052
public function generateMigration()
    {
        if (!$this->confirm('Do you want to create a migration?')) {
            return;
        }

        $this->console->call('generate:migration', [
            'name' => "create_{$this->getEntities()}_table",
            '--fields' => $this->console->option('fields'),
            '--force' => $this->console->option('force'),
        ]);
    }
524575
def optimize(population, toolbox, ngen, archive=None, stats=None, verbose=False, history=None):
    
    start = time.time()
    if history is not None:
        history.update(population)
    logbook = tools.Logbook()
    logbook.header = ['gen', 'nevals', 'cpu_time'] + (stats.fields if stats else [])
    render_fitness(population, toolbox, history)
    record_information(population, stats, start, archive, logbook, verbose)
    for gen in range(1, ngen + 1):
        offspring = generate_next_population(population, toolbox)
        render_fitness(offspring, toolbox, history)
        population = offspring
        record_information(population, stats, start, archive, logbook, verbose)
    return population, logbook, history
1138786
def mutate(self, mutation, timeout=None, metadata=None, credentials=None):
        """"""
        return self.stub.Mutate(mutation, timeout=timeout, metadata=metadata,
                                credentials=credentials)
883531
def generate(self, step, params):
        """"""
        # Recurse into a DictFactory: allows users to have some params depending
        # on others.
        params = step.recurse(base.DictFactory, params, force_sequence=step.sequence)
        filename, content = self._make_content(params)
        return django_files.File(content.file, filename)
124024
def _generate_constructor(cls, names):
        """"""

        cache = cls._constructors
        if names in cache:
            return cache[names]
        elif len(cache) > 3:
            cache.clear()

        func = generate_constructor(cls, names)
        cache[names] = func
        return func
666384
def __generate(self):
        """"""
        base = []
        texted = []
        for pat in ALL_PATTERNS:
            data = pat.copy()
            data['pattern'] = data['pattern']
            data['right'] = True
            data['basekey'] = data['key']
            base.append(data)

            data = pat.copy()
            data['basekey'] = data['key']
            data['key'] += ':time_1'
            data['right'] = True
            data['pattern'] = data['pattern'] + Optional(Literal(",")).suppress() + BASE_TIME_PATTERNS['pat:time:minutes']
            data['time_format'] = '%H:%M'
            data['length'] = {'min' : data['length']['min'] + 5, 'max' : data['length']['max'] + 8}
            base.append(data)

            data = pat.copy()
            data['basekey'] = data['key']
            data['right'] = True
            data['key'] += ':time_2'
            data['pattern'] = data['pattern'] + Optional(oneOf([',', '|'])).suppress() + BASE_TIME_PATTERNS['pat:time:full']
            data['time_format'] = '%H:%M:%S'
            data['length'] = {'min' : data['length']['min'] + 9, 'max' : data['length']['max'] + 9}
            base.append(data)

        for pat in base:
            # Right
            data = pat.copy()
            data['key'] += ':t_right'
            data['pattern'] = lineStart + data['pattern'] +  Optional(oneOf([',', '|', ':', ')'])).suppress() + restOfLine.suppress()
            data['length'] = {'min' : data['length']['min'] + 1, 'max' : data['length']['max'] + 90}
            texted.append(data)

        base.extend(texted)
        self.patterns = base
1027887
private void tinyGPEvolve()
   {
      int iPopSize = this.manager.getPopulationSize();

      double sum_rate = manager.getCrossoverRate()+manager.getMacroMutationRate()+manager.getMicroMutationRate()+manager.getReproductionRate();
      double crossover_disk = manager.getCrossoverRate() / sum_rate;
      double micro_mutation_disk = (manager.getCrossoverRate() + manager.getMicroMutationRate()) / sum_rate;
      double macro_mutation_disk = (manager.getCrossoverRate() + manager.getMicroMutationRate() + manager.getMacroMutationRate()) / sum_rate;

      RandEngine randEngine = manager.getRandEngine();

      bestSolutionInCurrentGeneration = globalBestSolution.orElse(null);
      for (int offspring_index = 0; offspring_index < iPopSize; offspring_index += 1)
      {
         double r = randEngine.uniform();
         List<Solution> children = new ArrayList<>();

         List<Solution> bad_parents = new ArrayList<>();

         TournamentSelectionResult<Solution> tournament = TournamentSelection.select(solutions, randEngine);
         TupleTwo<Solution, Solution> tournament_winners = tournament.getWinners();
         TupleTwo<Solution, Solution> tournament_losers = tournament.getLosers();

         bad_parents.add(tournament_losers._1());
         bad_parents.add(tournament_losers._2());

         if (r <= crossover_disk) // do crossover
         {
            Solution child1 = tournament_winners._1().makeCopy();
            Solution child2 = tournament_winners._2().makeCopy();

            Crossover.apply(child1, child2, manager);

            children.add(child1);
            children.add(child2);
         }
         else if (r <= micro_mutation_disk) // do point mutation
         {
            Solution child = tournament_winners._1().makeCopy();
            MicroMutation.apply(child, manager);
            children.add(child);
         }
         else if (r <= macro_mutation_disk) // do subtree mutation
         {
            Solution child = tournament_winners._1().makeCopy();
            MacroMutation.apply(child, manager);
            children.add(child);
         }
         else // do reproduction
         {
            Solution child = tournament_winners._1().makeCopy();
            children.add(child);
         }


         boolean successfully_replaced = false;
         for(int i=0; i < children.size(); ++i)
         {
            Solution child = children.get(i);

            evaluate(child);

            if (bestSolutionInCurrentGeneration == null || child.isBetterThan(bestSolutionInCurrentGeneration))
            {
               bestSolutionInCurrentGeneration = child;
            }

            for (Solution bad_parent : bad_parents)
            {
               if (child.isBetterThan(bad_parent))
               {
                  successfully_replaced = true;
                  solutions.set(solutions.indexOf(bad_parent), child);
                  break;
               }
            }

            if (successfully_replaced)
            {
               break;
            }
         }

      }

      updateGlobal(bestSolutionInCurrentGeneration);
   }
979652
def Start(self):
    """"""
    with data_store.DB.GetMutationPool() as mutation_pool:
      self.CreateCollections(mutation_pool)

    if not self.runner_args.description:
      self.SetDescription()
341730
def generate
      generators.each do |generator|
        start = Time.now
        generator.generate(self)
        Bunto.logger.debug "Generating:",
          "#{generator.class} finished in #{Time.now - start} seconds."
      end
    end
111278
def gen_modules(self, initial_load=False):
        '''
        
        '''
        self.opts['pillar'] = salt.pillar.get_pillar(
            self.opts,
            self.opts['grains'],
            self.opts['id'],
            self.opts['saltenv'],
            pillarenv=self.opts.get('pillarenv'),
        ).compile_pillar()

        self.utils = salt.loader.utils(self.opts)
        self.functions = salt.loader.minion_mods(self.opts, utils=self.utils)
        self.serializers = salt.loader.serializers(self.opts)
        self.returners = salt.loader.returners(self.opts, self.functions)
        self.proxy = salt.loader.proxy(self.opts, self.functions, self.returners, None)
        # TODO: remove
        self.function_errors = {}  # Keep the funcs clean
        self.states = salt.loader.states(self.opts,
                self.functions,
                self.utils,
                self.serializers)
        self.rend = salt.loader.render(self.opts, self.functions)
#        self.matcher = Matcher(self.opts, self.functions)
        self.matchers = salt.loader.matchers(self.opts)
        self.functions['sys.reload_modules'] = self.gen_modules
        self.executors = salt.loader.executors(self.opts)
1353280
def generate(self):
        """"""

        ts=self.generate_tobs()
        noise=self.generate_noise(ts)
        
        rvs=[]
        for t,n in zip(ts, noise):
            rvs.append(n + np.sum(rv.rv_model(t, self.params), axis=0))

        return ts,rvs
104839
def generate(self):
        

        result = self._gen(self.optimized, self.splitstring)
        if self.splitstring and result is not None:
            result = result[1:]
        return result
274889
private EvolutionResult<BitGene, Double> run(
		final EvolutionResult<BitGene, Double> last,
		final AtomicBoolean proceed
	) {
		System.out.println("Starting evolution with existing result.");

		return (last != null ? ENGINE.stream(last) : ENGINE.stream())
			.limit(r -> proceed.get())
			.collect(EvolutionResult.toBestEvolutionResult());
	}
860543
def _parallel_evolve(n_programs, parents, X, y, sample_weight, seeds, params):
    """"""
    n_samples, n_features = X.shape
    # Unpack parameters
    tournament_size = params['tournament_size']
    function_set = params['function_set']
    arities = params['arities']
    init_depth = params['init_depth']
    init_method = params['init_method']
    const_range = params['const_range']
    metric = params['_metric']
    transformer = params['_transformer']
    parsimony_coefficient = params['parsimony_coefficient']
    method_probs = params['method_probs']
    p_point_replace = params['p_point_replace']
    max_samples = params['max_samples']
    feature_names = params['feature_names']

    max_samples = int(max_samples * n_samples)

    def _tournament():
        """Find the fittest individual from a sub-population."""
        contenders = random_state.randint(0, len(parents), tournament_size)
        fitness = [parents[p].fitness_ for p in contenders]
        if metric.greater_is_better:
            parent_index = contenders[np.argmax(fitness)]
        else:
            parent_index = contenders[np.argmin(fitness)]
        return parents[parent_index], parent_index

    # Build programs
    programs = []

    for i in range(n_programs):

        random_state = check_random_state(seeds[i])

        if parents is None:
            program = None
            genome = None
        else:
            method = random_state.uniform()
            parent, parent_index = _tournament()

            if method < method_probs[0]:
                # crossover
                donor, donor_index = _tournament()
                program, removed, remains = parent.crossover(donor.program,
                                                             random_state)
                genome = {'method': 'Crossover',
                          'parent_idx': parent_index,
                          'parent_nodes': removed,
                          'donor_idx': donor_index,
                          'donor_nodes': remains}
            elif method < method_probs[1]:
                # subtree_mutation
                program, removed, _ = parent.subtree_mutation(random_state)
                genome = {'method': 'Subtree Mutation',
                          'parent_idx': parent_index,
                          'parent_nodes': removed}
            elif method < method_probs[2]:
                # hoist_mutation
                program, removed = parent.hoist_mutation(random_state)
                genome = {'method': 'Hoist Mutation',
                          'parent_idx': parent_index,
                          'parent_nodes': removed}
            elif method < method_probs[3]:
                # point_mutation
                program, mutated = parent.point_mutation(random_state)
                genome = {'method': 'Point Mutation',
                          'parent_idx': parent_index,
                          'parent_nodes': mutated}
            else:
                # reproduction
                program = parent.reproduce()
                genome = {'method': 'Reproduction',
                          'parent_idx': parent_index,
                          'parent_nodes': []}

        program = _Program(function_set=function_set,
                           arities=arities,
                           init_depth=init_depth,
                           init_method=init_method,
                           n_features=n_features,
                           metric=metric,
                           transformer=transformer,
                           const_range=const_range,
                           p_point_replace=p_point_replace,
                           parsimony_coefficient=parsimony_coefficient,
                           feature_names=feature_names,
                           random_state=random_state,
                           program=program)

        program.parents = genome

        # Draw samples, using sample weights, and then fit
        if sample_weight is None:
            curr_sample_weight = np.ones((n_samples,))
        else:
            curr_sample_weight = sample_weight.copy()
        oob_sample_weight = curr_sample_weight.copy()

        indices, not_indices = program.get_all_indices(n_samples,
                                                       max_samples,
                                                       random_state)

        curr_sample_weight[not_indices] = 0
        oob_sample_weight[indices] = 0

        program.raw_fitness_ = program.raw_fitness(X, y, curr_sample_weight)
        if max_samples < n_samples:
            # Calculate OOB fitness
            program.oob_fitness_ = program.raw_fitness(X, y, oob_sample_weight)

        programs.append(program)

    return programs