source: stable/2.4/Cbc/src/CbcHeuristicDive.hpp @ 1271

Last change on this file since 1271 was 1271, checked in by forrest, 10 years ago

Creating new stable branch 2.4 from trunk (rev 1270)

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