示例#1
0
void ComputeFit(const char *callerName, omxMatrix *fitMat, int want, FitContext *fc)
{
	bool doFit = want & FF_COMPUTE_FIT;
	fc->incrComputeCount();
	omxFitFunction *ff = fitMat->fitFunction;
	if (ff) {
		omxFitFunctionComputeAuto(ff, want, fc);
	} else {
		if (want != FF_COMPUTE_FIT) Rf_error("Only fit is available");
		if (fc->ciobj) Rf_error("CIs cannot be computed for unitless algebra");
		omxRecompute(fitMat, fc);
	}
	if (doFit) {
		fc->fit = totalLogLikelihood(fitMat);
		if (std::isfinite(fc->fit)) {
			fc->resetIterationError();
		}
		Global->checkpointPostfit(callerName, fc, fc->est, false);
		if (OMX_DEBUG) {
			mxLog("%s: completed evaluation, fit=%.12g", fitMat->name(), fc->fit);
		}
	}
}
示例#2
0
void ComputeFit(const char *callerName, omxMatrix *fitMat, int want, FitContext *fc)
{
	bool doFit = want & FF_COMPUTE_FIT;
	R_CheckUserInterrupt();

#pragma omp atomic
	++Global->computeCount; // could avoid lock by keeping in FitContext

	// old version of openmp can't do this as part of the atomic instruction
	int evaluation = Global->computeCount;

	if (doFit) {
		if (OMX_DEBUG) {
			mxLog("%s: starting evaluation %d, want %d", fitMat->name(), evaluation, want);
		}
		Global->checkpointPrefit(callerName, fc, fc->est, false);
	}
	omxFitFunction *ff = fitMat->fitFunction;
	if (ff) {
		omxFitFunctionComputeAuto(ff, want, fc);
	} else {
		if (want != FF_COMPUTE_FIT) Rf_error("Only fit is available");
		if (fc->CI) Rf_error("CIs cannot be computed for unitless algebra");
		omxRecompute(fitMat, fc);
	}
	if (doFit) {
		fc->fit = totalLogLikelihood(fitMat);
		if (std::isfinite(fc->fit)) {
			fc->resetIterationError();
		}
		Global->checkpointPostfit(fc);
		if (OMX_DEBUG) {
			mxLog("%s: completed evaluation %d, fit=%f", fitMat->name(), evaluation, fc->fit);
		}
	}
}
示例#3
0
void omxFitFunctionPreoptimize(omxFitFunction *off, FitContext *fc)
{
	omxFitFunctionComputeAuto(off, FF_COMPUTE_PREOPTIMIZE, fc);
	fc->fitUnits = off->units;
}