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

Last change on this file since 1100 was 1100, checked in by forrest, 12 years ago

add in a few modifications and naive heuristic

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