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

Last change on this file since 1899 was 1899, checked in by stefan, 6 years ago

fixup svn properties

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