int hypercache::NEQUI;
int hypercache::NSKIP;
int hypercache::nequileft;
+pair<int, char*> hypercache::mostEquilibratedConfig;
void hypercache::initCache(configcache **cache,
const string& cacheid, const int& nequi, const int& nskip, const string& datadir,
(*osit)->setPara(parid, val);
nequileft = NEQUI;
+ mostEquilibratedConfig.first = NEQUI;
}
void hypercache::finalize() {
C->readConfig(readnewconfig_nonex, nequileftReadConfig_nonex, &parentConfigs);
if (readnewconfig_nonex) {
- cout << ":" << nequileftReadConfig_nonex << endl;
nequileft = nequileftReadConfig_nonex;
readAtLeastOneConfig = true;
}
- if ( nequileft < 0 )
+ if ( nequileft < 0 && readnewconfig_nonex )
activeCFile = fileOfPath(C->getInFileName());
else
activeCFile = "";
free(tmpconfig);
}
+ /* storing most equilibrated config */
+ if ( nequileft < mostEquilibratedConfig.first && readAtLeastOneConfig ) {
+ *log << "HYPERCACHE: Storing a copy of so far most equilibrated config with nequileft = " << nequileft << endl << flush;
+ mostEquilibratedConfig.first = nequileft;
+ memcpy(mostEquilibratedConfig.second, C->getConfigMem(), C->getConfigSize());
+ }
+
+
+ /* injecting back most equilibrated config if nothing could be used anymore */
+ if ( nequileft > 0 && mostEquilibratedConfig.first < nequileft ) {
+ *log << "HYPERCACHE: Injecting back most equilibrated stored config with nequileft = " << mostEquilibratedConfig.first << endl << flush;
+ nequileft = mostEquilibratedConfig.first;
+ memcpy(C->getConfigMem(), mostEquilibratedConfig.second, C->getConfigSize());
+ readAtLeastOneConfig = false;
+ }
+
return readAtLeastOneConfig;
}