Debian Codegraph @

external/glpk/glpapi03.c

raw symbols SCIP
1 /* glpapi03.c (row and column searching routines) */cxx . . $ `<file>/external/glpk/glpapi03.c`/
2
3 /***********************************************************************
4 * This code is part of GLPK (GNU Linear Programming Kit).
5 *
6 * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
7 * 2009, 2010 Andrew Makhorin, Department for Applied Informatics,
8 * Moscow Aviation Institute, Moscow, Russia. All rights reserved.
9 * E-mail: <[email protected]>.
10 *
11 * GLPK is free software: you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * GLPK is distributed in the hope that it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
19 * License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with GLPK. If not, see <http://www.gnu.org/licenses/>.
23 ***********************************************************************/
24
25 #include "glpapi.h"cxx . . $ `<file>/external/glpk/glpapi.h`/
26
27 /***********************************************************************
28 * NAME
29 *
30 * glp_create_index - create the name index
31 *
32 * SYNOPSIS
33 *
34 * void glp_create_index(glp_prob *lp);
35 *
36 * DESCRIPTION
37 *
38 * The routine glp_create_index creates the name index for the
39 * specified problem object. The name index is an auxiliary data
40 * structure, which is intended to quickly (i.e. for logarithmic time)
41 * find rows and columns by their names.
42 *
43 * This routine can be called at any time. If the name index already
44 * exists, the routine does nothing. */
45
46 void glp_create_indexcxx . . $ glp_create_index(84c60d68cac39b9a).(glp_probcxx . . $ glp_prob# *lp)
47 { GLPROWcxx . . $ GLPROW# *row;
48 GLPCOLcxx . . $ GLPCOL# *col;
49 int i, j;
50 /* create row name index */
51 if (lp->r_treecxx . . $ glp_prob#r_tree. == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
52 { lp->r_treecxx . . $ glp_prob#r_tree. = avl_create_treecxx . . $ `external/glpk/glpavl.h:80:9`!(avl_strcmpcxx . . $ `external/glpk/glpavl.h:85:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
53 for (i = 1; i <= lp->mcxx . . $ glp_prob#m.; i++)
54 { row = lp->rowcxx . . $ glp_prob#row.[i];
55 xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(row->node == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
56 if (row->namecxx . . $ GLPROW#name. != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
57 { row->nodecxx . . $ GLPROW#node. = avl_insert_nodecxx . . $ `external/glpk/glpavl.h:89:9`!(lp->r_treecxx . . $ glp_prob#r_tree., row->namecxx . . $ GLPROW#name.);
58 avl_set_node_linkcxx . . $ `external/glpk/glpavl.h:97:9`!(row->nodecxx . . $ GLPROW#node., row);
59 }
60 }
61 }
62 /* create column name index */
63 if (lp->c_treecxx . . $ glp_prob#c_tree. == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
64 { lp->c_treecxx . . $ glp_prob#c_tree. = avl_create_treecxx . . $ `external/glpk/glpavl.h:80:9`!(avl_strcmpcxx . . $ `external/glpk/glpavl.h:85:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
65 for (j = 1; j <= lp->ncxx . . $ glp_prob#n.; j++)
66 { col = lp->colcxx . . $ glp_prob#col.[j];
67 xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(col->node == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
68 if (col->namecxx . . $ GLPCOL#name. != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
69 { col->nodecxx . . $ GLPCOL#node. = avl_insert_nodecxx . . $ `external/glpk/glpavl.h:89:9`!(lp->c_treecxx . . $ glp_prob#c_tree., col->namecxx . . $ GLPCOL#name.);
70 avl_set_node_linkcxx . . $ `external/glpk/glpavl.h:97:9`!(col->nodecxx . . $ GLPCOL#node., col);
71 }
72 }
73 }
74 return;
75 }
76
77 /***********************************************************************
78 * NAME
79 *
80 * glp_find_row - find row by its name
81 *
82 * SYNOPSIS
83 *
84 * int glp_find_row(glp_prob *lp, const char *name);
85 *
86 * RETURNS
87 *
88 * The routine glp_find_row returns the ordinal number of a row,
89 * which is assigned (by the routine glp_set_row_name) the specified
90 * symbolic name. If no such row exists, the routine returns 0. */
91
92 int glp_find_rowcxx . . $ glp_find_row(5aeec8fe9468a6e).(glp_probcxx . . $ glp_prob# *lp, const char *name)
93 { AVLNODEcxx . . $ AVLNODE# *node;
94 int i = 0;
95 if (lp->r_treecxx . . $ glp_prob#r_tree. == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
96 xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_find_row: row name index does not exist\n");
97 if (!(name == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`! || name[0] == '\0' || strlencxx . . $ strlen(751346f8406fd082).(name) > 255))
98 { node = avl_find_nodecxx . . $ `external/glpk/glpavl.h:101:9`!(lp->r_treecxx . . $ glp_prob#r_tree., name);
99 if (node != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
100 i = ((GLPROWcxx . . $ GLPROW# *)avl_get_node_linkcxx . . $ `external/glpk/glpavl.h:109:9`!(node))->icxx . . $ GLPROW#i.;
101 }
102 return i;
103 }
104
105 /***********************************************************************
106 * NAME
107 *
108 * glp_find_col - find column by its name
109 *
110 * SYNOPSIS
111 *
112 * int glp_find_col(glp_prob *lp, const char *name);
113 *
114 * RETURNS
115 *
116 * The routine glp_find_col returns the ordinal number of a column,
117 * which is assigned (by the routine glp_set_col_name) the specified
118 * symbolic name. If no such column exists, the routine returns 0. */
119
120 int glp_find_colcxx . . $ glp_find_col(5aeec8fe9468a6e).(glp_probcxx . . $ glp_prob# *lp, const char *name)
121 { AVLNODEcxx . . $ AVLNODE# *node;
122 int j = 0;
123 if (lp->c_treecxx . . $ glp_prob#c_tree. == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
124 xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_find_col: column name index does not exist\n");
125 if (!(name == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`! || name[0] == '\0' || strlencxx . . $ strlen(751346f8406fd082).(name) > 255))
126 { node = avl_find_nodecxx . . $ `external/glpk/glpavl.h:101:9`!(lp->c_treecxx . . $ glp_prob#c_tree., name);
127 if (node != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
128 j = ((GLPCOLcxx . . $ GLPCOL# *)avl_get_node_linkcxx . . $ `external/glpk/glpavl.h:109:9`!(node))->jcxx . . $ GLPCOL#j.;
129 }
130 return j;
131 }
132
133 /***********************************************************************
134 * NAME
135 *
136 * glp_delete_index - delete the name index
137 *
138 * SYNOPSIS
139 *
140 * void glp_delete_index(glp_prob *lp);
141 *
142 * DESCRIPTION
143 *
144 * The routine glp_delete_index deletes the name index previously
145 * created by the routine glp_create_index and frees the memory
146 * allocated to this auxiliary data structure.
147 *
148 * This routine can be called at any time. If the name index does not
149 * exist, the routine does nothing. */
150
151 void glp_delete_indexcxx . . $ glp_delete_index(84c60d68cac39b9a).(glp_probcxx . . $ glp_prob# *lp)
152 { int i, j;
153 /* delete row name index */
154 if (lp->r_treecxx . . $ glp_prob#r_tree. != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
155 { for (i = 1; i <= lp->mcxx . . $ glp_prob#m.; i++) lp->rowcxx . . $ glp_prob#row.[i]->nodecxx . . $ GLPROW#node. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
156 avl_delete_treecxx . . $ `external/glpk/glpavl.h:117:9`!(lp->r_treecxx . . $ glp_prob#r_tree.), lp->r_treecxx . . $ glp_prob#r_tree. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
157 }
158 /* delete column name index */
159 if (lp->c_treecxx . . $ glp_prob#c_tree. != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
160 { for (j = 1; j <= lp->ncxx . . $ glp_prob#n.; j++) lp->colcxx . . $ glp_prob#col.[j]->nodecxx . . $ GLPCOL#node. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
161 avl_delete_treecxx . . $ `external/glpk/glpavl.h:117:9`!(lp->c_treecxx . . $ glp_prob#c_tree.), lp->c_treecxx . . $ glp_prob#c_tree. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
162 }
163 return;
164 }
165
166 /* eof */