Changeset 50 for trunk/ClpDualRowSteepest.cpp
 Timestamp:
 Nov 5, 2002 1:04:44 AM (19 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/ClpDualRowSteepest.cpp
r2 r50 9 9 #include "ClpSimplex.hpp" 10 10 #include "ClpDualRowSteepest.hpp" 11 #include " OsiIndexedVector.hpp"11 #include "CoinIndexedVector.hpp" 12 12 #include "ClpFactorization.hpp" 13 13 #include "CoinHelperFunctions.hpp" 14 #include < stdio.h>14 #include <cstdio> 15 15 16 16 //############################################################################# … … 30 30 savedWeights_(NULL) 31 31 { 32 type_=2 ;32 type_=2+64*mode; 33 33 } 34 34 … … 43 43 model_ = rhs.model_; 44 44 if (rhs.infeasible_) { 45 infeasible_= new OsiIndexedVector(rhs.infeasible_);45 infeasible_= new CoinIndexedVector(rhs.infeasible_); 46 46 } else { 47 47 infeasible_=NULL; … … 51 51 int number = model_>numberRows(); 52 52 weights_= new double[number]; 53 C oinDisjointCopyN(rhs.weights_,number,weights_);53 ClpDisjointCopyN(rhs.weights_,number,weights_); 54 54 } else { 55 55 weights_=NULL; 56 56 } 57 57 if (rhs.alternateWeights_) { 58 alternateWeights_= new OsiIndexedVector(rhs.alternateWeights_);58 alternateWeights_= new CoinIndexedVector(rhs.alternateWeights_); 59 59 } else { 60 60 alternateWeights_=NULL; 61 61 } 62 62 if (rhs.savedWeights_) { 63 savedWeights_= new OsiIndexedVector(rhs.savedWeights_);63 savedWeights_= new CoinIndexedVector(rhs.savedWeights_); 64 64 } else { 65 65 savedWeights_=NULL; … … 94 94 delete savedWeights_; 95 95 if (rhs.infeasible_!=NULL) { 96 infeasible_= new OsiIndexedVector(rhs.infeasible_);96 infeasible_= new CoinIndexedVector(rhs.infeasible_); 97 97 } else { 98 98 infeasible_=NULL; … … 102 102 int number = model_>numberRows(); 103 103 weights_= new double[number]; 104 C oinDisjointCopyN(rhs.weights_,number,weights_);104 ClpDisjointCopyN(rhs.weights_,number,weights_); 105 105 } else { 106 106 weights_=NULL; 107 107 } 108 108 if (rhs.alternateWeights_!=NULL) { 109 alternateWeights_= new OsiIndexedVector(rhs.alternateWeights_);109 alternateWeights_= new CoinIndexedVector(rhs.alternateWeights_); 110 110 } else { 111 111 alternateWeights_=NULL; 112 112 } 113 113 if (rhs.savedWeights_!=NULL) { 114 savedWeights_= new OsiIndexedVector(rhs.savedWeights_);114 savedWeights_= new CoinIndexedVector(rhs.savedWeights_); 115 115 } else { 116 116 savedWeights_=NULL; … … 153 153 // Updates weights 154 154 void 155 ClpDualRowSteepest::updateWeights( OsiIndexedVector * input,156 OsiIndexedVector * spare,157 OsiIndexedVector * updatedColumn)155 ClpDualRowSteepest::updateWeights(CoinIndexedVector * input, 156 CoinIndexedVector * spare, 157 CoinIndexedVector * updatedColumn) 158 158 { 159 159 // clear other region … … 172 172 { 173 173 int numberRows = model_>numberRows(); 174 OsiIndexedVector * temp = new OsiIndexedVector();174 CoinIndexedVector * temp = new CoinIndexedVector(); 175 175 temp>reserve(numberRows+ 176 176 model_>factorization()>maximumPivots()); … … 245 245 } 246 246 } 247 #ifdef CLP_DEBUG 247 248 assert(work3[pivotRow]&&work[pivotRow]); 249 #endif 248 250 alternateWeights_>setNumElements(nSave); 249 251 if (norm < TRY_NORM) … … 263 265 void 264 266 ClpDualRowSteepest::updatePrimalSolution( 265 OsiIndexedVector * primalUpdate,267 CoinIndexedVector * primalUpdate, 266 268 double primalRatio, 267 269 double & objectiveChange) … … 275 277 const int * pivotVariable = model_>pivotVariable(); 276 278 double * infeas = infeasible_>denseVector(); 279 int pivotRow = model_>pivotRow(); 280 double * solution = model_>solutionRegion(); 277 281 for (i=0;i<number;i++) { 278 282 int iRow=which[i]; 279 283 int iPivot=pivotVariable[iRow]; 280 double & value = model_>solutionAddress(iPivot);284 double value = solution[iPivot]; 281 285 double cost = model_>cost(iPivot); 282 286 double change = primalRatio*work[iRow]; 283 287 value = change; 288 changeObj = change*cost; 289 solution[iPivot] = value; 284 290 double lower = model_>lower(iPivot); 285 291 double upper = model_>upper(iPivot); 292 // But if pivot row then use value of incoming 293 if (iRow==pivotRow) { 294 iPivot = model_>sequenceIn(); 295 // make last resort choice 296 lower = 1.0e6*model_>lower(iPivot); 297 upper = 1.0e6*model_>upper(iPivot); 298 value = 1.0e6*model_>valueIncomingDual(); 299 } 286 300 if (value>upper+tolerance) { 287 301 // store square in list … … 301 315 infeas[iRow] = 1.0e100; 302 316 } 303 changeObj = change*cost;304 317 work[iRow]=0.0; 305 318 } … … 332 345 } 333 346 state_=1; 334 } else if (mode==2mode==4 ) {347 } else if (mode==2mode==4mode==5) { 335 348 // restore 336 if (!weights_state_==1 ) {349 if (!weights_state_==1mode==5) { 337 350 // initialize weights 338 351 delete [] weights_; 339 352 delete alternateWeights_; 340 353 weights_ = new double[numberRows]; 341 alternateWeights_ = new OsiIndexedVector();354 alternateWeights_ = new CoinIndexedVector(); 342 355 // enough space so can use it for factorization 343 356 alternateWeights_>reserve(numberRows+ 344 357 model_>factorization()>maximumPivots()); 345 if (!mode_ ) {358 if (!mode_mode==5) { 346 359 // initialize to 1.0 (can we do better?) 347 360 for (i=0;i<numberRows;i++) { … … 349 362 } 350 363 } else { 351 OsiIndexedVector * temp = new OsiIndexedVector();364 CoinIndexedVector * temp = new CoinIndexedVector(); 352 365 temp>reserve(numberRows+ 353 366 model_>factorization()>maximumPivots()); … … 374 387 } 375 388 // create saved weights (not really indexedvector) 376 savedWeights_ = new OsiIndexedVector();389 savedWeights_ = new CoinIndexedVector(); 377 390 savedWeights_>reserve(numberRows); 378 391 … … 415 428 // set up infeasibilities 416 429 if (!infeasible_) { 417 infeasible_ = new OsiIndexedVector();430 infeasible_ = new CoinIndexedVector(); 418 431 infeasible_>reserve(numberRows); 419 432 } … … 468 481 } 469 482 } 470 483 // Gets rid of all arrays 484 void 485 ClpDualRowSteepest::clearArrays() 486 { 487 delete [] weights_; 488 weights_=NULL; 489 delete infeasible_; 490 infeasible_ = NULL; 491 delete alternateWeights_; 492 alternateWeights_ = NULL; 493 delete savedWeights_; 494 savedWeights_ = NULL; 495 state_ =1; 496 } 497
Note: See TracChangeset
for help on using the changeset viewer.