Couenne  0.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CouenneIterativeRounding.hpp
Go to the documentation of this file.
1 // (C) Copyright International Business Machines Corporation 2007
2 // All Rights Reserved.
3 // This code is published under the Eclipse Public License (EPL).
4 //
5 // Authors :
6 // Giacomo Nannicini, Tepper School of Business, Carnegie Mellon University
7 //
8 // Date : 07/25/2010
9 
10 #ifndef COUENNEITERATIVEROUNDING_HPP
11 #define COUENNEITERATIVEROUNDING_HPP
12 
13 #include "CouenneConfig.h"
14 #include "CbcHeuristic.hpp"
15 #include "BonOsiTMINLPInterface.hpp"
16 
17 #ifdef COIN_HAS_CPX
18 #include "OsiCpxSolverInterface.hpp"
19 #else
20 #include "CbcHeuristicFPump.hpp"
21 #include "CbcHeuristicRINS.hpp"
22 #include "CbcHeuristicDiveFractional.hpp"
23 #include "CbcHeuristicRandRound.hpp"
24 #endif
25 
26 #include "CouenneCutGenerator.hpp"
27 #include "CouenneProblem.hpp"
28 
29 namespace Couenne{
30 
36  class CouenneIterativeRounding : public CbcHeuristic{
37 
38  public:
42  CouenneIterativeRounding(Bonmin::OsiTMINLPInterface* nlp,
43  OsiSolverInterface* cinlp,
44  CouenneProblem* couenne,
48 
50  virtual ~CouenneIterativeRounding();
51 
53  virtual CbcHeuristic * clone() const;
54 
57 
59  void setNlp (Bonmin::OsiTMINLPInterface* nlp, OsiSolverInterface* cinlp);
60 
63  couenne_ = couenne;
64  }
65 
67  void resetModel(CbcModel * model){}
76  int solution(double & objectiveValue, double * newSolution);
77 
79  void setMaxRoundingIter(int value){
80  maxRoundingIter_ = value;
81  }
82 
84  void setMaxFirPoints(int value){
85  maxFirPoints_ = value;
86  }
87 
89  void setMaxTime(double value){
90  maxTime_ = value;
91  }
92 
94  void setMaxTimeFirstCall(double value){
95  maxTimeFirstCall_ = value;
96  }
97 
102  void setOmega(double value){
103  omega_ = value;
104  }
105 
109  void setBaseLbRhs(int value){
110  baseLbRhs_ = value;
111  }
112 
124  void setAggressiveness(int value);
125 
128 
129 private:
131  Bonmin::OsiTMINLPInterface * nlp_;
133  OsiSolverInterface * cinlp_;
135 #ifdef COIN_HAS_CPX
136  OsiCpxSolverInterface * milp_;
137 #else
138  OsiClpSolverInterface * milp_;
139 #endif
140 
145  double maxTime_;
151  int numSol_;
156  double* colLower_;
157  double* colUpper_;
160  double* colLowerNlp_;
161  double* colUpperNlp_;
162 #ifndef COIN_HAS_CPX
163 
164  CbcHeuristic** heuristics_;
166 #endif
167 
168  double startTime_;
170  double endTime_;
173  double omega_;
176 
179 
181  inline bool areEqual(double a, double b){
182  return (fabs(a-b) <= COUENNE_EPS);
183  }
184 
185  /* Try to find a first feasible solution */
186  int feasibilityIR(double& objectiveValue, double* newSolution);
187 
188  /* Try to improve a given solution */
189  int improvementIR(double& objectiveValue, double* newSolution,
190  const double* startingSolution);
191 
193  void setMilp();
194 
197  int computeIntAtBound(const double* x);
198 
202  int computeIntAtBound(const double* x, double& avgBoundSize);
203 
205  void writeLB(OsiRowCut& cut, const double* x, char sense, double rhs);
206 
208  int branchToCut(const double* x, OsiSolverInterface* solver,
209  std::vector<int>& previousBranches);
210 
212  bool solveMilp(OsiSolverInterface* milp, double maxTime);
213  };
214 }/* Ends namespace Couenne. */
215 
216 #endif
217 
CouenneIterativeRounding()
Default constructor.
void resetModel(CbcModel *model)
Does nothing.
An iterative rounding heuristic, tailored for nonconvex MINLPs.
double maxTime_
Max CPU time to run the heuristic.
double endTime_
Maximum allowed time for current run.
int numIntegers_
Number of integer variables in the original model.
void setMaxRoundingIter(int value)
Set maximum number of iterations for each rounding phase.
OsiSolverInterface * cinlp_
Pointer to the original NLP solver interface.
int branchToCut(const double *x, OsiSolverInterface *solver, std::vector< int > &previousBranches)
Branch on a random variable to cut given solution; returns var index.
void setMaxTimeFirstCall(double value)
Set maximum CPU time for the heuristic at the root node only.
double startTime_
Starting time for the heuristics.
void setMaxTime(double value)
Set maximum CPU time for the heuristic at each node.
void setMaxFirPoints(int value)
Set maximum number of points that we try to round in F-IR.
double maxTimeFirstCall_
Max CPU time to run the heuristic when no other solution is known.
bool solveMilp(OsiSolverInterface *milp, double maxTime)
Solve the MILP contained in milp to feasibility, or report failure.
void setMilp()
Set the milp solver at the root.
double omega_
Multiplication factor for log barrier parameter in F-IR; see in the paper.
double * colLower_
Pointer to original column lower and upper bounds of the reformulated problem, i.e.
int baseLbRhs_
Base value for the rhs of the local branching constraint it I-IR.
int maxFirPoints_
Maximum number of iterations in the outer loop for feasibility.
void setOmega(double value)
Set the value for omega, the multiplicative factor for the minimum log-barrier parameter mu used by F...
void setNlp(Bonmin::OsiTMINLPInterface *nlp, OsiSolverInterface *cinlp)
Set the minlp solver.
Class for MINLP problems with symbolic information.
bool areEqual(double a, double b)
Check if two double precision numbers are equal, up to some tolerance.
#define COUENNE_EPS
int feasibilityIR(double &objectiveValue, double *newSolution)
static void registerOptions(Ipopt::SmartPtr< Bonmin::RegisteredOptions >)
initialize options to be read later
void setBaseLbRhs(int value)
Set the base value for the rhs of the local branching constraint in the I-IR heuristic.
CouenneProblem * couenne_
Pointer to a couenne representation of the problem.
double * colLowerNlp_
Pointer to column lower and upper bounds of the original problem, i.e.
CbcHeuristic ** heuristics_
Heuristics for the MILP.
CouenneIterativeRounding & operator=(const CouenneIterativeRounding &rhs)
Assignment operator.
int solution(double &objectiveValue, double *newSolution)
Run heuristic, return 1 if a better solution than the one passed is found and 0 otherwise.
int computeIntAtBound(const double *x)
Compute number of integer variables at one of their bounds at a given point x.
int numInitialRows_
Number of rows in the original convexification.
void setCouenneProblem(CouenneProblem *couenne)
Set the couenne problem to use.
int numSol_
Number of solutions last time the heuristic was called.
int improvementIR(double &objectiveValue, double *newSolution, const double *startingSolution)
void setAggressiveness(int value)
Set aggressiveness of heuristic.
OsiClpSolverInterface * milp_
Pointer to a milp solver interface.
void writeLB(OsiRowCut &cut, const double *x, char sense, double rhs)
Write down a local branching constraint, as an OsiRowCut.
int maxRoundingIter_
Maximum number of iterations in the main loop.
Bonmin::OsiTMINLPInterface * nlp_
Pointer to a dynamic nlp solver interface.
virtual ~CouenneIterativeRounding()
Destructor.
virtual CbcHeuristic * clone() const
Clone.