source: trunk/Cbc/src/CbcCompareDefault.hpp @ 2464

Last change on this file since 2464 was 2464, checked in by unxusr, 10 months ago

.clang-format with proposal for formatting code

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
Line 
1// $Id: CbcCompareDefault.hpp 2464 2019-01-03 19:03:23Z unxusr $
2// Copyright (C) 2002, International Business Machines
3// Corporation and others.  All Rights Reserved.
4// This code is licensed under the terms of the Eclipse Public License (EPL).
5
6//Edwin 11/25/09 carved out of CbcCompareActual
7
8#ifndef CbcCompareDefault_H
9#define CbcCompareDefault_H
10
11//#############################################################################
12/*  These are alternative strategies for node traversal.
13    They can take data etc for fine tuning
14
15    At present the node list is stored as a heap and the "test"
16    comparison function returns true if node y is better than node x.
17
18*/
19#include "CbcNode.hpp"
20#include "CbcCompareBase.hpp"
21#include "CbcCompare.hpp"
22
23class CbcModel;
24
25/* This is an example of a more complex rule with data
26   It is default after first solution
27   If weight is 0.0 then it is computed to hit first solution
28   less 5%
29*/
30class CbcCompareDefault : public CbcCompareBase {
31public:
32  /// Default Constructor
33  CbcCompareDefault();
34  /// Constructor with weight
35  CbcCompareDefault(double weight);
36
37  /// Copy constructor
38  CbcCompareDefault(const CbcCompareDefault &rhs);
39
40  /// Assignment operator
41  CbcCompareDefault &operator=(const CbcCompareDefault &rhs);
42
43  /// Clone
44  virtual CbcCompareBase *clone() const;
45  /// Create C++ lines to get to current state
46  virtual void generateCpp(FILE *fp);
47
48  ~CbcCompareDefault();
49  /* This returns true if weighted value of node y is less than
50       weighted value of node x */
51  virtual bool test(CbcNode *x, CbcNode *y);
52
53  using CbcCompareBase::newSolution;
54  /// This allows method to change behavior as it is called
55  /// after each solution
56  virtual bool newSolution(CbcModel *model,
57    double objectiveAtContinuous,
58    int numberInfeasibilitiesAtContinuous);
59  /// This allows method to change behavior
60  /// Return true if want tree re-sorted
61  virtual bool every1000Nodes(CbcModel *model, int numberNodes);
62
63  /* if weight == -1.0 then fewest infeasibilities (before solution)
64       if -2.0 then do breadth first just for first 1000 nodes
65       if -3.0 then depth first before solution
66    */
67  inline double getWeight() const
68  {
69    return weight_;
70  }
71  inline void setWeight(double weight)
72  {
73    weight_ = weight;
74  }
75  /// Cutoff
76  inline double getCutoff() const
77  {
78    return cutoff_;
79  }
80  inline void setCutoff(double cutoff)
81  {
82    cutoff_ = cutoff;
83  }
84  /// Best possible solution
85  inline double getBestPossible() const
86  {
87    return bestPossible_;
88  }
89  inline void setBestPossible(double bestPossible)
90  {
91    bestPossible_ = bestPossible;
92  }
93  /// Depth above which want to explore first
94  inline void setBreadthDepth(int value)
95  {
96    breadthDepth_ = value;
97  }
98  /// Start dive
99  void startDive(CbcModel *model);
100  /// Clean up diving (i.e. switch off or prepare)
101  void cleanDive();
102
103protected:
104  /// Weight for each infeasibility
105  double weight_;
106  /// Weight for each infeasibility - computed from solution
107  double saveWeight_;
108  /// Cutoff
109  double cutoff_;
110  /// Best possible solution
111  double bestPossible_;
112  /// Number of solutions
113  int numberSolutions_;
114  /// Tree size (at last check)
115  int treeSize_;
116  /// Depth above which want to explore first
117  int breadthDepth_;
118  /// Chosen node from estimated (-1 is off)
119  int startNodeNumber_;
120  /// Node number when dive started
121  int afterNodeNumber_;
122  /// Indicates doing setup for diving
123  bool setupForDiving_;
124};
125
126#endif //CbcCompareDefault_H
Note: See TracBrowser for help on using the repository browser.