void AssignmentManager::endRun(){
	if(runBestLogProb >= optimalLogMPEValue - EPS){
		numRunsWithOptimumFound++;
	}
	if( runBestLogProb < worstSolutionCostFound ) worstSolutionCostFound = runBestLogProb;
	avgSolutionCostFound += runBestLogProb;

	//=== Gather best solution.
	if(runBestLogProb > overallBestLogProb - EPS){  
		if(runBestLogProb > overallBestLogProb + EPS){  // new better.
			overallBestLogProb = runBestLogProb;
			bestTime = runBestTime;
			bestRun = numRun;
			if(M_MPE){ // for M-MPE, the best assignment is not necessarily the first one in the array.
				double bestLogProb = -DOUBLE_BIG;
				int bestIndex = -1;
				for(int i=0; i<M; i++){
					if(runBestLogProbs[i] > bestLogProb){
						bestLogProb = runBestLogProbs[i];
						bestIndex = i;
					}
				}
				assert(bestIndex > -1);	
				copy_from_to(runBestAssignments[bestIndex], globalBestAssignments[0], numVars);
			} else {
				copy_from_to(runBestAssignments[0], globalBestAssignments[0], numVars);
			}
		}
	}
}
Exemple #2
0
WEAK buffer_t copy_of_buffer(void *user_context, const buffer_t &buf) {
    buffer_t result = buf;
    size_t buffer_size = full_extent(result);
    // TODO: ERROR RETURN
    result.host = (uint8_t *)halide_malloc(user_context, buffer_size * result.elem_size);
    copy_from_to(user_context, buf, result);
    return result;
}