Cbc  trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
CbcCompareDefault.hpp
Go to the documentation of this file.
00001 // $Id$
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 //Edwin 11/25/09 carved out of CbcCompareActual
00007 
00008 #ifndef CbcCompareDefault_H
00009 #define CbcCompareDefault_H
00010 
00011 
00012 //#############################################################################
00013 /*  These are alternative strategies for node traversal.
00014     They can take data etc for fine tuning
00015 
00016     At present the node list is stored as a heap and the "test"
00017     comparison function returns true if node y is better than node x.
00018 
00019 */
00020 #include "CbcNode.hpp"
00021 #include "CbcCompareBase.hpp"
00022 #include "CbcCompare.hpp"
00023 
00024 class CbcModel;
00025 
00026 /* This is an example of a more complex rule with data
00027    It is default after first solution
00028    If weight is 0.0 then it is computed to hit first solution
00029    less 5%
00030 */
00031 class CbcCompareDefault  : public CbcCompareBase {
00032 public:
00034     CbcCompareDefault () ;
00036     CbcCompareDefault (double weight);
00037 
00039     CbcCompareDefault ( const CbcCompareDefault &rhs);
00040 
00042     CbcCompareDefault & operator=( const CbcCompareDefault& rhs);
00043 
00045     virtual CbcCompareBase * clone() const;
00047     virtual void generateCpp( FILE * fp);
00048 
00049     ~CbcCompareDefault() ;
00050     /* This returns true if weighted value of node y is less than
00051        weighted value of node x */
00052     virtual bool test (CbcNode * x, CbcNode * y) ;
00053 
00054     using CbcCompareBase::newSolution ;
00057     virtual bool newSolution(CbcModel * model,
00058                              double objectiveAtContinuous,
00059                              int numberInfeasibilitiesAtContinuous) ;
00062     virtual bool every1000Nodes(CbcModel * model, int numberNodes);
00063 
00064     /* if weight == -1.0 then fewest infeasibilities (before solution)
00065        if -2.0 then do breadth first just for first 1000 nodes
00066        if -3.0 then depth first before solution
00067     */
00068     inline double getWeight() const {
00069         return weight_;
00070     }
00071     inline void setWeight(double weight) {
00072         weight_ = weight;
00073     }
00075     inline double getCutoff() const {
00076         return cutoff_;
00077     }
00078     inline void setCutoff(double cutoff) {
00079         cutoff_ = cutoff;
00080     }
00082     inline double getBestPossible() const {
00083         return bestPossible_;
00084     }
00085     inline void setBestPossible(double bestPossible) {
00086         bestPossible_ = bestPossible;
00087     }
00089     inline void setBreadthDepth(int value) {
00090         breadthDepth_ = value;
00091     }
00093     void startDive(CbcModel * model);
00095     void cleanDive();
00096 protected:
00098     double weight_;
00100     double saveWeight_;
00102     double cutoff_;
00104     double bestPossible_;
00106     int numberSolutions_;
00108     int treeSize_;
00110     int breadthDepth_;
00112     int startNodeNumber_;
00114     int afterNodeNumber_;
00116     bool setupForDiving_ ;
00117 };
00118 
00119 #endif //CbcCompareDefault_H
00120 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines