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

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

some changes e.g. DINS added and a bit of printing

File size: 3.3 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  /// Select candidate binary variables for fixing
58  void selectBinaryVariables();
59
60  /// Set percentage of integer variables to fix at bounds
61  void setPercentageToFix(double value)
62  { percentageToFix_ = value; }
63
64  /// Set maximum number of iterations
65  void setMaxIterations(int value)
66  { maxIterations_ = value; }
67
68  /// Set maximum time allowed
69  void setMaxTime(double value)
70  { maxTime_ = value; }
71
72  /// Tests if the heuristic can run
73  virtual bool canHeuristicRun();
74
75  /// Selects the next variable to branch on
76  /** Returns true if all the fractional variables can be trivially
77      rounded. Returns false, if there is at least one fractional variable
78      that is not trivially roundable. In this case, the bestColumn
79      returned will not be trivially roundable.
80  */
81  virtual bool selectVariableToBranch(OsiSolverInterface* solver,
82                                      const double* newSolution,
83                                      int& bestColumn,
84                                      int& bestRound) = 0;
85
86  /// Perform reduced cost fixing on integer variables
87  int reducedCostFix (OsiSolverInterface* solver);
88
89protected:
90  // Data
91
92  // Original matrix by column
93  CoinPackedMatrix matrix_;
94
95  // Original matrix by
96  CoinPackedMatrix matrixByRow_;
97
98  // Down locks
99  unsigned short * downLocks_;
100
101  // Up locks
102  unsigned short * upLocks_;
103
104  // Indexes of binary variables with 0 objective coefficient
105  // and in variable bound constraints
106  std::vector<int> binVarIndex_;
107
108  // Indexes of variable bound rows for each binary variable
109  std::vector<int> vbRowIndex_;
110
111  // Percentage of integer variables to fix at bounds
112  double percentageToFix_;
113
114  // Maximum number of major iterations
115  int maxIterations_;
116
117  // Maximum number of simplex iterations
118  int maxSimplexIterations_;
119
120  // Maximum time allowed
121  double maxTime_;
122
123};
124#endif
Note: See TracBrowser for help on using the repository browser.