/usr/include/coin/CbcHeuristicLocal.hpp is in coinor-libcbc-dev 2.5.0-2.3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | /* $Id: CbcHeuristicLocal.hpp 1432 2010-02-07 19:33:53Z bjarni $ */
// Copyright (C) 2002, International Business Machines
// Corporation and others. All Rights Reserved.
#ifndef CbcHeuristicLocal_H
#define CbcHeuristicLocal_H
#include "CbcHeuristic.hpp"
/** LocalSearch class
*/
class CbcHeuristicLocal : public CbcHeuristic {
public:
// Default Constructor
CbcHeuristicLocal ();
/* Constructor with model - assumed before cuts
Initial version does not do Lps
*/
CbcHeuristicLocal (CbcModel & model);
// Copy constructor
CbcHeuristicLocal ( const CbcHeuristicLocal &);
// Destructor
~CbcHeuristicLocal ();
/// Clone
virtual CbcHeuristic * clone() const;
/// Assignment operator
CbcHeuristicLocal & operator=(const CbcHeuristicLocal& rhs);
/// Create C++ lines to get to current state
virtual void generateCpp( FILE * fp) ;
/// Resets stuff if model changes
virtual void resetModel(CbcModel * model);
/// update model (This is needed if cliques update matrix etc)
virtual void setModel(CbcModel * model);
using CbcHeuristic::solution ;
/** returns 0 if no solution, 1 if valid solution.
Sets solution values if good, sets objective value (only if good)
This is called after cuts have been added - so can not add cuts
First tries setting a variable to better value. If feasible then
tries setting others. If not feasible then tries swaps
********
This first version does not do LP's and does swaps of two integer
variables. Later versions could do Lps.
*/
virtual int solution(double & objectiveValue,
double * newSolution);
/// This version fixes stuff and does IP
int solutionFix(double & objectiveValue,
double * newSolution,
const int * keep);
/// Sets type of search
inline void setSearchType(int value) {
swap_ = value;
}
/// Used array so we can set
inline int * used() const {
return used_;
}
protected:
// Data
// Original matrix by column
CoinPackedMatrix matrix_;
// Number of solutions so we only do after new solution
int numberSolutions_;
// Type of search 0=normal, 1=BAB
int swap_;
/// Whether a variable has been in a solution (also when)
int * used_;
};
/** Naive class
a) Fix all ints as close to zero as possible
b) Fix all ints with nonzero costs and < large to zero
c) Put bounds round continuous and UIs and maximize
*/
class CbcHeuristicNaive : public CbcHeuristic {
public:
// Default Constructor
CbcHeuristicNaive ();
/* Constructor with model - assumed before cuts
Initial version does not do Lps
*/
CbcHeuristicNaive (CbcModel & model);
// Copy constructor
CbcHeuristicNaive ( const CbcHeuristicNaive &);
// Destructor
~CbcHeuristicNaive ();
/// Clone
virtual CbcHeuristic * clone() const;
/// Assignment operator
CbcHeuristicNaive & operator=(const CbcHeuristicNaive& rhs);
/// Create C++ lines to get to current state
virtual void generateCpp( FILE * fp) ;
/// Resets stuff if model changes
virtual void resetModel(CbcModel * model);
/// update model (This is needed if cliques update matrix etc)
virtual void setModel(CbcModel * model);
using CbcHeuristic::solution ;
/** returns 0 if no solution, 1 if valid solution.
Sets solution values if good, sets objective value (only if good)
*/
virtual int solution(double & objectiveValue,
double * newSolution);
/// Sets large cost value
inline void setLargeValue(double value) {
large_ = value;
}
/// Gets large cost value
inline double largeValue() const {
return large_;
}
protected:
/// Data
/// Large value
double large_;
};
/** Crossover Search class
*/
class CbcHeuristicCrossover : public CbcHeuristic {
public:
// Default Constructor
CbcHeuristicCrossover ();
/* Constructor with model - assumed before cuts
Initial version does not do Lps
*/
CbcHeuristicCrossover (CbcModel & model);
// Copy constructor
CbcHeuristicCrossover ( const CbcHeuristicCrossover &);
// Destructor
~CbcHeuristicCrossover ();
/// Clone
virtual CbcHeuristic * clone() const;
/// Assignment operator
CbcHeuristicCrossover & operator=(const CbcHeuristicCrossover& rhs);
/// Create C++ lines to get to current state
virtual void generateCpp( FILE * fp) ;
/// Resets stuff if model changes
virtual void resetModel(CbcModel * model);
/// update model (This is needed if cliques update matrix etc)
virtual void setModel(CbcModel * model);
using CbcHeuristic::solution ;
/** returns 0 if no solution, 1 if valid solution.
Fix variables if agree in useNumber_ solutions
when_ 0 off, 1 only at new solutions, 2 also every now and then
add 10 to make only if agree at lower bound
*/
virtual int solution(double & objectiveValue,
double * newSolution);
/// Sets number of solutions to use
inline void setNumberSolutions(int value) {
if (value > 0 && value <= 10)
useNumber_ = value;
}
protected:
// Data
/// Attempts
std::vector <double> attempts_;
/// Random numbers to stop same search happening
double random_[10];
/// Number of solutions so we only do after new solution
int numberSolutions_;
/// Number of solutions to use
int useNumber_;
};
#endif
|