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 main (int ac, char **av) { int rval = 0; double start_time = COLORcpu_time(); double tot_rtime; COLORproblem colorproblem; COLORparms* parms = &(colorproblem.parms); colordata* cd = &(colorproblem.root_cd); int ncolors; COLORset *colorclasses; COLORset* debugcolors = (COLORset*) NULL; rval = COLORprogram_header (ac,av); COLORcheck_rval(rval, "Failed in COLORprogram_header"); COLORproblem_init(&colorproblem); cd->id = 0; colorproblem.ncolordata = 1; rval = parseargs (ac, av,parms); if (rval) goto CLEANUP; cd->upper_bound = parms->initial_upper_bound; get_problem_name(cd->pname,parms->edgefile); printf ("Rounding strategy: "); switch (parms->rounding_strategy) { case COLOR_neighbor_rounding: printf("neighbor\n"); break; case COLOR_uniform_rounding: printf("uniform\n"); break; case COLOR_no_rounding: printf("none\n"); break; } if (COLORdbg_lvl() > 1) printf ("Debugging turned on\n"); fflush (stdout); rval = COLORread_dimacs (parms->edgefile, &(cd->ncount), &(cd->ecount), &(cd->elist), (int **) NULL); COLORcheck_rval (rval, "COLORread_diamcs failed"); if (cd->upper_bound > cd->ncount) {cd->upper_bound = cd->ncount;} if (colorproblem.parms.backupdir) { recover_colordata(cd,&colorproblem); } rval = COLORexact_coloring(&colorproblem,&ncolors, &colorclasses); COLORcheck_rval(rval, "Failed to COLORexact_coloring"); if (cd->nbestcolors == cd->upper_bound) { printf ("Opt Colors: %d\n", cd->nbestcolors); fflush (stdout); print_colors(colorclasses, ncolors); } else if (cd->lower_bound == parms->initial_upper_bound) { printf("Lower bound reached predefined upper bound %d.\n", parms->initial_upper_bound); } else { printf("Finished with LB %d and UB %d.\n", cd->lower_bound, cd->upper_bound); } tot_rtime = COLORcpu_time() - start_time; printf("Computing coloring took %f seconds.\n",tot_rtime); CLEANUP: COLORproblem_free(&colorproblem); COLORfree_sets(&colorclasses, &ncolors); COLOR_IFFREE(debugcolors,COLORset); return rval; }
int main (int ac, char **av) { char pname[256] = ""; int rval = 0; int ncount, ecount; int *elist = (int *) NULL; int *wlen = (int *) NULL; int *new_ids = (int *) NULL; int ndelete; COLORadjgraph G1, G2; int i, new_ncount; rval = parseargs (ac, av); if (rval) goto CLEANUP; get_problem_name (pname, graphfile); printf("c Graph generated from %s with <= %d non-isolated vertices.\n", pname, partitionsize); rval = COLORread_dimacs (graphfile, &ncount, &ecount, &elist, &wlen); COLORcheck_rval (rval, "COLORread_dimacs failed"); rval = COLORadjgraph_build (&G1, ncount, ecount, elist); COLORcheck_rval (rval, "COLORadjgraph_build failed"); new_ids = COLOR_SAFE_MALLOC(ncount, int); COLORcheck_NULL(new_ids, "Failed to allocate new_ids"); for (i = 0; i < ncount; ++i) { new_ids[i] = i;} new_ncount = ncount; ndelete = ncount - partitionsize; if (ndelete > 0) { /* rval = COLORadjgraph_greedy_partition_1 (&G2, &G1,partitionsize); */ /* COLORcheck_rval (rval, "COLORadjgraph_build failed"); */ COLORadjgraph_incr_deled_smallest_degree_vertex(&G2, &G1, partitionsize); rval = COLORadjgraph_extract_edgelist(&ecount, &elist, &G2); COLORcheck_rval(rval,"Failed in COLORadjgraph_extract_edgelist"); new_ncount = 0; for (i = 0; i < ncount; ++i) { COLORadjnode* v = G2.nodelist + i; if (v->degree){ new_ids[i] = new_ncount++; printf("c node %d renamed to %d\n", i + 1, new_ids[i] + 1); } else { new_ids[i] = -1; } } } printf("p edge %d %d\n", new_ncount,ecount); for (i = 0; i < ecount; ++i) { printf("e %d %d\n",new_ids[elist[2*i]] + 1,new_ids[elist[2*i+1]] + 1); } CLEANUP: return rval; }