Changeset 93 for trunk


Ignore:
Timestamp:
Jan 13, 2003 4:29:31 PM (17 years ago)
Author:
forrest
Message:

Check for duplicate elements

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ClpMessage.cpp

    r86 r93  
    6767  {CLP_BAD_MATRIX,6003,0,"Matrix has %d large values, first at column %d, row %d is %g"},
    6868  {CLP_LOOP,6004,0,"Can't get out of loop - stopping (Debug) (Don't panic, OsiClpSolverInterface will resolve)"},
    69   {CLP_IMPORT_RESULT,18,1,"Model was imported from %s in %g seconds"},
     69  {CLP_DUPLICATEELEMENTS,26,0,"Matrix will be packed to eliminate %d duplicate elements"},
     70  {CLP_IMPORT_RESULT,27,1,"Model was imported from %s in %g seconds"},
    7071  {CLP_IMPORT_ERRORS,3001,1," There were %d errors when importing model from %s"},
    7172  {CLP_EMPTY_PROBLEM,3002,0,"Not solving empty problem - %d rows, %d columns and %d elements"},
  • trunk/ClpPackedMatrix.cpp

    r63 r93  
    822822  CoinBigIndex numberLarge=0;;
    823823  CoinBigIndex numberSmall=0;;
     824  CoinBigIndex numberDuplicate=0;;
    824825  int firstBadColumn=-1;
    825826  int firstBadRow=-1;
     
    831832  const double * elementByColumn = matrix_->getElements();
    832833  int numberColumns = matrix_->getNumCols();
     834  int numberRows = matrix_->getNumRows();
     835  int * mark = new int [numberRows];
     836  int i;
     837  for (i=0;i<numberRows;i++)
     838    mark[i]=-1;
    833839  for (iColumn=0;iColumn<numberColumns;iColumn++) {
    834840    CoinBigIndex j;
     
    836842         j<columnStart[iColumn]+columnLength[iColumn];j++) {
    837843      double value = fabs(elementByColumn[j]);
     844      int iRow = row[j];
     845      if (mark[iRow]==-1) {
     846        mark[iRow]=j;
     847      } else {
     848        // duplicate
     849        numberDuplicate++;
     850      }
    838851      //printf("%d %d %d %g\n",iColumn,j,row[j],elementByColumn[j]);
    839852      if (value<smallest) {
     
    848861      }
    849862    }
    850   }
     863    //clear mark
     864    for (j=columnStart[iColumn];
     865         j<columnStart[iColumn]+columnLength[iColumn];j++) {
     866      int iRow = row[j];
     867      mark[iRow]=-1;
     868    }
     869  }
     870  delete [] mark;
    851871  if (numberLarge) {
    852872    model->messageHandler()->message(CLP_BAD_MATRIX,model->messages())
     
    856876    return false;
    857877  }
    858   if (numberSmall) {
     878  if (numberSmall)
    859879    model->messageHandler()->message(CLP_SMALLELEMENTS,model->messages())
    860880      <<numberSmall
    861881      <<CoinMessageEol;
     882  if (numberDuplicate)
     883    model->messageHandler()->message(CLP_DUPLICATEELEMENTS,model->messages())
     884      <<numberDuplicate
     885      <<CoinMessageEol;
     886  if (numberDuplicate)
     887    matrix_->eliminateDuplicates(smallest);
     888  else if (numberSmall)
    862889    matrix_->compress(smallest);
    863   }
    864890  return true;
    865891}
  • trunk/include/ClpMessage.hpp

    r63 r93  
    5151  CLP_POSSIBLELOOP,
    5252  CLP_SMALLELEMENTS,
     53  CLP_DUPLICATEELEMENTS,
    5354  CLP_SIMPLEX_HOUSE1,
    5455  CLP_SIMPLEX_HOUSE2,
Note: See TracChangeset for help on using the changeset viewer.