Esempio n. 1
0
void AssignmentManager::outputRunLMs(FILE* outfile){
	fprintf(outfile, "\nOptimal MPE found: %s\n\n", foundOptimalThisRun() ? "yes" : "no"); 
	if(M_MPE){
		int i;
		/* build heap for sorting solutions in output. */
		int* order = new int[M];
		
		struct fheap* tmp;
		tmp = fh_alloc(M);
		for(i=0; i<fh_BestMLogProbs->n; i++){
			fh_insert(tmp, i+1, -runBestLogProbs[i]);
		}

		for(i=0; i<fh_BestMLogProbs->n; i++){
			order[i] = fh_delete_min(tmp)-1;
		}
	//	fh_free(tmp); crashes !!

		fprintf(outfile, "  Best M Scores:\n");
		for(i=0; i<fh_BestMLogProbs->n; i++){
			fprintf(outfile, "%.6lf ", runBestLogProbs[order[i]]);
		}
		fprintf(outfile, "\n");
		delete[] order;
	} else {
		if(outputBestMPE) outputAssignment(outfile, runBestAssignments[0]);
			if(fabs(get_log_score(runBestAssignments[0]) - runBestLogProb) > EPS){
			fprintf(outfile, "Log probability %lf of best run assignment does not match %lf\n", get_log_score(runBestAssignments[0]), runBestLogProb);
			fprintf(stderr, "Log probability %lf of best run assignment does not match %lf\n", get_log_score(runBestAssignments[0]), runBestLogProb);
			assert(false);
		}
	}
}
Esempio n. 2
0
void *_fh_alloc(long n) {
    return fh_alloc(n);
}