Beispiel #1
0
bool Solution::is_assignment_feasible() {
	StopAssignment* assignments = get_assignments();

	if (assignments == NULL) {
		return false;
	} else {
		return true;
	}
}
ErrorStack TpccLoadTask::load_customers() {
  if (!load_customers_secondary) {
    return kRetOk;
  }
  uint32_t from_wid, to_wid;
  get_assignments(kWarehouses, &from_wid, &to_wid);
  for (Wid wid = from_wid; wid < to_wid; ++wid) {
    for (Did did = 0; did < kDistricts; ++did) {
      CHECK_ERROR(load_customers_in_district(wid, did));
    }
  }
  return kRetOk;
}
Beispiel #3
0
void Solution::print() {
	/* Assignment calculated by the assignment maker */
	StopAssignment* assignment;

	printf(" Information about the solution: \n");
	routes->print();

	if (is_assignment_feasible()) {
		assignment = get_assignments();
		assignment->print();
	} else {
		printf("WARNING!!! Infeasible solution! There is no feasible assignment of students to stops. \n");
	}
}
Beispiel #4
0
void Solution::print_file_format(const char* f_p) {
	FILE *file; /*File*/
	/* Assignment calculated by the assignment maker */
	StopAssignment* assignment;

	/* Check that it was possible to make an assignment */
	assert(is_assignment_feasible());

	/* Get the assignment*/
	assignment = get_assignments();

	/* 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() + 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*/
	assignment->print_file_format(file);

	/* Print the routes traversed by the buses*/
	routes->print_file_format(file);

	fclose(file);
}