Changeset 165


Ignore:
Timestamp:
Sep 30, 2005 2:37:20 PM (14 years ago)
Author:
forrest
Message:

CbcFeasibility?

Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/CbcModel.cpp

    r162 r165  
    3030#include "CbcCountRowCut.hpp"
    3131#include "CbcCutGenerator.hpp"
     32#include "CbcFeasibilityBase.hpp"
    3233// include Probing
    3334#include "CglProbing.hpp"
     
    402403  if (!nodeCompare_)
    403404    nodeCompare_=new CbcCompareDefault();;
     405  if (!problemFeasibility_)
     406    problemFeasibility_=new CbcFeasibilityBase();
    404407# ifdef CBC_DEBUG
    405408  std::string problemName ;
     
    442445*/
    443446  bool feasible = resolve() ;
     447  if (problemFeasibility_->feasible(this,0)<0) {
     448    feasible=false; // pretend infeasible
     449  }
    444450/*
    445451  If the linear relaxation of the root is infeasible, bail out now. Otherwise,
     
    660666      if (anyAction == -1)
    661667      { feasible = resolve() ;
     668      if (problemFeasibility_->feasible(this,0)<0) {
     669        feasible=false; // pretend infeasible
     670      }
    662671        resolved = true ;
    663672#       ifdef CBC_DEBUG
     
    10521061              solver_->setHintParam(OsiDoInBranchAndCut,true,OsiHintDo,NULL) ;
    10531062              resolved = true ;
     1063              if (problemFeasibility_->feasible(this,0)<0) {
     1064                feasible=false; // pretend infeasible
     1065              }
    10541066              if (feasible)
    10551067              { newNode->setObjectiveValue(direction*
     
    16441656  dblParam_[CbcStartSeconds] = 0.0;
    16451657  nodeCompare_=new CbcCompareDefault();;
     1658  problemFeasibility_=new CbcFeasibilityBase();
    16461659  tree_= new CbcTree();
    16471660  branchingMethod_=NULL;
     
    17291742
    17301743  nodeCompare_=new CbcCompareDefault();;
     1744  problemFeasibility_=new CbcFeasibilityBase();
    17311745  tree_= new CbcTree();
    17321746  branchingMethod_=NULL;
     
    19451959  }
    19461960  nodeCompare_=rhs.nodeCompare_->clone();
     1961  problemFeasibility_=rhs.problemFeasibility_->clone();
    19471962  tree_= rhs.tree_->clone();
    19481963  branchingMethod_=rhs.branchingMethod_;
     
    21672182    }
    21682183    nodeCompare_=rhs.nodeCompare_->clone();
     2184    problemFeasibility_=rhs.problemFeasibility_->clone();
    21692185    delete tree_;
    21702186    tree_= rhs.tree_->clone();
     
    22582274  delete nodeCompare_;
    22592275  nodeCompare_=NULL;
     2276  delete problemFeasibility_;
     2277  problemFeasibility_=NULL;
    22602278  delete [] addedCuts_;
    22612279  addedCuts_=NULL;
     
    27322750    objectiveValue= node->objectiveValue();
    27332751  feasible = resolve() ;
     2752  if (problemFeasibility_->feasible(this,0)<0) {
     2753    feasible=false; // pretend infeasible
     2754  }
    27342755 
    27352756  // Update branching information if wanted
     
    59385959  nodeCompare_ = compare.clone();
    59395960}
     5961void
     5962CbcModel::setProblemFeasibility(CbcFeasibilityBase * feasibility)
     5963{
     5964  delete problemFeasibility_;
     5965  problemFeasibility_ = feasibility->clone();
     5966}
     5967void
     5968CbcModel::setProblemFeasibility(CbcFeasibilityBase & feasibility)
     5969{
     5970  delete problemFeasibility_;
     5971  problemFeasibility_ = feasibility.clone();
     5972}
    59405973// Set the strategy. Clones
    59415974void
  • trunk/CbcNode.cpp

    r154 r165  
    2323#include "OsiCuts.hpp"
    2424#include "CbcCountRowCut.hpp"
     25#include "CbcFeasibilityBase.hpp"
    2526#include "CbcMessage.hpp"
    2627#include "OsiClpSolverInterface.hpp"
     
    862863  const double * lower = solver->getColLower();
    863864  const double * upper = solver->getColUpper();
    864   int anyAction=0;
     865  // See what user thinks
     866  int anyAction=model->problemFeasibility()->feasible(model,0);
     867  if (anyAction) {
     868    // will return -2 if infeasible , 0 if treat as integer
     869    return anyAction-1;
     870  }
    865871  double integerTolerance =
    866872    model->getDblParam(CbcModel::CbcIntegerTolerance);
     
    13581364            // See if integer solution
    13591365            if (model->feasibleSolution(choice[i].numIntInfeasDown,
    1360                                         choice[i].numObjInfeasDown))
    1361               { model->setBestSolution(CBC_STRONGSOL,
    1362                                        newObjectiveValue,
    1363                                        solver->getColSolution()) ;
     1366                                        choice[i].numObjInfeasDown)
     1367                &&model->problemFeasibility()->feasible(model,-1)>=0) {
     1368              model->setBestSolution(CBC_STRONGSOL,
     1369                                     newObjectiveValue,
     1370                                     solver->getColSolution()) ;
    13641371              model->incrementUsed(solver->getColSolution());
    13651372              if (newObjectiveValue >= model->getCutoff())      //  *new* cutoff
    13661373                objectiveChange = 1.0e100 ;
    1367               }
     1374            }
    13681375          }
    13691376        } else if (iStatus==1) {
     
    14421449            // See if integer solution
    14431450            if (model->feasibleSolution(choice[i].numIntInfeasUp,
    1444                                         choice[i].numObjInfeasUp))
    1445               { model->setBestSolution(CBC_STRONGSOL,
    1446                                        newObjectiveValue,
    1447                                        solver->getColSolution()) ;
     1451                                        choice[i].numObjInfeasUp)
     1452                &&model->problemFeasibility()->feasible(model,-1)>=0) {
     1453              model->setBestSolution(CBC_STRONGSOL,
     1454                                     newObjectiveValue,
     1455                                     solver->getColSolution()) ;
    14481456              model->incrementUsed(solver->getColSolution());
    14491457              if (newObjectiveValue >= model->getCutoff())      //  *new* cutoff
    14501458                objectiveChange = 1.0e100 ;
    1451               }
     1459            }
    14521460          }
    14531461        } else if (iStatus==1) {
     
    17701778  const double * lower = solver->getColLower();
    17711779  const double * upper = solver->getColUpper();
    1772   int anyAction=0;
     1780  // See what user thinks
     1781  int anyAction=model->problemFeasibility()->feasible(model,0);
     1782  if (anyAction) {
     1783    // will return -2 if infeasible , 0 if treat as integer
     1784    return anyAction-1;
     1785  }
    17731786  int i;
    17741787  int stateOfSearch = model->stateOfSearch();
     
    22492262              // See if integer solution
    22502263              if (model->feasibleSolution(choice.numIntInfeasDown,
    2251                                           choice.numObjInfeasDown)) {
     2264                                          choice.numObjInfeasDown)
     2265                  &&model->problemFeasibility()->feasible(model,-1)>=0) {
    22522266                model->setBestSolution(CBC_STRONGSOL,
    22532267                                       newObjectiveValue,
     
    23082322              // See if integer solution
    23092323              if (model->feasibleSolution(choice.numIntInfeasUp,
    2310                                           choice.numObjInfeasUp)) {
     2324                                          choice.numObjInfeasUp)
     2325                  &&model->problemFeasibility()->feasible(model,-1)>=0) {
    23112326                model->setBestSolution(CBC_STRONGSOL,
    23122327                                       newObjectiveValue,
  • trunk/include/CbcModel.hpp

    r164 r165  
    2525class CbcTree;
    2626class CbcStrategy;
     27class CbcFeasibilityBase;
    2728
    2829//#############################################################################
     
    954955  //@}
    955956
     957  /** \name Problem feasibility checking */
     958  //@{
     959  // Feasibility functions (which may be overridden by inheritance)
     960  inline CbcFeasibilityBase * problemFeasibility() const
     961  { return problemFeasibility_;};
     962  void setProblemFeasibility(CbcFeasibilityBase * feasibility);
     963  void setProblemFeasibility(CbcFeasibilityBase & feasibility);
     964  //@}
     965
    956966  /** \name Tree methods and subtree methods */
    957967  //@{
     
    14511461  /// User node comparison function
    14521462  CbcCompareBase * nodeCompare_;
     1463  /// User feasibility function (see CbcFeasibleBase.hpp)
     1464  CbcFeasibilityBase * problemFeasibility_;
    14531465  /// Tree
    14541466  CbcTree * tree_;
Note: See TracChangeset for help on using the changeset viewer.