CbcCompareUser.hpp
Go to the documentation of this file.
1 // Copyright (C) 2002, International Business Machines
2 // Corporation and others. All Rights Reserved.
3 #ifndef CbcCompareUser_H
4 #define CbcCompareUser_H
5 
6 #include "CbcNode.hpp"
7 #include "CbcCompareBase.hpp"
8 class CbcModel;
9 /* This is an example of a more complex rule with data
10  It is default after first solution
11  If weight is 0.0 then it is computed to hit first solution
12  less 2%
13 */
15 public:
16  // Default Constructor
17  CbcCompareUser () ;
18  // Constructor with weight
19  CbcCompareUser (double weight);
20 
21  // Copy constructor
22  CbcCompareUser ( const CbcCompareUser &rhs);
23 
24  // Assignment operator
26 
28  virtual CbcCompareBase * clone() const;
29 
30  ~CbcCompareUser() ;
31  /* This returns true if weighted value of node y is less than
32  weighted value of node x */
33  virtual bool test (CbcNode * x, CbcNode * y) ;
35  virtual bool alternateTest (CbcNode * x, CbcNode * y);
36  // This allows method to change behavior as it is called
37  // after each solution
38  virtual void newSolution(CbcModel * model,
39  double objectiveAtContinuous,
40  int numberInfeasibilitiesAtContinuous) ;
42  virtual bool fullScan() const;
43  // This allows method to change behavior
44  // Return true if want tree re-sorted
45  virtual bool every1000Nodes(CbcModel * model,int numberNodes);
46 
47  /* if weight == -1.0 then depth first (before solution)
48  if -2.0 then do breadth first just for first 1000 nodes
49  */
50  inline double getWeight() const
51  { return weight_;}
52  inline void setWeight(double weight)
53  { weight_ = weight;}
54 protected:
55  // Weight for each infeasibility
56  double weight_;
57  // Weight for each infeasibility - computed from solution
58  double saveWeight_;
59  // Number of solutions
61  // count
62  mutable int count_;
63  // Tree size (at last check)
64  int treeSize_;
65 };
66 #endif