source: trunk/Cbc/src/CbcHeuristicDive.hpp @ 912

Last change on this file since 912 was 912, checked in by ladanyi, 13 years ago

Incorporated changes from branches/heur

File size: 2.5 KB
Line 
1// Copyright (C) 2008, International Business Machines
2// Corporation and others.  All Rights Reserved.
3#ifndef CbcHeuristicDive_H
4#define CbcHeuristicDive_H
5
6#include "CbcHeuristic.hpp"
7
8/** Dive class
9 */
10
11class CbcHeuristicDive : public CbcHeuristic {
12public:
13
14  // Default Constructor
15  CbcHeuristicDive ();
16
17  // Constructor with model - assumed before cuts
18  CbcHeuristicDive (CbcModel & model);
19 
20  // Copy constructor
21  CbcHeuristicDive ( const CbcHeuristicDive &);
22   
23  // Destructor
24  ~CbcHeuristicDive ();
25
26  /// Clone
27  virtual CbcHeuristicDive * clone() const = 0;
28 
29  /// Assignment operator
30  CbcHeuristicDive & operator=(const CbcHeuristicDive& rhs);
31
32  /// Create C++ lines to get to current state
33  virtual void generateCpp( FILE * fp) {}
34
35  /// Create C++ lines to get to current state - does work for base class
36  void generateCpp( FILE * fp,const char * heuristic);
37
38  /// Resets stuff if model changes
39  virtual void resetModel(CbcModel * model);
40
41  /// update model (This is needed if cliques update matrix etc)
42  virtual void setModel(CbcModel * model);
43 
44  //  REMLOVE using CbcHeuristic::solution ;
45  /** returns 0 if no solution, 1 if valid solution
46      with better objective value than one passed in
47      Sets solution values if good, sets objective value (only if good)
48      This is called after cuts have been added - so can not add cuts
49      This does Fractional Diving
50  */
51  virtual int solution(double & objectiveValue,
52                       double * newSolution);
53
54  /// Validate model i.e. sets when_ to 0 if necessary (may be NULL)
55  virtual void validate();
56
57  /// Set percentage of integer variables to fix at bounds
58  void setPercentageToFix(double value)
59  { percentageToFix_ = value; }
60
61  /// Set maximum number of iterations
62  void setMaxIterations(int value)
63  { maxIterations_ = value; }
64
65  /// Set maximum time allowed
66  void setMaxTime(double value)
67  { maxTime_ = value; }
68
69  /// Tests if the heuristic can run
70  virtual bool canHeuristicRun();
71
72  /// Selects the next variable to branch on
73  virtual void selectVariableToBranch(OsiSolverInterface* solver,
74                                      const double* newSolution,
75                                      int& bestColumn,
76                                      int& bestRound) = 0;
77
78protected:
79  // Data
80
81  // Original matrix by column
82  CoinPackedMatrix matrix_;
83
84  // Down locks
85  unsigned short * downLocks_;
86
87  // Up locks
88  unsigned short * upLocks_;
89
90  // Percentage of integer variables to fix at bounds
91  double percentageToFix_;
92
93  // Maximum number of iterations
94  int maxIterations_;
95
96  // Maximum time allowed
97  double maxTime_;
98
99};
100
101#endif
Note: See TracBrowser for help on using the repository browser.