void Solution::print_file_format_students(const char* f_p) { FILE *file; /*File*/ /* Assignment calculated by the assignment maker */ //StopAssignment* assignment = assignments; /* Check that it was possible to make an assignment */ assert(assignments != NULL); /* Open the file to store the solution*/ file = fopen(f_p, "w"); /* Check if the file could be opened or not.*/ if (file == NULL) { printf(" ERROR! The file in which a solution is going to be stored" " could not be opened (Class Solution).\n"); return; } /* Print the total number of paths that need to be drawn*/ fprintf(file, "%d\n", instance->get_num_students()); /* Print the total distance*/ fprintf(file, "%lf\n", get_total_distance()); /* Print the total time*/ fprintf(file, "%lf\n", get_total_time()); /* Print paths of the students to the stops they are assigned to*/ assignments->print_file_format(file); fclose(file); }
void Solution::print_file_format_buses(const char* f_p) { FILE *file; /*File*/ /* Check that it was possible to make an assignment */ assert(is_assignment_feasible()); /* Open the file to store the solution*/ file = fopen(f_p, "w"); /* Check if the file could be opened or not.*/ if (file == NULL) { printf(" ERROR! The file in which a solution is going to be stored" "could not be opened (Class Solution).\n"); return; } /* Print the total number of paths that need to be drawn*/ fprintf(file, "%d\n", routes->get_num_routes()); /* Print the total distance*/ fprintf(file, "%lf\n", get_total_distance()); /* Print the total time*/ fprintf(file, "%lf\n", get_total_time()); /* Print the routes traversed by the buses*/ routes->print_file_format(file); fclose(file); }
float get_late_per_total(solution_t *soln) { float late, total; late = get_total_time(soln); total = get_total_lateness(soln); return late/total; }
void Set_routes::print() { /* Code to be executed only if the flag _DEBUG is set*/ #ifdef _DEBUG /* Check the integrity of the route (distance and travel time)*/ assert_routes_structure(); #endif printf(" - Total distance traversed: %.2lf\n", get_total_distance()); printf(" - Total time: %.2lf\n", get_total_time()); printf(" - Set of routes traversed by the buses: \n"); for (int i = 0; i < get_num_routes(); i++) { route[i]->print(); } }
void print_timer_output() { printf("Time without gc is %f seconds.\n", get_total_time()); }