Changeset 686 for branches/devel


Ignore:
Timestamp:
Jul 12, 2007 12:24:52 PM (12 years ago)
Author:
forrest
Message:

for pseudo shadow prices in LOS

Location:
branches/devel/Cbc/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/devel/Cbc/src/CbcLinked.cpp

    r685 r686  
    56515651  return infeasibility_;
    56525652}
    5653 
     5653// Sets infeasibility and other when pseudo shadow prices
     5654void
     5655OsiBiLinear::getPseudoShadow(const OsiBranchingInformation * info)
     5656{
     5657  // order is LxLy, LxUy, UxLy and UxUy
     5658  double xB[2];
     5659  double yB[2];
     5660  xB[0]=info->lower_[xColumn_];
     5661  xB[1]=info->upper_[xColumn_];
     5662  yB[0]=info->lower_[yColumn_];
     5663  yB[1]=info->upper_[yColumn_];
     5664  double x = info->solution_[xColumn_];
     5665  x = CoinMax(x,xB[0]);
     5666  x = CoinMin(x,xB[1]);
     5667  double y = info->solution_[yColumn_];
     5668  y = CoinMax(y,yB[0]);
     5669  y = CoinMin(y,yB[1]);
     5670  int j;
     5671  double xyTrue = x*y;
     5672  double xyLambda = 0.0;
     5673  if ((branchingStrategy_&4)==0) {
     5674    for (j=0;j<4;j++) {
     5675      int iX = j>>1;
     5676      int iY = j&1;
     5677      xyLambda += xB[iX]*yB[iY]*info->solution_[firstLambda_+j];
     5678    }
     5679  } else {
     5680    if (xyRow_>=0) {
     5681      const double * element = info->elementByColumn_;
     5682      const int * row = info->row_;
     5683      const CoinBigIndex * columnStart = info->columnStart_;
     5684      const int * columnLength = info->columnLength_;
     5685      for (j=0;j<4;j++) {
     5686        int iColumn = firstLambda_+j;
     5687        int iStart = columnStart[iColumn];
     5688        int iEnd = iStart + columnLength[iColumn];
     5689        int k=iStart;
     5690        double sol = info->solution_[iColumn];
     5691        for (;k<iEnd;k++) {
     5692          if (xyRow_==row[k])
     5693            xyLambda += element[k]*sol;
     5694        }
     5695      }
     5696    } else {
     5697      // objective
     5698      const double * objective = info->objective_;
     5699      for (j=0;j<4;j++) {
     5700        int iColumn = firstLambda_+j;
     5701        double sol = info->solution_[iColumn];
     5702        xyLambda += objective[iColumn]*sol;
     5703      }
     5704    }
     5705    xyLambda /= coefficient_;
     5706  }
     5707  assert (info->defaultDual_>=0.0);
     5708  // If we move to xy then we move by coefficient * (xyTrue-xyLambda) on row xyRow_
     5709  double movement = xyTrue-xyLambda;
     5710  infeasibility_=0.0;
     5711  const double * pi = info->pi_;
     5712  const double * activity = info->rowActivity_;
     5713  const double * lower = info->rowLower_;
     5714  const double * upper = info->rowUpper_;
     5715  double tolerance = info->primalTolerance_;
     5716  double direction = info->direction_;
     5717  if (xyRow_>=0) {
     5718    assert (!boundType_);
     5719    if (lower[xyRow_]<-1.0e20)
     5720      assert (pi[xyRow_]<=1.0e-3);
     5721    if (upper[xyRow_]>1.0e20)
     5722      assert (pi[xyRow_]>=-1.0e-3);
     5723    double valueP = pi[xyRow_]*direction;
     5724    // if move makes infeasible then make at least default
     5725    double newValue = activity[xyRow_] + movement*coefficient_;
     5726    if (newValue>upper[xyRow_]+tolerance||newValue<lower[xyRow_]-tolerance)
     5727      infeasibility_ += fabs(movement*coefficient_)*CoinMax(fabs(valueP),info->defaultDual_);
     5728  } else {
     5729    // objective
     5730    assert (movement>-1.0e-7);
     5731    infeasibility_ += movement;
     5732  }
     5733  for (int i=0;i<numberExtraRows_;i++) {
     5734    int iRow = extraRow_[i];
     5735    if (lower[iRow]<-1.0e20)
     5736      assert (pi[iRow]<=1.0e-3);
     5737    if (upper[iRow]>1.0e20)
     5738      assert (pi[iRow]>=-1.0e-3);
     5739    double valueP = pi[iRow]*direction;
     5740    // if move makes infeasible then make at least default
     5741    double newValue = activity[iRow] + movement*multiplier_[i];
     5742    if (newValue>upper[iRow]+tolerance||newValue<lower[iRow]-tolerance)
     5743      infeasibility_ += fabs(movement*multiplier_[i])*CoinMax(fabs(valueP),info->defaultDual_);
     5744  }
     5745  if (infeasibility_<1.0e-7)
     5746    infeasibility_=0.0;
     5747  otherInfeasibility_ = CoinMax(1.0e-12,infeasibility_*10.0);
     5748}
    56545749// This looks at solution and sets bounds to contain solution
    56555750double
     
    68216916      if (newUp>upper[iRow]+tolerance||newUp<lower[iRow]-tolerance)
    68226917        u = CoinMax(u,info->defaultDual_);
    6823       upEstimate += u*upMovement;
     6918      upEstimate += u*upMovement*fabs(el2);
    68246919      // if down makes infeasible then make at least default
    68256920      double newDown = activity[iRow] - downMovement*el2;
    68266921      if (newDown>upper[iRow]+tolerance||newDown<lower[iRow]-tolerance)
    68276922        d = CoinMax(d,info->defaultDual_);
    6828       downEstimate += d*downMovement;
     6923      downEstimate += d*downMovement*fabs(el2);
    68296924    }
    68306925    if (downEstimate>=upEstimate) {
  • branches/devel/Cbc/src/CbcLinked.hpp

    r680 r686  
    851851  /// Compute lambdas if coefficients not changing
    852852  void computeLambdas(const OsiSolverInterface * solver,double lambda[4]) const;
     853  /// Sets infeasibility and other when pseudo shadow prices
     854  void getPseudoShadow(const OsiBranchingInformation * info);
    853855  /// data
    854856 
Note: See TracChangeset for help on using the changeset viewer.