1 | // Copyright (C) 2002, International Business Machines |
---|
2 | // Corporation and others. All Rights Reserved. |
---|
3 | #ifndef CbcHeuristicLocal_H |
---|
4 | #define CbcHeuristicLocal_H |
---|
5 | |
---|
6 | #include "CbcHeuristic.hpp" |
---|
7 | /** LocalSearch class |
---|
8 | */ |
---|
9 | |
---|
10 | class CbcHeuristicLocal : public CbcHeuristic { |
---|
11 | public: |
---|
12 | |
---|
13 | // Default Constructor |
---|
14 | CbcHeuristicLocal (); |
---|
15 | |
---|
16 | /* Constructor with model - assumed before cuts |
---|
17 | Initial version does not do Lps |
---|
18 | */ |
---|
19 | CbcHeuristicLocal (CbcModel & model); |
---|
20 | |
---|
21 | // Copy constructor |
---|
22 | CbcHeuristicLocal ( const CbcHeuristicLocal &); |
---|
23 | |
---|
24 | // Destructor |
---|
25 | ~CbcHeuristicLocal (); |
---|
26 | |
---|
27 | /// Clone |
---|
28 | virtual CbcHeuristic * clone() const; |
---|
29 | |
---|
30 | /// Create C++ lines to get to current state |
---|
31 | virtual void generateCpp( FILE * fp) ; |
---|
32 | |
---|
33 | /// Resets stuff if model changes |
---|
34 | virtual void resetModel(CbcModel * model); |
---|
35 | |
---|
36 | /// update model (This is needed if cliques update matrix etc) |
---|
37 | virtual void setModel(CbcModel * model); |
---|
38 | |
---|
39 | /** returns 0 if no solution, 1 if valid solution. |
---|
40 | Sets solution values if good, sets objective value (only if good) |
---|
41 | This is called after cuts have been added - so can not add cuts |
---|
42 | First tries setting a variable to better value. If feasible then |
---|
43 | tries setting others. If not feasible then tries swaps |
---|
44 | |
---|
45 | ******** |
---|
46 | |
---|
47 | This first version does not do LP's and does swaps of two integer |
---|
48 | variables. Later versions could do Lps. |
---|
49 | */ |
---|
50 | virtual int solution(double & objectiveValue, |
---|
51 | double * newSolution); |
---|
52 | /// This version fixes stuff and does IP |
---|
53 | int solutionFix(double & objectiveValue, |
---|
54 | double * newSolution, |
---|
55 | const int * keep); |
---|
56 | |
---|
57 | /// Sets type of search |
---|
58 | inline void setSearchType(int value) |
---|
59 | { swap_=value;}; |
---|
60 | /// Used array so we can set |
---|
61 | inline char * used() const |
---|
62 | { return used_;}; |
---|
63 | |
---|
64 | protected: |
---|
65 | // Data |
---|
66 | |
---|
67 | // Original matrix by column |
---|
68 | CoinPackedMatrix matrix_; |
---|
69 | |
---|
70 | // Number of solutions so we only do after new solution |
---|
71 | int numberSolutions_; |
---|
72 | // Type of search 0=normal, 1=BAB |
---|
73 | int swap_; |
---|
74 | /// Whether a variable has been in a solution |
---|
75 | char * used_; |
---|
76 | |
---|
77 | private: |
---|
78 | /// Illegal Assignment operator |
---|
79 | CbcHeuristicLocal & operator=(const CbcHeuristicLocal& rhs); |
---|
80 | }; |
---|
81 | |
---|
82 | |
---|
83 | #endif |
---|