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 
180 
183 
184  //
185  // PERSISTENT OBJECTS
186  //
187  // (not necessary to identify FP, but useful to keep between
188  // calls)
189  //
190 
194 
196  Ipopt::IpoptApplication *app_;
197 
200  OsiSolverInterface *milp_;
201 
205  OsiSolverInterface *postlp_;
206 
209 
211  std::set <CouenneFPsolution, compareSol> tabuPool_;
212 
214  int *match_;
215 
216  //
217  // PARAMETERS
218  //
219 
222 
225 
226  double multDistNLP_;
227  double multHessNLP_;
228  double multObjFNLP_;
229 
230  double multDistMILP_;
231  double multHessMILP_;
232  double multObjFMILP_;
233 
236 
239 
242 
244  int maxIter_;
245 
247  bool useSCIP_;
248 
251 
254 
256  int nCalls_;
257 
259  double fadeMult_;
260  };
261 }
262 
263 #endif
Cut Generator for linear convexifications.
static void registerOptions(Ipopt::SmartPtr< Bonmin::RegisteredOptions >)
initialize options to be read later
Ipopt::IpoptApplication * app_
Ipopt Application pointer for solving NLPs.
double multDistMILP_
weight of distance in MILP
Pool of solutions.
CouenneCutGenerator * couenneCG_
CouenneCutGenerator for linearization cuts.
CouenneProblem * Problem() const
return pointer to problem
expression * updateNLPObj(const double *)
set new expression as the NLP objective function using argument as point to minimize distance from...
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) ...
double multObjFNLP_
weight of objective in NLP
int maxIter_
Maximum iterations per call.
int nCalls_
How often should it be called.
double multObjFMILP_
weight of objective in MILP
void fint fint fint real * a
double multObjFNLP() const
weight of objective in NLP
int milpPhase(double *nSol, double *iSol)
MILP phase of the FP.
int & nCalls()
return number of calls (can be changed)
CouenneFeasPump & operator=(const CouenneFeasPump &rhs)
Assignment operator.
int nSepRounds_
Number of separation rounds for MILP convexification cuts.
virtual CbcHeuristic * clone() const
Clone.
double multHessMILP_
weight of Hessian in MILP
int nlpPhase(double *iSol, double *nSol)
NLP phase of the FP.
enum fpCutPlane milpCuttingPlane_
Separate convexification cuts during or after MILP.
int * match_
matching between reformulation&#39;s variables and L-1 norm variables
CouenneFPpool * pool_
Pool of solutions.
An implementation of the Feasibility pump that uses linearization and Ipopt to find the two sequences...
int milpMethod_
Which SCIP MILP method to use.
double multDistNLP_
Weights in computing distance, in both MILP and NLP (must sum up to 1 for MILP and for NLP): ...
double multObjFMILP() const
weight of objective in MILP
double multDistMILP() const
weight of distance in MILP
double findSolution(const double *nSol, double *&sol, int niter, int *nsuciter)
find feasible solution (called by solveMILP ())
Class for MINLP problems with symbolic information.
bool useSCIP_
Use SCIP instead of Cbc for solving MILPs.
CouenneTNLP * nlp() const
return NLP
int numberSolvePerLevel_
Number of NLPs solved for each given level of the tree.
virtual CouNumber solveNLP(const CouNumber *nSol, CouNumber *&iSol)
obtain solution to NLP
enum fpCompDistIntType compDistInt_
Compute distance from integer variables only, not all variables.
void init_MILP()
initialize all solvers at the first call, where the initial MILP is built
enum fpCompDistIntType compDistInt() const
return type of MILP solved
double multHessMILP() const
weight of Hessian in MILP
std::set< CouenneFPsolution, compareSol > tabuPool_
Solutions to avoid.
double multHessNLP_
weight of Hessian in NLP
double CouNumber
main number type in Couenne
OsiSolverInterface * postlp_
LP relaxation of the MINLP used when fixing integer variables (used for compDistInt_ in FP_DIST_POST ...
double fadingCoeff(double a)
CouenneFeasPump(CouenneProblem *couenne=NULL, CouenneCutGenerator *cg=NULL, Ipopt::SmartPtr< Ipopt::OptionsList > options=NULL)
Constructor with (optional) MINLP pointer.
enum fpTabuMgtPolicy tabuMgt_
Tabu management policy: none, use from pool, random perturbation of current solution.
void initIpoptApp()
Common code for initializing non-smartptr ipopt application.
double multHessNLP() const
weight of Hessian in NLP
virtual void resetModel(CbcModel *model)
Does nothing, but necessary as CbcHeuristic declares it pure virtual.
double multDistNLP() const
Return Weights in computing distance, in both MILP and NLP (must sum up to 1 for MILP and for NLP): ...
Expression base class.
Class for handling NLPs using CouenneProblem.
Definition: CouenneTNLP.hpp:27
CouenneProblem * problem_
Couenne representation of the problem.
double fadeMult_
decrease factor for MILP/NLP multipliers of distance/Hessian/objective
void setNumberSolvePerLevel(int value)
set number of nlp&#39;s solved for each given level of the tree
virtual int solution(double &objectiveValue, double *newSolution)
Run heuristic, return 1 if a better solution than the one passed is found and 0 otherwise.
OsiSolverInterface * milp_
MILP relaxation of the MINLP (used to find integer, non-NLP-feasible solutions)
bool fixIntVariables(const double *sol)
admits a (possibly fractional) solution and fixes the integer components in the nonlinear problem for...
CouenneTNLP * nlp_
Continuous relaxation of the problem, with an interface for Ipopt only.