source: branches/sandbox/Cbc/src/CbcHeuristicRINS.hpp @ 1315

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

final changes before cleaning

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