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 | // for backward compatibility include 3 other headers |
---|
9 | #include "CbcHeuristicRENS.hpp" |
---|
10 | #include "CbcHeuristicDINS.hpp" |
---|
11 | #include "CbcHeuristicVND.hpp" |
---|
12 | /** LocalSearch class |
---|
13 | */ |
---|
14 | |
---|
15 | class CbcHeuristicRINS : public CbcHeuristic { |
---|
16 | public: |
---|
17 | |
---|
18 | // Default Constructor |
---|
19 | CbcHeuristicRINS (); |
---|
20 | |
---|
21 | /* Constructor with model - assumed before cuts |
---|
22 | Initial version does not do Lps |
---|
23 | */ |
---|
24 | CbcHeuristicRINS (CbcModel & model); |
---|
25 | |
---|
26 | // Copy constructor |
---|
27 | CbcHeuristicRINS ( const CbcHeuristicRINS &); |
---|
28 | |
---|
29 | // Destructor |
---|
30 | ~CbcHeuristicRINS (); |
---|
31 | |
---|
32 | /// Clone |
---|
33 | virtual CbcHeuristic * clone() const; |
---|
34 | |
---|
35 | |
---|
36 | /// Assignment operator |
---|
37 | CbcHeuristicRINS & operator=(const CbcHeuristicRINS& rhs); |
---|
38 | |
---|
39 | /// Create C++ lines to get to current state |
---|
40 | virtual void generateCpp( FILE * fp) ; |
---|
41 | |
---|
42 | /// Resets stuff if model changes |
---|
43 | virtual void resetModel(CbcModel * model); |
---|
44 | |
---|
45 | /// update model (This is needed if cliques update matrix etc) |
---|
46 | virtual void setModel(CbcModel * model); |
---|
47 | |
---|
48 | using CbcHeuristic::solution ; |
---|
49 | /** returns 0 if no solution, 1 if valid solution. |
---|
50 | Sets solution values if good, sets objective value (only if good) |
---|
51 | This does Relaxation Induced Neighborhood Search |
---|
52 | */ |
---|
53 | virtual int solution(double & objectiveValue, |
---|
54 | double * newSolution); |
---|
55 | /// This version fixes stuff and does IP |
---|
56 | int solutionFix(double & objectiveValue, |
---|
57 | double * newSolution, |
---|
58 | const int * keep); |
---|
59 | |
---|
60 | /// Sets how often to do it |
---|
61 | inline void setHowOften(int value) { |
---|
62 | howOften_ = value; |
---|
63 | } |
---|
64 | /// Used array so we can set |
---|
65 | inline char * used() const { |
---|
66 | return used_; |
---|
67 | } |
---|
68 | /// Resets lastNode |
---|
69 | inline void setLastNode(int value) { |
---|
70 | lastNode_ = value; |
---|
71 | } |
---|
72 | |
---|
73 | protected: |
---|
74 | // Data |
---|
75 | |
---|
76 | /// Number of solutions so we can do something at solution |
---|
77 | int numberSolutions_; |
---|
78 | /// How often to do (code can change) |
---|
79 | int howOften_; |
---|
80 | /// Number of successes |
---|
81 | int numberSuccesses_; |
---|
82 | /// Number of tries |
---|
83 | int numberTries_; |
---|
84 | /** State of fixing continuous variables - |
---|
85 | 0 - not tried |
---|
86 | +n - this divisor makes small enough |
---|
87 | -n - this divisor still not small enough |
---|
88 | */ |
---|
89 | int stateOfFixing_; |
---|
90 | /// Node when last done |
---|
91 | int lastNode_; |
---|
92 | /// Whether a variable has been in a solution |
---|
93 | char * used_; |
---|
94 | }; |
---|
95 | #endif |
---|
96 | |
---|