00001 // $Id: CbcCompareUser.hpp 1574 2011-01-05 01:13:55Z lou $ 00002 // Copyright (C) 2002, International Business Machines 00003 // Corporation and others. All Rights Reserved. 00004 // This code is licensed under the terms of the Eclipse Public License (EPL). 00005 00006 #ifndef CbcCompareUser_H 00007 #define CbcCompareUser_H 00008 00009 #include "CbcNode.hpp" 00010 #include "CbcCompareBase.hpp" 00011 class CbcModel; 00012 /* This is an example of a more complex rule with data 00013 It is default after first solution 00014 If weight is 0.0 then it is computed to hit first solution 00015 less 2% 00016 */ 00017 class CbcCompareUser : public CbcCompareBase { 00018 public: 00019 // Default Constructor 00020 CbcCompareUser () ; 00021 // Constructor with weight 00022 CbcCompareUser (double weight); 00023 00024 // Copy constructor 00025 CbcCompareUser ( const CbcCompareUser &rhs); 00026 00027 // Assignment operator 00028 CbcCompareUser & operator=( const CbcCompareUser& rhs); 00029 00031 virtual CbcCompareBase * clone() const; 00032 00033 ~CbcCompareUser() ; 00034 /* This returns true if weighted value of node y is less than 00035 weighted value of node x */ 00036 virtual bool test (CbcNode * x, CbcNode * y) ; 00038 virtual bool alternateTest (CbcNode * x, CbcNode * y); 00039 // This allows method to change behavior as it is called 00040 // after each solution 00041 virtual bool newSolution(CbcModel * model, 00042 double objectiveAtContinuous, 00043 int numberInfeasibilitiesAtContinuous) ; 00045 virtual bool fullScan() const; 00046 // This allows method to change behavior 00047 // Return true if want tree re-sorted 00048 virtual bool every1000Nodes(CbcModel * model,int numberNodes); 00049 00050 /* if weight == -1.0 then depth first (before solution) 00051 if -2.0 then do breadth first just for first 1000 nodes 00052 */ 00053 inline double getWeight() const 00054 { return weight_;} 00055 inline void setWeight(double weight) 00056 { weight_ = weight;} 00057 protected: 00058 // Weight for each infeasibility 00059 double weight_; 00060 // Weight for each infeasibility - computed from solution 00061 double saveWeight_; 00062 // Number of solutions 00063 int numberSolutions_; 00064 // count 00065 mutable int count_; 00066 // Tree size (at last check) 00067 int treeSize_; 00068 }; 00069 #endif