Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

SbbCompareBase.hpp

00001 // Copyright (C) 2002, International Business Machines
00002 // Corporation and others.  All Rights Reserved.
00003 #ifndef SbbCompareBase_H
00004 #define SbbCompareBase_H
00005 
00006 
00007 //#############################################################################
00008 /*  These are alternative strategies for node traversal.  
00009     They can take data etc for fine tuning 
00010 
00011     At present the node list is stored as a heap and the "test"
00012     comparison function returns true if node y is better than node x.
00013 
00014 */
00015 #include "SbbNode.hpp"
00016 
00017 class SbbModel;
00018 class SbbCompareBase {
00019 public:
00020   SbbCompareBase * test_;
00021   // Default Constructor 
00022   SbbCompareBase () {test_=NULL;};
00023 
00024   // This allows any method to change behavior as it is called
00025   // after each solution
00026   virtual void newSolution(SbbModel * model) {};
00027 
00028   // This Also allows any method to change behavior as it is called
00029   // after each solution
00030   virtual void newSolution(SbbModel * model,
00031                            double objectiveAtContinuous,
00032                            int numberInfeasibilitiesAtContinuous) {};
00033 
00034   // This allows any method to change behavior as it is called
00035   // after every 1000 nodes
00036   virtual void every1000Nodes(SbbModel * model,int numberNodes) {};
00037 
00038   virtual ~SbbCompareBase() {};
00039 
00041   virtual bool test (SbbNode * x, SbbNode * y) {return true;};
00042 
00043   bool operator() (SbbNode * x, SbbNode * y) {
00044     return test(x,y);
00045   }
00046 };
00047 class SbbCompare {
00048 public:
00049   SbbCompareBase * test_;
00050   // Default Constructor 
00051   SbbCompare () {test_=NULL;};
00052 
00053   virtual ~SbbCompare() {};
00054 
00055   bool operator() (SbbNode * x, SbbNode * y) {
00056     return test_->test(x,y);
00057   }
00058 };
00059 //#############################################################################
00060 /*  These can be alternative strategies for choosing variables
00061     Any descendant can be passed in by setVariableChoice
00062 */
00063 
00064 class SbbChooseVariable {
00065 public:
00066   // Default Constructor 
00067   SbbChooseVariable () {};
00068 
00069   virtual ~SbbChooseVariable() {};
00075   virtual int chosen (const SbbModel * model,int numberToLookAt,
00076                       const int * which, const double * downMovement,
00077                       const double * upMovement, const double * solution,
00078                       int & way, double & value)=0;
00079 
00080 };
00081 #endif

Generated on Wed Dec 3 14:36:19 2003 for Sbb by doxygen 1.3.5