source: stable/2.4/Cbc/src/CbcHeuristicFPump.hpp @ 1271

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

Creating new stable branch 2.4 from trunk (rev 1270)

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