Changeset 1154


Ignore:
Timestamp:
Jan 20, 2008 3:14:57 PM (14 years ago)
Author:
forrest
Message:

changes for cbc

Location:
trunk/Clp/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Clp/src/ClpModel.cpp

    r1153 r1154  
    915915{
    916916  assert (from);
    917   assert (to);
    918917  const ClpPackedMatrix * matrixFrom = (dynamic_cast<const ClpPackedMatrix*>(from));
    919918  ClpPackedMatrix * matrixTo = (dynamic_cast< ClpPackedMatrix*>(to));
  • trunk/Clp/src/ClpPackedMatrix.cpp

    r1150 r1154  
    26752675  }
    26762676}
     2677// Creates scaled column copy if scales exist
     2678void
     2679ClpPackedMatrix::createScaledMatrix(ClpSimplex * model) const
     2680{
     2681  int numberRows = model->numberRows();
     2682  int numberColumns = matrix_->getNumCols();
     2683  model->setClpScaledMatrix(NULL); // get rid of any scaled matrix
     2684  // If empty - return as sanityCheck will trap
     2685  if (!numberRows||!numberColumns) {
     2686    model->setRowScale(NULL);
     2687    model->setColumnScale(NULL);
     2688    return ;
     2689  }
     2690  if (!model->rowScale())
     2691    return;
     2692  double * rowScale=model->mutableRowScale();
     2693  double * columnScale=model->mutableColumnScale();
     2694  // copy without gaps
     2695  CoinPackedMatrix * scaledMatrix = new CoinPackedMatrix(*matrix_,0,0);
     2696  ClpPackedMatrix * scaled = new ClpPackedMatrix(scaledMatrix);
     2697  model->setClpScaledMatrix(scaled);
     2698  // get matrix data pointers
     2699  const int * row = scaledMatrix->getIndices();
     2700  const CoinBigIndex * columnStart = scaledMatrix->getVectorStarts();
     2701#ifndef NDEBUG
     2702  const int * columnLength = scaledMatrix->getVectorLengths();
     2703#endif
     2704  double * elementByColumn = scaledMatrix->getMutableElements();
     2705  for (int iColumn=0;iColumn<numberColumns;iColumn++) {
     2706    CoinBigIndex j;
     2707    double scale = columnScale[iColumn];
     2708    assert (columnStart[iColumn+1]==columnStart[iColumn]+columnLength[iColumn]);
     2709    for (j=columnStart[iColumn];
     2710         j<columnStart[iColumn+1];j++) {
     2711      int iRow = row[j];
     2712      elementByColumn[j] *= scale*rowScale[iRow];
     2713    }
     2714  }
     2715}
    26772716/* Unpacks a column into an CoinIndexedvector
    26782717 */
  • trunk/Clp/src/ClpPackedMatrix.hpp

    r1150 r1154  
    109109      Only called if scales already exist */
    110110  virtual void scaleRowCopy(ClpModel * model) const ;
     111  /// Creates scaled column copy if scales exist
     112  void createScaledMatrix(ClpSimplex * model) const;
    111113  /** Realy really scales column copy
    112114      Only called if scales already exist.
  • trunk/Clp/src/ClpSimplex.cpp

    r1152 r1154  
    244244  // get an empty factorization so we can set tolerances etc
    245245  getEmptyFactorization();
     246  // say Steepest pricing
     247  dualRowPivot_ = new ClpDualRowSteepest();
     248  // say Steepest pricing
     249  primalColumnPivot_ = new ClpPrimalColumnSteepest();
     250  solveType_=1; // say simplex based life form
     251  if (fixOthers) {
     252    int numberOtherColumns=rhs->numberColumns();
     253    int numberOtherRows=rhs->numberRows();
     254    double * solution = new double [numberOtherColumns];
     255    CoinZeroN(solution,numberOtherColumns);
     256    int i;
     257    for (i=0;i<numberColumns;i++) {
     258      int iColumn = whichColumn[i];
     259      if (solution[iColumn])
     260        fixOthers=false; // duplicates
     261      solution[iColumn]=1.0;
     262    }
     263    if (fixOthers) {
     264      const double * otherSolution = rhs->primalColumnSolution();
     265      const double * objective = rhs->objective();
     266      double offset=0.0;
     267      for (i=0;i<numberOtherColumns;i++) {
     268        if (solution[i]) {
     269          solution[i]=0.0; // in
     270        } else {
     271          solution[i] = otherSolution[i];
     272          offset += objective[i]*otherSolution[i];
     273        }
     274      }
     275      double * rhsModification = new double [numberOtherRows];
     276      CoinZeroN(rhsModification,numberOtherRows);
     277      rhs->matrix()->times(solution,rhsModification) ;
     278      for ( i=0;i<numberRows;i++) {
     279        int iRow = whichRow[i];
     280        if (rowLower_[i]>-1.0e20)
     281          rowLower_[i] -= rhsModification[iRow];
     282        if (rowUpper_[i]<1.0e20)
     283          rowUpper_[i] -= rhsModification[iRow];
     284      }
     285      delete [] rhsModification;
     286      setObjectiveOffset(rhs->objectiveOffset()-offset);
     287      // And set objective value to match
     288      setObjectiveValue(rhs->objectiveValue());
     289    }
     290    delete [] solution;
     291  } 
     292}
     293// Subproblem constructor
     294ClpSimplex::ClpSimplex ( const ClpSimplex * rhs,
     295                         int numberRows, const int * whichRow,
     296                         int numberColumns, const int * whichColumn,
     297                         bool dropNames, bool dropIntegers,bool fixOthers)
     298  : ClpModel(rhs, numberRows, whichRow,
     299             numberColumns,whichColumn,dropNames,dropIntegers),
     300    columnPrimalInfeasibility_(0.0),
     301    rowPrimalInfeasibility_(0.0),
     302    columnPrimalSequence_(-2),
     303    rowPrimalSequence_(-2),
     304    columnDualInfeasibility_(0.0),
     305    rowDualInfeasibility_(0.0),
     306    moreSpecialOptions_(2),
     307    baseIteration_(0),
     308    primalToleranceToGetOptimal_(-1.0),
     309    remainingDualInfeasibility_(0.0),
     310    largeValue_(1.0e15),
     311    largestPrimalError_(0.0),
     312    largestDualError_(0.0),
     313    alphaAccuracy_(-1.0),
     314    dualBound_(1.0e10),
     315    alpha_(0.0),
     316    theta_(0.0),
     317  lowerIn_(0.0),
     318  valueIn_(0.0),
     319  upperIn_(-COIN_DBL_MAX),
     320  dualIn_(0.0),
     321  lowerOut_(-1),
     322  valueOut_(-1),
     323  upperOut_(-1),
     324  dualOut_(-1),
     325  dualTolerance_(0.0),
     326  primalTolerance_(0.0),
     327  sumDualInfeasibilities_(0.0),
     328  sumPrimalInfeasibilities_(0.0),
     329  infeasibilityCost_(1.0e10),
     330  sumOfRelaxedDualInfeasibilities_(0.0),
     331  sumOfRelaxedPrimalInfeasibilities_(0.0),
     332  acceptablePivot_(1.0e-8),
     333  lower_(NULL),
     334  rowLowerWork_(NULL),
     335  columnLowerWork_(NULL),
     336  upper_(NULL),
     337  rowUpperWork_(NULL),
     338  columnUpperWork_(NULL),
     339  cost_(NULL),
     340  rowObjectiveWork_(NULL),
     341  objectiveWork_(NULL),
     342  sequenceIn_(-1),
     343  directionIn_(-1),
     344  sequenceOut_(-1),
     345  directionOut_(-1),
     346  pivotRow_(-1),
     347  lastGoodIteration_(-100),
     348  dj_(NULL),
     349  rowReducedCost_(NULL),
     350  reducedCostWork_(NULL),
     351  solution_(NULL),
     352  rowActivityWork_(NULL),
     353  columnActivityWork_(NULL),
     354  auxiliaryModel_(NULL),
     355  numberDualInfeasibilities_(0),
     356  numberDualInfeasibilitiesWithoutFree_(0),
     357  numberPrimalInfeasibilities_(100),
     358  numberRefinements_(0),
     359  pivotVariable_(NULL),
     360  factorization_(NULL),
     361    savedSolution_(NULL),
     362  numberTimesOptimal_(0),
     363  disasterArea_(NULL),
     364  changeMade_(1),
     365  algorithm_(0),
     366  forceFactorization_(-1),
     367  perturbation_(100),
     368  nonLinearCost_(NULL),
     369  lastBadIteration_(-999999),
     370  lastFlaggedIteration_(-999999),
     371  numberFake_(0),
     372  numberChanged_(0),
     373  progressFlag_(0),
     374  firstFree_(-1),
     375  numberExtraRows_(0),
     376  maximumBasic_(0),
     377  incomingInfeasibility_(1.0),
     378  allowedInfeasibility_(10.0),
     379    automaticScale_(0),
     380  baseModel_(NULL)
     381{
     382  int i;
     383  for (i=0;i<6;i++) {
     384    rowArray_[i]=NULL;
     385    columnArray_[i]=NULL;
     386  }
     387  for (i=0;i<4;i++) {
     388    spareIntArray_[i]=0;
     389    spareDoubleArray_[i]=0.0;
     390  }
     391  saveStatus_=NULL;
     392  factorization_ = new ClpFactorization(*rhs->factorization_);
    246393  // say Steepest pricing
    247394  dualRowPivot_ = new ClpDualRowSteepest();
  • trunk/Clp/src/ClpSimplex.hpp

    r1147 r1154  
    9191  */
    9292  ClpSimplex (const ClpModel * wholeModel,
     93              int numberRows, const int * whichRows,
     94              int numberColumns, const int * whichColumns,
     95              bool dropNames=true, bool dropIntegers=true,
     96              bool fixOthers=false);
     97  /** Subproblem constructor.  A subset of whole model is created from the
     98      row and column lists given.  The new order is given by list order and
     99      duplicates are allowed.  Name and integer information can be dropped
     100      Can optionally modify rhs to take into account variables NOT in list
     101      in this case duplicates are not allowed (also see getbackSolution)
     102  */
     103  ClpSimplex (const ClpSimplex * wholeModel,
    93104              int numberRows, const int * whichRows,
    94105              int numberColumns, const int * whichColumns,
Note: See TracChangeset for help on using the changeset viewer.