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

Last change on this file since 1557 was 1432, checked in by bjarni, 10 years ago

Added extra return at end of each source file where needed, to remove possible linefeed conflicts (NightlyBuild? errors)

File size: 4.6 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
71    /// Set maximum number of iterations
72    void setMaxIterations(int value) {
73        maxIterations_ = value;
74    }
75
76    /// Set maximum number of simplex iterations
77    void setMaxSimplexIterations(int value) {
78        maxSimplexIterations_ = value;
79    }
80
81    /// Set maximum number of simplex iterations at root node
82    void setMaxSimplexIterationsAtRoot(int value) {
83        maxSimplexIterationsAtRoot_ = value;
84    }
85
86    /// Set maximum time allowed
87    void setMaxTime(double value) {
88        maxTime_ = value;
89    }
90
91    /// Tests if the heuristic can run
92    virtual bool canHeuristicRun();
93
94    /** Selects the next variable to branch on
95        Returns true if all the fractional variables can be trivially
96        rounded. Returns false, if there is at least one fractional variable
97        that is not trivially roundable. In this case, the bestColumn
98        returned will not be trivially roundable.
99    */
100    virtual bool selectVariableToBranch(OsiSolverInterface* solver,
101                                        const double* newSolution,
102                                        int& bestColumn,
103                                        int& bestRound) = 0;
104    /** Initializes any data which is going to be used repeatedly
105        in selectVariableToBranch */
106    virtual void initializeData() {}
107
108    /// Perform reduced cost fixing on integer variables
109    int reducedCostFix (OsiSolverInterface* solver);
110    /// Fix other variables at bounds
111    virtual int fixOtherVariables(OsiSolverInterface * solver,
112                                  const double * solution,
113                                  PseudoReducedCost * candidate,
114                                  const double * random);
115
116protected:
117    // Data
118
119    // Original matrix by column
120    CoinPackedMatrix matrix_;
121
122    // Original matrix by
123    CoinPackedMatrix matrixByRow_;
124
125    // Down locks
126    unsigned short * downLocks_;
127
128    // Up locks
129    unsigned short * upLocks_;
130
131    /// Extra down array (number Integers long)
132    double * downArray_;
133
134    /// Extra up array (number Integers long)
135    double * upArray_;
136
137    // Indexes of binary variables with 0 objective coefficient
138    // and in variable bound constraints
139    std::vector<int> binVarIndex_;
140
141    // Indexes of variable bound rows for each binary variable
142    std::vector<int> vbRowIndex_;
143
144    // Percentage of integer variables to fix at bounds
145    double percentageToFix_;
146
147    // Maximum number of major iterations
148    int maxIterations_;
149
150    // Maximum number of simplex iterations
151    int maxSimplexIterations_;
152
153    // Maximum number of simplex iterations at root node
154    int maxSimplexIterationsAtRoot_;
155
156    // Maximum time allowed
157    double maxTime_;
158
159};
160#endif
161
Note: See TracBrowser for help on using the repository browser.