int main(int argc, char **argv) { int termcode; mpp_problem *mpp; sym_environment *env = sym_open_environment(); sym_version(); CALL_FUNCTION( sym_get_user_data(env, (void **)&mpp) ); CALL_FUNCTION( sym_parse_command_line(env, argc, argv) ); if(mpp->par.test){ mpp_test(env); } else { CALL_FUNCTION( sym_load_problem(env) ); CALL_FUNCTION( sym_find_initial_bounds(env) ); CALL_FUNCTION( sym_solve(env) ); } CALL_FUNCTION( sym_close_environment(env) ); return(0); }
int main(int argc, char **argv) { #if USE_VRPH // A few things required by VRPH int i; double best_sol=VRP_INFINITY; int best_sol_buff[500]; #endif vrp_problem *vrp; sym_environment *env = sym_open_environment(); version(); sym_parse_command_line(env, argc, argv); sym_get_user_data(env, (void**)&vrp); #if USE_VRPH // Get the size of the problem in the input file int n=VRPGetDimension(vrp->par.infile); // Declare a VRP object of size n VRP V(n); // Declare a ClarkeWright object of size n ClarkeWright CW(n); // Populate the VRP object with the input file V.read_TSPLIB_file(vrp->par.infile); // Now create NUM_VRPH_SOLUTIONS solutions using VRPH and set the // upper bound to the best solution discovered for(i=0;i<NUM_VRPH_SOLUTIONS;i++) { // Create default routes - each customer on its own route V.create_default_routes(); // Create a new random feasible solution with Clarke Wright CW.Construct(&V, .5+ lcgrand(1),false); // Improve it with the RTR heuristic V.RTR_solve(ONE_POINT_MOVE+TWO_POINT_MOVE+TWO_OPT+THREE_OPT, 30,5,1,.01,25,VRPH_LI_PERTURB,VRPH_BEST_ACCEPT,false); if(V.get_total_route_length()-V.get_total_service_time()<best_sol) { best_sol=V.get_total_route_length()-V.get_total_service_time(); V.export_canonical_solution_buff(best_sol_buff); } // Reset VRPH's internal data structures V.reset(); } // Import the best solution and display it - if SYMPHONY claims an infeasibility // because the VRPH solution is optimal, we wouldn't see it otherwise! printf("VRPH set SYMPHONY upper bound to %f based on solution:\n",best_sol); V.import_solution_buff(best_sol_buff); V.summary(); // Set the upper bound using VRPH solution by accessing SYMPHONY's // internal data structures env->has_ub=1; env->ub=best_sol ; #if 0 // Note that this might be incorrect if the VRPH solution is not optimal // So the # of trucks still needs to be passed in on the command line! vrp->numroutes=V.get_total_number_of_routes(); #endif #endif // Now just let SYMPHONY do its thing. If an infeasibility is encountered, // then this certifies that the solution found by VRPH is indeed optimal // Note that the par.test will not work as we have processed only a single // file. Thus, we changed the following line // if (vrp->par.test){ if (0 && vrp->par.test){ vrp_test(env, argc, argv); } else { sym_load_problem(env); sym_find_initial_bounds(env); sym_set_str_param(env, "lp_executable_name", "vrp_lp_cg"); sym_set_str_param(env, "cp_executable_name", "vrp_cp"); sym_set_int_param(env, "generate_cgl_cuts", FALSE); sym_solve(env); } sym_close_environment(env); return(0); }