int main (int ac, char **av) { int rval; CCutil_timer z; CCutil_init_timer (&z, "Verification"); CCutil_start_timer (&z); rval = parseargs (ac, av); if (rval) return -1; if (textin) { rval = verify_text_pool (cutname, in_ncount); if (rval) { fprintf (stderr, "verify_text_pool failed\n"); goto CLEANUP; } } else if (probin) { rval = verify_problem (cutname, run_silently); if (rval) { fprintf (stderr, "verify_problem failed\n"); goto CLEANUP; } } else if (poolin) { rval = verify_binary_pool (cutname); if (rval) { fprintf (stderr, "verify_binary_pool failed\n"); goto CLEANUP; } } CLEANUP: printf ("Verification completed (%s) in %.2f seconds\n", rval ? "unsuccessful" : "successful", CCutil_stop_timer (&z, 0)); fflush (stdout); return rval; }
int main(int ac, char **av) { int val = 0; int i; wctproblem problem; wctproblem_init(&problem); CCcheck_val(val, "Failed in wctproblem_init"); wctparms *parms = &(problem.parms); wctdata *pd = &(problem.root_pd); val = program_header(ac, av); CCcheck_val(val, "Failed in programheader"); CCutil_start_timer(&(problem.tot_cputime)); double start_time = CCutil_zeit(); wctdata_init(pd); pd->id = 0; problem.nwctdata = 1; val = parseargs(ac, av, parms); problem.real_time = getRealTime(); if (val) { goto CLEAN; } get_problem_name(pd->pname, parms->jobfile); if (dbg_lvl() > 1) { printf("Debugging turned on\n"); } fflush(stdout); /** Reading and preprocessing the data */ val = read_problem(parms->jobfile, &(pd->njobs), &(problem.duration), &(problem.weight)); pd->nmachines = parms->nmachines; CCcheck_val(val, "read_adjlist failed"); pd->orig_node_ids = (int *)CC_SAFE_MALLOC(pd->njobs, int); CCcheck_NULL_2(pd->orig_node_ids, "No memory to allocated orig_node_ids\n"); for (i = 0; i < pd->njobs; i++) { pd->orig_node_ids[i] = i; } Preprocessdata(&problem, pd); printf("Reading and preprocessing of the data took %f seconds\n", CCutil_zeit() - start_time); /** Computing initial lowerbound */ CCutil_start_timer(&(problem.tot_lb)); problem.global_lower_bound = lowerbound_eei(pd->jobarray, pd->njobs, pd->nmachines); problem.global_lower_bound = CC_MAX(problem.global_lower_bound, lowerbound_cp(pd->jobarray, pd->njobs, pd->nmachines)); problem.global_lower_bound = CC_MAX(problem.global_lower_bound, lowerbound_cw(pd->jobarray, pd->njobs, pd->nmachines)); CCutil_stop_timer(&(problem.tot_lb), 0); printf("Computing lowerbound EEI, CP and CW took %f seconds\n", problem.tot_lb.cum_zeit); /** Construction Pricersolver at the root node */ CCutil_start_resume_time(&(problem.tot_build_dd)); pd->solver = newSolver(pd->duration, pd->weights, pd->releasetime, pd->duetime, pd->njobs, pd->H_min, pd->H_max); CCutil_suspend_timer(&(problem.tot_build_dd)); /** Construct Feasible solutions */ if (parms->nb_feas_sol > 0) { construct_feasible_solutions(&problem); } /** Compute Schedule with Branch and Price */ compute_schedule(&problem); problem.real_time = getRealTime() - problem.real_time; CCutil_stop_timer(&(problem.tot_cputime), 0); /** Print all the information to screen and csv */ if (problem.parms.print) { print_to_csv(&problem); } print_to_screen(&problem); CLEAN: wctproblem_free(&problem); return val; }
int construct_feasible_solutions(wctproblem *problem) { int val = 0; int iterations = 0; wctdata *pd = &(problem->root_pd); wctparms *parms = &(problem->parms) ; SS *scatter_search = &(problem->scatter_search); CCutil_timer *timer = &(problem->tot_scatter_search); GRand *rand1 = g_rand_new_with_seed(1984); GRand *rand2 = g_rand_new_with_seed(1654651); CCutil_start_timer(timer); val = SSproblem_definition(scatter_search, 10, 8, parms->scatter_search_cpu_limit, parms->combine_method, pd->njobs, pd->nmachines, pd->jobarray, problem->global_lower_bound); CCcheck_val_2(val, "Failed in SSproblem_definition"); while (scatter_search->p->PSize < parms->nb_feas_sol) { iterations++; solution *new_sol = (solution *) NULL; new_sol = new_sol_init(pd->nmachines, pd->njobs); CCcheck_NULL(new_sol, "Failed to allocate") if (problem->status == no_sol) { construct_wspt(pd->jobarray, pd->njobs, pd->nmachines, new_sol); problem->status = feasible; } else { if (g_rand_boolean(rand1)) { random_assignment(pd->jobarray, pd->njobs, pd->nmachines, new_sol, rand2); } else { random_rcl_assignment(pd->jobarray, pd->njobs, pd->nmachines, new_sol, rand2); } } val = add_feasible_solution(problem, new_sol); CCcheck_val(val, "Failed in add_feasible_solution"); } CCutil_suspend_timer(timer); printf("We needed %f seconds to construct %d solutions in %d iterations\n", timer->cum_zeit, parms->nb_feas_sol, iterations); printf("upperbound = %d, lowerbound = %d\n", problem->global_upper_bound, problem->global_lower_bound); CCutil_resume_timer(timer); if (parms->scatter_search) { SSCreate_refset(scatter_search); scatter_search->upperbound = problem->global_upper_bound; if (parms->combine_method) { SSrun_scatter_search(scatter_search, &(problem->tot_scatter_search)); } else { SSrun_scatter_searchPR(scatter_search, & (problem->tot_scatter_search)); } for (unsigned i = 0; i < scatter_search->rs->list1->len ; i++) { solution *new_sol = (solution *)g_ptr_array_index(scatter_search->rs->list1 , i); partlist_to_Scheduleset(new_sol->part, pd->nmachines, pd->njobs, &(pd->newsets), &(pd->nnewsets)); add_newsets(pd); } } CLEAN: g_rand_free(rand1); g_rand_free(rand2); CCutil_stop_timer(&(problem->tot_scatter_search), 0); return val; }