Ignore:
Timestamp:
Oct 1, 2008 11:45:12 AM (11 years ago)
Author:
forrest
Message:

changes for factorization and aux region

File:
1 edited

Legend:

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

    r1276 r1286  
    3131  sequence_(1),
    3232  numberInfeasibilities_(0),
     33  depth_(0),
    3334  numberFixed_(0),
    3435  flags_(0),
     
    6061  sequence_(1),
    6162  numberInfeasibilities_(0),
     63  depth_(0),
    6264  numberFixed_(0),
    6365  flags_(0),
     
    8385  int numberTotal = numberRows+numberColumns;
    8486  int maximumTotal = maximumRows_+maximumColumns_;
     87  depth_ = depth;
    8588  // save stuff
    8689  objectiveValue_ = model->objectiveValue()*model->optimizationDirection();
     
    163166      }
    164167      pivotVariables_ = new int [maximumRows_];
    165       if (model->pivotVariable())
     168      if (model->pivotVariable()&&model->numberRows()==numberRows)
    166169        CoinMemcpyN(model->pivotVariable(),numberRows,pivotVariables_);
     170      else
     171        CoinFillN(pivotVariables_,numberRows,-1);
    167172    }
    168173  }
     
    183188  int nFix=0;
    184189  double gap = CoinMax(model->dualObjectiveLimit()-objectiveValue_,1.0e-4);
    185 #define PSEUDO 2
    186 #if PSEUDO==1
     190#define PSEUDO 3
     191#if PSEUDO==1||PSEUDO==2
    187192  // Column copy of matrix
    188193  ClpPackedMatrix * matrix = model->clpScaledMatrix();
     
    196201  double direction = model->optimizationDirection();
    197202  const double * dual = dualSolution_+numberColumns;
    198 #elif PSEUDO==2
     203#if PSEUDO==2
     204  double * activeWeight = new double [numberRows];
     205  const double * rowLower = model->rowLower();
     206  const double * rowUpper = model->rowUpper();
     207  const double * rowActivity = model->primalRowSolution();
     208  double tolerance = 1.0e-6;
     209  for (int iRow = 0;iRow<numberRows;iRow++) {
     210    // could use pi to see if active or activity
     211    if (rowActivity[iRow]>rowUpper[iRow]-tolerance
     212        ||rowActivity[iRow]<rowLower[iRow]+tolerance) {
     213      activeWeight[iRow]=0.0;
     214    } else {
     215      activeWeight[iRow]=-1.0;
     216    }
     217  }
     218  for (int iColumn=0;iColumn<numberColumns;iColumn++) {
     219    if (integerType[iColumn]) {
     220      double value = solution[iColumn];
     221      if (fabs(value-floor(value+0.5))>1.0e-6) {
     222        CoinBigIndex start = columnStart[iColumn];
     223        CoinBigIndex end = start + columnLength[iColumn];
     224        for (CoinBigIndex j=start;j<end;j++) {
     225          int iRow = row[j];
     226          if (activeWeight[iRow]>=0.0)
     227            activeWeight[iRow] += 1.0;
     228        }
     229      }
     230    }
     231  }
     232  for (int iRow = 0;iRow<numberRows;iRow++) {
     233    if (activeWeight[iRow]>0.0) {
     234      // could use pi
     235      activeWeight[iRow] = 1.0/activeWeight[iRow];
     236    } else {
     237      activeWeight[iRow]=0.0;
     238    }
     239  }
     240#endif
     241#elif PSEUDO==3
    199242  const double * downPseudo = stuff->downPseudo_;
    200243  const int * numberDown = stuff->numberDown_;
     
    214257        numberInfeasibilities_++;
    215258        sumInfeasibilities_ += fabs(value-nearest);
    216 #if PSEUDO==1
     259#if PSEUDO==1 || PSEUDO ==2
    217260        double upValue = 0.0;
    218261        double downValue = 0.0;
    219         double value2 = direction*objective[iColumn];
     262        double value2 = objective ? direction*objective[iColumn] : 0.0;
    220263        if (value2) {
    221264          if (value2>0.0)
    222             upValue += value2;
     265            upValue += 1.5*value2;
    223266          else
    224             downValue -= value2;
     267            downValue -= 1.5*value2;
    225268        }
    226269        CoinBigIndex start = columnStart[iColumn];
     
    231274          if (value2) {
    232275            value2 *= element[j];
     276#if PSEUDO==2
     277            assert (activeWeight[iRow]>0.0||fabs(dual[iRow])<1.0e-6);
     278            value2 *= activeWeight[iRow];
     279#endif
    233280            if (value2>0.0)
    234281              upValue += value2;
     
    237284          }
    238285        }
     286        upValue = CoinMax(upValue,1.0e-8);
     287        downValue = CoinMax(downValue,1.0e-8);
    239288        upValue *= ceil(value)-value;
    240289        downValue *= value-floor(value);
     
    245294          infeasibility = 0.1*CoinMax(upValue,downValue)+
    246295            0.9*CoinMin(upValue,downValue) + integerTolerance;
    247 #elif PSEUDO==2
     296#elif PSEUDO==3
    248297        double upValue = (ceil(value)-value)*(upPseudo[iInteger]/(1.0+numberUp[iInteger]+numberUpInfeasible[iInteger]));
    249298        double downValue = (value-floor(value))*(downPseudo[iInteger]/(1.0+numberDown[iInteger]+numberDownInfeasible[iInteger]));
     
    309358    }
    310359  }
     360#if PSEUDO == 2
     361  delete [] activeWeight;
     362#endif
    311363  if (lower_) {
    312364    // save bounds
     
    497549  }
    498550}
     551// Choose a new variable
     552void
     553ClpNode::chooseVariable(ClpSimplex * model, ClpNodeStuff * info)
     554{
     555#if 0
     556  int way=branchState_.firstBranch;
     557  if (branchState_.branch>0)
     558    way=1-way;
     559  assert (!branchState_.branch);
     560  // We need to use pseudo costs to choose a variable
     561  int numberColumns = model->numberColumns();
     562#endif
     563}
    499564// Fix on reduced costs
    500565int
    501566ClpNode::fixOnReducedCosts(ClpSimplex * model)
    502567{
     568 
    503569  return 0;
    504570}
     
    609675    saveOptions_ = rhs.saveOptions_;
    610676    solverOptions_ = rhs.solverOptions_;
    611     if (nDepth_>=0) {
    612       int n = (1<<nDepth_)+1+nDepth_;
     677    int n = maximumNodes();
     678    if (n) {
    613679      for (int i=0;i<n;i++)
    614680        delete nodeInfo_[i];
     
    663729  delete [] numberDownInfeasible_;
    664730  delete [] numberUpInfeasible_;
    665   if (nDepth_>=0) {
    666     int n = (1<<nDepth_)+1+nDepth_;
     731  int n = maximumNodes();
     732  if (n) {
    667733    for (int i=0;i<n;i++)
    668734      delete nodeInfo_[i];
    669735    delete [] nodeInfo_;
    670736  }
     737}
     738// Return maximum number of nodes
     739int
     740ClpNodeStuff::maximumNodes() const
     741{
     742  int n;
     743  if ((solverOptions_&32)==0)
     744    n = (1<<nDepth_)+1+nDepth_;
     745  else if (nDepth_)
     746    n = 1+1+nDepth_;
     747  else
     748    n = 0;
     749  return n;
    671750}
    672751/* Fill with pseudocosts */
Note: See TracChangeset for help on using the changeset viewer.