--------------------------------------------------------- */ --------------------------------------------------------- */
| 1006 | /* --------------------------------------------------------- */ |
| 1007 | /* --------------------------------------------------------- */ |
| 1008 | void 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 | /* --------------------------------------------------------- */ |
| 1034 | void cmaes_WriteToFilePtr(cmaes_t *t, const char *key, FILE *fp) { |
no test coverage detected