/home/coin/SVN-release/Osi-0.96.0/Osi/src/OsiChooseVariable.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2006, International Business Machines
00002 // Corporation and others.  All Rights Reserved.
00003 #ifndef OsiChooseVariable_H
00004 #define OsiChooseVariable_H
00005 
00006 #include <string>
00007 #include <vector>
00008 
00009 #include "CoinWarmStartBasis.hpp"
00010 #include "OsiBranchingObject.hpp"
00011 
00012 class OsiSolverInterface;
00013 class OsiHotInfo;
00014 
00031 class OsiChooseVariable  {
00032  
00033 public:
00034     
00036   OsiChooseVariable ();
00037 
00039   OsiChooseVariable (const OsiSolverInterface * solver);
00040 
00042   OsiChooseVariable (const OsiChooseVariable &);
00043    
00045   OsiChooseVariable & operator= (const OsiChooseVariable& rhs);
00046 
00048   virtual OsiChooseVariable * clone() const;
00049 
00051   virtual ~OsiChooseVariable ();
00052 
00057   virtual int setupList ( OsiBranchingInformation *info, bool initialize);
00071   virtual int chooseVariable( OsiSolverInterface * solver, OsiBranchingInformation *info, bool fixVariables);
00084   int doStrongBranching( OsiSolverInterface * solver, 
00085                          OsiBranchingInformation *info, int numberToDo,
00086                          OsiHotInfo * results, int returnCriterion,
00087                          int & numberDone);
00089   bool feasibleSolution(const OsiBranchingInformation * info,
00090                         const double * solution,
00091                         int numberObjects,
00092                         const OsiObject ** objects);
00094   void saveSolution(const OsiSolverInterface * solver);
00096   void clearGoodSolution();
00098   virtual void updateInformation( const OsiBranchingInformation *info,
00099                                   int branch, OsiHotInfo * hotInfo);
00101   inline double goodObjectiveValue() const
00102   { return goodObjectiveValue_;};
00104   inline double upChange() const
00105   { return upChange_;};
00107   inline double downChange() const
00108   { return downChange_;};
00110   inline const double * goodSolution() const
00111   { return goodSolution_;};
00113   inline int bestObjectIndex() const
00114   { return bestObjectIndex_;};
00116   inline void setBestObjectIndex(int value)
00117   { bestObjectIndex_ = value;};
00119   inline int bestWhichWay() const
00120   { return bestWhichWay_;};
00122   inline void setBestWhichWay(int value)
00123   { bestWhichWay_ = value;};
00125   inline int firstForcedObjectIndex() const
00126   { return firstForcedObjectIndex_;};
00128   inline void setFirstForcedObjectIndex(int value)
00129   { firstForcedObjectIndex_ = value;};
00131   inline int firstForcedWhichWay() const
00132   { return firstForcedWhichWay_;};
00134   inline void setFirstForcedWhichWay(int value)
00135   { firstForcedWhichWay_ = value;};
00137   inline int numberUnsatisfied() const
00138   {return numberUnsatisfied_;};
00140   inline int numberStrong() const
00141   { return numberStrong_;};
00143   inline void setNumberStrong(int value)
00144   { numberStrong_ = value;};
00146   inline int numberOnList() const
00147   { return numberOnList_;};
00149   inline int numberStrongDone() const
00150   { return numberStrongDone_;};
00152   inline int numberStrongIterations() const
00153   { return numberStrongIterations_;};
00155   inline int numberStrongFixed() const
00156   { return numberStrongFixed_;};
00158   inline const int * candidates() const
00159   { return list_;};
00161   inline bool trustStrongForBound() const
00162   { return trustStrongForBound_;};
00164   inline void setTrustStrongForBound(bool yesNo)
00165   { trustStrongForBound_ = yesNo;};
00167   inline bool trustStrongForSolution() const
00168   { return trustStrongForSolution_;};
00170   inline void setTrustStrongForSolution(bool yesNo)
00171   { trustStrongForSolution_ = yesNo;};
00173   void setSolver (const OsiSolverInterface * solver);
00185   inline int status() const
00186   { return status_;};
00187   inline void setStatus(int value)
00188   { status_ = value;};
00189 
00190 
00191 protected:
00192   // Data
00194   double goodObjectiveValue_;
00196   double upChange_;
00198   double downChange_;
00200   double * goodSolution_;
00202   int * list_;
00204   double * useful_;
00206   const OsiSolverInterface * solver_;
00207   /* Status -
00208      -1 Node is infeasible
00209      0  Normal termination - we have a candidate
00210      1  All looks satisfied - no candidate
00211      2  We can change the bound on a variable - but we also have a strong branching candidate
00212      3  We can change the bound on a variable - but we have a non-strong branching candidate
00213      4  We can change the bound on a variable - no other candidates
00214   */
00215   int status_;
00217   int bestObjectIndex_;
00219   int bestWhichWay_;
00221   int firstForcedObjectIndex_;
00223   int firstForcedWhichWay_;
00225   int numberUnsatisfied_;
00227   int numberStrong_;
00229   int numberOnList_;
00231   int numberStrongDone_;
00233   int numberStrongIterations_;
00235   int numberStrongFixed_;
00238   bool trustStrongForBound_;
00240   bool trustStrongForSolution_;
00241 };
00242 
00257 class OsiChooseStrong  : public OsiChooseVariable {
00258  
00259 public:
00260     
00262   OsiChooseStrong ();
00263 
00265   OsiChooseStrong (const OsiSolverInterface * solver);
00266 
00268   OsiChooseStrong (const OsiChooseStrong &);
00269    
00271   OsiChooseStrong & operator= (const OsiChooseStrong& rhs);
00272 
00274   virtual OsiChooseVariable * clone() const;
00275 
00277   virtual ~OsiChooseStrong ();
00278 
00283   virtual int setupList ( OsiBranchingInformation *info, bool initialize);
00297   virtual int chooseVariable( OsiSolverInterface * solver, OsiBranchingInformation *info, bool fixVariables);
00298 
00300   virtual void updateInformation(const OsiBranchingInformation *info,
00301                                   int branch, OsiHotInfo * hotInfo);
00303   inline int numberBeforeTrusted() const
00304   { return numberBeforeTrusted_;};
00306   inline void setNumberBeforeTrusted(int value)
00307   { numberBeforeTrusted_ = value;};
00308 
00315   inline int shadowPriceMode() const
00316   { return shadowPriceMode_;};
00318   inline void setShadowPriceMode(int value)
00319   { shadowPriceMode_ = value;};
00320 
00321 
00322 protected:
00323   // Data
00325   double * upTotalChange_;
00327   double * downTotalChange_;
00329   int * upNumber_;
00331   int * downNumber_;
00333   int numberObjects_;
00335   int numberBeforeTrusted_;
00341   int shadowPriceMode_;
00342 };
00343 
00348 class OsiHotInfo  {
00349  
00350 public:
00351     
00353   OsiHotInfo ();
00354 
00356   OsiHotInfo ( OsiSolverInterface * solver, 
00357                const OsiBranchingInformation *info, const OsiObject ** objects,
00358                int whichObject);
00359 
00361   OsiHotInfo (const OsiHotInfo &);
00362    
00364   OsiHotInfo & operator= (const OsiHotInfo& rhs);
00365 
00367   virtual OsiHotInfo * clone() const;
00368 
00370   virtual ~OsiHotInfo ();
00371 
00375   int updateInformation( const OsiSolverInterface * solver, const OsiBranchingInformation * info,
00376                          OsiChooseVariable * choose);
00378   inline double originalObjectiveValue() const
00379   { return originalObjectiveValue_;};
00381   inline double upChange() const
00382   { assert (branchingObject_->numberBranches()==2); return changes_[1];};
00384   inline double downChange() const
00385   { assert (branchingObject_->numberBranches()==2); return changes_[0];};
00387   inline double change(int k) const
00388   { return changes_[k];};
00389 
00391   inline int upIterationCount() const
00392   { assert (branchingObject_->numberBranches()==2); return iterationCounts_[1];};
00394   inline int downIterationCount() const
00395   { assert (branchingObject_->numberBranches()==2); return iterationCounts_[0];};
00397   inline int iterationCount(int k) const
00398   { return iterationCounts_[k];};
00399 
00401   inline int upStatus() const
00402   { assert (branchingObject_->numberBranches()==2); return statuses_[1];};
00404   inline int downStatus() const
00405   { assert (branchingObject_->numberBranches()==2); return statuses_[0];};
00407   inline int status(int k) const
00408   { return statuses_[k];};
00410   inline OsiBranchingObject * branchingObject() const
00411   { return branchingObject_;}
00412   inline int whichObject() const
00413   { return whichObject_;};
00414 
00415 protected:
00416   // Data
00418   double originalObjectiveValue_;
00420   double * changes_;
00422   int * iterationCounts_;
00429   int * statuses_;
00431   OsiBranchingObject * branchingObject_;
00433   int whichObject_;
00434 };
00435 
00436 
00437 #endif

Generated on Fri May 16 00:11:08 2008 by  doxygen 1.4.7