int Database::save_all_objs() { int ret = 0; ObjMap::iterator it = global->obj_mgr->pool.begin(); for (; it != global->obj_mgr->pool.end(); it++) { ret = save_obj(it->second); if (ret != 0){ ERR("save obj error, obj name: %s\n", wstring_to_string(it->second->name)); return ret; } } return ret; }
static void saveobjchn(struct memfile *mf, struct obj *otmp) { int count = 0; struct obj *otmp2; mfmagic_set(mf, OBJCHAIN_MAGIC); for (otmp2 = otmp; otmp2; otmp2 = otmp2->nobj) count++; mwrite32(mf, count); while (otmp) { save_obj(mf, otmp); if (Has_contents(otmp)) saveobjchn(mf, otmp->cobj); otmp = otmp->nobj; } }
void run(char* func_name, int iRun) { iter=0; iter_each=0; cnArch=0; char objsal[256]; char varsal[256]; char timesal[256]; strcpy(testInstance,func_name); double start_time,end_time; double duration; sprintf(objsal,"results/FUN_%s_%d_%d",testInstance,nDim,iRun); sprintf(varsal,"results/VAR_%s_%d_%d",testInstance,nDim,iRun); sprintf(timesal,"results/TIME_%s_%d",testInstance,nDim); if(mpi_rank==0) start_time=clock(); initializeProblem(); initializePopulation(); // showPopulation(); initializeIndex(); if(mpi_color) evaluatePopInitial(); MPI_Barrier(MPI_COMM_WORLD); if(master_flag) collection_initial(); if(!mpi_color&&mpi_rank_master==mpi_rank_master_archive) refineRepertory_generateArchive(); MPI_Barrier(MPI_COMM_WORLD); if(master_flag) SynchronizeArchive(); SynchronizeArchive_one(); // refineRepertory_generateArchive_SDE(); // showArchive(); // showLimits(); if(mpi_color) { update_xBest_initial(); update_xBest_archive(); } MPI_Barrier(MPI_COMM_WORLD); iter=nPop*nObj; // for(int i=0;i<mpi_size;i++) // { // if(i==0&&mpi_rank==0) // showArchive(); // if(i!=0&&mpi_rank==i) // { // showGlobalBest(); // showPopulation(); // } // MPI_Barrier(MPI_COMM_WORLD); // } while(iter<maxIteration) { iter_each=0; nRep=0; if(mpi_color) { update_objective(); permIndexes(); } else { update_archive(); perm_archIndex(); } MPI_Barrier(MPI_COMM_WORLD); // showGlobalBest(); if(master_flag) { collect2master_archive(); if(mpi_rank_master==mpi_rank_master_archive) refineRepertory_generateArchive(); SynchronizeArchive(); } SynchronizeArchive_one(); if(mpi_color) update_xBest_archive(); // showArchive(); MPI_Barrier(MPI_COMM_WORLD); update_iteration(); } if(mpi_rank==0) { end_time=clock(); duration=(end_time-start_time)/CLOCKS_PER_SEC; } if(mpi_rank==0) { fpttime=fopen(timesal,"a"); fprintf(fpttime, "%e\n", duration); get_nonDominateSize(); fptobj=fopen(objsal,"w"); save_obj(fptobj); fptvar=fopen(varsal,"w"); save_var(fptvar); fclose(fpttime); fclose(fptobj); fclose(fptvar); } }