source: trunk/Cbc/src/CbcHeuristicFPump.hpp @ 1105

Last change on this file since 1105 was 1105, checked in by jpfasano, 12 years ago

added

#include "OsiClpSolverInterface?.hpp"

to avoid compile time error stating the OsiClpDisasterHandler? is an undefined base class.
This was happening on the Windows V8 build.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.7 KB
Line 
1// Copyright (C) 2004, International Business Machines
2// Corporation and others.  All Rights Reserved.
3#ifndef CbcHeuristicFeasibilityPump_H
4#define CbcHeuristicFeasibilityPump_H
5
6#include "CbcHeuristic.hpp"
7#include "OsiClpSolverInterface.hpp"
8
9/** Rounding class
10 */
11
12class CbcHeuristicFPump : public CbcHeuristic {
13public:
14
15  // Default Constructor
16  CbcHeuristicFPump ();
17
18  // Constructor with model - assumed before cuts
19  CbcHeuristicFPump (CbcModel & model,
20                     double downValue=0.5,bool roundExpensive=false);
21 
22  // Copy constructor
23  CbcHeuristicFPump ( const CbcHeuristicFPump &);
24   
25  // Destructor
26  ~CbcHeuristicFPump ();
27 
28  /// Assignment operator
29  CbcHeuristicFPump & operator=(const CbcHeuristicFPump& rhs);
30  /// Clone
31  virtual CbcHeuristic * clone() const;
32  /// Create C++ lines to get to current state
33  virtual void generateCpp( FILE * fp) ;
34
35  /// Resets stuff if model changes
36  virtual void resetModel(CbcModel * model);
37
38  /// update model (This is needed if cliques update matrix etc)
39  virtual void setModel(CbcModel * model);
40 
41  using CbcHeuristic::solution ;
42  /** returns 0 if no solution, 1 if valid solution
43      with better objective value than one passed in
44      Sets solution values if good, sets objective value (only if good)
45      This is called after cuts have been added - so can not add cuts.
46
47      It may make sense for user to call this outside Branch and Cut to
48      get solution.  Or normally is just at root node.
49
50      * new meanings for when_ - on first try then set back to 1
51        11 - at end fix all integers at same bound throughout
52        12 - also fix all integers staying at same internal integral value throughout
53        13 - also fix all continuous variables staying at same bound throughout
54        14 - also fix all continuous variables staying at same internal value throughout
55        15 - as 13 but no internal integers
56  */
57  virtual int solution(double & objectiveValue,
58                       double * newSolution);
59
60  /// Set maximum Time (default off) - also sets starttime to current
61  void setMaximumTime(double value);
62  /// Get maximum Time (default 0.0 == time limit off)
63  inline double maximumTime() const
64  { return maximumTime_;}
65  /// Set fake cutoff (default COIN_DBL_MAX == off)
66  inline void setFakeCutoff(double value)
67  { fakeCutoff_ = value;}
68  /// Get fake cutoff (default 0.0 == off)
69  inline double fakeCutoff() const
70  { return fakeCutoff_;}
71  /// Set absolute increment (default 0.0 == off)
72  inline void setAbsoluteIncrement(double value)
73  { absoluteIncrement_ = value;}
74  /// Get absolute increment (default 0.0 == off)
75  inline double absoluteIncrement() const
76  { return absoluteIncrement_;}
77  /// Set relative increment (default 0.0 == off)
78  inline void setRelativeIncrement(double value)
79  { relativeIncrement_ = value;}
80  /// Get relative increment (default 0.0 == off)
81  inline double relativeIncrement() const
82  { return relativeIncrement_;}
83  /// Set default rounding (default 0.5)
84  inline void setDefaultRounding(double value)
85  { defaultRounding_ = value;}
86  /// Get default rounding (default 0.5)
87  inline double defaultRounding() const
88  { return defaultRounding_;}
89  /// Set initial weight (default 0.0 == off)
90  inline void setInitialWeight(double value)
91  { initialWeight_ = value;}
92  /// Get initial weight (default 0.0 == off)
93  inline double initialWeight() const
94  { return initialWeight_;}
95  /// Set weight factor (default 0.1)
96  inline void setWeightFactor(double value)
97  { weightFactor_ = value;}
98  /// Get weight factor (default 0.1)
99  inline double weightFactor() const
100  { return weightFactor_;}
101  /// Set threshold cost for using original cost - even on continuous (default infinity)
102  inline void setArtificialCost(double value)
103  { artificialCost_ = value;}
104  /// Get threshold cost for using original cost - even on continuous (default infinity)
105  inline double artificialCost() const
106  { return artificialCost_;}
107  /// Get iteration to size ratio
108  inline double iterationRatio() const
109  { return iterationRatio_;}
110  /// Set iteration to size ratio
111  inline void setIterationRatio(double value)
112  { iterationRatio_ = value;}
113  /// Set maximum passes (default 100)
114  inline void setMaximumPasses(int value)
115  { maximumPasses_=value;}
116  /// Get maximum passes (default 100)
117  inline int maximumPasses() const
118  { return maximumPasses_;}
119  /// Set maximum retries (default 1)
120  inline void setMaximumRetries(int value)
121  { maximumRetries_=value;}
122  /// Get maximum retries (default 1)
123  inline int maximumRetries() const
124  { return maximumRetries_;}
125  /**  Set use of multiple solutions and solves
126       0 - do not reuse solves, do not accumulate integer solutions for local search
127       1 - do not reuse solves, accumulate integer solutions for local search
128       2 - reuse solves, do not accumulate integer solutions for local search
129       3 - reuse solves, accumulate integer solutions for local search
130  */
131  inline void setAccumulate(int value)
132  { accumulate_=value;}
133  /// Get accumulation option
134  inline int accumulate() const
135  { return accumulate_;}
136  /**  Set whether to fix variables on known solution
137       0 - do not fix
138       1 - fix integers on reduced costs
139       2 - fix integers on reduced costs but only on entry
140  */
141  inline void setFixOnReducedCosts(int value)
142  { fixOnReducedCosts_=value;}
143  /// Get reduced cost option
144  inline int fixOnReducedCosts() const
145  { return fixOnReducedCosts_;}
146
147protected:
148  // Data
149  /// Start time
150  double startTime_;
151  /// Maximum Cpu seconds
152  double maximumTime_;
153  /** Fake cutoff value.
154      If set then better of real cutoff and this used to add a constraint
155  */
156  double fakeCutoff_;
157  /// If positive carry on after solution expecting gain of at least this
158  double absoluteIncrement_;
159  /// If positive carry on after solution expecting gain of at least this times objective
160  double relativeIncrement_;
161  /// Default is round up if > this
162  double defaultRounding_;
163  /// Initial weight for true objective
164  double initialWeight_;
165  /// Factor for decreasing weight
166  double weightFactor_;
167  /// Threshold cost for using original cost - even on continuous
168  double artificialCost_;
169  /** If iterationRatio >0 use instead of maximumPasses_
170      test is iterations > ratio*(2*nrow+ncol) */
171  double iterationRatio_;
172  /// Maximum number of passes
173  int maximumPasses_;
174  /** Maximum number of retries if we find a solution.
175      If negative we clean out used array
176  */
177  int maximumRetries_;
178  /**  Set use of multiple solutions and solves
179       0 - do not reuse solves, do not accumulate integer solutions for local search
180       1 - do not reuse solves, accumulate integer solutions for local search
181       2 - reuse solves, do not accumulate integer solutions for local search
182       3 - reuse solves, accumulate integer solutions for local search
183       If we add 4 then use second form of problem (with extra rows and variables)
184  */
185  int accumulate_;
186  /**  Set whether to fix variables on known solution
187       0 - do not fix
188       1 - fix integers on reduced costs
189       2 - fix integers on reduced costs but only on entry
190  */
191  int fixOnReducedCosts_;
192  /// If true round to expensive
193  bool roundExpensive_;
194
195private:
196  /** Rounds solution - down if < downValue
197      If roundExpensive then always to more expnsive.
198      returns 0 if current is solution
199  */
200  int rounds(OsiSolverInterface * solver,double * solution, const double * objective, 
201             int numberIntegers, const int * integerVariable,
202             char * pumpPrint,int passNumber,
203             bool roundExpensive=false,
204             double downValue=0.5, int *flip=0);
205  /* note for eagle eyed readers.
206     when_ can now be exotic -
207     <=10 normal
208  */
209};
210
211# ifdef COIN_HAS_CLP
212 
213class CbcDisasterHandler : public OsiClpDisasterHandler {
214public:
215  /**@name Virtual methods that the derived classe should provide.
216  */
217  //@{
218#if 0
219  /// Into simplex
220  virtual void intoSimplex();
221  /// Checks if disaster
222  virtual bool check() const ;
223  /// saves information for next attempt
224  virtual void saveInfo();
225#endif
226  /// Type of disaster 0 can fix, 1 abort
227  virtual int typeOfDisaster();
228  //@}
229 
230 
231  /**@name Constructors, destructor */
232
233  //@{
234  /** Default constructor. */
235  CbcDisasterHandler(CbcModel * model = NULL);
236  /** Destructor */
237  virtual ~CbcDisasterHandler();
238  // Copy
239  CbcDisasterHandler(const CbcDisasterHandler&);
240  // Assignment
241  CbcDisasterHandler& operator=(const CbcDisasterHandler&);
242  /// Clone
243  virtual ClpDisasterHandler * clone() const;
244
245  //@}
246 
247  /**@name Sets/gets */
248
249  //@{
250  /** set model. */
251  void setCbcModel(CbcModel * model);
252  /// Get model
253  inline CbcModel * cbcModel() const
254  { return cbcModel_;}
255 
256  //@}
257 
258 
259protected:
260  /**@name Data members
261     The data members are protected to allow access for derived classes. */
262  //@{
263  /// Pointer to model
264  CbcModel * cbcModel_;
265     
266  //@}
267};
268#endif
269
270#endif
Note: See TracBrowser for help on using the repository browser.