void ccz_sqrmod(ccz *r, const ccz *s, const ccz *t) { ccz_set_sign(r, 1); ccz_set_capacity(r, CC_MAX(2 * ccz_n(s), ccz_n(t))); ccz_zp_decl(t, zt); ccn_sqr(ccz_n(s), r->u, s->u); cczp_modn(zt, r->u, 2 * ccz_n(s), r->u); ccz_set_n(r, ccn_n(cczp_n(zt), r->u)); }
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; }
float CCControlSlider::valueForLocation(CCPoint location) { float percent = location.x/ m_backgroundSprite->getContentSize().width; return CC_MAX(CC_MIN(m_minimumValue + percent * (m_maximumValue - m_minimumValue), m_maximumAllowedValue), m_minimumAllowedValue); }