Example #1
0
static int verify_text_pool (char *poolname, int nodecount)
{
    int rval;
    int *tour = (int *) NULL;
    CCtsp_lpcut_in *cuts = (CCtsp_lpcut_in *) NULL;
    CCtsp_lpcut_in *cnext;
    int cutcount;
    int nfail = 0;
    int nsuccess = 0;
    int i;

    tour = CC_SAFE_MALLOC (nodecount, int);
    if (tour == (int *) NULL) {
        fprintf (stderr, "Out of memory in verify_text_pool\n");
        rval = 1; goto CLEANUP;
    }
    for (i=0; i<nodecount; i++) tour[i] = i;
    
    rval = CCtsp_file_cuts (poolname, &cuts, &cutcount, nodecount, tour);
    if (rval) {
        fprintf (stderr, "CCtsp_file_cuts failed\n");
        goto CLEANUP;
    }

    while (cuts) {
        cnext = cuts->next;
        rval = CCverify_cut (cuts, CC_TYPE_ALL, (int *) NULL);
        if (rval) {
            fprintf (stderr, "CCverify_cut failed\n");
            nfail++;
        } else {
            nsuccess++;
        }
        CCtsp_free_lpcut_in (cuts);
        CC_FREE (cuts, CCtsp_lpcut_in);
        cuts = cnext;
    }

    printf ("%d of %d cuts failed verification\n", nfail, nfail + nsuccess);

    if (nfail == 0) rval = 0;
    else rval = -1;

  CLEANUP:
    CC_IFFREE (tour, int);
    while (cuts) {
        cnext = cuts->next;
        CCtsp_free_lpcut_in (cuts);
        CC_FREE (cuts, CCtsp_lpcut_in);
        cuts = cnext;
    }
    return rval;
}
Example #2
0
void wctlp_warmstart_free(wctlp_warmstart **w) {
    if (*w != (wctlp_warmstart *) NULL) {
        CC_IFFREE((*w)-> cstat, int);
        CC_IFFREE((*w)-> rstat, int);
        CC_IFFREE((*w)->dnorm, double);
        CC_FREE(*w, wctlp_warmstart);
    }
Example #3
0
int CCtsp_init_edgegenerator (CCtsp_edgegenerator *eg, int ncount,
        CCdatagroup *dg, CCtsp_genadj *adj, int nneighbors,
        int silent, CCrandstate *rstate)
{
    int rval;
    int norm;

    if (!silent) {
        printf ("CCtsp_init_edgegenerator (%d)\n", nneighbors); fflush (stdout);
    }

    eg->node_piest = (double *) NULL;
    eg->kdtree = (CCkdtree *) NULL;
    eg->xnear = (CCxnear *) NULL;
    eg->xprice = (CCtsp_xnorm_pricer *) NULL;
    eg->supply = (int *) NULL;
    eg->adjobjspace = (CCtsp_genadjobj *) NULL;
    eg->ncount = ncount;
    eg->dg = dg;
    eg->adj = adj;
    CCutil_dat_getnorm (dg, &norm);

    if (nneighbors == CCtsp_PRICE_COMPLETE_GRAPH) {
        eg->nneighbors = CCtsp_PRICE_COMPLETE_GRAPH;
        eg->supplyhead = 0;
        eg->start = 0;
        eg->current = 0;
        if ((((norm & CC_NORM_BITS) == CC_KD_NORM_TYPE) ||
            ((norm & CC_NORM_BITS) == CC_X_NORM_TYPE)) &&
              dg->ndepot == 0) {
            eg->supply = CC_SAFE_MALLOC (ncount, int);
            if (!eg->supply) {
                fprintf (stderr, "out of memory in CCtsp_init_edgegenerator\n");
                return 1;
            }
            eg->xprice = CC_SAFE_MALLOC (1, CCtsp_xnorm_pricer);
            if (!eg->xprice) {
                fprintf (stderr, "out of memory in CCtsp_init_edgegenerator\n");
                return 1;
            }
            rval = xprice_build (ncount, dg, eg->xprice, silent);
            if (rval) {
                fprintf (stderr, "xprice_build failed\n");
                CC_FREE (eg->xprice, CCtsp_xnorm_pricer);
                return rval;
            }
        }