source: trunk/Cbc/src/CbcHeuristicLocal.hpp @ 1173

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

add $id

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.6 KB
Line 
1/* $Id: CbcHeuristicLocal.hpp 1173 2009-06-04 09:44:10Z forrest $ */
2// Copyright (C) 2002, International Business Machines
3// Corporation and others.  All Rights Reserved.
4#ifndef CbcHeuristicLocal_H
5#define CbcHeuristicLocal_H
6
7#include "CbcHeuristic.hpp"
8/** LocalSearch class
9 */
10
11class CbcHeuristicLocal : public CbcHeuristic {
12public:
13
14  // Default Constructor
15  CbcHeuristicLocal ();
16
17  /* Constructor with model - assumed before cuts
18     Initial version does not do Lps
19  */
20  CbcHeuristicLocal (CbcModel & model);
21 
22  // Copy constructor
23  CbcHeuristicLocal ( const CbcHeuristicLocal &);
24   
25  // Destructor
26  ~CbcHeuristicLocal ();
27 
28  /// Clone
29  virtual CbcHeuristic * clone() const;
30
31  /// Assignment operator
32  CbcHeuristicLocal & operator=(const CbcHeuristicLocal& 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 is called after cuts have been added - so can not add cuts
47      First tries setting a variable to better value.  If feasible then
48      tries setting others.  If not feasible then tries swaps
49
50      ********
51
52      This first version does not do LP's and does swaps of two integer
53      variables.  Later versions could do Lps.
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 type of search
63  inline void setSearchType(int value)
64  { swap_=value;}
65  /// Used array so we can set
66  inline char * used() const
67  { return used_;}
68
69protected:
70  // Data
71
72  // Original matrix by column
73  CoinPackedMatrix matrix_;
74
75  // Number of solutions so we only do after new solution
76  int numberSolutions_;
77  // Type of search 0=normal, 1=BAB
78  int swap_;
79  /// Whether a variable has been in a solution
80  char * used_;
81};
82
83
84/** Naive class
85    a) Fix all ints as close to zero as possible
86    b) Fix all ints with nonzero costs and < large to zero
87    c) Put bounds round continuous and UIs and maximize
88 */
89
90class CbcHeuristicNaive : public CbcHeuristic {
91public:
92
93  // Default Constructor
94  CbcHeuristicNaive ();
95
96  /* Constructor with model - assumed before cuts
97     Initial version does not do Lps
98  */
99  CbcHeuristicNaive (CbcModel & model);
100 
101  // Copy constructor
102  CbcHeuristicNaive ( const CbcHeuristicNaive &);
103   
104  // Destructor
105  ~CbcHeuristicNaive ();
106 
107  /// Clone
108  virtual CbcHeuristic * clone() const;
109
110  /// Assignment operator
111  CbcHeuristicNaive & operator=(const CbcHeuristicNaive& rhs);
112
113  /// Create C++ lines to get to current state
114  virtual void generateCpp( FILE * fp) ;
115
116  /// Resets stuff if model changes
117  virtual void resetModel(CbcModel * model);
118
119  /// update model (This is needed if cliques update matrix etc)
120  virtual void setModel(CbcModel * model);
121 
122  using CbcHeuristic::solution ;
123  /** returns 0 if no solution, 1 if valid solution.
124      Sets solution values if good, sets objective value (only if good)
125  */
126  virtual int solution(double & objectiveValue,
127                       double * newSolution);
128
129  /// Sets large cost value
130  inline void setLargeValue(double value)
131  { large_=value;}
132  /// Gets large cost value
133  inline double largeValue() const
134  { return large_;}
135
136protected:
137  /// Data
138  /// Large value
139  double large_;
140};
141
142
143#endif
Note: See TracBrowser for help on using the repository browser.