CouenneFPFindSolution.cpp
Go to the documentation of this file.
1 /* $Id: CouenneFPFindSolution.cpp 1071 2014-03-13 01:35:13Z pbelotti $
2  *
3  * Name: CouenneFPFindSolution.cpp
4  * Authors: Pietro Belotti
5  * Timo Berthold, ZIB Berlin
6  * Purpose: Find solution by looping through MILP solvers/heuristics
7  *
8  * This file is licensed under the Eclipse Public License (EPL)
9  */
10 
11 #include "CoinTime.hpp"
12 
13 #include "CouenneFeasPump.hpp"
14 #include "CouenneFPpool.hpp"
15 #include "CouenneProblem.hpp"
16 #include "CouenneExprVar.hpp"
17 
18 #include "cons_rowcuts.h"
19 
20 #ifdef COIN_HAS_SCIP
21 #include "scip/scip.h"
22 #endif
23 
24 using namespace Couenne;
25 
27 double CouenneFeasPump::findSolution (const double *nSol, double* &iSol, int niter, int* nsuciter) {
28 
39 
40  // What order should we use? I suggest we use priorities, assigned
41  // at the beginning but changeable in the event of multiple failures
42  // (or successes) of a given method.
43  //
44  // Rule of thumb:
45  //
46  // 1) Assign all methods i a number p[i] (for instance those in the
47  // list above)
48  //
49  // 2) Call each in the order defined by p[i], return a solution if
50  // found, otherwise proceed to next method
51  //
52  // 3) If K consecutive successes at finding new solution (not
53  // necessarily new best feasible), --p[i]
54  //
55  // 4) if H consecutive failures, ++p[i]
56 
57  double obj;
58 
60 
61  if (0) {
62  static int nSolves = 0;
63  char name [40];
64  sprintf (name, "fp_milp_%d", nSolves++);
65  milp_ -> writeLp (name);
66  }
67 
68 #ifdef COIN_HAS_SCIP
69 
70  if (useSCIP_ && problem_ -> nIntVars () > 0) { // if LP, use Clp below
71 
72  SCIP_RETCODE retcode = ScipSolve (nSol, iSol, niter, nsuciter, obj);
73 
74  if (retcode != SCIP_OKAY) {
75 
76  printf ("Couenne Feasibility Pump: SCIP did not return a feasible solution\n");
77  obj = COIN_DBL_MAX;
78  }
79  } else
80 
81 #endif
82  {
83 
84  milp_ -> messageHandler () -> setLogLevel (0);
85 
86  if (problem_ -> nIntVars () > 0) milp_ -> branchAndBound ();
87  else milp_ -> initialSolve ();
88 
89  if (!iSol)
90  iSol = new CouNumber [problem_ -> nVars ()];
91 
92  if (milp_ -> getColSolution ())
93  CoinCopyN (milp_ -> getColSolution (), problem_ -> nVars (), iSol);
94  else {
95 
96  if (iSol)
97  delete [] iSol;
98  iSol = NULL;
99  }
100 
101  obj = milp_ -> getObjValue ();
102  }
103 
104  return obj;
105 }
106 
constraint handler for rowcuts constraints enables separation of convexification cuts during SCIP sol...
double findSolution(const double *nSol, double *&sol, int niter, int *nsuciter)
find feasible solution (called by solveMILP ())
bool useSCIP_
Use SCIP instead of Cbc for solving MILPs.
void init_MILP()
initialize all solvers at the first call, where the initial MILP is built
double CouNumber
main number type in Couenne
CouenneProblem * problem_
Couenne representation of the problem.
OsiSolverInterface * milp_
MILP relaxation of the MINLP (used to find integer, non-NLP-feasible solutions)