Changeset 560


Ignore:
Timestamp:
Mar 14, 2005 10:40:08 AM (14 years ago)
Author:
forrest
Message:

CoinAssert? and check column numbers

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/ClpModel.cpp

    r559 r560  
    366366    delete [] objective;
    367367    delete [] integerType;
    368       delete [] associated;
    369       if (numberErrors)
    370         handler_->message(CLP_BAD_STRING_VALUES,messages_)
    371           <<numberErrors
    372           <<CoinMessageEol;
     368    delete [] associated;
     369    if (numberErrors)
     370      handler_->message(CLP_BAD_STRING_VALUES,messages_)
     371        <<numberErrors
     372        <<CoinMessageEol;
    373373  }
    374374  matrix_->setDimensions(numberRows_,numberColumns_);
     
    436436  if (upper>1.0e27)
    437437    upper=COIN_DBL_MAX;
    438   assert (upper>=lower);
     438  CoinAssert (upper>=lower);
    439439  rowLower_[elementIndex] = lower;
    440440  rowUpper_[elementIndex] = upper;
     
    464464    if (upper[iRow]>1.0e27)
    465465      upper[iRow]=COIN_DBL_MAX;
    466     assert (upper[iRow]>=lower[iRow]);
     466    CoinAssert (upper[iRow]>=lower[iRow]);
    467467  }
    468468}
     
    519519  columnLower_[elementIndex] = lower;
    520520  columnUpper_[elementIndex] = upper;
    521   assert (upper>=lower);
     521  CoinAssert (upper>=lower);
    522522  whatsChanged_ = 0; // Can't be sure (use ClpSimplex to keep)
    523523}
     
    541541    lower[iColumn]= *boundList++;
    542542    upper[iColumn]= *boundList++;
    543     assert (upper[iColumn]>=lower[iColumn]);
     543    CoinAssert (upper[iColumn]>=lower[iColumn]);
    544544    if (lower[iColumn]<-1.0e27)
    545545      lower[iColumn]=-COIN_DBL_MAX;
     
    12901290ClpModel::addRows(const CoinBuild & buildObject,bool tryPlusMinusOne)
    12911291{
    1292   assert (buildObject.type()==0); // check correct
     1292  CoinAssertHint (buildObject.type()==0,"Looks as if both addRows and addCols being used"); // check correct
    12931293  int number = buildObject.numberRows();
    12941294  if (number) {
     
    13681368      // check size
    13691369      int numberColumns = maxColumn+1;
    1370       assert (numberColumns<=numberColumns_);
     1370      CoinAssertHint (numberColumns<=numberColumns_,
     1371                      "rows having column indices >= numberColumns_");
    13711372      size=0;
    13721373      int iColumn;
     
    14731474      CoinBigIndex * startNegative = NULL;
    14741475      int numberColumns = modelObject.numberColumns();
    1475       if ((!matrix_||!matrix_->getNumElements())
    1476           &&!numberRows&&tryPlusMinusOne) {
     1476      if ((!matrix_||!matrix_->getNumElements())&&!numberRows&&tryPlusMinusOne) {
    14771477        startPositive = new CoinBigIndex[numberColumns+1];
    14781478        startNegative = new CoinBigIndex[numberColumns];
     
    17071707ClpModel::addColumns(const CoinBuild & buildObject,bool tryPlusMinusOne)
    17081708{
    1709   assert (buildObject.type()==1); // check correct
     1709  CoinAssertHint (buildObject.type()==1,"Looks as if both addRows and addCols being used"); // check correct
    17101710  int number = buildObject.numberColumns();
    17111711  if (number) {
     
    18481848      CoinBigIndex * startPositive = NULL;
    18491849      CoinBigIndex * startNegative = NULL;
    1850       if ((!matrix_||!matrix_->getNumElements())
    1851           &&!numberColumns&&tryPlusMinusOne) {
     1850      if ((!matrix_||!matrix_->getNumElements())&&!numberColumns&&tryPlusMinusOne) {
    18521851        startPositive = new CoinBigIndex[numberColumns2+1];
    18531852        startNegative = new CoinBigIndex[numberColumns2];
     
    23202319{
    23212320  whatsChanged_ = 0; // Use ClpSimplex stuff to keep
    2322   assert (numberColumns==numberColumns_);
     2321  CoinAssert (numberColumns==numberColumns_);
    23232322  assert ((dynamic_cast< ClpLinearObjective*>(objective_)));
    23242323  double offset;
     
    23342333{
    23352334  whatsChanged_ = 0; // Use ClpSimplex stuff to keep
    2336   assert (matrix.getNumCols()==numberColumns_);
     2335  CoinAssert (matrix.getNumCols()==numberColumns_);
    23372336  assert ((dynamic_cast< ClpLinearObjective*>(objective_)));
    23382337  double offset;
  • trunk/ClpSimplex.cpp

    r554 r560  
    24192419    objectiveWork_ = cost_;
    24202420    rowObjectiveWork_ = cost_+numberColumns_;
    2421     memcpy(objectiveWork_,objective(),numberColumns_*sizeof(double));
     2421    const double * obj = objective();
     2422    for (i=0;i<numberColumns_;i++) {
     2423      cost_[i]=obj[i];
     2424      CoinAssert(fabs(cost_[i])<1.0e25);
     2425    }
    24222426    if (rowObjective_)
    24232427      memcpy(rowObjectiveWork_,rowObjective_,numberRows_*sizeof(double));
     
    35223526  int saveQuadraticActivated = objective_->activated();
    35233527  objective_->setActivated(0);
    3524   assert (ifValuesPass>=0&&ifValuesPass<3);
     3528  CoinAssert (ifValuesPass>=0&&ifValuesPass<3);
    35253529  /*  Note use of "down casting".  The only class the user sees is ClpSimplex.
    35263530      Classes ClpSimplexDual, ClpSimplexPrimal, (ClpSimplexNonlinear)
     
    36203624    return reducedGradient();
    36213625 
    3622   assert (ifValuesPass>=0&&ifValuesPass<3);
     3626  CoinAssert (ifValuesPass>=0&&ifValuesPass<3);
    36233627  /*  Note use of "down casting".  The only class the user sees is ClpSimplex.
    36243628      Classes ClpSimplexDual, ClpSimplexPrimal, (ClpSimplexNonlinear)
     
    42574261        new char[CoinMax(numberRows_,numberColumns_)*(lengthNames_+1)];
    42584262      char * put = array;
    4259       assert (numberRows_ == (int) rowNames_.size());
     4263      CoinAssert (numberRows_ == (int) rowNames_.size());
    42604264      for (i=0;i<numberRows_;i++) {
    42614265        assert((int)rowNames_[i].size()<=lengthNames_);
     
    42674271        return 1;
    42684272      put=array;
    4269       assert (numberColumns_ == (int) columnNames_.size());
     4273      CoinAssert (numberColumns_ == (int) columnNames_.size());
    42704274      for (i=0;i<numberColumns_;i++) {
    42714275        assert((int) columnNames_[i].size()<=lengthNames_);
     
    42804284    // just standard type at present
    42814285    assert (matrix_->type()==1);
    4282     assert (matrix_->getNumCols() == numberColumns_);
    4283     assert (matrix_->getNumRows() == numberRows_);
     4286    CoinAssert (matrix_->getNumCols() == numberColumns_);
     4287    CoinAssert (matrix_->getNumRows() == numberRows_);
    42844288    // we are going to save with gaps
    42854289    length = matrix_->getVectorStarts()[numberColumns_-1]
     
    49194923ClpSimplex::crash(double gap,int pivot)
    49204924{
    4921   assert(!rowObjective_); // not coded
     4925  CoinAssert(!rowObjective_); // not coded
    49224926  int iColumn;
    49234927  int numberBad=0;
     
    59225926  incomingInfeasibility_=incomingInfeasibility;
    59235927  allowedInfeasibility_=allowedInfeasibility;
    5924   assert(incomingInfeasibility_>=0.0);
    5925   assert(allowedInfeasibility_>=incomingInfeasibility_);
     5928  CoinAssert(incomingInfeasibility_>=0.0);
     5929  CoinAssert(allowedInfeasibility_>=incomingInfeasibility_);
    59265930}
    59275931//#############################################################################
     
    63786382  }
    63796383  whatsChanged_=0;
    6380   assert (wholeModel->matrix_);
     6384  CoinAssert (wholeModel->matrix_);
    63816385  wholeModel->matrix_ = wholeModel->matrix_->subsetClone(numberRows_,whichRow,
    63826386                                        numberColumns,whichColumns);
     
    69276931    abort();
    69286932  }
    6929   assert (index);
     6933  CoinAssert (index);
    69306934  memcpy(index,pivotVariable(),
    69316935         numberRows()*sizeof(int));
     
    70277031  if (upperValue>1.0e27)
    70287032    upperValue=COIN_DBL_MAX;
    7029   assert (upperValue>=lowerValue);
     7033  CoinAssert (upperValue>=lowerValue);
    70307034  if (rowLower_[elementIndex] != lowerValue) {
    70317035    rowLower_[elementIndex] = lowerValue;
     
    70817085    if (upperValue>1.0e27)
    70827086      upperValue=COIN_DBL_MAX;
    7083     assert (upperValue>=lowerValue);
     7087    CoinAssert (upperValue>=lowerValue);
    70847088    if (rowLower_[iRow] != lowerValue) {
    70857089      rowLower_[iRow] = lowerValue;
     
    72077211  if (upperValue>1.0e27)
    72087212    upperValue=COIN_DBL_MAX;
    7209   assert (upperValue>=lowerValue);
     7213  CoinAssert (upperValue>=lowerValue);
    72107214  if (columnUpper_[elementIndex] != upperValue) {
    72117215    columnUpper_[elementIndex] = upperValue;
     
    72467250    if (upperValue>1.0e27)
    72477251      upperValue=COIN_DBL_MAX;
    7248     assert (upperValue>=lowerValue);
     7252    CoinAssert (upperValue>=lowerValue);
    72497253    if (columnLower_[iColumn] != lowerValue) {
    72507254      columnLower_[iColumn] = lowerValue;
  • trunk/ClpSimplexDual.cpp

    r553 r560  
    709709      } else {
    710710        // Make sure direction plausible
    711         assert (upperOut_<1.0e50||lowerOut_>-1.0e50);
     711        CoinAssert (upperOut_<1.0e50||lowerOut_>-1.0e50);
    712712        if (directionOut_<0&&fabs(valueOut_-upperOut_)>dualBound_+primalTolerance_) {
    713713          if (fabs(valueOut_-upperOut_)>fabs(valueOut_-lowerOut_))
     
    904904          }
    905905        }
    906         assert(fabs(dualOut_)<1.0e50);
     906        CoinAssert(fabs(dualOut_)<1.0e50);
    907907        // if stable replace in basis
    908908        int updateStatus = factorization_->replaceColumn(this,
     
    19131913          // set non basic free variables to fake bounds
    19141914          // I don't think we should ever get here
    1915           assert(!("should not be here"));
     1915          CoinAssert(!("should not be here"));
    19161916          lower_[iSequence]=-0.5*dualBound_;
    19171917          upper_[iSequence]= 0.5*dualBound_;
     
    39243924    // Start of fast iterations
    39253925    int status = fastDual(alwaysFinish);
    3926     assert (status_||objectiveValue_<1.0e50);
     3926    CoinAssert (status_||objectiveValue_<1.0e50);
    39273927    // make sure plausible
    39283928    double obj = CoinMax(objectiveValue_,saveObjectiveValue);
  • trunk/ClpSimplexPrimal.cpp

    r533 r560  
    22552255       
    22562256        //alpha_ = rowArray_[1]->denseVector()[pivotRow_];
    2257         assert (fabs(alpha_)>1.0e-8);
     2257        CoinAssert (fabs(alpha_)>1.0e-8);
    22582258        double multiplier = dualIn_/alpha_;
    22592259        rowArray_[0]->insert(pivotRow_,multiplier);
     
    22852285        rowArray_[0]->setNumElements(0);
    22862286        // check incoming
    2287         assert (fabs(dj_[sequenceIn_])<1.0e-1);
     2287        CoinAssert (fabs(dj_[sequenceIn_])<1.0e-1);
    22882288      }
    22892289      // if stable replace in basis
  • trunk/Samples/addRows.cpp

    r558 r560  
    1414int main (int argc, const char *argv[])
    1515{
    16   {
     16  try {
    1717    // Empty model
    1818    ClpSimplex  model;
     
    8888    model.dual();
    8989    model=modelSave;
    90     int del[]={0,1};
     90    int del[]={0,1,2};
    9191    model.deleteRows(2,del);
    9292    // Now use build +-1
     
    194194    }
    195195    std::cout<<"--------------------------------------"<<std::endl;
     196    // Test CoinAssert
     197    std::cout<<"If Clp compiled with -g below should give assert, if with -O1 or COIN_ASSERT CoinError"<<std::endl;
     198    model=modelSave;
     199    model.deleteRows(2,del);
     200    // Deliberate error
     201    model.deleteColumns(1,del+2);
     202    // Now use build +-1
     203    CoinBuild buildObject3;
     204    time1 = CoinCpuTime();
     205    for ( k=0;k<10000;k++) {
     206      int row2Index[] = {0,1,2};
     207      double row2Value[]={1.0,-1.0,1.0};
     208      buildObject3.addRow(3,row2Index,row2Value,
     209                          1.0,1.0);
     210    }
     211    model.addRows(buildObject3,true);
     212  }
     213  catch (CoinError e) {
     214    e.print();
     215    if (e.lineNumber()>=0)
     216      std::cout<<"This was from a CoinAssert"<<std::endl;
    196217  }
    197218  return 0;
Note: See TracChangeset for help on using the changeset viewer.