Debian Codegraph @

Bonmin/src/CbcBonmin/Heuristics/BonHeuristicDive.hpp

raw
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 BonHeuristicDive_HPP
11 #define BonHeuristicDive_HPP
12 #include "BonOsiTMINLPInterface.hpp"
13 #include "BonBonminSetup.hpp"
14 #include "CbcHeuristic.hpp"
15
16 namespace Bonmin
17 {
18 class HeuristicDive : public CbcHeuristic
19 {
20 public:
21 /// Default constructor
22 HeuristicDive();
23
24 /// Constructor with setup
25 HeuristicDive(BonminSetup * setup);
26
27 /// Copy constructor
28 HeuristicDive(const HeuristicDive &copy);
29
30 /// Destructor
31 ~HeuristicDive() {}
32
33 /// Assignment operator
34 HeuristicDive & operator=(const HeuristicDive & rhs);
35
36 /// Clone
37 virtual CbcHeuristic * clone() const = 0;
38
39 /// Resets stuff if model changes
40 virtual void resetModel(CbcModel * model){
41 setModel(model);
42 }
43
44 /** Change setup used for heuristic.*/
45 virtual void setSetup(BonminSetup * setup){
46 setup_ = setup;
47 // Initialize(setup_->options());
48 }
49
50 /// Set percentage of integer variables to fix at bounds
51 void setPercentageToFix(double value)
52 { percentageToFix_ = value; }
53
54 /// Performs heuristic
55 virtual int solution(double &solutionValue, double *betterSolution);
56
57 /// sets internal variables
58 virtual void setInternalVariables(TMINLP2TNLP* minlp) = 0;
59
60 /// Selects the next variable to branch on
61 /** If bestColumn = -1, it means that no variable was found
62 */
63 virtual void selectVariableToBranch(TMINLP2TNLP* minlp,
64 const vector<int> & integerColumns,
65 const double* newSolution,
66 int& bestColumn,
67 int& bestRound) = 0;
68
69 protected:
70 /** Setup to use for local searches (will make copies).*/
71 BonminSetup * setup_;
72
73 /// Percentage of integer variables to fix at bounds
74 double percentageToFix_;
75
76 private:
77 /// How often to do (code can change)
78 int howOften_;
79
80 };
81
82 /// checks if the NLP relaxation of the problem is feasible
83 bool isNlpFeasible(TMINLP2TNLP* minlp, const double primalTolerance);
84
85 /// Adjusts the primalTolerance in case some of the constraints are violated
86 void adjustPrimalTolerance(TMINLP2TNLP* minlp, double & primalTolerance);
87 }
88 #endif