| 1 |
// Copyright (C) 2007, International Business Machines Corporation and others. |
| 2 |
// All Rights Reserved. |
| 3 |
// This code is published under the Eclipse Public License. |
| 4 |
// |
| 5 |
// Authors : |
| 6 |
// Joao P. Goncalves, International Business Machines Corporation |
| 7 |
// |
| 8 |
// Date : November 12, 2007 |
| 9 |
|
| 10 |
#ifndef BonHeuristicDiveMIP_HPP |
| 11 |
#define BonHeuristicDiveMIP_HPP |
| 12 |
#include "BonOsiTMINLPInterface.hpp" |
| 13 |
#include "BonBonminSetup.hpp" |
| 14 |
#include "CbcHeuristic.hpp" |
| 15 |
#include "CbcStrategy.hpp" |
| 16 |
namespace Bonmin |
| 17 |
{ |
| 18 |
class SubMipSolver; |
| 19 |
class HeuristicDiveMIP : public CbcHeuristic |
| 20 |
{ |
| 21 |
public: |
| 22 |
#if 0 |
| 23 |
/// Default constructor |
| 24 |
HeuristicDiveMIP(); |
| 25 |
#endif |
| 26 |
|
| 27 |
/// Constructor with setup |
| 28 |
HeuristicDiveMIP(BonminSetup * setup); |
| 29 |
|
| 30 |
/// Copy constructor |
| 31 |
HeuristicDiveMIP(const HeuristicDiveMIP ©); |
| 32 |
|
| 33 |
/// Destructor |
| 34 |
~HeuristicDiveMIP(); |
| 35 |
|
| 36 |
/// Assignment operator |
| 37 |
HeuristicDiveMIP & operator=(const HeuristicDiveMIP & rhs); |
| 38 |
|
| 39 |
/// Clone |
| 40 |
virtual CbcHeuristic * clone() const = 0; |
| 41 |
|
| 42 |
/// Initialize method |
| 43 |
void Initialize(BonminSetup * setup); |
| 44 |
|
| 45 |
/// Resets stuff if model changes |
| 46 |
virtual void resetModel(CbcModel * model){ |
| 47 |
setModel(model); |
| 48 |
} |
| 49 |
|
| 50 |
/** Change setup used for heuristic.*/ |
| 51 |
virtual void setSetup(BonminSetup * setup){ |
| 52 |
setup_ = setup; |
| 53 |
// Initialize(setup_->options()); |
| 54 |
} |
| 55 |
|
| 56 |
/// Performs heuristic |
| 57 |
virtual int solution(double &solutionValue, double *betterSolution); |
| 58 |
|
| 59 |
/// sets internal variables |
| 60 |
virtual void setInternalVariables(TMINLP2TNLP* minlp) = 0; |
| 61 |
|
| 62 |
/// Selects the next variable to branch on |
| 63 |
/** If bestColumn = -1, it means that no variable was found |
| 64 |
*/ |
| 65 |
virtual void selectVariableToBranch(TMINLP2TNLP* minlp, |
| 66 |
const vector<int> & integerColumns, |
| 67 |
const double* newSolution, |
| 68 |
int& bestColumn, |
| 69 |
int& bestRound) = 0; |
| 70 |
|
| 71 |
protected: |
| 72 |
/** Setup to use for local searches (will make copies).*/ |
| 73 |
BonminSetup * setup_; |
| 74 |
|
| 75 |
private: |
| 76 |
/// How often to do (code can change) |
| 77 |
int howOften_; |
| 78 |
/// A subsolver for MIP |
| 79 |
SubMipSolver * mip_; |
| 80 |
|
| 81 |
}; |
| 82 |
} |
| 83 |
#endif |