1 | // Copyright (C) 2006, International Business Machines |
---|
2 | // Corporation and others. All Rights Reserved. |
---|
3 | #ifndef CbcHeuristicRINS_H |
---|
4 | #define CbcHeuristicRINS_H |
---|
5 | |
---|
6 | #include "CbcHeuristic.hpp" |
---|
7 | /** LocalSearch class |
---|
8 | */ |
---|
9 | |
---|
10 | class CbcHeuristicRINS : public CbcHeuristic { |
---|
11 | public: |
---|
12 | |
---|
13 | // Default Constructor |
---|
14 | CbcHeuristicRINS (); |
---|
15 | |
---|
16 | /* Constructor with model - assumed before cuts |
---|
17 | Initial version does not do Lps |
---|
18 | */ |
---|
19 | CbcHeuristicRINS (CbcModel & model); |
---|
20 | |
---|
21 | // Copy constructor |
---|
22 | CbcHeuristicRINS ( const CbcHeuristicRINS &); |
---|
23 | |
---|
24 | // Destructor |
---|
25 | ~CbcHeuristicRINS (); |
---|
26 | |
---|
27 | /// Clone |
---|
28 | virtual CbcHeuristic * clone() const; |
---|
29 | |
---|
30 | |
---|
31 | /// Assignment operator |
---|
32 | CbcHeuristicRINS & operator=(const CbcHeuristicRINS& rhs); |
---|
33 | |
---|
34 | /// Create C++ lines to get to current state |
---|
35 | virtual void generateCpp( FILE * fp) ; |
---|
36 | |
---|
37 | /// Resets stuff if model changes |
---|
38 | virtual void resetModel(CbcModel * model); |
---|
39 | |
---|
40 | /// update model (This is needed if cliques update matrix etc) |
---|
41 | virtual void setModel(CbcModel * model); |
---|
42 | |
---|
43 | using CbcHeuristic::solution ; |
---|
44 | /** returns 0 if no solution, 1 if valid solution. |
---|
45 | Sets solution values if good, sets objective value (only if good) |
---|
46 | This does Relaxation Induced Neighborhood Search |
---|
47 | */ |
---|
48 | virtual int solution(double & objectiveValue, |
---|
49 | double * newSolution); |
---|
50 | /// This version fixes stuff and does IP |
---|
51 | int solutionFix(double & objectiveValue, |
---|
52 | double * newSolution, |
---|
53 | const int * keep); |
---|
54 | |
---|
55 | /// Sets how often to do it |
---|
56 | inline void setHowOften(int value) |
---|
57 | { howOften_=value;} |
---|
58 | /// Sets decay factor (for howOften) on failure |
---|
59 | inline void setDecayFactor(double value) |
---|
60 | { decayFactor_=value;} |
---|
61 | /// Used array so we can set |
---|
62 | inline char * used() const |
---|
63 | { return used_;} |
---|
64 | |
---|
65 | protected: |
---|
66 | // Data |
---|
67 | |
---|
68 | /// Number of solutions so we can do something at solution |
---|
69 | int numberSolutions_; |
---|
70 | /// How often to do (code can change) |
---|
71 | int howOften_; |
---|
72 | /// How much to increase how often |
---|
73 | double decayFactor_; |
---|
74 | /// Number of successes |
---|
75 | int numberSuccesses_; |
---|
76 | /// Number of tries |
---|
77 | int numberTries_; |
---|
78 | /// Whether a variable has been in a solution |
---|
79 | char * used_; |
---|
80 | }; |
---|
81 | |
---|
82 | /** LocalSearch class |
---|
83 | */ |
---|
84 | |
---|
85 | class CbcHeuristicRENS : public CbcHeuristic { |
---|
86 | public: |
---|
87 | |
---|
88 | // Default Constructor |
---|
89 | CbcHeuristicRENS (); |
---|
90 | |
---|
91 | /* Constructor with model - assumed before cuts |
---|
92 | Initial version does not do Lps |
---|
93 | */ |
---|
94 | CbcHeuristicRENS (CbcModel & model); |
---|
95 | |
---|
96 | // Copy constructor |
---|
97 | CbcHeuristicRENS ( const CbcHeuristicRENS &); |
---|
98 | |
---|
99 | // Destructor |
---|
100 | ~CbcHeuristicRENS (); |
---|
101 | |
---|
102 | /// Clone |
---|
103 | virtual CbcHeuristic * clone() const; |
---|
104 | |
---|
105 | |
---|
106 | /// Assignment operator |
---|
107 | CbcHeuristicRENS & operator=(const CbcHeuristicRENS& rhs); |
---|
108 | |
---|
109 | /// Resets stuff if model changes |
---|
110 | virtual void resetModel(CbcModel * model); |
---|
111 | |
---|
112 | /// update model (This is needed if cliques update matrix etc) |
---|
113 | virtual void setModel(CbcModel * model); |
---|
114 | |
---|
115 | using CbcHeuristic::solution ; |
---|
116 | /** returns 0 if no solution, 1 if valid solution. |
---|
117 | Sets solution values if good, sets objective value (only if good) |
---|
118 | This does Relaxation Extension Neighborhood Search |
---|
119 | */ |
---|
120 | virtual int solution(double & objectiveValue, |
---|
121 | double * newSolution); |
---|
122 | |
---|
123 | protected: |
---|
124 | // Data |
---|
125 | /// Number of tries |
---|
126 | int numberTries_; |
---|
127 | }; |
---|
128 | |
---|
129 | |
---|
130 | #endif |
---|