Changeset 462:9b082b3fb33f in lemonmain for lemon/soplex.cc
 Timestamp:
 01/12/09 13:26:02 (11 years ago)
 Branch:
 default
 Phase:
 public
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

lemon/soplex.cc
r461 r462 27 27 namespace lemon { 28 28 29 LpSoplex::LpSoplex() {29 SoplexLp::SoplexLp() { 30 30 soplex = new soplex::SoPlex; 31 31 } 32 32 33 LpSoplex::~LpSoplex() {33 SoplexLp::~SoplexLp() { 34 34 delete soplex; 35 35 } 36 36 37 LpSoplex::LpSoplex(const LpSoplex& lp) {37 SoplexLp::SoplexLp(const SoplexLp& lp) { 38 38 rows = lp.rows; 39 39 cols = lp.cols; … … 50 50 } 51 51 52 void LpSoplex::_clear_temporals() {52 void SoplexLp::_clear_temporals() { 53 53 _primal_values.clear(); 54 54 _dual_values.clear(); 55 55 } 56 56 57 LpSoplex* LpSoplex::_newSolver() const {58 LpSoplex* newlp = new LpSoplex();57 SoplexLp* SoplexLp::_newSolver() const { 58 SoplexLp* newlp = new SoplexLp(); 59 59 return newlp; 60 60 } 61 61 62 LpSoplex* LpSoplex::_cloneSolver() const {63 LpSoplex* newlp = new LpSoplex(*this);62 SoplexLp* SoplexLp::_cloneSolver() const { 63 SoplexLp* newlp = new SoplexLp(*this); 64 64 return newlp; 65 65 } 66 66 67 const char* LpSoplex::_solverName() const { return "LpSoplex"; }68 69 int LpSoplex::_addCol() {67 const char* SoplexLp::_solverName() const { return "SoplexLp"; } 68 69 int SoplexLp::_addCol() { 70 70 soplex::LPCol c; 71 71 c.setLower(soplex::infinity); … … 78 78 } 79 79 80 int LpSoplex::_addRow() {80 int SoplexLp::_addRow() { 81 81 soplex::LPRow r; 82 82 r.setLhs(soplex::infinity); … … 90 90 91 91 92 void LpSoplex::_eraseCol(int i) {92 void SoplexLp::_eraseCol(int i) { 93 93 soplex>removeCol(i); 94 94 _col_names_ref.erase(_col_names[i]); … … 98 98 } 99 99 100 void LpSoplex::_eraseRow(int i) {100 void SoplexLp::_eraseRow(int i) { 101 101 soplex>removeRow(i); 102 102 _row_names_ref.erase(_row_names[i]); … … 106 106 } 107 107 108 void LpSoplex::_eraseColId(int i) {108 void SoplexLp::_eraseColId(int i) { 109 109 cols.eraseIndex(i); 110 110 cols.relocateIndex(i, cols.maxIndex()); 111 111 } 112 void LpSoplex::_eraseRowId(int i) {112 void SoplexLp::_eraseRowId(int i) { 113 113 rows.eraseIndex(i); 114 114 rows.relocateIndex(i, rows.maxIndex()); 115 115 } 116 116 117 void LpSoplex::_getColName(int c, std::string &name) const {117 void SoplexLp::_getColName(int c, std::string &name) const { 118 118 name = _col_names[c]; 119 119 } 120 120 121 void LpSoplex::_setColName(int c, const std::string &name) {121 void SoplexLp::_setColName(int c, const std::string &name) { 122 122 _col_names_ref.erase(_col_names[c]); 123 123 _col_names[c] = name; … … 127 127 } 128 128 129 int LpSoplex::_colByName(const std::string& name) const {129 int SoplexLp::_colByName(const std::string& name) const { 130 130 std::map<std::string, int>::const_iterator it = 131 131 _col_names_ref.find(name); … … 137 137 } 138 138 139 void LpSoplex::_getRowName(int r, std::string &name) const {139 void SoplexLp::_getRowName(int r, std::string &name) const { 140 140 name = _row_names[r]; 141 141 } 142 142 143 void LpSoplex::_setRowName(int r, const std::string &name) {143 void SoplexLp::_setRowName(int r, const std::string &name) { 144 144 _row_names_ref.erase(_row_names[r]); 145 145 _row_names[r] = name; … … 149 149 } 150 150 151 int LpSoplex::_rowByName(const std::string& name) const {151 int SoplexLp::_rowByName(const std::string& name) const { 152 152 std::map<std::string, int>::const_iterator it = 153 153 _row_names_ref.find(name); … … 160 160 161 161 162 void LpSoplex::_setRowCoeffs(int i, ExprIterator b, ExprIterator e) {162 void SoplexLp::_setRowCoeffs(int i, ExprIterator b, ExprIterator e) { 163 163 for (int j = 0; j < soplex>nCols(); ++j) { 164 164 soplex>changeElement(i, j, 0.0); … … 169 169 } 170 170 171 void LpSoplex::_getRowCoeffs(int i, InsertIterator b) const {171 void SoplexLp::_getRowCoeffs(int i, InsertIterator b) const { 172 172 const soplex::SVector& vec = soplex>rowVector(i); 173 173 for (int k = 0; k < vec.size(); ++k) { … … 177 177 } 178 178 179 void LpSoplex::_setColCoeffs(int j, ExprIterator b, ExprIterator e) {179 void SoplexLp::_setColCoeffs(int j, ExprIterator b, ExprIterator e) { 180 180 for (int i = 0; i < soplex>nRows(); ++i) { 181 181 soplex>changeElement(i, j, 0.0); … … 186 186 } 187 187 188 void LpSoplex::_getColCoeffs(int i, InsertIterator b) const {188 void SoplexLp::_getColCoeffs(int i, InsertIterator b) const { 189 189 const soplex::SVector& vec = soplex>colVector(i); 190 190 for (int k = 0; k < vec.size(); ++k) { … … 194 194 } 195 195 196 void LpSoplex::_setCoeff(int i, int j, Value value) {196 void SoplexLp::_setCoeff(int i, int j, Value value) { 197 197 soplex>changeElement(i, j, value); 198 198 } 199 199 200 LpSoplex::Value LpSoplex::_getCoeff(int i, int j) const {200 SoplexLp::Value SoplexLp::_getCoeff(int i, int j) const { 201 201 return soplex>rowVector(i)[j]; 202 202 } 203 203 204 void LpSoplex::_setColLowerBound(int i, Value value) {204 void SoplexLp::_setColLowerBound(int i, Value value) { 205 205 LEMON_ASSERT(value != INF, "Invalid bound"); 206 206 soplex>changeLower(i, value != INF ? value : soplex::infinity); 207 207 } 208 208 209 LpSoplex::Value LpSoplex::_getColLowerBound(int i) const {209 SoplexLp::Value SoplexLp::_getColLowerBound(int i) const { 210 210 double value = soplex>lower(i); 211 211 return value != soplex::infinity ? value : INF; 212 212 } 213 213 214 void LpSoplex::_setColUpperBound(int i, Value value) {214 void SoplexLp::_setColUpperBound(int i, Value value) { 215 215 LEMON_ASSERT(value != INF, "Invalid bound"); 216 216 soplex>changeUpper(i, value != INF ? value : soplex::infinity); 217 217 } 218 218 219 LpSoplex::Value LpSoplex::_getColUpperBound(int i) const {219 SoplexLp::Value SoplexLp::_getColUpperBound(int i) const { 220 220 double value = soplex>upper(i); 221 221 return value != soplex::infinity ? value : INF; 222 222 } 223 223 224 void LpSoplex::_setRowLowerBound(int i, Value lb) {224 void SoplexLp::_setRowLowerBound(int i, Value lb) { 225 225 LEMON_ASSERT(lb != INF, "Invalid bound"); 226 226 soplex>changeRange(i, lb != INF ? lb : soplex::infinity, soplex>rhs(i)); 227 227 } 228 228 229 LpSoplex::Value LpSoplex::_getRowLowerBound(int i) const {229 SoplexLp::Value SoplexLp::_getRowLowerBound(int i) const { 230 230 double res = soplex>lhs(i); 231 231 return res == soplex::infinity ? INF : res; 232 232 } 233 233 234 void LpSoplex::_setRowUpperBound(int i, Value ub) {234 void SoplexLp::_setRowUpperBound(int i, Value ub) { 235 235 LEMON_ASSERT(ub != INF, "Invalid bound"); 236 236 soplex>changeRange(i, soplex>lhs(i), ub != INF ? ub : soplex::infinity); 237 237 } 238 238 239 LpSoplex::Value LpSoplex::_getRowUpperBound(int i) const {239 SoplexLp::Value SoplexLp::_getRowUpperBound(int i) const { 240 240 double res = soplex>rhs(i); 241 241 return res == soplex::infinity ? INF : res; 242 242 } 243 243 244 void LpSoplex::_setObjCoeffs(ExprIterator b, ExprIterator e) {244 void SoplexLp::_setObjCoeffs(ExprIterator b, ExprIterator e) { 245 245 for (int j = 0; j < soplex>nCols(); ++j) { 246 246 soplex>changeObj(j, 0.0); … … 251 251 } 252 252 253 void LpSoplex::_getObjCoeffs(InsertIterator b) const {253 void SoplexLp::_getObjCoeffs(InsertIterator b) const { 254 254 for (int j = 0; j < soplex>nCols(); ++j) { 255 255 Value coef = soplex>obj(j); … … 261 261 } 262 262 263 void LpSoplex::_setObjCoeff(int i, Value obj_coef) {263 void SoplexLp::_setObjCoeff(int i, Value obj_coef) { 264 264 soplex>changeObj(i, obj_coef); 265 265 } 266 266 267 LpSoplex::Value LpSoplex::_getObjCoeff(int i) const {267 SoplexLp::Value SoplexLp::_getObjCoeff(int i) const { 268 268 return soplex>obj(i); 269 269 } 270 270 271 LpSoplex::SolveExitStatus LpSoplex::_solve() {271 SoplexLp::SolveExitStatus SoplexLp::_solve() { 272 272 273 273 _clear_temporals(); … … 285 285 } 286 286 287 LpSoplex::Value LpSoplex::_getPrimal(int i) const {287 SoplexLp::Value SoplexLp::_getPrimal(int i) const { 288 288 if (_primal_values.empty()) { 289 289 _primal_values.resize(soplex>nCols()); … … 294 294 } 295 295 296 LpSoplex::Value LpSoplex::_getDual(int i) const {296 SoplexLp::Value SoplexLp::_getDual(int i) const { 297 297 if (_dual_values.empty()) { 298 298 _dual_values.resize(soplex>nRows()); … … 303 303 } 304 304 305 LpSoplex::Value LpSoplex::_getPrimalValue() const {305 SoplexLp::Value SoplexLp::_getPrimalValue() const { 306 306 return soplex>objValue(); 307 307 } 308 308 309 LpSoplex::VarStatus LpSoplex::_getColStatus(int i) const {309 SoplexLp::VarStatus SoplexLp::_getColStatus(int i) const { 310 310 switch (soplex>getBasisColStatus(i)) { 311 311 case soplex::SPxSolver::BASIC: … … 325 325 } 326 326 327 LpSoplex::VarStatus LpSoplex::_getRowStatus(int i) const {327 SoplexLp::VarStatus SoplexLp::_getRowStatus(int i) const { 328 328 switch (soplex>getBasisRowStatus(i)) { 329 329 case soplex::SPxSolver::BASIC: … … 343 343 } 344 344 345 LpSoplex::Value LpSoplex::_getPrimalRay(int i) const {345 SoplexLp::Value SoplexLp::_getPrimalRay(int i) const { 346 346 if (_primal_ray.empty()) { 347 347 _primal_ray.resize(soplex>nCols()); … … 352 352 } 353 353 354 LpSoplex::Value LpSoplex::_getDualRay(int i) const {354 SoplexLp::Value SoplexLp::_getDualRay(int i) const { 355 355 if (_dual_ray.empty()) { 356 356 _dual_ray.resize(soplex>nRows()); … … 361 361 } 362 362 363 LpSoplex::ProblemType LpSoplex::_getPrimalType() const {363 SoplexLp::ProblemType SoplexLp::_getPrimalType() const { 364 364 switch (soplex>status()) { 365 365 case soplex::SPxSolver::OPTIMAL: … … 374 374 } 375 375 376 LpSoplex::ProblemType LpSoplex::_getDualType() const {376 SoplexLp::ProblemType SoplexLp::_getDualType() const { 377 377 switch (soplex>status()) { 378 378 case soplex::SPxSolver::OPTIMAL: … … 387 387 } 388 388 389 void LpSoplex::_setSense(Sense sense) {389 void SoplexLp::_setSense(Sense sense) { 390 390 switch (sense) { 391 391 case MIN: … … 397 397 } 398 398 399 LpSoplex::Sense LpSoplex::_getSense() const {399 SoplexLp::Sense SoplexLp::_getSense() const { 400 400 switch (soplex>spxSense()) { 401 401 case soplex::SPxSolver::MAXIMIZE: … … 405 405 default: 406 406 LEMON_ASSERT(false, "Wrong sense."); 407 return LpSoplex::Sense();408 } 409 } 410 411 void LpSoplex::_clear() {407 return SoplexLp::Sense(); 408 } 409 } 410 411 void SoplexLp::_clear() { 412 412 soplex>clear(); 413 413 _col_names.clear();
Note: See TracChangeset
for help on using the changeset viewer.