Bonmin  1.8.8
BonHeuristicDive.hpp
Go to the documentation of this file.
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
13 #include "BonBonminSetup.hpp"
14 #include "CbcHeuristic.hpp"
15 
16 namespace Bonmin
17 {
18  class HeuristicDive : public CbcHeuristic
19  {
20  public:
22  HeuristicDive();
23 
25  HeuristicDive(BonminSetup * setup);
26 
28  HeuristicDive(const HeuristicDive &copy);
29 
32 
34  HeuristicDive & operator=(const HeuristicDive & rhs);
35 
37  virtual CbcHeuristic * clone() const = 0;
38 
40  virtual void resetModel(CbcModel * model){
41  setModel(model);
42  }
43 
45  virtual void setSetup(BonminSetup * setup){
46  setup_ = setup;
47  // Initialize(setup_->options());
48  }
49 
51  void setPercentageToFix(double value)
52  { percentageToFix_ = value; }
53 
55  virtual int solution(double &solutionValue, double *betterSolution);
56 
58  virtual void setInternalVariables(TMINLP2TNLP* minlp) = 0;
59 
61 
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:
72 
75 
76  private:
78  int howOften_;
79 
80  };
81 
83  bool isNlpFeasible(TMINLP2TNLP* minlp, const double primalTolerance);
84 
86  void adjustPrimalTolerance(TMINLP2TNLP* minlp, double & primalTolerance);
87 }
88 #endif
virtual void selectVariableToBranch(TMINLP2TNLP *minlp, const vector< int > &integerColumns, const double *newSolution, int &bestColumn, int &bestRound)=0
Selects the next variable to branch on.
HeuristicDive()
Default constructor.
int howOften_
How often to do (code can change)
virtual int solution(double &solutionValue, double *betterSolution)
Performs heuristic.
bool isNlpFeasible(TMINLP2TNLP *minlp, const double primalTolerance)
checks if the NLP relaxation of the problem is feasible
void adjustPrimalTolerance(TMINLP2TNLP *minlp, double &primalTolerance)
Adjusts the primalTolerance in case some of the constraints are violated.
BonminSetup * setup_
Setup to use for local searches (will make copies).
~HeuristicDive()
Destructor.
virtual void setSetup(BonminSetup *setup)
Change setup used for heuristic.
virtual void resetModel(CbcModel *model)
Resets stuff if model changes.
HeuristicDive & operator=(const HeuristicDive &rhs)
Assignment operator.
virtual CbcHeuristic * clone() const =0
Clone.
virtual void setInternalVariables(TMINLP2TNLP *minlp)=0
sets internal variables
This is an adapter class that converts a TMINLP to a TNLP to be solved by Ipopt.
void setPercentageToFix(double value)
Set percentage of integer variables to fix at bounds.
double percentageToFix_
Percentage of integer variables to fix at bounds.