source: stable/2.4/Cbc/src/CbcHeuristicRINS.hpp @ 1271

Last change on this file since 1271 was 1271, checked in by forrest, 10 years ago

Creating new stable branch 2.4 from trunk (rev 1270)

File size: 7.1 KB
Line 
1/* $Id: CbcHeuristicRINS.hpp 1261 2009-10-30 12:45:20Z forrest $ */
2// Copyright (C) 2006, International Business Machines
3// Corporation and others.  All Rights Reserved.
4#ifndef CbcHeuristicRINS_H
5#define CbcHeuristicRINS_H
6
7#include "CbcHeuristic.hpp"
8/** LocalSearch class
9 */
10
11class CbcHeuristicRINS : public CbcHeuristic {
12public:
13
14  // Default Constructor
15  CbcHeuristicRINS ();
16
17  /* Constructor with model - assumed before cuts
18     Initial version does not do Lps
19  */
20  CbcHeuristicRINS (CbcModel & model);
21 
22  // Copy constructor
23  CbcHeuristicRINS ( const CbcHeuristicRINS &);
24   
25  // Destructor
26  ~CbcHeuristicRINS ();
27 
28  /// Clone
29  virtual CbcHeuristic * clone() const;
30
31
32  /// Assignment operator
33  CbcHeuristicRINS & operator=(const CbcHeuristicRINS& rhs);
34
35  /// Create C++ lines to get to current state
36  virtual void generateCpp( FILE * fp) ;
37
38  /// Resets stuff if model changes
39  virtual void resetModel(CbcModel * model);
40
41  /// update model (This is needed if cliques update matrix etc)
42  virtual void setModel(CbcModel * model);
43 
44  using CbcHeuristic::solution ;
45  /** returns 0 if no solution, 1 if valid solution.
46      Sets solution values if good, sets objective value (only if good)
47      This does Relaxation Induced Neighborhood Search
48  */
49  virtual int solution(double & objectiveValue,
50                       double * newSolution);
51  /// This version fixes stuff and does IP
52  int solutionFix(double & objectiveValue,
53                  double * newSolution,
54                  const int * keep);
55
56  /// Sets how often to do it
57  inline void setHowOften(int value)
58  { howOften_=value;}
59  /// Used array so we can set
60  inline char * used() const
61  { return used_;}
62
63protected:
64  // Data
65
66  /// Number of solutions so we can do something at solution
67  int numberSolutions_;
68  /// How often to do (code can change)
69  int howOften_;
70  /// Number of successes
71  int numberSuccesses_;
72  /// Number of tries
73  int numberTries_;
74  /** State of fixing continuous variables -
75      0 - not tried
76      +n - this divisor makes small enough
77      -n - this divisor still not small enough
78  */
79  int stateOfFixing_;
80  /// Node when last done
81  int lastNode_;
82  /// Whether a variable has been in a solution
83  char * used_;
84};
85
86/** LocalSearch class
87 */
88
89class CbcHeuristicRENS : public CbcHeuristic {
90public:
91
92  // Default Constructor
93  CbcHeuristicRENS ();
94
95  /* Constructor with model - assumed before cuts
96     Initial version does not do Lps
97  */
98  CbcHeuristicRENS (CbcModel & model);
99 
100  // Copy constructor
101  CbcHeuristicRENS ( const CbcHeuristicRENS &);
102   
103  // Destructor
104  ~CbcHeuristicRENS ();
105 
106  /// Clone
107  virtual CbcHeuristic * clone() const;
108
109
110  /// Assignment operator
111  CbcHeuristicRENS & operator=(const CbcHeuristicRENS& rhs);
112
113  /// Resets stuff if model changes
114  virtual void resetModel(CbcModel * model);
115
116  /// update model (This is needed if cliques update matrix etc)
117  virtual void setModel(CbcModel * model);
118 
119  using CbcHeuristic::solution ;
120  /** returns 0 if no solution, 1 if valid solution.
121      Sets solution values if good, sets objective value (only if good)
122      This does Relaxation Extension Neighborhood Search
123      Does not run if when_<2 and a solution exists
124  */
125  virtual int solution(double & objectiveValue,
126                       double * newSolution);
127
128protected:
129  // Data
130  /// Number of tries
131  int numberTries_;
132};
133
134class CbcHeuristicDINS : public CbcHeuristic {
135public:
136
137  // Default Constructor
138  CbcHeuristicDINS ();
139
140  /* Constructor with model - assumed before cuts
141     Initial version does not do Lps
142  */
143  CbcHeuristicDINS (CbcModel & model);
144 
145  // Copy constructor
146  CbcHeuristicDINS ( const CbcHeuristicDINS &);
147   
148  // Destructor
149  ~CbcHeuristicDINS ();
150 
151  /// Clone
152  virtual CbcHeuristic * clone() const;
153
154
155  /// Assignment operator
156  CbcHeuristicDINS & operator=(const CbcHeuristicDINS& rhs);
157
158  /// Create C++ lines to get to current state
159  virtual void generateCpp( FILE * fp) ;
160
161  /// Resets stuff if model changes
162  virtual void resetModel(CbcModel * model);
163
164  /// update model (This is needed if cliques update matrix etc)
165  virtual void setModel(CbcModel * model);
166 
167  using CbcHeuristic::solution ;
168  /** returns 0 if no solution, 1 if valid solution.
169      Sets solution values if good, sets objective value (only if good)
170      This does Relaxation Induced Neighborhood Search
171  */
172  virtual int solution(double & objectiveValue,
173                       double * newSolution);
174  /// This version fixes stuff and does IP
175  int solutionFix(double & objectiveValue,
176                  double * newSolution,
177                  const int * keep);
178
179  /// Sets how often to do it
180  inline void setHowOften(int value)
181  { howOften_=value;}
182  /// Sets maximum number of solutions kept
183  inline void setMaximumKeep(int value)
184  { maximumKeepSolutions_=value;}
185  /// Sets tightness of extra constraint
186  inline void setConstraint(int value)
187  { localSpace_=value;}
188
189protected:
190  // Data
191
192  /// Number of solutions so we can do something at solution
193  int numberSolutions_;
194  /// How often to do (code can change)
195  int howOften_;
196  /// Number of successes
197  int numberSuccesses_;
198  /// Number of tries
199  int numberTries_;
200  /// Maximum number of solutions to keep
201  int maximumKeepSolutions_;
202  /// Number of solutions kept
203  int numberKeptSolutions_;
204  /// Number of integer variables
205  int numberIntegers_;
206  /// Local parameter
207  int localSpace_;
208  /// Values of integer variables
209  int ** values_;
210};
211
212/** LocalSearch class
213 */
214
215class CbcHeuristicVND : public CbcHeuristic {
216public:
217
218  // Default Constructor
219  CbcHeuristicVND ();
220
221  /* Constructor with model - assumed before cuts
222     Initial version does not do Lps
223  */
224  CbcHeuristicVND (CbcModel & model);
225 
226  // Copy constructor
227  CbcHeuristicVND ( const CbcHeuristicVND &);
228   
229  // Destructor
230  ~CbcHeuristicVND ();
231 
232  /// Clone
233  virtual CbcHeuristic * clone() const;
234
235
236  /// Assignment operator
237  CbcHeuristicVND & operator=(const CbcHeuristicVND& rhs);
238
239  /// Create C++ lines to get to current state
240  virtual void generateCpp( FILE * fp) ;
241
242  /// Resets stuff if model changes
243  virtual void resetModel(CbcModel * model);
244
245  /// update model (This is needed if cliques update matrix etc)
246  virtual void setModel(CbcModel * model);
247 
248  using CbcHeuristic::solution ;
249  /** returns 0 if no solution, 1 if valid solution.
250      Sets solution values if good, sets objective value (only if good)
251      This does Relaxation Induced Neighborhood Search
252  */
253  virtual int solution(double & objectiveValue,
254                       double * newSolution);
255  /// This version fixes stuff and does IP
256  int solutionFix(double & objectiveValue,
257                  double * newSolution,
258                  const int * keep);
259
260  /// Sets how often to do it
261  inline void setHowOften(int value)
262  { howOften_=value;}
263  /// base solution array so we can set
264  inline double * baseSolution() const
265  { return baseSolution_;}
266
267protected:
268  // Data
269
270  /// Number of solutions so we can do something at solution
271  int numberSolutions_;
272  /// How often to do (code can change)
273  int howOften_;
274  /// Number of successes
275  int numberSuccesses_;
276  /// Number of tries
277  int numberTries_;
278  /// Node when last done
279  int lastNode_;
280  /// Step size for decomposition
281  int stepSize_;
282  int k_;
283  int kmax_;
284  int nDifferent_;
285  /// Base solution
286  double * baseSolution_;
287};
288
289#endif
Note: See TracBrowser for help on using the repository browser.