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/ClpSimplexDual.cpp

    r20 r21  
    246246  // save dual bound
    247247  double saveDualBound_ = dualBound_;
    248 
    249   int iRow,iColumn;
    250   // Do initial factorization
    251   // and set certain stuff
    252   // We can either set increasing rows so ...IsBasic gives pivot row
    253   // or we can just increment iBasic one by one
    254   // for now let ...iBasic give pivot row
    255   factorization_->increasingRows(2);
    256   // row activities have negative sign
    257   factorization_->slackValue(-1.0);
    258   factorization_->zeroTolerance(1.0e-13);
     248  // save perturbation
     249  int savePerturbation = perturbation_;
    259250  // save if sparse factorization wanted
    260251  int saveSparse = factorization_->sparseThreshold();
    261252
    262   int factorizationStatus = internalFactorize(0);
    263   if (factorizationStatus<0)
    264     return 1; // some error
    265   else if (factorizationStatus)
    266     handler_->message(CLP_SINGULARITIES,messages_)
    267     <<factorizationStatus
    268     <<CoinMessageEol;
    269 
    270   // If user asked for perturbation - do it
    271   int savePerturbation = perturbation_;
    272 
    273   if (perturbation_<100)
    274     perturb();
    275 
    276   double objectiveChange;
    277   // for dual we will change bounds using dualBound_
    278   // for this we need clean basis so it is after factorize
    279   gutsOfSolution(rowActivityWork_,columnActivityWork_);
    280 
    281   numberFake_ =0; // Number of variables at fake bounds
    282   changeBounds(true,NULL,objectiveChange);
    283 
    284   problemStatus_ = -1;
    285   numberIterations_=0;
    286 
    287   int lastCleaned=0; // last time objective or bounds cleaned up
    288 
    289   // number of times we have declared optimality
    290   numberTimesOptimal_=0;
    291 
    292   // Progress indicator
    293   ClpSimplexProgress progress(this);
    294 
    295   // This says whether to restore things etc
    296   int factorType=0;
    297   /*
    298     Status of problem:
    299     0 - optimal
    300     1 - infeasible
    301     2 - unbounded
    302     -1 - iterating
    303     -2 - factorization wanted
    304     -3 - redo checking without factorization
    305     -4 - looks infeasible
    306   */
    307   while (problemStatus_<0) {
    308     // clear
    309     for (iRow=0;iRow<4;iRow++) {
    310       rowArray_[iRow]->clear();
    311     }   
     253  if (sanityCheck()) {
     254    // Problem looks okay
     255    int iRow,iColumn;
     256    // Do initial factorization
     257    // and set certain stuff
     258    // We can either set increasing rows so ...IsBasic gives pivot row
     259    // or we can just increment iBasic one by one
     260    // for now let ...iBasic give pivot row
     261    factorization_->increasingRows(2);
     262    // row activities have negative sign
     263    factorization_->slackValue(-1.0);
     264    factorization_->zeroTolerance(1.0e-13);
    312265   
    313     for (iColumn=0;iColumn<2;iColumn++) {
    314       columnArray_[iColumn]->clear();
    315     }   
    316 
    317     // give matrix (and model costs and bounds a chance to be
    318     // refreshed (normally null)
    319     matrix_->refresh(this);
    320     // If getting nowhere - why not give it a kick
     266    int factorizationStatus = internalFactorize(0);
     267    if (factorizationStatus<0)
     268      return 1; // some error
     269    else if (factorizationStatus)
     270      handler_->message(CLP_SINGULARITIES,messages_)
     271        <<factorizationStatus
     272        <<CoinMessageEol;
     273   
     274    // If user asked for perturbation - do it
     275   
     276    if (perturbation_<100)
     277      perturb();
     278   
     279    double objectiveChange;
     280    // for dual we will change bounds using dualBound_
     281    // for this we need clean basis so it is after factorize
     282    gutsOfSolution(rowActivityWork_,columnActivityWork_);
     283   
     284    numberFake_ =0; // Number of variables at fake bounds
     285    changeBounds(true,NULL,objectiveChange);
     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    // This says whether to restore things etc
     299    int factorType=0;
     300    /*
     301      Status of problem:
     302      0 - optimal
     303      1 - infeasible
     304      2 - unbounded
     305      -1 - iterating
     306      -2 - factorization wanted
     307      -3 - redo checking without factorization
     308      -4 - looks infeasible
     309    */
     310    while (problemStatus_<0) {
     311      // clear
     312      for (iRow=0;iRow<4;iRow++) {
     313        rowArray_[iRow]->clear();
     314      }   
     315     
     316      for (iColumn=0;iColumn<2;iColumn++) {
     317        columnArray_[iColumn]->clear();
     318      }   
     319     
     320      // give matrix (and model costs and bounds a chance to be
     321      // refreshed (normally null)
     322      matrix_->refresh(this);
     323      // If getting nowhere - why not give it a kick
    321324#if 0
    322     // does not seem to work too well - do some more work
    323     if (perturbation_<101&&numberIterations_>2*(numberRows_+numberColumns_))
    324       perturb();
    325 #endif
    326     // may factorize, checks if problem finished
    327     statusOfProblemInDual(lastCleaned,factorType,progress);
    328 
    329     // Say good factorization
    330     factorType=1;
    331     if (saveSparse) {
    332       // use default at present
    333       factorization_->sparseThreshold(0);
    334       factorization_->goSparse();
    335     }
    336 
    337     // Do iterations
    338     whileIterating();
     325      // does not seem to work too well - do some more work
     326      if (perturbation_<101&&numberIterations_>2*(numberRows_+numberColumns_))
     327        perturb();
     328#endif
     329      // may factorize, checks if problem finished
     330      statusOfProblemInDual(lastCleaned,factorType,progress);
     331     
     332      // Say good factorization
     333      factorType=1;
     334      if (saveSparse) {
     335        // use default at present
     336        factorization_->sparseThreshold(0);
     337        factorization_->goSparse();
     338      }
     339     
     340      // Do iterations
     341      whileIterating();
     342    }
    339343  }
    340344
Note: See TracChangeset for help on using the changeset viewer.