Scippy

SCIP

Solving Constraint Integer Programs

heur_mpec.c
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and library */
4 /* SCIP --- Solving Constraint Integer Programs */
5 /* */
6 /* Copyright (C) 2002-2018 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not email to scip@zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file heur_mpec.c
17  * @brief mpec primal heuristic
18  * @author Felipe Serrano
19  * @author Benjamin Mueller
20  */
21 
22 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
23 
24 #include <assert.h>
25 #include <string.h>
26 
27 #include "scip/heur_mpec.h"
28 #include "scip/heur_subnlp.h"
29 #include "nlpi/nlpi.h"
30 
31 
32 #define HEUR_NAME "mpec"
33 #define HEUR_DESC "regularization heuristic for convex and nonconvex MINLPs"
34 #define HEUR_DISPCHAR 'W'
35 #define HEUR_PRIORITY -2050000
36 #define HEUR_FREQ 50
37 #define HEUR_FREQOFS 0
38 #define HEUR_MAXDEPTH -1
39 #define HEUR_TIMING SCIP_HEURTIMING_AFTERLPNODE
40 #define HEUR_USESSUBSCIP TRUE /**< disable the heuristic in sub-SCIPs, even though it does not use any */
41 
42 #define DEFAULT_INITTHETA 0.125 /**< default initial regularization right-hand side value (< 0.25) */
43 #define DEFAULT_SIGMA 0.5 /**< default regularization update factor (< 1) */
44 #define DEFAULT_MAXITER 100 /**< default maximum number of iterations of the MPEC loop */
45 #define DEFAULT_MAXNLPITER 500 /**< default maximum number of NLP iterations per solve */
46 #define DEFAULT_MINGAPLEFT 0.05 /**< default minimum amount of gap left in order to call the heuristic */
47 #define DEFAULT_SUBNLPTRIGGER 1e-3 /**< default maximum integrality violation before triggering a sub-NLP call */
48 #define DEFAULT_MAXNLPCOST 1e+8 /**< default maximum cost available for solving NLPs per call of the heuristic */
49 #define DEFAULT_MINIMPROVE 0.01 /**< default factor by which heuristic should at least improve the incumbent */
50 #define DEFAULT_MAXNUNSUCC 10 /**< default maximum number of consecutive calls for which the heuristic did not find an improving solution */
51 
52 /*
53  * Data structures
54  */
55 
56 /** primal heuristic data */
57 struct SCIP_HeurData
58 {
59  SCIP_NLPI* nlpi; /**< nlpi used to create the nlpi problem */
60  SCIP_NLPIPROBLEM* nlpiprob; /**< nlpi problem representing the NLP relaxation */
61  SCIP_HASHMAP* var2idx; /**< mapping between variables and nlpi indices */
62  SCIP_HEUR* subnlp; /**< sub-NLP heuristic */
63 
64  SCIP_Real inittheta; /**< initial regularization right-hand side value */
65  SCIP_Real sigma; /**< regularization update factor */
66  SCIP_Real subnlptrigger; /**< maximum number of NLP iterations per solve */
67  SCIP_Real maxnlpcost; /**< maximum cost available for solving NLPs per call of the heuristic */
68  SCIP_Real minimprove; /**< factor by which heuristic should at least improve the incumbent */
69  SCIP_Real mingapleft; /**< minimum amount of gap left in order to call the heuristic */
70  int maxiter; /**< maximum number of iterations of the MPEC loop */
71  int maxnlpiter; /**< maximum number of NLP iterations per solve */
72  int nunsucc; /**< number of consecutive calls for which the heuristic did not find an
73  * improving solution */
74  int maxnunsucc; /**< maximum number of consecutive calls for which the heuristic did not
75  * find an improving solution */
76 };
77 
78 
79 /*
80  * Local methods
81  */
82 
83 /** creates the data structure for generating the current NLP relaxation */
84 static
86  SCIP* scip, /**< SCIP data structure */
87  SCIP_HEURDATA* heurdata /**< heuristic data */
88  )
89 {
90  SCIP_Real cutoff = SCIPinfinity(scip);
91 
92  assert(heurdata != NULL);
93  assert(heurdata->nlpi != NULL);
94 
95  /* NLP has been already created */
96  if( heurdata->nlpiprob != NULL )
97  return SCIP_OKAY;
98 
99  /* compute cutoff value to ensure minimum improvement */
100  if( SCIPgetNSols(scip) > 0 )
101  {
102  SCIP_Real upperbound = SCIPgetUpperbound(scip) - SCIPsumepsilon(scip);
103 
104  assert( !SCIPisInfinity(scip, SCIPgetUpperbound(scip)) );
105 
106  if( !SCIPisInfinity(scip, -SCIPgetLowerbound(scip)) )
107  {
108  cutoff = (1.0 - heurdata->minimprove) * SCIPgetUpperbound(scip)
109  + heurdata->minimprove * SCIPgetLowerbound(scip);
110  }
111  else
112  {
113  if( SCIPgetUpperbound(scip) >= 0.0 )
114  cutoff = ( 1.0 - heurdata->minimprove ) * SCIPgetUpperbound(scip);
115  else
116  cutoff = ( 1.0 + heurdata->minimprove ) * SCIPgetUpperbound(scip);
117  }
118  cutoff = MIN(upperbound, cutoff);
119  SCIPdebugMsg(scip, "set objective limit %g in [%g,%g]\n", cutoff, SCIPgetLowerbound(scip),
120  SCIPgetUpperbound(scip));
121  }
122 
123  SCIP_CALL( SCIPnlpiCreateProblem(heurdata->nlpi, &heurdata->nlpiprob, "MPEC-nlp") );
124  SCIP_CALL( SCIPhashmapCreate(&heurdata->var2idx, SCIPblkmem(scip), SCIPgetNVars(scip)) );
125  SCIP_CALL( SCIPcreateNlpiProb(scip, heurdata->nlpi, SCIPgetNLPNlRows(scip), SCIPgetNNLPNlRows(scip),
126  heurdata->nlpiprob, heurdata->var2idx, NULL, cutoff, TRUE, FALSE) );
127 
128  return SCIP_OKAY;
129 }
130 
131 /** frees the data structures for the NLP relaxation */
132 static
134  SCIP* scip, /**< SCIP data structure */
135  SCIP_HEURDATA* heurdata /**< heuristic data */
136  )
137 {
138  assert(heurdata != NULL);
139 
140  /* NLP has not been created yet */
141  if( heurdata->nlpiprob == NULL )
142  return SCIP_OKAY;
143 
144  assert(heurdata->nlpi != NULL);
145  assert(heurdata->var2idx != NULL);
146 
147  SCIPhashmapFree(&heurdata->var2idx);
148  SCIP_CALL( SCIPnlpiFreeProblem(heurdata->nlpi, &heurdata->nlpiprob) );
149 
150  return SCIP_OKAY;
151 }
152 
153 /** add or updates the regularization constraints to the NLP; for a given parameter theta we add for each non-fixed
154  * binary variable z the constraint z*(1-z) <= theta; if these constraint are already present we update the theta on
155  * the right-hand side
156  */
157 static
159  SCIP* scip, /**< SCIP data structure */
160  SCIP_HEURDATA* heurdata, /**< heuristic data */
161  SCIP_VAR** binvars, /**< array containing all non-fixed binary variables */
162  int nbinvars, /**< total number of non-fixed binary variables */
163  SCIP_Real theta, /**< regularization parameter */
164  SCIP_Bool update /**< should the regularization constraints be added or updated? */
165  )
166 {
167  int i;
168 
169  assert(binvars != NULL);
170  assert(nbinvars > 0);
171 
172  /* add or update regularization for each non-fixed binary variables */
173  if( !update )
174  {
175  SCIP_QUADELEM* quadelems;
176  SCIP_Real* linvals;
177  int* lininds;
178 
179  SCIP_CALL( SCIPallocBufferArray(scip, &quadelems, 1) );
180  SCIP_CALL( SCIPallocBufferArray(scip, &lininds, 1) );
181  SCIP_CALL( SCIPallocBufferArray(scip, &linvals, 1) );
182 
183  for( i = 0; i < nbinvars; ++i )
184  {
185  SCIP_VAR* var = binvars[i];
186  SCIP_Real lhs = -SCIPinfinity(scip);
187  SCIP_Real rhs = theta;
188  int nlininds = 1;
189  int nquadelems = 1;
190  int idx;
191 
192  assert(var != NULL);
193  assert(heurdata->var2idx != NULL);
194  assert(SCIPhashmapExists(heurdata->var2idx, (void*)var));
195  idx = (int)(size_t)SCIPhashmapGetImage(heurdata->var2idx, (void*)var);
196 
197  lininds[0] = idx;
198  linvals[0] = 1.0;
199  quadelems->idx1 = lininds[0];
200  quadelems->idx2 = lininds[0];
201  quadelems->coef = -1.0;
202 
203  SCIP_CALL( SCIPnlpiAddConstraints(heurdata->nlpi, heurdata->nlpiprob, 1, &lhs, &rhs, &nlininds,
204  &lininds, &linvals, &nquadelems, &quadelems, NULL, NULL, NULL) );
205  }
206 
207  SCIPfreeBufferArray(scip, &linvals);
208  SCIPfreeBufferArray(scip, &lininds);
209  SCIPfreeBufferArray(scip, &quadelems);
210  }
211  else
212  {
213  int startidx = SCIPgetNNLPNlRows(scip) + 1; /* the cutoff is a separate constraint */
214  SCIP_Real* lhss;
215  SCIP_Real* rhss;
216  int* indices;
217 
218  SCIP_CALL( SCIPallocBufferArray(scip, &lhss, nbinvars) );
219  SCIP_CALL( SCIPallocBufferArray(scip, &rhss, nbinvars) );
220  SCIP_CALL( SCIPallocBufferArray(scip, &indices, nbinvars) );
221 
222  for( i = 0; i < nbinvars; ++i )
223  {
224  lhss[i] = -SCIPinfinity(scip);
225  rhss[i] = theta;
226  indices[i] = startidx + i;
227  }
228 
229  SCIP_CALL( SCIPnlpiChgConsSides(heurdata->nlpi, heurdata->nlpiprob, nbinvars, indices, lhss, rhss) );
230 
231  SCIPfreeBufferArray(scip, &indices);
232  SCIPfreeBufferArray(scip, &rhss);
233  SCIPfreeBufferArray(scip, &lhss);
234  }
235 
236  return SCIP_OKAY;
237 }
238 
239 /** recursive helper function to count the number of nodes in a sub-tree */
240 static
242  SCIP_EXPR* expr /**< expression */
243  )
244 {
245  int sum;
246  int i;
247 
248  assert(expr != NULL);
249 
250  sum = 0;
251  for( i = 0; i < SCIPexprGetNChildren(expr); ++i )
252  {
253  SCIP_EXPR* child = SCIPexprGetChildren(expr)[i];
254  sum += getExprSize(child);
255  }
256  return 1 + sum;
257 }
258 
259 /** returns the number of nodes in an expression tree */
260 static
262  SCIP_EXPRTREE* tree /**< expression tree */
263  )
264 {
265  if( tree == NULL )
266  return 0;
267  return getExprSize(SCIPexprtreeGetRoot(tree));
268 }
269 
270 /** returns the available time limit that is left */
271 static
273  SCIP* scip, /**< SCIP data structure */
274  SCIP_Real* timeleft /**< pointer to store the remaining time limit */
275  )
276 {
277  SCIP_Real timelim;
278 
279  assert(timeleft != NULL);
280 
281  SCIP_CALL( SCIPgetRealParam(scip, "limits/time", &timelim) );
282 
283  if( SCIPisInfinity(scip, timelim) )
284  *timeleft = timelim - SCIPgetSolvingTime(scip);
285  else
286  *timeleft = SCIPinfinity(scip);
287 
288  return SCIP_OKAY;
289 }
290 
291 /** main execution function of the MPEC heuristic */
292 static
294  SCIP* scip, /**< SCIP data structure */
295  SCIP_HEUR* heur, /**< MPEC heuristic */
296  SCIP_HEURDATA* heurdata, /**< heuristic data */
297  SCIP_RESULT* result /**< pointer to store the result */
298  )
299 {
300  SCIP_NLPSTATISTICS* nlpstatistics = NULL;
301  SCIP_VAR** binvars = NULL;
302  SCIP_Real* initguess = NULL;
303  SCIP_Real* ubs = NULL;
304  SCIP_Real* lbs = NULL;
305  int* indices = NULL;
306  SCIP_Real theta = heurdata->inittheta;
307  SCIP_Real nlpcostperiter = 0.0;
308  SCIP_Real nlpcostleft = heurdata->maxnlpcost;
309  SCIP_Bool reinit = TRUE;
310  SCIP_Bool fixed = FALSE;
311  SCIP_Bool subnlpcalled = FALSE;
312  int nbinvars = 0;
313  int i;
314 
315  assert(heurdata->nlpiprob != NULL);
316  assert(heurdata->var2idx != NULL);
317  assert(heurdata->nlpi != NULL);
318  assert(result != NULL);
319 
320  SCIP_CALL( SCIPallocBufferArray(scip, &binvars, SCIPgetNBinVars(scip)) );
321  SCIP_CALL( SCIPnlpStatisticsCreate(SCIPblkmem(scip), &nlpstatistics) );
322 
323  /* collect all non-fixed binary variables */
324  for( i = 0; i < SCIPgetNBinVars(scip); ++i )
325  {
326  SCIP_VAR* var = SCIPgetVars(scip)[i];
327  assert(SCIPvarGetType(var) == SCIP_VARTYPE_BINARY);
328 
329  if( !SCIPisFeasEQ(scip, SCIPvarGetLbLocal(var), SCIPvarGetUbLocal(var)) )
330  binvars[nbinvars++] = var;
331  }
332 
333  /* all binary variables are fixed */
334  SCIPdebugMsg(scip, "nbinvars %d\n", nbinvars);
335  if( nbinvars == 0 )
336  goto TERMINATE;
337 
338  SCIP_CALL( SCIPallocBufferArray(scip, &initguess, SCIPgetNVars(scip)) );
339  SCIP_CALL( SCIPallocBufferArray(scip, &lbs, nbinvars) );
340  SCIP_CALL( SCIPallocBufferArray(scip, &ubs, nbinvars) );
341  SCIP_CALL( SCIPallocBufferArray(scip, &indices, nbinvars) );
342 
343  /* compute estimate cost for each NLP iteration */
344  for( i = 0; i < SCIPgetNNLPNlRows(scip); ++i )
345  {
346  SCIP_NLROW* nlrow = SCIPgetNLPNlRows(scip)[i];
347  assert(nlrow != NULL);
348 
349  nlpcostperiter += 1.0 * SCIPnlrowGetNLinearVars(nlrow)
350  + 2.0 * SCIPnlrowGetNQuadElems(nlrow)
351  + 3.0 * getExprtreeSize(SCIPnlrowGetExprtree(nlrow));
352  }
353 
354  /* set initial guess */
355  for( i = 0; i < SCIPgetNVars(scip); ++i )
356  {
357  SCIP_VAR* var = SCIPgetVars(scip)[i];
358  initguess[i] = SCIPgetSolVal(scip, NULL, var);
359  /* SCIPdebugMsg(scip, "set initial value for %s to %g\n", SCIPvarGetName(var), initguess[i]); */
360  }
361  SCIP_CALL( SCIPnlpiSetInitialGuess(heurdata->nlpi, heurdata->nlpiprob, initguess, NULL, NULL, NULL) );
362 
363  /* set parameters of NLP solver */
364  SCIP_CALL( SCIPnlpiSetRealPar(heurdata->nlpi, heurdata->nlpiprob, SCIP_NLPPAR_FEASTOL,
365  SCIPfeastol(scip) / 10.0) );
366  SCIP_CALL( SCIPnlpiSetRealPar(heurdata->nlpi, heurdata->nlpiprob, SCIP_NLPPAR_RELOBJTOL,
367  SCIPdualfeastol(scip) / 10.0) );
368  SCIP_CALL( SCIPnlpiSetIntPar(heurdata->nlpi, heurdata->nlpiprob, SCIP_NLPPAR_VERBLEVEL, 0) );
369 
370  /* main loop */
371  for( i = 0; i < heurdata->maxiter && *result != SCIP_FOUNDSOL && nlpcostleft > 0.0 && !SCIPisStopped(scip); ++i )
372  {
373  SCIP_Real* primal = NULL;
374  SCIP_Real timeleft = SCIPinfinity(scip);
375  SCIP_Bool binaryfeasible;
376  SCIP_Bool regularfeasible;
377  SCIP_NLPSOLSTAT solstat;
378  SCIP_Real maxviolbin = 0.0;
379  SCIP_Real maxviolreg = 0.0;
380  int j;
381 
382  /* add or update regularization */
383  SCIP_CALL( addRegularScholtes(scip, heurdata, binvars, nbinvars, theta, i > 0) );
384 
385  /* set working limits */
386  SCIP_CALL( getTimeLeft(scip, &timeleft) );
387  if( timeleft <= 0.0 )
388  {
389  SCIPdebugMsg(scip, "skip NLP solve; no time left\n");
390  break;
391  }
392 
393  SCIP_CALL( SCIPnlpiSetRealPar(heurdata->nlpi, heurdata->nlpiprob, SCIP_NLPPAR_TILIM, timeleft) );
394  SCIP_CALL( SCIPnlpiSetIntPar(heurdata->nlpi, heurdata->nlpiprob, SCIP_NLPPAR_ITLIM, heurdata->maxnlpiter) );
395 
396  /* solve NLP */
397  SCIP_CALL( SCIPnlpiSolve(heurdata->nlpi, heurdata->nlpiprob) );
398  solstat = SCIPnlpiGetSolstat(heurdata->nlpi, heurdata->nlpiprob);
399 
400  /* give up if an error occurred or no primal values are accessible */
401  if( solstat > SCIP_NLPSOLSTAT_LOCINFEASIBLE )
402  {
403  SCIPdebugMsg(scip, "error occured during NLP solve -> stop!\n");
404  break;
405  }
406 
407  /* update nlpcostleft */
408  SCIP_CALL( SCIPnlpiGetStatistics(heurdata->nlpi, heurdata->nlpiprob, nlpstatistics) );
409  nlpcostleft -= SCIPnlpStatisticsGetNIterations(nlpstatistics) * nlpcostperiter * nbinvars;
410  SCIPdebugMsg(scip, "nlpcostleft = %e\n", nlpcostleft);
411 
412  SCIP_CALL( SCIPnlpiGetSolution(heurdata->nlpi, heurdata->nlpiprob, &primal, NULL, NULL, NULL, NULL) );
413  assert(primal != NULL);
414 
415  /* check for binary feasibility */
416  binaryfeasible = TRUE;
417  regularfeasible = TRUE;
418  for( j = 0; j < nbinvars; ++j )
419  {
420  int idx = (int)(size_t)SCIPhashmapGetImage(heurdata->var2idx, (void*)binvars[j]);
421  binaryfeasible = binaryfeasible && SCIPisFeasIntegral(scip, primal[idx]);
422  regularfeasible = regularfeasible && SCIPisLE(scip, primal[idx] - SQR(primal[idx]), theta);
423 
424  maxviolreg = MAX(maxviolreg, primal[idx] - SQR(primal[idx]) - theta);
425  maxviolbin = MAX(maxviolbin, MIN(primal[idx], 1.0-primal[idx]));
426  }
427  SCIPdebugMsg(scip, "maxviol-regularization %g maxviol-integrality %g\n", maxviolreg, maxviolbin);
428 
429  /* call sub-NLP heuristic when the maximum binary infeasibility is small enough (or this is the last iteration
430  * because we reached the nlpcost limit)
431  */
432  if( !subnlpcalled && heurdata->subnlp != NULL
433  && (SCIPisLE(scip, maxviolbin, heurdata->subnlptrigger) || nlpcostleft <= 0.0)
434  && !SCIPisStopped(scip) )
435  {
436  SCIP_SOL* refpoint;
437  SCIP_RESULT subnlpresult;
438 
439  SCIPdebugMsg(scip, "call sub-NLP heuristic because binary infeasibility is small enough\n");
440  SCIP_CALL( SCIPcreateSol(scip, &refpoint, heur) );
441 
442  for( j = 0; j < SCIPgetNVars(scip); ++j )
443  {
444  SCIP_VAR* var = SCIPgetVars(scip)[j];
445  SCIP_Real val = SCIPvarIsBinary(var) ? SCIPfeasRound(scip, primal[j]) : primal[j];
446  SCIP_CALL( SCIPsetSolVal(scip, refpoint, var, val) );
447  }
448 
449  SCIP_CALL( getTimeLeft(scip, &timeleft) );
450  SCIP_CALL( SCIPapplyHeurSubNlp(scip, heurdata->subnlp, &subnlpresult, refpoint, -1LL, timeleft,
451  heurdata->minimprove, NULL,
452  NULL) );
453  SCIP_CALL( SCIPfreeSol(scip, &refpoint) );
454  SCIPdebugMsg(scip, "result of sub-NLP call: %d\n", subnlpresult);
455 
456  /* stop MPEC heuristic when the sub-NLP heuristic has found a feasible solution */
457  if( subnlpresult == SCIP_FOUNDSOL )
458  {
459  SCIPdebugMsg(scip, "sub-NLP found a feasible solution -> stop!\n");
460  break;
461  }
462 
463  subnlpcalled = TRUE;
464  }
465 
466  /* NLP feasible + binary feasible -> add solution and stop */
467  if( solstat <= SCIP_NLPSOLSTAT_FEASIBLE && binaryfeasible )
468  {
469  SCIP_SOL* sol;
470  SCIP_Bool stored;
471 
472  SCIP_CALL( SCIPcreateSol(scip, &sol, heur) );
473 
474  for( j = 0; j < SCIPgetNVars(scip); ++j )
475  {
476  SCIP_VAR* var = SCIPgetVars(scip)[j];
477  assert(j == (int)(size_t)SCIPhashmapGetImage(heurdata->var2idx, (void*)var));
478  SCIP_CALL( SCIPsetSolVal(scip, sol, var, primal[j]) );
479  }
480 
481 #ifdef SCIP_DEBUG
482  SCIP_CALL( SCIPtrySolFree(scip, &sol, TRUE, TRUE, TRUE, TRUE, FALSE, &stored) );
483 #else
484  SCIP_CALL( SCIPtrySolFree(scip, &sol, FALSE, FALSE, TRUE, TRUE, FALSE, &stored) );
485 #endif
486  SCIPdebugMsg(scip, "found a solution (stored = %u)\n", stored);
487 
488  if( stored )
489  *result = SCIP_FOUNDSOL;
490  break;
491  }
492 
493  /* NLP feasible + binary infeasible -> reduce theta */
494  else if( solstat <= SCIP_NLPSOLSTAT_FEASIBLE && !binaryfeasible )
495  {
496  BMScopyMemoryArray(initguess, primal, SCIPgetNVars(scip));
497  SCIP_CALL( SCIPnlpiSetInitialGuess(heurdata->nlpi, heurdata->nlpiprob, primal, NULL, NULL, NULL) );
498  SCIPdebugMsg(scip, "update theta from %g -> %g\n", theta, theta*heurdata->sigma);
499 
500  if( !reinit )
501  {
502  SCIPdebugMsg(scip, "reinit fixed the infeasibility\n");
503  reinit = TRUE;
504  }
505 
506  theta *= heurdata->sigma;
507 
508  /* unfix binary variables */
509  if( fixed )
510  {
511  SCIPdebugMsg(scip, "unfixing binary variables\n");
512  for( j = 0; j < nbinvars; ++j )
513  {
514  lbs[j] = 0.0;
515  ubs[j] = 1.0;
516  indices[j] = (int)(size_t)SCIPhashmapGetImage(heurdata->var2idx, (void*)binvars[j]);
517  }
518  SCIP_CALL( SCIPnlpiChgVarBounds(heurdata->nlpi, heurdata->nlpiprob, nbinvars, indices, lbs, ubs) );
519  fixed = FALSE;
520  }
521  }
522 
523  /* NLP infeasible + regularization feasible -> stop (give up) */
524  else if( solstat > SCIP_NLPSOLSTAT_FEASIBLE && regularfeasible )
525  {
526  SCIPdebugMsg(scip, "NLP is infeasible but regularization constraints are satisfied -> stop!\n");
527  break;
528  }
529 
530  /* NLP infeasible + binary infeasible -> set initial point / fix binary variables */
531  else
532  {
533  assert(solstat > SCIP_NLPSOLSTAT_FEASIBLE && !regularfeasible);
534 
535  SCIPdebugMsg(scip, "NLP solution is not feasible for the NLP and the binary variables\n");
536 
537  /* stop if fixing did not resolve the infeasibility */
538  if( fixed )
539  {
540  SCIPdebugMsg(scip, "fixing variables did not resolve infeasibility -> stop!\n");
541  break;
542  }
543 
544  /* fix variables if reinit is FALSE; otherwise set another initial point */
545  if( !reinit )
546  {
547  int nfixedvars = 0;
548 
549  /* fix binary variables */
550  for( j = 0; j < nbinvars; ++j )
551  {
552  int idx = (int)(size_t)SCIPhashmapGetImage(heurdata->var2idx, (void*)binvars[j]);
553  indices[j] = idx;
554 
555  if( SCIPisFeasLE(scip, primal[idx] - SQR(primal[idx]), theta) )
556  {
557  lbs[j] = 0.0;
558  ubs[j] = 1.0;
559  }
560  else
561  {
562  lbs[j] = primal[idx] >= 0.5 ? 0.0 : 1.0;
563  ubs[j] = primal[idx] >= 0.5 ? 0.0 : 1.0;
564  ++nfixedvars;
565  /* SCIPdebugMsg(scip, "fix binary variable %s = %g\n", SCIPvarGetName(binvars[j]), ubs[j]); */
566  }
567  }
568  SCIPdebugMsg(scip, "fixed %d binary variables\n", nfixedvars);
569  SCIP_CALL( SCIPnlpiChgVarBounds(heurdata->nlpi, heurdata->nlpiprob, nbinvars, indices, lbs, ubs) );
570  fixed = TRUE;
571  }
572  else
573  {
574  SCIPdebugMsg(scip, "update initial guess\n");
575 
576  /* set initial point */
577  for( j = 0; j < nbinvars; ++j )
578  {
579  int idx = (int)(size_t)SCIPhashmapGetImage(heurdata->var2idx, (void*)binvars[j]);
580  initguess[idx] = primal[idx] >= 0.5 ? 0.0 : 1.0;
581  /* SCIPdebugMsg(scip, "update init guess for %s to %g\n", SCIPvarGetName(binvars[j]), initguess[idx]); */
582  }
583  SCIP_CALL( SCIPnlpiSetInitialGuess(heurdata->nlpi, heurdata->nlpiprob, initguess, NULL, NULL, NULL) );
584  reinit = FALSE;
585  }
586  }
587  }
588 
589 TERMINATE:
590  SCIPfreeBufferArrayNull(scip, &indices);
591  SCIPfreeBufferArrayNull(scip, &ubs);
592  SCIPfreeBufferArrayNull(scip, &lbs);
593  SCIPfreeBufferArrayNull(scip, &initguess);
594  SCIPnlpStatisticsFree(SCIPblkmem(scip), &nlpstatistics);
595  SCIPfreeBufferArray(scip, &binvars);
596 
597  return SCIP_OKAY;
598 }
599 
600 
601 /*
602  * Callback methods of primal heuristic
603  */
604 
605 /** copy method for primal heuristic plugins (called when SCIP copies plugins) */
606 static
607 SCIP_DECL_HEURCOPY(heurCopyMpec)
608 { /*lint --e{715}*/
609  assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
610 
611  /* call inclusion method of primal heuristic */
613 
614  return SCIP_OKAY;
615 }
616 
617 /** destructor of primal heuristic to free user data (called when SCIP is exiting) */
618 static
619 SCIP_DECL_HEURFREE(heurFreeMpec)
620 { /*lint --e{715}*/
621  SCIP_HEURDATA* heurdata = SCIPheurGetData(heur);
622  assert(heurdata != NULL);
623 
624  SCIPfreeBlockMemory(scip, &heurdata);
625  SCIPheurSetData(heur, NULL);
626 
627  return SCIP_OKAY;
628 }
629 
630 /** solving process initialization method of primal heuristic (called when branch and bound process is about to begin) */
631 static
632 SCIP_DECL_HEURINITSOL(heurInitsolMpec)
633 { /*lint --e{715}*/
634  SCIP_HEURDATA* heurdata = SCIPheurGetData(heur);
635 
636  assert(heurdata != NULL);
637  assert(heurdata->nlpi == NULL);
638 
639  if( SCIPgetNNlpis(scip) > 0 )
640  {
641  heurdata->nlpi = SCIPgetNlpis(scip)[0];
642  heurdata->subnlp = SCIPfindHeur(scip, "subnlp");
643  }
644 
645  return SCIP_OKAY;
646 }
647 
648 
649 /** solving process deinitialization method of primal heuristic (called before branch and bound process data is freed) */
650 static
651 SCIP_DECL_HEUREXITSOL(heurExitsolMpec)
652 { /*lint --e{715}*/
653  SCIP_HEURDATA* heurdata = SCIPheurGetData(heur);
654 
655  assert(heurdata != NULL);
656  heurdata->nlpi = NULL;
657 
658  return SCIP_OKAY;
659 }
660 
661 /** execution method of primal heuristic */
662 static
663 SCIP_DECL_HEUREXEC(heurExecMpec)
664 { /*lint --e{715}*/
665  SCIP_HEURDATA* heurdata = SCIPheurGetData(heur);
666  SCIP_CONSHDLR* andhdlr = SCIPfindConshdlr(scip, "and");
667  SCIP_CONSHDLR* sosonehdlr = SCIPfindConshdlr(scip, "SOS1");
668  SCIP_CONSHDLR* sostwohdlr = SCIPfindConshdlr(scip, "SOS2");
669 
670  assert(heurdata != NULL);
671 
672  *result = SCIP_DIDNOTRUN;
673 
674  if( SCIPgetNIntVars(scip) > 0 || SCIPgetNBinVars(scip) == 0
675  || heurdata->nlpi == NULL || !SCIPisNLPConstructed(scip)
676  || heurdata->mingapleft > SCIPgetGap(scip)
677  || heurdata->nunsucc > heurdata->maxnunsucc )
678  return SCIP_OKAY;
679 
680  /* skip heuristic if constraints without a nonlinear representation are present */
681  if( (andhdlr != NULL && SCIPconshdlrGetNConss(andhdlr) > 0) ||
682  (sosonehdlr != NULL && SCIPconshdlrGetNConss(sosonehdlr) > 0) ||
683  (sostwohdlr != NULL && SCIPconshdlrGetNConss(sostwohdlr) > 0) )
684  {
685  return SCIP_OKAY;
686  }
687 
688  *result = SCIP_DIDNOTFIND;
689 
690  /* call MPEC method */
691  SCIP_CALL( createNLP(scip, heurdata) );
692  SCIP_CALL( heurExec(scip, heur, heurdata, result) );
693  SCIP_CALL( freeNLP(scip, heurdata) );
694 
695  /* update number of unsuccessful calls */
696  heurdata->nunsucc = (*result == SCIP_FOUNDSOL) ? 0 : heurdata->nunsucc + 1;
697 
698  return SCIP_OKAY;
699 }
700 
701 
702 /*
703  * primal heuristic specific interface methods
704  */
705 
706 /** creates the mpec primal heuristic and includes it in SCIP */
708  SCIP* scip /**< SCIP data structure */
709  )
710 {
711  SCIP_HEURDATA* heurdata = NULL;
712  SCIP_HEUR* heur = NULL;
713 
714  /* create mpec primal heuristic data */
715  SCIP_CALL( SCIPallocBlockMemory(scip, &heurdata) );
716  BMSclearMemory(heurdata);
717 
718  /* include primal heuristic */
719  SCIP_CALL( SCIPincludeHeurBasic(scip, &heur,
721  HEUR_MAXDEPTH, HEUR_TIMING, HEUR_USESSUBSCIP, heurExecMpec, heurdata) );
722 
723  assert(heur != NULL);
724 
725  /* set non fundamental callbacks via setter functions */
726  SCIP_CALL( SCIPsetHeurCopy(scip, heur, heurCopyMpec) );
727  SCIP_CALL( SCIPsetHeurFree(scip, heur, heurFreeMpec) );
728  SCIP_CALL( SCIPsetHeurInitsol(scip, heur, heurInitsolMpec) );
729  SCIP_CALL( SCIPsetHeurExitsol(scip, heur, heurExitsolMpec) );
730 
731  /* add mpec primal heuristic parameters */
732  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/inittheta",
733  "initial regularization right-hand side value",
734  &heurdata->inittheta, FALSE, DEFAULT_INITTHETA, 0.0, 0.25, NULL, NULL) );
735 
736  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/sigma",
737  "regularization update factor",
738  &heurdata->sigma, FALSE, DEFAULT_SIGMA, 0.0, 1.0, NULL, NULL) );
739 
740  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/subnlptrigger",
741  "maximum number of NLP iterations per solve",
742  &heurdata->subnlptrigger, FALSE, DEFAULT_SUBNLPTRIGGER, 0.0, 1.0, NULL, NULL) );
743 
744  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/maxnlpcost",
745  "maximum cost available for solving NLPs per call of the heuristic",
746  &heurdata->maxnlpcost, FALSE, DEFAULT_MAXNLPCOST, 0.0, SCIPinfinity(scip), NULL, NULL) );
747 
748  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/minimprove",
749  "factor by which heuristic should at least improve the incumbent",
750  &heurdata->minimprove, FALSE, DEFAULT_MINIMPROVE, 0.0, 1.0, NULL, NULL) );
751 
752  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/mingapleft",
753  "minimum amount of gap left in order to call the heuristic",
754  &heurdata->mingapleft, FALSE, DEFAULT_MINGAPLEFT, 0.0, SCIPinfinity(scip), NULL, NULL) );
755 
756  SCIP_CALL( SCIPaddIntParam(scip, "heuristics/" HEUR_NAME "/maxiter",
757  "maximum number of iterations of the MPEC loop",
758  &heurdata->maxiter, FALSE, DEFAULT_MAXITER, 0, INT_MAX, NULL, NULL) );
759 
760  SCIP_CALL( SCIPaddIntParam(scip, "heuristics/" HEUR_NAME "/maxnlpiter",
761  "maximum number of NLP iterations per solve",
762  &heurdata->maxnlpiter, FALSE, DEFAULT_MAXNLPITER, 0, INT_MAX, NULL, NULL) );
763 
764  SCIP_CALL( SCIPaddIntParam(scip, "heuristics/" HEUR_NAME "/maxnunsucc",
765  "maximum number of consecutive calls for which the heuristic did not find an improving solution",
766  &heurdata->maxnunsucc, FALSE, DEFAULT_MAXNUNSUCC, 0, INT_MAX, NULL, NULL) );
767 
768  return SCIP_OKAY;
769 }
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:52
SCIP_RETCODE SCIPsetHeurExitsol(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEUREXITSOL((*heurexitsol)))
Definition: scip.c:8209
SCIP_RETCODE SCIPincludeHeurMpec(SCIP *scip)
Definition: heur_mpec.c:707
int SCIPgetNIntVars(SCIP *scip)
Definition: scip.c:11902
static SCIP_RETCODE heurExec(SCIP *scip, SCIP_HEUR *heur, SCIP_HEURDATA *heurdata, SCIP_RESULT *result)
Definition: heur_mpec.c:293
#define HEUR_FREQ
Definition: heur_mpec.c:36
int SCIPgetNNLPNlRows(SCIP *scip)
Definition: scip.c:31462
SCIP_Real SCIPgetSolvingTime(SCIP *scip)
Definition: scip.c:46306
mpec primal heuristic
SCIP_RETCODE SCIPnlpiGetStatistics(SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM *problem, SCIP_NLPSTATISTICS *statistics)
Definition: nlpi.c:556
SCIP_Real SCIPfeastol(SCIP *scip)
Definition: scip.c:46443
SCIP_Bool SCIPisNLPConstructed(SCIP *scip)
Definition: scip.c:31233
static SCIP_DECL_HEURFREE(heurFreeMpec)
Definition: heur_mpec.c:619
SCIP_Bool SCIPisFeasEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip.c:47298
SCIP_CONSHDLR * SCIPfindConshdlr(SCIP *scip, const char *name)
Definition: scip.c:6604
SCIP_RETCODE SCIPcreateNlpiProb(SCIP *scip, SCIP_NLPI *nlpi, SCIP_NLROW **nlrows, int nnlrows, SCIP_NLPIPROBLEM *nlpiprob, SCIP_HASHMAP *var2idx, SCIP_Real *nlscore, SCIP_Real cutoffbound, SCIP_Bool setobj, SCIP_Bool onlyconvex)
Definition: scip.c:34032
SCIP_RETCODE SCIPgetRealParam(SCIP *scip, const char *name, SCIP_Real *value)
Definition: scip.c:4489
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
Definition: var.c:17332
internal methods for NLPI solver interfaces
SCIP_RETCODE SCIPnlpiCreateProblem(SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM **problem, const char *name)
Definition: nlpi.c:211
SCIP_Real SCIPfeasRound(SCIP *scip, SCIP_Real val)
Definition: scip.c:47447
SCIP_Bool SCIPvarIsBinary(SCIP_VAR *var)
Definition: var.c:16842
SCIP_RETCODE SCIPnlpiGetSolution(SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM *problem, SCIP_Real **primalvalues, SCIP_Real **consdualvalues, SCIP_Real **varlbdualvalues, SCIP_Real **varubdualvalues, SCIP_Real *objval)
Definition: nlpi.c:537
SCIP_Real SCIPdualfeastol(SCIP *scip)
Definition: scip.c:46471
#define DEFAULT_SUBNLPTRIGGER
Definition: heur_mpec.c:47
#define FALSE
Definition: def.h:64
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
Definition: misc.c:2793
SCIP_RETCODE SCIPnlpiAddConstraints(SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM *problem, int nconss, const SCIP_Real *lhss, const SCIP_Real *rhss, const int *nlininds, int *const *lininds, SCIP_Real *const *linvals, const int *nquadelems, SCIP_QUADELEM *const *quadelems, int *const *exprvaridxs, SCIP_EXPRTREE *const *exprtrees, const char **names)
Definition: nlpi.c:268
static SCIP_RETCODE createNLP(SCIP *scip, SCIP_HEURDATA *heurdata)
Definition: heur_mpec.c:85
#define DEFAULT_MAXNLPITER
Definition: heur_mpec.c:45
SCIP_Real SCIPinfinity(SCIP *scip)
Definition: scip.c:47028
#define HEUR_USESSUBSCIP
Definition: heur_mpec.c:40
#define TRUE
Definition: def.h:63
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
#define DEFAULT_MAXNLPCOST
Definition: heur_mpec.c:48
int SCIPnlrowGetNLinearVars(SCIP_NLROW *nlrow)
Definition: nlp.c:3245
struct SCIP_HeurData SCIP_HEURDATA
Definition: type_heur.h:51
#define SCIPfreeBlockMemory(scip, ptr)
Definition: scip.h:22602
SCIP_RETCODE SCIPincludeHeurBasic(SCIP *scip, SCIP_HEUR **heur, const char *name, const char *desc, char dispchar, int priority, int freq, int freqofs, int maxdepth, SCIP_HEURTIMING timingmask, SCIP_Bool usessubscip, SCIP_DECL_HEUREXEC((*heurexec)), SCIP_HEURDATA *heurdata)
Definition: scip.c:8084
SCIP_RETCODE SCIPnlpiChgVarBounds(SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM *problem, int nvars, const int *indices, const SCIP_Real *lbs, const SCIP_Real *ubs)
Definition: nlpi.c:325
void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin)
Definition: misc.c:2931
void SCIPnlpStatisticsFree(BMS_BLKMEM *blkmem, SCIP_NLPSTATISTICS **statistics)
Definition: nlpi.c:801
#define SCIPfreeBufferArray(scip, ptr)
Definition: scip.h:22632
void SCIPheurSetData(SCIP_HEUR *heur, SCIP_HEURDATA *heurdata)
Definition: heur.c:1119
#define SCIPallocBlockMemory(scip, ptr)
Definition: scip.h:22585
#define DEFAULT_MAXNUNSUCC
Definition: heur_mpec.c:50
#define SCIPdebugMsg
Definition: scip.h:455
SCIP_RETCODE SCIPaddIntParam(SCIP *scip, const char *name, const char *desc, int *valueptr, SCIP_Bool isadvanced, int defaultvalue, int minvalue, int maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip.c:4265
#define DEFAULT_MINGAPLEFT
Definition: heur_mpec.c:46
SCIP_NLROW ** SCIPgetNLPNlRows(SCIP *scip)
Definition: scip.c:31440
#define HEUR_DESC
Definition: heur_mpec.c:33
#define DEFAULT_MAXITER
Definition: heur_mpec.c:44
int SCIPnlrowGetNQuadElems(SCIP_NLROW *nlrow)
Definition: nlp.c:3322
static SCIP_DECL_HEUREXITSOL(heurExitsolMpec)
Definition: heur_mpec.c:651
SCIP_Bool SCIPhashmapExists(SCIP_HASHMAP *hashmap, void *origin)
Definition: misc.c:3025
SCIP_RETCODE SCIPnlpiSolve(SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM *problem)
Definition: nlpi.c:497
SCIP_Real coef
Definition: type_expr.h:102
SCIP_RETCODE SCIPsetHeurInitsol(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURINITSOL((*heurinitsol)))
Definition: scip.c:8193
static SCIP_RETCODE getTimeLeft(SCIP *scip, SCIP_Real *timeleft)
Definition: heur_mpec.c:272
const char * SCIPheurGetName(SCIP_HEUR *heur)
Definition: heur.c:1198
SCIP_HEUR * SCIPfindHeur(SCIP *scip, const char *name)
Definition: scip.c:8225
static int getExprtreeSize(SCIP_EXPRTREE *tree)
Definition: heur_mpec.c:261
SCIP_RETCODE SCIPsetHeurFree(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURFREE((*heurfree)))
Definition: scip.c:8145
enum SCIP_NlpSolStat SCIP_NLPSOLSTAT
Definition: type_nlpi.h:69
#define SCIPfreeBufferArrayNull(scip, ptr)
Definition: scip.h:22633
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
Definition: scip.c:46731
static SCIP_DECL_HEURCOPY(heurCopyMpec)
Definition: heur_mpec.c:607
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
Definition: misc.c:2826
int SCIPgetNNlpis(SCIP *scip)
Definition: scip.c:9602
SCIP_RETCODE SCIPnlpiChgConsSides(SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM *problem, int nconss, const int *indices, const SCIP_Real *lhss, const SCIP_Real *rhss)
Definition: nlpi.c:343
#define SCIP_CALL(x)
Definition: def.h:350
SCIP_Real SCIPgetLowerbound(SCIP *scip)
Definition: scip.c:43277
SCIP_RETCODE SCIPnlpiSetInitialGuess(SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM *problem, SCIP_Real *primalvalues, SCIP_Real *consdualvalues, SCIP_Real *varlbdualvalues, SCIP_Real *varubdualvalues)
Definition: nlpi.c:479
SCIP_Bool SCIPisFeasLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip.c:47324
static SCIP_DECL_HEUREXEC(heurExecMpec)
Definition: heur_mpec.c:663
#define HEUR_TIMING
Definition: heur_mpec.c:39
#define HEUR_PRIORITY
Definition: heur_mpec.c:35
SCIP_EXPR * SCIPexprtreeGetRoot(SCIP_EXPRTREE *tree)
Definition: expr.c:8602
SCIP_NLPSOLSTAT SCIPnlpiGetSolstat(SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM *problem)
Definition: nlpi.c:511
static SCIP_RETCODE freeNLP(SCIP *scip, SCIP_HEURDATA *heurdata)
Definition: heur_mpec.c:133
int SCIPconshdlrGetNConss(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4515
#define HEUR_MAXDEPTH
Definition: heur_mpec.c:38
#define HEUR_NAME
Definition: heur_mpec.c:32
SCIP_RETCODE SCIPnlpiFreeProblem(SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM **problem)
Definition: nlpi.c:224
#define SCIPallocBufferArray(scip, ptr, num)
Definition: scip.h:22620
SCIP_RETCODE SCIPsetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real val)
Definition: scip.c:38771
SCIP_EXPR ** SCIPexprGetChildren(SCIP_EXPR *expr)
Definition: expr.c:5713
#define SCIP_Bool
Definition: def.h:61
#define DEFAULT_INITTHETA
Definition: heur_mpec.c:42
SCIP_RETCODE SCIPnlpiSetIntPar(SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM *problem, SCIP_NLPPARAM type, int ival)
Definition: nlpi.c:636
SCIP_Real SCIPgetGap(SCIP *scip)
Definition: scip.c:43536
#define MAX(x, y)
Definition: tclique_def.h:75
SCIP_RETCODE SCIPtrySolFree(SCIP *scip, SCIP_SOL **sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
Definition: scip.c:40794
int SCIPexprGetNChildren(SCIP_EXPR *expr)
Definition: expr.c:5703
SCIP_RETCODE SCIPfreeSol(SCIP *scip, SCIP_SOL **sol)
Definition: scip.c:38535
int SCIPgetNSols(SCIP *scip)
Definition: scip.c:39783
#define BMScopyMemoryArray(ptr, source, num)
Definition: memory.h:116
SCIP_RETCODE SCIPapplyHeurSubNlp(SCIP *scip, SCIP_HEUR *heur, SCIP_RESULT *result, SCIP_SOL *refpoint, SCIP_Longint itercontingent, SCIP_Real timelimit, SCIP_Real minimprove, SCIP_Longint *iterused, SCIP_SOL *resultsol)
Definition: heur_subnlp.c:1674
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
Definition: scip.c:47039
#define BMSclearMemory(ptr)
Definition: memory.h:111
int SCIPgetNBinVars(SCIP *scip)
Definition: scip.c:11857
static int getExprSize(SCIP_EXPR *expr)
Definition: heur_mpec.c:241
int SCIPgetNVars(SCIP *scip)
Definition: scip.c:11812
SCIP_EXPRTREE * SCIPnlrowGetExprtree(SCIP_NLROW *nlrow)
Definition: nlp.c:3363
#define HEUR_DISPCHAR
Definition: heur_mpec.c:34
static SCIP_DECL_HEURINITSOL(heurInitsolMpec)
Definition: heur_mpec.c:632
#define DEFAULT_SIGMA
Definition: heur_mpec.c:43
NLP local search primal heuristic using sub-SCIPs.
SCIP_RETCODE SCIPnlpStatisticsCreate(BMS_BLKMEM *blkmem, SCIP_NLPSTATISTICS **statistics)
Definition: nlpi.c:784
#define HEUR_FREQOFS
Definition: heur_mpec.c:37
static SCIP_RETCODE addRegularScholtes(SCIP *scip, SCIP_HEURDATA *heurdata, SCIP_VAR **binvars, int nbinvars, SCIP_Real theta, SCIP_Bool update)
Definition: heur_mpec.c:158
SCIP_VAR ** SCIPgetVars(SCIP *scip)
Definition: scip.c:11767
#define SCIP_Real
Definition: def.h:149
SCIP_Bool SCIPisStopped(SCIP *scip)
Definition: scip.c:1145
int SCIPnlpStatisticsGetNIterations(SCIP_NLPSTATISTICS *statistics)
Definition: nlpi.c:816
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
Definition: var.c:16827
SCIP_Bool SCIPisLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip.c:46989
SCIP_RETCODE SCIPsetHeurCopy(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURCOPY((*heurcopy)))
Definition: scip.c:8129
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
Definition: var.c:17342
SCIP_Bool SCIPisFeasIntegral(SCIP *scip, SCIP_Real val)
Definition: scip.c:47399
SCIP_Real SCIPsumepsilon(SCIP *scip)
Definition: scip.c:46429
SCIP_NLPI ** SCIPgetNlpis(SCIP *scip)
Definition: scip.c:9589
SCIP_Real SCIPgetUpperbound(SCIP *scip)
Definition: scip.c:43426
SCIP_HEURDATA * SCIPheurGetData(SCIP_HEUR *heur)
Definition: heur.c:1109
SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
Definition: scip.c:38911
SCIP_RETCODE SCIPaddRealParam(SCIP *scip, const char *name, const char *desc, SCIP_Real *valueptr, SCIP_Bool isadvanced, SCIP_Real defaultvalue, SCIP_Real minvalue, SCIP_Real maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip.c:4321
#define DEFAULT_MINIMPROVE
Definition: heur_mpec.c:49
SCIP_RETCODE SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip.c:37878
SCIP_RETCODE SCIPnlpiSetRealPar(SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM *problem, SCIP_NLPPARAM type, SCIP_Real dval)
Definition: nlpi.c:671