Changeset 490


Ignore:
Timestamp:
Oct 27, 2004 4:44:03 PM (15 years ago)
Author:
forrest
Message:

startFinishOptions for strongBranching

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ClpSimplexDual.cpp

    r482 r490  
    36353635                                    int * outputStatus, int * outputIterations,
    36363636                                    bool stopOnFirstInfeasible,
    3637                                     bool alwaysFinish)
     3637                                    bool alwaysFinish,
     3638                                    int startFinishOptions)
    36383639{
    36393640  int i;
    36403641  int returnCode=0;
    36413642  double saveObjectiveValue = objectiveValue_;
    3642 #if 1
    36433643  algorithm_ = -1;
    36443644
     
    36473647  // put in standard form (and make row copy)
    36483648  // create modifiable copies of model rim and do optional scaling
    3649   createRim(7+8+16+32,true);
     3649  createRim(7+8+16+32,true,startFinishOptions);
    36503650
    36513651  // change newLower and newUpper if scaled
     
    36563656  // or we can just increment iBasic one by one
    36573657  // for now let ...iBasic give pivot row
    3658   factorization_->increasingRows(2);
    3659   // row activities have negative sign
    3660   factorization_->slackValue(-1.0);
    3661   factorization_->zeroTolerance(1.0e-13);
    3662 
    3663   int factorizationStatus = internalFactorize(0);
    3664   if (factorizationStatus<0) {
    3665     // some error
    3666     // we should either debug or ignore
     3658  int useFactorization=false;
     3659  if ((startFinishOptions&2)!=0)
     3660    useFactorization=true; // Keep factorization if possible
     3661  if (!useFactorization||factorization_->numberRows()!=numberRows_) {
     3662    useFactorization = false;
     3663    factorization_->increasingRows(2);
     3664    // row activities have negative sign
     3665    factorization_->slackValue(-1.0);
     3666    factorization_->zeroTolerance(1.0e-13);
     3667
     3668    int factorizationStatus = internalFactorize(0);
     3669    if (factorizationStatus<0) {
     3670      // some error
     3671      // we should either debug or ignore
    36673672#ifndef NDEBUG
    3668     printf("***** ClpDual strong branching factorization error - debug\n");
    3669 #endif
    3670     return -2;
    3671   }
    3672   else if (factorizationStatus)
    3673     handler_->message(CLP_SINGULARITIES,messages_)
    3674       <<factorizationStatus
    3675       <<CoinMessageEol;
    3676  
     3673      printf("***** ClpDual strong branching factorization error - debug\n");
     3674#endif
     3675      return -2;
     3676    } else if (factorizationStatus) {
     3677      handler_->message(CLP_SINGULARITIES,messages_)
     3678        <<factorizationStatus
     3679        <<CoinMessageEol;
     3680    }
     3681  }
    36773682  // save stuff
    36783683  ClpFactorization saveFactorization(*factorization_);
     
    38593864  delete [] saveStatus;
    38603865  delete [] savePivot;
    3861 
    3862   // Get rid of some arrays and empty factorization
    3863   deleteRim();
    3864 #else
    3865   // save basis and solution
    3866   double * rowSolution = new double[numberRows_];
    3867   memcpy(rowSolution,rowActivity_,numberRows_*sizeof(double));
    3868   double * columnSolution = new double[numberColumns_];
    3869   memcpy(columnSolution,columnActivity_,numberColumns_*sizeof(double));
    3870   unsigned char * saveStatus =
    3871     new unsigned char [numberRows_+numberColumns_];
    3872   if (!status_) {
    3873     // odd but anyway setup all slack basis
    3874     status_ = new unsigned char [numberColumns_+numberRows_];
    3875     memset(status_,0,(numberColumns_+numberRows_)*sizeof(char));
    3876   }
    3877   memcpy(saveStatus,status_,(numberColumns_+numberRows_)*sizeof(char));
    3878   int iSolution =0;
    3879   for (i=0;i<numberVariables;i++) {
    3880     int iColumn = variables[i];
    3881     double objectiveChange;
    3882    
    3883     // try down
    3884    
    3885     double saveUpper = columnUpper_[iColumn];
    3886     columnUpper_[iColumn] = newUpper[i];
    3887     int status=dual(0);
    3888     memcpy(outputSolution[iSolution],columnActivity_,numberColumns_*sizeof(double));
    3889     outputStatus[iSolution]=status;
    3890     outputIterations[iSolution]=numberIterations_;
    3891     iSolution++;
    3892 
    3893     // restore
    3894     columnUpper_[iColumn] = saveUpper;
    3895     memcpy(rowActivity_,rowSolution,numberRows_*sizeof(double));
    3896     memcpy(columnActivity_,columnSolution,numberColumns_*sizeof(double));
    3897     memcpy(status_,saveStatus,(numberColumns_+numberRows_)*sizeof(char));
    3898 
    3899     if (problemStatus_==0&&!isDualObjectiveLimitReached()) {
    3900       objectiveChange = objectiveValue_-saveObjectiveValue;
    3901     } else {
    3902       objectiveChange = 1.0e100;
    3903     }
    3904     newUpper[i]=objectiveChange;
    3905 #ifdef CLP_DEBUG
    3906     printf("down on %d costs %g\n",iColumn,objectiveChange);
    3907 #endif
    3908          
    3909     // try up
    3910    
    3911     double saveLower = columnLower_[iColumn];
    3912     columnLower_[iColumn] = newLower[i];
    3913     status=dual(0);
    3914     memcpy(outputSolution[iSolution],columnActivity_,numberColumns_*sizeof(double));
    3915     outputStatus[iSolution]=status;
    3916     outputIterations[iSolution]=numberIterations_;
    3917     iSolution++;
    3918 
    3919     // restore
    3920     columnLower_[iColumn] = saveLower;
    3921     memcpy(rowActivity_,rowSolution,numberRows_*sizeof(double));
    3922     memcpy(columnActivity_,columnSolution,numberColumns_*sizeof(double));
    3923     memcpy(status_,saveStatus,(numberColumns_+numberRows_)*sizeof(char));
    3924 
    3925     if (problemStatus_==0&&!isDualObjectiveLimitReached()) {
    3926       objectiveChange = objectiveValue_-saveObjectiveValue;
    3927     } else {
    3928       objectiveChange = 1.0e100;
    3929     }
    3930     newLower[i]=objectiveChange;
    3931 #ifdef CLP_DEBUG
    3932     printf("up on %d costs %g\n",iColumn,objectiveChange);
    3933 #endif
    3934          
    3935     /* Possibilities are:
    3936        Both sides feasible - store
    3937        Neither side feasible - set objective high and exit
    3938        One side feasible - change bounds and resolve
    3939     */
    3940     if (newUpper[i]<1.0e100) {
    3941       if(newLower[i]<1.0e100) {
    3942         // feasible - no action
    3943       } else {
    3944         // up feasible, down infeasible
    3945         returnCode=1;
    3946         if (stopOnFirstInfeasible)
    3947           break;
    3948       }
    3949     } else {
    3950       if(newLower[i]<1.0e100) {
    3951         // down feasible, up infeasible
    3952         returnCode=1;
    3953         if (stopOnFirstInfeasible)
    3954           break;
    3955       } else {
    3956         // neither side feasible
    3957         returnCode=-1;
    3958         break;
    3959       }
    3960     }
    3961   }
    3962   delete [] rowSolution;
    3963   delete [] columnSolution;
    3964   delete [] saveStatus;
    3965 #endif
     3866  if ((startFinishOptions&1)==0) {
     3867    deleteRim(1);
     3868    whatsChanged_=0;
     3869  } else {
     3870    // Put back original factorization
     3871    delete factorization_;
     3872    factorization_ = new ClpFactorization(saveFactorization);
     3873    deleteRim(0);
     3874    // mark all as current
     3875    whatsChanged_ = 0xffff;
     3876  }
    39663877  objectiveValue_ = saveObjectiveValue;
    39673878  return returnCode;
  • trunk/include/ClpSimplexDual.hpp

    r472 r490  
    129129                      int * outputStatus, int * outputIterations,
    130130                      bool stopOnFirstInfeasible=true,
    131                       bool alwaysFinish=false);
     131                      bool alwaysFinish=false,
     132                      int startFinishOptions=0);
    132133  //@}
    133134
Note: See TracChangeset for help on using the changeset viewer.