source: branches/heur/Cbc/src/CbcHeuristicFPump.hpp @ 885

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

changes to heuristics and allow collection of more statistics

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.2 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  /// Set maximum passes (default 100)
107  inline void setMaximumPasses(int value)
108  { maximumPasses_=value;}
109  /// Get maximum passes (default 100)
110  inline int maximumPasses() const
111  { return maximumPasses_;}
112  /// Set maximum retries (default 1)
113  inline void setMaximumRetries(int value)
114  { maximumRetries_=value;}
115  /// Get maximum retries (default 1)
116  inline int maximumRetries() const
117  { return maximumRetries_;}
118  /**  Set use of multiple solutions and solves
119       0 - do not reuse solves, do not accumulate integer solutions for local search
120       1 - do not reuse solves, accumulate integer solutions for local search
121       2 - reuse solves, do not accumulate integer solutions for local search
122       3 - reuse solves, accumulate integer solutions for local search
123  */
124  inline void setAccumulate(int value)
125  { accumulate_=value;}
126  /// Get accumulation option
127  inline int accumulate() const
128  { return accumulate_;}
129  /**  Set whether to fix variables on known solution
130       0 - do not fix
131       1 - fix integers on reduced costs
132       2 - fix integers on reduced costs but only on entry
133  */
134  inline void setFixOnReducedCosts(int value)
135  { fixOnReducedCosts_=value;}
136  /// Get reduced cost option
137  inline int fixOnReducedCosts() const
138  { return fixOnReducedCosts_;}
139
140protected:
141  // Data
142  /// Start time
143  double startTime_;
144  /// Maximum Cpu seconds
145  double maximumTime_;
146  /** Fake cutoff value.
147      If set then better of real cutoff and this used to add a constraint
148  */
149  double fakeCutoff_;
150  /// If positive carry on after solution expecting gain of at least this
151  double absoluteIncrement_;
152  /// If positive carry on after solution expecting gain of at least this times objective
153  double relativeIncrement_;
154  /// Default is round up if > this
155  double defaultRounding_;
156  /// Initial weight for true objective
157  double initialWeight_;
158  /// Factor for decreasing weight
159  double weightFactor_;
160  /// Threshold cost for using original cost - even on continuous
161  double artificialCost_;
162  /// Maximum number of passes
163  int maximumPasses_;
164  /** Maximum number of retries if we find a solution.
165      If negative we clean out used array
166  */
167  int maximumRetries_;
168  /**  Set use of multiple solutions and solves
169       0 - do not reuse solves, do not accumulate integer solutions for local search
170       1 - do not reuse solves, accumulate integer solutions for local search
171       2 - reuse solves, do not accumulate integer solutions for local search
172       3 - reuse solves, accumulate integer solutions for local search
173       If we add 4 then use second form of problem (with extra rows and variables)
174  */
175  int accumulate_;
176  /**  Set whether to fix variables on known solution
177       0 - do not fix
178       1 - fix integers on reduced costs
179       2 - fix integers on reduced costs but only on entry
180  */
181  int fixOnReducedCosts_;
182  /// If true round to expensive
183  bool roundExpensive_;
184
185private:
186  /** Rounds solution - down if < downValue
187      If roundExpensive then always to more expnsive.
188      returns 0 if current is solution
189  */
190  int rounds(OsiSolverInterface * solver,double * solution, const double * objective, 
191             int numberIntegers, const int * integerVariable,
192             char * pumpPrint,int & passNumber,
193             bool roundExpensive=false,
194             double downValue=0.5, int *flip=0);
195  /* note for eagle eyed readers.
196     when_ can now be exotic -
197     <=10 normal
198  */
199};
200
201
202#endif
Note: See TracBrowser for help on using the repository browser.