Ignore:
Timestamp:
Sep 17, 2002 4:43:03 PM (18 years ago)
Author:
forrest
Message:

Check matrix more carefully

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/devel-1/ClpSimplexPrimal.cpp

    r20 r21  
    227227  // save infeasibility cost
    228228  double saveInfeasibilityCost = infeasibilityCost_;
    229 
    230   int iRow,iColumn;
    231   // Do initial factorization
    232   // and set certain stuff
    233   // We can either set increasing rows so ...IsBasic gives pivot row
    234   // or we can just increment iBasic one by one
    235   // for now let ...iBasic give pivot row
    236   factorization_->increasingRows(2);
    237   // row activities have negative sign
    238   factorization_->slackValue(-1.0);
    239   factorization_->zeroTolerance(1.0e-13);
    240  
    241 
    242   // If user asked for perturbation - do it
     229  // Save perturbation
    243230  int savePerturbation = perturbation_;
    244 
    245   if (perturbation_<100)
    246     perturb();
    247 
    248   // for primal we will change bounds using infeasibilityCost_
    249   if (nonLinearCost_==NULL) {
    250     // get a valid nonlinear cost function
    251     delete nonLinearCost_;
    252     nonLinearCost_= new ClpNonLinearCost(this);
    253   }
    254 
    255231  // save if sparse factorization wanted
    256232  int saveSparse = factorization_->sparseThreshold();
    257233
    258   // loop round to clean up solution if values pass
    259   int numberThrownOut = -1;
    260   int firstSuperBasic=numberRows_+numberColumns_;
    261   int totalNumberThrownOut=0;
    262   while(numberThrownOut) {
    263     int status = internalFactorize(0+10*ifValuesPass);
    264     if (status<0)
    265       return 1; // some error
    266     else
    267       totalNumberThrownOut+= status;
    268 
    269     // for this we need clean basis so it is after factorize
    270     numberThrownOut=gutsOfSolution(rowActivityWork_,columnActivityWork_,
    271                                    ifValuesPass);
    272     totalNumberThrownOut+= numberThrownOut;
    273 
    274     // find first superbasic - columns, then rows
    275     if (ifValuesPass) {
    276       nextSuperBasic(firstSuperBasic);
    277       if (firstSuperBasic==numberRows_+numberColumns_)
    278         ifValuesPass=0; // signal no values pass
    279     }
    280   }
    281 
    282   if (totalNumberThrownOut)
    283     handler_->message(CLP_SINGULARITIES,messages_)
    284     <<totalNumberThrownOut
    285     <<CoinMessageEol;
    286 
    287   problemStatus_ = -1;
    288   numberIterations_=0;
    289 
    290   int lastCleaned=0; // last time objective or bounds cleaned up
    291 
    292   // number of times we have declared optimality
    293   numberTimesOptimal_=0;
    294 
    295   // Progress indicator
    296   ClpSimplexProgress progress(this);
    297 
    298   // Say no pivot has occurred (for steepest edge and updates)
    299   pivotRow_=-2;
    300 
    301   // This says whether to restore things etc
    302   int factorType=0;
    303   // Save iteration number
    304   int saveNumber = -1;
    305   /*
    306     Status of problem:
    307     0 - optimal
    308     1 - infeasible
    309     2 - unbounded
    310     -1 - iterating
    311     -2 - factorization wanted
    312     -3 - redo checking without factorization
    313     -4 - looks infeasible
    314     -5 - looks unbounded
    315   */
    316   while (problemStatus_<0) {
    317     // clear
    318     for (iRow=0;iRow<4;iRow++) {
    319       rowArray_[iRow]->clear();
    320     }   
     234  if (sanityCheck()) {
     235    // Model looks okay
     236    int iRow,iColumn;
     237    // Do initial factorization
     238    // and set certain stuff
     239    // We can either set increasing rows so ...IsBasic gives pivot row
     240    // or we can just increment iBasic one by one
     241    // for now let ...iBasic give pivot row
     242    factorization_->increasingRows(2);
     243    // row activities have negative sign
     244    factorization_->slackValue(-1.0);
     245    factorization_->zeroTolerance(1.0e-13);
    321246   
    322     for (iColumn=0;iColumn<2;iColumn++) {
    323       columnArray_[iColumn]->clear();
    324     }   
    325 
    326     // give matrix (and model costs and bounds a chance to be
    327     // refreshed (normally null)
    328     matrix_->refresh(this);
    329     // If getting nowhere - why not give it a kick
    330 #if 0
    331     // primal perturbation not coded yet
    332     if (perturbation_<101&&numberIterations_>2*(numberRows_+numberColumns_))
     247   
     248    // If user asked for perturbation - do it
     249   
     250    if (perturbation_<100)
    333251      perturb();
    334 #endif
    335     // If we have done no iterations - special
    336     if (saveNumber==numberIterations_)
    337       factorType=3;
    338     // may factorize, checks if problem finished
    339     statusOfProblemInPrimal(lastCleaned,factorType,progress);
    340 
    341     // Say good factorization
    342     factorType=1;
    343     if (saveSparse) {
    344       // use default at present
    345       factorization_->sparseThreshold(0);
    346       factorization_->goSparse();
    347     }
    348 
     252   
     253    // for primal we will change bounds using infeasibilityCost_
     254    if (nonLinearCost_==NULL) {
     255      // get a valid nonlinear cost function
     256      delete nonLinearCost_;
     257      nonLinearCost_= new ClpNonLinearCost(this);
     258    }
     259   
     260    // loop round to clean up solution if values pass
     261    int numberThrownOut = -1;
     262    int firstSuperBasic=numberRows_+numberColumns_;
     263    int totalNumberThrownOut=0;
     264    while(numberThrownOut) {
     265      int status = internalFactorize(0+10*ifValuesPass);
     266      if (status<0)
     267        return 1; // some error
     268      else
     269        totalNumberThrownOut+= status;
     270     
     271      // for this we need clean basis so it is after factorize
     272      numberThrownOut=gutsOfSolution(rowActivityWork_,columnActivityWork_,
     273                                     ifValuesPass);
     274      totalNumberThrownOut+= numberThrownOut;
     275     
     276      // find first superbasic - columns, then rows
     277      if (ifValuesPass) {
     278        nextSuperBasic(firstSuperBasic);
     279        if (firstSuperBasic==numberRows_+numberColumns_)
     280          ifValuesPass=0; // signal no values pass
     281      }
     282    }
     283   
     284    if (totalNumberThrownOut)
     285      handler_->message(CLP_SINGULARITIES,messages_)
     286        <<totalNumberThrownOut
     287        <<CoinMessageEol;
     288   
     289    problemStatus_ = -1;
     290    numberIterations_=0;
     291   
     292    int lastCleaned=0; // last time objective or bounds cleaned up
     293   
     294    // number of times we have declared optimality
     295    numberTimesOptimal_=0;
     296   
     297    // Progress indicator
     298    ClpSimplexProgress progress(this);
     299   
    349300    // Say no pivot has occurred (for steepest edge and updates)
    350301    pivotRow_=-2;
    351 
     302   
     303    // This says whether to restore things etc
     304    int factorType=0;
    352305    // Save iteration number
    353     saveNumber = numberIterations_;
    354 
    355     // Iterate
    356     whileIterating(firstSuperBasic);
    357   }
    358 
     306    int saveNumber = -1;
     307    /*
     308      Status of problem:
     309      0 - optimal
     310      1 - infeasible
     311      2 - unbounded
     312      -1 - iterating
     313      -2 - factorization wanted
     314      -3 - redo checking without factorization
     315      -4 - looks infeasible
     316      -5 - looks unbounded
     317    */
     318    while (problemStatus_<0) {
     319      // clear
     320      for (iRow=0;iRow<4;iRow++) {
     321        rowArray_[iRow]->clear();
     322      }   
     323     
     324      for (iColumn=0;iColumn<2;iColumn++) {
     325        columnArray_[iColumn]->clear();
     326      }   
     327     
     328      // give matrix (and model costs and bounds a chance to be
     329      // refreshed (normally null)
     330      matrix_->refresh(this);
     331      // If getting nowhere - why not give it a kick
     332#if 0
     333      // primal perturbation not coded yet
     334      if (perturbation_<101&&numberIterations_>2*(numberRows_+numberColumns_))
     335        perturb();
     336#endif
     337      // If we have done no iterations - special
     338      if (saveNumber==numberIterations_)
     339        factorType=3;
     340      // may factorize, checks if problem finished
     341      statusOfProblemInPrimal(lastCleaned,factorType,progress);
     342     
     343      // Say good factorization
     344      factorType=1;
     345      if (saveSparse) {
     346        // use default at present
     347        factorization_->sparseThreshold(0);
     348        factorization_->goSparse();
     349      }
     350     
     351      // Say no pivot has occurred (for steepest edge and updates)
     352      pivotRow_=-2;
     353     
     354      // Save iteration number
     355      saveNumber = numberIterations_;
     356     
     357      // Iterate
     358      whileIterating(firstSuperBasic);
     359    }
     360  }
    359361  // if infeasible get real values
    360   if (problemStatus_) {
     362  if (problemStatus_==1) {
    361363    infeasibilityCost_=0.0;
    362364    createRim(7);
Note: See TracChangeset for help on using the changeset viewer.