1 | // Copyright (C) 2004, International Business Machines |
---|
2 | // Corporation and others. All Rights Reserved. |
---|
3 | #ifndef CbcHeuristicFeasibilityPump_H |
---|
4 | #define CbcHeuristicFeasibilityPump_H |
---|
5 | |
---|
6 | #include "CbcHeuristic.hpp" |
---|
7 | |
---|
8 | /** Rounding class |
---|
9 | */ |
---|
10 | |
---|
11 | class CbcHeuristicFPump : public CbcHeuristic { |
---|
12 | public: |
---|
13 | |
---|
14 | // Default Constructor |
---|
15 | CbcHeuristicFPump (); |
---|
16 | |
---|
17 | // Constructor with model - assumed before cuts |
---|
18 | CbcHeuristicFPump (CbcModel & model, |
---|
19 | double downValue=0.5,bool roundExpensive=false); |
---|
20 | |
---|
21 | // Copy constructor |
---|
22 | CbcHeuristicFPump ( const CbcHeuristicFPump &); |
---|
23 | |
---|
24 | // Destructor |
---|
25 | ~CbcHeuristicFPump (); |
---|
26 | |
---|
27 | /// Assignment operator |
---|
28 | CbcHeuristicFPump & operator=(const CbcHeuristicFPump& rhs); |
---|
29 | /// Clone |
---|
30 | virtual CbcHeuristic * clone() const; |
---|
31 | /// Create C++ lines to get to current state |
---|
32 | virtual void generateCpp( FILE * fp) ; |
---|
33 | |
---|
34 | /// Resets stuff if model changes |
---|
35 | virtual void resetModel(CbcModel * model); |
---|
36 | |
---|
37 | /// update model (This is needed if cliques update matrix etc) |
---|
38 | virtual void setModel(CbcModel * model); |
---|
39 | |
---|
40 | /** returns 0 if no solution, 1 if valid solution |
---|
41 | with better objective value than one passed in |
---|
42 | Sets solution values if good, sets objective value (only if good) |
---|
43 | This is called after cuts have been added - so can not add cuts. |
---|
44 | |
---|
45 | It may make sense for user to call this outside Branch and Cut to |
---|
46 | get solution. Or normally is just at root node. |
---|
47 | |
---|
48 | * new meanings for when_ - on first try then set back to 1 |
---|
49 | 11 - at end fix all integers at same bound throughout |
---|
50 | 12 - also fix all integers staying at same internal integral value throughout |
---|
51 | 13 - also fix all continuous variables staying at same bound throughout |
---|
52 | 14 - also fix all continuous variables staying at same internal value throughout |
---|
53 | 15 - as 13 but no internal integers |
---|
54 | */ |
---|
55 | virtual int solution(double & objectiveValue, |
---|
56 | double * newSolution); |
---|
57 | |
---|
58 | /// Set maximum Time (default off) - also sets starttime to current |
---|
59 | void setMaximumTime(double value); |
---|
60 | /// Get maximum Time (default 0.0 == time limit off) |
---|
61 | inline double maximumTime() const |
---|
62 | { return maximumTime_;}; |
---|
63 | /// Set fake cutoff (default COIN_DBL_MAX == off) |
---|
64 | inline void setFakeCutoff(double value) |
---|
65 | { fakeCutoff_ = value;}; |
---|
66 | /// Get fake cutoff (default 0.0 == off) |
---|
67 | inline double fakeCutoff() const |
---|
68 | { return fakeCutoff_;}; |
---|
69 | /// Set absolute increment (default 0.0 == off) |
---|
70 | inline void setAbsoluteIncrement(double value) |
---|
71 | { absoluteIncrement_ = value;}; |
---|
72 | /// Get absolute increment (default 0.0 == off) |
---|
73 | inline double absoluteIncrement() const |
---|
74 | { return absoluteIncrement_;}; |
---|
75 | /// Set relative increment (default 0.0 == off) |
---|
76 | inline void setRelativeIncrement(double value) |
---|
77 | { relativeIncrement_ = value;}; |
---|
78 | /// Get relative increment (default 0.0 == off) |
---|
79 | inline double relativeIncrement() const |
---|
80 | { return relativeIncrement_;}; |
---|
81 | /// Set default rounding (default 0.5) |
---|
82 | inline void setDefaultRounding(double value) |
---|
83 | { defaultRounding_ = value;}; |
---|
84 | /// Get default rounding (default 0.5) |
---|
85 | inline double defaultRounding() const |
---|
86 | { return defaultRounding_;}; |
---|
87 | /// Set initial weight (default 0.0 == off) |
---|
88 | inline void setInitialWeight(double value) |
---|
89 | { initialWeight_ = value;}; |
---|
90 | /// Get initial weight (default 0.0 == off) |
---|
91 | inline double initialWeight() const |
---|
92 | { return initialWeight_;}; |
---|
93 | /// Set weight factor (default 0.1) |
---|
94 | inline void setWeightFactor(double value) |
---|
95 | { weightFactor_ = value;}; |
---|
96 | /// Get weight factor (default 0.1) |
---|
97 | inline double weightFactor() const |
---|
98 | { return weightFactor_;}; |
---|
99 | /// Set maximum passes (default 100) |
---|
100 | inline void setMaximumPasses(int value) |
---|
101 | { maximumPasses_=value;}; |
---|
102 | /// Get maximum passes (default 100) |
---|
103 | inline int maximumPasses() const |
---|
104 | { return maximumPasses_;}; |
---|
105 | /// Set maximum retries (default 1) |
---|
106 | inline void setMaximumRetries(int value) |
---|
107 | { maximumRetries_=value;}; |
---|
108 | /// Get maximum retries (default 1) |
---|
109 | inline int maximumRetries() const |
---|
110 | { return maximumRetries_;}; |
---|
111 | /** Set use of multiple solutions and solves |
---|
112 | 0 - do not reuse solves, do not accumulate integer solutions for local search |
---|
113 | 1 - do not reuse solves, accumulate integer solutions for local search |
---|
114 | 2 - reuse solves, do not accumulate integer solutions for local search |
---|
115 | 3 - reuse solves, accumulate integer solutions for local search |
---|
116 | */ |
---|
117 | inline void setAccumulate(int value) |
---|
118 | { accumulate_=value;}; |
---|
119 | /// Get accumulation option |
---|
120 | inline int accumulate() const |
---|
121 | { return accumulate_;}; |
---|
122 | |
---|
123 | protected: |
---|
124 | // Data |
---|
125 | /// Start time |
---|
126 | double startTime_; |
---|
127 | /// Maximum Cpu seconds |
---|
128 | double maximumTime_; |
---|
129 | /** Fake cutoff value. |
---|
130 | If set then better of real cutoff and this used to add a constraint |
---|
131 | */ |
---|
132 | double fakeCutoff_; |
---|
133 | /// If positive carry on after solution expecting gain of at least this |
---|
134 | double absoluteIncrement_; |
---|
135 | /// If positive carry on after solution expecting gain of at least this times objective |
---|
136 | double relativeIncrement_; |
---|
137 | /// Default is round up if > this |
---|
138 | double defaultRounding_; |
---|
139 | /// Initial weight for true objective |
---|
140 | double initialWeight_; |
---|
141 | /// factor for decreasing weight |
---|
142 | double weightFactor_; |
---|
143 | /// Maximum number of passes |
---|
144 | int maximumPasses_; |
---|
145 | /** Maximum number of retries if we find a solution. |
---|
146 | If negative we clean out used array |
---|
147 | */ |
---|
148 | int maximumRetries_; |
---|
149 | /** Set use of multiple solutions and solves |
---|
150 | 0 - do not reuse solves, do not accumulate integer solutions for local search |
---|
151 | 1 - do not reuse solves, accumulate integer solutions for local search |
---|
152 | 2 - reuse solves, do not accumulate integer solutions for local search |
---|
153 | 3 - reuse solves, accumulate integer solutions for local search |
---|
154 | If we add 4 then use second form of problem (with extra rows and variables) |
---|
155 | */ |
---|
156 | int accumulate_; |
---|
157 | /// If true round to expensive |
---|
158 | bool roundExpensive_; |
---|
159 | |
---|
160 | private: |
---|
161 | /** Rounds solution - down if < downValue |
---|
162 | If roundExpensive then always to more expnsive. |
---|
163 | returns 0 if current is solution |
---|
164 | */ |
---|
165 | int rounds(double * solution, const double * objective, |
---|
166 | int numberIntegers, const int * integerVariable, |
---|
167 | bool roundExpensive=false, |
---|
168 | double downValue=0.5, int *flip=0); |
---|
169 | /* note for eagle eyed readers. |
---|
170 | when_ can now be exotic - |
---|
171 | <=10 normal |
---|
172 | */ |
---|
173 | }; |
---|
174 | |
---|
175 | |
---|
176 | #endif |
---|