CbcHeuristicFPump.hpp
Go to the documentation of this file.
1 /* $Id: CbcHeuristicFPump.hpp 1432 2010-02-07 19:33:53Z bjarni $ */
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 
13 class CbcHeuristicFPump : public CbcHeuristic {
14 public:
15 
16  // Default Constructor
18 
19  // Constructor with model - assumed before cuts
20  CbcHeuristicFPump (CbcModel & model,
21  double downValue = 0.5, bool roundExpensive = false);
22 
23  // Copy constructor
25 
26  // Destructor
28 
32  virtual CbcHeuristic * clone() const;
34  virtual void generateCpp( FILE * fp) ;
35 
37  virtual void resetModel(CbcModel * model);
38 
40  virtual void setModel(CbcModel * model);
41 
63  virtual int solution(double & objectiveValue,
64  double * newSolution);
65 
67  void setMaximumTime(double value);
69  inline double maximumTime() const {
70  return maximumTime_;
71  }
73  inline void setFakeCutoff(double value) {
74  fakeCutoff_ = value;
75  }
77  inline double fakeCutoff() const {
78  return fakeCutoff_;
79  }
81  inline void setAbsoluteIncrement(double value) {
82  absoluteIncrement_ = value;
83  }
85  inline double absoluteIncrement() const {
86  return absoluteIncrement_;
87  }
89  inline void setRelativeIncrement(double value) {
90  relativeIncrement_ = value;
91  }
93  inline double relativeIncrement() const {
94  return relativeIncrement_;
95  }
97  inline void setDefaultRounding(double value) {
98  defaultRounding_ = value;
99  }
101  inline double defaultRounding() const {
102  return defaultRounding_;
103  }
105  inline void setInitialWeight(double value) {
106  initialWeight_ = value;
107  }
109  inline double initialWeight() const {
110  return initialWeight_;
111  }
113  inline void setWeightFactor(double value) {
114  weightFactor_ = value;
115  }
117  inline double weightFactor() const {
118  return weightFactor_;
119  }
121  inline void setArtificialCost(double value) {
122  artificialCost_ = value;
123  }
125  inline double artificialCost() const {
126  return artificialCost_;
127  }
129  inline double iterationRatio() const {
130  return iterationRatio_;
131  }
133  inline void setIterationRatio(double value) {
134  iterationRatio_ = value;
135  }
137  inline void setMaximumPasses(int value) {
138  maximumPasses_ = value;
139  }
141  inline int maximumPasses() const {
142  return maximumPasses_;
143  }
145  inline void setMaximumRetries(int value) {
146  maximumRetries_ = value;
147  }
149  inline int maximumRetries() const {
150  return maximumRetries_;
151  }
173  inline void setAccumulate(int value) {
174  accumulate_ = value;
175  }
177  inline int accumulate() const {
178  return accumulate_;
179  }
185  inline void setFixOnReducedCosts(int value) {
186  fixOnReducedCosts_ = value;
187  }
189  inline int fixOnReducedCosts() const {
190  return fixOnReducedCosts_;
191  }
196  inline void setReducedCostMultiplier(double value) {
197  reducedCostMultiplier_ = value;
198  }
200  inline double reducedCostMultiplier() const {
201  return reducedCostMultiplier_;
202  }
203 
204 protected:
205  // Data
207  double startTime_;
209  double maximumTime_;
213  double fakeCutoff_;
215  double absoluteIncrement_;
217  double relativeIncrement_;
219  double defaultRounding_;
221  double initialWeight_;
223  double weightFactor_;
225  double artificialCost_;
228  double iterationRatio_;
233  double reducedCostMultiplier_;
235  int maximumPasses_;
239  int maximumRetries_;
250  int accumulate_;
256  int fixOnReducedCosts_;
258  bool roundExpensive_;
259 
260 private:
265  int rounds(OsiSolverInterface * solver, double * solution,
266  /*const double * objective, */
267  int numberIntegers, const int * integerVariable,
268  /*char * pumpPrint,*/int passNumber,
269  /*bool roundExpensive=false,*/
270  double downValue = 0.5, int *flip = 0);
271  /* note for eagle eyed readers.
272  when_ can now be exotic -
273  <=10 normal
274  */
275 };
276 
277 # ifdef COIN_HAS_CLP
278 
279 class CbcDisasterHandler : public OsiClpDisasterHandler {
280 public:
284 #ifdef JJF_ZERO
285  virtual void intoSimplex();
288  virtual bool check() const ;
290  virtual void saveInfo();
291 #endif
292  virtual int typeOfDisaster();
295 
296 
301  CbcDisasterHandler(CbcModel * model = NULL);
303  virtual ~CbcDisasterHandler();
304  // Copy
305  CbcDisasterHandler(const CbcDisasterHandler&);
306  // Assignment
307  CbcDisasterHandler& operator=(const CbcDisasterHandler&);
309  virtual ClpDisasterHandler * clone() const;
310 
312 
317  void setCbcModel(CbcModel * model);
319  inline CbcModel * cbcModel() const {
320  return cbcModel_;
321  }
322 
324 
325 
326 protected:
330  CbcModel * cbcModel_;
332 
334 };
335 #endif
336 
337 #endif
338 
void setRelativeIncrement(double value)
Set relative increment (default 0.0 == off)
int maximumRetries() const
Get maximum retries (default 1)
double fakeCutoff() const
Get fake cutoff (default 0.0 == off)
double defaultRounding_
Default is round up if > this.
double artificialCost() const
Get threshold cost for using original cost - even on continuous (default infinity) ...
double defaultRounding() const
Get default rounding (default 0.5)
int fixOnReducedCosts_
Set whether to fix variables on known solution 0 - do not fix 1 - fix integers on reduced costs 2 - f...
double startTime_
Start time.
void setReducedCostMultiplier(double value)
Set reduced cost multiplier 1.0 as normal <1.0 (x) - pretend gap is x* actual gap - just for fixing...
int rounds(OsiSolverInterface *solver, double *solution, int numberIntegers, const int *integerVariable, int passNumber, double downValue=0.5, int *flip=0)
Rounds solution - down if < downValue If roundExpensive then always to more expnsive.
void setFakeCutoff(double value)
Set fake cutoff (default COIN_DBL_MAX == off)
double relativeIncrement() const
Get relative increment (default 0.0 == off)
double artificialCost_
Threshold cost for using original cost - even on continuous.
double fakeCutoff_
Fake cutoff value.
double initialWeight_
Initial weight for true objective.
double maximumTime_
Maximum Cpu seconds.
double absoluteIncrement() const
Get absolute increment (default 0.0 == off)
int fixOnReducedCosts() const
Get reduced cost option.
void setMaximumPasses(int value)
Set maximum passes (default 100)
virtual int solution(double &objectiveValue, double *newSolution)=0
returns 0 if no solution, 1 if valid solution with better objective value than one passed in Sets sol...
virtual int solution(double &objectiveValue, double *newSolution)
returns 0 if no solution, 1 if valid solution with better objective value than one passed in Sets sol...
void setAccumulate(int value)
Set use of multiple solutions and solves 0 - do not reuse solves, do not accumulate integer solutions...
bool roundExpensive_
If true round to expensive.
void setMaximumRetries(int value)
Set maximum retries (default 1)
double relativeIncrement_
If positive carry on after solution expecting gain of at least this times objective.
void setFixOnReducedCosts(int value)
Set whether to fix variables on known solution 0 - do not fix 1 - fix integers on reduced costs 2 - f...
Feasibility Pump class.
int accumulate() const
Get accumulation option.
virtual CbcHeuristic * clone() const
Clone.
void setArtificialCost(double value)
Set threshold cost for using original cost - even on continuous (default infinity) ...
void setAbsoluteIncrement(double value)
Set absolute increment (default 0.0 == off)
int maximumRetries_
Maximum number of retries if we find a solution.
void setDefaultRounding(double value)
Set default rounding (default 0.5)
virtual void generateCpp(FILE *fp)
Create C++ lines to get to current state.
virtual void resetModel(CbcModel *model)
Resets stuff if model changes.
double reducedCostMultiplier_
Reduced cost multiplier 1.0 as normal <1.0 (x) - pretend gap is x* actual gap - just for fixing...
double reducedCostMultiplier() const
Get reduced cost multiplier.
CbcHeuristicFPump & operator=(const CbcHeuristicFPump &rhs)
Assignment operator.
double weightFactor_
Factor for decreasing weight.
double iterationRatio_
If iterationRatio >0 use instead of maximumPasses_ test is iterations > ratio*(2*nrow+ncol) ...
double initialWeight() const
Get initial weight (default 0.0 == off)
double maximumTime() const
Get maximum Time (default 0.0 == time limit off)
Heuristic base class.
double absoluteIncrement_
If positive carry on after solution expecting gain of at least this.
void setInitialWeight(double value)
Set initial weight (default 0.0 == off)
int maximumPasses() const
Get maximum passes (default 100)
void setMaximumTime(double value)
Set maximum Time (default off) - also sets starttime to current.
void setIterationRatio(double value)
Set iteration to size ratio.
int accumulate_
Set use of multiple solutions and solves 0 - do not reuse solves, do not accumulate integer solutions...
void setWeightFactor(double value)
Set weight factor (default 0.1)
virtual void setModel(CbcModel *model)
update model (This is needed if cliques update matrix etc)
double weightFactor() const
Get weight factor (default 0.1)
int maximumPasses_
Maximum number of passes.
Simple Branch and bound class.
Definition: CbcModel.hpp:98
double iterationRatio() const
Get iteration to size ratio.