当前位置: 首页>>代码示例>>C++>>正文


C++ Population::SetParameters方法代码示例

本文整理汇总了C++中Population::SetParameters方法的典型用法代码示例。如果您正苦于以下问题:C++ Population::SetParameters方法的具体用法?C++ Population::SetParameters怎么用?C++ Population::SetParameters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Population的用法示例。


在下文中一共展示了Population::SetParameters方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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;
			}
//.........这里部分代码省略.........
开发者ID:spflanagan,项目名称:gwsca_simulation_model,代码行数:101,代码来源:life_cycle.cpp


注:本文中的Population::SetParameters方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。