Example #1
0
/**
 * \copydoc Simulation::needsChanged()
 */
void StatisticsSimulation::needsChanged() {
	set<ResultType>::iterator it = find(lNeeds.begin(), lNeeds.end(),
			PERIOD_SCORES);
	lpModel->needScores(it != lNeeds.end());
	if (lpModel->needScores()) {
		LOGS(Priority::DEBUG)<<"simulation collects scores";
		// Create stores only the first time.
		if (lScores.empty()) {
			setupMaps(lScores, lScoresData, lNThreads, nPeriods(), nParameters());
		}
	}
}
Example #2
0
/**
 * Constructs the StatisticsSimulation object.
 *
 * @param pModel Pointer to the Model.
 * @param pData Pointer to the Data.
 * @param nThreads Number of threads used to perform parallel simulations.
 */
StatisticsSimulation::StatisticsSimulation(Model* pModel, Data* pData,
		const unsigned int nThreads) :
		Simulation(pModel, pData), //
		lNThreads(nThreads), //
		lEpochSimulations(), //
		lSeeds(pData->observationCount() - 1, vector<int>()), //
		lTargets(calculateTargetStatistics().colwise().sum()), //
		lPeriodWiseTargets(calculateTargetStatistics()), //
		lStatistic(), //
		lStatisticsData(), //
		lStatistics(), //
		lScoresData(), //
		lScores(), //
		lTimesData(), //
		lTimes(), //
		lMeanStatisticsMinusTargets(nStatistics()), //
		lResult(&lTheta, &lTargets, &lPeriodWiseTargets, &lStatistic, &lStatistics,
				&lMeanStatisticsMinusTargets, &lSeeds, &lScores, 0/*ptr*/, &lTimes) {
	assert(lNThreads > 0);
	resizeEpochSimulations(lNThreads);
	// Setup the mapped matrices for statistics and time. Statistics is always
	// needed.
	LOG(Priority::DEBUG, "setup mapped statistics vector");
	setupMaps(lStatistics, lStatisticsData, lNThreads, nPeriods(),
			nStatistics());
	// Conditional is not changed during phases, so no later change required.
	if (lpModel->conditional()) {
		LOG(Priority::DEBUG, "setup mapped times vector");
		setupMaps(lTimes, lTimesData, lNThreads, nPeriods(), 1);
	}
	// Score might not be needed if they are needsChanged, creates the stores.
	int n = lpModel->needScores() ? lNThreads : 0;
	setupMaps(lScores, lScoresData, n, nPeriods(), nParameters());

	static MeanStatisticsCalculator s;
	addResultModificator(&s);
}
SimpleParser::SimpleParser(void){
    setupMaps();
}