Esempio n. 1
0
void npp_delete_wksp(NPP *npp)
{     /* delete LP/MIP preprocessor workspace */
      if (npp->pool != NULL)
         dmp_delete_pool(npp->pool);
      if (npp->stack != NULL)
         dmp_delete_pool(npp->stack);
      if (npp->row_ref != NULL)
         xfree(npp->row_ref);
      if (npp->col_ref != NULL)
         xfree(npp->col_ref);
      if (npp->r_stat != NULL)
         xfree(npp->r_stat);
#if 0
      if (npp->r_prim != NULL)
         xfree(npp->r_prim);
#endif
      if (npp->r_pi != NULL)
         xfree(npp->r_pi);
      if (npp->c_stat != NULL)
         xfree(npp->c_stat);
      if (npp->c_value != NULL)
         xfree(npp->c_value);
#if 0
      if (npp->c_dual != NULL)
         xfree(npp->c_dual);
#endif
      xfree(npp);
      return;
}
Esempio n. 2
0
void ipp_delete_wksp(IPP *ipp)
{     if (ipp->row_pool != NULL) dmp_delete_pool(ipp->row_pool);
      if (ipp->col_pool != NULL) dmp_delete_pool(ipp->col_pool);
      if (ipp->aij_pool != NULL) dmp_delete_pool(ipp->aij_pool);
      if (ipp->tqe_pool != NULL) dmp_delete_pool(ipp->tqe_pool);
      if (ipp->col_stat != NULL) xfree(ipp->col_stat);
      if (ipp->col_mipx != NULL) xfree(ipp->col_mipx);
      xfree(ipp);
      return;
}
Esempio n. 3
0
void mpl_terminate(MPL *mpl)
{     if (setjmp(mpl->jump)) xassert(mpl != mpl);
      switch (mpl->phase)
      {  case 0:
         case 1:
         case 2:
         case 3:
            /* there were no errors; clean the model content */
            clean_model(mpl);
            xassert(mpl->a_list == NULL);
#if 1 /* 11/II-2008 */
            xassert(mpl->dca == NULL);
#endif
            break;
         case 4:
            /* model processing has been finished due to error; delete
               search trees, which may be created for some arrays */
            {  ARRAY *a;
               for (a = mpl->a_list; a != NULL; a = a->next)
                  if (a->tree != NULL) avl_delete_tree(a->tree);
            }
#if 1 /* 11/II-2008 */
            free_dca(mpl);
#endif
            break;
         default:
            xassert(mpl != mpl);
      }
      /* delete the translator database */
      xfree(mpl->image);
      xfree(mpl->b_image);
      xfree(mpl->f_image);
      xfree(mpl->context);
      dmp_delete_pool(mpl->pool);
      avl_delete_tree(mpl->tree);
      dmp_delete_pool(mpl->strings);
      dmp_delete_pool(mpl->symbols);
      dmp_delete_pool(mpl->tuples);
      dmp_delete_pool(mpl->arrays);
      dmp_delete_pool(mpl->members);
      dmp_delete_pool(mpl->elemvars);
      dmp_delete_pool(mpl->formulae);
      dmp_delete_pool(mpl->elemcons);
      xfree(mpl->sym_buf);
      xfree(mpl->tup_buf);
      rng_delete_rand(mpl->rand);
      if (mpl->row != NULL) xfree(mpl->row);
      if (mpl->col != NULL) xfree(mpl->col);
      if (mpl->in_fp != NULL) xfclose(mpl->in_fp);
      if (mpl->out_fp != NULL && mpl->out_fp != (void *)stdout)
         xfclose(mpl->out_fp);
      if (mpl->out_file != NULL) xfree(mpl->out_file);
      if (mpl->prt_fp != NULL) xfclose(mpl->prt_fp);
      if (mpl->prt_file != NULL) xfree(mpl->prt_file);
      if (mpl->mod_file != NULL) xfree(mpl->mod_file);
      xfree(mpl->mpl_buf);
      xfree(mpl);
      return;
}
Esempio n. 4
0
void lpp_delete_wksp(LPP *lpp)
{     if (lpp->row_pool != NULL) dmp_delete_pool(lpp->row_pool);
      if (lpp->col_pool != NULL) dmp_delete_pool(lpp->col_pool);
      if (lpp->aij_pool != NULL) dmp_delete_pool(lpp->aij_pool);
      if (lpp->tqe_pool != NULL) dmp_delete_pool(lpp->tqe_pool);
      if (lpp->row_ref != NULL) ufree(lpp->row_ref);
      if (lpp->col_ref != NULL) ufree(lpp->col_ref);
      if (lpp->row_stat != NULL) ufree(lpp->row_stat);
      if (lpp->row_prim != NULL) ufree(lpp->row_prim);
      if (lpp->row_dual != NULL) ufree(lpp->row_dual);
      if (lpp->col_stat != NULL) ufree(lpp->col_stat);
      if (lpp->col_prim != NULL) ufree(lpp->col_prim);
      if (lpp->col_dual != NULL) ufree(lpp->col_dual);
      ufree(lpp);
      return;
}
Esempio n. 5
0
void gmp_free_mem(void)
{     if (gmp_pool != NULL) dmp_delete_pool(gmp_pool);
      if (gmp_work != NULL) xfree(gmp_work);
      gmp_pool = NULL;
      gmp_size = 0;
      gmp_work = NULL;
      return;
}
Esempio n. 6
0
void spm_delete_mat(SPM *A)
{     /* delete sparse matrix */
      if (A->pool != NULL) dmp_delete_pool(A->pool);
      if (A->row != NULL) xfree(A->row);
      if (A->col != NULL) xfree(A->col);
      xfree(A);
      return;
}
Esempio n. 7
0
void cfg_delete_graph(CFG *G)
{     tfree(G->pos);
      tfree(G->neg);
      dmp_delete_pool(G->pool);
      tfree(G->ref);
      tfree(G->vptr);
      tfree(G->cptr);
      tfree(G);
      return;
}
Esempio n. 8
0
void scg_delete_graph(SCG *g)
{     /* delete cliqued graph */
      dmp_delete_pool(g->pool);
      xfree(g->i_ptr);
      xfree(g->j_ptr);
      xfree(g->c_ptr);
      xfree(g->v_ptr);
      xfree(g->flag);
      xfree(g);
      return;
}
Esempio n. 9
0
static void delete_prob(glp_prob *lp)
{     dmp_delete_pool(lp->pool);
      xfree(lp->cps);
      xassert(lp->tree == NULL);
      xfree(lp->row);
      xfree(lp->col);
      if (lp->r_tree != NULL) avl_delete_tree(lp->r_tree);
      if (lp->c_tree != NULL) avl_delete_tree(lp->c_tree);
      xfree(lp->head);
      if (lp->bfcp != NULL) xfree(lp->bfcp);
      if (lp->bfd != NULL) bfd_delete_it(lp->bfd);
      return;
}
Esempio n. 10
0
void lux_delete(LUX *lux)
{     int n = lux->n;
      LUXELM *fij, *vij;
      int i;
      for (i = 1; i <= n; i++)
      {  for (fij = lux->F_row[i]; fij != NULL; fij = fij->r_next)
            mpq_clear(fij->val);
         mpq_clear(lux->V_piv[i]);
         for (vij = lux->V_row[i]; vij != NULL; vij = vij->r_next)
            mpq_clear(vij->val);
      }
      dmp_delete_pool(lux->pool);
      xfree(lux->F_row);
      xfree(lux->F_col);
      xfree(lux->V_piv);
      xfree(lux->V_row);
      xfree(lux->V_col);
      xfree(lux->P_row);
      xfree(lux->P_col);
      xfree(lux->Q_row);
      xfree(lux->Q_col);
      xfree(lux);
      return;
}
Esempio n. 11
0
LPX *lpp_build_prob(LPP *lpp)
{     LPX *prob;
      LPPROW *row;
      LPPCOL *col;
      struct load_info info;
      int i, j, typx;
      /* count number of rows and columns in the resultant problem */
      lpp->m = lpp->n = 0;
      for (row = lpp->row_ptr; row != NULL; row = row->next) lpp->m++;
      for (col = lpp->col_ptr; col != NULL; col = col->next) lpp->n++;
      /* allocate two arrays to save reference numbers assigned to rows
         and columns of the resultant problem */
      lpp->row_ref = ucalloc(1+lpp->m, sizeof(int));
      lpp->col_ref = ucalloc(1+lpp->n, sizeof(int));
      /* create LP problem object */
      prob = lpx_create_prob();
      /* the resultant problem should have the same optimization sense
         as the original problem */
      lpx_set_obj_dir(prob, lpp->orig_dir);
      /* set the constant term of the objective function */
      lpx_set_obj_c0(prob,
         lpp->orig_dir == LPX_MIN ? + lpp->c0 : - lpp->c0);
      /* create rows of the resultant problem */
      insist(lpp->m > 0);
      lpx_add_rows(prob, lpp->m);
      for (i = 1, row = lpp->row_ptr; i <= lpp->m; i++, row = row->next)
      {  insist(row != NULL);
         lpp->row_ref[i] = row->i;
         row->i = i;
         if (row->lb == -DBL_MAX && row->ub == +DBL_MAX)
            typx = LPX_FR;
         else if (row->ub == +DBL_MAX)
            typx = LPX_LO;
         else if (row->lb == -DBL_MAX)
            typx = LPX_UP;
         else if (row->lb != row->ub)
            typx = LPX_DB;
         else
            typx = LPX_FX;
         lpx_set_row_bnds(prob, i, typx, row->lb, row->ub);
      }
      insist(row == NULL);
      /* create columns of the resultant problem */
      insist(lpp->n > 0);
      lpx_add_cols(prob, lpp->n);
      for (j = 1, col = lpp->col_ptr; j <= lpp->n; j++, col = col->next)
      {  insist(col != NULL);
         lpp->col_ref[j] = col->j;
         col->j = j;
         if (col->lb == -DBL_MAX && col->ub == +DBL_MAX)
            typx = LPX_FR;
         else if (col->ub == +DBL_MAX)
            typx = LPX_LO;
         else if (col->lb == -DBL_MAX)
            typx = LPX_UP;
         else if (col->lb != col->ub)
            typx = LPX_DB;
         else
            typx = LPX_FX;
         lpx_set_col_bnds(prob, j, typx, col->lb, col->ub);
         lpx_set_col_coef(prob, j,
            lpp->orig_dir == LPX_MIN ? + col->c : - col->c);
      }
      insist(col == NULL);
      /* create the constraint matrix of the resultant problem */
      info.lpp = lpp;
      info.row = NULL;
      info.aij = NULL;
      lpx_load_mat(prob, &info, next_aij);
      /* count number of non-zeros in the resultant problem */
      lpp->nnz = lpx_get_num_nz(prob);
      /* internal data structures that represnts the resultant problem
         are no longer needed, so free them */
      dmp_delete_pool(lpp->row_pool), lpp->row_pool = NULL;
      dmp_delete_pool(lpp->col_pool), lpp->col_pool = NULL;
      dmp_delete_pool(lpp->aij_pool), lpp->aij_pool = NULL;
      lpp->row_ptr = NULL, lpp->col_ptr = NULL;
      lpp->row_que = NULL, lpp->col_que = NULL;
      /* return a pointer to the built LP problem object */
      return prob;
}
Esempio n. 12
0
void npp_build_prob(NPP *npp, glp_prob *prob)
{     /* build resultant (preprocessed) problem */
      NPPROW *row;
      NPPCOL *col;
      NPPAIJ *aij;
      int i, j, type, len, *ind;
      double dir, *val;
      glp_erase_prob(prob);
      glp_set_prob_name(prob, npp->name);
      glp_set_obj_name(prob, npp->obj);
      glp_set_obj_dir(prob, npp->orig_dir);
      if (npp->orig_dir == GLP_MIN)
         dir = +1.0;
      else if (npp->orig_dir == GLP_MAX)
         dir = -1.0;
      else
         xassert(npp != npp);
      glp_set_obj_coef(prob, 0, dir * npp->c0);
      /* build rows */
      for (row = npp->r_head; row != NULL; row = row->next)
      {  row->temp = i = glp_add_rows(prob, 1);
         glp_set_row_name(prob, i, row->name);
         if (row->lb == -DBL_MAX && row->ub == +DBL_MAX)
            type = GLP_FR;
         else if (row->ub == +DBL_MAX)
            type = GLP_LO;
         else if (row->lb == -DBL_MAX)
            type = GLP_UP;
         else if (row->lb != row->ub)
            type = GLP_DB;
         else
            type = GLP_FX;
         glp_set_row_bnds(prob, i, type, row->lb, row->ub);
      }
      /* build columns and the constraint matrix */
      ind = xcalloc(1+prob->m, sizeof(int));
      val = xcalloc(1+prob->m, sizeof(double));
      for (col = npp->c_head; col != NULL; col = col->next)
      {  j = glp_add_cols(prob, 1);
         glp_set_col_name(prob, j, col->name);
#if 0
         glp_set_col_kind(prob, j, col->kind);
#else
         glp_set_col_kind(prob, j, col->is_int ? GLP_IV : GLP_CV);
#endif
         if (col->lb == -DBL_MAX && col->ub == +DBL_MAX)
            type = GLP_FR;
         else if (col->ub == +DBL_MAX)
            type = GLP_LO;
         else if (col->lb == -DBL_MAX)
            type = GLP_UP;
         else if (col->lb != col->ub)
            type = GLP_DB;
         else
            type = GLP_FX;
         glp_set_col_bnds(prob, j, type, col->lb, col->ub);
         glp_set_obj_coef(prob, j, dir * col->coef);
         len = 0;
         for (aij = col->ptr; aij != NULL; aij = aij->c_next)
         {  len++;
            ind[len] = aij->row->temp;
            val[len] = aij->val;
         }
         glp_set_mat_col(prob, j, len, ind, val);
      }
      xfree(ind);
      xfree(val);
      /* resultant problem has been built */
      npp->m = prob->m;
      npp->n = prob->n;
      npp->nnz = prob->nnz;
      npp->row_ref = xcalloc(1+npp->m, sizeof(int));
      npp->col_ref = xcalloc(1+npp->n, sizeof(int));
      for (row = npp->r_head, i = 0; row != NULL; row = row->next)
         npp->row_ref[++i] = row->i;
      for (col = npp->c_head, j = 0; col != NULL; col = col->next)
         npp->col_ref[++j] = col->j;
      /* transformed problem segment is no longer needed */
      dmp_delete_pool(npp->pool), npp->pool = NULL;
      npp->name = npp->obj = NULL;
      npp->c0 = 0.0;
      npp->r_head = npp->r_tail = NULL;
      npp->c_head = npp->c_tail = NULL;
      return;
}
Esempio n. 13
0
static void delete_graph(glp_graph *G)
{     dmp_delete_pool(G->pool);
      xfree(G->v);
      if (G->index != NULL) avl_delete_tree(G->index);
      return;
}
Esempio n. 14
0
void avl_delete_tree(AVL *tree)
{     /* delete AVL tree */
      dmp_delete_pool(tree->pool);
      xfree(tree);
      return;
}