- Timestamp:
- Jul 16, 2007 4:20:32 PM (14 years ago)
- Location:
- trunk/Cbc/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cbc/src/CbcLinked.cpp
r687 r692 5712 5712 double tolerance = info->primalTolerance_; 5713 5713 double direction = info->direction_; 5714 bool infeasible=false; 5714 5715 if (xyRow_>=0) { 5715 5716 assert (!boundType_); … … 5721 5722 // if move makes infeasible then make at least default 5722 5723 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) { 5724 5725 infeasibility_ += fabs(movement*coefficient_)*CoinMax(fabs(valueP),info->defaultDual_); 5726 infeasible=true; 5727 } 5725 5728 } else { 5726 5729 // objective … … 5737 5740 // if move makes infeasible then make at least default 5738 5741 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) { 5740 5743 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 } 5744 5753 otherInfeasibility_ = CoinMax(1.0e-12,infeasibility_*10.0); 5754 } 5755 // Gets sum of movements to correct value 5756 double 5757 OsiBiLinear::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; 5745 5839 } 5746 5840 // This looks at solution and sets bounds to contain solution … … 7889 7983 numberObjects_=numberObjectsToUse_; 7890 7984 // Use shadow prices 7891 info->defaultDual_=0.0;7985 //info->defaultDual_=0.0; 7892 7986 int numberUnsatisfied=OsiChooseStrong::setupList ( info, initialize); 7893 7987 solver->setNumberObjects(numberObjects); … … 7910 8004 OsiChooseStrongSubset::chooseVariable( OsiSolverInterface * solver, OsiBranchingInformation *info, bool fixVariables) 7911 8005 { 7912 int numberObjects = solver->numberObjects();7913 solver->setNumberObjects(numberObjectsToUse_);7914 numberObjects_=numberObjectsToUse_;8006 //int numberObjects = solver->numberObjects(); 8007 //solver->setNumberObjects(numberObjectsToUse_); 8008 //numberObjects_=numberObjectsToUse_; 7915 8009 // Use shadow prices 7916 info->defaultDual_=0.0;8010 //info->defaultDual_=0.0; 7917 8011 int returnCode=OsiChooseStrong::chooseVariable(solver,info,fixVariables); 7918 solver->setNumberObjects(numberObjects);7919 numberObjects_=numberObjects;8012 //solver->setNumberObjects(numberObjects); 8013 //numberObjects_=numberObjects; 7920 8014 return returnCode; 7921 8015 } … … 8023 8117 OsiBiLinear * obj = dynamic_cast<OsiBiLinear *> (objects_[i]); 8024 8118 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); 8027 8122 } 8028 8123 bool satisfied=false; 8029 8124 whichWay=-1; 8030 if ( infeasibility_<=info->integerTolerance_) {8125 if (!infeasibility_) { 8031 8126 otherInfeasibility_ = 1.0; 8032 8127 satisfied=true; -
trunk/Cbc/src/CbcLinked.hpp
r687 r692 844 844 /// Sets infeasibility and other when pseudo shadow prices 845 845 void getPseudoShadow(const OsiBranchingInformation * info); 846 /// Gets sum of movements to correct value 847 double getMovement(const OsiBranchingInformation * info); 846 848 847 849 protected: -
trunk/Cbc/src/CbcModel.cpp
r687 r692 4495 4495 addUpdateInformation(update); 4496 4496 } 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 } 4498 4524 } 4499 4525 }
Note: See TracChangeset
for help on using the changeset viewer.