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