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-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_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 #define DEFAULT_USELOOP TRUE /**< should the heuristic continue to run as long as improvements are found? */
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  SCIP_Bool useloop; /**< should the heuristic continue to run as long as improvements are found? */
60 };
61 
62 
63 /*
64  * Local methods
65  */
66 
67 /** creates a new solution for the original problem by copying the solution of the subproblem */
68 static
70  SCIP* scip, /**< original SCIP data structure */
71  SCIP* subscip, /**< SCIP structure of the subproblem */
72  SCIP_VAR** subvars, /**< the variables of the subproblem */
73  SCIP_HEUR* heur, /**< zeroobj heuristic structure */
74  SCIP_SOL* subsol, /**< solution of the subproblem */
75  SCIP_Bool* success /**< used to store whether new solution was found or not */
76  )
77 {
78  SCIP_VAR** vars; /* the original problem's variables */
79  int nvars; /* the original problem's number of variables */
80  SCIP_Real* subsolvals; /* solution values of the subproblem */
81  SCIP_SOL* newsol; /* solution to be created for the original problem */
82 
83  assert(scip != NULL);
84  assert(subscip != NULL);
85  assert(subvars != NULL);
86  assert(subsol != NULL);
87 
88  /* get variables' data */
89  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, NULL, NULL, NULL, NULL) );
90 
91  /* sub-SCIP may have more variables than the number of active (transformed) variables in the main SCIP
92  * since constraint copying may have required the copy of variables that are fixed in the main SCIP
93  */
94  assert(nvars <= SCIPgetNOrigVars(subscip));
95 
96  SCIP_CALL( SCIPallocBufferArray(scip, &subsolvals, nvars) );
97 
98  /* copy the solution */
99  SCIP_CALL( SCIPgetSolVals(subscip, subsol, nvars, subvars, subsolvals) );
100 
101  /* create new solution for the original problem */
102  SCIP_CALL( SCIPcreateSol(scip, &newsol, heur) );
103  SCIP_CALL( SCIPsetSolVals(scip, newsol, nvars, vars, subsolvals) );
104 
105  /* try to add new solution to scip and free it immediately */
106  SCIP_CALL( SCIPtrySolFree(scip, &newsol, FALSE, FALSE, TRUE, TRUE, TRUE, success) );
107 
108  SCIPfreeBufferArray(scip, &subsolvals);
109 
110  return SCIP_OKAY;
111 }
112 
113 /** compute value by which the solution of variable @p var can be shifted */
114 static
116  SCIP* scip, /**< SCIP data structure */
117  SCIP_VAR* var, /**< variable that should be shifted */
118  SCIP_Real solval, /**< current solution value */
119  SCIP_Real* activities /**< LP row activities */
120  )
121 {
122  SCIP_Real lb;
123  SCIP_Real ub;
124  SCIP_Real obj;
125  SCIP_Real shiftval;
126 
127  SCIP_COL* col;
128  SCIP_ROW** colrows;
129  SCIP_Real* colvals;
130  SCIP_Bool shiftdown;
131 
132  int ncolrows;
133  int i;
134 
135 
136  /* get variable's solution value, global bounds and objective coefficient */
137  lb = SCIPvarGetLbGlobal(var);
138  ub = SCIPvarGetUbGlobal(var);
139  obj = SCIPvarGetObj(var);
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  SCIPdebugMsg(scip, "Try to shift %s variable <%s> with\n", shiftdown ? "down" : "up", SCIPvarGetName(var) );
155  SCIPdebugMsg(scip, " 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  SCIPdebugMsg(scip, " -> The shift value had to be reduced to <%g>, because of row <%s>.\n",
190  shiftvalrow, SCIProwGetName(row));
191  SCIPdebugMsg(scip, " 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 /** setup and solve oneopt sub-SCIP */
262 static
264  SCIP* scip, /**< SCIP data structure */
265  SCIP* subscip, /**< sub-SCIP data structure */
266  SCIP_HEUR* heur, /**< mutation heuristic */
267  SCIP_VAR** vars, /**< SCIP variables */
268  SCIP_VAR** subvars, /**< subproblem's variables */
269  SCIP_SOL* bestsol, /**< incumbent solution */
270  SCIP_RESULT* result, /**< pointer to store the result */
271  SCIP_Bool* valid /**< pointer to store the valid value */
272  )
273 {
274  SCIP_HASHMAP* varmapfw; /* mapping of SCIP variables to sub-SCIP variables */
275  SCIP_SOL** subsols;
276  SCIP_SOL* startsol;
277  SCIP_Real* subsolvals; /* solution values of the subproblem */
278  int nsubsols;
279  int nvars; /* number of original problem's variables */
280  int i;
281 
282  assert(scip != NULL);
283  assert(subscip != NULL);
284  assert(heur != NULL);
285 
286  nvars = SCIPgetNVars(scip);
287 
288  /* create the variable mapping hash map */
289  SCIP_CALL( SCIPhashmapCreate(&varmapfw, SCIPblkmem(subscip), nvars) );
290 
291  /* copy complete SCIP instance */
292  *valid = FALSE;
293  SCIP_CALL( SCIPcopy(scip, subscip, varmapfw, NULL, "oneopt", TRUE, FALSE, TRUE, valid) );
294  SCIP_CALL( SCIPtransformProb(subscip) );
295 
296  /* get variable image */
297  for( i = 0; i < nvars; i++ )
298  subvars[i] = (SCIP_VAR*) SCIPhashmapGetImage(varmapfw, vars[i]);
299 
300  /* copy the solution */
301  SCIP_CALL( SCIPallocBufferArray(scip, &subsolvals, nvars) );
302  SCIP_CALL( SCIPgetSolVals(scip, bestsol, nvars, vars, subsolvals) );
303 
304  /* create start solution for the subproblem */
305  SCIP_CALL( SCIPcreateOrigSol(subscip, &startsol, NULL) );
306  SCIP_CALL( SCIPsetSolVals(subscip, startsol, nvars, subvars, subsolvals) );
307 
308  /* try to add new solution to sub-SCIP and free it immediately */
309  *valid = FALSE;
310  SCIP_CALL( SCIPtrySolFree(subscip, &startsol, FALSE, FALSE, FALSE, FALSE, FALSE, valid) );
311  SCIPfreeBufferArray(scip, &subsolvals);
312  SCIPhashmapFree(&varmapfw);
313 
314  /* deactivate basically everything except oneopt in the sub-SCIP */
318 
319  /* set limits for the subproblem */
320  SCIP_CALL( SCIPcopyLimits(scip, subscip) );
321  SCIP_CALL( SCIPsetLongintParam(subscip, "limits/nodes", 1LL) );
322 
323  SCIP_CALL( SCIPsetBoolParam(subscip, "misc/catchctrlc", FALSE) );
324 
325 #ifdef SCIP_DEBUG
326  /* for debugging, enable full output */
327  SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", 5) );
328  SCIP_CALL( SCIPsetIntParam(subscip, "display/freq", 100000000) );
329 #else
330  /* disable statistic timing inside sub SCIP and output to console */
331  SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", 0) );
332  SCIP_CALL( SCIPsetBoolParam(subscip, "timing/statistictiming", FALSE) );
333 #endif
334 
335  /* if necessary, some of the parameters have to be unfixed first */
336  if( SCIPisParamFixed(subscip, "lp/solvefreq") )
337  {
338  SCIPwarningMessage(scip, "unfixing parameter lp/solvefreq in subscip of oneopt heuristic\n");
339  SCIP_CALL( SCIPunfixParam(subscip, "lp/solvefreq") );
340  }
341  SCIP_CALL( SCIPsetIntParam(subscip, "lp/solvefreq", -1) );
342 
343  if( SCIPisParamFixed(subscip, "heuristics/oneopt/freq") )
344  {
345  SCIPwarningMessage(scip, "unfixing parameter heuristics/oneopt/freq in subscip of oneopt heuristic\n");
346  SCIP_CALL( SCIPunfixParam(subscip, "heuristics/oneopt/freq") );
347  }
348  SCIP_CALL( SCIPsetIntParam(subscip, "heuristics/oneopt/freq", 1) );
349 
350  if( SCIPisParamFixed(subscip, "heuristics/oneopt/forcelpconstruction") )
351  {
352  SCIPwarningMessage(scip, "unfixing parameter heuristics/oneopt/forcelpconstruction in subscip of oneopt heuristic\n");
353  SCIP_CALL( SCIPunfixParam(subscip, "heuristics/oneopt/forcelpconstruction") );
354  }
355  SCIP_CALL( SCIPsetBoolParam(subscip, "heuristics/oneopt/forcelpconstruction", TRUE) );
356 
357  /* avoid recursive call, which would lead to an endless loop */
358  if( SCIPisParamFixed(subscip, "heuristics/oneopt/beforepresol") )
359  {
360  SCIPwarningMessage(scip, "unfixing parameter heuristics/oneopt/beforepresol in subscip of oneopt heuristic\n");
361  SCIP_CALL( SCIPunfixParam(subscip, "heuristics/oneopt/beforepresol") );
362  }
363  SCIP_CALL( SCIPsetBoolParam(subscip, "heuristics/oneopt/beforepresol", FALSE) );
364 
365  /* speed up sub-SCIP by not checking dual LP feasibility */
366  SCIP_CALL( SCIPsetBoolParam(subscip, "lp/checkdualfeas", FALSE) );
367 
368  if( *valid )
369  {
370  /* errors in solving the subproblem should not kill the overall solving process;
371  * hence, the return code is caught and a warning is printed, only in debug mode, SCIP will stop.
372  */
373  SCIP_CALL_ABORT( SCIPsolve(subscip) );
374 
375 #ifdef SCIP_DEBUG
376  SCIP_CALL( SCIPprintStatistics(subscip, NULL) );
377 #endif
378 
379  /* check, whether a solution was found;
380  * due to numerics, it might happen that not all solutions are feasible -> try all solutions until one was accepted
381  */
382  nsubsols = SCIPgetNSols(subscip);
383  subsols = SCIPgetSols(subscip);
384  *valid = FALSE;
385  for( i = 0; i < nsubsols && !(*valid); ++i )
386  {
387  SCIP_CALL( createNewSol(scip, subscip, subvars, heur, subsols[i], valid) );
388  if( *valid )
389  *result = SCIP_FOUNDSOL;
390  }
391  }
392 
393  return SCIP_OKAY;
394 }
395 
396 /*
397  * Callback methods of primal heuristic
398  */
399 
400 /** copy method for primal heuristic plugins (called when SCIP copies plugins) */
401 static
402 SCIP_DECL_HEURCOPY(heurCopyOneopt)
403 { /*lint --e{715}*/
404  assert(scip != NULL);
405  assert(heur != NULL);
406  assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
407 
408  /* call inclusion method of primal heuristic */
410 
411  return SCIP_OKAY;
412 }
413 
414 /** destructor of primal heuristic to free user data (called when SCIP is exiting) */
415 static
416 SCIP_DECL_HEURFREE(heurFreeOneopt)
417 { /*lint --e{715}*/
418  SCIP_HEURDATA* heurdata;
419 
420  assert(heur != NULL);
421  assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
422  assert(scip != NULL);
423 
424  /* free heuristic data */
425  heurdata = SCIPheurGetData(heur);
426  assert(heurdata != NULL);
427  SCIPfreeBlockMemory(scip, &heurdata);
428  SCIPheurSetData(heur, NULL);
429 
430  return SCIP_OKAY;
431 }
432 
433 
434 /** solving process initialization method of primal heuristic (called when branch and bound process is about to begin) */
435 static
436 SCIP_DECL_HEURINITSOL(heurInitsolOneopt)
437 {
438  SCIP_HEURDATA* heurdata;
439 
440  assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
441 
442  /* create heuristic data */
443  heurdata = SCIPheurGetData(heur);
444  assert(heurdata != NULL);
445 
446  /* 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 */
447  if( heurdata->duringroot && SCIPheurGetFreqofs(heur) == 0 )
449 
450  return SCIP_OKAY;
451 }
452 
453 /** solving process deinitialization method of primal heuristic (called before branch and bound process data is freed) */
454 static
455 SCIP_DECL_HEUREXITSOL(heurExitsolOneopt)
456 {
457  assert(heur != NULL);
458  assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
459 
460  /* reset the timing mask to its default value */
462 
463  return SCIP_OKAY;
464 }
465 
466 /** initialization method of primal heuristic (called after problem was transformed) */
467 static
468 SCIP_DECL_HEURINIT(heurInitOneopt)
469 { /*lint --e{715}*/
470  SCIP_HEURDATA* heurdata;
471 
472  assert(heur != NULL);
473  assert(scip != NULL);
474 
475  /* get heuristic data */
476  heurdata = SCIPheurGetData(heur);
477  assert(heurdata != NULL);
478 
479  /* initialize last solution index */
480  heurdata->lastsolindex = -1;
481 
482  return SCIP_OKAY;
483 }
484 
485 /** execution method of primal heuristic */
486 static
487 SCIP_DECL_HEUREXEC(heurExecOneopt)
488 { /*lint --e{715}*/
489 
490  SCIP_HEURDATA* heurdata;
491  SCIP_SOL* bestsol; /* incumbent solution */
492  SCIP_SOL* worksol; /* heuristic's working solution */
493  SCIP_VAR** vars; /* SCIP variables */
494  SCIP_VAR** shiftcands; /* shiftable variables */
495  SCIP_ROW** lprows; /* SCIP LP rows */
496  SCIP_Real* activities; /* row activities for working solution */
497  SCIP_Real* shiftvals;
498  SCIP_Bool shifted;
499 
500  SCIP_RETCODE retcode;
501 
502  SCIP_Real lb;
503  SCIP_Real ub;
504  SCIP_Bool localrows;
505  SCIP_Bool valid;
506  int nchgbound;
507  int nbinvars;
508  int nintvars;
509  int nvars;
510  int nlprows;
511  int i;
512  int nshiftcands;
513  int shiftcandssize;
514  int nsuccessfulshifts;
515  int niterations;
516 
517  assert(heur != NULL);
518  assert(scip != NULL);
519  assert(result != NULL);
520 
521  /* get heuristic's data */
522  heurdata = SCIPheurGetData(heur);
523  assert(heurdata != NULL);
524 
525  *result = SCIP_DELAYED;
526 
527  /* we only want to process each solution once */
528  bestsol = SCIPgetBestSol(scip);
529  if( bestsol == NULL || heurdata->lastsolindex == SCIPsolGetIndex(bestsol) )
530  return SCIP_OKAY;
531 
532  /* reset the timing mask to its default value (at the root node it could be different) */
533  if( SCIPgetNNodes(scip) > 1 )
535 
536  /* get problem variables */
537  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, &nbinvars, &nintvars, NULL, NULL) );
538  nintvars += nbinvars;
539 
540  /* do not run if there are no discrete variables */
541  if( nintvars == 0 )
542  {
543  *result = SCIP_DIDNOTRUN;
544  return SCIP_OKAY;
545  }
546 
547  if( heurtiming == SCIP_HEURTIMING_BEFOREPRESOL )
548  {
549  SCIP* subscip; /* the subproblem created by oneopt */
550  SCIP_VAR** subvars; /* subproblem's variables */
551 
552  SCIP_Bool success;
553 
554  if( !heurdata->beforepresol )
555  return SCIP_OKAY;
556 
557  /* check whether there is enough time and memory left */
558  SCIP_CALL( SCIPcheckCopyLimits(scip, &success) );
559 
560  if( !success )
561  return SCIP_OKAY;
562 
563  SCIP_CALL( SCIPallocBufferArray(scip, &subvars, nvars) );
564 
565  /* initialize the subproblem */
566  SCIP_CALL( SCIPcreate(&subscip) );
567 
568  /* setup and solve the subproblem and catch the return code */
569  retcode = setupAndSolveSubscipOneopt(scip, subscip, heur, vars, subvars, bestsol, result, &valid);
570 
571  /* free the subscip in any case */
572  SCIP_CALL( SCIPfree(&subscip) );
573  SCIP_CALL( retcode );
574 
575  SCIPfreeBufferArray(scip, &subvars);
576 
577  return SCIP_OKAY;
578  }
579 
580  /* we can only work on solutions valid in the transformed space */
581  if( SCIPsolIsOriginal(bestsol) )
582  return SCIP_OKAY;
583 
584  if( heurtiming == SCIP_HEURTIMING_BEFORENODE && (SCIPhasCurrentNodeLP(scip) || heurdata->forcelpconstruction) )
585  {
586  SCIP_Bool cutoff;
587 
588  SCIP_CALL( SCIPconstructLP(scip, &cutoff) );
589 
590  /* manually cut off the node if the LP construction detected infeasibility (heuristics cannot return such a result) */
591  if( cutoff )
592  {
594  return SCIP_OKAY;
595  }
596 
598 
599  /* get problem variables again, SCIPconstructLP() might have added new variables */
600  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, &nbinvars, &nintvars, NULL, NULL) );
601  nintvars += nbinvars;
602  }
603 
604  /* we need an LP */
605  if( SCIPgetNLPRows(scip) == 0 )
606  return SCIP_OKAY;
607 
608  *result = SCIP_DIDNOTFIND;
609 
610  heurdata->lastsolindex = SCIPsolGetIndex(bestsol);
611  SCIP_CALL( SCIPcreateSolCopy(scip, &worksol, bestsol) );
612  SCIPsolSetHeur(worksol,heur);
613 
614  SCIPdebugMsg(scip, "Starting bound adjustment in 1-opt heuristic\n");
615 
616  nchgbound = 0;
617  /* change solution values due to possible global bound changes first */
618  for( i = nvars - 1; i >= 0; --i )
619  {
620  SCIP_VAR* var;
621  SCIP_Real solval;
622 
623  var = vars[i];
624  lb = SCIPvarGetLbGlobal(var);
625  ub = SCIPvarGetUbGlobal(var);
626 
627  solval = SCIPgetSolVal(scip, worksol, var);
628  /* old solution value is smaller than the actual lower bound */
629  if( SCIPisFeasLT(scip, solval, lb) )
630  {
631  /* set the solution value to the global lower bound */
632  SCIP_CALL( SCIPsetSolVal(scip, worksol, var, lb) );
633  ++nchgbound;
634  SCIPdebugMsg(scip, "var <%s> type %d, old solval %g now fixed to lb %g\n", SCIPvarGetName(var), SCIPvarGetType(var), solval, lb);
635  }
636  /* old solution value is greater than the actual upper bound */
637  else if( SCIPisFeasGT(scip, solval, SCIPvarGetUbGlobal(var)) )
638  {
639  /* set the solution value to the global upper bound */
640  SCIP_CALL( SCIPsetSolVal(scip, worksol, var, ub) );
641  ++nchgbound;
642  SCIPdebugMsg(scip, "var <%s> type %d, old solval %g now fixed to ub %g\n", SCIPvarGetName(var), SCIPvarGetType(var), solval, ub);
643  }
644  }
645 
646  SCIPdebugMsg(scip, "number of bound changes (due to global bounds) = %d\n", nchgbound);
647 
648  SCIP_CALL( SCIPgetLPRowsData(scip, &lprows, &nlprows) );
649  SCIP_CALL( SCIPallocBufferArray(scip, &activities, nlprows) );
650 
651  localrows = FALSE;
652  valid = TRUE;
653 
654  /* initialize LP row activities */
655  for( i = 0; i < nlprows; ++i )
656  {
657  SCIP_ROW* row;
658 
659  row = lprows[i];
660  assert(SCIProwGetLPPos(row) == i);
661 
662  if( !SCIProwIsLocal(row) )
663  {
664  activities[i] = SCIPgetRowSolActivity(scip, row, worksol);
665  SCIPdebugMsg(scip, "Row <%s> has activity %g\n", SCIProwGetName(row), activities[i]);
666  if( SCIPisFeasLT(scip, activities[i], SCIProwGetLhs(row)) || SCIPisFeasGT(scip, activities[i], SCIProwGetRhs(row)) )
667  {
668  valid = FALSE;
669  SCIPdebug( SCIP_CALL( SCIPprintRow(scip, row, NULL) ) );
670  SCIPdebugMsg(scip, "row <%s> activity %g violates bounds, lhs = %g, rhs = %g\n", SCIProwGetName(row), activities[i], SCIProwGetLhs(row), SCIProwGetRhs(row));
671  break;
672  }
673  }
674  else
675  localrows = TRUE;
676  }
677 
678  if( !valid )
679  {
680  /** @todo try to correct lp rows */
681  SCIPdebugMsg(scip, "Some global bound changes were not valid in lp rows.\n");
682 
683  SCIPfreeBufferArray(scip, &activities);
684  SCIP_CALL( SCIPfreeSol(scip, &worksol) );
685 
686  return SCIP_OKAY;
687  }
688 
689  /* allocate buffer storage for possible shift candidates */
690  shiftcandssize = 8;
691  SCIP_CALL( SCIPallocBufferArray(scip, &shiftcands, shiftcandssize) );
692  SCIP_CALL( SCIPallocBufferArray(scip, &shiftvals, shiftcandssize) );
693  nsuccessfulshifts = 0;
694  niterations = 0;
695  do
696  {
697  /* initialize data */
698  shifted = FALSE;
699  nshiftcands = 0;
700  ++niterations;
701  SCIPdebugMsg(scip, "Starting 1-opt heuristic iteration #%d\n", niterations);
702 
703  /* enumerate all integer variables and find out which of them are shiftable */
704  /* @todo if useloop=TRUE store for each variable which constraint blocked it and only iterate over those variables
705  * in the following rounds for which the constraint slack was increased by previous shifts
706  */
707  for( i = 0; i < nintvars; i++ )
708  {
709  if( SCIPvarGetStatus(vars[i]) == SCIP_VARSTATUS_COLUMN )
710  {
711  SCIP_Real shiftval;
712  SCIP_Real solval;
713 
714  /* find out whether the variable can be shifted */
715  solval = SCIPgetSolVal(scip, worksol, vars[i]);
716  shiftval = calcShiftVal(scip, vars[i], solval, activities);
717 
718  /* insert the variable into the list of shifting candidates */
719  if( !SCIPisFeasZero(scip, shiftval) )
720  {
721  SCIPdebugMsg(scip, " -> Variable <%s> can be shifted by <%1.1f> \n", SCIPvarGetName(vars[i]), shiftval);
722 
723  if( nshiftcands == shiftcandssize)
724  {
725  shiftcandssize *= 8;
726  SCIP_CALL( SCIPreallocBufferArray(scip, &shiftcands, shiftcandssize) );
727  SCIP_CALL( SCIPreallocBufferArray(scip, &shiftvals, shiftcandssize) );
728  }
729  shiftcands[nshiftcands] = vars[i];
730  shiftvals[nshiftcands] = shiftval;
731  nshiftcands++;
732  }
733  }
734  }
735 
736  /* if at least one variable can be shifted, shift variables sorted by their objective */
737  if( nshiftcands > 0 )
738  {
739  SCIP_Real shiftval;
740  SCIP_Real solval;
741  SCIP_VAR* var;
742 
743  /* the case that exactly one variable can be shifted is slightly easier */
744  if( nshiftcands == 1 )
745  {
746  var = shiftcands[0];
747  assert(var != NULL);
748  solval = SCIPgetSolVal(scip, worksol, var);
749  shiftval = shiftvals[0];
750  assert(!SCIPisFeasZero(scip,shiftval));
751  SCIPdebugMsg(scip, " Only one shiftcand found, var <%s>, which is now shifted by<%1.1f> \n",
752  SCIPvarGetName(var), shiftval);
753  SCIP_CALL( SCIPsetSolVal(scip, worksol, var, solval+shiftval) );
754  SCIP_CALL( updateRowActivities(scip, activities, var, shiftval) );
755  ++nsuccessfulshifts;
756  }
757  else
758  {
759  SCIP_Real* objcoeffs;
760 
761  SCIP_CALL( SCIPallocBufferArray(scip, &objcoeffs, nshiftcands) );
762 
763  SCIPdebugMsg(scip, " %d shiftcands found \n", nshiftcands);
764 
765  /* sort the variables by their objective, optionally weighted with the shiftval */
766  if( heurdata->weightedobj )
767  {
768  for( i = 0; i < nshiftcands; ++i )
769  objcoeffs[i] = SCIPvarGetObj(shiftcands[i])*shiftvals[i];
770  }
771  else
772  {
773  for( i = 0; i < nshiftcands; ++i )
774  objcoeffs[i] = SCIPvarGetObj(shiftcands[i]);
775  }
776 
777  /* sort arrays with respect to the first one */
778  SCIPsortRealPtr(objcoeffs, (void**)shiftcands, nshiftcands);
779 
780  /* try to shift each variable -> Activities have to be updated */
781  for( i = 0; i < nshiftcands; ++i )
782  {
783  var = shiftcands[i];
784  assert(var != NULL);
785  solval = SCIPgetSolVal(scip, worksol, var);
786  shiftval = calcShiftVal(scip, var, solval, activities);
787  assert(i > 0 || !SCIPisFeasZero(scip, shiftval));
788  assert(SCIPisFeasGE(scip, solval+shiftval, SCIPvarGetLbGlobal(var)) && SCIPisFeasLE(scip, solval+shiftval, SCIPvarGetUbGlobal(var)));
789 
790  /* update data structures for nonzero shift value */
791  if( ! SCIPisFeasZero(scip, shiftval) )
792  {
793  SCIPdebugMsg(scip, " -> Variable <%s> is now shifted by <%1.1f> \n", SCIPvarGetName(vars[i]), shiftval);
794  SCIP_CALL( SCIPsetSolVal(scip, worksol, var, solval+shiftval) );
795  SCIP_CALL( updateRowActivities(scip, activities, var, shiftval) );
796  ++nsuccessfulshifts;
797  }
798  }
799 
800  SCIPfreeBufferArray(scip, &objcoeffs);
801  }
802  shifted = TRUE;
803  }
804 
805  } while( heurdata->useloop && shifted );
806 
807  if( nsuccessfulshifts > 0 )
808  {
809  /* if the problem is a pure IP, try to install the solution, if it is a MIP, solve LP again to set the continuous
810  * variables to the best possible value
811  */
812  if( nvars == nintvars || !SCIPhasCurrentNodeLP(scip) || SCIPgetLPSolstat(scip) != SCIP_LPSOLSTAT_OPTIMAL )
813  {
814  SCIP_Bool success;
815 
816  /* since we ignore local rows, we cannot guarantee their feasibility and have to set the checklprows flag to
817  * TRUE if local rows are present
818  */
819  SCIP_CALL( SCIPtrySol(scip, worksol, FALSE, FALSE, FALSE, FALSE, localrows, &success) );
820 
821  if( success )
822  {
823  SCIPdebugMsg(scip, "found feasible shifted solution:\n");
824  SCIPdebug( SCIP_CALL( SCIPprintSol(scip, worksol, NULL, FALSE) ) );
825  *result = SCIP_FOUNDSOL;
826  }
827  }
828  else
829  {
830  SCIP_Bool lperror;
831 #ifdef NDEBUG
832  SCIP_RETCODE retstat;
833 #endif
834 
835  SCIPdebugMsg(scip, "shifted solution should be feasible -> solve LP to fix continuous variables to best values\n");
836 
837  /* start diving to calculate the LP relaxation */
839 
840  /* set the bounds of the variables: fixed for integers, global bounds for continuous */
841  for( i = 0; i < nvars; ++i )
842  {
843  if( SCIPvarGetStatus(vars[i]) == SCIP_VARSTATUS_COLUMN )
844  {
845  SCIP_CALL( SCIPchgVarLbDive(scip, vars[i], SCIPvarGetLbGlobal(vars[i])) );
846  SCIP_CALL( SCIPchgVarUbDive(scip, vars[i], SCIPvarGetUbGlobal(vars[i])) );
847  }
848  }
849  /* apply this after global bounds to not cause an error with intermediate empty domains */
850  for( i = 0; i < nintvars; ++i )
851  {
852  if( SCIPvarGetStatus(vars[i]) == SCIP_VARSTATUS_COLUMN )
853  {
854  SCIP_Real solval;
855  solval = SCIPgetSolVal(scip, worksol, vars[i]);
856  SCIP_CALL( SCIPchgVarLbDive(scip, vars[i], solval) );
857  SCIP_CALL( SCIPchgVarUbDive(scip, vars[i], solval) );
858  }
859  }
860 
861  /* solve LP */
862  SCIPdebugMsg(scip, " -> old LP iterations: %" SCIP_LONGINT_FORMAT "\n", SCIPgetNLPIterations(scip));
863 
864  /**@todo in case of an MINLP, if SCIPisNLPConstructed() is TRUE, say, rather solve the NLP instead of the LP */
865  /* Errors in the LP solver should not kill the overall solving process, if the LP is just needed for a heuristic.
866  * Hence in optimized mode, the return code is caught and a warning is printed, only in debug mode, SCIP will stop.
867  */
868 #ifdef NDEBUG
869  retstat = SCIPsolveDiveLP(scip, -1, &lperror, NULL);
870  if( retstat != SCIP_OKAY )
871  {
872  SCIPwarningMessage(scip, "Error while solving LP in 1-opt heuristic; LP solve terminated with code <%d>\n",retstat);
873  }
874 #else
875  SCIP_CALL( SCIPsolveDiveLP(scip, -1, &lperror, NULL) );
876 #endif
877 
878  SCIPdebugMsg(scip, " -> new LP iterations: %" SCIP_LONGINT_FORMAT "\n", SCIPgetNLPIterations(scip));
879  SCIPdebugMsg(scip, " -> error=%u, status=%d\n", lperror, SCIPgetLPSolstat(scip));
880 
881  /* check if this is a feasible solution */
882  if( !lperror && SCIPgetLPSolstat(scip) == SCIP_LPSOLSTAT_OPTIMAL )
883  {
884  SCIP_Bool success;
885 
886  /* copy the current LP solution to the working solution */
887  SCIP_CALL( SCIPlinkLPSol(scip, worksol) );
888  SCIP_CALL( SCIPtrySol(scip, worksol, FALSE, FALSE, FALSE, FALSE, FALSE, &success) );
889 
890  /* check solution for feasibility */
891  if( success )
892  {
893  SCIPdebugMsg(scip, "found feasible shifted solution:\n");
894  SCIPdebug( SCIP_CALL( SCIPprintSol(scip, worksol, NULL, FALSE) ) );
895  *result = SCIP_FOUNDSOL;
896  }
897  }
898 
899  /* terminate the diving */
901  }
902  }
903 
904  /* heuristic should not rerun on this incumbent because the heuristic loop finishes only after no further
905  * improvements of the incumbent solution are possible
906  */
907  if( heurdata->useloop )
908  heurdata->lastsolindex = SCIPsolGetIndex(SCIPgetBestSol(scip));
909 
910  SCIPfreeBufferArray(scip, &shiftvals);
911  SCIPfreeBufferArray(scip, &shiftcands);
912  SCIPfreeBufferArray(scip, &activities);
913 
914  SCIP_CALL( SCIPfreeSol(scip, &worksol) );
915 
916  SCIPdebugMsg(scip, "Finished 1-opt heuristic\n");
917 
918  return SCIP_OKAY;
919 }
920 
921 /*
922  * primal heuristic specific interface methods
923  */
924 
925 /** creates the oneopt primal heuristic and includes it in SCIP */
927  SCIP* scip /**< SCIP data structure */
928  )
929 {
930  SCIP_HEURDATA* heurdata;
931  SCIP_HEUR* heur;
932 
933  /* create Oneopt primal heuristic data */
934  SCIP_CALL( SCIPallocBlockMemory(scip, &heurdata) );
935 
936  /* include primal heuristic */
937  SCIP_CALL( SCIPincludeHeurBasic(scip, &heur,
939  HEUR_MAXDEPTH, HEUR_TIMING, HEUR_USESSUBSCIP, heurExecOneopt, heurdata) );
940 
941  assert(heur != NULL);
942 
943  /* set non-NULL pointers to callback methods */
944  SCIP_CALL( SCIPsetHeurCopy(scip, heur, heurCopyOneopt) );
945  SCIP_CALL( SCIPsetHeurFree(scip, heur, heurFreeOneopt) );
946  SCIP_CALL( SCIPsetHeurInitsol(scip, heur, heurInitsolOneopt) );
947  SCIP_CALL( SCIPsetHeurExitsol(scip, heur, heurExitsolOneopt) );
948  SCIP_CALL( SCIPsetHeurInit(scip, heur, heurInitOneopt) );
949 
950  /* add oneopt primal heuristic parameters */
951  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/oneopt/weightedobj",
952  "should the objective be weighted with the potential shifting value when sorting the shifting candidates?",
953  &heurdata->weightedobj, TRUE, DEFAULT_WEIGHTEDOBJ, NULL, NULL) );
954 
955  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/oneopt/duringroot",
956  "should the heuristic be called before and during the root node?",
957  &heurdata->duringroot, TRUE, DEFAULT_DURINGROOT, NULL, NULL) );
958 
959  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/oneopt/forcelpconstruction",
960  "should the construction of the LP be forced even if LP solving is deactivated?",
961  &heurdata->forcelpconstruction, TRUE, DEFAULT_FORCELPCONSTRUCTION, NULL, NULL) );
962 
963  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/oneopt/beforepresol",
964  "should the heuristic be called before presolving?",
965  &heurdata->beforepresol, TRUE, DEFAULT_BEFOREPRESOL, NULL, NULL) );
966 
967  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/oneopt/useloop",
968  "should the heuristic continue to run as long as improvements are found?",
969  &heurdata->useloop, TRUE, DEFAULT_USELOOP, NULL, NULL) );
970 
971  return SCIP_OKAY;
972 }
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:52
SCIP_Bool SCIPsolIsOriginal(SCIP_SOL *sol)
Definition: sol.c:2465
SCIP_RETCODE SCIPsetHeurExitsol(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEUREXITSOL((*heurexitsol)))
Definition: scip.c:8209
#define HEUR_DISPCHAR
Definition: heur_oneopt.c:34
SCIP_Bool SCIPisFeasZero(SCIP *scip, SCIP_Real val)
Definition: scip.c:47363
#define SCIP_HEURTIMING_DURINGLPLOOP
Definition: type_timing.h:71
#define DEFAULT_BEFOREPRESOL
Definition: heur_oneopt.c:44
SCIP_RETCODE SCIPlinkLPSol(SCIP *scip, SCIP_SOL *sol)
Definition: scip.c:38576
SCIP_RETCODE SCIPsetSeparating(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
Definition: scip.c:5158
#define DEFAULT_WEIGHTEDOBJ
Definition: heur_oneopt.c:42
Improvement heuristic that alters single variable values.
SCIP_NODE * SCIPgetCurrentNode(SCIP *scip)
Definition: scip.c:41404
SCIP_Longint SCIPgetNLPIterations(SCIP *scip)
Definition: scip.c:42333
SCIP_Bool SCIPisFeasLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip.c:47311
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
Definition: var.c:17276
#define DEFAULT_DURINGROOT
Definition: heur_oneopt.c:43
SCIP_Real * SCIPcolGetVals(SCIP_COL *col)
Definition: lp.c:16363
static SCIP_RETCODE setupAndSolveSubscipOneopt(SCIP *scip, SCIP *subscip, SCIP_HEUR *heur, SCIP_VAR **vars, SCIP_VAR **subvars, SCIP_SOL *bestsol, SCIP_RESULT *result, SCIP_Bool *valid)
Definition: heur_oneopt.c:263
int SCIPgetNOrigVars(SCIP *scip)
Definition: scip.c:12252
#define SCIP_HEURTIMING_BEFORENODE
Definition: type_timing.h:70
const char * SCIProwGetName(SCIP_ROW *row)
Definition: lp.c:16543
SCIP_Bool SCIPisFeasGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip.c:47350
SCIP_RETCODE SCIPgetVarsData(SCIP *scip, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars)
Definition: scip.c:11686
SCIP_RETCODE SCIPsetHeuristics(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
Definition: scip.c:5106
#define DEFAULT_FORCELPCONSTRUCTION
Definition: heur_oneopt.c:45
SCIP_SOL ** SCIPgetSols(SCIP *scip)
Definition: scip.c:39832
SCIP_Real SCIProwGetLhs(SCIP_ROW *row)
Definition: lp.c:16484
#define FALSE
Definition: def.h:64
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
Definition: misc.c:2793
SCIP_RETCODE SCIPcopyLimits(SCIP *sourcescip, SCIP *targetscip)
Definition: scip.c:4192
SCIP_RETCODE SCIPcutoffNode(SCIP *scip, SCIP_NODE *node)
Definition: scip.c:41747
SCIP_Real SCIPinfinity(SCIP *scip)
Definition: scip.c:47028
#define TRUE
Definition: def.h:63
#define SCIPdebug(x)
Definition: pub_message.h:74
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
#define HEUR_DESC
Definition: heur_oneopt.c:33
SCIP_RETCODE SCIPsetPresolving(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
Definition: scip.c:5132
int SCIPheurGetFreqofs(SCIP_HEUR *heur)
Definition: heur.c:1304
SCIP_RETCODE SCIPchgVarLbDive(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
Definition: scip.c:35445
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
void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin)
Definition: misc.c:2931
SCIP_RETCODE SCIPconstructLP(SCIP *scip, SCIP_Bool *cutoff)
Definition: scip.c:29249
static SCIP_Real calcShiftVal(SCIP *scip, SCIP_VAR *var, SCIP_Real solval, SCIP_Real *activities)
Definition: heur_oneopt.c:115
#define SCIPfreeBufferArray(scip, ptr)
Definition: scip.h:22632
SCIP_RETCODE SCIPcreate(SCIP **scip)
Definition: scip.c:748
void SCIPheurSetData(SCIP_HEUR *heur, SCIP_HEURDATA *heurdata)
Definition: heur.c:1119
#define SCIPallocBlockMemory(scip, ptr)
Definition: scip.h:22585
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
Definition: scip.c:1267
#define SCIPdebugMsg
Definition: scip.h:455
SCIP_RETCODE SCIPprintStatistics(SCIP *scip, FILE *file)
Definition: scip.c:45651
SCIP_RETCODE SCIPcreateOrigSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip.c:38115
SCIP_Real SCIPfeasFloor(SCIP *scip, SCIP_Real val)
Definition: scip.c:47423
SCIP_Bool SCIProwIsInLP(SCIP_ROW *row)
Definition: lp.c:16695
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
Definition: var.c:17286
#define HEUR_MAXDEPTH
Definition: heur_oneopt.c:38
SCIP_RETCODE SCIPcreateSolCopy(SCIP *scip, SCIP_SOL **sol, SCIP_SOL *sourcesol)
Definition: scip.c:38168
SCIP_RETCODE SCIPsetHeurInitsol(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURINITSOL((*heurinitsol)))
Definition: scip.c:8193
SCIP_RETCODE SCIPsolve(SCIP *scip)
Definition: scip.c:16115
const char * SCIPheurGetName(SCIP_HEUR *heur)
Definition: heur.c:1198
SCIP_Bool SCIPisParamFixed(SCIP *scip, const char *name)
Definition: scip.c:4401
SCIP_RETCODE SCIPsolveDiveLP(SCIP *scip, int itlim, SCIP_Bool *lperror, SCIP_Bool *cutoff)
Definition: scip.c:35704
SCIP_RETCODE SCIPsetHeurFree(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURFREE((*heurfree)))
Definition: scip.c:8145
SCIP_ROW ** SCIPcolGetRows(SCIP_COL *col)
Definition: lp.c:16353
SCIP_RETCODE SCIPgetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
Definition: scip.c:38948
SCIP_Bool SCIProwIsLocal(SCIP_ROW *row)
Definition: lp.c:16593
SCIP_RETCODE SCIPsetBoolParam(SCIP *scip, const char *name, SCIP_Bool value)
Definition: scip.c:4630
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
Definition: scip.c:46731
static SCIP_DECL_HEURCOPY(heurCopyOneopt)
Definition: heur_oneopt.c:402
const char * SCIPvarGetName(SCIP_VAR *var)
Definition: var.c:16662
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
Definition: misc.c:2826
static SCIP_RETCODE updateRowActivities(SCIP *scip, SCIP_Real *activities, SCIP_VAR *var, SCIP_Real shiftval)
Definition: heur_oneopt.c:213
SCIP_RETCODE SCIPunfixParam(SCIP *scip, const char *name)
Definition: scip.c:4567
int SCIPgetNLPRows(SCIP *scip)
Definition: scip.c:29696
#define SCIP_CALL(x)
Definition: def.h:350
SCIP_Bool SCIPisFeasGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip.c:47337
SCIP_Bool SCIPisFeasLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip.c:47324
static SCIP_DECL_HEUREXITSOL(heurExitsolOneopt)
Definition: heur_oneopt.c:455
SCIP_Real SCIProwGetRhs(SCIP_ROW *row)
Definition: lp.c:16494
#define SCIP_HEURTIMING_BEFOREPRESOL
Definition: type_timing.h:86
#define DEFAULT_USELOOP
Definition: heur_oneopt.c:46
#define HEUR_FREQ
Definition: heur_oneopt.c:36
SCIP_Bool SCIPhasCurrentNodeLP(SCIP *scip)
Definition: scip.c:29208
#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
#define HEUR_USESSUBSCIP
Definition: heur_oneopt.c:40
#define SCIP_Bool
Definition: def.h:61
#define HEUR_PRIORITY
Definition: heur_oneopt.c:35
SCIP_LPSOLSTAT SCIPgetLPSolstat(SCIP *scip)
Definition: scip.c:29293
SCIP_RETCODE SCIPchgVarUbDive(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
Definition: scip.c:35477
#define HEUR_FREQOFS
Definition: heur_oneopt.c:37
void SCIPsolSetHeur(SCIP_SOL *sol, SCIP_HEUR *heur)
Definition: sol.c:2589
#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
SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value)
Definition: scip.c:4688
SCIP_RETCODE SCIPfreeSol(SCIP *scip, SCIP_SOL **sol)
Definition: scip.c:38535
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
Definition: var.c:17124
static SCIP_DECL_HEUREXEC(heurExecOneopt)
Definition: heur_oneopt.c:487
int SCIPgetNSols(SCIP *scip)
Definition: scip.c:39783
SCIP_COL * SCIPvarGetCol(SCIP_VAR *var)
Definition: var.c:16990
SCIP_RETCODE SCIPflushLP(SCIP *scip)
Definition: scip.c:29273
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
Definition: scip.c:47039
SCIP_Real SCIPgetRowSolActivity(SCIP *scip, SCIP_ROW *row, SCIP_SOL *sol)
Definition: scip.c:31111
SCIP_RETCODE SCIPtrySol(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:40700
int SCIPgetNVars(SCIP *scip)
Definition: scip.c:11812
static SCIP_DECL_HEURINIT(heurInitOneopt)
Definition: heur_oneopt.c:468
SCIP_SOL * SCIPgetBestSol(SCIP *scip)
Definition: scip.c:39882
static SCIP_RETCODE createNewSol(SCIP *scip, SCIP *subscip, SCIP_VAR **subvars, SCIP_HEUR *heur, SCIP_SOL *subsol, SCIP_Bool *success)
Definition: heur_oneopt.c:69
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:3795
SCIP_RETCODE SCIPsetHeurInit(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURINIT((*heurinit)))
Definition: scip.c:8161
#define HEUR_TIMING
Definition: heur_oneopt.c:39
SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
Definition: var.c:16781
int SCIProwGetLPPos(SCIP_ROW *row)
Definition: lp.c:16673
#define SCIP_Real
Definition: def.h:149
void SCIPheurSetTimingmask(SCIP_HEUR *heur, SCIP_HEURTIMING timingmask)
Definition: heur.c:1238
#define HEUR_NAME
Definition: heur_oneopt.c:32
SCIP_RETCODE SCIPprintRow(SCIP *scip, SCIP_ROW *row, FILE *file)
Definition: scip.c:31160
static SCIP_DECL_HEURFREE(heurFreeOneopt)
Definition: heur_oneopt.c:416
void SCIPsortRealPtr(SCIP_Real *realarray, void **ptrarray, int len)
SCIP_RETCODE SCIPcheckCopyLimits(SCIP *sourcescip, SCIP_Bool *success)
Definition: scip.c:4156
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
Definition: var.c:16827
SCIP_RETCODE SCIPstartDive(SCIP *scip)
Definition: scip.c:35268
SCIP_RETCODE SCIPsetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
Definition: scip.c:38813
SCIP_RETCODE SCIPtransformProb(SCIP *scip)
Definition: scip.c:13935
static SCIP_DECL_HEURINITSOL(heurInitsolOneopt)
Definition: heur_oneopt.c:436
SCIP_RETCODE SCIPsetHeurCopy(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURCOPY((*heurcopy)))
Definition: scip.c:8129
SCIP_RETCODE SCIPincludeHeurOneopt(SCIP *scip)
Definition: heur_oneopt.c:926
SCIP_RETCODE SCIPgetLPRowsData(SCIP *scip, SCIP_ROW ***rows, int *nrows)
Definition: scip.c:29640
SCIP_RETCODE SCIPendDive(SCIP *scip)
Definition: scip.c:35317
#define SCIP_CALL_ABORT(x)
Definition: def.h:329
SCIP_HEURDATA * SCIPheurGetData(SCIP_HEUR *heur)
Definition: heur.c:1109
SCIP_Longint SCIPgetNNodes(SCIP *scip)
Definition: scip.c:42133
int SCIPcolGetNLPNonz(SCIP_COL *col)
Definition: lp.c:16342
SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
Definition: scip.c:38911
int SCIPsolGetIndex(SCIP_SOL *sol)
Definition: sol.c:2579
SCIP_RETCODE SCIPsetLongintParam(SCIP *scip, const char *name, SCIP_Longint value)
Definition: scip.c:4746
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:4239
SCIP_RETCODE SCIPfree(SCIP **scip)
Definition: scip.c:780
SCIP_RETCODE SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip.c:37878
#define SCIPreallocBufferArray(scip, ptr, num)
Definition: scip.h:22624
SCIP_RETCODE SCIPprintSol(SCIP *scip, SCIP_SOL *sol, FILE *file, SCIP_Bool printzeros)
Definition: scip.c:39325