Scippy

SCIP

Solving Constraint Integer Programs

heur_oneopt.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-2016 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_oneopt.c
17  * @brief improvement heuristic that alters single variable values
18  * @author Timo Berthold
19  */
20 
21 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
22 
23 #include <assert.h>
24 #include <string.h>
25 
26 #include "scip/heur_oneopt.h"
27 
28 /* @note If the heuristic runs in the root node, the timing is changed to (SCIP_HEURTIMING_DURINGLPLOOP |
29  * SCIP_HEURTIMING_BEFORENODE), see SCIP_DECL_HEURINITSOL callback.
30  */
31 
32 #define HEUR_NAME "oneopt"
33 #define HEUR_DESC "1-opt heuristic which tries to improve setting of single integer variables"
34 #define HEUR_DISPCHAR 'b'
35 #define HEUR_PRIORITY -20000
36 #define HEUR_FREQ 1
37 #define HEUR_FREQOFS 0
38 #define HEUR_MAXDEPTH -1
39 #define HEUR_TIMING SCIP_HEURTIMING_BEFOREPRESOL | SCIP_HEURTIMING_AFTERNODE
40 #define HEUR_USESSUBSCIP FALSE /**< does the heuristic use a secondary SCIP instance? */
41 
42 #define DEFAULT_WEIGHTEDOBJ TRUE /**< should the objective be weighted with the potential shifting value when sorting the shifting candidates? */
43 #define DEFAULT_DURINGROOT TRUE /**< should the heuristic be called before and during the root node? */
44 #define DEFAULT_BEFOREPRESOL FALSE /**< should the heuristic be called before presolving */
45 #define DEFAULT_FORCELPCONSTRUCTION FALSE /**< should the construction of the LP be forced even if LP solving is deactivated? */
46 
47 /*
48  * Data structures
49  */
50 
51 /** primal heuristic data */
52 struct SCIP_HeurData
53 {
54  int lastsolindex; /**< index of the last solution for which oneopt was performed */
55  SCIP_Bool weightedobj; /**< should the objective be weighted with the potential shifting value when sorting the shifting candidates? */
56  SCIP_Bool duringroot; /**< should the heuristic be called before and during the root node? */
57  SCIP_Bool forcelpconstruction;/**< should the construction of the LP be forced even if LP solving is deactivated? */
58  SCIP_Bool beforepresol; /**< should the heuristic be called before presolving */
59 };
60 
61 
62 /*
63  * Local methods
64  */
65 
66 /** creates a new solution for the original problem by copying the solution of the subproblem */
67 static
69  SCIP* scip, /**< original SCIP data structure */
70  SCIP* subscip, /**< SCIP structure of the subproblem */
71  SCIP_VAR** subvars, /**< the variables of the subproblem */
72  SCIP_HEUR* heur, /**< zeroobj heuristic structure */
73  SCIP_SOL* subsol, /**< solution of the subproblem */
74  SCIP_Bool* success /**< used to store whether new solution was found or not */
75  )
76 {
77  SCIP_VAR** vars; /* the original problem's variables */
78  int nvars; /* the original problem's number of variables */
79  SCIP_Real* subsolvals; /* solution values of the subproblem */
80  SCIP_SOL* newsol; /* solution to be created for the original problem */
81 
82  assert(scip != NULL);
83  assert(subscip != NULL);
84  assert(subvars != NULL);
85  assert(subsol != NULL);
86 
87  /* get variables' data */
88  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, NULL, NULL, NULL, NULL) );
89 
90  /* sub-SCIP may have more variables than the number of active (transformed) variables in the main SCIP
91  * since constraint copying may have required the copy of variables that are fixed in the main SCIP
92  */
93  assert(nvars <= SCIPgetNOrigVars(subscip));
94 
95  SCIP_CALL( SCIPallocBufferArray(scip, &subsolvals, nvars) );
96 
97  /* copy the solution */
98  SCIP_CALL( SCIPgetSolVals(subscip, subsol, nvars, subvars, subsolvals) );
99 
100  /* create new solution for the original problem */
101  SCIP_CALL( SCIPcreateSol(scip, &newsol, heur) );
102  SCIP_CALL( SCIPsetSolVals(scip, newsol, nvars, vars, subsolvals) );
103 
104  /* try to add new solution to scip and free it immediately */
105  SCIP_CALL( SCIPtrySolFree(scip, &newsol, FALSE, TRUE, TRUE, TRUE, success) );
106 
107  SCIPfreeBufferArray(scip, &subsolvals);
108 
109  return SCIP_OKAY;
110 }
111 
112 /** compute value by which the solution of variable @p var can be shifted */
113 static
115  SCIP* scip, /**< SCIP data structure */
116  SCIP_VAR* var, /**< variable that should be shifted */
117  SCIP_Real solval, /**< current solution value */
118  SCIP_Real* activities /**< LP row activities */
119  )
120 {
121  SCIP_Real lb;
122  SCIP_Real ub;
123  SCIP_Real obj;
124  SCIP_Real shiftval;
125 
126  SCIP_COL* col;
127  SCIP_ROW** colrows;
128  SCIP_Real* colvals;
129  SCIP_Bool shiftdown;
130 
131  int ncolrows;
132  int i;
133 
134 
135  /* get variable's solution value, global bounds and objective coefficient */
136  lb = SCIPvarGetLbGlobal(var);
137  ub = SCIPvarGetUbGlobal(var);
138  obj = SCIPvarGetObj(var);
139  shiftval = 0.0;
140  shiftdown = TRUE;
141 
142  /* determine shifting direction and maximal possible shifting w.r.t. corresponding bound */
143  if( obj > 0.0 && SCIPisFeasGE(scip, solval - 1.0, lb) )
144  shiftval = SCIPfeasFloor(scip, solval - lb);
145  else if( obj < 0.0 && SCIPisFeasLE(scip, solval + 1.0, ub) )
146  {
147  shiftval = SCIPfeasFloor(scip, ub - solval);
148  shiftdown = FALSE;
149  }
150  else
151  return 0.0;
152 
153 
154  SCIPdebugMessage("Try to shift %s variable <%s> with\n", shiftdown ? "down" : "up", SCIPvarGetName(var) );
155  SCIPdebugMessage(" lb:<%g> <= val:<%g> <= ub:<%g> and obj:<%g> by at most: <%g>\n", lb, solval, ub, obj, shiftval);
156 
157  /* get data of LP column */
158  col = SCIPvarGetCol(var);
159  colrows = SCIPcolGetRows(col);
160  colvals = SCIPcolGetVals(col);
161  ncolrows = SCIPcolGetNLPNonz(col);
162 
163  assert(ncolrows == 0 || (colrows != NULL && colvals != NULL));
164 
165  /* find minimal shift value, st. all rows stay valid */
166  for( i = 0; i < ncolrows && shiftval > 0.0; ++i )
167  {
168  SCIP_ROW* row;
169  int rowpos;
170 
171  row = colrows[i];
172  rowpos = SCIProwGetLPPos(row);
173  assert(-1 <= rowpos && rowpos < SCIPgetNLPRows(scip) );
174 
175  /* only global rows need to be valid */
176  if( rowpos >= 0 && !SCIProwIsLocal(row) )
177  {
178  SCIP_Real shiftvalrow;
179 
180  assert(SCIProwIsInLP(row));
181 
182  if( shiftdown == (colvals[i] > 0) )
183  shiftvalrow = SCIPfeasFloor(scip, (activities[rowpos] - SCIProwGetLhs(row)) / ABS(colvals[i]));
184  else
185  shiftvalrow = SCIPfeasFloor(scip, (SCIProwGetRhs(row) - activities[rowpos]) / ABS(colvals[i]));
186 #ifdef SCIP_DEBUG
187  if( shiftvalrow < shiftval )
188  {
189  SCIPdebugMessage(" -> The shift value had to be reduced to <%g>, because of row <%s>.\n",
190  shiftvalrow, SCIProwGetName(row));
191  SCIPdebugMessage(" lhs:<%g> <= act:<%g> <= rhs:<%g>, colval:<%g>\n",
192  SCIProwGetLhs(row), activities[rowpos], SCIProwGetRhs(row), colvals[i]);
193  }
194 #endif
195  shiftval = MIN(shiftval, shiftvalrow);
196  /* shiftvalrow might be negative, if we detected infeasibility -> make sure that shiftval is >= 0 */
197  shiftval = MAX(shiftval, 0.0);
198  }
199  }
200  if( shiftdown )
201  shiftval *= -1.0;
202 
203  /* we must not shift variables to infinity */
204  if( SCIPisInfinity(scip, solval + shiftval) )
205  shiftval = 0.0;
206 
207  return shiftval;
208 }
209 
210 
211 /** update row activities after a variable's solution value changed */
212 static
214  SCIP* scip, /**< SCIP data structure */
215  SCIP_Real* activities, /**< LP row activities */
216  SCIP_VAR* var, /**< variable that has been changed */
217  SCIP_Real shiftval /**< value that is added to variable */
218  )
219 {
220  SCIP_Real* colvals;
221  SCIP_ROW** colrows;
222  SCIP_COL* col;
223 
224  int ncolrows;
225  int i;
226 
227  assert(activities != NULL);
228 
229  /* get data of column associated to variable */
230  col = SCIPvarGetCol(var);
231  colrows = SCIPcolGetRows(col);
232  colvals = SCIPcolGetVals(col);
233  ncolrows = SCIPcolGetNLPNonz(col);
234  assert(ncolrows == 0 || (colrows != NULL && colvals != NULL));
235 
236  /* enumerate all rows with nonzero entry in this column */
237  for( i = 0; i < ncolrows; ++i )
238  {
239  SCIP_ROW* row;
240  int rowpos;
241 
242  row = colrows[i];
243  rowpos = SCIProwGetLPPos(row);
244  assert(-1 <= rowpos && rowpos < SCIPgetNLPRows(scip) );
245 
246  /* update row activity, only regard global rows in the LP */
247  if( rowpos >= 0 && !SCIProwIsLocal(row) )
248  {
249  activities[rowpos] += shiftval * colvals[i];
250 
251  if( SCIPisInfinity(scip, activities[rowpos]) )
252  activities[rowpos] = SCIPinfinity(scip);
253  else if( SCIPisInfinity(scip, -activities[rowpos]) )
254  activities[rowpos] = -SCIPinfinity(scip);
255  }
256  }
257 
258  return SCIP_OKAY;
259 }
260 
261 /*
262  * Callback methods of primal heuristic
263  */
264 
265 /** copy method for primal heuristic plugins (called when SCIP copies plugins) */
266 static
267 SCIP_DECL_HEURCOPY(heurCopyOneopt)
268 { /*lint --e{715}*/
269  assert(scip != NULL);
270  assert(heur != NULL);
271  assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
272 
273  /* call inclusion method of primal heuristic */
275 
276  return SCIP_OKAY;
277 }
278 
279 /** destructor of primal heuristic to free user data (called when SCIP is exiting) */
280 static
281 SCIP_DECL_HEURFREE(heurFreeOneopt)
282 { /*lint --e{715}*/
283  SCIP_HEURDATA* heurdata;
284 
285  assert(heur != NULL);
286  assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
287  assert(scip != NULL);
288 
289  /* free heuristic data */
290  heurdata = SCIPheurGetData(heur);
291  assert(heurdata != NULL);
292  SCIPfreeMemory(scip, &heurdata);
293  SCIPheurSetData(heur, NULL);
294 
295  return SCIP_OKAY;
296 }
297 
298 
299 /** solving process initialization method of primal heuristic (called when branch and bound process is about to begin) */
300 static
301 SCIP_DECL_HEURINITSOL(heurInitsolOneopt)
302 {
303  SCIP_HEURDATA* heurdata;
304 
305  assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
306 
307  /* create heuristic data */
308  heurdata = SCIPheurGetData(heur);
309  assert(heurdata != NULL);
310 
311  /* if the heuristic is called at the root node, we may want to be called during the cut-and-price loop and even before the first LP solve */
312  if( heurdata->duringroot && SCIPheurGetFreqofs(heur) == 0 )
314 
315  return SCIP_OKAY;
316 }
317 
318 /** solving process deinitialization method of primal heuristic (called before branch and bound process data is freed) */
319 static
320 SCIP_DECL_HEUREXITSOL(heurExitsolOneopt)
321 {
322  assert(heur != NULL);
323  assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
324 
325  /* reset the timing mask to its default value */
327 
328  return SCIP_OKAY;
329 }
330 
331 /** initialization method of primal heuristic (called after problem was transformed) */
332 static
333 SCIP_DECL_HEURINIT(heurInitOneopt)
334 { /*lint --e{715}*/
335  SCIP_HEURDATA* heurdata;
336 
337  assert(heur != NULL);
338  assert(scip != NULL);
339 
340  /* get heuristic data */
341  heurdata = SCIPheurGetData(heur);
342  assert(heurdata != NULL);
343 
344  /* initialize last solution index */
345  heurdata->lastsolindex = -1;
346 
347  return SCIP_OKAY;
348 }
349 
350 
351 /** execution method of primal heuristic */
352 static
353 SCIP_DECL_HEUREXEC(heurExecOneopt)
354 { /*lint --e{715}*/
355 
356  SCIP_HEURDATA* heurdata;
357  SCIP_SOL* bestsol; /* incumbent solution */
358  SCIP_SOL* worksol; /* heuristic's working solution */
359  SCIP_VAR** vars; /* SCIP variables */
360  SCIP_VAR** shiftcands; /* shiftable variables */
361  SCIP_ROW** lprows; /* SCIP LP rows */
362  SCIP_Real* activities; /* row activities for working solution */
363  SCIP_Real* shiftvals;
364 
365  SCIP_Real lb;
366  SCIP_Real ub;
367  SCIP_Bool localrows;
368  SCIP_Bool valid;
369  int nchgbound;
370  int nbinvars;
371  int nintvars;
372  int nvars;
373  int nlprows;
374  int i;
375  int nshiftcands;
376  int shiftcandssize;
377  SCIP_RETCODE retcode;
378 
379  assert(heur != NULL);
380  assert(scip != NULL);
381  assert(result != NULL);
382 
383  /* get heuristic's data */
384  heurdata = SCIPheurGetData(heur);
385  assert(heurdata != NULL);
386 
387  *result = SCIP_DELAYED;
388 
389  /* we only want to process each solution once */
390  bestsol = SCIPgetBestSol(scip);
391  if( bestsol == NULL || heurdata->lastsolindex == SCIPsolGetIndex(bestsol) )
392  return SCIP_OKAY;
393 
394  /* reset the timing mask to its default value (at the root node it could be different) */
395  if( SCIPgetNNodes(scip) > 1 )
397 
398  /* get problem variables */
399  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, &nbinvars, &nintvars, NULL, NULL) );
400  nintvars += nbinvars;
401 
402  /* do not run if there are no discrete variables */
403  if( nintvars == 0 )
404  {
405  *result = SCIP_DIDNOTRUN;
406  return SCIP_OKAY;
407  }
408 
409  if( heurtiming == SCIP_HEURTIMING_BEFOREPRESOL )
410  {
411  SCIP* subscip; /* the subproblem created by zeroobj */
412  SCIP_HASHMAP* varmapfw; /* mapping of SCIP variables to sub-SCIP variables */
413  SCIP_VAR** subvars; /* subproblem's variables */
414  SCIP_Real* subsolvals; /* solution values of the subproblem */
415 
416  SCIP_Real timelimit; /* time limit for zeroobj subproblem */
417  SCIP_Real memorylimit; /* memory limit for zeroobj subproblem */
418 
419  SCIP_SOL* startsol;
420  SCIP_SOL** subsols;
421  int nsubsols;
422 
423  if( !heurdata->beforepresol )
424  return SCIP_OKAY;
425 
426  /* check whether there is enough time and memory left */
427  timelimit = 0.0;
428  memorylimit = 0.0;
429  SCIP_CALL( SCIPgetRealParam(scip, "limits/time", &timelimit) );
430  if( !SCIPisInfinity(scip, timelimit) )
431  timelimit -= SCIPgetSolvingTime(scip);
432  SCIP_CALL( SCIPgetRealParam(scip, "limits/memory", &memorylimit) );
433 
434  /* substract the memory already used by the main SCIP and the estimated memory usage of external software */
435  if( !SCIPisInfinity(scip, memorylimit) )
436  {
437  memorylimit -= SCIPgetMemUsed(scip)/1048576.0;
438  memorylimit -= SCIPgetMemExternEstim(scip)/1048576.0;
439  }
440 
441  /* abort if no time is left or not enough memory to create a copy of SCIP, including external memory usage */
442  if( timelimit <= 0.0 || memorylimit <= 2.0*SCIPgetMemExternEstim(scip)/1048576.0 )
443  return SCIP_OKAY;
444 
445  /* initialize the subproblem */
446  SCIP_CALL( SCIPcreate(&subscip) );
447 
448  /* create the variable mapping hash map */
449  SCIP_CALL( SCIPhashmapCreate(&varmapfw, SCIPblkmem(subscip), SCIPcalcHashtableSize(5 * nvars)) );
450  SCIP_CALL( SCIPallocBufferArray(scip, &subvars, nvars) );
451 
452  /* copy complete SCIP instance */
453  valid = FALSE;
454  SCIP_CALL( SCIPcopy(scip, subscip, varmapfw, NULL, "oneopt", TRUE, FALSE, TRUE, &valid) );
455  SCIP_CALL( SCIPtransformProb(subscip) );
456 
457  /* get variable image */
458  for( i = 0; i < nvars; i++ )
459  subvars[i] = (SCIP_VAR*) SCIPhashmapGetImage(varmapfw, vars[i]);
460 
461  /* copy the solution */
462  SCIP_CALL( SCIPallocBufferArray(scip, &subsolvals, nvars) );
463  SCIP_CALL( SCIPgetSolVals(scip, bestsol, nvars, vars, subsolvals) );
464 
465  /* create start solution for the subproblem */
466  SCIP_CALL( SCIPcreateOrigSol(subscip, &startsol, NULL) );
467  SCIP_CALL( SCIPsetSolVals(subscip, startsol, nvars, subvars, subsolvals) );
468 
469  /* try to add new solution to sub-SCIP and free it immediately */
470  valid = FALSE;
471  SCIP_CALL( SCIPtrySolFree(subscip, &startsol, FALSE, FALSE, FALSE, FALSE, &valid) );
472  SCIPfreeBufferArray(scip, &subsolvals);
473  SCIPhashmapFree(&varmapfw);
474 
475  /* disable statistic timing inside sub SCIP */
476  SCIP_CALL( SCIPsetBoolParam(subscip, "timing/statistictiming", FALSE) );
477 
478  /* deactivate basically everything except oneopt in the sub-SCIP */
482  SCIP_CALL( SCIPsetLongintParam(subscip, "limits/nodes", 1LL) );
483  SCIP_CALL( SCIPsetRealParam(subscip, "limits/time", timelimit) );
484  SCIP_CALL( SCIPsetRealParam(subscip, "limits/memory", memorylimit) );
485  SCIP_CALL( SCIPsetBoolParam(subscip, "misc/catchctrlc", FALSE) );
486  SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", 0) );
487 
488  /* if necessary, some of the parameters have to be unfixed first */
489  if( SCIPisParamFixed(subscip, "lp/solvefreq") )
490  {
491  SCIPwarningMessage(scip, "unfixing parameter lp/solvefreq in subscip of oneopt heuristic\n");
492  SCIP_CALL( SCIPunfixParam(subscip, "lp/solvefreq") );
493  }
494  SCIP_CALL( SCIPsetIntParam(subscip, "lp/solvefreq", -1) );
495 
496  if( SCIPisParamFixed(subscip, "heuristics/oneopt/freq") )
497  {
498  SCIPwarningMessage(scip, "unfixing parameter heuristics/oneopt/freq in subscip of oneopt heuristic\n");
499  SCIP_CALL( SCIPunfixParam(subscip, "heuristics/oneopt/freq") );
500  }
501  SCIP_CALL( SCIPsetIntParam(subscip, "heuristics/oneopt/freq", 1) );
502 
503  if( SCIPisParamFixed(subscip, "heuristics/oneopt/forcelpconstruction") )
504  {
505  SCIPwarningMessage(scip, "unfixing parameter heuristics/oneopt/forcelpconstruction in subscip of oneopt heuristic\n");
506  SCIP_CALL( SCIPunfixParam(subscip, "heuristics/oneopt/forcelpconstruction") );
507  }
508  SCIP_CALL( SCIPsetBoolParam(subscip, "heuristics/oneopt/forcelpconstruction", TRUE) );
509 
510  /* avoid recursive call, which would lead to an endless loop */
511  if( SCIPisParamFixed(subscip, "heuristics/oneopt/beforepresol") )
512  {
513  SCIPwarningMessage(scip, "unfixing parameter heuristics/oneopt/beforepresol in subscip of oneopt heuristic\n");
514  SCIP_CALL( SCIPunfixParam(subscip, "heuristics/oneopt/beforepresol") );
515  }
516  SCIP_CALL( SCIPsetBoolParam(subscip, "heuristics/oneopt/beforepresol", FALSE) );
517 
518  if( valid )
519  {
520  retcode = SCIPsolve(subscip);
521 
522  /* errors in solving the subproblem should not kill the overall solving process;
523  * hence, the return code is caught and a warning is printed, only in debug mode, SCIP will stop.
524  */
525  if( retcode != SCIP_OKAY )
526  {
527 #ifndef NDEBUG
528  SCIP_CALL( retcode );
529 #endif
530  SCIPwarningMessage(scip, "Error while solving subproblem in zeroobj heuristic; sub-SCIP terminated with code <%d>\n",retcode);
531  }
532 
533 #ifdef SCIP_DEBUG
534  SCIP_CALL( SCIPprintStatistics(subscip, NULL) );
535 #endif
536  }
537 
538  /* check, whether a solution was found;
539  * due to numerics, it might happen that not all solutions are feasible -> try all solutions until one was accepted
540  */
541  nsubsols = SCIPgetNSols(subscip);
542  subsols = SCIPgetSols(subscip);
543  valid = FALSE;
544  for( i = 0; i < nsubsols && !valid; ++i )
545  {
546  SCIP_CALL( createNewSol(scip, subscip, subvars, heur, subsols[i], &valid) );
547  if( valid )
548  *result = SCIP_FOUNDSOL;
549  }
550 
551  /* free subproblem */
552  SCIPfreeBufferArray(scip, &subvars);
553  SCIP_CALL( SCIPfree(&subscip) );
554 
555  return SCIP_OKAY;
556  }
557 
558  /* we can only work on solutions valid in the transformed space */
559  if( SCIPsolIsOriginal(bestsol) )
560  return SCIP_OKAY;
561 
562  if( heurtiming == SCIP_HEURTIMING_BEFORENODE && (SCIPhasCurrentNodeLP(scip) || heurdata->forcelpconstruction) )
563  {
564  SCIP_Bool cutoff;
565  cutoff = FALSE;
566  SCIP_CALL( SCIPconstructLP(scip, &cutoff) );
568 
569  /* get problem variables again, SCIPconstructLP() might have added new variables */
570  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, &nbinvars, &nintvars, NULL, NULL) );
571  nintvars += nbinvars;
572  }
573 
574  /* we need an LP */
575  if( SCIPgetNLPRows(scip) == 0 )
576  return SCIP_OKAY;
577 
578  *result = SCIP_DIDNOTFIND;
579 
580  nchgbound = 0;
581 
582  /* initialize data */
583  nshiftcands = 0;
584  shiftcandssize = 8;
585  heurdata->lastsolindex = SCIPsolGetIndex(bestsol);
586  SCIP_CALL( SCIPcreateSolCopy(scip, &worksol, bestsol) );
587  SCIPsolSetHeur(worksol,heur);
588 
589  SCIPdebugMessage("Starting bound adjustment in 1-opt heuristic\n");
590 
591  /* maybe change solution values due to global bound changes first */
592  for( i = nvars - 1; i >= 0; --i )
593  {
594  SCIP_VAR* var;
595  SCIP_Real solval;
596 
597  var = vars[i];
598  lb = SCIPvarGetLbGlobal(var);
599  ub = SCIPvarGetUbGlobal(var);
600 
601  solval = SCIPgetSolVal(scip, bestsol,var);
602  /* old solution value is smaller than the actual lower bound */
603  if( SCIPisFeasLT(scip, solval, lb) )
604  {
605  /* set the solution value to the global lower bound */
606  SCIP_CALL( SCIPsetSolVal(scip, worksol, var, lb) );
607  ++nchgbound;
608  SCIPdebugMessage("var <%s> type %d, old solval %g now fixed to lb %g\n", SCIPvarGetName(var), SCIPvarGetType(var), solval, lb);
609  }
610  /* old solution value is greater than the actual upper bound */
611  else if( SCIPisFeasGT(scip, solval, SCIPvarGetUbGlobal(var)) )
612  {
613  /* set the solution value to the global upper bound */
614  SCIP_CALL( SCIPsetSolVal(scip, worksol, var, ub) );
615  ++nchgbound;
616  SCIPdebugMessage("var <%s> type %d, old solval %g now fixed to ub %g\n", SCIPvarGetName(var), SCIPvarGetType(var), solval, ub);
617  }
618  }
619 
620  SCIPdebugMessage("number of bound changes (due to global bounds) = %d\n", nchgbound);
621  SCIP_CALL( SCIPgetLPRowsData(scip, &lprows, &nlprows) );
622  SCIP_CALL( SCIPallocBufferArray(scip, &activities, nlprows) );
623 
624  localrows = FALSE;
625  valid = TRUE;
626 
627  /* initialize activities */
628  for( i = 0; i < nlprows; ++i )
629  {
630  SCIP_ROW* row;
631 
632  row = lprows[i];
633  assert(SCIProwGetLPPos(row) == i);
634 
635  if( !SCIProwIsLocal(row) )
636  {
637  activities[i] = SCIPgetRowSolActivity(scip, row, worksol);
638  SCIPdebugMessage("Row <%s> has activity %g\n", SCIProwGetName(row), activities[i]);
639  if( SCIPisFeasLT(scip, activities[i], SCIProwGetLhs(row)) || SCIPisFeasGT(scip, activities[i], SCIProwGetRhs(row)) )
640  {
641  valid = FALSE;
643  SCIPdebugMessage("row <%s> activity %g violates bounds, lhs = %g, rhs = %g\n", SCIProwGetName(row), activities[i], SCIProwGetLhs(row), SCIProwGetRhs(row));
644  break;
645  }
646  }
647  else
648  localrows = TRUE;
649  }
650 
651  if( !valid )
652  {
653  /** @todo try to correct lp rows */
654  SCIPdebugMessage("Some global bound changes were not valid in lp rows.\n");
655  goto TERMINATE;
656  }
657 
658  SCIP_CALL( SCIPallocBufferArray(scip, &shiftcands, shiftcandssize) );
659  SCIP_CALL( SCIPallocBufferArray(scip, &shiftvals, shiftcandssize) );
660 
661 
662  SCIPdebugMessage("Starting 1-opt heuristic\n");
663 
664  /* enumerate all integer variables and find out which of them are shiftable */
665  for( i = 0; i < nintvars; i++ )
666  {
667  if( SCIPvarGetStatus(vars[i]) == SCIP_VARSTATUS_COLUMN )
668  {
669  SCIP_Real shiftval;
670  SCIP_Real solval;
671 
672  /* find out whether the variable can be shifted */
673  solval = SCIPgetSolVal(scip, worksol, vars[i]);
674  shiftval = calcShiftVal(scip, vars[i], solval, activities);
675 
676  /* insert the variable into the list of shifting candidates */
677  if( !SCIPisFeasZero(scip, shiftval) )
678  {
679  SCIPdebugMessage(" -> Variable <%s> can be shifted by <%1.1f> \n", SCIPvarGetName(vars[i]), shiftval);
680 
681  if( nshiftcands == shiftcandssize)
682  {
683  shiftcandssize *= 8;
684  SCIP_CALL( SCIPreallocBufferArray(scip, &shiftcands, shiftcandssize) );
685  SCIP_CALL( SCIPreallocBufferArray(scip, &shiftvals, shiftcandssize) );
686  }
687  shiftcands[nshiftcands] = vars[i];
688  shiftvals[nshiftcands] = shiftval;
689  nshiftcands++;
690  }
691  }
692  }
693 
694  /* if at least one variable can be shifted, shift variables sorted by their objective */
695  if( nshiftcands > 0 )
696  {
697  SCIP_Real shiftval;
698  SCIP_Real solval;
699  SCIP_VAR* var;
700 
701  /* the case that exactly one variable can be shifted is slightly easier */
702  if( nshiftcands == 1 )
703  {
704  var = shiftcands[0];
705  assert(var != NULL);
706  solval = SCIPgetSolVal(scip, worksol, var);
707  shiftval = shiftvals[0];
708  assert(!SCIPisFeasZero(scip,shiftval));
709  SCIPdebugMessage(" Only one shiftcand found, var <%s>, which is now shifted by<%1.1f> \n",
710  SCIPvarGetName(var), shiftval);
711  SCIP_CALL( SCIPsetSolVal(scip, worksol, var, solval+shiftval) );
712  }
713  else
714  {
715  SCIP_Real* objcoeffs;
716 
717  SCIP_CALL( SCIPallocBufferArray(scip, &objcoeffs, nshiftcands) );
718 
719  SCIPdebugMessage(" %d shiftcands found \n", nshiftcands);
720 
721  /* sort the variables by their objective, optionally weighted with the shiftval */
722  if( heurdata->weightedobj )
723  {
724  for( i = 0; i < nshiftcands; ++i )
725  objcoeffs[i] = SCIPvarGetObj(shiftcands[i])*shiftvals[i];
726  }
727  else
728  {
729  for( i = 0; i < nshiftcands; ++i )
730  objcoeffs[i] = SCIPvarGetObj(shiftcands[i]);
731  }
732 
733  /* sort arrays with respect to the first one */
734  SCIPsortRealPtr(objcoeffs, (void**)shiftcands, nshiftcands);
735 
736  /* try to shift each variable -> Activities have to be updated */
737  for( i = 0; i < nshiftcands; ++i )
738  {
739  var = shiftcands[i];
740  assert(var != NULL);
741  solval = SCIPgetSolVal(scip, worksol, var);
742  shiftval = calcShiftVal(scip, var, solval, activities);
743  SCIPdebugMessage(" -> Variable <%s> is now shifted by <%1.1f> \n", SCIPvarGetName(vars[i]), shiftval);
744  assert(i > 0 || !SCIPisFeasZero(scip, shiftval));
745  assert(SCIPisFeasGE(scip, solval+shiftval, SCIPvarGetLbGlobal(var)) && SCIPisFeasLE(scip, solval+shiftval, SCIPvarGetUbGlobal(var)));
746  SCIP_CALL( SCIPsetSolVal(scip, worksol, var, solval+shiftval) );
747  SCIP_CALL( updateRowActivities(scip, activities, var, shiftval) );
748  }
749 
750  SCIPfreeBufferArray(scip, &objcoeffs);
751  }
752 
753  /* if the problem is a pure IP, try to install the solution, if it is a MIP, solve LP again to set the continuous
754  * variables to the best possible value
755  */
756  if( nvars == nintvars || !SCIPhasCurrentNodeLP(scip) || SCIPgetLPSolstat(scip) != SCIP_LPSOLSTAT_OPTIMAL )
757  {
758  SCIP_Bool success;
759 
760  /* since we ignore local rows, we cannot guarantee their feasibility and have to set the checklprows flag to
761  * TRUE if local rows are present
762  */
763  SCIP_CALL( SCIPtrySol(scip, worksol, FALSE, FALSE, FALSE, localrows, &success) );
764 
765  if( success )
766  {
767  SCIPdebugMessage("found feasible shifted solution:\n");
768  SCIPdebug( SCIP_CALL( SCIPprintSol(scip, worksol, NULL, FALSE) ) );
769  heurdata->lastsolindex = SCIPsolGetIndex(bestsol);
770  *result = SCIP_FOUNDSOL;
771  }
772  }
773  else
774  {
775  SCIP_Bool lperror;
776 #ifdef NDEBUG
777  SCIP_RETCODE retstat;
778 #endif
779 
780  SCIPdebugMessage("shifted solution should be feasible -> solve LP to fix continuous variables to best values\n");
781 
782  /* start diving to calculate the LP relaxation */
784 
785  /* set the bounds of the variables: fixed for integers, global bounds for continuous */
786  for( i = 0; i < nvars; ++i )
787  {
788  if( SCIPvarGetStatus(vars[i]) == SCIP_VARSTATUS_COLUMN )
789  {
790  SCIP_CALL( SCIPchgVarLbDive(scip, vars[i], SCIPvarGetLbGlobal(vars[i])) );
791  SCIP_CALL( SCIPchgVarUbDive(scip, vars[i], SCIPvarGetUbGlobal(vars[i])) );
792  }
793  }
794  /* apply this after global bounds to not cause an error with intermediate empty domains */
795  for( i = 0; i < nintvars; ++i )
796  {
797  if( SCIPvarGetStatus(vars[i]) == SCIP_VARSTATUS_COLUMN )
798  {
799  solval = SCIPgetSolVal(scip, worksol, vars[i]);
800  SCIP_CALL( SCIPchgVarLbDive(scip, vars[i], solval) );
801  SCIP_CALL( SCIPchgVarUbDive(scip, vars[i], solval) );
802  }
803  }
804 
805  /* solve LP */
806  SCIPdebugMessage(" -> old LP iterations: %" SCIP_LONGINT_FORMAT "\n", SCIPgetNLPIterations(scip));
807 
808  /**@todo in case of an MINLP, if SCIPisNLPConstructed() is TRUE, say, rather solve the NLP instead of the LP */
809  /* Errors in the LP solver should not kill the overall solving process, if the LP is just needed for a heuristic.
810  * Hence in optimized mode, the return code is caught and a warning is printed, only in debug mode, SCIP will stop.
811  */
812 #ifdef NDEBUG
813  retstat = SCIPsolveDiveLP(scip, -1, &lperror, NULL);
814  if( retstat != SCIP_OKAY )
815  {
816  SCIPwarningMessage(scip, "Error while solving LP in Oneopt heuristic; LP solve terminated with code <%d>\n",retstat);
817  }
818 #else
819  SCIP_CALL( SCIPsolveDiveLP(scip, -1, &lperror, NULL) );
820 #endif
821 
822  SCIPdebugMessage(" -> new LP iterations: %" SCIP_LONGINT_FORMAT "\n", SCIPgetNLPIterations(scip));
823  SCIPdebugMessage(" -> error=%u, status=%d\n", lperror, SCIPgetLPSolstat(scip));
824 
825  /* check if this is a feasible solution */
826  if( !lperror && SCIPgetLPSolstat(scip) == SCIP_LPSOLSTAT_OPTIMAL )
827  {
828  SCIP_Bool success;
829 
830  /* copy the current LP solution to the working solution */
831  SCIP_CALL( SCIPlinkLPSol(scip, worksol) );
832  SCIP_CALL( SCIPtrySol(scip, worksol, FALSE, FALSE, FALSE, FALSE, &success) );
833 
834  /* check solution for feasibility */
835  if( success )
836  {
837  SCIPdebugMessage("found feasible shifted solution:\n");
838  SCIPdebug( SCIP_CALL( SCIPprintSol(scip, worksol, NULL, FALSE) ) );
839  heurdata->lastsolindex = SCIPsolGetIndex(bestsol);
840  *result = SCIP_FOUNDSOL;
841  }
842  }
843 
844  /* terminate the diving */
846  }
847  }
848  SCIPdebugMessage("Finished 1-opt heuristic\n");
849 
850  SCIPfreeBufferArray(scip, &shiftvals);
851  SCIPfreeBufferArray(scip, &shiftcands);
852 
853  TERMINATE:
854  SCIPfreeBufferArray(scip, &activities);
855  SCIP_CALL( SCIPfreeSol(scip, &worksol) );
856 
857  return SCIP_OKAY;
858 }
859 
860 /*
861  * primal heuristic specific interface methods
862  */
863 
864 /** creates the oneopt primal heuristic and includes it in SCIP */
866  SCIP* scip /**< SCIP data structure */
867  )
868 {
869  SCIP_HEURDATA* heurdata;
870  SCIP_HEUR* heur;
871 
872  /* create Oneopt primal heuristic data */
873  SCIP_CALL( SCIPallocMemory(scip, &heurdata) );
874 
875  /* include primal heuristic */
876  SCIP_CALL( SCIPincludeHeurBasic(scip, &heur,
878  HEUR_MAXDEPTH, HEUR_TIMING, HEUR_USESSUBSCIP, heurExecOneopt, heurdata) );
879 
880  assert(heur != NULL);
881 
882  /* set non-NULL pointers to callback methods */
883  SCIP_CALL( SCIPsetHeurCopy(scip, heur, heurCopyOneopt) );
884  SCIP_CALL( SCIPsetHeurFree(scip, heur, heurFreeOneopt) );
885  SCIP_CALL( SCIPsetHeurInitsol(scip, heur, heurInitsolOneopt) );
886  SCIP_CALL( SCIPsetHeurExitsol(scip, heur, heurExitsolOneopt) );
887  SCIP_CALL( SCIPsetHeurInit(scip, heur, heurInitOneopt) );
888 
889  /* add oneopt primal heuristic parameters */
890  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/oneopt/weightedobj",
891  "should the objective be weighted with the potential shifting value when sorting the shifting candidates?",
892  &heurdata->weightedobj, TRUE, DEFAULT_WEIGHTEDOBJ, NULL, NULL) );
893 
894  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/oneopt/duringroot",
895  "should the heuristic be called before and during the root node?",
896  &heurdata->duringroot, TRUE, DEFAULT_DURINGROOT, NULL, NULL) );
897 
898  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/oneopt/forcelpconstruction",
899  "should the construction of the LP be forced even if LP solving is deactivated?",
900  &heurdata->forcelpconstruction, TRUE, DEFAULT_FORCELPCONSTRUCTION, NULL, NULL) );
901 
902  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/oneopt/beforepresol",
903  "should the heuristic be called before presolving?",
904  &heurdata->beforepresol, TRUE, DEFAULT_BEFOREPRESOL, NULL, NULL) );
905 
906  return SCIP_OKAY;
907 }
SCIP_RETCODE SCIPsetHeurInitsol(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURINITSOL((*heurinitsol)))
Definition: scip.c:7361
#define HEUR_DISPCHAR
Definition: heur_oneopt.c:34
#define SCIP_HEURTIMING_DURINGLPLOOP
Definition: type_timing.h:69
SCIP_RETCODE SCIPprintStatistics(SCIP *scip, FILE *file)
Definition: scip.c:40329
#define DEFAULT_BEFOREPRESOL
Definition: heur_oneopt.c:44
#define SCIPallocMemory(scip, ptr)
Definition: scip.h:20526
#define DEFAULT_WEIGHTEDOBJ
Definition: heur_oneopt.c:42
const char * SCIPvarGetName(SCIP_VAR *var)
Definition: var.c:16443
SCIP_Real SCIPgetRowSolActivity(SCIP *scip, SCIP_ROW *row, SCIP_SOL *sol)
Definition: scip.c:28285
Improvement heuristic that alters single variable values.
#define SCIPreallocBufferArray(scip, ptr, num)
Definition: scip.h:20589
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
Definition: scip.c:41648
const char * SCIPheurGetName(SCIP_HEUR *heur)
Definition: heur.c:1147
SCIP_RETCODE SCIPsetHeurCopy(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURCOPY((*heurcopy)))
Definition: scip.c:7297
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
Definition: scip.c:1248
SCIP_Bool SCIPisFeasLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip.c:41920
SCIP_Longint SCIPgetNLPIterations(SCIP *scip)
Definition: scip.c:37454
#define DEFAULT_DURINGROOT
Definition: heur_oneopt.c:43
#define NULL
Definition: lpi_spx.cpp:130
SCIP_Real SCIPfeasFloor(SCIP *scip, SCIP_Real val)
Definition: scip.c:42032
#define SCIP_HEURTIMING_BEFORENODE
Definition: type_timing.h:68
SCIP_Real SCIProwGetLhs(SCIP_ROW *row)
Definition: lp.c:18915
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
Definition: var.c:17067
SCIP_RETCODE SCIPsetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real val)
Definition: scip.c:34843
SCIP_RETCODE SCIPincludeHeurBasic(SCIP *scip, SCIP_HEUR **heur, const char *name, const char *desc, char dispchar, int priority, int freq, int freqofs, int maxdepth, unsigned int timingmask, SCIP_Bool usessubscip, SCIP_DECL_HEUREXEC((*heurexec)), SCIP_HEURDATA *heurdata)
Definition: scip.c:7252
SCIP_RETCODE SCIPchgVarUbDive(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
Definition: scip.c:31772
SCIP_RETCODE SCIPunfixParam(SCIP *scip, const char *name)
Definition: scip.c:3875
#define DEFAULT_FORCELPCONSTRUCTION
Definition: heur_oneopt.c:45
#define FALSE
Definition: def.h:56
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
Definition: misc.c:2057
SCIP_Real SCIPgetSolvingTime(SCIP *scip)
Definition: scip.c:41009
SCIP_RETCODE SCIPsetLongintParam(SCIP *scip, const char *name, SCIP_Longint value)
Definition: scip.c:4046
#define TRUE
Definition: def.h:55
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
#define HEUR_DESC
Definition: heur_oneopt.c:33
#define SCIP_CALL(x)
Definition: def.h:266
SCIP_RETCODE SCIPtrySolFree(SCIP *scip, SCIP_SOL **sol, SCIP_Bool printreason, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
Definition: scip.c:36299
SCIP_Bool SCIPisFeasZero(SCIP *scip, SCIP_Real val)
Definition: scip.c:41972
SCIP_RETCODE SCIPsetRealParam(SCIP *scip, const char *name, SCIP_Real value)
Definition: scip.c:4109
struct SCIP_HeurData SCIP_HEURDATA
Definition: type_heur.h:51
SCIP_LPSOLSTAT SCIPgetLPSolstat(SCIP *scip)
Definition: scip.c:26439
#define SCIPdebugMessage
Definition: pub_message.h:77
SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
Definition: scip.c:34983
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
Definition: var.c:16905
void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin)
Definition: misc.c:2116
static SCIP_Real calcShiftVal(SCIP *scip, SCIP_VAR *var, SCIP_Real solval, SCIP_Real *activities)
Definition: heur_oneopt.c:114
SCIP_RETCODE SCIPstartDive(SCIP *scip)
Definition: scip.c:31575
SCIP_RETCODE SCIPchgVarLbDive(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
Definition: scip.c:31740
int SCIPgetNSols(SCIP *scip)
Definition: scip.c:35668
SCIP_RETCODE SCIPaddBoolParam(SCIP *scip, const char *name, const char *desc, SCIP_Bool *valueptr, SCIP_Bool isadvanced, SCIP_Bool defaultvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip.c:3547
SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
Definition: var.c:16562
int SCIPgetNOrigVars(SCIP *scip)
Definition: scip.c:11138
#define HEUR_MAXDEPTH
Definition: heur_oneopt.c:38
#define SCIPfreeMemory(scip, ptr)
Definition: scip.h:20542
SCIP_RETCODE SCIPconstructLP(SCIP *scip, SCIP_Bool *cutoff)
Definition: scip.c:26395
SCIP_ROW ** SCIPcolGetRows(SCIP_COL *col)
Definition: lp.c:18784
SCIP_RETCODE SCIPcopy(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, const char *suffix, SCIP_Bool global, SCIP_Bool enablepricing, SCIP_Bool passmessagehdlr, SCIP_Bool *valid)
Definition: scip.c:3254
SCIP_Real SCIProwGetRhs(SCIP_ROW *row)
Definition: lp.c:18925
int SCIPcalcHashtableSize(int minsize)
Definition: misc.c:1157
SCIP_RETCODE SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip.c:34002
void SCIPsolSetHeur(SCIP_SOL *sol, SCIP_HEUR *heur)
Definition: sol.c:2293
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
Definition: scip.c:41353
static SCIP_DECL_HEURCOPY(heurCopyOneopt)
Definition: heur_oneopt.c:267
SCIP_Bool SCIProwIsInLP(SCIP_ROW *row)
Definition: lp.c:19126
SCIP_Bool SCIProwIsLocal(SCIP_ROW *row)
Definition: lp.c:19024
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
Definition: misc.c:2075
SCIP_RETCODE SCIPsetSeparating(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
Definition: scip.c:4457
static SCIP_RETCODE updateRowActivities(SCIP *scip, SCIP_Real *activities, SCIP_VAR *var, SCIP_Real shiftval)
Definition: heur_oneopt.c:213
SCIP_COL * SCIPvarGetCol(SCIP_VAR *var)
Definition: var.c:16771
SCIP_RETCODE SCIPgetLPRowsData(SCIP *scip, SCIP_ROW ***rows, int *nrows)
Definition: scip.c:26750
SCIP_RETCODE SCIPgetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
Definition: scip.c:35020
SCIP_Real SCIPinfinity(SCIP *scip)
Definition: scip.c:41637
void SCIPheurSetTimingmask(SCIP_HEUR *heur, SCIP_HEURTIMING timingmask)
Definition: heur.c:1187
SCIP_Bool SCIPhasCurrentNodeLP(SCIP *scip)
Definition: scip.c:26354
int SCIPcolGetNLPNonz(SCIP_COL *col)
Definition: lp.c:18773
SCIP_RETCODE SCIPfree(SCIP **scip)
Definition: scip.c:766
static SCIP_DECL_HEUREXITSOL(heurExitsolOneopt)
Definition: heur_oneopt.c:320
SCIP_SOL ** SCIPgetSols(SCIP *scip)
Definition: scip.c:35717
#define SCIP_HEURTIMING_BEFOREPRESOL
Definition: type_timing.h:84
const char * SCIProwGetName(SCIP_ROW *row)
Definition: lp.c:18974
SCIP_Bool SCIPisFeasGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip.c:41946
SCIP_RETCODE SCIPtransformProb(SCIP *scip)
Definition: scip.c:12623
#define HEUR_FREQ
Definition: heur_oneopt.c:36
void SCIPheurSetData(SCIP_HEUR *heur, SCIP_HEURDATA *heurdata)
Definition: heur.c:1068
SCIP_RETCODE SCIPincludeHeurOneopt(SCIP *scip)
Definition: heur_oneopt.c:865
#define HEUR_USESSUBSCIP
Definition: heur_oneopt.c:40
#define SCIP_Bool
Definition: def.h:53
#define HEUR_PRIORITY
Definition: heur_oneopt.c:35
SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value)
Definition: scip.c:4001
SCIP_Bool SCIPisParamFixed(SCIP *scip, const char *name)
Definition: scip.c:3709
#define HEUR_FREQOFS
Definition: heur_oneopt.c:37
#define MAX(x, y)
Definition: tclique_def.h:75
SCIP_RETCODE SCIPcreateSolCopy(SCIP *scip, SCIP_SOL **sol, SCIP_SOL *sourcesol)
Definition: scip.c:34271
SCIP_Longint SCIPgetMemUsed(SCIP *scip)
Definition: scip.c:41396
static SCIP_DECL_HEUREXEC(heurExecOneopt)
Definition: heur_oneopt.c:353
SCIP_RETCODE SCIPsetHeurExitsol(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEUREXITSOL((*heurexitsol)))
Definition: scip.c:7377
SCIP_RETCODE SCIPsetPresolving(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
Definition: scip.c:4431
int SCIPsolGetIndex(SCIP_SOL *sol)
Definition: sol.c:2283
SCIP_RETCODE SCIPlinkLPSol(SCIP *scip, SCIP_SOL *sol)
Definition: scip.c:34648
SCIP_Bool SCIPsolIsOriginal(SCIP_SOL *sol)
Definition: sol.c:2179
SCIP_RETCODE SCIPsetHeurInit(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURINIT((*heurinit)))
Definition: scip.c:7329
SCIP_RETCODE SCIPsolve(SCIP *scip)
Definition: scip.c:14503
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
Definition: var.c:16608
SCIP_RETCODE SCIPsetHeuristics(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
Definition: scip.c:4405
#define SCIPallocBufferArray(scip, ptr, num)
Definition: scip.h:20585
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
Definition: var.c:17057
SCIP_RETCODE SCIPcreate(SCIP **scip)
Definition: scip.c:692
static SCIP_DECL_HEURINIT(heurInitOneopt)
Definition: heur_oneopt.c:333
static SCIP_RETCODE createNewSol(SCIP *scip, SCIP *subscip, SCIP_VAR **subvars, SCIP_HEUR *heur, SCIP_SOL *subsol, SCIP_Bool *success)
Definition: heur_oneopt.c:68
SCIP_RETCODE SCIPendDive(SCIP *scip)
Definition: scip.c:31618
SCIP_RETCODE SCIPcreateOrigSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip.c:34218
SCIP_Bool SCIPisFeasLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip.c:41933
SCIP_RETCODE SCIPsetHeurFree(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURFREE((*heurfree)))
Definition: scip.c:7313
#define HEUR_TIMING
Definition: heur_oneopt.c:39
#define SCIP_Real
Definition: def.h:127
SCIP_RETCODE SCIPflushLP(SCIP *scip)
Definition: scip.c:26419
#define MIN(x, y)
Definition: memory.c:67
SCIP_RETCODE SCIPprintRow(SCIP *scip, SCIP_ROW *row, FILE *file)
Definition: scip.c:28334
SCIP_Bool SCIPisFeasGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip.c:41959
#define HEUR_NAME
Definition: heur_oneopt.c:32
static SCIP_DECL_HEURFREE(heurFreeOneopt)
Definition: heur_oneopt.c:281
void SCIPsortRealPtr(SCIP_Real *realarray, void **ptrarray, int len)
SCIP_RETCODE SCIPsetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
Definition: scip.c:34885
int SCIProwGetLPPos(SCIP_ROW *row)
Definition: lp.c:19104
SCIP_RETCODE SCIPsetBoolParam(SCIP *scip, const char *name, SCIP_Bool value)
Definition: scip.c:3938
SCIP_HEURDATA * SCIPheurGetData(SCIP_HEUR *heur)
Definition: heur.c:1058
SCIP_RETCODE SCIPgetVarsData(SCIP *scip, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars)
Definition: scip.c:10572
#define SCIPfreeBufferArray(scip, ptr)
Definition: scip.h:20597
SCIP_RETCODE SCIPgetRealParam(SCIP *scip, const char *name, SCIP_Real *value)
Definition: scip.c:3797
static SCIP_DECL_HEURINITSOL(heurInitsolOneopt)
Definition: heur_oneopt.c:301
#define SCIPdebug(x)
Definition: pub_message.h:74
SCIP_RETCODE SCIPsolveDiveLP(SCIP *scip, int itlim, SCIP_Bool *lperror, SCIP_Bool *cutoff)
Definition: scip.c:31999
SCIP_SOL * SCIPgetBestSol(SCIP *scip)
Definition: scip.c:35767
SCIP_Real * SCIPcolGetVals(SCIP_COL *col)
Definition: lp.c:18794
int SCIPgetNLPRows(SCIP *scip)
Definition: scip.c:26806
SCIP_RETCODE SCIPtrySol(SCIP *scip, SCIP_SOL *sol, SCIP_Bool printreason, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
Definition: scip.c:36217
SCIP_Longint SCIPgetNNodes(SCIP *scip)
Definition: scip.c:37372
SCIP_RETCODE SCIPprintSol(SCIP *scip, SCIP_SOL *sol, FILE *file, SCIP_Bool printzeros)
Definition: scip.c:35397
SCIP_RETCODE SCIPfreeSol(SCIP *scip, SCIP_SOL **sol)
Definition: scip.c:34607
SCIP_Longint SCIPgetMemExternEstim(SCIP *scip)
Definition: scip.c:41409
int SCIPheurGetFreqofs(SCIP_HEUR *heur)
Definition: heur.c:1253