Ignore:
Timestamp:
Apr 6, 2013 8:54:16 AM (7 years ago)
Author:
stefan
Message:

revert r1925 (so we can merge r1926) and sync with rev 1927

Location:
stable/1.15/Clp
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • stable/1.15/Clp

  • stable/1.15/Clp/src

  • stable/1.15/Clp/src/OsiClp

  • stable/1.15/Clp/src/OsiClp/OsiClpSolverInterface.cpp

    r1887 r1928  
    133133  int saveMessageLevel2 = messageLevel;
    134134  // Set message handler
    135   solver->passInMessageHandler(handler_);
     135  if (!defaultHandler_)
     136    solver->passInMessageHandler(handler_);
    136137  // But keep log level
    137138  solver->messageHandler()->setLogLevel(saveMessageLevel);
     
    778779  }
    779780  modelPtr_->whatsChanged_ |= 0x30000;
     781#if 0
     782  // delete scaled matrix and rowcopy for safety
     783  delete modelPtr_->scaledMatrix_;
     784  modelPtr_->scaledMatrix_=NULL;
     785  delete modelPtr_->rowCopy_;
     786  modelPtr_->rowCopy_=NULL;
     787#endif
    780788  //std::cout<<time1<<" seconds - total "<<totalTime<<std::endl;
    781789  delete pinfo;
     
    919927  int messageLevel=messageHandler()->logLevel();
    920928  bool oldDefault;
    921   CoinMessageHandler * saveHandler = modelPtr_->pushMessageHandler(handler_,oldDefault);
     929  CoinMessageHandler * saveHandler = NULL;
     930  if (!defaultHandler_)
     931    saveHandler = modelPtr_->pushMessageHandler(handler_,oldDefault);
    922932  //printf("basis before dual\n");
    923933  //basis_.print();
     
    12571267  //printf("basis after dual\n");
    12581268  //basis_.print();
    1259   modelPtr_->popMessageHandler(saveHandler,oldDefault);
     1269  if (!defaultHandler_)
     1270    modelPtr_->popMessageHandler(saveHandler,oldDefault);
    12601271  modelPtr_->messageHandler()->setLogLevel(saveMessageLevel);
    12611272  if (saveSolveType==2) {
     
    20392050      //small->setLogLevel(0);
    20402051      // Could be infeasible if forced one way (and other way stopped on iterations)
    2041       if (small->status()==1) {
     2052      // could also be stopped on iterations
     2053      if (small->status()) {
    20422054#ifndef KEEP_SMALL
    20432055        if (small!=modelPtr_)
     
    23542366    double saveObjectiveValue = arrayD[0];
    23552367    double * saveSolution = arrayD+1;
     2368    // double check arrays exist (? for nonlinear)
     2369    //if (!smallModel_->solutionRegion())
     2370    //smallModel_->createRim(63);
    23562371    int numberRows2 = smallModel_->numberRows();
    23572372    int numberColumns2 = smallModel_->numberColumns();
     
    29002915                                                        bool fullRay) const
    29012916{
    2902   if (fullRay == true) {
    2903     throw CoinError("Full dual rays not yet implemented.","getDualRays",
    2904                     "OsiClpSolverInterface");
    2905   }
    2906   return std::vector<double*>(1, modelPtr_->infeasibilityRay());
     2917  return std::vector<double*>(1, modelPtr_->infeasibilityRay(fullRay));
    29072918}
    29082919//------------------------------------------------------------------
     
    34783489  modelPtr_->scaledMatrix_=NULL;
    34793490  if (saveRowCopy) {
    3480 #if 1
    34813491    matrixByRow_=saveRowCopy;
    34823492    matrixByRow_->deleteRows(num,rowIndices);
    3483     assert (matrixByRow_->getNumElements()==modelPtr_->clpMatrix()->getNumElements());
    3484 #else
    3485     delete saveRowCopy;
    3486 #endif
     3493    if (matrixByRow_->getNumElements()!=modelPtr_->clpMatrix()->getNumElements()) {
     3494      delete matrixByRow_; // odd type matrix
     3495      matrixByRow_=NULL;
     3496    }
    34873497  }
    34883498  lastAlgorithm_ = saveAlgorithm;
     
    42784288  }
    42794289  starts[numberCuts]=size;
    4280   if (!modelPtr_->clpMatrix())
     4290 if (!modelPtr_->clpMatrix())
    42814291    modelPtr_->createEmptyMatrix();
    42824292  //modelPtr_->matrix()->appendRows(numberCuts,rows);
    42834293  modelPtr_->clpMatrix()->appendMatrix(numberCuts,0,starts,indices,elements);
    42844294  modelPtr_->setNewRowCopy(NULL);
     4295  modelPtr_->setClpScaledMatrix(NULL);
    42854296  freeCachedResults1();
    42864297  redoScaleFactors( numberCuts,starts, indices, elements);
     
    42894300    matrixByRow_=saveRowCopy;
    42904301    matrixByRow_->appendRows(numberCuts,starts,indices,elements,0);
    4291     assert (matrixByRow_->getNumElements()==modelPtr_->clpMatrix()->getNumElements());
     4302    if (matrixByRow_->getNumElements()!=modelPtr_->clpMatrix()->getNumElements()) {
     4303      delete matrixByRow_; // odd type matrix
     4304      matrixByRow_=NULL;
     4305    }
    42924306#else
    42934307    delete saveRowCopy;
     
    53345348OsiClpSolverInterface::getRowName(int rowIndex, unsigned int /*maxLen*/) const
    53355349{
    5336         if (rowIndex == getNumRows())
    5337                 return getObjName();
    5338   return modelPtr_->getRowName(rowIndex);
     5350  if (rowIndex == getNumRows())
     5351    return getObjName();
     5352  int useNames;
     5353  getIntParam (OsiNameDiscipline,useNames);
     5354  if (useNames)
     5355    return modelPtr_->getRowName(rowIndex);
     5356  else
     5357    return dfltRowColName('r',rowIndex);
    53395358}
    53405359   
     
    53575376OsiClpSolverInterface::getColName(int colIndex, unsigned int /*maxLen*/) const
    53585377{
    5359   return modelPtr_->getColumnName(colIndex);
     5378  int useNames;
     5379  getIntParam (OsiNameDiscipline,useNames);
     5380  if (useNames)
     5381    return modelPtr_->getColumnName(colIndex);
     5382  else
     5383    return dfltRowColName('c',colIndex);
    53605384}
    53615385   
     
    55015525  delete modelPtr_->scaledMatrix_;
    55025526  modelPtr_->scaledMatrix_=NULL;
     5527  // make sure using standard factorization
     5528  modelPtr_->factorization()->forceOtherFactorization(4);
    55035529#ifdef NDEBUG
    55045530  modelPtr_->startup(0);
     
    67066732          delete [] modelPtr_->ray_;
    67076733          modelPtr_->ray_=NULL;
     6734          if (problemStatus==1&&small->ray_) {
     6735            // get ray to full problem
     6736            int numberRows = modelPtr_->numberRows();
     6737            int numberRows2 = small->numberRows();
     6738            double * ray = new double [numberRows];
     6739            memset(ray,0,numberRows*sizeof(double));
     6740            for (int i = 0; i < numberRows2; i++) {
     6741              int iRow = whichRow[i];
     6742              ray[iRow] = small->ray_[i];
     6743            }
     6744            // Column copy of matrix
     6745            const double * element = getMatrixByCol()->getElements();
     6746            const int * row = getMatrixByCol()->getIndices();
     6747            const CoinBigIndex * columnStart = getMatrixByCol()->getVectorStarts();
     6748            const int * columnLength = getMatrixByCol()->getVectorLengths();
     6749            // translate
     6750            //pivotRow=whichRow[pivotRow];
     6751            //modelPtr_->spareIntArray_[3]=pivotRow;
     6752            int pivotRow=-1;
     6753            for (int jRow = nBound; jRow < 2 * numberRows; jRow++) {
     6754              int iRow = whichRow[jRow];
     6755              int iColumn = whichRow[jRow+numberRows];
     6756              if (modelPtr_->getColumnStatus(iColumn) == ClpSimplex::basic) {
     6757                double value = 0.0;
     6758                double sum = 0.0;
     6759                for (CoinBigIndex j = columnStart[iColumn];
     6760                     j < columnStart[iColumn] + columnLength[iColumn]; j++) {
     6761                  if (iRow == row[j]) {
     6762                    value = element[j];
     6763                  } else {
     6764                    sum += ray[row[j]]*element[j];
     6765                  }
     6766                }
     6767                if (iRow!=pivotRow) {
     6768                  ray[iRow] = -sum / value;
     6769                } else {
     6770                  printf("what now - direction %d wanted %g sum %g value %g\n",
     6771                         small->directionOut_,ray[iRow],
     6772                         sum,value);
     6773                }
     6774              }
     6775            }
     6776            for (int i=0;i<modelPtr_->numberColumns_;i++) {
     6777              if (modelPtr_->getStatus(i)!=ClpSimplex::basic&&
     6778                  modelPtr_->columnLower_[i]==modelPtr_->columnUpper_[i])
     6779                modelPtr_->setStatus(i,ClpSimplex::isFixed);
     6780            }
     6781            modelPtr_->ray_=ray;
     6782            modelPtr_->directionOut_=small->directionOut_;
     6783          }
    67086784        }
    67096785      }
  • stable/1.15/Clp/src/OsiClp/OsiClpSolverInterface.hpp

    r1828 r1928  
    177177  */
    178178  virtual void enableSimplexInterface(bool doingPrimal);
     179  /// Copy across enabled stuff from one solver to another
     180  void copyEnabledSuff(OsiClpSolverInterface & rhs);
    179181 
    180182  /*! \brief Undo setting changes made by #enableSimplexInterface */
    181183  virtual void disableSimplexInterface();
     184  /// Copy across enabled stuff from one solver to another
     185  void copyEnabledStuff(ClpSimplex & rhs);
    182186
    183187  /** Perform a pivot by substituting a colIn for colOut in the basis.
Note: See TracChangeset for help on using the changeset viewer.