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

SbbCompareActual.hpp

00001 // Copyright (C) 2002, International Business Machines
00002 // Corporation and others.  All Rights Reserved.
00003 #ifndef SbbCompareActual_H
00004 #define SbbCompareActual_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 #include "SbbCompareBase.hpp"
00017 
00018 // This is default before first solution
00019 class SbbCompareDepth : public SbbCompareBase{
00020 public:
00021   // Default Constructor 
00022   SbbCompareDepth () {test_=this;};
00023 
00024   ~SbbCompareDepth() {};
00025   // This returns true if the depth of node y is greater than depth of node x
00026   virtual bool test (SbbNode * x, SbbNode * y) {
00027     return x->depth() < y->depth();
00028   }
00029 };
00030 class SbbCompareObjective  : public SbbCompareBase {
00031 public:
00032   // Default Constructor 
00033   SbbCompareObjective () {test_=this;};
00034 
00035   ~SbbCompareObjective() {};
00036 
00037   /* This returns true if objective value of node y is less than
00038      objective value of node x */
00039   virtual bool test (SbbNode * x, SbbNode * y) {
00040     return x->objectiveValue() > y->objectiveValue();
00041   }
00042 };
00043 /* This is an example of a more complex rule with data
00044    It is default after first solution
00045    If weight is 0.0 then it is computed to hit first solution
00046    less 2%
00047 */
00048 class SbbCompareDefault  : public SbbCompareBase {
00049 public:
00050   // Weight for each infeasibility
00051   double weight_;
00052   // Default Constructor 
00053   SbbCompareDefault () : weight_(0.0) {test_=this;};
00054   // Constructor with weight
00055   SbbCompareDefault (double weight) : weight_(weight) {test_=this;};
00056 
00057   ~SbbCompareDefault() {};
00058   /* This returns true if weighted value of node y is less than
00059      weighted value of node x */
00060   virtual bool test (SbbNode * x, SbbNode * y) {
00061     return x->objectiveValue()+ weight_*x->numberUnsatisfied() > 
00062       y->objectiveValue() + weight_*y->numberUnsatisfied();
00063   }
00064   double getWeight() const
00065   { return weight_;};
00066   void setWeight(double weight)
00067   { weight_ = weight;};
00068 };
00069 
00070 /* This is when rounding is being done
00071 */
00072 class SbbCompareEstimate  : public SbbCompareBase {
00073 public:
00074   // Default Constructor 
00075   SbbCompareEstimate () {test_=this;};
00076 
00077   ~SbbCompareEstimate() {};
00078   virtual bool test (SbbNode * x, SbbNode * y) {
00079     return x->guessedObjectiveValue() >  y->guessedObjectiveValue() ;
00080   }
00081 };
00082 
00083 #endif

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