Couenne  0.5.8
CouenneFeasPump.hpp
Go to the documentation of this file.
1 /* $Id: CouenneFeasPump.hpp 1071 2014-03-13 01:35:13Z pbelotti $
2  *
3  * Name: CouenneFeasPump.hpp
4  * Authors: Pietro Belotti
5  * Timo Berthold, ZIB Berlin
6  * Purpose: Define the Feasibility Pump heuristic class
7  * Created: August 5, 2009
8  *
9  * This file is licensed under the Eclipse Public License (EPL)
10  */
11 
12 #ifndef CouenneFeasPump_HPP
13 #define CouenneFeasPump_HPP
14 
15 #include <queue>
16 
17 #include "CouenneTypes.hpp"
18 #include "CbcHeuristic.hpp"
19 #include "CouenneFPpool.hpp"
20 #include "IpOptionsList.hpp"
21 
22 #ifdef COIN_HAS_SCIP
23 #include "scip/scip.h"
24 #endif
25 
26 struct Scip;
27 class OsiSolverInterface;
28 
29 //
30 // A fading coefficient decreases from a to a^k at every iteration if
31 // a > 0. If a is negative, then it increases from 1-|a| = 1+a to
32 // 1-|a|^k and eventually converges to 1
33 //
34 
35 inline double fadingCoeff (double a)
36 {return (a<0) ? a+1 : a;}
37 
38 namespace Ipopt {
39  class IpoptApplication;
40 }
41 
42 namespace Bonmin {
43  class RegisteredOptions;
44 }
45 
46 namespace Couenne {
47 
48  class expression;
49  class CouenneProblem;
50  class CouenneCutGenerator;
51  class CouenneTNLP;
52  class CouenneSparseMatrix;
53 
56 
57  class CouenneFeasPump: public CbcHeuristic {
58 
59  public:
60 
64 
66  CouenneFeasPump (CouenneProblem *couenne = NULL,
67  CouenneCutGenerator *cg = NULL,
69 
71  CouenneFeasPump (const CouenneFeasPump &other);
72 
74  virtual ~CouenneFeasPump();
75 
77  virtual CbcHeuristic *clone () const;
78 
81 
83  virtual void resetModel (CbcModel *model) {}
84 
92  virtual int solution (double &objectiveValue, double *newSolution);
93 
95  void setNumberSolvePerLevel (int value)
96  {numberSolvePerLevel_ = value;}
97 
98 #ifdef COIN_HAS_SCIP
99  void checkInfinity (struct Scip *scip, double val, double infinity);
101 #endif
102 
106  virtual CouNumber solveMILP (const CouNumber *nSol, CouNumber *&iSol, int niter, int* nsuciter);
107 
109  virtual CouNumber solveNLP (const CouNumber *nSol, CouNumber *&iSol);
110 
114  expression *updateNLPObj (const double *);
115 
119  bool fixIntVariables (const double *sol);
120 
123 
125  double findSolution (const double *nSol, double *&sol, int niter, int* nsuciter);
126 
129  void init_MILP ();
130 
132  void initIpoptApp ();
133 
136  {return problem_;}
137 
140  {return compDistInt_;}
141 
144 
145  double multDistNLP () const {return fadingCoeff (multDistNLP_);}
146  double multHessNLP () const {return fadingCoeff (multHessNLP_);}
147  double multObjFNLP () const {return fadingCoeff (multObjFNLP_);}
148 
149  double multDistMILP () const {return fadingCoeff (multDistMILP_);}
150  double multHessMILP () const {return fadingCoeff (multHessMILP_);}
151  double multObjFMILP () const {return fadingCoeff (multObjFMILP_);}
152 
154  CouenneTNLP *nlp () const
155  {return nlp_;}
156 
158  int &nCalls ()
159  {return nCalls_;}
160 
162  int milpPhase (double *nSol, double *iSol);
163 
165  int nlpPhase (double *iSol, double *nSol);
166 
167 #ifdef COIN_HAS_SCIP
168  SCIP_RETCODE ScipSolve (const double *nSol, double* &sol, int niter, int* nsuciter, CouNumber &obj);
169 #endif
170 
171  private:
172 
173  //
174  // ESSENTIAL TOOLS for the FP: a problem pointer and one for the
175  // linearization cut generator
176  //
177 
179  CouenneProblem *problem_;
180 
182  CouenneCutGenerator *couenneCG_;
183 
184  //
185  // PERSISTENT OBJECTS
186  //
187  // (not necessary to identify FP, but useful to keep between
188  // calls)
189  //
190 
193  CouenneTNLP *nlp_;
194 
197 
200  OsiSolverInterface *milp_;
201 
205  OsiSolverInterface *postlp_;
206 
208  CouenneFPpool *pool_;
209 
211  std::set <CouenneFPsolution, compareSol> tabuPool_;
212 
214  int *match_;
215 
216  //
217  // PARAMETERS
218  //
219 
221  int numberSolvePerLevel_;
222 
225 
226  double multDistNLP_;
227  double multHessNLP_;
228  double multObjFNLP_;
229 
230  double multDistMILP_;
231  double multHessMILP_;
232  double multObjFMILP_;
233 
235  enum fpCompDistIntType compDistInt_;
236 
238  enum fpCutPlane milpCuttingPlane_;
239 
241  int nSepRounds_;
242 
244  int maxIter_;
245 
247  bool useSCIP_;
248 
250  int milpMethod_;
251 
253  enum fpTabuMgtPolicy tabuMgt_;
254 
256  int nCalls_;
257 
259  double fadeMult_;
260  };
261 }
262 
263 #endif
Couenne::CouenneTNLP
Class for handling NLPs using CouenneProblem.
Definition: CouenneTNLP.hpp:27
Couenne::CouenneFeasPump::nlp
CouenneTNLP * nlp() const
return NLP
Definition: CouenneFeasPump.hpp:154
Couenne::CouenneFeasPump::milpPhase
int milpPhase(double *nSol, double *iSol)
MILP phase of the FP.
Couenne::CouenneFeasPump::updateNLPObj
expression * updateNLPObj(const double *)
set new expression as the NLP objective function using argument as point to minimize distance from.
Couenne::CouenneFeasPump::~CouenneFeasPump
virtual ~CouenneFeasPump()
Destructor.
Couenne::CouenneFeasPump::solveNLP
virtual CouNumber solveNLP(const CouNumber *nSol, CouNumber *&iSol)
obtain solution to NLP
fadingCoeff
double fadingCoeff(double a)
Definition: CouenneFeasPump.hpp:35
Couenne::CouenneFeasPump::fpTabuMgtPolicy
fpTabuMgtPolicy
Definition: CouenneFeasPump.hpp:63
Couenne::CouenneFeasPump::FP_TABU_POOL
@ FP_TABU_POOL
Definition: CouenneFeasPump.hpp:63
Couenne::CouenneFeasPump::initIpoptApp
void initIpoptApp()
Common code for initializing non-smartptr ipopt application.
Couenne::CouenneFeasPump::Problem
CouenneProblem * Problem() const
return pointer to problem
Definition: CouenneFeasPump.hpp:135
Couenne::CouenneFeasPump::FP_DIST_POST
@ FP_DIST_POST
Definition: CouenneFeasPump.hpp:61
Couenne::CouenneFeasPump::FP_CUT_INTEGRATED
@ FP_CUT_INTEGRATED
Definition: CouenneFeasPump.hpp:62
Bonmin
Couenne::CouenneFeasPump::resetModel
virtual void resetModel(CbcModel *model)
Does nothing, but necessary as CbcHeuristic declares it pure virtual.
Definition: CouenneFeasPump.hpp:83
Couenne::CouenneFeasPump::fixIntVariables
bool fixIntVariables(const double *sol)
admits a (possibly fractional) solution and fixes the integer components in the nonlinear problem for...
Couenne::CouenneFeasPump
An implementation of the Feasibility pump that uses linearization and Ipopt to find the two sequences...
Definition: CouenneFeasPump.hpp:57
Couenne::CouenneFeasPump::FP_CUT_NONE
@ FP_CUT_NONE
Definition: CouenneFeasPump.hpp:62
Ipopt
CbcHeuristic
Couenne::CouenneCutGenerator
Cut Generator for linear convexifications.
Definition: CouenneCutGenerator.hpp:49
Couenne::CouenneFeasPump::FP_TABU_NONE
@ FP_TABU_NONE
Definition: CouenneFeasPump.hpp:63
Couenne::CouenneFeasPump::FP_CUT_POST
@ FP_CUT_POST
Definition: CouenneFeasPump.hpp:62
Couenne
general include file for different compilers
Definition: CouenneAggrProbing.hpp:24
CouenneFPpool.hpp
Couenne::CouenneFeasPump::fpCompDistIntType
fpCompDistIntType
Definition: CouenneFeasPump.hpp:61
Couenne::CouenneFeasPump::CouenneFeasPump
CouenneFeasPump(CouenneProblem *couenne=NULL, CouenneCutGenerator *cg=NULL, Ipopt::SmartPtr< Ipopt::OptionsList > options=NULL)
Constructor with (optional) MINLP pointer.
Couenne::CouenneFeasPump::solveMILP
virtual CouNumber solveMILP(const CouNumber *nSol, CouNumber *&iSol, int niter, int *nsuciter)
find integer (possibly NLP-infeasible) point isol closest (according to the l-1 norm of the hessian) ...
Couenne::CouenneFeasPump::nlpPhase
int nlpPhase(double *iSol, double *nSol)
NLP phase of the FP.
Couenne::CouenneFeasPump::setNumberSolvePerLevel
void setNumberSolvePerLevel(int value)
set number of nlp's solved for each given level of the tree
Definition: CouenneFeasPump.hpp:95
CbcHeuristic.hpp
Couenne::CouenneFeasPump::FP_TABU_CUT
@ FP_TABU_CUT
Definition: CouenneFeasPump.hpp:63
CbcModel
Ipopt::SmartPtr< Ipopt::OptionsList >
Couenne::CouNumber
double CouNumber
main number type in Couenne
Definition: CouenneTypes.hpp:100
Couenne::CouenneFeasPump::solution
virtual int solution(double &objectiveValue, double *newSolution)
Run heuristic, return 1 if a better solution than the one passed is found and 0 otherwise.
Ipopt::IpoptApplication
Couenne::CouenneFeasPump::nCalls
int & nCalls()
return number of calls (can be changed)
Definition: CouenneFeasPump.hpp:158
OsiSolverInterface
CouenneTypes.hpp
Couenne::CouenneFeasPump::FP_TABU_PERTURB
@ FP_TABU_PERTURB
Definition: CouenneFeasPump.hpp:63
Couenne::CouenneFeasPump::findSolution
double findSolution(const double *nSol, double *&sol, int niter, int *nsuciter)
find feasible solution (called by solveMILP ())
Couenne::CouenneFeasPump::clone
virtual CbcHeuristic * clone() const
Clone.
Couenne::CouenneFeasPump::init_MILP
void init_MILP()
initialize all solvers at the first call, where the initial MILP is built
Couenne::CouenneFeasPump::FP_DIST_ALL
@ FP_DIST_ALL
Definition: CouenneFeasPump.hpp:61
Couenne::CouenneFeasPump::registerOptions
static void registerOptions(Ipopt::SmartPtr< Bonmin::RegisteredOptions >)
initialize options to be read later
Couenne::CouenneFeasPump::FP_DIST_INT
@ FP_DIST_INT
Definition: CouenneFeasPump.hpp:61
Couenne::CouenneFeasPump::fpCutPlane
fpCutPlane
Definition: CouenneFeasPump.hpp:62
Couenne::CouenneFeasPump::compDistInt
enum fpCompDistIntType compDistInt() const
return type of MILP solved
Definition: CouenneFeasPump.hpp:139
Couenne::CouenneProblem
Class for MINLP problems with symbolic information.
Definition: CouenneProblem.hpp:169
IpOptionsList.hpp
Couenne::expression
Expression base class.
Definition: CouenneExpression.hpp:48
Couenne::CouenneFPpool
Pool of solutions.
Definition: CouenneFPpool.hpp:91
Couenne::CouenneFeasPump::FP_CUT_EXTERNAL
@ FP_CUT_EXTERNAL
Definition: CouenneFeasPump.hpp:62
Couenne::CouenneFeasPump::operator=
CouenneFeasPump & operator=(const CouenneFeasPump &rhs)
Assignment operator.