void glp_create_index(glp_prob *lp)
{   GLPROW *row;
    GLPCOL *col;
    int i, j;
    /* create row name index */
    if (lp->r_tree == NULL)
    {   lp->r_tree = avl_create_tree(avl_strcmp, NULL);
        for (i = 1; i <= lp->m; i++)
        {   row = lp->row[i];
            xassert(row->node == NULL);
            if (row->name != NULL)
            {   row->node = avl_insert_node(lp->r_tree, row->name);
                avl_set_node_link(row->node, row);
            }
        }
    }
    /* create column name index */
    if (lp->c_tree == NULL)
    {   lp->c_tree = avl_create_tree(avl_strcmp, NULL);
        for (j = 1; j <= lp->n; j++)
        {   col = lp->col[j];
            xassert(col->node == NULL);
            if (col->name != NULL)
            {   col->node = avl_insert_node(lp->c_tree, col->name);
                avl_set_node_link(col->node, col);
            }
        }
    }
    return;
}
void glp_set_col_name(glp_prob *lp, int j, const char *name)
{     GLPCOL *col;
      if (!(1 <= j && j <= lp->n))
         xerror("glp_set_col_name: j = %d; column number out of range\n"
            , j);
      col = lp->col[j];
      if (col->name != NULL)
      {  if (col->node != NULL)
         {  xassert(lp->c_tree != NULL);
            avl_delete_node(lp->c_tree, col->node);
            col->node = NULL;
         }
         dmp_free_atom(lp->pool, col->name, strlen(col->name)+1);
         col->name = NULL;
      }
      if (!(name == NULL || name[0] == '\0'))
      {  if (strlen(name) > 255)
            xerror("glp_set_col_name: j = %d; column name too long\n",
               j);
         col->name = dmp_get_atom(lp->pool, strlen(name)+1);
         strcpy(col->name, name);
         if (lp->c_tree != NULL && col->name != NULL)
         {  xassert(col->node == NULL);
            col->node = avl_insert_node(lp->c_tree, col->name);
            avl_set_node_link(col->node, col);
         }
      }
      return;
}
void glp_set_row_name(glp_prob *lp, int i, const char *name)
{     GLPROW *row;
      if (!(1 <= i && i <= lp->m))
         xerror("glp_set_row_name: i = %d; row number out of range\n",
            i);
      row = lp->row[i];
      if (row->name != NULL)
      {  if (row->node != NULL)
         {  xassert(lp->r_tree != NULL);
            avl_delete_node(lp->r_tree, row->node);
            row->node = NULL;
         }
         dmp_free_atom(lp->pool, row->name, strlen(row->name)+1);
         row->name = NULL;
      }
      if (!(name == NULL || name[0] == '\0'))
      {  if (strlen(name) > 255)
            xerror("glp_set_row_name: i = %d; row name too long\n", i);
         row->name = dmp_get_atom(lp->pool, strlen(name)+1);
         strcpy(row->name, name);
         if (lp->r_tree != NULL)
         {  xassert(row->node == NULL);
            row->node = avl_insert_node(lp->r_tree, row->name);
            avl_set_node_link(row->node, row);
         }
      }
      return;
}
Beispiel #4
0
void glp_create_v_index(glp_graph *G)
{   /* create vertex name index */
    glp_vertex *v;
    int i;
    if (G->index == NULL)
    {   G->index = avl_create_tree(avl_strcmp, NULL);
        for (i = 1; i <= G->nv; i++)
        {   v = G->v[i];
            xassert(v->entry == NULL);
            if (v->name != NULL)
            {   v->entry = avl_insert_node(G->index, v->name);
                avl_set_node_link(v->entry, v);
            }
        }
    }
    return;
}
Beispiel #5
0
void glp_set_row_name(glp_prob *lp, int i, const char *name)
{     glp_tree *tree = lp->tree;
      GLPROW *row;
      if (!(1 <= i && i <= lp->m))
         xerror("glp_set_row_name: i = %d; row number out of range\n",
            i);
      row = lp->row[i];
      if (tree != NULL && tree->reason != 0)
      {  xassert(tree->curr != NULL);
         xassert(row->level == tree->curr->level);
      }
      if (row->name != NULL)
      {  if (row->node != NULL)
         {  xassert(lp->r_tree != NULL);
            avl_delete_node(lp->r_tree, row->node);
            row->node = NULL;
         }
         dmp_free_atom(lp->pool, row->name, strlen(row->name)+1);
         row->name = NULL;
      }
      if (!(name == NULL || name[0] == '\0'))
      {  int k;
         for (k = 0; name[k] != '\0'; k++)
         {  if (k == 256)
               xerror("glp_set_row_name: i = %d; row name too long\n",
                  i);
            if (iscntrl((unsigned char)name[k]))
               xerror("glp_set_row_name: i = %d: row name contains inva"
                  "lid character(s)\n", i);
         }
         row->name = dmp_get_atom(lp->pool, strlen(name)+1);
         strcpy(row->name, name);
         if (lp->r_tree != NULL)
         {  xassert(row->node == NULL);
            row->node = avl_insert_node(lp->r_tree, row->name);
            avl_set_node_link(row->node, row);
         }
      }
      return;
}
Beispiel #6
0
void glp_set_col_name(glp_prob *lp, int j, const char *name)
{     glp_tree *tree = lp->tree;
      GLPCOL *col;
      if (tree != NULL && tree->reason != 0)
         xerror("glp_set_col_name: operation not allowed\n");
      if (!(1 <= j && j <= lp->n))
         xerror("glp_set_col_name: j = %d; column number out of range\n"
            , j);
      col = lp->col[j];
      if (col->name != NULL)
      {  if (col->node != NULL)
         {  xassert(lp->c_tree != NULL);
            avl_delete_node(lp->c_tree, col->node);
            col->node = NULL;
         }
         dmp_free_atom(lp->pool, col->name, strlen(col->name)+1);
         col->name = NULL;
      }
      if (!(name == NULL || name[0] == '\0'))
      {  int k;
         for (k = 0; name[k] != '\0'; k++)
         {  if (k == 256)
               xerror("glp_set_col_name: j = %d; column name too long\n"
                  , j);
            if (iscntrl((unsigned char)name[k]))
               xerror("glp_set_col_name: j = %d: column name contains i"
                  "nvalid character(s)\n", j);
         }
         col->name = dmp_get_atom(lp->pool, strlen(name)+1);
         strcpy(col->name, name);
         if (lp->c_tree != NULL && col->name != NULL)
         {  xassert(col->node == NULL);
            col->node = avl_insert_node(lp->c_tree, col->name);
            avl_set_node_link(col->node, col);
         }
      }
      return;
}
Beispiel #7
0
void glp_set_vertex_name(glp_graph *G, int i, const char *name)
{   /* assign (change) vertex name */
    glp_vertex *v;
    if (!(1 <= i && i <= G->nv))
        xerror("glp_set_vertex_name: i = %d; vertex number out of rang"
               "e\n", i);
    v = G->v[i];
    if (v->name != NULL)
    {   if (v->entry != NULL)
        {   xassert(G->index != NULL);
            avl_delete_node(G->index, v->entry);
            v->entry = NULL;
        }
        dmp_free_atom(G->pool, v->name, strlen(v->name)+1);
        v->name = NULL;
    }
    if (!(name == NULL || name[0] == '\0'))
    {   int k;
        for (k = 0; name[k] != '\0'; k++)
        {   if (k == 256)
                xerror("glp_set_vertex_name: i = %d; vertex name too lon"
                       "g\n", i);
            if (iscntrl((unsigned char)name[k]))
                xerror("glp_set_vertex_name: i = %d; vertex name contain"
                       "s invalid character(s)\n", i);
        }
        v->name = dmp_get_atom(G->pool, strlen(name)+1);
        strcpy(v->name, name);
        if (G->index != NULL)
        {   xassert(v->entry == NULL);
            v->entry = avl_insert_node(G->index, v->name);
            avl_set_node_link(v->entry, v);
        }
    }
    return;
}