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


C++ Array1D::display方法代码示例

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


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

示例1: printSimulationResultsForTed_pedigreeDepth

/*!
 * Print simulation results to standard output
 */
void printSimulationResultsForTed_pedigreeDepth(PedigreeDepthStorage *pdStorage, bool cellProductionConstraintsMet, bool fecundityScheduleConstraintsMet, bool allConstraintsMet, ProgramOptionParser *opt) {

	// print pedigree depth (i.e., value that Ted's optimizer is minimizing)
	float valueBeingOptimized = 0;
	string option_str(opt->fitnessMetric.c_str());
	if      (option_str.find("meanPedigreeDepthMeioticCells:")!=string::npos) {valueBeingOptimized = pdStorage->pd_AllCellsEnterMeioticRegion->mean();}
	else if (strcmp(option_str.c_str(),"spermOocyteMean")==0) {valueBeingOptimized = pdStorage->pd_spermOocyte->mean();}
	else if (strcmp(option_str.c_str(),"spermOocyteSum")==0) {valueBeingOptimized = pdStorage->pd_spermOocyteSum->mean();}
	else if (strcmp(option_str.c_str(),"generationRate")==0) {float r = calculateGenerationFitness(pdStorage->simulatedFecunditySchedule,pdStorage->fecundityConstraints,pdStorage->pd_spermOocyte->mean(),opt->deleteriousMutationRate,opt->maximalGenerationRate,opt->maximalPedigreeDepth);valueBeingOptimized = -r;}
        else if (strcmp(option_str.c_str(),"generationRate2")==0) {float r = calculateGenerationFitness_selectionCoefficient(pdStorage->simulatedFecunditySchedule,pdStorage->fecundityConstraints,pdStorage->pd_spermOocyte->mean(),opt->deleteriousMutationRate,opt->maximalGenerationRate,opt->maximalPedigreeDepth);valueBeingOptimized = -r;}

	else {std::cerr << "Invalid choice of fitnessScoringMethod" << endl;exit(1);}
	printf("%f\n",valueBeingOptimized);

	// print whether cell production constraints (cpc) met
	printf("%d\n", cellProductionConstraintsMet);

	// print whether fecundity constraints (fc) met
	printf("%d\n", fecundityScheduleConstraintsMet);

	// print whether all constraints met
	printf("%d\n", allConstraintsMet);

	// print pedigree depth of individual simulations runs
	if      (option_str.find("meanPedigreeDepthMeioticCells:")!=string::npos) {pdStorage->pd_AllCellsEnterMeioticRegion->display();}
	else if (strcmp(option_str.c_str(),"spermOocyteMean")==0) {pdStorage->pd_spermOocyte->display();}
	else if (strcmp(option_str.c_str(),"spermOocyteSum")==0) {pdStorage->pd_spermOocyteSum->display();}
	else if (strcmp(option_str.c_str(),"generationRate")==0) {
		Array1D<float> output;
		output.resize(pdStorage->pd_spermOocyte->size());
        float r = calculateGenerationFitness(pdStorage->simulatedFecunditySchedule,pdStorage->fecundityConstraints,pdStorage->pd_spermOocyte->mean(),opt->deleteriousMutationRate,opt->maximalGenerationRate,opt->maximalPedigreeDepth);
		for (int i=0;i<pdStorage->pd_spermOocyte->size();i++) {
			output(i) = -r;
		}
		output.display();
	}
        else if (strcmp(option_str.c_str(),"generationRate2")==0) {
                Array1D<float> output;
                output.resize(pdStorage->pd_spermOocyte->size());
        float r = calculateGenerationFitness_selectionCoefficient(pdStorage->simulatedFecunditySchedule,pdStorage->fecundityConstraints,pdStorage->pd_spermOocyte->mean(),opt->deleteriousMutationRate,opt->maximalGenerationRate,opt->maximalPedigreeDepth);
                for (int i=0;i<pdStorage->pd_spermOocyte->size();i++) {
                        output(i) = -r;
                }
                output.display();
        }

	else {std::cerr << "Invalid choice of fitnessScoringMethod" << endl;exit(1);}

	// print whether cell production constraint is met for individual simulation runs
	Array2D<float>::array_index dimx_cellProduction,dimy_cellProduction;
	pdStorage->simulatedCellProductionSchedule->getDimensions(dimx_cellProduction,dimy_cellProduction);
	for (int x=0;x<dimx_cellProduction;x++) {
		bool constraintsSatisfied=true;
		for (int y=0;y<dimy_cellProduction;y++) {
			if ((*pdStorage->simulatedCellProductionSchedule)(x,y)>(*pdStorage->cellProductionConstraints)(0,y)) {
				constraintsSatisfied=false;
				break;
			}
		}
		if (opt->constraintMethod.compare("none")==0){
			constraintsSatisfied=true;
		}
		printf("%d",constraintsSatisfied);
		if (x!=dimx_cellProduction-1) {
			printf(",");
		}
	}
	printf("\n");

	// print whether fecundity constraint is met for individual simulation runs
	Array2D<float>::array_index dimx_simulatedFecundity, dimy_simulatedFecundity;
	pdStorage->simulatedFecunditySchedule->getDimensions(dimx_simulatedFecundity,dimy_simulatedFecundity);
	for (Array2D<float>::array_index x=0;x<dimx_simulatedFecundity;x++) {
		bool constraintsSatisfied=true;
		int sum_sim = 0;
		int sum_sched = 0;
		for (int y=0;y<dimy_simulatedFecundity;y++) {
			if (y==0) {  			// check sperm constraint
				int numSperm_sim = boost::math::iround((*pdStorage->simulatedFecunditySchedule)(x,y));
				int numSperm_sched = opt->numSperm; // boost::math::iround((*pdStorage->fecundityConstraints)(0,y));
				if (numSperm_sim!=numSperm_sched) {
					constraintsSatisfied=false;
					break;
				}
			} else {				// check oocyte constraint
				sum_sim+=ceil((*pdStorage->simulatedFecunditySchedule)(x,y));
				sum_sched+=boost::math::iround((*pdStorage->fecundityConstraints)(y));
				if (sum_sim<sum_sched) {
					constraintsSatisfied=false;
					break;
				}
			}
		}
		if (opt->constraintMethod.compare("none")==0){
			constraintsSatisfied=true;
		}
		printf("%d",constraintsSatisfied);
//.........这里部分代码省略.........
开发者ID:mc-simworm,项目名称:simworm,代码行数:101,代码来源:util_germline.cpp

示例2: printSimulationResultsForTed_pedigreeDepth_badMR

/*!
 * Print simulation results to standard output when MR constraints are not satisfied.
 * These results fixed to very high pedigree depths / non-satisfied constraints
 */
void printSimulationResultsForTed_pedigreeDepth_badMR(PedigreeDepthStorage *pdStorage, ProgramOptionParser *opt) {

	// print pedigree depth (i.e., value that Ted's optimizer is minimizing)
	printf("999\n");

	// print whether cell production constraints (cpc) met
	printf("0\n");

	// print whether fecundity constraints (fc) met
	printf("0\n");

	// print whether all constraints met
	printf("0\n");

	// print pedigree depth of individual simulations runs
	Array1D<float> temp;
	Array1D<float>::array_index numRuns = pdStorage->pd_AllCellsEnterMeioticRegion->size();
	temp.resize(numRuns);
	temp.fill(999);
	temp.display();

	// print whether cell production constraint is met for individual simulation runs
	Array2D<float>::array_index dimx_cellProduction,dimy_cellProduction;
	pdStorage->simulatedCellProductionSchedule->getDimensions(dimx_cellProduction,dimy_cellProduction);
	for (int x=0;x<dimx_cellProduction;x++) {
		printf("0");
		if (x!=dimx_cellProduction-1) {
			printf(",");
		}
	}
	printf("\n");

	// print whether fecundity constraint is met for individual simulation runs
	Array2D<float>::array_index dimx_simulatedFecundity, dimy_simulatedFecundity;
	pdStorage->simulatedFecunditySchedule->getDimensions(dimx_simulatedFecundity,dimy_simulatedFecundity);
	for (Array2D<float>::array_index x=0;x<dimx_simulatedFecundity;x++) {
		printf("%d",false);
		if (x!=dimx_simulatedFecundity-1) {
			printf(",");
		}
	}
	printf("\n");

	// print cell production time constraints for individual runs
	for (int i=0;i<dimy_cellProduction;i++) {
		printf("%f",(*pdStorage->cellProductionConstraints)(0,i));
		if (i!=dimy_cellProduction-1) {
			printf(",");
		}
	}
	printf("\n");

	// print cell production times for individual runs
	for (int i=0;i<dimy_cellProduction;i++) {
		for (int j=0;j<dimx_cellProduction;j++) {
			printf("999");
			if (j!=dimx_cellProduction-1) {
				printf(",");
			}
		}
		printf("\n");
	}

	// print fecundity constraints for individual runs
	int sumConstraint=0;
	for (int i=0;i<dimy_simulatedFecundity;i++) {
		int constraint;
		if (i==0) {
			constraint = opt->numSperm;
		} else {
			constraint = boost::math::iround((*pdStorage->fecundityConstraints)(i));
		}
		sumConstraint+=constraint;
		printf("%d",sumConstraint);
		if (i!=dimy_simulatedFecundity-1) {
			printf(",");
		}
	}
	printf("\n");

	// print fecundity for individual runs
	Array1D<float> sumGamete;
	sumGamete.resize(dimx_cellProduction);
	for (int i=0;i<dimy_simulatedFecundity;i++) {
		for (int j=0;j<dimx_cellProduction;j++) {
			sumGamete(j)+=(*pdStorage->simulatedFecunditySchedule)(j,i);
			printf("%d",boost::math::iround(sumGamete(j)));
			if (j!=dimx_cellProduction-1) {
				printf(",");
			}
		}
		printf("\n");
	}
}
开发者ID:mc-simworm,项目名称:simworm,代码行数:98,代码来源:util_germline.cpp


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