Changeset 2386:81b47fc5c444 in lemon-0.x for lemon/lp_glpk.cc
- Timestamp:
- 03/02/07 19:04:28 (17 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@3217
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/lp_glpk.cc
r2368 r2386 104 104 105 105 void LpGlpk::_eraseCol(int i) { 106 int c ols[2];107 c ols[1]=i;108 lpx_del_cols(lp, 1, c ols);106 int ca[2]; 107 ca[1]=i; 108 lpx_del_cols(lp, 1, ca); 109 109 } 110 110 111 111 void LpGlpk::_eraseRow(int i) { 112 int r ows[2];113 r ows[1]=i;114 lpx_del_rows(lp, 1, r ows);115 } 116 117 void LpGlpk::_getColName(int c ol, std::string & name) const118 { 119 120 char *n = lpx_get_col_name(lp,c ol);112 int ra[2]; 113 ra[1]=i; 114 lpx_del_rows(lp, 1, ra); 115 } 116 117 void LpGlpk::_getColName(int c, std::string & name) const 118 { 119 120 char *n = lpx_get_col_name(lp,c); 121 121 name = n?n:""; 122 122 } 123 123 124 124 125 void LpGlpk::_setColName(int c ol, const std::string & name)126 { 127 lpx_set_col_name(lp,c ol,const_cast<char*>(name.c_str()));125 void LpGlpk::_setColName(int c, const std::string & name) 126 { 127 lpx_set_col_name(lp,c,const_cast<char*>(name.c_str())); 128 128 129 129 } … … 152 152 } 153 153 154 void LpGlpk::_getRowCoeffs(int i , RowIterator b) const155 { 156 int length = lpx_get_mat_row(lp, i , 0, 0);154 void LpGlpk::_getRowCoeffs(int ix, RowIterator b) const 155 { 156 int length = lpx_get_mat_row(lp, ix, 0, 0); 157 157 158 158 std::vector<int> indices(length + 1); 159 159 std::vector<Value> values(length + 1); 160 160 161 lpx_get_mat_row(lp, i , &indices[0], &values[0]);161 lpx_get_mat_row(lp, ix, &indices[0], &values[0]); 162 162 163 163 for (int i = 1; i <= length; ++i) { … … 167 167 } 168 168 169 void LpGlpk::_setColCoeffs(int i , ConstColIterator b, ConstColIterator e) {169 void LpGlpk::_setColCoeffs(int ix, ConstColIterator b, ConstColIterator e) { 170 170 171 171 std::vector<int> indices; … … 180 180 } 181 181 182 lpx_set_mat_col(lp, i , values.size() - 1, &indices[0], &values[0]);183 } 184 185 void LpGlpk::_getColCoeffs(int i , ColIterator b) const186 { 187 int length = lpx_get_mat_col(lp, i , 0, 0);182 lpx_set_mat_col(lp, ix, values.size() - 1, &indices[0], &values[0]); 183 } 184 185 void LpGlpk::_getColCoeffs(int ix, ColIterator b) const 186 { 187 int length = lpx_get_mat_col(lp, ix, 0, 0); 188 188 189 189 std::vector<int> indices(length + 1); 190 190 std::vector<Value> values(length + 1); 191 191 192 lpx_get_mat_col(lp, i , &indices[0], &values[0]);192 lpx_get_mat_col(lp, ix, &indices[0], &values[0]); 193 193 194 194 for (int i = 1; i <= length; ++i) { … … 198 198 } 199 199 200 void LpGlpk::_setCoeff(int row, int col, Value value)200 void LpGlpk::_setCoeff(int ix, int jx, Value value) 201 201 { 202 202 203 203 if (lpx_get_num_cols(lp) < lpx_get_num_rows(lp)) { 204 204 205 int length=lpx_get_mat_row(lp, row, 0, 0);205 int length=lpx_get_mat_row(lp, ix, 0, 0); 206 206 207 207 std::vector<int> indices(length + 2); 208 208 std::vector<Value> values(length + 2); 209 209 210 lpx_get_mat_row(lp, row, &indices[0], &values[0]);210 lpx_get_mat_row(lp, ix, &indices[0], &values[0]); 211 211 212 212 //The following code does not suppose that the elements of the … … 214 214 bool found=false; 215 215 for (int i = 1; i <= length; ++i) { 216 if (indices[i]== col){216 if (indices[i]==jx){ 217 217 found=true; 218 218 values[i]=value; … … 222 222 if (!found){ 223 223 ++length; 224 indices[length]= col;224 indices[length]=jx; 225 225 values[length]=value; 226 226 } 227 227 228 lpx_set_mat_row(lp, row, length, &indices[0], &values[0]);228 lpx_set_mat_row(lp, ix, length, &indices[0], &values[0]); 229 229 230 230 } else { 231 231 232 int length=lpx_get_mat_col(lp, col, 0, 0);232 int length=lpx_get_mat_col(lp, jx, 0, 0); 233 233 234 234 std::vector<int> indices(length + 2); 235 235 std::vector<Value> values(length + 2); 236 236 237 lpx_get_mat_col(lp, col, &indices[0], &values[0]);237 lpx_get_mat_col(lp, jx, &indices[0], &values[0]); 238 238 239 239 //The following code does not suppose that the elements of the … … 241 241 bool found=false; 242 242 for (int i = 1; i <= length; ++i) { 243 if (indices[i]== col){243 if (indices[i]==jx){ 244 244 found=true; 245 245 values[i]=value; … … 249 249 if (!found){ 250 250 ++length; 251 indices[length]= row;251 indices[length]=ix; 252 252 values[length]=value; 253 253 } 254 254 255 lpx_set_mat_col(lp, col, length, &indices[0], &values[0]);256 } 257 } 258 259 LpGlpk::Value LpGlpk::_getCoeff(int row, int col) const260 { 261 262 int length=lpx_get_mat_row(lp, row, 0, 0);255 lpx_set_mat_col(lp, jx, length, &indices[0], &values[0]); 256 } 257 } 258 259 LpGlpk::Value LpGlpk::_getCoeff(int ix, int jx) const 260 { 261 262 int length=lpx_get_mat_row(lp, ix, 0, 0); 263 263 264 264 std::vector<int> indices(length + 1); 265 265 std::vector<Value> values(length + 1); 266 266 267 lpx_get_mat_row(lp, row, &indices[0], &values[0]);267 lpx_get_mat_row(lp, ix, &indices[0], &values[0]); 268 268 269 269 //The following code does not suppose that the elements of the 270 270 //array indices are sorted 271 271 for (int i = 1; i <= length; ++i) { 272 if (indices[i]== col){272 if (indices[i]==jx){ 273 273 return values[i]; 274 274 }
Note: See TracChangeset
for help on using the changeset viewer.