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 2002-2022 Zuse Institute Berlin */
7 /* */
8 /* Licensed under the Apache License, Version 2.0 (the "License"); */
9 /* you may not use this file except in compliance with the License. */
10 /* You may obtain a copy of the License at */
11 /* */
12 /* http://www.apache.org/licenses/LICENSE-2.0 */
13 /* */
14 /* Unless required by applicable law or agreed to in writing, software */
15 /* distributed under the License is distributed on an "AS IS" BASIS, */
16 /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17 /* See the License for the specific language governing permissions and */
18 /* limitations under the License. */
19 /* */
20 /* You should have received a copy of the Apache-2.0 license */
21 /* along with SCIP; see the file LICENSE. If not visit scipopt.org. */
22 /* */
23 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24 
25 /**@file heur_oneopt.c
26  * @ingroup DEFPLUGINS_HEUR
27  * @brief improvement heuristic that alters single variable values
28  * @author Timo Berthold
29  */
30 
31 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
32 
33 #include "blockmemshell/memory.h"
34 #include "scip/heur_oneopt.h"
35 #include "scip/pub_heur.h"
36 #include "scip/pub_lp.h"
37 #include "scip/pub_message.h"
38 #include "scip/pub_misc.h"
39 #include "scip/pub_misc_sort.h"
40 #include "scip/pub_sol.h"
41 #include "scip/pub_var.h"
42 #include "scip/scip_copy.h"
43 #include "scip/scip_general.h"
44 #include "scip/scip_heur.h"
45 #include "scip/scip_lp.h"
46 #include "scip/scip_mem.h"
47 #include "scip/scip_message.h"
48 #include "scip/scip_numerics.h"
49 #include "scip/scip_param.h"
50 #include "scip/scip_prob.h"
51 #include "scip/scip_sol.h"
52 #include "scip/scip_solve.h"
53 #include "scip/scip_solvingstats.h"
54 #include "scip/scip_tree.h"
55 #include <string.h>
56 
57 /* @note If the heuristic runs in the root node, the timing is changed to (SCIP_HEURTIMING_DURINGLPLOOP |
58  * SCIP_HEURTIMING_BEFORENODE), see SCIP_DECL_HEURINITSOL callback.
59  */
60 
61 #define HEUR_NAME "oneopt"
62 #define HEUR_DESC "1-opt heuristic which tries to improve setting of single integer variables"
63 #define HEUR_DISPCHAR SCIP_HEURDISPCHAR_ITERATIVE
64 #define HEUR_PRIORITY -20000
65 #define HEUR_FREQ 1
66 #define HEUR_FREQOFS 0
67 #define HEUR_MAXDEPTH -1
68 #define HEUR_TIMING SCIP_HEURTIMING_BEFOREPRESOL | SCIP_HEURTIMING_AFTERNODE
69 #define HEUR_USESSUBSCIP FALSE /**< does the heuristic use a secondary SCIP instance? */
70 
71 #define DEFAULT_WEIGHTEDOBJ TRUE /**< should the objective be weighted with the potential shifting value when sorting the shifting candidates? */
72 #define DEFAULT_DURINGROOT TRUE /**< should the heuristic be called before and during the root node? */
73 #define DEFAULT_BEFOREPRESOL FALSE /**< should the heuristic be called before presolving */
74 #define DEFAULT_FORCELPCONSTRUCTION FALSE /**< should the construction of the LP be forced even if LP solving is deactivated? */
75 #define DEFAULT_USELOOP TRUE /**< should the heuristic continue to run as long as improvements are found? */
76 /*
77  * Data structures
78  */
79 
80 /** primal heuristic data */
81 struct SCIP_HeurData
82 {
83  int lastsolindex; /**< index of the last solution for which oneopt was performed */
84  SCIP_Bool weightedobj; /**< should the objective be weighted with the potential shifting value when sorting the shifting candidates? */
85  SCIP_Bool duringroot; /**< should the heuristic be called before and during the root node? */
86  SCIP_Bool forcelpconstruction;/**< should the construction of the LP be forced even if LP solving is deactivated? */
87  SCIP_Bool beforepresol; /**< should the heuristic be called before presolving */
88  SCIP_Bool useloop; /**< should the heuristic continue to run as long as improvements are found? */
89 };
90 
91 
92 /*
93  * Local methods
94  */
95 
96 /** compute value by which the solution of variable @p var can be shifted */
97 static
99  SCIP* scip, /**< SCIP data structure */
100  SCIP_VAR* var, /**< variable that should be shifted */
101  SCIP_Real solval, /**< current solution value */
102  SCIP_Real* activities /**< LP row activities */
103  )
104 {
105  SCIP_Real lb;
106  SCIP_Real ub;
107  SCIP_Real obj;
108  SCIP_Real shiftval;
109 
110  SCIP_COL* col;
111  SCIP_ROW** colrows;
112  SCIP_Real* colvals;
113  SCIP_Bool shiftdown;
114 
115  int ncolrows;
116  int i;
117 
118  /* get variable's solution value, global bounds and objective coefficient */
119  lb = SCIPvarGetLbGlobal(var);
120  ub = SCIPvarGetUbGlobal(var);
121  obj = SCIPvarGetObj(var);
122  shiftdown = TRUE;
123 
124  /* determine shifting direction and maximal possible shifting w.r.t. corresponding bound */
125  if( obj > 0.0 && SCIPisFeasGE(scip, solval - 1.0, lb) )
126  shiftval = SCIPfeasFloor(scip, solval - lb);
127  else if( obj < 0.0 && SCIPisFeasLE(scip, solval + 1.0, ub) )
128  {
129  shiftval = SCIPfeasFloor(scip, ub - solval);
130  shiftdown = FALSE;
131  }
132  else
133  return 0.0;
134 
135  SCIPdebugMsg(scip, "Try to shift %s variable <%s> with\n", shiftdown ? "down" : "up", SCIPvarGetName(var) );
136  SCIPdebugMsg(scip, " lb:<%g> <= val:<%g> <= ub:<%g> and obj:<%g> by at most: <%g>\n", lb, solval, ub, obj, shiftval);
137 
138  /* get data of LP column */
139  col = SCIPvarGetCol(var);
140  colrows = SCIPcolGetRows(col);
141  colvals = SCIPcolGetVals(col);
142  ncolrows = SCIPcolGetNLPNonz(col);
143 
144  assert(ncolrows == 0 || (colrows != NULL && colvals != NULL));
145 
146  /* find minimal shift value, st. all rows stay valid */
147  for( i = 0; i < ncolrows && shiftval > 0.0; ++i )
148  {
149  SCIP_ROW* row;
150  int rowpos;
151 
152  row = colrows[i];
153  rowpos = SCIProwGetLPPos(row);
154  assert(-1 <= rowpos && rowpos < SCIPgetNLPRows(scip) );
155 
156  /* only global rows need to be valid */
157  if( rowpos >= 0 && !SCIProwIsLocal(row) )
158  {
159  SCIP_Real shiftvalrow;
160 
161  assert(SCIProwIsInLP(row));
162 
163  if( shiftdown == (colvals[i] > 0) )
164  shiftvalrow = SCIPfeasFloor(scip, (activities[rowpos] - SCIProwGetLhs(row)) / ABS(colvals[i]));
165  else
166  shiftvalrow = SCIPfeasFloor(scip, (SCIProwGetRhs(row) - activities[rowpos]) / ABS(colvals[i]));
167 #ifdef SCIP_DEBUG
168  if( shiftvalrow < shiftval )
169  {
170  SCIPdebugMsg(scip, " -> The shift value had to be reduced to <%g>, because of row <%s>.\n",
171  shiftvalrow, SCIProwGetName(row));
172  SCIPdebugMsg(scip, " lhs:<%g> <= act:<%g> <= rhs:<%g>, colval:<%g>\n",
173  SCIProwGetLhs(row), activities[rowpos], SCIProwGetRhs(row), colvals[i]);
174  }
175 #endif
176  shiftval = MIN(shiftval, shiftvalrow);
177  /* shiftvalrow might be negative, if we detected infeasibility -> make sure that shiftval is >= 0 */
178  shiftval = MAX(shiftval, 0.0);
179  }
180  }
181  if( shiftdown )
182  shiftval *= -1.0;
183 
184  /* we must not shift variables to infinity */
185  if( SCIPisInfinity(scip, solval + shiftval) )
186  shiftval = 0.0;
187 
188  return shiftval;
189 }
190 
191 
192 /** update row activities after a variable's solution value changed */
193 static
195  SCIP* scip, /**< SCIP data structure */
196  SCIP_Real* activities, /**< LP row activities */
197  SCIP_VAR* var, /**< variable that has been changed */
198  SCIP_Real shiftval /**< value that is added to variable */
199  )
200 {
201  SCIP_Real* colvals;
202  SCIP_ROW** colrows;
203  SCIP_COL* col;
204 
205  int ncolrows;
206  int i;
207 
208  assert(activities != NULL);
209 
210  /* get data of column associated to variable */
211  col = SCIPvarGetCol(var);
212  colrows = SCIPcolGetRows(col);
213  colvals = SCIPcolGetVals(col);
214  ncolrows = SCIPcolGetNLPNonz(col);
215  assert(ncolrows == 0 || (colrows != NULL && colvals != NULL));
216 
217  /* enumerate all rows with nonzero entry in this column */
218  for( i = 0; i < ncolrows; ++i )
219  {
220  SCIP_ROW* row;
221  int rowpos;
222 
223  row = colrows[i];
224  rowpos = SCIProwGetLPPos(row);
225  assert(-1 <= rowpos && rowpos < SCIPgetNLPRows(scip) );
226 
227  /* update row activity, only regard global rows in the LP */
228  if( rowpos >= 0 && !SCIProwIsLocal(row) )
229  {
230  activities[rowpos] += shiftval * colvals[i];
231 
232  if( SCIPisInfinity(scip, activities[rowpos]) )
233  activities[rowpos] = SCIPinfinity(scip);
234  else if( SCIPisInfinity(scip, -activities[rowpos]) )
235  activities[rowpos] = -SCIPinfinity(scip);
236  }
237  }
238 
239  return SCIP_OKAY;
240 }
241 
242 /** setup and solve oneopt sub-SCIP */
243 static
245  SCIP* scip, /**< SCIP data structure */
246  SCIP* subscip, /**< sub-SCIP data structure */
247  SCIP_HEUR* heur, /**< oneopt heuristic */
248  SCIP_VAR** vars, /**< SCIP variables */
249  SCIP_VAR** subvars, /**< subproblem's variables */
250  SCIP_SOL* bestsol, /**< incumbent solution */
251  SCIP_RESULT* result, /**< pointer to store the result */
252  SCIP_Bool* valid /**< pointer to store the valid value */
253  )
254 {
255  SCIP_HASHMAP* varmapfw; /* mapping of SCIP variables to sub-SCIP variables */
256  SCIP_SOL* startsol;
257  int nvars; /* number of original problem's variables */
258  int i;
259 
260  assert(scip != NULL);
261  assert(subscip != NULL);
262  assert(heur != NULL);
263 
264  nvars = SCIPgetNVars(scip);
265 
266  /* create the variable mapping hash map */
267  SCIP_CALL( SCIPhashmapCreate(&varmapfw, SCIPblkmem(subscip), nvars) );
268 
269  /* copy complete SCIP instance */
270  *valid = FALSE;
271  SCIP_CALL( SCIPcopy(scip, subscip, varmapfw, NULL, "oneopt", TRUE, FALSE, FALSE, TRUE, valid) );
272  SCIP_CALL( SCIPtransformProb(subscip) );
273 
274  /* get variable image and create start solution for the subproblem */
275  SCIP_CALL( SCIPcreateOrigSol(subscip, &startsol, NULL) );
276  for( i = 0; i < nvars; i++ )
277  {
278  subvars[i] = (SCIP_VAR*) SCIPhashmapGetImage(varmapfw, vars[i]);
279  if( subvars[i] != NULL )
280  SCIP_CALL( SCIPsetSolVal(subscip, startsol, subvars[i], SCIPgetSolVal(scip, bestsol, vars[i])) );
281  }
282 
283  /* try to add new solution to sub-SCIP and free it immediately */
284  *valid = FALSE;
285  SCIP_CALL( SCIPtrySolFree(subscip, &startsol, FALSE, FALSE, FALSE, FALSE, FALSE, valid) );
286  SCIPhashmapFree(&varmapfw);
287 
288  /* deactivate basically everything except oneopt in the sub-SCIP */
292 
293  /* set limits for the subproblem */
294  SCIP_CALL( SCIPcopyLimits(scip, subscip) );
295  SCIP_CALL( SCIPsetLongintParam(subscip, "limits/nodes", 1LL) );
296 
297  SCIP_CALL( SCIPsetBoolParam(subscip, "misc/catchctrlc", FALSE) );
298 
299 #ifdef SCIP_DEBUG
300  /* for debugging, enable full output */
301  SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", 5) );
302  SCIP_CALL( SCIPsetIntParam(subscip, "display/freq", 100000000) );
303 #else
304  /* disable statistic timing inside sub SCIP and output to console */
305  SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", 0) );
306  SCIP_CALL( SCIPsetBoolParam(subscip, "timing/statistictiming", FALSE) );
307 #endif
308 
309  /* if necessary, some of the parameters have to be unfixed first */
310  if( SCIPisParamFixed(subscip, "lp/solvefreq") )
311  {
312  SCIPwarningMessage(scip, "unfixing parameter lp/solvefreq in subscip of oneopt heuristic\n");
313  SCIP_CALL( SCIPunfixParam(subscip, "lp/solvefreq") );
314  }
315  SCIP_CALL( SCIPsetIntParam(subscip, "lp/solvefreq", -1) );
316 
317  if( SCIPisParamFixed(subscip, "heuristics/oneopt/freq") )
318  {
319  SCIPwarningMessage(scip, "unfixing parameter heuristics/oneopt/freq in subscip of oneopt heuristic\n");
320  SCIP_CALL( SCIPunfixParam(subscip, "heuristics/oneopt/freq") );
321  }
322  SCIP_CALL( SCIPsetIntParam(subscip, "heuristics/oneopt/freq", 1) );
323 
324  if( SCIPisParamFixed(subscip, "heuristics/oneopt/forcelpconstruction") )
325  {
326  SCIPwarningMessage(scip, "unfixing parameter heuristics/oneopt/forcelpconstruction in subscip of oneopt heuristic\n");
327  SCIP_CALL( SCIPunfixParam(subscip, "heuristics/oneopt/forcelpconstruction") );
328  }
329  SCIP_CALL( SCIPsetBoolParam(subscip, "heuristics/oneopt/forcelpconstruction", TRUE) );
330 
331  /* avoid recursive call, which would lead to an endless loop */
332  if( SCIPisParamFixed(subscip, "heuristics/oneopt/beforepresol") )
333  {
334  SCIPwarningMessage(scip, "unfixing parameter heuristics/oneopt/beforepresol in subscip of oneopt heuristic\n");
335  SCIP_CALL( SCIPunfixParam(subscip, "heuristics/oneopt/beforepresol") );
336  }
337  SCIP_CALL( SCIPsetBoolParam(subscip, "heuristics/oneopt/beforepresol", FALSE) );
338 
339  /* speed up sub-SCIP by not checking dual LP feasibility */
340  SCIP_CALL( SCIPsetBoolParam(subscip, "lp/checkdualfeas", FALSE) );
341 
342  if( *valid )
343  {
344  /* errors in solving the subproblem should not kill the overall solving process;
345  * hence, the return code is caught and a warning is printed, only in debug mode, SCIP will stop.
346  */
347  SCIP_CALL_ABORT( SCIPsolve(subscip) );
348 
349 #ifdef SCIP_DEBUG
350  SCIP_CALL( SCIPprintStatistics(subscip, NULL) );
351 #endif
352 
353  /* check, whether a solution was found;
354  * due to numerics, it might happen that not all solutions are feasible -> try all solutions until one was accepted
355  */
356  SCIP_CALL( SCIPtranslateSubSols(scip, subscip, heur, subvars, valid, NULL) );
357  if( *valid )
358  *result = SCIP_FOUNDSOL;
359  }
360 
361  return SCIP_OKAY;
362 }
363 
364 /*
365  * Callback methods of primal heuristic
366  */
367 
368 /** copy method for primal heuristic plugins (called when SCIP copies plugins) */
369 static
370 SCIP_DECL_HEURCOPY(heurCopyOneopt)
371 { /*lint --e{715}*/
372  assert(scip != NULL);
373  assert(heur != NULL);
374  assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
375 
376  /* call inclusion method of primal heuristic */
378 
379  return SCIP_OKAY;
380 }
381 
382 /** destructor of primal heuristic to free user data (called when SCIP is exiting) */
383 static
384 SCIP_DECL_HEURFREE(heurFreeOneopt)
385 { /*lint --e{715}*/
386  SCIP_HEURDATA* heurdata;
387 
388  assert(heur != NULL);
389  assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
390  assert(scip != NULL);
391 
392  /* free heuristic data */
393  heurdata = SCIPheurGetData(heur);
394  assert(heurdata != NULL);
395  SCIPfreeBlockMemory(scip, &heurdata);
396  SCIPheurSetData(heur, NULL);
397 
398  return SCIP_OKAY;
399 }
400 
401 
402 /** solving process initialization method of primal heuristic (called when branch and bound process is about to begin) */
403 static
404 SCIP_DECL_HEURINITSOL(heurInitsolOneopt)
405 {
406  SCIP_HEURDATA* heurdata;
407 
408  assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
409 
410  /* create heuristic data */
411  heurdata = SCIPheurGetData(heur);
412  assert(heurdata != NULL);
413 
414  /* 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 */
415  if( heurdata->duringroot && SCIPheurGetFreqofs(heur) == 0 )
417 
418  return SCIP_OKAY;
419 }
420 
421 /** solving process deinitialization method of primal heuristic (called before branch and bound process data is freed) */
422 static
423 SCIP_DECL_HEUREXITSOL(heurExitsolOneopt)
424 {
425  assert(heur != NULL);
426  assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
427 
428  /* reset the timing mask to its default value */
430 
431  return SCIP_OKAY;
432 }
433 
434 /** initialization method of primal heuristic (called after problem was transformed) */
435 static
436 SCIP_DECL_HEURINIT(heurInitOneopt)
437 { /*lint --e{715}*/
438  SCIP_HEURDATA* heurdata;
439 
440  assert(heur != NULL);
441  assert(scip != NULL);
442 
443  /* get heuristic data */
444  heurdata = SCIPheurGetData(heur);
445  assert(heurdata != NULL);
446 
447  /* initialize last solution index */
448  heurdata->lastsolindex = -1;
449 
450  return SCIP_OKAY;
451 }
452 
453 /** execution method of primal heuristic */
454 static
455 SCIP_DECL_HEUREXEC(heurExecOneopt)
456 { /*lint --e{715}*/
457  SCIP_HEURDATA* heurdata;
458  SCIP_SOL* bestsol; /* incumbent solution */
459  SCIP_SOL* worksol; /* heuristic's working solution */
460  SCIP_VAR** vars; /* SCIP variables */
461  SCIP_VAR** shiftcands; /* shiftable variables */
462  SCIP_ROW** lprows; /* SCIP LP rows */
463  SCIP_Real* activities; /* row activities for working solution */
464  SCIP_Real* shiftvals;
465  SCIP_Bool shifted;
466 
467  SCIP_RETCODE retcode;
468 
469  SCIP_Real lb;
470  SCIP_Real ub;
471  SCIP_Bool localrows;
472  SCIP_Bool valid;
473  int nchgbound;
474  int nbinvars;
475  int nintvars;
476  int nvars;
477  int nlprows;
478  int i;
479  int nshiftcands;
480  int shiftcandssize;
481  int nsuccessfulshifts;
482  int niterations;
483 
484  assert(heur != NULL);
485  assert(scip != NULL);
486  assert(result != NULL);
487 
488  /* get heuristic's data */
489  heurdata = SCIPheurGetData(heur);
490  assert(heurdata != NULL);
491 
492  *result = SCIP_DELAYED;
493 
494  /* we only want to process each solution once */
495  bestsol = SCIPgetBestSol(scip);
496  if( bestsol == NULL || heurdata->lastsolindex == SCIPsolGetIndex(bestsol) )
497  return SCIP_OKAY;
498 
499  /* reset the timing mask to its default value (at the root node it could be different) */
500  if( SCIPgetNNodes(scip) > 1 )
502 
503  /* get problem variables */
504  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, &nbinvars, &nintvars, NULL, NULL) );
505  nintvars += nbinvars;
506 
507  /* do not run if there are no discrete variables */
508  if( nintvars == 0 )
509  {
510  *result = SCIP_DIDNOTRUN;
511  return SCIP_OKAY;
512  }
513 
514  if( heurtiming == SCIP_HEURTIMING_BEFOREPRESOL )
515  {
516  SCIP* subscip; /* the subproblem created by oneopt */
517  SCIP_VAR** subvars; /* subproblem's variables */
518 
519  SCIP_Bool success;
520 
521  if( !heurdata->beforepresol )
522  return SCIP_OKAY;
523 
524  /* check whether there is enough time and memory left */
525  SCIP_CALL( SCIPcheckCopyLimits(scip, &success) );
526 
527  if( !success )
528  return SCIP_OKAY;
529 
530  SCIP_CALL( SCIPallocBufferArray(scip, &subvars, nvars) );
531 
532  /* initialize the subproblem */
533  SCIP_CALL( SCIPcreate(&subscip) );
534 
535  /* setup and solve the subproblem and catch the return code */
536  retcode = setupAndSolveSubscipOneopt(scip, subscip, heur, vars, subvars, bestsol, result, &valid);
537 
538  /* free the subscip in any case */
539  SCIP_CALL( SCIPfree(&subscip) );
540  SCIP_CALL( retcode );
541 
542  SCIPfreeBufferArray(scip, &subvars);
543 
544  return SCIP_OKAY;
545  }
546 
547  /* we can only work on solutions valid in the transformed space */
548  if( SCIPsolIsOriginal(bestsol) )
549  return SCIP_OKAY;
550 
551  if( heurtiming == SCIP_HEURTIMING_BEFORENODE && (SCIPhasCurrentNodeLP(scip) || heurdata->forcelpconstruction) )
552  {
553  SCIP_Bool cutoff;
554 
555  SCIP_CALL( SCIPconstructLP(scip, &cutoff) );
556 
557  /* manually cut off the node if the LP construction detected infeasibility (heuristics cannot return such a result) */
558  if( cutoff )
559  {
561  return SCIP_OKAY;
562  }
563 
565 
566  /* get problem variables again, SCIPconstructLP() might have added new variables */
567  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, &nbinvars, &nintvars, NULL, NULL) );
568  nintvars += nbinvars;
569  }
570 
571  /* we need an LP */
572  if( SCIPgetNLPRows(scip) == 0 )
573  return SCIP_OKAY;
574 
575  *result = SCIP_DIDNOTFIND;
576 
577  heurdata->lastsolindex = SCIPsolGetIndex(bestsol);
578  SCIP_CALL( SCIPcreateSolCopy(scip, &worksol, bestsol) );
579  SCIPsolSetHeur(worksol,heur);
580 
581  SCIPdebugMsg(scip, "Starting bound adjustment in 1-opt heuristic\n");
582 
583  nchgbound = 0;
584  /* change solution values due to possible global bound changes first */
585  for( i = nvars - 1; i >= 0; --i )
586  {
587  SCIP_VAR* var;
588  SCIP_Real solval;
589 
590  var = vars[i];
591  lb = SCIPvarGetLbGlobal(var);
592  ub = SCIPvarGetUbGlobal(var);
593 
594  solval = SCIPgetSolVal(scip, worksol, var);
595  /* old solution value is smaller than the actual lower bound */
596  if( SCIPisFeasLT(scip, solval, lb) )
597  {
598  /* set the solution value to the global lower bound */
599  SCIP_CALL( SCIPsetSolVal(scip, worksol, var, lb) );
600  ++nchgbound;
601  SCIPdebugMsg(scip, "var <%s> type %d, old solval %g now fixed to lb %g\n", SCIPvarGetName(var), SCIPvarGetType(var), solval, lb);
602  }
603  /* old solution value is greater than the actual upper bound */
604  else if( SCIPisFeasGT(scip, solval, SCIPvarGetUbGlobal(var)) )
605  {
606  /* set the solution value to the global upper bound */
607  SCIP_CALL( SCIPsetSolVal(scip, worksol, var, ub) );
608  ++nchgbound;
609  SCIPdebugMsg(scip, "var <%s> type %d, old solval %g now fixed to ub %g\n", SCIPvarGetName(var), SCIPvarGetType(var), solval, ub);
610  }
611  }
612 
613  SCIPdebugMsg(scip, "number of bound changes (due to global bounds) = %d\n", nchgbound);
614 
615  SCIP_CALL( SCIPgetLPRowsData(scip, &lprows, &nlprows) );
616  SCIP_CALL( SCIPallocBufferArray(scip, &activities, nlprows) );
617 
618  localrows = FALSE;
619  valid = TRUE;
620 
621  /* initialize LP row activities */
622  for( i = 0; i < nlprows; ++i )
623  {
624  SCIP_ROW* row;
625 
626  row = lprows[i];
627  assert(SCIProwGetLPPos(row) == i);
628 
629  if( !SCIProwIsLocal(row) )
630  {
631  activities[i] = SCIPgetRowSolActivity(scip, row, worksol);
632  SCIPdebugMsg(scip, "Row <%s> has activity %g\n", SCIProwGetName(row), activities[i]);
633  if( SCIPisFeasLT(scip, activities[i], SCIProwGetLhs(row)) || SCIPisFeasGT(scip, activities[i], SCIProwGetRhs(row)) )
634  {
635  valid = FALSE;
637  SCIPdebugMsg(scip, "row <%s> activity %g violates bounds, lhs = %g, rhs = %g\n", SCIProwGetName(row), activities[i], SCIProwGetLhs(row), SCIProwGetRhs(row));
638  break;
639  }
640  }
641  else
642  localrows = TRUE;
643  }
644 
645  if( !valid )
646  {
647  /** @todo try to correct lp rows */
648  SCIPdebugMsg(scip, "Some global bound changes were not valid in lp rows.\n");
649 
650  SCIPfreeBufferArray(scip, &activities);
651  SCIP_CALL( SCIPfreeSol(scip, &worksol) );
652 
653  return SCIP_OKAY;
654  }
655 
656  /* allocate buffer storage for possible shift candidates */
657  shiftcandssize = 8;
658  SCIP_CALL( SCIPallocBufferArray(scip, &shiftcands, shiftcandssize) );
659  SCIP_CALL( SCIPallocBufferArray(scip, &shiftvals, shiftcandssize) );
660  nsuccessfulshifts = 0;
661  niterations = 0;
662  do
663  {
664  /* initialize data */
665  shifted = FALSE;
666  nshiftcands = 0;
667  ++niterations;
668  SCIPdebugMsg(scip, "Starting 1-opt heuristic iteration #%d\n", niterations);
669 
670  /* enumerate all integer variables and find out which of them are shiftable */
671  /* @todo if useloop=TRUE store for each variable which constraint blocked it and only iterate over those variables
672  * in the following rounds for which the constraint slack was increased by previous shifts
673  */
674  for( i = 0; i < nintvars; i++ )
675  {
676  if( SCIPvarGetStatus(vars[i]) == SCIP_VARSTATUS_COLUMN )
677  {
678  SCIP_Real shiftval;
679  SCIP_Real solval;
680 
681  /* find out whether the variable can be shifted */
682  solval = SCIPgetSolVal(scip, worksol, vars[i]);
683  shiftval = calcShiftVal(scip, vars[i], solval, activities);
684 
685  /* insert the variable into the list of shifting candidates */
686  if( !SCIPisFeasZero(scip, shiftval) )
687  {
688  SCIPdebugMsg(scip, " -> Variable <%s> can be shifted by <%1.1f> \n", SCIPvarGetName(vars[i]), shiftval);
689 
690  if( nshiftcands == shiftcandssize)
691  {
692  shiftcandssize *= 8;
693  SCIP_CALL( SCIPreallocBufferArray(scip, &shiftcands, shiftcandssize) );
694  SCIP_CALL( SCIPreallocBufferArray(scip, &shiftvals, shiftcandssize) );
695  }
696  shiftcands[nshiftcands] = vars[i];
697  shiftvals[nshiftcands] = shiftval;
698  nshiftcands++;
699  }
700  }
701  }
702 
703  /* if at least one variable can be shifted, shift variables sorted by their objective */
704  if( nshiftcands > 0 )
705  {
706  SCIP_Real shiftval;
707  SCIP_Real solval;
708  SCIP_VAR* var;
709 
710  /* the case that exactly one variable can be shifted is slightly easier */
711  if( nshiftcands == 1 )
712  {
713  var = shiftcands[0];
714  assert(var != NULL);
715  solval = SCIPgetSolVal(scip, worksol, var);
716  shiftval = shiftvals[0];
717  assert(!SCIPisFeasZero(scip,shiftval));
718  SCIPdebugMsg(scip, " Only one shiftcand found, var <%s>, which is now shifted by<%1.1f> \n",
719  SCIPvarGetName(var), shiftval);
720  SCIP_CALL( SCIPsetSolVal(scip, worksol, var, solval+shiftval) );
721  SCIP_CALL( updateRowActivities(scip, activities, var, shiftval) );
722  ++nsuccessfulshifts;
723  }
724  else
725  {
726  SCIP_Real* objcoeffs;
727 
728  SCIP_CALL( SCIPallocBufferArray(scip, &objcoeffs, nshiftcands) );
729 
730  SCIPdebugMsg(scip, " %d shiftcands found \n", nshiftcands);
731 
732  /* sort the variables by their objective, optionally weighted with the shiftval */
733  if( heurdata->weightedobj )
734  {
735  for( i = 0; i < nshiftcands; ++i )
736  objcoeffs[i] = SCIPvarGetObj(shiftcands[i])*shiftvals[i];
737  }
738  else
739  {
740  for( i = 0; i < nshiftcands; ++i )
741  objcoeffs[i] = SCIPvarGetObj(shiftcands[i]);
742  }
743 
744  /* sort arrays with respect to the first one */
745  SCIPsortRealPtr(objcoeffs, (void**)shiftcands, nshiftcands);
746 
747  /* try to shift each variable -> Activities have to be updated */
748  for( i = 0; i < nshiftcands; ++i )
749  {
750  var = shiftcands[i];
751  assert(var != NULL);
752  solval = SCIPgetSolVal(scip, worksol, var);
753  shiftval = calcShiftVal(scip, var, solval, activities);
754  assert(i > 0 || !SCIPisFeasZero(scip, shiftval));
755  assert(SCIPisFeasGE(scip, solval+shiftval, SCIPvarGetLbGlobal(var)) && SCIPisFeasLE(scip, solval+shiftval, SCIPvarGetUbGlobal(var)));
756 
757  /* update data structures for nonzero shift value */
758  if( ! SCIPisFeasZero(scip, shiftval) )
759  {
760  SCIPdebugMsg(scip, " -> Variable <%s> is now shifted by <%1.1f> \n", SCIPvarGetName(vars[i]), shiftval);
761  SCIP_CALL( SCIPsetSolVal(scip, worksol, var, solval+shiftval) );
762  SCIP_CALL( updateRowActivities(scip, activities, var, shiftval) );
763  ++nsuccessfulshifts;
764  }
765  }
766 
767  SCIPfreeBufferArray(scip, &objcoeffs);
768  }
769  shifted = TRUE;
770  }
771  }
772  while( heurdata->useloop && shifted );
773 
774  if( nsuccessfulshifts > 0 )
775  {
776  /* if the problem is a pure IP, try to install the solution, if it is a MIP, solve LP again to set the continuous
777  * variables to the best possible value
778  */
779  if( nvars == nintvars || !SCIPhasCurrentNodeLP(scip) || SCIPgetLPSolstat(scip) != SCIP_LPSOLSTAT_OPTIMAL )
780  {
781  SCIP_Bool success;
782 
783  /* since we ignore local rows, we cannot guarantee their feasibility and have to set the checklprows flag to
784  * TRUE if local rows are present
785  */
786  SCIP_CALL( SCIPtrySol(scip, worksol, FALSE, FALSE, FALSE, FALSE, localrows, &success) );
787 
788  if( success )
789  {
790  SCIPdebugMsg(scip, "found feasible shifted solution:\n");
791  SCIPdebug( SCIP_CALL( SCIPprintSol(scip, worksol, NULL, FALSE) ) );
792  *result = SCIP_FOUNDSOL;
793  }
794  }
795  else
796  {
797  SCIP_Bool lperror;
798 #ifdef NDEBUG
799  SCIP_RETCODE retstat;
800 #endif
801 
802  SCIPdebugMsg(scip, "shifted solution should be feasible -> solve LP to fix continuous variables to best values\n");
803 
804  /* start diving to calculate the LP relaxation */
806 
807  /* set the bounds of the variables: fixed for integers, global bounds for continuous */
808  for( i = 0; i < nvars; ++i )
809  {
810  if( SCIPvarGetStatus(vars[i]) == SCIP_VARSTATUS_COLUMN )
811  {
812  SCIP_CALL( SCIPchgVarLbDive(scip, vars[i], SCIPvarGetLbGlobal(vars[i])) );
813  SCIP_CALL( SCIPchgVarUbDive(scip, vars[i], SCIPvarGetUbGlobal(vars[i])) );
814  }
815  }
816  /* apply this after global bounds to not cause an error with intermediate empty domains */
817  for( i = 0; i < nintvars; ++i )
818  {
819  if( SCIPvarGetStatus(vars[i]) == SCIP_VARSTATUS_COLUMN )
820  {
821  SCIP_Real solval;
822  solval = SCIPgetSolVal(scip, worksol, vars[i]);
823  SCIP_CALL( SCIPchgVarLbDive(scip, vars[i], solval) );
824  SCIP_CALL( SCIPchgVarUbDive(scip, vars[i], solval) );
825  }
826  }
827 
828  /* solve LP */
829  SCIPdebugMsg(scip, " -> old LP iterations: %" SCIP_LONGINT_FORMAT "\n", SCIPgetNLPIterations(scip));
830 
831  /**@todo in case of an MINLP, if SCIPisNLPConstructed() is TRUE, say, rather solve the NLP instead of the LP */
832  /* Errors in the LP solver should not kill the overall solving process, if the LP is just needed for a heuristic.
833  * Hence in optimized mode, the return code is caught and a warning is printed, only in debug mode, SCIP will stop.
834  */
835 #ifdef NDEBUG
836  retstat = SCIPsolveDiveLP(scip, -1, &lperror, NULL);
837  if( retstat != SCIP_OKAY )
838  {
839  SCIPwarningMessage(scip, "Error while solving LP in 1-opt heuristic; LP solve terminated with code <%d>\n",retstat);
840  }
841 #else
842  SCIP_CALL( SCIPsolveDiveLP(scip, -1, &lperror, NULL) );
843 #endif
844 
845  SCIPdebugMsg(scip, " -> new LP iterations: %" SCIP_LONGINT_FORMAT "\n", SCIPgetNLPIterations(scip));
846  SCIPdebugMsg(scip, " -> error=%u, status=%d\n", lperror, SCIPgetLPSolstat(scip));
847 
848  /* check if this is a feasible solution */
849  if( !lperror && SCIPgetLPSolstat(scip) == SCIP_LPSOLSTAT_OPTIMAL )
850  {
851  SCIP_Bool success;
852 
853  /* copy the current LP solution to the working solution */
854  SCIP_CALL( SCIPlinkLPSol(scip, worksol) );
855  SCIP_CALL( SCIPtrySol(scip, worksol, FALSE, FALSE, FALSE, FALSE, FALSE, &success) );
856 
857  /* check solution for feasibility */
858  if( success )
859  {
860  SCIPdebugMsg(scip, "found feasible shifted solution:\n");
861  SCIPdebug( SCIP_CALL( SCIPprintSol(scip, worksol, NULL, FALSE) ) );
862  *result = SCIP_FOUNDSOL;
863  }
864  }
865 
866  /* terminate the diving */
868  }
869  }
870 
871  /* heuristic should not rerun on this incumbent because the heuristic loop finishes only after no further
872  * improvements of the incumbent solution are possible
873  */
874  if( heurdata->useloop )
875  heurdata->lastsolindex = SCIPsolGetIndex(SCIPgetBestSol(scip));
876 
877  SCIPfreeBufferArray(scip, &shiftvals);
878  SCIPfreeBufferArray(scip, &shiftcands);
879  SCIPfreeBufferArray(scip, &activities);
880 
881  SCIP_CALL( SCIPfreeSol(scip, &worksol) );
882 
883  SCIPdebugMsg(scip, "Finished 1-opt heuristic\n");
884 
885  return SCIP_OKAY;
886 }
887 
888 /*
889  * primal heuristic specific interface methods
890  */
891 
892 /** creates the oneopt primal heuristic and includes it in SCIP */
894  SCIP* scip /**< SCIP data structure */
895  )
896 {
897  SCIP_HEURDATA* heurdata;
898  SCIP_HEUR* heur;
899 
900  /* create Oneopt primal heuristic data */
901  SCIP_CALL( SCIPallocBlockMemory(scip, &heurdata) );
902 
903  /* include primal heuristic */
904  SCIP_CALL( SCIPincludeHeurBasic(scip, &heur,
906  HEUR_MAXDEPTH, HEUR_TIMING, HEUR_USESSUBSCIP, heurExecOneopt, heurdata) );
907 
908  assert(heur != NULL);
909 
910  /* set non-NULL pointers to callback methods */
911  SCIP_CALL( SCIPsetHeurCopy(scip, heur, heurCopyOneopt) );
912  SCIP_CALL( SCIPsetHeurFree(scip, heur, heurFreeOneopt) );
913  SCIP_CALL( SCIPsetHeurInitsol(scip, heur, heurInitsolOneopt) );
914  SCIP_CALL( SCIPsetHeurExitsol(scip, heur, heurExitsolOneopt) );
915  SCIP_CALL( SCIPsetHeurInit(scip, heur, heurInitOneopt) );
916 
917  /* add oneopt primal heuristic parameters */
918  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/oneopt/weightedobj",
919  "should the objective be weighted with the potential shifting value when sorting the shifting candidates?",
920  &heurdata->weightedobj, TRUE, DEFAULT_WEIGHTEDOBJ, NULL, NULL) );
921 
922  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/oneopt/duringroot",
923  "should the heuristic be called before and during the root node?",
924  &heurdata->duringroot, TRUE, DEFAULT_DURINGROOT, NULL, NULL) );
925 
926  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/oneopt/forcelpconstruction",
927  "should the construction of the LP be forced even if LP solving is deactivated?",
928  &heurdata->forcelpconstruction, TRUE, DEFAULT_FORCELPCONSTRUCTION, NULL, NULL) );
929 
930  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/oneopt/beforepresol",
931  "should the heuristic be called before presolving?",
932  &heurdata->beforepresol, TRUE, DEFAULT_BEFOREPRESOL, NULL, NULL) );
933 
934  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/oneopt/useloop",
935  "should the heuristic continue to run as long as improvements are found?",
936  &heurdata->useloop, TRUE, DEFAULT_USELOOP, NULL, NULL) );
937 
938  return SCIP_OKAY;
939 }
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:61
SCIP_Bool SCIPsolIsOriginal(SCIP_SOL *sol)
Definition: sol.c:2530
SCIP_RETCODE SCIPsetHeurExitsol(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEUREXITSOL((*heurexitsol)))
Definition: scip_heur.c:242
#define HEUR_DISPCHAR
Definition: heur_oneopt.c:63
SCIP_Bool SCIPisFeasZero(SCIP *scip, SCIP_Real val)
#define SCIP_HEURTIMING_DURINGLPLOOP
Definition: type_timing.h:80
#define DEFAULT_BEFOREPRESOL
Definition: heur_oneopt.c:73
SCIP_RETCODE SCIPlinkLPSol(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:1026
SCIP_RETCODE SCIPsetSeparating(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
Definition: scip_param.c:958
#define DEFAULT_WEIGHTEDOBJ
Definition: heur_oneopt.c:71
Improvement heuristic that alters single variable values.
public methods for SCIP parameter handling
SCIP_NODE * SCIPgetCurrentNode(SCIP *scip)
Definition: scip_tree.c:91
SCIP_Longint SCIPgetNLPIterations(SCIP *scip)
SCIP_Bool SCIPisFeasLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
public methods for memory management
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
Definition: var.c:17919
#define DEFAULT_DURINGROOT
Definition: heur_oneopt.c:72
SCIP_Real * SCIPcolGetVals(SCIP_COL *col)
Definition: lp.c:17153
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:244
SCIP_RETCODE SCIPcopy(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, const char *suffix, SCIP_Bool global, SCIP_Bool enablepricing, SCIP_Bool threadsafe, SCIP_Bool passmessagehdlr, SCIP_Bool *valid)
Definition: scip_copy.c:2866
#define SCIP_HEURTIMING_BEFORENODE
Definition: type_timing.h:79
public solving methods
const char * SCIProwGetName(SCIP_ROW *row)
Definition: lp.c:17343
SCIP_Bool SCIPisFeasGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_RETCODE SCIPgetVarsData(SCIP *scip, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars)
Definition: scip_prob.c:1874
SCIP_RETCODE SCIPsetHeuristics(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
Definition: scip_param.c:906
#define DEFAULT_FORCELPCONSTRUCTION
Definition: heur_oneopt.c:74
SCIP_Real SCIProwGetLhs(SCIP_ROW *row)
Definition: lp.c:17284
#define FALSE
Definition: def.h:96
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
Definition: misc.c:3023
SCIP_RETCODE SCIPcopyLimits(SCIP *sourcescip, SCIP *targetscip)
Definition: scip_copy.c:3287
SCIP_RETCODE SCIPcutoffNode(SCIP *scip, SCIP_NODE *node)
Definition: scip_tree.c:434
SCIP_Real SCIPinfinity(SCIP *scip)
#define TRUE
Definition: def.h:95
#define SCIPdebug(x)
Definition: pub_message.h:93
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:63
#define HEUR_DESC
Definition: heur_oneopt.c:62
SCIP_RETCODE SCIPsetPresolving(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
Definition: scip_param.c:932
int SCIPheurGetFreqofs(SCIP_HEUR *heur)
Definition: heur.c:1556
SCIP_RETCODE SCIPchgVarLbDive(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
Definition: scip_lp.c:2413
struct SCIP_HeurData SCIP_HEURDATA
Definition: type_heur.h:76
public methods for problem variables
#define SCIPfreeBlockMemory(scip, ptr)
Definition: scip_mem.h:108
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_heur.c:117
SCIP_RETCODE SCIPtranslateSubSols(SCIP *scip, SCIP *subscip, SCIP_HEUR *heur, SCIP_VAR **subvars, SCIP_Bool *success, int *solindex)
Definition: scip_copy.c:1448
void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin)
Definition: misc.c:3210
SCIP_RETCODE SCIPconstructLP(SCIP *scip, SCIP_Bool *cutoff)
Definition: scip_lp.c:124
static SCIP_Real calcShiftVal(SCIP *scip, SCIP_VAR *var, SCIP_Real solval, SCIP_Real *activities)
Definition: heur_oneopt.c:98
#define SCIPfreeBufferArray(scip, ptr)
Definition: scip_mem.h:136
SCIP_RETCODE SCIPcreate(SCIP **scip)
Definition: scip_general.c:292
void SCIPheurSetData(SCIP_HEUR *heur, SCIP_HEURDATA *heurdata)
Definition: heur.c:1371
#define SCIPallocBlockMemory(scip, ptr)
Definition: scip_mem.h:89
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
Definition: scip_message.c:120
#define SCIPdebugMsg
Definition: scip_message.h:78
SCIP_RETCODE SCIPprintStatistics(SCIP *scip, FILE *file)
SCIP_RETCODE SCIPcreateOrigSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip_sol.c:565
public methods for numerical tolerances
SCIP_Real SCIPfeasFloor(SCIP *scip, SCIP_Real val)
public methods for querying solving statistics
SCIP_Bool SCIProwIsInLP(SCIP_ROW *row)
Definition: lp.c:17515
public methods for the branch-and-bound tree
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
Definition: var.c:17929
#define HEUR_MAXDEPTH
Definition: heur_oneopt.c:67
SCIP_RETCODE SCIPcreateSolCopy(SCIP *scip, SCIP_SOL **sol, SCIP_SOL *sourcesol)
Definition: scip_sol.c:618
SCIP_RETCODE SCIPsetHeurInitsol(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURINITSOL((*heurinitsol)))
Definition: scip_heur.c:226
SCIP_RETCODE SCIPsolve(SCIP *scip)
Definition: scip_solve.c:2622
const char * SCIPheurGetName(SCIP_HEUR *heur)
Definition: heur.c:1450
SCIP_Bool SCIPisParamFixed(SCIP *scip, const char *name)
Definition: scip_param.c:219
SCIP_RETCODE SCIPsolveDiveLP(SCIP *scip, int itlim, SCIP_Bool *lperror, SCIP_Bool *cutoff)
Definition: scip_lp.c:2672
SCIP_RETCODE SCIPsetHeurFree(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURFREE((*heurfree)))
Definition: scip_heur.c:178
SCIP_ROW ** SCIPcolGetRows(SCIP_COL *col)
Definition: lp.c:17143
SCIP_Bool SCIProwIsLocal(SCIP_ROW *row)
Definition: lp.c:17393
SCIP_RETCODE SCIPsetBoolParam(SCIP *scip, const char *name, SCIP_Bool value)
Definition: scip_param.c:429
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
Definition: scip_mem.c:57
static SCIP_DECL_HEURCOPY(heurCopyOneopt)
Definition: heur_oneopt.c:370
const char * SCIPvarGetName(SCIP_VAR *var)
Definition: var.c:17260
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
Definition: misc.c:3057
#define NULL
Definition: lpi_spx1.cpp:164
static SCIP_RETCODE updateRowActivities(SCIP *scip, SCIP_Real *activities, SCIP_VAR *var, SCIP_Real shiftval)
Definition: heur_oneopt.c:194
SCIP_RETCODE SCIPunfixParam(SCIP *scip, const char *name)
Definition: scip_param.c:385
int SCIPgetNLPRows(SCIP *scip)
Definition: scip_lp.c:626
public methods for problem copies
public methods for primal CIP solutions
#define SCIP_CALL(x)
Definition: def.h:393
SCIP_Bool SCIPisFeasGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisFeasLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
static SCIP_DECL_HEUREXITSOL(heurExitsolOneopt)
Definition: heur_oneopt.c:423
SCIP_Real SCIProwGetRhs(SCIP_ROW *row)
Definition: lp.c:17294
#define SCIP_HEURTIMING_BEFOREPRESOL
Definition: type_timing.h:95
#define DEFAULT_USELOOP
Definition: heur_oneopt.c:75
#define HEUR_FREQ
Definition: heur_oneopt.c:65
SCIP_Bool SCIPhasCurrentNodeLP(SCIP *scip)
Definition: scip_lp.c:83
public methods for primal heuristic plugins and divesets
#define SCIPallocBufferArray(scip, ptr, num)
Definition: scip_mem.h:124
SCIP_RETCODE SCIPsetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real val)
Definition: scip_sol.c:1221
public data structures and miscellaneous methods
#define HEUR_USESSUBSCIP
Definition: heur_oneopt.c:69
#define SCIP_Bool
Definition: def.h:93
#define HEUR_PRIORITY
Definition: heur_oneopt.c:64
SCIP_LPSOLSTAT SCIPgetLPSolstat(SCIP *scip)
Definition: scip_lp.c:168
SCIP_RETCODE SCIPchgVarUbDive(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
Definition: scip_lp.c:2445
#define HEUR_FREQOFS
Definition: heur_oneopt.c:66
void SCIPsolSetHeur(SCIP_SOL *sol, SCIP_HEUR *heur)
Definition: sol.c:2658
#define MAX(x, y)
Definition: tclique_def.h:92
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_sol.c:3240
SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value)
Definition: scip_param.c:487
public methods for LP management
SCIP_RETCODE SCIPfreeSol(SCIP *scip, SCIP_SOL **sol)
Definition: scip_sol.c:985
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
Definition: var.c:17767
static SCIP_DECL_HEUREXEC(heurExecOneopt)
Definition: heur_oneopt.c:455
SCIP_COL * SCIPvarGetCol(SCIP_VAR *var)
Definition: var.c:17630
SCIP_RETCODE SCIPflushLP(SCIP *scip)
Definition: scip_lp.c:148
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
SCIP_Real SCIPgetRowSolActivity(SCIP *scip, SCIP_ROW *row, SCIP_SOL *sol)
Definition: scip_lp.c:2138
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_sol.c:3134
public methods for the LP relaxation, rows and columns
int SCIPgetNVars(SCIP *scip)
Definition: scip_prob.c:2000
methods for sorting joint arrays of various types
general public methods
static SCIP_DECL_HEURINIT(heurInitOneopt)
Definition: heur_oneopt.c:436
SCIP_SOL * SCIPgetBestSol(SCIP *scip)
Definition: scip_sol.c:2313
public methods for solutions
public methods for message output
SCIP_RETCODE SCIPsetHeurInit(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURINIT((*heurinit)))
Definition: scip_heur.c:194
#define HEUR_TIMING
Definition: heur_oneopt.c:68
SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
Definition: var.c:17379
int SCIProwGetLPPos(SCIP_ROW *row)
Definition: lp.c:17493
#define SCIP_Real
Definition: def.h:186
public methods for message handling
void SCIPheurSetTimingmask(SCIP_HEUR *heur, SCIP_HEURTIMING timingmask)
Definition: heur.c:1490
#define HEUR_NAME
Definition: heur_oneopt.c:61
SCIP_RETCODE SCIPprintRow(SCIP *scip, SCIP_ROW *row, FILE *file)
Definition: scip_lp.c:2206
static SCIP_DECL_HEURFREE(heurFreeOneopt)
Definition: heur_oneopt.c:384
void SCIPsortRealPtr(SCIP_Real *realarray, void **ptrarray, int len)
SCIP_RETCODE SCIPcheckCopyLimits(SCIP *sourcescip, SCIP_Bool *success)
Definition: scip_copy.c:3244
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
Definition: var.c:17425
SCIP_RETCODE SCIPstartDive(SCIP *scip)
Definition: scip_lp.c:2236
SCIP_RETCODE SCIPtransformProb(SCIP *scip)
Definition: scip_solve.c:367
static SCIP_DECL_HEURINITSOL(heurInitsolOneopt)
Definition: heur_oneopt.c:404
SCIP_RETCODE SCIPsetHeurCopy(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURCOPY((*heurcopy)))
Definition: scip_heur.c:162
SCIP_RETCODE SCIPincludeHeurOneopt(SCIP *scip)
Definition: heur_oneopt.c:893
public methods for primal heuristics
SCIP_RETCODE SCIPgetLPRowsData(SCIP *scip, SCIP_ROW ***rows, int *nrows)
Definition: scip_lp.c:570
SCIP_RETCODE SCIPendDive(SCIP *scip)
Definition: scip_lp.c:2285
#define SCIP_CALL_ABORT(x)
Definition: def.h:372
SCIP_HEURDATA * SCIPheurGetData(SCIP_HEUR *heur)
Definition: heur.c:1361
SCIP_Longint SCIPgetNNodes(SCIP *scip)
public methods for global and local (sub)problems
int SCIPcolGetNLPNonz(SCIP_COL *col)
Definition: lp.c:17132
SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
Definition: scip_sol.c:1361
int SCIPsolGetIndex(SCIP_SOL *sol)
Definition: sol.c:2644
SCIP_RETCODE SCIPsetLongintParam(SCIP *scip, const char *name, SCIP_Longint value)
Definition: scip_param.c:545
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_param.c:57
SCIP_RETCODE SCIPfree(SCIP **scip)
Definition: scip_general.c:324
#define SCIPreallocBufferArray(scip, ptr, num)
Definition: scip_mem.h:128
memory allocation routines
SCIP_RETCODE SCIPprintSol(SCIP *scip, SCIP_SOL *sol, FILE *file, SCIP_Bool printzeros)
Definition: scip_sol.c:1775