Changeset 692


Ignore:
Timestamp:
Jul 16, 2007 4:20:32 PM (12 years ago)
Author:
forrest
Message:

changes so OsiIntegers? have pseudocosts updated on branch

Location:
trunk/Cbc/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cbc/src/CbcLinked.cpp

    r687 r692  
    57125712  double tolerance = info->primalTolerance_;
    57135713  double direction = info->direction_;
     5714  bool infeasible=false;
    57145715  if (xyRow_>=0) {
    57155716    assert (!boundType_);
     
    57215722    // if move makes infeasible then make at least default
    57225723    double newValue = activity[xyRow_] + movement*coefficient_;
    5723     if (newValue>upper[xyRow_]+tolerance||newValue<lower[xyRow_]-tolerance)
     5724    if (newValue>upper[xyRow_]+tolerance||newValue<lower[xyRow_]-tolerance) {
    57245725      infeasibility_ += fabs(movement*coefficient_)*CoinMax(fabs(valueP),info->defaultDual_);
     5726      infeasible=true;
     5727    }
    57255728  } else {
    57265729    // objective
     
    57375740    // if move makes infeasible then make at least default
    57385741    double newValue = activity[iRow] + movement*multiplier_[i];
    5739     if (newValue>upper[iRow]+tolerance||newValue<lower[iRow]-tolerance)
     5742    if (newValue>upper[iRow]+tolerance||newValue<lower[iRow]-tolerance) {
    57405743      infeasibility_ += fabs(movement*multiplier_[i])*CoinMax(fabs(valueP),info->defaultDual_);
    5741   }
    5742   if (infeasibility_<1.0e-7)
    5743     infeasibility_=0.0;
     5744      infeasible=true;
     5745    }
     5746  }
     5747  if (infeasibility_<info->integerTolerance_) {
     5748    if (!infeasible)
     5749      infeasibility_=0.0;
     5750    else
     5751      infeasibility_ = info->integerTolerance_;
     5752  }
    57445753  otherInfeasibility_ = CoinMax(1.0e-12,infeasibility_*10.0);
     5754}
     5755// Gets sum of movements to correct value
     5756double
     5757OsiBiLinear::getMovement(const OsiBranchingInformation * info)
     5758{
     5759  // order is LxLy, LxUy, UxLy and UxUy
     5760  double xB[2];
     5761  double yB[2];
     5762  xB[0]=info->lower_[xColumn_];
     5763  xB[1]=info->upper_[xColumn_];
     5764  yB[0]=info->lower_[yColumn_];
     5765  yB[1]=info->upper_[yColumn_];
     5766  double x = info->solution_[xColumn_];
     5767  x = CoinMax(x,xB[0]);
     5768  x = CoinMin(x,xB[1]);
     5769  double y = info->solution_[yColumn_];
     5770  y = CoinMax(y,yB[0]);
     5771  y = CoinMin(y,yB[1]);
     5772  int j;
     5773  double xyTrue = x*y;
     5774  double xyLambda = 0.0;
     5775  if ((branchingStrategy_&4)==0) {
     5776    for (j=0;j<4;j++) {
     5777      int iX = j>>1;
     5778      int iY = j&1;
     5779      xyLambda += xB[iX]*yB[iY]*info->solution_[firstLambda_+j];
     5780    }
     5781  } else {
     5782    if (xyRow_>=0) {
     5783      const double * element = info->elementByColumn_;
     5784      const int * row = info->row_;
     5785      const CoinBigIndex * columnStart = info->columnStart_;
     5786      const int * columnLength = info->columnLength_;
     5787      for (j=0;j<4;j++) {
     5788        int iColumn = firstLambda_+j;
     5789        int iStart = columnStart[iColumn];
     5790        int iEnd = iStart + columnLength[iColumn];
     5791        int k=iStart;
     5792        double sol = info->solution_[iColumn];
     5793        for (;k<iEnd;k++) {
     5794          if (xyRow_==row[k])
     5795            xyLambda += element[k]*sol;
     5796        }
     5797      }
     5798    } else {
     5799      // objective
     5800      const double * objective = info->objective_;
     5801      for (j=0;j<4;j++) {
     5802        int iColumn = firstLambda_+j;
     5803        double sol = info->solution_[iColumn];
     5804        xyLambda += objective[iColumn]*sol;
     5805      }
     5806    }
     5807    xyLambda /= coefficient_;
     5808  }
     5809  // If we move to xy then we move by coefficient * (xyTrue-xyLambda) on row xyRow_
     5810  double movement = xyTrue-xyLambda;
     5811  const double * activity = info->rowActivity_;
     5812  const double * lower = info->rowLower_;
     5813  const double * upper = info->rowUpper_;
     5814  double tolerance = info->primalTolerance_;
     5815  double  infeasibility=0.0;
     5816  if (xyRow_>=0) {
     5817    assert (!boundType_);
     5818    // if move makes infeasible
     5819    double newValue = activity[xyRow_] + movement*coefficient_;
     5820    if (newValue>upper[xyRow_]+tolerance)
     5821      infeasibility += newValue-upper[xyRow_];
     5822    else if (newValue<lower[xyRow_]-tolerance)
     5823      infeasibility += lower[xyRow_]-newValue;
     5824  } else {
     5825    // objective
     5826    assert (movement>-1.0e-7);
     5827    infeasibility += movement;
     5828  }
     5829  for (int i=0;i<numberExtraRows_;i++) {
     5830    int iRow = extraRow_[i];
     5831    // if move makes infeasible
     5832    double newValue = activity[iRow] + movement*multiplier_[i];
     5833    if (newValue>upper[iRow]+tolerance)
     5834      infeasibility += newValue-upper[iRow];
     5835    else if (newValue<lower[iRow]-tolerance)
     5836      infeasibility += lower[iRow]-newValue;
     5837  }
     5838  return infeasibility;
    57455839}
    57465840// This looks at solution and sets bounds to contain solution
     
    78897983  numberObjects_=numberObjectsToUse_;
    78907984  // Use shadow prices
    7891   info->defaultDual_=0.0;
     7985  //info->defaultDual_=0.0;
    78927986  int numberUnsatisfied=OsiChooseStrong::setupList ( info, initialize);
    78937987  solver->setNumberObjects(numberObjects);
     
    79108004OsiChooseStrongSubset::chooseVariable( OsiSolverInterface * solver, OsiBranchingInformation *info, bool fixVariables)
    79118005{
    7912   int numberObjects = solver->numberObjects();
    7913   solver->setNumberObjects(numberObjectsToUse_);
    7914   numberObjects_=numberObjectsToUse_;
     8006  //int numberObjects = solver->numberObjects();
     8007  //solver->setNumberObjects(numberObjectsToUse_);
     8008  //numberObjects_=numberObjectsToUse_;
    79158009  // Use shadow prices
    7916   info->defaultDual_=0.0;
     8010  //info->defaultDual_=0.0;
    79178011  int returnCode=OsiChooseStrong::chooseVariable(solver,info,fixVariables);
    7918   solver->setNumberObjects(numberObjects);
    7919   numberObjects_=numberObjects;
     8012  //solver->setNumberObjects(numberObjects);
     8013  //numberObjects_=numberObjects;
    79208014  return returnCode;
    79218015}
     
    80238117    OsiBiLinear * obj = dynamic_cast<OsiBiLinear *> (objects_[i]);
    80248118    assert (obj);
    8025     obj->getPseudoShadow(info);
    8026     infeasibility_ += objects_[i]->infeasibility();
     8119    //obj->getPseudoShadow(info);
     8120    //infeasibility_ += objects_[i]->infeasibility(info,whichWay);
     8121    infeasibility_ += obj->getMovement(info);
    80278122  }
    80288123  bool satisfied=false;
    80298124  whichWay=-1;
    8030   if (infeasibility_<=info->integerTolerance_) {
     8125  if (!infeasibility_) {
    80318126    otherInfeasibility_ = 1.0;
    80328127    satisfied=true;
  • trunk/Cbc/src/CbcLinked.hpp

    r687 r692  
    844844  /// Sets infeasibility and other when pseudo shadow prices
    845845  void getPseudoShadow(const OsiBranchingInformation * info);
     846  /// Gets sum of movements to correct value
     847  double getMovement(const OsiBranchingInformation * info);
    846848
    847849protected:
  • trunk/Cbc/src/CbcModel.cpp

    r687 r692  
    44954495      addUpdateInformation(update);
    44964496    } else {
    4497       branchingMethod_->updateInformation(solver_,node);
     4497      OsiTwoWayBranchingObject * obj = dynamic_cast<OsiTwoWayBranchingObject *> (bobj);
     4498      if (obj) {
     4499        const OsiObject * object = obj->originalObject();
     4500        // have to compute object number as not saved
     4501        int iObject;
     4502        int iColumn = object->columnNumber();
     4503        for (iObject = 0 ; iObject < numberObjects_ ; iObject++) {
     4504          if (object_[iColumn]->columnNumber()==iColumn)
     4505            break;
     4506        }
     4507        assert (iObject<numberObjects_);
     4508        int branch = obj->firstBranch();
     4509        if (obj->branchIndex()==2)
     4510          branch = 1-branch;
     4511        assert (branch==0||branch==1);
     4512        double originalValue=node->objectiveValue();
     4513        double objectiveValue = solver_->getObjValue()*solver_->getObjSense();
     4514        double changeInObjective = CoinMax(0.0,objectiveValue-originalValue);
     4515        int iStatus = (feasible) ? 0 : 0;
     4516        double value = obj->value();
     4517        if (branch)
     4518          value = ceil(value)-value;
     4519        else
     4520          value = value -floor(value);
     4521        branchingMethod_->chooseMethod()->updateInformation(iObject,branch,changeInObjective,
     4522                                                            value,iStatus);
     4523      }
    44984524    }
    44994525  }
Note: See TracChangeset for help on using the changeset viewer.