Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
model::model( const vector<statement*> & statements )
{
    if (debug::is_enabled())
        cout << endl << "### Dataflow Analysis ###" << endl;

    vector<statement*> finite_statements;
    vector<statement*> infinite_statements;
    vector<statement*> invalid_statements;

    int actor_id = 0;
    for(statement *stmt : statements)
    {
        vector<int> infinite_dims = stmt->infinite_dimensions();
        if (infinite_dims.empty())
            finite_statements.push_back(stmt);
        else if (infinite_dims.size() == 1)
        {
            infinite_statements.push_back(stmt);

            actor a(stmt, actor_id++);
            a.flow_dimension = infinite_dims.front();
            m_actors.emplace(stmt, a);
        }
        else
            invalid_statements.push_back(stmt);
    }

    if (debug::is_enabled())
    {
        cout << endl << "Statement types:" << endl;
        cout << "- finite: " << finite_statements.size() << endl;
        cout << "- infinite: " << infinite_statements.size() << endl;
        cout << "- invalid: " << invalid_statements.size() << endl;
    }

    if (!invalid_statements.empty())
    {
        ostringstream msg;
        msg << "The following statements are infinite"
            << " in more than 1 dimension: " << endl;
        for (statement *stmt: invalid_statements)
        {
            msg << "- " << stmt->name << endl;
        }
        throw std::runtime_error(msg.str());
    }

    compute_channels();

    if (!m_channels.empty())
        compute_schedule();

    for (auto & actor_record : m_actors)
    {
        actor & a = actor_record.second;
        if (!a.steady_count)
        {
            cout << "WARNING: Infinite statement with no channels: " << a.stmt->name << endl;
            cout << '\t' << "Assuming default steady-period count of 1.";
            a.steady_count = 1;
        }
    }
}