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

Last change on this file since 1173 was 1173, checked in by forrest, 11 years ago

add $id

  • Property svn:keywords set to Id
File size: 3.7 KB
Line 
1/* $Id: CbcHeuristicDive.hpp 1173 2009-06-04 09:44:10Z forrest $ */
2// Copyright (C) 2008, International Business Machines
3// Corporation and others.  All Rights Reserved.
4#ifndef CbcHeuristicDive_H
5#define CbcHeuristicDive_H
6
7#include "CbcHeuristic.hpp"
8
9/** Dive class
10 */
11
12class CbcHeuristicDive : public CbcHeuristic {
13public:
14
15  // Default Constructor
16  CbcHeuristicDive ();
17
18  // Constructor with model - assumed before cuts
19  CbcHeuristicDive (CbcModel & model);
20 
21  // Copy constructor
22  CbcHeuristicDive ( const CbcHeuristicDive &);
23   
24  // Destructor
25  ~CbcHeuristicDive ();
26
27  /// Clone
28  virtual CbcHeuristicDive * clone() const = 0;
29 
30  /// Assignment operator
31  CbcHeuristicDive & operator=(const CbcHeuristicDive& rhs);
32
33  /// Create C++ lines to get to current state
34  virtual void generateCpp( FILE * fp) {}
35
36  /// Create C++ lines to get to current state - does work for base class
37  void generateCpp( FILE * fp,const char * heuristic);
38
39  /// Resets stuff if model changes
40  virtual void resetModel(CbcModel * model);
41
42  /// update model (This is needed if cliques update matrix etc)
43  virtual void setModel(CbcModel * model);
44 
45  //  REMLOVE using CbcHeuristic::solution ;
46  /** returns 0 if no solution, 1 if valid solution
47      with better objective value than one passed in
48      Sets solution values if good, sets objective value (only if good)
49      This is called after cuts have been added - so can not add cuts
50      This does Fractional Diving
51  */
52  virtual int solution(double & objectiveValue,
53                       double * newSolution);
54
55  /// Validate model i.e. sets when_ to 0 if necessary (may be NULL)
56  virtual void validate();
57
58  /// Select candidate binary variables for fixing
59  void selectBinaryVariables();
60
61  /// Set percentage of integer variables to fix at bounds
62  void setPercentageToFix(double value)
63  { percentageToFix_ = value; }
64
65  /// Set maximum number of iterations
66  void setMaxIterations(int value)
67  { maxIterations_ = value; }
68
69  /// Set maximum number of simplex iterations
70  void setMaxSimplexIterations(int value)
71  { maxSimplexIterations_ = value; }
72
73  /// Set maximum number of simplex iterations at root node
74  void setMaxSimplexIterationsAtRoot(int value)
75  { maxSimplexIterationsAtRoot_ = value; }
76
77  /// Set maximum time allowed
78  void setMaxTime(double value)
79  { maxTime_ = value; }
80
81  /// Tests if the heuristic can run
82  virtual bool canHeuristicRun();
83
84  /// Selects the next variable to branch on
85  /** Returns true if all the fractional variables can be trivially
86      rounded. Returns false, if there is at least one fractional variable
87      that is not trivially roundable. In this case, the bestColumn
88      returned will not be trivially roundable.
89  */
90  virtual bool selectVariableToBranch(OsiSolverInterface* solver,
91                                      const double* newSolution,
92                                      int& bestColumn,
93                                      int& bestRound) = 0;
94
95  /// Perform reduced cost fixing on integer variables
96  int reducedCostFix (OsiSolverInterface* solver);
97
98protected:
99  // Data
100
101  // Original matrix by column
102  CoinPackedMatrix matrix_;
103
104  // Original matrix by
105  CoinPackedMatrix matrixByRow_;
106
107  // Down locks
108  unsigned short * downLocks_;
109
110  // Up locks
111  unsigned short * upLocks_;
112
113  // Indexes of binary variables with 0 objective coefficient
114  // and in variable bound constraints
115  std::vector<int> binVarIndex_;
116
117  // Indexes of variable bound rows for each binary variable
118  std::vector<int> vbRowIndex_;
119
120  // Percentage of integer variables to fix at bounds
121  double percentageToFix_;
122
123  // Maximum number of major iterations
124  int maxIterations_;
125
126  // Maximum number of simplex iterations
127  int maxSimplexIterations_;
128
129  // Maximum number of simplex iterations at root node
130  int maxSimplexIterationsAtRoot_;
131
132  // Maximum time allowed
133  double maxTime_;
134
135};
136#endif
Note: See TracBrowser for help on using the repository browser.