本文整理汇总了C++中Population::Mutation方法的典型用法代码示例。如果您正苦于以下问题:C++ Population::Mutation方法的具体用法?C++ Population::Mutation怎么用?C++ Population::Mutation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Population
的用法示例。
在下文中一共展示了Population::Mutation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: strlen
int main(int ac, char **av)
{
Population population;
char *target;
unsigned int epochs = 0;
if (ac == 6 && check_string(av[1]) && check_params(av))
{
target = av[1];
population.setSelectionRate(atof(av[3]));
population.setMutationRate(atof(av[4]));
population.setPoolSize(atoi(av[5]));
population.CreatePopulation(atoi(av[2]), strlen(target));
while (population.getBestFitness() < 100)
{
std::cout << "Epochs: " << epochs++ << std::endl;
population.Evaluate((Fitness)evaluate_sample, target);
population.Selection();
population.Crossover();
population.Mutation();
population.Evaluate((Fitness)evaluate_sample, target);
std::cout << population << std::endl;
}
}
else
std::cerr << "Usage: ./GeneticString \"[a-z](length > 2)\" pop_size(int) select_rate[0.0-1.0] mutation_rate[0.0-1.0] pool_size(int)" << std::endl;
return (0);
}
示例2: main
int main()
{
int NumReps = 1;//this is one parameter to mess with here
string basefilename = "null_1rep_440a_160j_6alleles";
int vs_initial = 500;
int vs_sampled = 500;
int ss_initial = 0;
int ss_sampled = 0;
int end, g, reps, ld_count;
vector <double> ci95_det, ci95_spu, ci99_det, ci99_spu;//for sexual selection
vector <double> vs_ci95_det, vs_ci95_spu, vs_ci99_det, vs_ci99_spu;//vs = viability selection
vector <double> bs95_det, bs95_spu, bs99_det, bs99_spu, fdr_spu, fdr_det;
double ci95d_SE, ci95s_SE, ci99d_SE, ci99s_SE;//standard errors of spurious and detected peaks
double ci95d_m, ci95s_m, ci99d_m, ci99s_m;//means of spurious and detected peaks
double bs95d_SE, bs95s_SE, bs99d_SE, bs99s_SE, fdr_SE, fdrs_SE;//standard errors of spurious and detected peaks
double bs95d_m, bs95s_m, bs99d_m, bs99s_m, fdr_m, fdrs_m;//means of spurious and detected peaks
int peak_n = 0, total_QTL, vs_peak_n = 0;
Population Pop;
ofstream summ;
ofstream Fsts;
ofstream plot_Fsts;
ofstream parameters;
ofstream QTLs;
ofstream peak_summ;
ofstream ld, sig_thresh;
string ldname = basefilename + "_LD.txt";
string QTLname = basefilename + "_QTLs.txt";
string parametername = basefilename + "_Parameters.txt";
string summfilename = basefilename + "_SummStats.txt";
string adultfilename = basefilename + "_AdultSummStats.txt";
string fstfilename = basefilename + "_Fsts.txt";
string fdrfilename = basefilename + "_plot_Fsts.txt";
string peaksummname = basefilename + "_peakSumm.txt";
string sig_threshold_name = basefilename + "_sig_thresholds.txt";
ld.open(ldname.c_str());
summ.open(summfilename.c_str());
Fsts.open(fstfilename.c_str());
plot_Fsts.open(fdrfilename.c_str());
parameters.open(parametername.c_str());
QTLs.open(QTLname.c_str());
sig_thresh.open(sig_threshold_name.c_str());
sig_thresh << "rep\tgen\tnum.fdr.real\tnum.fdr.spur\tnum.99.real\tnum.99.spur\tnum.95.real\tnum.95.spur\tnum.bs99.real\tnum.bs99.spur\tnum.bs95.real\tnum.bs95.spur";
summ << "rep\tgen\tTimepoint\twhich\tMeanLD\t" << "GenVar\t" << "PhenVar\t" << "Heritability\t" << "PopulationSize\t" << "NumMales\t"
<< "NumFem\t" << "SexRatio\t" << "Mean Trait Value\t" << "MaleTraitMean\t" << "FemTraitMean\t" << "Mating Diff\t"
<< "Male m'\t" << "Fem m'" << "\tbs99_real\tbs99_spurious\tci99_real\tci99spurious" << '\n';
parameters << "NumReps\tCarryingCapacity\tMaxFecundity\tMaxEncounters\tAdultSampleSize\tOffSampleSize\tNumGen\tNumSelGen\tNumLoci"
<< "\tNumChrom\tNumQTLs\tMaxNumAlleles\tRecombRate\tMutRate\tMutVar\tEnvVar\tSigma\tbs_reps\tNumforLD\n";
ci95s_m = ci95d_m = ci99d_m = ci99s_m = 0;
bs95d_m = bs95s_m = bs99d_m = bs99s_m = fdr_m = fdrs_m = 0;
bs95d_SE = bs95s_SE = bs99d_SE = bs99s_SE = fdr_SE = fdrs_SE = 0;
vector <double> new_within_chrom_dprime;
double mean_dp_ldistchrom = 0;
//vector <double> adams_avg_dprime;
ld_info returned_data;
for (reps = 0; reps < NumReps; reps++)
{
Pop.SetParameters();
Pop.Initialize(Pop.prior_qtl);
cout << "Started rep " << reps + 1 << '\n';
if (reps == 0)
{
ld << "rep\tgen\t" << "Avg_perchrom_ldDp\t" << "PairwiseD\t" << "Dprime\t"
<< "long_dist_d\t" << "long_distDprime";
total_QTL = Pop.NumQTLs*Pop.NumChrom;
QTLs << "reps";
for (int c = 0; c < Pop.NumChrom; c++)
{
new_within_chrom_dprime.push_back(0);
// adams_avg_dprime.push_back(0);
ld << "\tchrom_" << c << "_D" << "\tchrom_" << c << "_ldDp";
for (int cc = 0; cc < Pop.NumQTLs; cc++)
QTLs << '\t' << c << "." << cc;
}
QTLs << '\n';
ld << '\n';
parameters << NumReps << '\t' << Pop.CarryingCapacity << '\t' << Pop.MaximumFecundity << '\t' << Pop.MaximumEncounters << '\t'
<< Pop.pAdultSample << '\t' << Pop.ProgSample << '\t' << Pop.Generations << '\t' << Pop.NumSelGen << '\t' << Pop.NumMarkers << '\t'
<< Pop.NumChrom << '\t' << Pop.NumQTLs << '\t' << Pop.NumAlleles << '\t' << Pop.RecombRate << '\t' << Pop.MutationRate << '\t'
<< Pop.MutationalVariance << '\t' << Pop.EnvironmentalVariance << '\t' << Pop.sigma << '\t' << Pop.bs_replicates << '\t' << Pop.NumLD << '\n';
}
QTLs << reps;
for (int c = 0; c < Pop.NumChrom; c++)
{
for (int cc = 0; cc < Pop.NumQTLs; cc++)
QTLs << '\t' << Pop.Locations[c].LociOnChrom[cc];
}
QTLs << '\n';
for (g = 0; g < Pop.Generations; g++)
{
Pop.PopulationSize = Pop.DeterminePopSize();
Pop.Mating(ss_initial);//random mating if 0
if (Pop.popExtinct == true)
{
cout << "Extinct Generation " << g + 1 << '\n';
break;
}
//.........这里部分代码省略.........