Changeset 927 for stable/1.3
 Timestamp:
 Feb 27, 2007 3:26:29 PM (14 years ago)
 Location:
 stable/1.3/Clp
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

stable/1.3/Clp/examples/sprintGub.cpp
r924 r927 11 11 const int * whichColumn, const int * startSet, 12 12 const char * rowType, 13 int numberGub,double smallFactor )13 int numberGub,double smallFactor,int * sort, int numberSort) 14 14 { 15 15 int numberColumns = model.numberColumns(); … … 17 17 18 18 // We will need an array to choose variables. 19 int * sort = new int [numberColumns];20 19 float * weight = new float [numberColumns]; 21 20 const int * ordRow = setToRow+numberGub; 22 int numberSort=0;23 // Set up initial list24 numberSort=numberRows;25 int i;26 for (i=0;i<numberSort;i++)27 sort[i] = i;28 21 // and basic 29 22 int nOrd=numberColumns  startSet[numberGub]; 30 int i Row,iColumn;23 int i,iRow,iColumn; 31 24 const double * columnLower = model.columnLower(); 32 25 const double * columnUpper = model.columnUpper(); 33 26 double * fullSolution = model.primalColumnSolution(); 34 CoinPackedMatrix * matrix = model.matrix();35 const int * columnStart = matrix>getVectorStarts();36 for (iColumn=numberRows;iColumn<numberColumns;iColumn++) {37 if(model.getColumnStatus(iColumn)==ClpSimplex::basic38 columnStart[iColumn+1]==columnStart[iColumn]+1) {39 sort[numberSort++]=iColumn;40 } else if (fullSolution[iColumn]>columnLower[iColumn]+1.0e7&&41 fullSolution[iColumn]<columnUpper[iColumn]1.0e7) {42 sort[numberSort++]=iColumn;43 }44 if (fullSolution[iColumn]>columnLower[iColumn]1.0e7&&45 fullSolution[iColumn]<columnUpper[iColumn]+1.0e7) {46 } else {47 printf("bad %d %g %g %g\n",iColumn,columnLower[iColumn],48 fullSolution[iColumn],columnUpper[iColumn]);49 }50 if (fullSolution[iColumn]<columnLower[iColumn])51 fullSolution[iColumn]=columnLower[iColumn];52 if (fullSolution[iColumn]>columnUpper[iColumn])53 fullSolution[iColumn]=columnUpper[iColumn];54 }55 27 double time1 = CoinCpuTime(); 56 28 … … 74 46 // Basic counts for each set 75 47 int * counts = new int[numberGub]; 76 memset(counts,0,numberGub*sizeof(int)); 48 // For first pass  say all have counts 49 for (i=0;i<numberGub;i++) 50 counts[i]=1; 77 51 // Negative dj counts 78 52 int * negCounts = new int[numberGub]; … … 154 128 model.setColumnStatus(kColumn,small.getColumnStatus(iColumn)); 155 129 fullSolution[kColumn]=solution[iColumn]; 156 if (fullSolution[ iColumn]>columnLower[iColumn]1.0e7&&157 fullSolution[ iColumn]<columnUpper[iColumn]+1.0e7) {130 if (fullSolution[kColumn]>columnLower[kColumn]1.0e7&& 131 fullSolution[kColumn]<columnUpper[kColumn]+1.0e7) { 158 132 } else { 159 133 printf("bad2 %d\n",iColumn); … … 162 136 model.setObjectiveValue(small.objectiveValue()); 163 137 double * rowSol1 = model.primalRowSolution(); 164 double * rowSol2 = small.primalRowSolution(); 138 memset (rowSol1,0,numberRows*sizeof(double)); 139 model.times(1.0,model.primalColumnSolution(),rowSol1); 140 //double * rowSol2 = small.primalRowSolution(); 165 141 double * rowPi1 = model.dualRowSolution(); 166 142 double * rowPi2 = small.dualRowSolution(); … … 168 144 int jRow = whichRows[iRow]; 169 145 model.setRowStatus(jRow,small.getRowStatus(iRow)); 170 rowSol1[jRow] = rowSol2[iRow];146 //rowSol1[jRow] = rowSol2[iRow]; 171 147 rowPi1[jRow] = rowPi2[iRow]; 172 148 } … … 407 383 delete [] negSum; 408 384 delete [] weight; 409 delete [] sort;410 385 delete [] whichRows; 411 386 printf("Sprint took %g seconds\n",CoinCpuTime()time1); … … 507 482 // Get initial list in some magical way 508 483 // Add in your own coding here 509 abort(); 484 int iColumn; 485 const double * columnLower = model.columnLower(); 486 const double * columnUpper = model.columnUpper(); 487 double * fullSolution = model.primalColumnSolution(); 488 CoinPackedMatrix * matrix = model.matrix(); 489 const int * columnStart = matrix>getVectorStarts(); 490 int numberColumns = model.numberColumns(); 491 for (iColumn=numberRows;iColumn<numberColumns;iColumn++) { 492 if(model.getColumnStatus(iColumn)==ClpSimplex::basic 493 columnStart[iColumn+1]==columnStart[iColumn]+1) { 494 sort[numberSort++]=iColumn; 495 } else if (fullSolution[iColumn]>columnLower[iColumn]+1.0e7&& 496 fullSolution[iColumn]<columnUpper[iColumn]1.0e7) { 497 sort[numberSort++]=iColumn; 498 } 499 if (fullSolution[iColumn]>columnLower[iColumn]1.0e7&& 500 fullSolution[iColumn]<columnUpper[iColumn]+1.0e7) { 501 } else { 502 printf("bad %d %g %g %g\n",iColumn,columnLower[iColumn], 503 fullSolution[iColumn],columnUpper[iColumn]); 504 } 505 if (fullSolution[iColumn]<columnLower[iColumn]) 506 fullSolution[iColumn]=columnLower[iColumn]; 507 if (fullSolution[iColumn]>columnUpper[iColumn]) 508 fullSolution[iColumn]=columnUpper[iColumn]; 509 } 510 510 } 511 511 // gub stuff … … 572 572 nOrd=numberColumnsstartSet[numberGub]; 573 573 printf("%d ordinary columns, %d gub sets\n",nOrd,numberGub); 574 if (nOrd>numberRows) { 575 printf("This algorithm only designed for problems with few ordinary columns\n"); 576 exit(77); 577 } 574 578 assert (numberGub<numberRows); // otherwise array bad 575 579 char * rowType = new char[numberRows]; 576 580 memset(rowType,0,numberRows); 577 581 sprint( model, setToRow, whichGub, 578 whichColumn, startSet, rowType, numberGub,3 );582 whichColumn, startSet, rowType, numberGub,3,sort,numberSort); 579 583 delete [] setToRow; 580 584 delete [] whichGub; 
stable/1.3/Clp/src/ClpPackedMatrix.cpp
r800 r927 2864 2864 numberErrors=matrix_>appendCols(number,starts,index,element,numberOther); 2865 2865 } 2866 numberActiveColumns_ = matrix_>getNumCols(); 2866 2867 return numberErrors; 2867 2868 }
Note: See TracChangeset
for help on using the changeset viewer.