32 if (!solver->mpi_partition->get_proc0_world())
return;
35 output_file.open(solver->output_filename.c_str());
36 if (!output_file.is_open()) {
37 std::cerr <<
"output file: " << solver->output_filename << std::endl;
38 throw std::runtime_error(
"Error! Unable to open output file.");
41 output_file <<
"Recorder type:" << std::endl <<
"standard" << std::endl <<
"N_parameters:" << std::endl << solver->N_parameters << std::endl <<
"function_evaluation,seconds";
42 for (
int j=0; j<solver->N_parameters; j++) {
43 output_file <<
",x(" << j+1 <<
")";
45 output_file <<
",objective_function" << std::endl;
49 void mango::Recorder_standard::write_file_line(
int function_evaluations, clock_t print_time,
const double* x,
double f) {
58 double elapsed_time = ((float)(print_time - solver->start_time)) / CLOCKS_PER_SEC;
59 output_file << std::setw(6) << std::right << function_evaluations <<
"," << std::setw(12) << std::setprecision(4) << std::scientific << elapsed_time;
60 for (
int j=0; j<solver->N_parameters; j++) {
61 output_file <<
"," << std::setw(24) << std::setprecision(16) << std::scientific << x[j];
63 output_file <<
"," << std::setw(24) << f << std::endl << std::flush;
68 if (!solver->mpi_partition->get_proc0_world())
return;
69 write_file_line(function_evaluations, print_time, x, f);
76 if (!solver->mpi_partition->get_proc0_world())
return;
78 write_file_line(solver->best_function_evaluation, solver->best_time, solver->state_vector, solver->best_objective_function);