PetscErrorCode OutputMonitor(TS ts,PetscInt it_number,PetscReal c_time,Vec U,void *mctx) { PetscErrorCode ierr; PetscFunctionBegin; ierr = WriteSolution(U,"./nsk%d.dat",it_number);CHKERRQ(ierr); PetscFunctionReturn(0); }
void CommonHeuristicProcess(Station** stations, Task** tasks, float timeBound, int (*selectionFunction)(Task**, int), int (*behindDueFunction)(Task**, float)) { Worker** workers = NULL; struct timeb beginning; struct timeb ending; int processTime; ftime(&beginning); workers = Heuristic(stations, tasks, timeBound, (*selectionFunction), (*behindDueFunction)); ftime(&ending); processTime = ending.millitm - beginning.millitm; WriteSolution(workers); printf("Processing Time: %dms\n", processTime); ClearWorkers(workers); }
void GAMachine::Update(float dt) { // Find best out of the maximum tries, then start over if (generations > NUM_MAX_GENERATIONS) { WriteSolution(); // Reset CreateStartPopulation(); Reset(); } liveCount = 0; for (int i = 0; i < POPULATION_SIZE; i++) { if (!Session->ships[i]->active) continue; parent->UpdatePerceptions(dt, i); ApplyBehaviorRule(i); UpdateFitness(i); } if (!liveCount) SetupNextGeneration(); }