11 #include "CbcModel.hpp"
24 #include "scip/scip.h"
25 #include "scip/cons_linear.h"
26 #include "scip/scipdefplugins.h"
29 using namespace Couenne;
31 #define NUMERICS_THRES 1e19
34 void CouenneFeasPump::checkInfinity(SCIP *scip, SCIP_Real val,
double infinity){
35 if( SCIPisInfinity(scip, val) && val < infinity)
37 "Warning: %g will be considered to be Infinity by SCIP.\n", val);
95 bool firstCall = (
milp_ == NULL);
106 for (
int i=
problem_ -> nVars (); i--;)
117 for (
int i=
problem_ -> nVars (); i--;) {
134 printf (
"======================================================================================================================================\n");
137 printf (
"(%d,%d)", i,
match_ [i]);
138 if ((++
j) % 6 == 0) printf (
"\n");
140 printf (
"======================================================================================================================================\n");
143 int nInitRows =
milp_ -> getNumRows ();
151 CoinCopyN (nSol0,
problem_ -> nOrigVars (), nlpSolExp);
155 nlpSolExp = CoinCopyOfArray (
milp_ -> getColSolution (),
165 int nFinalRows =
milp_ -> getNumRows ();
178 sprintf (filename,
"fp-milp%04d", cntr++);
179 milp_ -> writeLp (filename);
180 printf (
"saving FP_MILP %d\n", cntr);
183 double obj =
findSolution (nSol0, iSol, niter, nsuciter);
185 if ((nSol0 && iSol) &&
191 for (
int i = 0; i <
problem_ -> nVars (); ++i) {
193 if (
problem_ -> Var (i) -> Multiplicity () <= 0)
197 (fabs (iSol [i] - floor (iSol [i] + .5)) >
COUENNE_EPS))
201 (iSol [i] - nSol0 [i]) *
202 (iSol [i] - nSol0 [i]);
205 problem_ -> Jnlst () -> Printf (Ipopt::J_WARNING,
J_NLPHEURISTIC,
"FP: after MILP, distance %g, %d nonintegers\n", sqrt (dist), nNonint);
221 bool numerics =
false;
228 if (( (*i) -> Multiplicity () > 0) &&
253 int nvars =
postlp_ -> getNumCols ();
257 *saveLB = CoinCopyOfArray (
postlp_ -> getColLower (), nvars),
258 *saveUB = CoinCopyOfArray (
postlp_ -> getColUpper (), nvars),
259 *newLB = CoinCopyOfArray (
postlp_ -> getColLower (), nvars),
260 *newUB = CoinCopyOfArray (
postlp_ -> getColUpper (), nvars);
264 for (
int i =
problem_ -> nVars (); i--;)
266 if ((
problem_ -> Var (i) -> Multiplicity () > 0) &&
269 newLB [i] = newUB [i] = iSol [i] = floor (iSol [i] + .5);
271 postlp_ -> setColLower (newLB);
272 postlp_ -> setColUpper (newUB);
276 int nInitRowsLP =
postlp_ -> getNumRows ();
278 int nFinalRowsLP =
postlp_ -> getNumRows ();
286 if (
postlp_ -> isProvenOptimal ())
289 postlp_ -> setColLower (saveLB);
290 postlp_ -> setColUpper (saveUB);
302 nDeleted = nFinalRowsLP - nInitRowsLP,
303 *deleted =
new int [nDeleted],
304 nCurRow = nInitRowsLP;
306 for (
int i = nDeleted; i--;)
307 deleted [i] = nCurRow++;
309 postlp_ -> deleteRows (nDeleted, deleted);
318 nDeleted = nFinalRows - nInitRows,
319 *deleted =
new int [nDeleted],
322 for (
int i = nDeleted; i--;)
323 deleted [i] = nCurRow++;
325 milp_ -> deleteRows (nDeleted, deleted);
int nVars() const
Total number of variables.
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) ...
static int match(const char **sp, const char *t)
void addDistanceConstraints(const CouenneFeasPump *fp, OsiSolverInterface *lp, double *sol, bool isMILP, int *match)
modify MILP or LP to implement distance by adding extra rows (extra cols were already added by create...
int * match_
matching between reformulation's variables and L-1 norm variables
An implementation of the Feasibility pump that uses linearization and Ipopt to find the two sequences...
void fint fint fint real fint real real real real real real real real real fint real fint * lp
double findSolution(const double *nSol, double *&sol, int niter, int *nsuciter)
find feasible solution (called by solveMILP ())
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
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 ...
OsiSolverInterface * createCloneMILP(const CouenneFeasPump *fp, CbcModel *model, bool isMILP, int *match)
create clone of MILP and add variables for special objective
const Ipopt::EJournalCategory J_NLPHEURISTIC(Ipopt::J_USER5)
CouenneProblem * problem_
Couenne representation of the problem.
The in-memory representation of the variables element.
OsiSolverInterface * milp_
MILP relaxation of the MINLP (used to find integer, non-NLP-feasible solutions)
bool isInteger(CouNumber x)
is this number integer?