MCPcopy Create free account
hub / github.com/FreeFem/FreeFem-sources / cmaes_WriteToFileAW

Function cmaes_WriteToFileAW

plugin/seq/cmaes.cpp:1008–1031  ·  view source on GitHub ↗

--------------------------------------------------------- */ --------------------------------------------------------- */

Source from the content-addressed store, hash-verified

1006/* --------------------------------------------------------- */
1007/* --------------------------------------------------------- */
1008void cmaes_WriteToFileAW(cmaes_t *t, const char *key, const char *name, const char *appendwrite) {
1009 const char *s = "tmpcmaes.dat";
1010 FILE *fp;
1011
1012 if (name == nullptr) {
1013 name = s;
1014 }
1015
1016 fp = fopen(name, appendwrite);
1017
1018 if (fp == nullptr) {
1019 ERRORMESSAGE("cmaes_WriteToFile(): could not open '", name, "' with flag ", appendwrite);
1020 return;
1021 }
1022
1023 if (appendwrite[0] == 'w') {
1024 /* write a header line, very rudimentary */
1025 fprintf(fp, "%% # %s (randomSeed=%d, %s)\n", key, t->sp.seed, getTimeStr( ));
1026 } else if (t->gen > 0 || strncmp(name, "outcmaesfit", 11) != 0) {
1027 cmaes_WriteToFilePtr(t, key, fp); /* do not write fitness for gen==0 */
1028 }
1029
1030 fclose(fp);
1031} /* WriteToFile */
1032
1033/* --------------------------------------------------------- */
1034void cmaes_WriteToFilePtr(cmaes_t *t, const char *key, FILE *fp) {

Callers 2

cmaes_WriteToFileFunction · 0.85
cmaes_ReadFromFilePtrFunction · 0.85

Calls 3

ERRORMESSAGEFunction · 0.85
getTimeStrFunction · 0.85
cmaes_WriteToFilePtrFunction · 0.85

Tested by

no test coverage detected