#include <ClpNetworkMatrix.hpp>
Inheritance diagram for ClpNetworkMatrix:
Public Member Functions | |
Useful methods | |
virtual CoinPackedMatrix * | getPackedMatrix () const |
Return a complete CoinPackedMatrix. | |
virtual bool | isColOrdered () const |
virtual CoinBigIndex | getNumElements () const |
virtual int | getNumCols () const |
virtual int | getNumRows () const |
virtual const double * | getElements () const |
virtual const int * | getIndices () const |
virtual const CoinBigIndex * | getVectorStarts () const |
virtual const int * | getVectorLengths () const |
virtual void | deleteCols (const int numDel, const int *indDel) |
virtual void | deleteRows (const int numDel, const int *indDel) |
virtual ClpMatrixBase * | reverseOrderedCopy () const |
virtual CoinBigIndex | numberInBasis (const int *columnIsBasic) const |
virtual CoinBigIndex | fillBasis (const ClpSimplex *model, const int *columnIsBasic, int &numberBasic, int *row, int *column, double *element) const |
Fills in basis (Returns number of elements and updates numberBasic). | |
virtual CoinBigIndex | fillBasis (const ClpSimplex *model, const int *whichColumn, int numberRowBasic, int numberColumnBasic, int *row, int *column, double *element) const |
virtual CoinBigIndex * | dubiousWeights (const ClpSimplex *model, int *inputWeights) const |
virtual void | rangeOfElements (double &smallestNegative, double &largestNegative, double &smallestPositive, double &largestPositive) |
virtual void | unpack (const ClpSimplex *model, CoinIndexedVector *rowArray, int column) const |
virtual void | unpackPacked (ClpSimplex *model, CoinIndexedVector *rowArray, int column) const |
virtual void | add (const ClpSimplex *model, CoinIndexedVector *rowArray, int column, double multiplier) const |
virtual void | releaseNetworkMatrix () const |
Allow any parts of a created CoinMatrix to be deleted. | |
virtual bool | canDoPartialPricing () const |
Says whether it can do partial pricing. | |
virtual void | partialPricing (ClpSimplex *model, int start, int end, int &bestSequence, int &numberWanted) |
Partial pricing. | |
Matrix times vector methods | |
virtual void | times (double scalar, const double *x, double *y) const |
virtual void | times (double scalar, const double *x, double *y, const double *rowScale, const double *columnScale) const |
And for scaling. | |
virtual void | transposeTimes (double scalar, const double *x, double *y) const |
virtual void | transposeTimes (double scalar, const double *x, double *y, const double *rowScale, const double *columnScale) const |
And for scaling. | |
virtual void | transposeTimes (const ClpSimplex *model, double scalar, const CoinIndexedVector *x, CoinIndexedVector *y, CoinIndexedVector *z) const |
virtual void | subsetTransposeTimes (const ClpSimplex *model, const CoinIndexedVector *x, const CoinIndexedVector *y, CoinIndexedVector *z) const |
Other | |
bool | trueNetwork () const |
Return true if really network, false if has slacks. | |
Constructors, destructor | |
ClpNetworkMatrix () | |
ClpNetworkMatrix (int numberColumns, const int *head, const int *tail) | |
virtual | ~ClpNetworkMatrix () |
Copy method | |
ClpNetworkMatrix (const ClpNetworkMatrix &) | |
ClpNetworkMatrix (const CoinPackedMatrix &) | |
ClpNetworkMatrix & | operator= (const ClpNetworkMatrix &) |
virtual ClpMatrixBase * | clone () const |
Clone. | |
Protected Attributes | |
Data members | |
The data members are protected to allow access for derived classes. | |
double * | elements_ |
For fake CoinPackedMatrix. | |
int * | starts_ |
int * | lengths_ |
int * | indices_ |
Data -1, then +1 rows in pairs (row==-1 if one entry). | |
int | numberRows_ |
Number of rows. | |
int | numberColumns_ |
Number of columns. | |
bool | trueNetwork_ |
True if all entries have two elements. |
If you want more sophisticated version then you could inherit from this. Also you might want to allow networks with gain
Definition at line 16 of file ClpNetworkMatrix.hpp.
|
Default constructor. Definition at line 26 of file ClpNetworkMatrix.cpp. References elements_, indices_, numberColumns_, numberRows_, ClpMatrixBase::setType(), and trueNetwork_. Referenced by clone().
00027 : ClpMatrixBase() 00028 { 00029 setType(11); 00030 elements_ = NULL; 00031 starts_ = NULL; 00032 lengths_=NULL; 00033 indices_=NULL; 00034 numberRows_=0; 00035 numberColumns_=0; 00036 trueNetwork_=false; 00037 } |
|
Constructor from two arrays Definition at line 40 of file ClpNetworkMatrix.cpp. References elements_, indices_, numberColumns_, numberRows_, ClpMatrixBase::setType(), and trueNetwork_.
00042 : ClpMatrixBase() 00043 { 00044 setType(11); 00045 elements_ = NULL; 00046 starts_ = NULL; 00047 lengths_=NULL; 00048 indices_=new int[2*numberColumns];; 00049 numberRows_=-1; 00050 numberColumns_=numberColumns; 00051 trueNetwork_=true; 00052 int iColumn; 00053 CoinBigIndex j=0; 00054 for (iColumn=0;iColumn<numberColumns_;iColumn++, j+=2) { 00055 int iRow = head[iColumn]; 00056 numberRows_ = max(numberRows_,iRow); 00057 indices_[j]=iRow; 00058 iRow = tail[iColumn]; 00059 numberRows_ = max(numberRows_,iRow); 00060 indices_[j+1]=iRow; 00061 } 00062 numberRows_++; 00063 } |
|
Destructor Definition at line 181 of file ClpNetworkMatrix.cpp. References elements_, and indices_.
|
|
The copy constructor. Definition at line 67 of file ClpNetworkMatrix.cpp. References elements_, indices_, numberColumns_, numberRows_, and trueNetwork_.
00068 : ClpMatrixBase(rhs) 00069 { 00070 elements_ = NULL; 00071 starts_ = NULL; 00072 lengths_=NULL; 00073 indices_=NULL; 00074 numberRows_=rhs.numberRows_; 00075 numberColumns_=rhs.numberColumns_; 00076 trueNetwork_=rhs.trueNetwork_; 00077 if (numberColumns_) { 00078 indices_ = new int [ 2*numberColumns_]; 00079 memcpy(indices_,rhs.indices_,2*numberColumns_*sizeof(int)); 00080 } 00081 } |
|
The copy constructor from an CoinNetworkMatrix. Definition at line 83 of file ClpNetworkMatrix.cpp. References elements_, indices_, numberColumns_, numberRows_, ClpMatrixBase::setType(), and trueNetwork_.
00084 : ClpMatrixBase() 00085 { 00086 setType(11); 00087 elements_ = NULL; 00088 starts_ = NULL; 00089 lengths_=NULL; 00090 indices_=NULL; 00091 int iColumn; 00092 assert (rhs.isColOrdered()); 00093 // get matrix data pointers 00094 const int * row = rhs.getIndices(); 00095 const CoinBigIndex * columnStart = rhs.getVectorStarts(); 00096 const int * columnLength = rhs.getVectorLengths(); 00097 const double * elementByColumn = rhs.getElements(); 00098 numberColumns_ = rhs.getNumCols(); 00099 int goodNetwork=1; 00100 numberRows_=-1; 00101 indices_ = new int[2*numberColumns_]; 00102 CoinBigIndex j=0; 00103 for (iColumn=0;iColumn<numberColumns_;iColumn++, j+=2) { 00104 CoinBigIndex k=columnStart[iColumn]; 00105 int iRow; 00106 switch (columnLength[iColumn]) { 00107 case 0: 00108 goodNetwork=-1; // not classic network 00109 indices_[j]=-1; 00110 indices_[j+1]=-1; 00111 break; 00112 00113 case 1: 00114 goodNetwork=-1; // not classic network 00115 if (fabs(elementByColumn[k]-1.0)<1.0e-10) { 00116 indices_[j] = -1; 00117 iRow = row[k]; 00118 numberRows_ = max(numberRows_,iRow); 00119 indices_[j+1]=iRow; 00120 } else if (fabs(elementByColumn[k]+1.0)<1.0e-10) { 00121 indices_[j+1] = -1; 00122 iRow = row[k]; 00123 numberRows_ = max(numberRows_,iRow); 00124 indices_[j]=iRow; 00125 } else { 00126 goodNetwork = 0; // not a network 00127 } 00128 break; 00129 00130 case 2: 00131 if (fabs(elementByColumn[k]-1.0)<1.0e-10) { 00132 if (fabs(elementByColumn[k+1]+1.0)<1.0e-10) { 00133 iRow = row[k]; 00134 numberRows_ = max(numberRows_,iRow); 00135 indices_[j+1]=iRow; 00136 iRow = row[k+1]; 00137 numberRows_ = max(numberRows_,iRow); 00138 indices_[j] = iRow; 00139 } else { 00140 goodNetwork = 0; // not a network 00141 } 00142 } else if (fabs(elementByColumn[k]+1.0)<1.0e-10) { 00143 if (fabs(elementByColumn[k+1]-1.0)<1.0e-10) { 00144 iRow = row[k]; 00145 numberRows_ = max(numberRows_,iRow); 00146 indices_[j]=iRow; 00147 iRow = row[k+1]; 00148 numberRows_ = max(numberRows_,iRow); 00149 indices_[j+1] = iRow; 00150 } else { 00151 goodNetwork = 0; // not a network 00152 } 00153 } else { 00154 goodNetwork = 0; // not a network 00155 } 00156 break; 00157 00158 default: 00159 goodNetwork = 0; // not a network 00160 break; 00161 } 00162 if (!goodNetwork) 00163 break; 00164 } 00165 if (!goodNetwork) { 00166 delete [] indices_; 00167 // put in message 00168 printf("Not a network - can test if indices_ null\n"); 00169 indices_=NULL; 00170 numberRows_=0; 00171 numberColumns_=0; 00172 } else { 00173 numberRows_ ++; // correct 00174 trueNetwork_ = goodNetwork>0; 00175 } 00176 } |
|
Adds multiple of a column into an CoinIndexedvector You can use quickAdd to add to vector Implements ClpMatrixBase. Definition at line 704 of file ClpNetworkMatrix.cpp. References indices_, and CoinIndexedVector::quickAdd().
|
|
Delete the columns whose indices are listed in Implements ClpMatrixBase. Definition at line 773 of file ClpNetworkMatrix.cpp.
00774 {
00775 std::cerr<<"deleteCols not implemented in ClpNetworkMatrix"<<std::endl;
00776 abort();
00777 }
|
|
Delete the rows whose indices are listed in Implements ClpMatrixBase. Definition at line 779 of file ClpNetworkMatrix.cpp.
00780 {
00781 std::cerr<<"deleteRows not implemented in ClpNetworkMatrix"<<std::endl;
00782 abort();
00783 }
|
|
Given positive integer weights for each row fills in sum of weights for each column (and slack). Returns weights vector Reimplemented from ClpMatrixBase. Definition at line 789 of file ClpNetworkMatrix.cpp. References indices_, ClpModel::numberColumns(), and ClpModel::numberRows().
00790 { 00791 int numberRows = model->numberRows(); 00792 int numberColumns =model->numberColumns(); 00793 int number = numberRows+numberColumns; 00794 CoinBigIndex * weights = new CoinBigIndex[number]; 00795 int i; 00796 for (i=0;i<numberColumns;i++) { 00797 CoinBigIndex j=i<<1; 00798 CoinBigIndex count=0; 00799 int iRowM = indices_[j]; 00800 int iRowP = indices_[j+1]; 00801 if (iRowM>=0) { 00802 count += inputWeights[iRowM]; 00803 } 00804 if (iRowP>=0) { 00805 count += inputWeights[iRowP]; 00806 } 00807 weights[i]=count; 00808 } 00809 for (i=0;i<numberRows;i++) { 00810 weights[i+numberColumns]=inputWeights[i]; 00811 } 00812 return weights; 00813 } |
|
If element NULL returns number of elements in column part of basis, If not NULL fills in as well Implements ClpMatrixBase. Definition at line 599 of file ClpNetworkMatrix.cpp. References indices_, and trueNetwork_.
00605 { 00606 int i; 00607 CoinBigIndex numberElements=0; 00608 if (elementU!=NULL) { 00609 if (trueNetwork_) { 00610 for (i=0;i<numberColumnBasic;i++) { 00611 int iColumn = whichColumn[i]; 00612 CoinBigIndex j=iColumn<<1; 00613 int iRowM = indices_[j]; 00614 int iRowP = indices_[j+1]; 00615 indexRowU[numberElements]=iRowM; 00616 indexColumnU[numberElements]=numberBasic; 00617 elementU[numberElements]=-1.0; 00618 indexRowU[numberElements+1]=iRowP; 00619 indexColumnU[numberElements+1]=numberBasic; 00620 elementU[numberElements+1]=1.0; 00621 numberElements+=2; 00622 numberBasic++; 00623 } 00624 } else { 00625 for (i=0;i<numberColumnBasic;i++) { 00626 int iColumn = whichColumn[i]; 00627 CoinBigIndex j=iColumn<<1; 00628 int iRowM = indices_[j]; 00629 int iRowP = indices_[j+1]; 00630 if (iRowM>=0) { 00631 indexRowU[numberElements]=iRowM; 00632 indexColumnU[numberElements]=numberBasic; 00633 elementU[numberElements++]=-1.0; 00634 } 00635 if (iRowP>=0) { 00636 indexRowU[numberElements]=iRowP; 00637 indexColumnU[numberElements]=numberBasic; 00638 elementU[numberElements++]=1.0; 00639 } 00640 numberBasic++; 00641 } 00642 } 00643 } else { 00644 if (trueNetwork_) { 00645 numberElements = 2*numberColumnBasic; 00646 } else { 00647 for (i=0;i<numberColumnBasic;i++) { 00648 int iColumn = whichColumn[i]; 00649 CoinBigIndex j=iColumn<<1; 00650 int iRowM = indices_[j]; 00651 int iRowP = indices_[j+1]; 00652 if (iRowM>=0) 00653 numberElements ++; 00654 if (iRowP>=0) 00655 numberElements ++; 00656 } 00657 } 00658 } 00659 return numberElements; 00660 } |
|
A vector containing the elements in the packed matrix. Note that there might be gaps in this list, entries that do not belong to any major-dimension vector. To get the actual elements one should look at this vector together with vectorStarts and vectorLengths. Implements ClpMatrixBase. Definition at line 731 of file ClpNetworkMatrix.cpp. References elements_, numberColumns_, and trueNetwork_. Referenced by getPackedMatrix().
00732 { 00733 assert (trueNetwork_); // fix later 00734 if (!elements_) { 00735 elements_ = new double [2*numberColumns_]; 00736 int i; 00737 for (i=0;i<2*numberColumns_;i+=2) { 00738 elements_[i]=-1.0; 00739 elements_[i+1]=1.0; 00740 } 00741 } 00742 return elements_; 00743 } |
|
A vector containing the minor indices of the elements in the packed matrix. Note that there might be gaps in this list, entries that do not belong to any major-dimension vector. To get the actual elements one should look at this vector together with vectorStarts and vectorLengths. Implements ClpMatrixBase. Definition at line 43 of file ClpNetworkMatrix.hpp. References indices_.
00044 { return indices_;}; |
|
Number of columns. Implements ClpMatrixBase. Definition at line 29 of file ClpNetworkMatrix.hpp. References numberColumns_.
00029 { return numberColumns_; } |
|
Number of entries in the packed matrix. Implements ClpMatrixBase. Definition at line 26 of file ClpNetworkMatrix.hpp. References numberColumns_.
00027 { return 2*numberColumns_; } |
|
Number of rows. Implements ClpMatrixBase. Definition at line 31 of file ClpNetworkMatrix.hpp. References numberRows_.
00031 { return numberRows_; }; |
|
The lengths of the major-dimension vectors. Implements ClpMatrixBase. Definition at line 760 of file ClpNetworkMatrix.cpp. References numberColumns_, and trueNetwork_. Referenced by getPackedMatrix().
00761 { 00762 assert (trueNetwork_); // fix later 00763 if (!lengths_) { 00764 lengths_ = new int [numberColumns_]; 00765 int i; 00766 for (i=0;i<numberColumns_;i++) { 00767 lengths_[i]=2; 00768 } 00769 } 00770 return lengths_; 00771 } |
|
Whether the packed matrix is column major ordered or not. Implements ClpMatrixBase. Definition at line 24 of file ClpNetworkMatrix.hpp.
00024 { return true; } |
|
Returns number of elements in basis column is basic if entry >=0 Implements ClpMatrixBase. Definition at line 520 of file ClpNetworkMatrix.cpp. References indices_, numberColumns_, and trueNetwork_.
00521 { 00522 int i; 00523 CoinBigIndex numberElements=0; 00524 if (trueNetwork_) { 00525 for (i=0;i<numberColumns_;i++) { 00526 if (columnIsBasic[i]>=0) 00527 numberElements ++; 00528 } 00529 numberElements *= 2; 00530 } else { 00531 for (i=0;i<numberColumns_;i++) { 00532 if (columnIsBasic[i]>=0) { 00533 CoinBigIndex j=i<<1; 00534 int iRowM = indices_[j]; 00535 int iRowP = indices_[j+1]; 00536 if (iRowM>=0) 00537 numberElements ++; 00538 if (iRowP>=0) 00539 numberElements ++; 00540 } 00541 } 00542 } 00543 return numberElements; 00544 } |
|
Returns largest and smallest elements of both signs. Largest refers to largest absolute value. Reimplemented from ClpMatrixBase. Definition at line 818 of file ClpNetworkMatrix.cpp.
00820 { 00821 smallestNegative=-1.0; 00822 largestNegative=-1.0; 00823 smallestPositive=1.0; 00824 largestPositive=1.0; 00825 } |
|
Returns a new matrix in reverse order without gaps Reimplemented from ClpMatrixBase. Definition at line 225 of file ClpNetworkMatrix.cpp. References indices_, numberColumns_, numberRows_, and ClpPlusMinusOneMatrix::passInCopy().
00226 { 00227 // count number in each row 00228 int * tempP = new int [numberRows_]; 00229 int * tempN = new int [numberRows_]; 00230 memset(tempP,0,numberRows_*sizeof(int)); 00231 memset(tempN,0,numberRows_*sizeof(int)); 00232 CoinBigIndex j=0; 00233 int i; 00234 for (i=0;i<numberColumns_;i++,j+=2) { 00235 int iRow = indices_[j]; 00236 tempN[iRow]++; 00237 iRow = indices_[j+1]; 00238 tempP[iRow]++; 00239 } 00240 int * newIndices = new int [2*numberColumns_]; 00241 int * newP = new int [numberRows_+1]; 00242 int * newN = new int[numberRows_]; 00243 int iRow; 00244 j=0; 00245 // do starts 00246 for (iRow=0;iRow<numberRows_;iRow++) { 00247 newP[iRow]=j; 00248 j += tempP[iRow]; 00249 tempP[iRow]=newP[iRow]; 00250 newN[iRow] = j; 00251 j += tempN[iRow]; 00252 tempN[iRow]=newN[iRow]; 00253 } 00254 newP[numberRows_]=j; 00255 j=0; 00256 for (i=0;i<numberColumns_;i++,j+=2) { 00257 int iRow = indices_[j]; 00258 int put = tempN[iRow]; 00259 newIndices[put++] = i; 00260 tempN[iRow] = put; 00261 iRow = indices_[j+1]; 00262 put = tempP[iRow]; 00263 newIndices[put++] = i; 00264 tempP[iRow] = put; 00265 } 00266 delete [] tempP; 00267 delete [] tempN; 00268 ClpPlusMinusOneMatrix * newCopy = new ClpPlusMinusOneMatrix(); 00269 newCopy->passInCopy(numberRows_, numberColumns_, 00270 false, newIndices, newP, newN); 00271 return newCopy; 00272 } |
|
Return Implements ClpMatrixBase. Definition at line 477 of file ClpNetworkMatrix.cpp. References CoinIndexedVector::clear(), CoinIndexedVector::denseVector(), CoinIndexedVector::getIndices(), CoinIndexedVector::getNumElements(), indices_, CoinIndexedVector::packedMode(), CoinIndexedVector::setPacked(), and trueNetwork_.
00481 { 00482 columnArray->clear(); 00483 double * pi = rowArray->denseVector(); 00484 double * array = columnArray->denseVector(); 00485 int jColumn; 00486 int numberToDo = y->getNumElements(); 00487 const int * which = y->getIndices(); 00488 assert (!rowArray->packedMode()); 00489 columnArray->setPacked(); 00490 if (trueNetwork_) { 00491 for (jColumn=0;jColumn<numberToDo;jColumn++) { 00492 int iColumn = which[jColumn]; 00493 double value = 0.0; 00494 CoinBigIndex j=iColumn<<1; 00495 int iRowM = indices_[j]; 00496 int iRowP = indices_[j+1]; 00497 value -= pi[iRowM]; 00498 value += pi[iRowP]; 00499 array[jColumn]=value; 00500 } 00501 } else { 00502 // skip negative rows 00503 for (jColumn=0;jColumn<numberToDo;jColumn++) { 00504 int iColumn = which[jColumn]; 00505 double value = 0.0; 00506 CoinBigIndex j=iColumn<<1; 00507 int iRowM = indices_[j]; 00508 int iRowP = indices_[j+1]; 00509 if (iRowM>=0) 00510 value -= pi[iRowM]; 00511 if (iRowP>=0) 00512 value += pi[iRowP]; 00513 array[jColumn]=value; 00514 } 00515 } 00516 } |
|
Return
Implements ClpMatrixBase. Definition at line 275 of file ClpNetworkMatrix.cpp. References indices_, numberColumns_, and trueNetwork_. Referenced by times().
00277 { 00278 int iColumn; 00279 CoinBigIndex j=0; 00280 if (trueNetwork_) { 00281 for (iColumn=0;iColumn<numberColumns_;iColumn++,j+=2) { 00282 double value = scalar*x[iColumn]; 00283 if (value) { 00284 int iRowM = indices_[j]; 00285 int iRowP = indices_[j+1]; 00286 y[iRowM] -= value; 00287 y[iRowP] += value; 00288 } 00289 } 00290 } else { 00291 // skip negative rows 00292 for (iColumn=0;iColumn<numberColumns_;iColumn++,j+=2) { 00293 double value = scalar*x[iColumn]; 00294 if (value) { 00295 int iRowM = indices_[j]; 00296 int iRowP = indices_[j+1]; 00297 if (iRowM>=0) 00298 y[iRowM] -= value; 00299 if (iRowP>=0) 00300 y[iRowP] += value; 00301 } 00302 } 00303 } 00304 } |
|
Return Implements ClpMatrixBase. Definition at line 355 of file ClpNetworkMatrix.cpp. References CoinIndexedVector::capacity(), CoinIndexedVector::clear(), CoinIndexedVector::denseVector(), ClpSimplex::factorization(), CoinIndexedVector::getIndices(), CoinIndexedVector::getNumElements(), indices_, ClpModel::numberColumns(), numberColumns_, ClpModel::numberRows(), CoinIndexedVector::packedMode(), ClpModel::rowCopy(), CoinIndexedVector::setNumElements(), ClpPlusMinusOneMatrix::transposeTimesByRow(), and trueNetwork_.
00359 { 00360 // we know it is not scaled 00361 columnArray->clear(); 00362 double * pi = rowArray->denseVector(); 00363 int numberNonZero=0; 00364 int * index = columnArray->getIndices(); 00365 double * array = columnArray->denseVector(); 00366 int numberInRowArray = rowArray->getNumElements(); 00367 // maybe I need one in OsiSimplex 00368 double zeroTolerance = model->factorization()->zeroTolerance(); 00369 int numberRows = model->numberRows(); 00370 ClpPlusMinusOneMatrix* rowCopy = 00371 dynamic_cast< ClpPlusMinusOneMatrix*>(model->rowCopy()); 00372 bool packed = rowArray->packedMode(); 00373 double factor = 0.3; 00374 // We may not want to do by row if there may be cache problems 00375 int numberColumns = model->numberColumns(); 00376 // It would be nice to find L2 cache size - for moment 512K 00377 // Be slightly optimistic 00378 if (numberColumns*sizeof(double)>1000000) { 00379 if (numberRows*10<numberColumns) 00380 factor=0.1; 00381 else if (numberRows*4<numberColumns) 00382 factor=0.15; 00383 else if (numberRows*2<numberColumns) 00384 factor=0.2; 00385 //if (model->numberIterations()%50==0) 00386 //printf("%d nonzero\n",numberInRowArray); 00387 } 00388 if (numberInRowArray>factor*numberRows||!rowCopy) { 00389 // do by column 00390 int iColumn; 00391 assert (!y->getNumElements()); 00392 CoinBigIndex j=0; 00393 if (packed) { 00394 // need to expand pi into y 00395 assert(y->capacity()>=numberRows); 00396 double * piOld = pi; 00397 pi = y->denseVector(); 00398 const int * whichRow = rowArray->getIndices(); 00399 int i; 00400 // modify pi so can collapse to one loop 00401 for (i=0;i<numberInRowArray;i++) { 00402 int iRow = whichRow[i]; 00403 pi[iRow]=scalar*piOld[i]; 00404 } 00405 if (trueNetwork_) { 00406 for (iColumn=0;iColumn<numberColumns_;iColumn++,j+=2) { 00407 double value = 0.0; 00408 int iRowM = indices_[j]; 00409 int iRowP = indices_[j+1]; 00410 value -= pi[iRowM]; 00411 value += pi[iRowP]; 00412 if (fabs(value)>zeroTolerance) { 00413 array[numberNonZero]=value; 00414 index[numberNonZero++]=iColumn; 00415 } 00416 } 00417 } else { 00418 // skip negative rows 00419 for (iColumn=0;iColumn<numberColumns_;iColumn++,j+=2) { 00420 double value = 0.0; 00421 int iRowM = indices_[j]; 00422 int iRowP = indices_[j+1]; 00423 if (iRowM>=0) 00424 value -= pi[iRowM]; 00425 if (iRowP>=0) 00426 value += pi[iRowP]; 00427 if (fabs(value)>zeroTolerance) { 00428 array[numberNonZero]=value; 00429 index[numberNonZero++]=iColumn; 00430 } 00431 } 00432 } 00433 for (i=0;i<numberInRowArray;i++) { 00434 int iRow = whichRow[i]; 00435 pi[iRow]=0.0; 00436 } 00437 } else { 00438 if (trueNetwork_) { 00439 for (iColumn=0;iColumn<numberColumns_;iColumn++,j+=2) { 00440 double value = 0.0; 00441 int iRowM = indices_[j]; 00442 int iRowP = indices_[j+1]; 00443 value -= scalar*pi[iRowM]; 00444 value += scalar*pi[iRowP]; 00445 if (fabs(value)>zeroTolerance) { 00446 index[numberNonZero++]=iColumn; 00447 array[iColumn]=value; 00448 } 00449 } 00450 } else { 00451 // skip negative rows 00452 for (iColumn=0;iColumn<numberColumns_;iColumn++,j+=2) { 00453 double value = 0.0; 00454 int iRowM = indices_[j]; 00455 int iRowP = indices_[j+1]; 00456 if (iRowM>=0) 00457 value -= scalar*pi[iRowM]; 00458 if (iRowP>=0) 00459 value += scalar*pi[iRowP]; 00460 if (fabs(value)>zeroTolerance) { 00461 index[numberNonZero++]=iColumn; 00462 array[iColumn]=value; 00463 } 00464 } 00465 } 00466 } 00467 columnArray->setNumElements(numberNonZero); 00468 } else { 00469 // do by row 00470 rowCopy->transposeTimesByRow(model, scalar, rowArray, y, columnArray); 00471 } 00472 } |
|
Return
Implements ClpMatrixBase. Definition at line 306 of file ClpNetworkMatrix.cpp. References indices_, numberColumns_, and trueNetwork_. Referenced by transposeTimes().
00308 { 00309 int iColumn; 00310 CoinBigIndex j=0; 00311 if (trueNetwork_) { 00312 for (iColumn=0;iColumn<numberColumns_;iColumn++,j+=2) { 00313 double value = y[iColumn]; 00314 int iRowM = indices_[j]; 00315 int iRowP = indices_[j+1]; 00316 value -= scalar*x[iRowM]; 00317 value += scalar*x[iRowP]; 00318 y[iColumn] = value; 00319 } 00320 } else { 00321 // skip negative rows 00322 for (iColumn=0;iColumn<numberColumns_;iColumn++,j+=2) { 00323 double value = y[iColumn]; 00324 int iRowM = indices_[j]; 00325 int iRowP = indices_[j+1]; 00326 if (iRowM>=0) 00327 value -= scalar*x[iRowM]; 00328 if (iRowP>=0) 00329 value += scalar*x[iRowP]; 00330 y[iColumn] = value; 00331 } 00332 } 00333 } |
|
Unpacks a column into an CoinIndexedvector Implements ClpMatrixBase. Definition at line 664 of file ClpNetworkMatrix.cpp. References CoinIndexedVector::add(), and indices_.
|
|
Unpacks a column into an CoinIndexedvector in packed format Note that model is NOT const. Bounds and objective could be modified if doing column generation (just for this variable) Implements ClpMatrixBase. Definition at line 680 of file ClpNetworkMatrix.cpp. References CoinIndexedVector::denseVector(), CoinIndexedVector::getIndices(), indices_, CoinIndexedVector::setNumElements(), and CoinIndexedVector::setPackedMode().
00683 { 00684 int * index = rowArray->getIndices(); 00685 double * array = rowArray->denseVector(); 00686 int number = 0; 00687 CoinBigIndex j=iColumn<<1; 00688 int iRowM = indices_[j]; 00689 int iRowP = indices_[j+1]; 00690 if (iRowM>=0) { 00691 array[number]=-1.0; 00692 index[number++]=iRowM; 00693 } 00694 if (iRowP>=0) { 00695 array[number]=1.0; 00696 index[number++]=iRowP; 00697 } 00698 rowArray->setNumElements(number); 00699 rowArray->setPackedMode(true); 00700 } |