Scippy

SCIP

Solving Constraint Integer Programs

debug.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-2020 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 visit scipopt.org. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file debug.c
17  * @ingroup OTHER_CFILES
18  * @brief methods for debugging
19  * @author Tobias Achterberg
20  */
21 
22 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
23 
24 #include <stdio.h>
25 #include <string.h>
26 #include <assert.h>
27 #if defined(_WIN32) || defined(_WIN64)
28 #else
29 #include <strings.h> /*lint --e{766}*/
30 #endif
31 
32 #include "scip/def.h"
33 #include "blockmemshell/memory.h"
34 #include "scip/set.h"
35 #include "scip/lp.h"
36 #include "scip/var.h"
37 #include "scip/prob.h"
38 #include "scip/tree.h"
39 #include "scip/scip.h"
40 #include "scip/debug.h"
41 #include "scip/pub_message.h"
42 #include "scip/pub_misc.h"
43 #include "scip/struct_scip.h"
44 
45 #ifdef WITH_DEBUG_SOLUTION
46 
47 #define SCIP_HASHSIZE_DEBUG 500 /**< minimum size of hash map for storing whether a solution is valid for the node */
48 
49 struct SCIP_DebugSolData
50 {
51  char** solnames; /**< variable names in the solution */
52  SCIP_Real* solvals; /**< solution value array (only nonzero entries) */
53  int nsolvals; /**< number of entries in the debug solution */
54  int solsize; /**< size of the array entries */
55  SCIP_SOL* debugsol; /**< a debug solution */
56  SCIP_STAGE debugsolstage; /**< solving stage of debug solution */
57  SCIP_HASHMAP* solinnode; /**< maps nodes to bools, storing whether the solution is valid for the node */
58  SCIP_Bool falseptr; /**< pointer to value FALSE used for hashmap */
59  SCIP_Bool trueptr; /**< pointer to value TRUE used for hashmap */
60  SCIP_Bool solisachieved; /**< means if current best solution is better than the given debug solution */
61  SCIP_Real debugsolval; /**< objective value for debug solution */
62  SCIP_Bool debugsoldisabled; /**< flag indicating if debugging of solution was disabled or not */
63  SCIP_Bool warningprinted; /**< flag indicating if a warning was already printed */
64 };
65 
66 
67 /** creates debug solution data */
69  SCIP_DEBUGSOLDATA** debugsoldata /**< pointer to debug solution data */
70  )
71 {
72  assert(debugsoldata != NULL);
73 
74  SCIP_ALLOC( BMSallocMemory(debugsoldata) );
75 
76  (*debugsoldata)->solnames = NULL;
77  (*debugsoldata)->solvals = NULL;
78  (*debugsoldata)->nsolvals = 0;
79  (*debugsoldata)->solsize = 0;
80  (*debugsoldata)->debugsol = NULL;
81  (*debugsoldata)->debugsolstage = SCIP_STAGE_INIT;
82  (*debugsoldata)->solinnode = NULL;
83  (*debugsoldata)->falseptr = FALSE;
84  (*debugsoldata)->trueptr = TRUE;
85  (*debugsoldata)->solisachieved = FALSE;
86  (*debugsoldata)->debugsolval = 0.0;
87  (*debugsoldata)->debugsoldisabled = TRUE;
88  (*debugsoldata)->warningprinted = FALSE;
89 
90  return SCIP_OKAY;
91 }
92 
93 #ifdef SCIP_MORE_DEBUG
94 /** comparison method for sorting variables w.r.t. to their name */
95 static
96 SCIP_DECL_SORTPTRCOMP(sortVarsAfterNames)
97 {
98  return strcmp(SCIPvarGetName((SCIP_VAR*)elem1), SCIPvarGetName((SCIP_VAR*)elem2));
99 }
100 #endif
101 
102 /* checks whether the parameter is specified */
103 static
104 SCIP_Bool debugSolutionAvailable(
105  SCIP_SET* set /**< global SCIP settings */
106  )
107 {
108  SCIP_DEBUGSOLDATA* debugsoldata;
109 
110  assert(set != NULL);
111 
112  debugsoldata = SCIPsetGetDebugSolData(set);
113 
114  /* check whether a debug solution is specified */
115  if( strcmp(set->misc_debugsol, "-") == 0 )
116  {
117  if( !debugsoldata->warningprinted )
118  {
119  SCIPmessagePrintWarning(SCIPgetMessagehdlr(set->scip), "SCIP is compiled with 'DEBUGSOL=true' but no debug solution is given:\n ");
120  SCIPmessagePrintWarning(SCIPgetMessagehdlr(set->scip), "*** Please set the parameter 'misc/debugsol' and reload the problem again to use the debugging-mechanism ***\n\n");
121  debugsoldata->warningprinted = TRUE;
122  }
123  return FALSE;
124  }
125  else
126  {
127  debugsoldata->warningprinted = FALSE;
128  return TRUE;
129  }
130 }
131 
132 /** reads solution from given file into given arrays */
133 static
134 SCIP_RETCODE readSolfile(
135  SCIP_SET* set, /**< global SCIP settings */
136  const char* solfilename, /**< solution filename to read */
137  SCIP_SOL** debugsolptr,
138  SCIP_Real* debugsolvalptr,
139  SCIP_STAGE* debugsolstageptr,
140  char*** names, /**< pointer to store the array of variable names */
141  SCIP_Real** vals, /**< pointer to store the array of solution values */
142  int* nvals, /**< pointer to store the number of non-zero elements */
143  int* valssize /**< pointer to store the length of the variable names and solution values arrays */
144  )
145 {
146  SCIP_VAR** vars;
147  SCIP_Real* solvalues;
148  SCIP_FILE* file;
149  SCIP_SOL* debugsol;
150  SCIP_Real debugsolval;
151  int nonvalues;
152  int nfound;
153  int i;
154  SCIP_Bool unknownvariablemessage;
155 
156  assert(set != NULL);
157  assert(solfilename != NULL);
158  assert(names != NULL);
159  assert(*names == NULL);
160  assert(vals != NULL);
161  assert(*vals == NULL);
162  assert(nvals != NULL);
163  assert(valssize != NULL);
164 
165  printf("***** debug: reading solution file <%s>\n", solfilename);
166 
167  /* open solution file */
168  file = SCIPfopen(solfilename, "r");
169  if( file == NULL )
170  {
171  SCIPerrorMessage("cannot open solution file <%s> specified in scip/debug.h\n", solfilename);
172  SCIPprintSysError(solfilename);
173  return SCIP_NOFILE;
174  }
175 
176  /* read data */
177  nonvalues = 0;
178  *valssize = 0;
179  unknownvariablemessage = FALSE;
180 
181  while( !SCIPfeof(file) )
182  {
183  char buf[SCIP_MAXSTRLEN];
184  char name[SCIP_MAXSTRLEN];
185  char objstring[SCIP_MAXSTRLEN];
186  char valuestring[SCIP_MAXSTRLEN];
187  SCIP_VAR* var;
188  SCIP_Real val;
189  int nread;
190 
191  if( SCIPfgets(buf, SCIP_MAXSTRLEN, file) == NULL )
192  {
193  if( SCIPfeof(file) )
194  break;
195  else
196  return SCIP_READERROR;
197  }
198 
199  /* there are some lines which may preceed the solution information */
200  if( strncasecmp(buf, "solution status:", 16) == 0 || strncasecmp(buf, "objective value:", 16) == 0 ||
201  strncasecmp(buf, "Log started", 11) == 0 || strncasecmp(buf, "Variable Name", 13) == 0 ||
202  strncasecmp(buf, "All other variables", 19) == 0 || strncasecmp(buf, "\n", 1) == 0 ||
203  strncasecmp(buf, "NAME", 4) == 0 || strncasecmp(buf, "ENDATA", 6) == 0 ) /* allow parsing of SOL-format on the MIPLIB 2003 pages */
204  {
205  ++nonvalues;
206  continue;
207  }
208 
209  /* cppcheck-suppress invalidscanf */
210  nread = sscanf(buf, "%s %s %s\n", name, valuestring, objstring);
211  if( nread < 2 )
212  {
213  printf("invalid input line %d in solution file <%s>: <%s>\n", *nvals + nonvalues, solfilename, name);
214  SCIPfclose(file);
215  return SCIP_READERROR;
216  }
217 
218  /* find the variable */
219  var = SCIPfindVar(set->scip, name);
220  if( var == NULL )
221  {
222  if( !unknownvariablemessage )
223  {
224  SCIPverbMessage(set->scip, SCIP_VERBLEVEL_NORMAL, NULL, "unknown variable <%s> in line %d of solution file <%s>\n",
225  name, *nvals + nonvalues, solfilename);
226  SCIPverbMessage(set->scip, SCIP_VERBLEVEL_NORMAL, NULL, " (further unknown variables are ignored)\n");
227  unknownvariablemessage = TRUE;
228  }
229  continue;
230  }
231 
232  /* cast the value, check first for inv(alid) or inf(inite) ones that need special treatment */
233  if( strncasecmp(valuestring, "inv", 3) == 0 )
234  continue;
235  else if( strncasecmp(valuestring, "+inf", 4) == 0 || strncasecmp(valuestring, "inf", 3) == 0 )
236  val = SCIPsetInfinity(set);
237  else if( strncasecmp(valuestring, "-inf", 4) == 0 )
238  val = -SCIPsetInfinity(set);
239  else
240  {
241  /* cppcheck-suppress invalidscanf */
242  nread = sscanf(valuestring, "%lf", &val);
243  if( nread != 1 )
244  {
245  SCIPerrorMessage("Invalid solution value <%s> for variable <%s> in line %d of solution file <%s>.\n",
246  valuestring, name, *nvals + nonvalues, solfilename);
247  SCIPfclose(file);
248  return SCIP_READERROR;
249  }
250  }
251 
252  /* allocate memory */
253  if( *nvals >= *valssize )
254  {
255  *valssize = MAX(2 * *valssize, (*nvals)+1);
256  SCIP_ALLOC( BMSreallocMemoryArray(names, *valssize) );
257  SCIP_ALLOC( BMSreallocMemoryArray(vals, *valssize) );
258  }
259  assert(*nvals < *valssize);
260 
261  /* store solution value in sorted list */
262  for( i = *nvals; i > 0 && strcmp(name, (*names)[i-1]) < 0; --i )
263  {
264  (*names)[i] = (*names)[i-1];
265  (*vals)[i] = (*vals)[i-1];
266  }
267  SCIP_ALLOC( BMSduplicateMemoryArray(&(*names)[i], name, strlen(name)+1) );
268  SCIPdebugMsg(set->scip, "found variable <%s>: value <%g>\n", (*names)[i], val);
269  (*vals)[i] = val;
270  (*nvals)++;
271  }
272 
273  /* get memory for SCIP solution */
274  SCIP_ALLOC( BMSallocMemoryArray(&vars, *valssize) );
275  SCIP_ALLOC( BMSallocMemoryArray(&solvalues, *valssize) );
276 
277  debugsolval = 0.0;
278  nfound = 0;
279 
280  /* get solution value */
281  for( i = 0; i < *nvals; ++i)
282  {
283  SCIP_VAR* var;
284  var = SCIPfindVar(set->scip, (*names)[i]);
285  if( var != NULL )
286  {
287  vars[nfound] = var;
288  solvalues[nfound] = (*vals)[i];
289  ++nfound;
290  debugsolval += (*vals)[i] * SCIPvarGetObj(var);
291  }
292  }
293  SCIPdebugMsg(set->scip, "Debug Solution value is %g.\n", debugsolval);
294 
295 #ifdef SCIP_MORE_DEBUG
296  SCIPsortPtrReal((void**)vars, solvalues, sortVarsAfterNames, nfound);
297 
298  for( i = 0; i < nfound - 1; ++i)
299  {
300  assert(strcmp(SCIPvarGetName(vars[i]), SCIPvarGetName(vars[i + 1])) != 0);
301  }
302 #endif
303 
304  if( debugsolptr != NULL )
305  {
306  /* create SCIP solution */
307  SCIP_CALL( SCIPcreateOrigSol(set->scip, &debugsol, NULL) );
308  *debugsolstageptr = SCIPgetStage(set->scip);
309 
310  /* set SCIP solution values */
311  SCIP_CALL( SCIPsetSolVals(set->scip, debugsol, nfound, vars, solvalues ) );
312  }
313 
314  BMSfreeMemoryArray(&vars);
315  BMSfreeMemoryArray(&solvalues);
316 
317  if( debugsolptr != NULL )
318  *debugsolptr = debugsol;
319 
320  if( debugsolvalptr != NULL )
321  *debugsolvalptr = debugsolval;
322 
323  /* close file */
324  SCIPfclose(file);
325 
326  printf("***** debug: read %d non-zero entries (%d variables found)\n", *nvals, nfound);
327 
328  return SCIP_OKAY;
329 }
330 
331 /** reads feasible solution to check from file */
332 static
333 SCIP_RETCODE readSolution(
334  SCIP_SET* set /**< global SCIP settings */
335  )
336 {
337  SCIP_DEBUGSOLDATA* debugsoldata;
338 
339  assert(set != NULL);
340 
341  debugsoldata = SCIPsetGetDebugSolData(set);
342 
343  /* check whether a debug solution is available */
344  if( !debugSolutionAvailable(set) )
345  return SCIP_OKAY;
346 
347  if( debugsoldata == NULL || debugsoldata->nsolvals > 0 )
348  return SCIP_OKAY;
349 
350  SCIP_CALL( readSolfile(set, set->misc_debugsol, &debugsoldata->debugsol, &debugsoldata->debugsolval,
351  &debugsoldata->debugsolstage, &(debugsoldata->solnames), &(debugsoldata->solvals), &(debugsoldata->nsolvals),
352  &(debugsoldata->solsize)) );
353 
354  return SCIP_OKAY;
355 }
356 
357 /** gets value of given variable in debugging solution */
358 static
359 SCIP_RETCODE getSolutionValue(
360  SCIP_SET* set, /**< global SCIP settings */
361  SCIP_VAR* var, /**< variable to get solution value for */
362  SCIP_Real* val /**< pointer to store solution value */
363  )
364 {
365  SCIP_VAR* solvar;
366  SCIP_DEBUGSOLDATA* debugsoldata;
367  SCIP_Real scalar;
368  SCIP_Real constant;
369  const char* name;
370  int left;
371  int right;
372  int middle;
373  int cmp;
374 
375  assert(set != NULL);
376  assert(var != NULL);
377  assert(val != NULL);
378 
379  /* check whether a debug solution is available */
380  if( !debugSolutionAvailable(set) )
381  return SCIP_OKAY;
382 
383  debugsoldata = SCIPsetGetDebugSolData(set);
384  assert(debugsoldata != NULL);
385 
386  /* allow retrieving solution values only if referring to the SCIP instance that is debugged */
387  if( !SCIPdebugSolIsEnabled(set->scip) )
388  {
389  *val = SCIP_UNKNOWN;
390  return SCIP_OKAY;
391  }
392 
393  SCIP_CALL( readSolution(set) );
394  SCIPsetDebugMsg(set, "Now handling variable <%s>, which has status %d, is of type %d, and was deleted: %d, negated: %d, transformed: %d\n",
396 
397  /* ignore deleted variables */
398  if( SCIPvarIsDeleted(var) )
399  {
400  SCIPsetDebugMsg(set, "**** unknown solution value for deleted variable <%s>\n", SCIPvarGetName(var));
401  *val = SCIP_UNKNOWN;
402  return SCIP_OKAY;
403  }
404 
405  /* retransform variable onto original variable space */
406  solvar = var;
407  scalar = 1.0;
408  constant = 0.0;
409  if( SCIPvarIsNegated(solvar) )
410  {
411  scalar = -1.0;
412  constant = SCIPvarGetNegationConstant(solvar);
413  solvar = SCIPvarGetNegationVar(solvar);
414  }
415 
416  if( SCIPvarIsTransformed(solvar) )
417  {
418  SCIP_CALL( SCIPvarGetOrigvarSum(&solvar, &scalar, &constant) );
419  if( solvar == NULL )
420  {
421  /* if no original counterpart, then maybe someone added a value for the transformed variable, so search for var (or its negation) */
422  SCIPsetDebugMsg(set, "variable <%s> has no original counterpart\n", SCIPvarGetName(var));
423  solvar = var;
424  scalar = 1.0;
425  constant = 0.0;
426  if( SCIPvarIsNegated(solvar) )
427  {
428  scalar = -1.0;
429  constant = SCIPvarGetNegationConstant(solvar);
430  solvar = SCIPvarGetNegationVar(solvar);
431  }
432  }
433  }
434 
435  /* perform a binary search for the variable */
436  name = SCIPvarGetName(solvar);
437  left = 0;
438  right = debugsoldata->nsolvals-1;
439  while( left <= right )
440  {
441  middle = (left+right)/2;
442  cmp = strcmp(name, debugsoldata->solnames[middle]);
443  if( cmp < 0 )
444  right = middle-1;
445  else if( cmp > 0 )
446  left = middle+1;
447  else
448  {
449  *val = scalar * debugsoldata->solvals[middle] + constant;
450 
451  if( SCIPsetIsFeasLT(set, *val, SCIPvarGetLbGlobal(var)) || SCIPsetIsFeasGT(set, *val, SCIPvarGetUbGlobal(var)) )
452  {
453  SCIPmessagePrintWarning(SCIPgetMessagehdlr(set->scip), "invalid solution value %.15g for variable <%s>[%.15g,%.15g]\n",
454  *val, SCIPvarGetName(var), SCIPvarGetLbGlobal(var), SCIPvarGetUbGlobal(var));
455  }
456 
457  return SCIP_OKAY;
458  }
459  }
460  *val = constant;
461 
462  if( SCIPsetIsFeasLT(set, *val, SCIPvarGetLbGlobal(var)) || SCIPsetIsFeasGT(set, *val, SCIPvarGetUbGlobal(var)) )
463  {
464  SCIPmessagePrintWarning(SCIPgetMessagehdlr(set->scip), "invalid solution value %.15g for variable <%s>[%.15g,%.15g]\n",
465  *val, SCIPvarGetName(var), SCIPvarGetLbGlobal(var), SCIPvarGetUbGlobal(var));
466  }
467 
468  return SCIP_OKAY;
469 }
470 
471 /** gets pointer to the debug solution */
472 SCIP_RETCODE SCIPdebugGetSol(
473  SCIP* scip, /**< SCIP data structure */
474  SCIP_SOL** sol /**< buffer to store pointer to the debug solution */
475  )
476 {
477  SCIP_DEBUGSOLDATA* debugsoldata;
478 
479  debugsoldata = SCIPsetGetDebugSolData(scip->set);
480  assert(scip != NULL);
481  assert(sol != NULL);
482 
483  *sol = NULL;
484 
485  /* check whether a debug solution is available */
486  if( !debugSolutionAvailable(scip->set) )
487  return SCIP_OKAY;
488 
489  SCIP_CALL( readSolution(scip->set) );
490 
491  if( debugsoldata->debugsol == NULL )
492  return SCIP_ERROR;
493 
494  *sol = debugsoldata->debugsol;
495 
496  return SCIP_OKAY;
497 }
498 
499 /** gets value for a variable in the debug solution
500  *
501  * if no value is stored for the variable, gives 0.0
502  */
504  SCIP* scip, /**< SCIP data structure */
505  SCIP_VAR* var, /**< variable for which to get the value */
506  SCIP_Real* val /**< buffer to store solution value */
507  )
508 {
509  SCIP_CALL( getSolutionValue(scip->set, var, val) );
510 
511  return SCIP_OKAY;
512 }
513 
514 /** returns whether the debug solution is worse than the best known solution or if the debug solution was found */
515 static
516 SCIP_Bool debugSolIsAchieved(
517  SCIP_SET* set /**< global SCIP settings */
518  )
519 {
520  SCIP_SOL* bestsol;
521  SCIP* scip;
522  SCIP_DEBUGSOLDATA* debugsoldata;
523 
524  /* check whether a debug solution is available */
525  if( !debugSolutionAvailable(set) )
526  return SCIP_OKAY;
527 
528  assert(set != NULL);
529  debugsoldata = SCIPsetGetDebugSolData(set);
530 
531  assert(debugsoldata != NULL);
532 
533  if( debugsoldata->solisachieved )
534  return TRUE;
535 
536  assert(set != NULL);
537 
538  scip = set->scip;
539  assert(scip != NULL);
540 
541  bestsol = SCIPgetBestSol(scip);
542 
543  if( bestsol != NULL )
544  {
545  SCIP_Real solvalue;
546 
547  /* don't check solution while in problem creation stage */
548  if( SCIPsetGetStage(set) == SCIP_STAGE_PROBLEM )
549  return TRUE;
550 
551  solvalue = SCIPgetSolOrigObj(scip, bestsol);
552 
553  /* make sure a debug solution has been read, so we do not compare against the initial debugsolval == 0 */
554  SCIP_CALL( readSolution(set) );
555 
556  if( (SCIPgetObjsense(scip) == SCIP_OBJSENSE_MINIMIZE && SCIPsetIsLE(set, solvalue, debugsoldata->debugsolval))
557  || (SCIPgetObjsense(scip) == SCIP_OBJSENSE_MAXIMIZE && SCIPsetIsGE(set, solvalue, debugsoldata->debugsolval)) )
558  debugsoldata->solisachieved = TRUE;
559  }
560 
561  return debugsoldata->solisachieved;
562 }
563 
564 /** returns whether the solution is contained in node's subproblem */
565 static
566 SCIP_RETCODE isSolutionInNode(
567  BMS_BLKMEM* blkmem, /**< block memory */
568  SCIP_SET* set, /**< global SCIP settings */
569  SCIP_NODE* node, /**< local node where this bound change was applied */
570  SCIP_Bool* solcontained /**< pointer to store whether the solution is contained in node's subproblem */
571  )
572 {
573  SCIP_Bool* boolptr;
574  SCIP_DEBUGSOLDATA* debugsoldata;
575 
576  assert(set != NULL);
577  assert(blkmem != NULL);
578  assert(node != NULL);
579  assert(solcontained != NULL);
580 
581  /* check whether a debug solution is available */
582  if( !debugSolutionAvailable(set) )
583  return SCIP_OKAY;
584 
585  debugsoldata = SCIPsetGetDebugSolData(set);
586  assert(debugsoldata != NULL);
587 
588  if( debugsoldata ->debugsoldisabled )
589  {
590  *solcontained = FALSE;
591  return SCIP_OKAY;
592  }
593 
594  /* generate the hashmap */
595  if( debugsoldata->solinnode == NULL )
596  {
597  SCIP_CALL( SCIPhashmapCreate(&debugsoldata->solinnode, blkmem, SCIP_HASHSIZE_DEBUG) );
598  }
599 
600  /* check, whether we know already whether the solution is contained in the given node */
601  boolptr = (SCIP_Bool*)SCIPhashmapGetImage(debugsoldata->solinnode, (void*)node);
602  if( boolptr != NULL )
603  {
604  if( boolptr != &debugsoldata->falseptr && boolptr != &debugsoldata->trueptr )
605  {
606  SCIPerrorMessage("wrong value in node hashmap\n");
607  SCIPABORT();
608  return SCIP_ERROR;
609  }
610  *solcontained = *boolptr;
611  return SCIP_OKAY;
612  }
613 
614  /* if the solution is not contained in the parent of the node, it cannot be contained in the current node */
615  *solcontained = TRUE;
616  if( node->parent != NULL )
617  {
618  SCIP_CALL( isSolutionInNode(blkmem, set, node->parent, solcontained) );
619  }
620 
621  if( *solcontained )
622  {
623  /* check whether the bound changes at the current node remove the debugging solution from the subproblem */
624  if( node->domchg != NULL )
625  {
626  SCIP_DOMCHGBOUND* domchgbound;
627  SCIP_BOUNDCHG* boundchgs;
628  int i;
629 
630  domchgbound = &node->domchg->domchgbound;
631  boundchgs = domchgbound->boundchgs;
632  for( i = 0; i < (int)domchgbound->nboundchgs && *solcontained; ++i )
633  {
634  SCIP_Real varsol;
635 
636  /* get solution value of variable */
637  SCIP_CALL( getSolutionValue(set, boundchgs[i].var, &varsol) );
638 
639  if( varsol != SCIP_UNKNOWN ) /*lint !e777*/
640  {
641  /* compare the bound change with the solution value */
642  if( SCIPboundchgGetBoundtype(&boundchgs[i]) == SCIP_BOUNDTYPE_LOWER )
643  *solcontained = SCIPsetIsFeasGE(set, varsol, boundchgs[i].newbound);
644  else
645  *solcontained = SCIPsetIsFeasLE(set, varsol, boundchgs[i].newbound);
646 
647  if( !(*solcontained) && SCIPboundchgGetBoundchgtype(&boundchgs[i]) != SCIP_BOUNDCHGTYPE_BRANCHING )
648  {
649  SCIPerrorMessage("debugging solution was cut off in local node %p at depth %d by inference <%s>[%.15g] %s %.15g\n",
650  node, SCIPnodeGetDepth(node), SCIPvarGetName(boundchgs[i].var), varsol,
651  SCIPboundchgGetBoundtype(&boundchgs[i]) == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=", boundchgs[i].newbound);
652  SCIPABORT();
653  }
654  }
655  else if( SCIPboundchgGetBoundchgtype(&boundchgs[i]) == SCIP_BOUNDCHGTYPE_BRANCHING )
656  {
657  /* we branched on a variable were we don't know the solution: no debugging can be applied in this subtree */
658  *solcontained = FALSE;
659  }
660  }
661  }
662  }
663 
664  /* remember the status of the current node */
665  SCIP_CALL( SCIPhashmapSetImage(debugsoldata->solinnode, (void*)node, *solcontained ? (void*)(&debugsoldata->trueptr) : (void*)(&debugsoldata->falseptr)) );
666 
667  return SCIP_OKAY;
668 }
669 
670 /** frees the debug solution */
672  SCIP_SET* set
673  )
674 {
675  SCIP_DEBUGSOLDATA* debugsoldata;
676 
677  debugsoldata = SCIPsetGetDebugSolData(set);
678  assert(debugsoldata != NULL);
679 
680  if( debugsoldata->debugsol != NULL && ((SCIPgetStage(set->scip) > SCIP_STAGE_PROBLEM && debugsoldata->debugsolstage > SCIP_STAGE_PROBLEM)
681  || (SCIPgetStage(set->scip) <= SCIP_STAGE_PROBLEM && debugsoldata->debugsolstage <= SCIP_STAGE_PROBLEM)) )
682  {
683  SCIP_CALL( SCIPfreeSol(set->scip, &debugsoldata->debugsol) );
684  }
685 
686  return SCIP_OKAY;
687 }
688 
689 /** resets the data structure after restart */
691  SCIP_SET* set
692  )
693 {
694  SCIP_DEBUGSOLDATA* debugsoldata;
695 
696  assert(set != NULL);
697 
698  debugsoldata = SCIPsetGetDebugSolData(set);
699  assert(debugsoldata != NULL);
700 
701  if( debugsoldata->solinnode != NULL )
702  {
703  SCIP_CALL( SCIPhashmapRemoveAll(debugsoldata->solinnode) );
704  }
705 
706  return SCIP_OKAY;
707 }
708 
709 /** frees all debugging solution data */
711  SCIP_SET* set /**< global SCIP settings */
712  )
713 {
714  int s;
715 
716  SCIP_DEBUGSOLDATA* debugsoldata;
717  assert(set != NULL);
718 
719  debugsoldata = SCIPsetGetDebugSolData(set);
720  assert(debugsoldata != NULL);
721 
722  for( s = debugsoldata->nsolvals - 1; s >= 0; --s )
723  BMSfreeMemoryArrayNull(&(debugsoldata->solnames[s]));
724 
725  BMSfreeMemoryArrayNull(&debugsoldata->solnames);
726  BMSfreeMemoryArrayNull(&debugsoldata->solvals);
727 
728  debugsoldata->nsolvals = 0;
729  debugsoldata->debugsolval= 0.0;
730  debugsoldata->solisachieved = FALSE;
731 
732  if( debugsoldata->solinnode != NULL)
733  SCIPhashmapFree(&debugsoldata->solinnode);
734 
735  /* free the debug solution */
736  SCIP_CALL( SCIPdebugFreeSol(set) );
737 
738  BMSfreeMemoryNull(&debugsoldata);
739 
740  set->debugsoldata = NULL;
741 
742  return SCIP_OKAY;
743 }
744 
745 /** checks for validity of the debugging solution in given constraints */
747  SCIP* scip, /**< SCIP data structure */
748  SCIP_CONS** conss, /**< constraints to check for validity */
749  int nconss /**< number of given constraints */
750  )
751 {
752  SCIP_RESULT result;
753  int c;
754 
755  SCIP_DEBUGSOLDATA* debugsoldata;
756  assert(scip->set != NULL);
757 
758  /* check if we are in the original problem and not in a sub MIP */
759  if( !SCIPdebugSolIsEnabled(scip) )
760  return SCIP_OKAY;
761 
762  /* check whether a debug solution is available */
763  if( !debugSolutionAvailable(scip->set) )
764  return SCIP_OKAY;
765 
766  debugsoldata = SCIPsetGetDebugSolData(scip->set);
767 
768  assert(conss != NULL || nconss == 0);
769  assert(debugsoldata->debugsol != NULL);
770 
771  /* check if the incumbent solution is at least as good as the debug solution, so we can stop to check the debug
772  * solution
773  */
774  if( debugSolIsAchieved(scip->set) )
775  return SCIP_OKAY;
776 
777  result = SCIP_FEASIBLE;
778 
779  /* checking each given constraint against the debugging solution */
780  for( c = nconss - 1; c >= 0; --c )
781  {
782  assert(conss[c] != NULL);
783 
784  if( !SCIPconsIsActive(conss[c]) )
785  continue;
786 
787  assert(SCIPconsGetActiveDepth(conss[c]) <= SCIPgetDepth(scip));
788 
789  /* if the cons is only locally valid, check whether the debugging solution is contained in the local subproblem */
790  if( SCIPconsIsLocal(conss[c]) )
791  {
792  SCIP_Bool solcontained;
793 
794  SCIP_CALL( isSolutionInNode(SCIPblkmem(scip), scip->set, SCIPgetCurrentNode(scip), &solcontained) );
795  if( !solcontained )
796  return SCIP_OKAY;
797  }
798 
799  SCIP_CALL( SCIPcheckCons(scip, conss[c], debugsoldata->debugsol, TRUE, TRUE, TRUE, &result) );
800 
801  SCIPdebugMsg(scip, " -> checking of constraint %s returned result <%d>\n", SCIPconsGetName(conss[c]), result);
802 
803  if( result != SCIP_FEASIBLE )
804  {
805  SCIPerrorMessage("constraint %s violates the debugging solution\n", SCIPconsGetName(conss[c]));
806  SCIPABORT();
807  }
808  }
809 
810  return SCIP_OKAY;
811 }
812 
813 /** checks whether given row is valid for the debugging solution */
815  SCIP_SET* set, /**< global SCIP settings */
816  SCIP_ROW* row /**< row to check for validity */
817  )
818 {
819  SCIP_COL** cols;
820  SCIP_Real* vals;
821  SCIP_Real lhs;
822  SCIP_Real rhs;
823  int nnonz;
824  int i;
825  SCIP_Real minactivity;
826  SCIP_Real maxactivity;
827  SCIP_Real solval;
828 
829  assert(set != NULL);
830  assert(row != NULL);
831 
832  /* when debugging was disabled the solution is not defined to be not valid in the current subtree */
833  if( !SCIPdebugSolIsEnabled(set->scip) )
834  return SCIP_OKAY;
835 
836  /* check whether a debug solution is available */
837  if( !debugSolutionAvailable(set) )
838  return SCIP_OKAY;
839 
840  /* check if the incumbent solution is at least as good as the debug solution, so we can stop to check the debug solution */
841  if( debugSolIsAchieved(set) )
842  return SCIP_OKAY;
843 
844  /* if the row is only locally valid, check whether the debugging solution is contained in the local subproblem */
845  if( SCIProwIsLocal(row) )
846  {
847  SCIP_Bool solcontained;
848 
849  SCIP_CALL( isSolutionInNode(SCIPblkmem(set->scip), set, SCIPgetCurrentNode(set->scip), &solcontained) );
850  if( !solcontained )
851  return SCIP_OKAY;
852  }
853 
854  cols = SCIProwGetCols(row);
855  vals = SCIProwGetVals(row);
856  nnonz = SCIProwGetNNonz(row);
857  lhs = SCIProwGetLhs(row);
858  rhs = SCIProwGetRhs(row);
859 
860  /* calculate row's activity on debugging solution */
861  minactivity = SCIProwGetConstant(row);
862  maxactivity = minactivity;
863  for( i = 0; i < nnonz; ++i )
864  {
865  SCIP_VAR* var;
866 
867  /* get solution value of variable in debugging solution */
868  var = SCIPcolGetVar(cols[i]);
869  SCIP_CALL( getSolutionValue(set, var, &solval) );
870 
871  if( solval != SCIP_UNKNOWN ) /*lint !e777*/
872  {
873  minactivity += vals[i] * solval;
874  maxactivity += vals[i] * solval;
875  }
876  else if( vals[i] > 0.0 )
877  {
878  minactivity += vals[i] * SCIPvarGetLbGlobal(var);
879  maxactivity += vals[i] * SCIPvarGetUbGlobal(var);
880  }
881  else if( vals[i] < 0.0 )
882  {
883  minactivity += vals[i] * SCIPvarGetUbGlobal(var);
884  maxactivity += vals[i] * SCIPvarGetLbGlobal(var);
885  }
886  }
887  SCIPsetDebugMsg(set, "debugging solution on row <%s>: %g <= [%g,%g] <= %g\n",
888  SCIProwGetName(row), lhs, minactivity, maxactivity, rhs);
889 
890  /* check row for violation, using absolute LP feasibility tolerance (as LP solver should do) */
891  if( maxactivity + SCIPgetLPFeastol(set->scip) < lhs || minactivity - SCIPgetLPFeastol(set->scip) > rhs )
892  {
893  printf("***** debug: row <%s> violates debugging solution (lhs=%.15g, rhs=%.15g, activity=[%.15g,%.15g], local=%u, lpfeastol=%g)\n",
894  SCIProwGetName(row), lhs, rhs, minactivity, maxactivity, SCIProwIsLocal(row), SCIPgetLPFeastol(set->scip));
895  SCIProwPrint(row, SCIPgetMessagehdlr(set->scip), NULL);
896 
897  /* output row with solution values */
898  printf("\n\n");
899  printf("***** debug: violated row <%s>:\n", SCIProwGetName(row));
900  printf(" %.15g <= %.15g", lhs, SCIProwGetConstant(row));
901  for( i = 0; i < nnonz; ++i )
902  {
903  /* get solution value of variable in debugging solution */
904  SCIP_CALL( getSolutionValue(set, SCIPcolGetVar(cols[i]), &solval) );
905  printf(" %+.15g<%s>[%.15g]", vals[i], SCIPvarGetName(SCIPcolGetVar(cols[i])), solval);
906  }
907  printf(" <= %.15g\n", rhs);
908 
909  SCIPABORT();
910  }
911 
912  return SCIP_OKAY;
913 }
914 
915 /** checks whether given global lower bound is valid for the debugging solution */
917  SCIP* scip, /**< SCIP data structure */
918  SCIP_VAR* var, /**< problem variable */
919  SCIP_Real lb /**< lower bound */
920  )
921 {
922  SCIP_Real varsol;
923 
924  assert(scip != NULL);
925  assert(var != NULL);
926 
927  /* check if we are in the original problem and not in a sub MIP */
928  if( !SCIPdebugSolIsEnabled(scip) )
929  return SCIP_OKAY;
930 
931  /* check whether a debug solution is available */
932  if( !debugSolutionAvailable(scip->set) )
933  return SCIP_OKAY;
934 
935  if( SCIPgetStage(scip) == SCIP_STAGE_PROBLEM )
936  return SCIP_OKAY;
937 
938  /* skip unused relaxation-only variables
939  * Relaxation-only variables are not part of any constraints or the original problem and thus there is no need to check their solution value.
940  * However, for relaxation-only variables that are still in use for the current solve round and for which a debug solution value has been set,
941  * checking against the debug solution value is helpful. If they not in use anymore, they will be captured only by the transformed problem
942  * and they may get fixed to some arbitrary value, e.g., in dual fixing.
943  * Thus, we skip checking bound changes on unused relaxation-only variables.
944  */
945  if( SCIPvarIsRelaxationOnly(var) && SCIPvarGetNUses(var) == 1 )
946  return SCIP_OKAY;
947 
948  /* check if the incumbent solution is at least as good as the debug solution, so we can stop to check the debug solution */
949  if( debugSolIsAchieved(scip->set) )
950  return SCIP_OKAY;
951 
952  /* get solution value of variable */
953  SCIP_CALL( getSolutionValue(scip->set, var, &varsol) );
954  SCIPdebugMsg(scip, "debugging solution on lower bound of <%s>[%g] >= %g\n", SCIPvarGetName(var), varsol, lb);
955 
956  /* check validity of debugging solution */
957  if( varsol != SCIP_UNKNOWN && SCIPisFeasLT(scip, varsol, lb) ) /*lint !e777*/
958  {
959  SCIPerrorMessage("invalid global lower bound: <%s>[%.15g] >= %.15g\n", SCIPvarGetName(var), varsol, lb);
960  SCIPABORT();
961  }
962 
963  return SCIP_OKAY;
964 }
965 
966 /** checks whether given global upper bound is valid for the debugging solution */
968  SCIP* scip, /**< SCIP data structure */
969  SCIP_VAR* var, /**< problem variable */
970  SCIP_Real ub /**< upper bound */
971  )
972 {
973  SCIP_Real varsol;
974 
975  assert(scip != NULL);
976  assert(var != NULL);
977 
978  /* when debugging was disabled the solution is not defined to be not valid in the current subtree */
979  if( !SCIPdebugSolIsEnabled(scip) )
980  return SCIP_OKAY;
981 
982  /* check whether a debug solution is available */
983  if( !debugSolutionAvailable(scip->set) )
984  return SCIP_OKAY;
985 
986  if( SCIPgetStage(scip) == SCIP_STAGE_PROBLEM )
987  return SCIP_OKAY;
988 
989  /* skip unused relaxation-only variables, see also comment in SCIPdebugCheckLbGlobal() */
990  if( SCIPvarIsRelaxationOnly(var) && SCIPvarGetNUses(var) == 1 )
991  return SCIP_OKAY;
992 
993  /* check if the incumbent solution is at least as good as the debug solution, so we can stop to check the debug solution */
994  if( debugSolIsAchieved(scip->set) )
995  return SCIP_OKAY;
996 
997  /* get solution value of variable */
998  SCIP_CALL( getSolutionValue(scip->set, var, &varsol) );
999  SCIPdebugMsg(scip, "debugging solution on upper bound of <%s>[%g] <= %g\n", SCIPvarGetName(var), varsol, ub);
1000 
1001  /* check validity of debugging solution */
1002  if( varsol != SCIP_UNKNOWN && SCIPisFeasGT(scip, varsol, ub) ) /*lint !e777*/
1003  {
1004  SCIPerrorMessage("invalid global upper bound: <%s>[%.15g] <= %.15g\n", SCIPvarGetName(var), varsol, ub);
1005  SCIPABORT();
1006  }
1007 
1008  return SCIP_OKAY;
1009 }
1010 
1011 /** checks whether given local bound implication is valid for the debugging solution */
1013  BMS_BLKMEM* blkmem, /**< block memory */
1014  SCIP_SET* set, /**< global SCIP settings */
1015  SCIP_NODE* node, /**< local node where this bound change was applied */
1016  SCIP_VAR* var, /**< problem variable */
1017  SCIP_Real newbound, /**< new value for bound */
1018  SCIP_BOUNDTYPE boundtype /**< type of bound: lower or upper bound */
1019  )
1020 {
1021  SCIP_Real varsol;
1022  SCIP_Bool solcontained;
1023 
1024  assert(set != NULL);
1025  assert(blkmem != NULL);
1026  assert(node != NULL);
1027  assert(var != NULL);
1028 
1029  /* in case we are in probing or diving we have to avoid checking the solution */
1030  if( SCIPlpDiving(set->scip->lp) || SCIPtreeProbing(set->scip->tree) )
1031  return SCIP_OKAY;
1032 
1033  /* when debugging was disabled the solution is not defined to be not valid in the current subtree */
1034  if( !SCIPdebugSolIsEnabled(set->scip) )
1035  return SCIP_OKAY;
1036 
1037  /* check whether a debug solution is available */
1038  if( !debugSolutionAvailable(set) )
1039  return SCIP_OKAY;
1040 
1041  /* check if the incumbent solution is at least as good as the debug solution, so we can stop to check the debug solution */
1042  if( debugSolIsAchieved(set) )
1043  return SCIP_OKAY;
1044 
1045  /* check whether the debugging solution is contained in the local subproblem */
1046  SCIP_CALL( isSolutionInNode(blkmem, set, node, &solcontained) );
1047  if( !solcontained )
1048  return SCIP_OKAY;
1049 
1050  /* get solution value of variable */
1051  SCIP_CALL( getSolutionValue(set, var, &varsol) );
1052 
1053  /* check validity of debugging solution */
1054  if( varsol != SCIP_UNKNOWN ) /*lint !e777*/
1055  {
1056  if( boundtype == SCIP_BOUNDTYPE_LOWER && SCIPsetIsFeasLT(set, varsol, newbound) )
1057  {
1058  SCIPerrorMessage("invalid local lower bound implication: <%s>[%.15g] >= %.15g\n", SCIPvarGetName(var), varsol, newbound);
1059  SCIPABORT();
1060  }
1061  if( boundtype == SCIP_BOUNDTYPE_UPPER && SCIPsetIsFeasGT(set, varsol, newbound) )
1062  {
1063  SCIPerrorMessage("invalid local upper bound implication: <%s>[%.15g] <= %.15g\n", SCIPvarGetName(var), varsol, newbound);
1064  SCIPABORT();
1065  }
1066  }
1067 
1068  return SCIP_OKAY;
1069 }
1070 
1071 /** informs solution debugger, that the given node will be freed */
1073  BMS_BLKMEM* blkmem, /**< block memory */
1074  SCIP_SET* set, /**< global SCIP settings */
1075  SCIP_NODE* node /**< node that will be freed */
1076  )
1077 {
1078  SCIP_DEBUGSOLDATA* debugsoldata;
1079 
1080  assert(set != NULL);
1081  assert(blkmem != NULL);
1082  assert(node != NULL);
1083 
1084  debugsoldata = SCIPsetGetDebugSolData(set);
1085  assert(debugsoldata != NULL);
1086 
1087  /* when debugging was disabled the solution is not defined to be not valid in the current subtree */
1088  if( !SCIPdebugSolIsEnabled(set->scip) )
1089  return SCIP_OKAY;
1090 
1091  /* check whether a debug solution is available */
1092  if( !debugSolutionAvailable(set) )
1093  return SCIP_OKAY;
1094 
1095  /* check if the incumbent solution is at least as good as the debug solution, so we can stop to check the debug solution */
1096  if( debugSolIsAchieved(set) )
1097  return SCIP_OKAY;
1098 
1099  /* check if a solution will be cutoff in tree */
1102  {
1103  SCIP_Bool solisinnode;
1104 
1105  solisinnode = FALSE;
1106 
1107  SCIP_CALL( isSolutionInNode(blkmem, set, node, &solisinnode) );
1108  /* wrong node will be cutoff */
1109  if( solisinnode )
1110  {
1111  SCIPerrorMessage("debugging solution was cut off in local node #%" SCIP_LONGINT_FORMAT " (%p) at depth %d\n",
1112  node->number, node, SCIPnodeGetDepth(node));
1113  SCIPABORT();
1114  }
1115  }
1116 
1117  /* remove node from the hash map */
1118  if( debugsoldata->solinnode != NULL )
1119  {
1120  SCIP_CALL( SCIPhashmapRemove(debugsoldata->solinnode, (void*)node) );
1121  }
1122 
1123  return SCIP_OKAY;
1124 }
1125 
1126 /** checks whether given variable bound is valid for the debugging solution */
1128  SCIP_SET* set, /**< global SCIP settings */
1129  SCIP_VAR* var, /**< problem variable x in x <= b*z + d or x >= b*z + d */
1130  SCIP_BOUNDTYPE vbtype, /**< type of variable bound (LOWER or UPPER) */
1131  SCIP_VAR* vbvar, /**< variable z in x <= b*z + d or x >= b*z + d */
1132  SCIP_Real vbcoef, /**< coefficient b in x <= b*z + d or x >= b*z + d */
1133  SCIP_Real vbconstant /**< constant d in x <= b*z + d or x >= b*z + d */
1134  )
1135 {
1136  SCIP_Real varsol;
1137  SCIP_Real vbvarsol;
1138  SCIP_Real vb;
1139 
1140  assert(set != NULL);
1141  assert(var != NULL);
1142 
1143  /* when debugging was disabled the solution is not defined to be not valid in the current subtree */
1144  if( !SCIPdebugSolIsEnabled(set->scip) )
1145  return SCIP_OKAY;
1146 
1147  /* check whether a debug solution is available */
1148  if( !debugSolutionAvailable(set) )
1149  return SCIP_OKAY;
1150 
1151  /* check if the incumbent solution is at least as good as the debug solution, so we can stop to check the debug solution */
1152  if( debugSolIsAchieved(set) )
1153  return SCIP_OKAY;
1154 
1155  /* get solution value of variables */
1156  SCIP_CALL( getSolutionValue(set, var, &varsol) );
1157  SCIP_CALL( getSolutionValue(set, vbvar, &vbvarsol) );
1158 
1159  /* check validity of debugging solution */
1160  if( varsol != SCIP_UNKNOWN && vbvarsol != SCIP_UNKNOWN ) /*lint !e777*/
1161  {
1162  vb = vbcoef * vbvarsol + vbconstant;
1163  if( (vbtype == SCIP_BOUNDTYPE_LOWER && SCIPsetIsFeasLT(set, varsol, vb))
1164  || (vbtype == SCIP_BOUNDTYPE_UPPER && SCIPsetIsFeasGT(set, varsol, vb)) )
1165  {
1166  SCIPerrorMessage("invalid variable bound: <%s>[%.15g] %s %.15g<%s>[%.15g] %+.15g\n",
1167  SCIPvarGetName(var), varsol, vbtype == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=", vbcoef,
1168  SCIPvarGetName(vbvar), vbvarsol, vbconstant);
1169  SCIPABORT();
1170  }
1171  }
1172 
1173  return SCIP_OKAY;
1174 }
1175 
1176 /** checks whether given implication is valid for the debugging solution */
1178  SCIP_SET* set, /**< global SCIP settings */
1179  SCIP_VAR* var, /**< problem variable */
1180  SCIP_Bool varfixing, /**< FALSE if y should be added in implications for x == 0, TRUE for x == 1 */
1181  SCIP_VAR* implvar, /**< variable y in implication y <= b or y >= b */
1182  SCIP_BOUNDTYPE impltype, /**< type of implication y <= b (SCIP_BOUNDTYPE_UPPER) or y >= b (SCIP_BOUNDTYPE_LOWER) */
1183  SCIP_Real implbound /**< bound b in implication y <= b or y >= b */
1184  )
1185 {
1186  SCIP_Real solval;
1187 
1188  assert(set != NULL);
1189  assert(var != NULL);
1190  assert(SCIPvarGetType(var) == SCIP_VARTYPE_BINARY);
1191 
1192  /* when debugging was disabled the solution is not defined to be not valid in the current subtree */
1193  if( !SCIPdebugSolIsEnabled(set->scip) )
1194  return SCIP_OKAY;
1195 
1196  /* check whether a debug solution is available */
1197  if( !debugSolutionAvailable(set) )
1198  return SCIP_OKAY;
1199 
1200  /* check if the incumbent solution is at least as good as the debug solution, so we can stop to check the debug solution */
1201  if( debugSolIsAchieved(set) )
1202  return SCIP_OKAY;
1203 
1204  /* get solution value of variable */
1205  SCIP_CALL( getSolutionValue(set, var, &solval) );
1206  if( solval == SCIP_UNKNOWN ) /*lint !e777*/
1207  return SCIP_OKAY;
1208  assert(SCIPsetIsFeasZero(set, solval) || SCIPsetIsFeasEQ(set, solval, 1.0));
1209 
1210  /* check, whether the implication applies for the debugging solution */
1211  if( (solval > 0.5) != varfixing )
1212  return SCIP_OKAY;
1213 
1214  /* get solution value of implied variable */
1215  SCIP_CALL( getSolutionValue(set, implvar, &solval) );
1216  if( solval == SCIP_UNKNOWN ) /*lint !e777*/
1217  return SCIP_OKAY;
1218 
1219  if( impltype == SCIP_BOUNDTYPE_LOWER )
1220  {
1221  if( SCIPsetIsFeasLT(set, solval, implbound) )
1222  {
1223  SCIPerrorMessage("invalid implication <%s> == %d -> <%s> >= %.15g (variable has value %.15g in solution)\n",
1224  SCIPvarGetName(var), varfixing, SCIPvarGetName(implvar), implbound, solval);
1225  SCIPABORT();
1226  }
1227  }
1228  else
1229  {
1230  if( SCIPsetIsFeasGT(set, solval, implbound) )
1231  {
1232  SCIPerrorMessage("invalid implication <%s> == %d -> <%s> <= %.15g (variable has value %.15g in solution)\n",
1233  SCIPvarGetName(var), varfixing, SCIPvarGetName(implvar), implbound, solval);
1234  SCIPABORT();
1235  }
1236  }
1237 
1238  return SCIP_OKAY;
1239 }
1240 
1241 /** checks whether given (multi)-aggregation is valid for the debugging solution */
1243  SCIP_SET* set, /**< global SCIP settings */
1244  SCIP_VAR* var, /**< problem variable */
1245  SCIP_VAR** aggrvars, /**< variables y_i in aggregation x = a_1*y_1 + ... + a_n*y_n + c */
1246  SCIP_Real* scalars, /**< multipliers a_i in aggregation x = a_1*y_1 + ... + a_n*y_n + c */
1247  SCIP_Real constant, /**< constant shift c in aggregation x = a_1*y_1 + ... + a_n*y_n + c */
1248  int naggrvars /**< number n of variables in aggregation x = a_1*y_1 + ... + a_n*y_n + c */
1249  )
1250 {
1251  SCIP_Real solval;
1252  SCIP_Real val;
1253  int i;
1254 
1255  assert(set != NULL);
1256  assert(var != NULL);
1257  assert(aggrvars != NULL);
1258  assert(scalars != NULL);
1259  assert(naggrvars >= 1);
1260 
1261  /* when debugging was disabled the solution is not defined to be not valid in the current subtree */
1262  if( !SCIPdebugSolIsEnabled(set->scip) )
1263  return SCIP_OKAY;
1264 
1265  /* check whether a debug solution is available */
1266  if( !debugSolutionAvailable(set) )
1267  return SCIP_OKAY;
1268 
1269  /* check if the incumbent solution is at least as good as the debug solution, so we can stop to check the debug solution */
1270  if( debugSolIsAchieved(set) )
1271  return SCIP_OKAY;
1272 
1273  /* get solution value of x variable */
1274  SCIP_CALL( getSolutionValue(set, var, &solval) );
1275 
1276  if( solval == SCIP_UNKNOWN ) /*lint !e777*/
1277  return SCIP_OKAY;
1278 
1279  val = constant;
1280 
1281  for( i = 0; i < naggrvars; i++ )
1282  {
1283  SCIP_Real aggrsolval;
1284 
1285  /* get solution value of y variable */
1286  SCIP_CALL( getSolutionValue(set, aggrvars[i], &aggrsolval) );
1287 
1288  if( aggrsolval == SCIP_UNKNOWN ) /*lint !e777*/
1289  return SCIP_OKAY;
1290 
1291  val += scalars[i] * aggrsolval;
1292  }
1293 
1294  /* print debug message if the aggregation violates the debugging solution */
1295  if( !SCIPsetIsRelEQ(set, solval, val) )
1296  {
1297  if( naggrvars == 1 )
1298  {
1299  SCIP_Real aggrsolval;
1300 
1301  /* get solution value of y variable */
1302  SCIP_CALL( getSolutionValue(set, aggrvars[0], &aggrsolval) );
1303 
1304  SCIPerrorMessage("aggregation <%s>[%g] = %g<%s>[%g] + %g violates debugging solution (expected %g)\n",
1305  SCIPvarGetName(var), solval, scalars[0], SCIPvarGetName(aggrvars[0]), aggrsolval, constant, val);
1306  }
1307  else
1308  {
1309  SCIPerrorMessage("multi-aggregation <%s>[%g] = ... %d vars ... + %g violates debugging solution (expected %g)\n",
1310  SCIPvarGetName(var), solval, naggrvars, constant, val);
1311  }
1312  SCIPABORT();
1313  }
1314 
1315  return SCIP_OKAY;
1316 }
1317 
1318 /** check whether given clique is valid for the debugging solution */
1320  SCIP_SET* set, /**< global SCIP settings */
1321  SCIP_VAR** vars, /**< binary variables in the clique: at most one can be set to the given value */
1322  SCIP_Bool* values, /**< values of the variables in the clique; NULL to use TRUE for all vars */
1323  int nvars /**< number of variables in the clique */
1324  )
1325 {
1326  SCIP_Real solval;
1327  int pos1;
1328  int pos2;
1329  int v;
1330 
1331  assert(set != NULL);
1332  assert(vars != NULL);
1333 
1334  /* when debugging was disabled the solution is not defined to be not valid in the current subtree */
1335  if( !SCIPdebugSolIsEnabled(set->scip) )
1336  return SCIP_OKAY;
1337 
1338  /* check whether a debug solution is available */
1339  if( !debugSolutionAvailable(set) )
1340  return SCIP_OKAY;
1341 
1342  /* check if the incumbent solution is at least as good as the debug solution, so we can stop to check the debug solution */
1343  if( debugSolIsAchieved(set) )
1344  return SCIP_OKAY;
1345 
1346  pos1 = -1;
1347  pos2 = -1;
1348 
1349  for( v = 0; v < nvars; ++v )
1350  {
1351  assert(vars[v] != NULL);
1352  assert(SCIPvarIsBinary(vars[v]));
1353 
1354  /* get solution value of variable */
1355  SCIP_CALL( getSolutionValue(set, vars[v], &solval) );
1356 
1357  if( solval == SCIP_UNKNOWN ) /*lint !e777*/
1358  continue;
1359 
1360  assert(SCIPsetIsFeasZero(set, solval) || SCIPsetIsFeasEQ(set, solval, 1.0));
1361 
1362  /* negated solution value if negated variable is in clique */
1363  if( values != NULL && values[v] == 0 )
1364  solval = 1.0 - solval;
1365 
1366  if( SCIPsetIsFeasEQ(set, solval, 1.0) )
1367  {
1368  if( pos1 == -1 )
1369  pos1 = v;
1370  else
1371  {
1372  assert(pos2 == -1);
1373  pos2 = v;
1374  break;
1375  }
1376  }
1377  }
1378 
1379  /* print debug message if the clique violates the debugging solution */
1380  if( pos2 != -1 )
1381  {
1382  assert(pos1 != -1);
1383  SCIPerrorMessage("clique violates debugging solution, (at least) variable <%s%s> and variable <%s%s> are both one in the debugging solution\n",
1384  (values == NULL || values[pos1]) ? "" : "~", SCIPvarGetName(vars[pos1]), (values == NULL || values[pos2]) ? "" : "~", SCIPvarGetName(vars[pos2]));
1385  SCIPABORT();
1386  }
1387 
1388  return SCIP_OKAY;
1389 }
1390 
1391 /** check, whether at least one literals is TRUE in the debugging solution */
1392 static
1393 SCIP_Bool debugCheckBdchginfos(
1394  SCIP_SET* set, /**< global SCIP settings */
1395  SCIP_BDCHGINFO** bdchginfos, /**< bound change informations of the conflict set */
1396  SCIP_Real* relaxedbds, /**< array with relaxed bounds which are efficient to create a valid conflict, or NULL */
1397  int nbdchginfos /**< number of bound changes in the conflict set */
1398  )
1399 {
1400  SCIP_Real solval;
1401  int i;
1402 
1403  /* check whether a debug solution is available */
1404  if( !debugSolutionAvailable(set) )
1405  return SCIP_OKAY;
1406 
1407  assert(SCIPdebugSolIsEnabled(set->scip));
1408 
1409  solval = 0.0;
1410  /* check, whether at least one literals is TRUE in the debugging solution */
1411  for( i = 0; i < nbdchginfos; ++i )
1412  {
1413  SCIP_BDCHGINFO* bdchginfo;
1414  SCIP_VAR* var;
1415  SCIP_Real newbound;
1416 
1417  bdchginfo = bdchginfos[i];
1418  assert(bdchginfo != NULL);
1419 
1420  var = SCIPbdchginfoGetVar(bdchginfo);
1421  assert(var != NULL);
1422 
1423  if( relaxedbds != NULL )
1424  newbound = relaxedbds[i];
1425  else
1426  newbound = SCIPbdchginfoGetNewbound(bdchginfo);
1427 
1428  SCIP_CALL( getSolutionValue(set, var, &solval) );
1429 
1430  if( solval == SCIP_UNKNOWN ) /*lint !e777*/
1431  return TRUE;
1432 
1434  {
1435  assert(SCIPsetIsLE(set, newbound, SCIPbdchginfoGetNewbound(bdchginfo)));
1436 
1438  {
1439  if( SCIPsetIsLE(set, solval, newbound) )
1440  return TRUE;
1441  }
1442  else
1443  {
1444  if( SCIPsetIsLT(set, solval, newbound) )
1445  return TRUE;
1446  }
1447  }
1448  else
1449  {
1450  assert(SCIPsetIsGE(set, newbound, SCIPbdchginfoGetNewbound(bdchginfo)));
1451 
1453  {
1454  if( SCIPsetIsGE(set, solval, newbound) )
1455  return TRUE;
1456  }
1457  else
1458  {
1459  if( SCIPsetIsGT(set, solval, newbound) )
1460  return TRUE;
1461  }
1462  }
1463  }
1464 
1465  return FALSE;
1466 }
1467 
1468 /** print bound change information */
1469 static
1470 SCIP_RETCODE printBdchginfo(
1471  SCIP_SET* set, /**< global SCIP settings */
1472  SCIP_BDCHGINFO * bdchginfo, /**< bound change information */
1473  SCIP_Real relaxedbd /**< array with relaxed bounds which are efficient to create a valid conflict, or NULL */
1474  )
1475 {
1476  SCIP_Real solval;
1477 
1478  /* check whether a debug solution is available */
1479  if( !debugSolutionAvailable(set) )
1480  return SCIP_OKAY;
1481 
1482  /* get solution value within the debug solution */
1483  SCIP_CALL( getSolutionValue(set, SCIPbdchginfoGetVar(bdchginfo), &solval) );
1484 
1485  printf(" <%s>[%.15g] %s %g(%g)", SCIPvarGetName(SCIPbdchginfoGetVar(bdchginfo)), solval,
1486  SCIPbdchginfoGetBoundtype(bdchginfo) == SCIP_BOUNDTYPE_LOWER ? ">=" : "<=",
1487  SCIPbdchginfoGetNewbound(bdchginfo), relaxedbd);
1488 
1489  return SCIP_OKAY;
1490 }
1491 
1492 
1493 /** print bound change information */
1494 static
1495 SCIP_RETCODE printBdchginfos(
1496  SCIP_SET* set, /**< global SCIP settings */
1497  SCIP_BDCHGINFO** bdchginfos, /**< bound change information array */
1498  SCIP_Real* relaxedbds, /**< array with relaxed bounds which are efficient to create a valid conflict, or NULL */
1499  int nbdchginfos /**< number of bound changes in the conflict set */
1500  )
1501 {
1502  int i;
1503 
1504  /* check whether a debug solution is available */
1505  if( !debugSolutionAvailable(set) )
1506  return SCIP_OKAY;
1507 
1508  for( i = 0; i < nbdchginfos; ++i )
1509  {
1510  SCIP_BDCHGINFO* bdchginfo;
1511 
1512  bdchginfo = bdchginfos[i];
1513  assert(bdchginfo != NULL);
1514 
1515  printBdchginfo(set, bdchginfo, relaxedbds != NULL ? relaxedbds[i] : SCIPbdchginfoGetNewbound(bdchginfo));
1516  }
1517 
1518  return SCIP_OKAY;
1519 }
1520 
1521 /** checks whether given conflict is valid for the debugging solution */
1523  BMS_BLKMEM* blkmem, /**< block memory */
1524  SCIP_SET* set, /**< global SCIP settings */
1525  SCIP_NODE* node, /**< node where the conflict clause is added */
1526  SCIP_BDCHGINFO** bdchginfos, /**< bound change informations of the conflict set */
1527  SCIP_Real* relaxedbds, /**< array with relaxed bounds which are efficient to create a valid conflict */
1528  int nbdchginfos /**< number of bound changes in the conflict set */
1529  )
1530 {
1531  SCIP_Bool solcontained;
1532 
1533  assert(set != NULL);
1534  assert(blkmem != NULL);
1535  assert(node != NULL);
1536  assert(nbdchginfos == 0 || bdchginfos != NULL);
1537 
1538  /* when debugging was disabled the solution is not defined to be not valid in the current subtree */
1539  if( !SCIPdebugSolIsEnabled(set->scip) )
1540  return SCIP_OKAY;
1541 
1542  /* check whether a debug solution is available */
1543  if( !debugSolutionAvailable(set) )
1544  return SCIP_OKAY;
1545 
1546  /* check if the incumbent solution is at least as good as the debug solution, so we can stop to check the debug solution */
1547  if( debugSolIsAchieved(set) )
1548  return SCIP_OKAY;
1549 
1550  /* check whether the debugging solution is contained in the local subproblem */
1551  SCIP_CALL( isSolutionInNode(blkmem, set, node, &solcontained) );
1552  if( !solcontained )
1553  return SCIP_OKAY;
1554 
1555  /* check, whether at least one literals is TRUE in the debugging solution */
1556  if( debugCheckBdchginfos(set, bdchginfos, relaxedbds, nbdchginfos) )
1557  return SCIP_OKAY;
1558 
1559  SCIPerrorMessage("invalid conflict set:");
1560 
1561  /* print bound changes which are already part of the conflict set */
1562  SCIP_CALL( printBdchginfos(set, bdchginfos, relaxedbds, nbdchginfos) );
1563 
1564  printf("\n");
1565  SCIPABORT();
1566 
1567  return SCIP_OKAY; /*lint !e527*/
1568 }
1569 
1570 /** checks whether given conflict graph frontier is valid for the debugging solution */
1572  BMS_BLKMEM* blkmem, /**< block memory */
1573  SCIP_SET* set, /**< global SCIP settings */
1574  SCIP_NODE* node, /**< node where the conflict clause is added */
1575  SCIP_BDCHGINFO* bdchginfo, /**< bound change info which got resolved, or NULL */
1576  SCIP_BDCHGINFO** bdchginfos, /**< bound change informations of the conflict set */
1577  SCIP_Real* relaxedbds, /**< array with relaxed bounds which are efficient to create a valid conflict */
1578  int nbdchginfos, /**< number of bound changes in the conflict set */
1579  SCIP_PQUEUE* bdchgqueue, /**< unprocessed conflict bound changes */
1580  SCIP_PQUEUE* forcedbdchgqueue /**< unprocessed conflict bound changes that must be resolved */
1581  )
1582 {
1583  SCIP_BDCHGINFO** bdchgqueued;
1584  SCIP_BDCHGINFO** forcedbdchgqueued;
1585  SCIP_Bool solcontained;
1586  int nbdchgqueued;
1587  int nforcedbdchgqueued;
1588 
1589  assert(set != NULL);
1590  assert(blkmem != NULL);
1591  assert(node != NULL);
1592  assert(nbdchginfos == 0 || bdchginfos != NULL);
1593 
1594  /* when debugging was disabled the solution is not defined to be not valid in the current subtree */
1595  if( !SCIPdebugSolIsEnabled(set->scip) )
1596  return SCIP_OKAY;
1597 
1598  /* check whether a debug solution is available */
1599  if( !debugSolutionAvailable(set) )
1600  return SCIP_OKAY;
1601 
1602  /* check if the incumbent solution is at least as good as the debug solution, so we can stop to check the debug solution */
1603  if( debugSolIsAchieved(set) )
1604  return SCIP_OKAY;
1605 
1606  /* check whether the debugging solution is contained in the local subproblem */
1607  SCIP_CALL( isSolutionInNode(blkmem, set, node, &solcontained) );
1608  if( !solcontained )
1609  return SCIP_OKAY;
1610 
1611  /* check, whether one literals is TRUE in the debugging solution */
1612  if( debugCheckBdchginfos(set, bdchginfos, relaxedbds, nbdchginfos) )
1613  return SCIP_OKAY;
1614 
1615  /* get the elements of the bound change queue */
1616  bdchgqueued = (SCIP_BDCHGINFO**)SCIPpqueueElems(bdchgqueue);
1617  nbdchgqueued = SCIPpqueueNElems(bdchgqueue);
1618 
1619  /* check, whether one literals is TRUE in the debugging solution */
1620  if( debugCheckBdchginfos(set, bdchgqueued, NULL, nbdchgqueued) )
1621  return SCIP_OKAY;
1622 
1623  /* get the elements of the bound change queue */
1624  forcedbdchgqueued = (SCIP_BDCHGINFO**)SCIPpqueueElems(forcedbdchgqueue);
1625  nforcedbdchgqueued = SCIPpqueueNElems(forcedbdchgqueue);
1626 
1627  /* check, whether one literals is TRUE in the debugging solution */
1628  if( debugCheckBdchginfos(set, forcedbdchgqueued, NULL, nforcedbdchgqueued) )
1629  return SCIP_OKAY;
1630 
1631  SCIPerrorMessage("invalid conflict frontier");
1632 
1633  if( bdchginfo != NULL )
1634  {
1635  printf(" (after resolving bound change ");
1636  printBdchginfo(set, bdchginfo, SCIPbdchginfoGetNewbound(bdchginfo));
1637  printf(")");
1638  }
1639  printf(":");
1640 
1641  /* print bound changes which are already part of the conflict set */
1642  SCIP_CALL( printBdchginfos(set, bdchginfos, relaxedbds, nbdchginfos) );
1643 
1644  /* print bound changes which are queued */
1645  SCIP_CALL( printBdchginfos(set, bdchgqueued, NULL, nbdchgqueued) );
1646 
1647  /* print bound changes which are queued in the force queue */
1648  SCIP_CALL( printBdchginfos(set, forcedbdchgqueued, NULL, nforcedbdchgqueued) );
1649 
1650  printf("\n");
1651  SCIPABORT();
1652 
1653  return SCIP_OKAY; /*lint !e527*/
1654 }
1655 
1656 /** check whether the debugging solution is valid in the current node */
1658  SCIP* scip, /**< SCIP data structure */
1659  SCIP_Bool* isvalidinsubtree /**< pointer to store whether the solution is valid in the current
1660  * subtree */
1661  )
1662 {
1663  SCIP_Bool solcontained;
1664 
1665  *isvalidinsubtree = FALSE;
1666 
1667  assert(scip->set != NULL);
1668 
1669  /* when debugging was disabled the solution is not defined to be not valid in the current subtree */
1670  if( !SCIPdebugSolIsEnabled(scip) )
1671  return SCIP_OKAY;
1672 
1673  /* check whether a debug solution is available */
1674  if( !debugSolutionAvailable(scip->set) )
1675  return SCIP_OKAY;
1676 
1677  /* check if the incumbent solution is at least as good as the debug solution, so we can stop to check the debug solution */
1678  if( debugSolIsAchieved(scip->set) )
1679  return SCIP_OKAY;
1680 
1681  /* check whether the debugging solution is contained in the local subproblem */
1682  SCIP_CALL( isSolutionInNode(SCIPblkmem(scip), scip->set, SCIPgetCurrentNode(scip), &solcontained) );
1683 
1684  if( solcontained )
1685  *isvalidinsubtree = TRUE;
1686 
1687  return SCIP_OKAY;
1688 }
1689 
1690 /** checks whether SCIP data structure is the main SCIP (the one for which debugging is enabled) */
1691 SCIP_Bool SCIPdebugIsMainscip(
1692  SCIP* scip /**< SCIP data structure */
1693  )
1694 {
1695  assert(scip != NULL);
1696 
1697  return SCIPdebugSolIsEnabled(scip);
1698 }
1699 
1700 /** enabling solution debugging mechanism */
1701 void SCIPdebugSolEnable(
1702  SCIP* scip /**< SCIP data structure */
1703  )
1704 {
1705  SCIP_DEBUGSOLDATA* debugsoldata;
1706  assert(scip != NULL);
1707  assert(scip->set != NULL);
1708 
1709  debugsoldata = SCIPsetGetDebugSolData(scip->set);
1710  assert(debugsoldata != NULL);
1711 
1712  debugsoldata->debugsoldisabled = FALSE;
1713 }
1714 
1715 /** disabling solution debugging mechanism */
1716 void SCIPdebugSolDisable(
1717  SCIP* scip /**< SCIP data structure */
1718  )
1719 {
1720  SCIP_DEBUGSOLDATA* debugsoldata;
1721  assert(scip != NULL);
1722  assert(scip->set != NULL);
1723 
1724  debugsoldata = SCIPsetGetDebugSolData(scip->set);
1725  assert(debugsoldata != NULL);
1726 
1727  debugsoldata->debugsoldisabled = TRUE;
1728 }
1729 
1730 /** check if solution debugging mechanism is enabled */
1732  SCIP* scip /**< SCIP data structure */
1733  )
1734 {
1735  SCIP_DEBUGSOLDATA* debugsoldata;
1736  assert(scip != NULL);
1737  assert(scip->set != NULL);
1738 
1739  debugsoldata = SCIPsetGetDebugSolData(scip->set);
1740  assert(debugsoldata != NULL);
1741 
1742  return (!debugsoldata->debugsoldisabled);
1743 }
1744 
1745 /** propagator to force finding the debugging solution */
1746 static
1747 SCIP_DECL_PROPEXEC(propExecDebug)
1748 { /*lint --e{715}*/
1749  SCIP_VAR** vars;
1750  int nvars;
1751  int i;
1752 
1753  assert(scip != NULL);
1754  assert(result != NULL);
1755 
1756  *result = SCIP_DIDNOTFIND;
1757 
1758  /* check if we are in the original problem and not in a sub MIP */
1759  if( !SCIPdebugIsMainscip(scip) )
1760  return SCIP_OKAY;
1761 
1762  if( SCIPgetStage(scip) != SCIP_STAGE_SOLVING )
1763  return SCIP_OKAY;
1764 
1765  /* check whether a debug solution is available */
1766  if( !debugSolutionAvailable(scip->set) )
1767  return SCIP_OKAY;
1768 
1769  /* check if the incumbent solution is at least as good as the debug solution, so we can stop to check the debug solution */
1770  if( debugSolIsAchieved(scip->set) )
1771  return SCIP_OKAY;
1772 
1773 #if 1
1774  /* solve at least one LP */
1775  if( SCIPgetNLPIterations(scip) == 0 )
1776  return SCIP_OKAY;
1777 #endif
1778 
1779  vars = SCIPgetOrigVars(scip);
1780  nvars = SCIPgetNOrigVars(scip);
1781  for( i = 0; i < nvars; ++i )
1782  {
1783  SCIP_Real solval;
1784  SCIP_Real lb;
1785  SCIP_Real ub;
1786  SCIP_Bool infeasible;
1787  SCIP_Bool fixed;
1788 
1789  SCIP_CALL( getSolutionValue(scip->set, vars[i], &solval) );
1790  if( solval == SCIP_UNKNOWN ) /*lint !e777*/
1791  {
1792  SCIPerrorMessage("original variable without debugging solution value\n");
1793  SCIPABORT();
1794  }
1795 
1796  lb = SCIPvarGetLbGlobal(vars[i]);
1797  ub = SCIPvarGetUbGlobal(vars[i]);
1798  if( SCIPisLT(scip, solval, lb) || SCIPisGT(scip, solval, ub) )
1799  {
1800  SCIPerrorMessage("solution value %.15g of <%s> outside bounds loc=[%.15g,%.15g], glb=[%.15g,%.15g]\n",
1801  solval, SCIPvarGetName(vars[i]), lb, ub, SCIPvarGetLbGlobal(vars[i]), SCIPvarGetUbGlobal(vars[i]));
1802  SCIPABORT();
1803  }
1804 
1805  SCIP_CALL( SCIPfixVar(scip, vars[i], solval, &infeasible, &fixed) );
1806  if( infeasible )
1807  *result = SCIP_CUTOFF;
1808  else if( fixed )
1809  *result = SCIP_REDUCEDDOM;
1810  }
1811 
1812  return SCIP_OKAY;
1813 }
1814 
1815 /** creates the debugging propagator and includes it in SCIP */
1817  SCIP* scip /**< SCIP data structure */
1818  )
1819 {
1820  assert(scip != NULL);
1821 
1822  /* include propagator */
1823  SCIP_CALL( SCIPincludeProp(scip, "debug", "debugging propagator", 99999999, -1, FALSE,
1825  NULL, propExecDebug, NULL, NULL) );
1826 
1827  return SCIP_OKAY;
1828 }
1829 
1830 /** adds a solution value for a new variable in the transformed problem that has no original counterpart
1831  * a value can only be set if no value has been set for this variable before
1832  */
1834  SCIP* scip, /**< SCIP data structure */
1835  SCIP_VAR* var, /**< variable for which to add a value */
1836  SCIP_Real val /**< solution value for variable */
1837  )
1838 {
1839  SCIP_DEBUGSOLDATA* debugsoldata;
1840  SCIP_Real testval;
1841  const char* varname;
1842  int i;
1843 
1844  assert(scip != NULL);
1845  assert(var != NULL);
1846  assert(scip->set != NULL);
1847 
1848  debugsoldata = SCIPsetGetDebugSolData(scip->set);
1849  assert(debugsoldata != NULL);
1850 
1851  /* assert that we are in the SCIP instance that we are debugging and not some different (subSCIP,
1852  * auxiliary CIP, ...)
1853  */
1854  if( !SCIPdebugSolIsEnabled(scip) )
1855  return SCIP_OKAY;
1856 
1857  /* check whether a debug solution is available */
1858  if( !debugSolutionAvailable(scip->set) )
1859  return SCIP_OKAY;
1860 
1861  if( debugsoldata->debugsol == NULL )
1862  {
1863  /* make sure a debug solution has been read, so we do not compare against the initial debugsolval == 0 */
1864  SCIP_CALL( readSolution(scip->set) );
1865  }
1866 
1867  /* allocate memory */
1868  if( debugsoldata->nsolvals >= debugsoldata->solsize )
1869  {
1870  debugsoldata->solsize = MAX(2*debugsoldata->solsize, debugsoldata->nsolvals+1);
1871  SCIP_ALLOC( BMSreallocMemoryArray(&debugsoldata->solnames, debugsoldata->solsize) );
1872  SCIP_ALLOC( BMSreallocMemoryArray(&debugsoldata->solvals, debugsoldata->solsize) );
1873  }
1874  assert(debugsoldata->nsolvals < debugsoldata->solsize);
1875 
1876  /* store solution value in sorted list */
1877  varname = SCIPvarGetName(var);
1878  for( i = debugsoldata->nsolvals; i > 0 && strcmp(varname, debugsoldata->solnames[i-1]) < 0; --i )
1879  {
1880  debugsoldata->solnames[i] = debugsoldata->solnames[i-1];
1881  debugsoldata->solvals[i] = debugsoldata->solvals[i-1];
1882  }
1883  if( i > 0 && strcmp(varname, debugsoldata->solnames[i-1]) == 0 )
1884  {
1885  if( REALABS(debugsoldata->solvals[i-1] - val) > 1e-9 )
1886  {
1887  SCIPerrorMessage("already have stored different debugging solution value (%g) for variable <%s>, cannot store %g\n", debugsoldata->solvals[i-1], varname, val);
1888  return SCIP_ERROR;
1889  }
1890  else
1891  {
1892  SCIPdebugMsg(scip, "already have stored debugging solution value %g for variable <%s>, do not store same value again\n", val, varname);
1893  for( ; i < debugsoldata->nsolvals; ++i )
1894  {
1895  debugsoldata->solnames[i] = debugsoldata->solnames[i+1];
1896  debugsoldata->solvals[i] = debugsoldata->solvals[i+1];
1897  }
1898  return SCIP_OKAY;
1899  }
1900  }
1901 
1902  /* insert new solution value */
1903  SCIP_ALLOC( BMSduplicateMemoryArray(&(debugsoldata->solnames[i]), varname, strlen(varname)+1) );
1904  SCIPdebugMsg(scip, "add variable <%s>: value <%g>\n", debugsoldata->solnames[i], val);
1905  debugsoldata->solvals[i] = val;
1906  debugsoldata->nsolvals++;
1907 
1908  /* update objective function value of debug solution */
1909  debugsoldata->debugsolval += debugsoldata->solvals[i] * SCIPvarGetObj(var);
1910  SCIPdebugMsg(scip, "Debug Solution value is now %g.\n", debugsoldata->debugsolval);
1911 
1913  {
1914  /* add values to SCIP debug solution */
1915  SCIP_CALL( SCIPsetSolVal(scip, debugsoldata->debugsol, var, debugsoldata->solvals[i] ) );
1916  }
1917 
1918  /* get solution value once to produce warning if solution was cut off */
1919  SCIPdebugGetSolVal(scip, var, &testval);
1920 
1921  return SCIP_OKAY;
1922 }
1923 
1924 #else
1925 
1926 /** this is a dummy method to make the SunOS gcc linker happy */
1927 extern void SCIPdummyDebugMethodForSun(void);
1929 {
1930  return;
1931 }
1932 
1933 #endif
1934 
1935 
1936 /*
1937  * debug method for LP interface, to check if the LP interface works correct
1938  */
1939 #ifdef SCIP_DEBUG_LP_INTERFACE
1940 
1941 /* check whether coef is the r-th row of the inverse basis matrix B^-1; this is
1942  * the case if( coef * B ) is the r-th unit vector */
1944  SCIP* scip, /**< SCIP data structure */
1945  int r, /**< row number */
1946  SCIP_Real* coef /**< r-th row of the inverse basis matrix */
1947  )
1948 {
1949  SCIP_Real vecval;
1950  SCIP_Real matrixval;
1951  int* basisind;
1952  int nrows;
1953  int idx;
1954  int i;
1955  int k;
1956 
1957  assert(scip != NULL);
1958 
1959  nrows = SCIPgetNLPRows(scip);
1960 
1961  /* get basic indices for the basic matrix B */
1962  SCIP_CALL( SCIPallocBufferArray(scip, &basisind, nrows) );
1963  SCIP_CALL( SCIPgetLPBasisInd(scip, basisind) );
1964 
1965  /* loop over the columns of B */
1966  for( k = 0; k < nrows; ++k )
1967  {
1968  vecval = 0.0;
1969 
1970  /* indices of basic columns and rows:
1971  * - index i >= 0 corresponds to column i,
1972  * - index i < 0 to row -i-1
1973  */
1974  idx = basisind[k];
1975 
1976  /* check if we have a slack variable; this is the case if idx < 0 */
1977  if( idx >= 0 )
1978  {
1979  /* loop over the rows to compute the corresponding value in the unit vector */
1980  for( i = 0; i < nrows; ++i )
1981  {
1982  SCIP_CALL( SCIPlpiGetCoef(scip->lp->lpi, i, idx, &matrixval) );
1983  vecval += coef[i] * matrixval;
1984  }
1985  }
1986  else
1987  {
1988  assert( idx < 0 );
1989 
1990  /* retransform idx
1991  * - index i >= 0 corresponds to column i,
1992  * - index i < 0 to row -i-1
1993  */
1994  idx = -idx - 1;
1995  assert( idx >= 0 && idx < nrows );
1996 
1997  /* since idx < 0 we are in the case of a slack variable, i.e., the corresponding column
1998  is the idx-unit vector; note that some LP solver return a -idx-unit vector */
1999  /* vecval = REALABS(coef[idx]);*/
2000  vecval = coef[idx];
2001  }
2002 
2003  /* check if vecval fits to the r-th unit vector */
2004  if( k == r && !SCIPisFeasEQ(scip, vecval, 1.0) )
2005  {
2006  /* we expected a 1.0 and found something different */
2007  SCIPmessagePrintWarning(SCIPgetMessagehdlr(scip), "checked SCIPgetLPBInvRow() found value <%g> expected 1.0\n", vecval);
2008  }
2009  else if( k != r && !SCIPisFeasZero(scip, vecval) )
2010  {
2011  /* we expected a 0.0 and found something different */
2012  SCIPmessagePrintWarning(SCIPgetMessagehdlr(scip), "checked SCIPgetLPBInvRow() found value <%g> expected 0.0\n", vecval);
2013  }
2014  }
2015 
2016  SCIPfreeBufferArray(scip, &basisind);
2017 
2018  return SCIP_OKAY;
2019 }
2020 
2021 #endif
2022 
2023 /** checks, if SCIP is in one of the feasible stages */
2024 #ifndef NDEBUG
2026  SCIP* scip, /**< SCIP data structure */
2027  const char* method, /**< method that was called */
2028  SCIP_Bool init, /**< may method be called in the INIT stage? */
2029  SCIP_Bool problem, /**< may method be called in the PROBLEM stage? */
2030  SCIP_Bool transforming, /**< may method be called in the TRANSFORMING stage? */
2031  SCIP_Bool transformed, /**< may method be called in the TRANSFORMED stage? */
2032  SCIP_Bool initpresolve, /**< may method be called in the INITPRESOLVE stage? */
2033  SCIP_Bool presolving, /**< may method be called in the PRESOLVING stage? */
2034  SCIP_Bool exitpresolve, /**< may method be called in the EXITPRESOLE stage? */
2035  SCIP_Bool presolved, /**< may method be called in the PRESOLVED stage? */
2036  SCIP_Bool initsolve, /**< may method be called in the INITSOLVE stage? */
2037  SCIP_Bool solving, /**< may method be called in the SOLVING stage? */
2038  SCIP_Bool solved, /**< may method be called in the SOLVED stage? */
2039  SCIP_Bool exitsolve, /**< may method be called in the EXITSOLVE stage? */
2040  SCIP_Bool freetrans, /**< may method be called in the FREETRANS stage? */
2041  SCIP_Bool freescip /**< may method be called in the FREE stage? */
2042  )
2043 {
2044  assert(scip != NULL);
2045  assert(method != NULL);
2046 
2047  /*SCIPdebugMsg(scip, "called method <%s> at stage %d ------------------------------------------------\n",
2048  method, scip->set->stage);*/
2049 
2050  assert(scip->mem != NULL);
2051  assert(scip->set != NULL);
2052  assert(scip->interrupt != NULL);
2053  assert(scip->dialoghdlr != NULL);
2054  assert(scip->totaltime != NULL);
2055 
2056  switch( scip->set->stage )
2057  {
2058  case SCIP_STAGE_INIT:
2059  assert(scip->stat == NULL);
2060  assert(scip->origprob == NULL);
2061  assert(scip->eventfilter == NULL);
2062  assert(scip->eventqueue == NULL);
2063  assert(scip->branchcand == NULL);
2064  assert(scip->lp == NULL);
2065  assert(scip->nlp == NULL);
2066  assert(scip->primal == NULL);
2067  assert(scip->tree == NULL);
2068  assert(scip->conflict == NULL);
2069  assert(scip->transprob == NULL);
2070  assert(scip->pricestore == NULL);
2071  assert(scip->sepastore == NULL);
2072  assert(scip->cutpool == NULL);
2073  assert(scip->delayedcutpool == NULL);
2074 
2075  if( !init )
2076  {
2077  SCIPerrorMessage("cannot call method <%s> in initialization stage\n", method);
2078  return SCIP_INVALIDCALL;
2079  }
2080  return SCIP_OKAY;
2081 
2082  case SCIP_STAGE_PROBLEM:
2083  assert(scip->stat != NULL);
2084  assert(scip->origprob != NULL);
2085  assert(scip->eventfilter == NULL);
2086  assert(scip->eventqueue == NULL);
2087  assert(scip->branchcand == NULL);
2088  assert(scip->lp == NULL);
2089  assert(scip->nlp == NULL);
2090  assert(scip->primal == NULL);
2091  assert(scip->tree == NULL);
2092  assert(scip->conflict == NULL);
2093  assert(scip->transprob == NULL);
2094  assert(scip->pricestore == NULL);
2095  assert(scip->sepastore == NULL);
2096  assert(scip->cutpool == NULL);
2097  assert(scip->delayedcutpool == NULL);
2098 
2099  if( !problem )
2100  {
2101  SCIPerrorMessage("cannot call method <%s> in problem creation stage\n", method);
2102  return SCIP_INVALIDCALL;
2103  }
2104  return SCIP_OKAY;
2105 
2107  assert(scip->stat != NULL);
2108  assert(scip->origprob != NULL);
2109  assert(scip->eventfilter != NULL);
2110  assert(scip->eventqueue != NULL);
2111  assert(scip->branchcand != NULL);
2112  assert(scip->lp != NULL);
2113  assert(scip->primal != NULL);
2114  assert(scip->tree != NULL);
2115  assert(scip->conflict != NULL);
2116  assert(scip->transprob != NULL);
2117  assert(scip->pricestore == NULL);
2118  assert(scip->sepastore == NULL);
2119  assert(scip->cutpool == NULL);
2120  assert(scip->delayedcutpool == NULL);
2121 
2122  if( !transforming )
2123  {
2124  SCIPerrorMessage("cannot call method <%s> in problem transformation stage\n", method);
2125  return SCIP_INVALIDCALL;
2126  }
2127  return SCIP_OKAY;
2128 
2130  assert(scip->stat != NULL);
2131  assert(scip->origprob != NULL);
2132  assert(scip->eventfilter != NULL);
2133  assert(scip->eventqueue != NULL);
2134  assert(scip->branchcand != NULL);
2135  assert(scip->lp != NULL);
2136  assert(scip->primal != NULL);
2137  assert(scip->tree != NULL);
2138  assert(scip->conflict != NULL);
2139  assert(scip->transprob != NULL);
2140  assert(scip->pricestore == NULL);
2141  assert(scip->sepastore == NULL);
2142  assert(scip->cutpool == NULL);
2143  assert(scip->delayedcutpool == NULL);
2144 
2145  if( !transformed )
2146  {
2147  SCIPerrorMessage("cannot call method <%s> in problem transformed stage\n", method);
2148  return SCIP_INVALIDCALL;
2149  }
2150  return SCIP_OKAY;
2151 
2153  assert(scip->stat != NULL);
2154  assert(scip->origprob != NULL);
2155  assert(scip->eventfilter != NULL);
2156  assert(scip->eventqueue != NULL);
2157  assert(scip->branchcand != NULL);
2158  assert(scip->lp != NULL);
2159  assert(scip->primal != NULL);
2160  assert(scip->tree != NULL);
2161  assert(scip->conflict != NULL);
2162  assert(scip->transprob != NULL);
2163  assert(scip->pricestore == NULL);
2164  assert(scip->sepastore == NULL);
2165  assert(scip->cutpool == NULL);
2166  assert(scip->delayedcutpool == NULL);
2167 
2168  if( !initpresolve )
2169  {
2170  SCIPerrorMessage("cannot call method <%s> in init presolving stage\n", method);
2171  return SCIP_INVALIDCALL;
2172  }
2173  return SCIP_OKAY;
2174 
2175  case SCIP_STAGE_PRESOLVING:
2176  assert(scip->stat != NULL);
2177  assert(scip->origprob != NULL);
2178  assert(scip->eventfilter != NULL);
2179  assert(scip->eventqueue != NULL);
2180  assert(scip->branchcand != NULL);
2181  assert(scip->lp != NULL);
2182  assert(scip->primal != NULL);
2183  assert(scip->tree != NULL);
2184  assert(scip->conflict != NULL);
2185  assert(scip->transprob != NULL);
2186  assert(scip->pricestore == NULL);
2187  assert(scip->sepastore == NULL);
2188  assert(scip->cutpool == NULL);
2189  assert(scip->delayedcutpool == NULL);
2190 
2191  if( !presolving )
2192  {
2193  SCIPerrorMessage("cannot call method <%s> in presolving stage\n", method);
2194  return SCIP_INVALIDCALL;
2195  }
2196  return SCIP_OKAY;
2197 
2199  assert(scip->stat != NULL);
2200  assert(scip->origprob != NULL);
2201  assert(scip->eventfilter != NULL);
2202  assert(scip->eventqueue != NULL);
2203  assert(scip->branchcand != NULL);
2204  assert(scip->lp != NULL);
2205  assert(scip->primal != NULL);
2206  assert(scip->tree != NULL);
2207  assert(scip->conflict != NULL);
2208  assert(scip->transprob != NULL);
2209  assert(scip->pricestore == NULL);
2210  assert(scip->sepastore == NULL);
2211  assert(scip->cutpool == NULL);
2212  assert(scip->delayedcutpool == NULL);
2213 
2214  if( !exitpresolve )
2215  {
2216  SCIPerrorMessage("cannot call method <%s> in exit presolving stage\n", method);
2217  return SCIP_INVALIDCALL;
2218  }
2219  return SCIP_OKAY;
2220 
2221  case SCIP_STAGE_PRESOLVED:
2222  assert(scip->stat != NULL);
2223  assert(scip->origprob != NULL);
2224  assert(scip->eventfilter != NULL);
2225  assert(scip->eventqueue != NULL);
2226  assert(scip->branchcand != NULL);
2227  assert(scip->lp != NULL);
2228  assert(scip->primal != NULL);
2229  assert(scip->tree != NULL);
2230  assert(scip->conflict != NULL);
2231  assert(scip->transprob != NULL);
2232  assert(scip->pricestore == NULL);
2233  assert(scip->sepastore == NULL);
2234  assert(scip->cutpool == NULL);
2235  assert(scip->delayedcutpool == NULL);
2236 
2237  if( !presolved )
2238  {
2239  SCIPerrorMessage("cannot call method <%s> in problem presolved stage\n", method);
2240  return SCIP_INVALIDCALL;
2241  }
2242  return SCIP_OKAY;
2243 
2244  case SCIP_STAGE_INITSOLVE:
2245  assert(scip->stat != NULL);
2246  assert(scip->origprob != NULL);
2247  assert(scip->eventfilter != NULL);
2248  assert(scip->eventqueue != NULL);
2249  assert(scip->branchcand != NULL);
2250  assert(scip->lp != NULL);
2251  assert(scip->primal != NULL);
2252  assert(scip->tree != NULL);
2253  assert(scip->transprob != NULL);
2254 
2255  if( !initsolve )
2256  {
2257  SCIPerrorMessage("cannot call method <%s> in init solve stage\n", method);
2258  return SCIP_INVALIDCALL;
2259  }
2260  return SCIP_OKAY;
2261 
2262  case SCIP_STAGE_SOLVING:
2263  assert(scip->stat != NULL);
2264  assert(scip->origprob != NULL);
2265  assert(scip->eventfilter != NULL);
2266  assert(scip->eventqueue != NULL);
2267  assert(scip->branchcand != NULL);
2268  assert(scip->lp != NULL);
2269  assert(scip->primal != NULL);
2270  assert(scip->tree != NULL);
2271  assert(scip->conflict != NULL);
2272  assert(scip->transprob != NULL);
2273  assert(scip->pricestore != NULL);
2274  assert(scip->sepastore != NULL);
2275  assert(scip->cutpool != NULL);
2276  assert(scip->delayedcutpool != NULL);
2277 
2278  if( !solving )
2279  {
2280  SCIPerrorMessage("cannot call method <%s> in solving stage\n", method);
2281  return SCIP_INVALIDCALL;
2282  }
2283  return SCIP_OKAY;
2284 
2285  case SCIP_STAGE_SOLVED:
2286  assert(scip->stat != NULL);
2287  assert(scip->origprob != NULL);
2288  assert(scip->eventfilter != NULL);
2289  assert(scip->eventqueue != NULL);
2290  assert(scip->branchcand != NULL);
2291  assert(scip->lp != NULL);
2292  assert(scip->primal != NULL);
2293  assert(scip->tree != NULL);
2294  assert(scip->conflict != NULL);
2295  assert(scip->transprob != NULL);
2296  assert(scip->pricestore != NULL);
2297  assert(scip->sepastore != NULL);
2298  assert(scip->cutpool != NULL);
2299  assert(scip->delayedcutpool != NULL);
2300 
2301  if( !solved )
2302  {
2303  SCIPerrorMessage("cannot call method <%s> in problem solved stage\n", method);
2304  return SCIP_INVALIDCALL;
2305  }
2306  return SCIP_OKAY;
2307 
2308  case SCIP_STAGE_EXITSOLVE:
2309  assert(scip->stat != NULL);
2310  assert(scip->origprob != NULL);
2311  assert(scip->eventfilter != NULL);
2312  assert(scip->eventqueue != NULL);
2313  assert(scip->branchcand != NULL);
2314  assert(scip->lp != NULL);
2315  assert(scip->primal != NULL);
2316  assert(scip->tree != NULL);
2317  assert(scip->transprob != NULL);
2318 
2319  if( !exitsolve )
2320  {
2321  SCIPerrorMessage("cannot call method <%s> in solve deinitialization stage\n", method);
2322  return SCIP_INVALIDCALL;
2323  }
2324  return SCIP_OKAY;
2325 
2326  case SCIP_STAGE_FREETRANS:
2327  assert(scip->stat != NULL);
2328  assert(scip->origprob != NULL);
2329  assert(scip->pricestore == NULL);
2330  assert(scip->sepastore == NULL);
2331  assert(scip->cutpool == NULL);
2332  assert(scip->delayedcutpool == NULL);
2333 
2334  if( !freetrans )
2335  {
2336  SCIPerrorMessage("cannot call method <%s> in free transformed problem stage\n", method);
2337  return SCIP_INVALIDCALL;
2338  }
2339  return SCIP_OKAY;
2340 
2341  case SCIP_STAGE_FREE:
2342  if( !freescip )
2343  {
2344  SCIPerrorMessage("cannot call method <%s> in free stage\n", method);
2345  return SCIP_INVALIDCALL;
2346  }
2347  return SCIP_OKAY;
2348 
2349  default:
2350  /* note that this is in an internal SCIP error since all SCIP stages are covert in the switch above */
2351  SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
2352  return SCIP_ERROR;
2353  }
2354 }
2355 #endif
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:52
SCIP_STAT * stat
Definition: struct_scip.h:70
SCIP_RETCODE SCIPincludeProp(SCIP *scip, const char *name, const char *desc, int priority, int freq, SCIP_Bool delay, SCIP_PROPTIMING timingmask, int presolpriority, int presolmaxrounds, SCIP_PRESOLTIMING presoltiming, SCIP_DECL_PROPCOPY((*propcopy)), SCIP_DECL_PROPFREE((*propfree)), SCIP_DECL_PROPINIT((*propinit)), SCIP_DECL_PROPEXIT((*propexit)), SCIP_DECL_PROPINITPRE((*propinitpre)), SCIP_DECL_PROPEXITPRE((*propexitpre)), SCIP_DECL_PROPINITSOL((*propinitsol)), SCIP_DECL_PROPEXITSOL((*propexitsol)), SCIP_DECL_PROPPRESOL((*proppresol)), SCIP_DECL_PROPEXEC((*propexec)), SCIP_DECL_PROPRESPROP((*propresprop)), SCIP_PROPDATA *propdata)
Definition: scip_prop.c:53
enum SCIP_BoundType SCIP_BOUNDTYPE
Definition: type_lp.h:50
SCIP_RETCODE SCIPcreateOrigSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip_sol.c:557
SCIP_RETCODE SCIPfreeSol(SCIP *scip, SCIP_SOL **sol)
Definition: scip_sol.c:977
SCIP_Bool SCIProwIsLocal(SCIP_ROW *row)
Definition: lp.c:17250
SCIP_EXPORT SCIP_Bool SCIPvarIsTransformed(SCIP_VAR *var)
Definition: var.c:17159
SCIP_EXPORT SCIP_Bool SCIPvarIsNegated(SCIP_VAR *var)
Definition: var.c:17172
SCIP_Bool SCIPsetIsLE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6038
SCIP_Bool SCIPsetIsFeasZero(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6488
SCIP_EXPORT int SCIPvarGetNUses(SCIP_VAR *var)
Definition: var.c:17027
SCIP_RETCODE SCIPsetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real val)
Definition: scip_sol.c:1213
SCIP_Bool SCIPlpDiving(SCIP_LP *lp)
Definition: lp.c:17669
#define SCIPdebugRemoveNode(blkmem, set, node)
Definition: debug.h:248
#define BMSfreeMemoryArrayNull(ptr)
Definition: memory.h:140
internal methods for branch and bound tree
SCIP_CONFLICT * conflict
Definition: struct_scip.h:87
int SCIPgetNLPRows(SCIP *scip)
Definition: scip_lp.c:596
#define SCIPdebugFreeDebugData(set)
Definition: debug.h:242
SCIP_Bool SCIPconsIsLocal(SCIP_CONS *cons)
Definition: cons.c:8328
SCIP_Bool SCIPsetIsFeasEQ(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6378
#define SCIP_MAXSTRLEN
Definition: def.h:273
SCIP_BOUNDCHG * boundchgs
Definition: struct_var.h:125
#define SCIPdebugCheckImplic(set, var, varfixing, implvar, impltype, implbound)
Definition: debug.h:250
int SCIProwGetNNonz(SCIP_ROW *row)
Definition: lp.c:17062
SCIP_EVENTQUEUE * eventqueue
Definition: struct_scip.h:80
SCIP_CLOCK * totaltime
Definition: struct_scip.h:67
#define SCIPdebugSolDataCreate(debugsoldata)
Definition: debug.h:239
SCIP_PRIMAL * primal
Definition: struct_scip.h:85
SCIP_CUTPOOL * delayedcutpool
Definition: struct_scip.h:97
SCIP_Real SCIPsetInfinity(SCIP_SET *set)
Definition: set.c:5845
unsigned int nboundchgs
Definition: struct_var.h:123
SCIP_Real SCIProwGetConstant(SCIP_ROW *row)
Definition: lp.c:17107
SCIP_NODE * SCIPgetCurrentNode(SCIP *scip)
Definition: scip_tree.c:81
SCIP_EXPORT SCIP_Bool SCIPvarIsBinary(SCIP_VAR *var)
Definition: var.c:17197
#define SCIPdebugCheckClique(set, vars, values, nvars)
Definition: debug.h:252
SCIP_BRANCHCAND * branchcand
Definition: struct_scip.h:81
SCIP_Bool SCIPconsIsActive(SCIP_CONS *cons)
Definition: cons.c:8150
void SCIPverbMessage(SCIP *scip, SCIP_VERBLEVEL msgverblevel, FILE *file, const char *formatstr,...)
Definition: scip_message.c:216
#define FALSE
Definition: def.h:73
SCIP_EXPORT SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
Definition: var.c:17515
SCIP_EXPORT int SCIPnodeGetDepth(SCIP_NODE *node)
Definition: tree.c:7430
SCIP_STAGE stage
Definition: struct_set.h:63
SCIP_EXPORT SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
Definition: var.c:17182
#define TRUE
Definition: def.h:72
#define SCIPdebugCheckRow(set, row)
Definition: debug.h:244
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:54
int SCIPpqueueNElems(SCIP_PQUEUE *pqueue)
Definition: misc.c:1467
SCIP_EXPORT SCIP_Bool SCIPvarIsTransformedOrigvar(SCIP_VAR *var)
Definition: var.c:12632
void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin)
Definition: misc.c:3200
#define BMSallocMemoryArray(ptr, num)
Definition: memory.h:115
SCIP_EXPORT void SCIPsortPtrReal(void **ptrarray, SCIP_Real *realarray, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), int len)
SCIP_EXPORT SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
Definition: var.c:17136
SCIP_PROB * transprob
Definition: struct_scip.h:89
SCIP_EXPORT SCIP_RETCODE SCIPlpiGetCoef(SCIP_LPI *lpi, int row, int col, SCIP_Real *val)
Definition: lpi_clp.cpp:1762
#define SCIPfreeBufferArray(scip, ptr)
Definition: scip_mem.h:123
#define SCIP_DECL_PROPEXEC(x)
Definition: type_prop.h:208
#define SCIPdebugCheckVbound(set, var, vbtype, vbvar, vbcoef, vbconstant)
Definition: debug.h:249
#define SCIPdebugMsg
Definition: scip_message.h:69
internal methods for LP management
Definition: heur_padm.c:125
SCIP_PROB * origprob
Definition: struct_scip.h:71
SCIP_Longint number
Definition: struct_tree.h:134
#define SCIP_PRESOLTIMING_FAST
Definition: type_timing.h:43
SCIP_DIALOGHDLR * dialoghdlr
Definition: struct_scip.h:65
SCIP_Bool SCIPsetIsGE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6074
#define SCIPdebugCheckConflict(blkmem, set, node, bdchginfos, relaxedbds, nliterals)
Definition: debug.h:253
SCIP_PRICESTORE * pricestore
Definition: struct_scip.h:92
SCIP_EXPORT SCIP_Bool SCIPvarIsRelaxationOnly(SCIP_VAR *var)
Definition: var.c:17304
SCIP_FILE * SCIPfopen(const char *path, const char *mode)
Definition: fileio.c:144
struct SCIP_DebugSolData SCIP_DEBUGSOLDATA
Definition: debug.h:50
SCIP_Bool SCIPsetIsLT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6020
SCIP_MEM * mem
Definition: struct_scip.h:62
SCIP_DOMCHG * domchg
Definition: struct_tree.h:150
SCIP_RETCODE SCIPcheckCons(SCIP *scip, SCIP_CONS *cons, SCIP_SOL *sol, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool printreason, SCIP_RESULT *result)
Definition: scip_cons.c:2072
SCIP_Bool SCIPtreeProbing(SCIP_TREE *tree)
Definition: tree.c:8262
SCIP_EXPORT const char * SCIPvarGetName(SCIP_VAR *var)
Definition: var.c:17017
#define SCIPdebugIncludeProp(scip)
Definition: debug.h:255
#define BMSfreeMemoryArray(ptr)
Definition: memory.h:139
SCIP_COL ** SCIProwGetCols(SCIP_ROW *row)
Definition: lp.c:17087
internal methods for storing and manipulating the main problem
#define SCIPerrorMessage
Definition: pub_message.h:55
SCIP_EVENTFILTER * eventfilter
Definition: struct_scip.h:79
SCIP_INTERRUPT * interrupt
Definition: struct_scip.h:64
SCIP_EXPORT SCIP_BOUNDCHGTYPE SCIPboundchgGetBoundchgtype(SCIP_BOUNDCHG *boundchg)
Definition: var.c:16934
SCIP_Bool SCIPisFeasEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
#define SCIPdebugCheckInference(blkmem, set, node, var, newbound, boundtype)
Definition: debug.h:247
SCIP_Bool SCIPisInRestart(SCIP *scip)
Definition: scip_solve.c:3539
SCIP_Bool SCIPsetIsRelEQ(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6857
SCIP_RETCODE SCIPcheckStage(SCIP *scip, const char *method, SCIP_Bool init, SCIP_Bool problem, SCIP_Bool transforming, SCIP_Bool transformed, SCIP_Bool initpresolve, SCIP_Bool presolving, SCIP_Bool exitpresolve, SCIP_Bool presolved, SCIP_Bool initsolve, SCIP_Bool solving, SCIP_Bool solved, SCIP_Bool exitsolve, SCIP_Bool freetrans, SCIP_Bool freescip)
Definition: debug.c:2025
int SCIPfeof(SCIP_FILE *stream)
Definition: fileio.c:218
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
Definition: scip_mem.c:48
struct SCIP_File SCIP_FILE
Definition: pub_fileio.h:34
char * SCIPfgets(char *s, int size, SCIP_FILE *stream)
Definition: fileio.c:191
SCIP_Real * SCIProwGetVals(SCIP_ROW *row)
Definition: lp.c:17097
#define SCIPdebugCheckAggregation(set, var, aggrvars, scalars, constant, naggrvars)
Definition: debug.h:251
void SCIPmessagePrintWarning(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr,...)
Definition: message.c:418
#define NULL
Definition: lpi_spx1.cpp:155
SCIP_OBJSENSE SCIPgetObjsense(SCIP *scip)
Definition: scip_prob.c:1223
#define REALABS(x)
Definition: def.h:187
#define SCIP_PROPTIMING_ALWAYS
Definition: type_timing.h:64
internal methods for global SCIP settings
#define SCIP_CALL(x)
Definition: def.h:364
SCIP main data structure.
SCIP_Bool SCIPsetIsFeasGE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6466
void SCIPdummyDebugMethodForSun(void)
Definition: debug.c:1928
int SCIPgetNOrigVars(SCIP *scip)
Definition: scip_prob.c:2426
#define SCIPdebugCheckBInvRow(scip, r, coef)
Definition: debug.h:280
#define SCIPdebugCheckLbGlobal(scip, var, lb)
Definition: debug.h:245
SCIP_LPI * lpi
Definition: struct_lp.h:286
#define SCIPdebugGetSolVal(scip, var, val)
Definition: debug.h:257
void SCIProwPrint(SCIP_ROW *row, SCIP_MESSAGEHDLR *messagehdlr, FILE *file)
Definition: lp.c:5287
SCIP_EXPORT SCIP_Real SCIPvarGetNegationConstant(SCIP_VAR *var)
Definition: var.c:17504
SCIP_Bool SCIPsetIsFeasLE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6422
#define SCIPdebugCheckUbGlobal(scip, var, ub)
Definition: debug.h:246
#define BMSduplicateMemoryArray(ptr, source, num)
Definition: memory.h:135
SCIP_CUTPOOL * cutpool
Definition: struct_scip.h:96
#define SCIPdebugCheckConss(scip, conss, nconss)
Definition: debug.h:243
SCIP_Bool SCIPisFeasZero(SCIP *scip, SCIP_Real val)
internal methods for problem variables
#define SCIPallocBufferArray(scip, ptr, num)
Definition: scip_mem.h:111
#define SCIP_UNKNOWN
Definition: def.h:184
SCIP_SEPASTORE * sepastore
Definition: struct_scip.h:93
public data structures and miscellaneous methods
SCIP_EXPORT SCIP_VAR * SCIPvarGetNegationVar(SCIP_VAR *var)
Definition: var.c:17493
SCIP_RETCODE SCIPsetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
Definition: scip_sol.c:1255
SCIP_Real SCIPgetLPFeastol(SCIP *scip)
Definition: scip_lp.c:419
int SCIPgetDepth(SCIP *scip)
Definition: scip_tree.c:638
#define SCIP_Bool
Definition: def.h:70
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
Definition: misc.c:3013
SCIP_EXPORT SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
Definition: var.c:17677
#define SCIPdebugSolIsValidInSubtree(scip, isvalidinsubtree)
Definition: debug.h:258
SCIP_MESSAGEHDLR * SCIPgetMessagehdlr(SCIP *scip)
Definition: scip_message.c:91
#define MAX(x, y)
Definition: tclique_def.h:83
SCIP_VAR ** SCIPgetOrigVars(SCIP *scip)
Definition: scip_prob.c:2399
SCIP_Real SCIProwGetLhs(SCIP_ROW *row)
Definition: lp.c:17141
#define SCIPdebugCheckConflictFrontier(blkmem, set, node, bdchginfo, bdchginfos, relaxedbds, nliterals, bdchgqueue, forcedbdchgqueue)
Definition: debug.h:254
methods for debugging
#define SCIPsetDebugMsg
Definition: set.h:1721
SCIP_EXPORT SCIP_BOUNDTYPE SCIPbdchginfoGetBoundtype(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18289
SCIP_RETCODE SCIPfixVar(SCIP *scip, SCIP_VAR *var, SCIP_Real fixedval, SCIP_Bool *infeasible, SCIP_Bool *fixed)
Definition: scip_var.c:8255
SCIP_EXPORT SCIP_Bool SCIPvarIsDeleted(SCIP_VAR *var)
Definition: var.c:17238
SCIP_RETCODE SCIPhashmapRemoveAll(SCIP_HASHMAP *hashmap)
Definition: misc.c:3572
SCIP_Bool SCIPsetIsFeasLT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6400
SCIP_VAR * SCIPcolGetVar(SCIP_COL *col)
Definition: lp.c:16901
SCIP_VAR * SCIPfindVar(SCIP *scip, const char *name)
Definition: scip_prob.c:2679
SCIP_Real * r
Definition: circlepacking.c:50
#define SCIPdebugReset(set)
Definition: debug.h:241
SCIP_DOMCHGBOUND domchgbound
Definition: struct_var.h:153
SCIP_EXPORT SCIP_VAR * SCIPbdchginfoGetVar(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18269
int SCIPconsGetActiveDepth(SCIP_CONS *cons)
Definition: cons.c:8139
SCIP_Bool SCIPisFeasGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_NODE * parent
Definition: struct_tree.h:148
SCIP_Longint SCIPgetNLPIterations(SCIP *scip)
void ** SCIPpqueueElems(SCIP_PQUEUE *pqueue)
Definition: misc.c:1478
static const SCIP_Real scalars[]
Definition: lp.c:5731
#define SCIP_DECL_SORTPTRCOMP(x)
Definition: type_misc.h:172
SCIP_EXPORT SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
Definition: var.c:17667
SCIP_Bool SCIPisFeasLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
#define BMSfreeMemoryNull(ptr)
Definition: memory.h:138
SCIP_SET * set
Definition: struct_scip.h:63
public methods for message output
SCIP_Bool SCIPsetIsGT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6056
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
Definition: misc.c:3047
const char * SCIPconsGetName(SCIP_CONS *cons)
Definition: cons.c:8089
#define SCIPdebugSolDisable(scip)
Definition: debug.h:260
#define SCIP_Real
Definition: def.h:163
enum SCIP_Stage SCIP_STAGE
Definition: type_set.h:50
SCIP_DEBUGSOLDATA * SCIPsetGetDebugSolData(SCIP_SET *set)
Definition: set.c:5737
const char * SCIProwGetName(SCIP_ROW *row)
Definition: lp.c:17200
SCIP_NLP * nlp
Definition: struct_scip.h:83
SCIP_Bool SCIPisLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_EXPORT SCIP_RETCODE SCIPvarGetOrigvarSum(SCIP_VAR **var, SCIP_Real *scalar, SCIP_Real *constant)
Definition: var.c:12545
#define BMSallocMemory(ptr)
Definition: memory.h:111
#define BMSreallocMemoryArray(ptr, num)
Definition: memory.h:119
SCIP_RETCODE SCIPgetLPBasisInd(SCIP *scip, int *basisind)
Definition: scip_lp.c:656
void SCIPprintSysError(const char *message)
Definition: misc.c:10499
#define SCIPdebugAddSolVal(scip, var, val)
Definition: debug.h:256
SCIP_Bool SCIPsetIsFeasGT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6444
SCIP_TREE * tree
Definition: struct_scip.h:86
#define SCIPdebugSolIsEnabled(scip)
Definition: debug.h:261
SCIP_STAGE SCIPsetGetStage(SCIP_SET *set)
Definition: set.c:2917
SCIP_EXPORT SCIP_NODETYPE SCIPnodeGetType(SCIP_NODE *node)
Definition: tree.c:7410
SCIP_Real SCIProwGetRhs(SCIP_ROW *row)
Definition: lp.c:17151
common defines and data types used in all packages of SCIP
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:429
int SCIPfclose(SCIP_FILE *fp)
Definition: fileio.c:223
SCIP_EXPORT SCIP_BOUNDTYPE SCIPboundchgGetBoundtype(SCIP_BOUNDCHG *boundchg)
Definition: var.c:16944
SCIP_STAGE SCIPgetStage(SCIP *scip)
Definition: scip_general.c:356
SCIP_LP * lp
Definition: struct_scip.h:82
#define SCIP_ALLOC(x)
Definition: def.h:375
#define SCIPdebugSolEnable(scip)
Definition: debug.h:259
#define SCIPABORT()
Definition: def.h:336
SCIP_SOL * SCIPgetBestSol(SCIP *scip)
Definition: scip_sol.c:2305
#define SCIPdebugFreeSol(set)
Definition: debug.h:240
SCIP_RETCODE SCIPhashmapRemove(SCIP_HASHMAP *hashmap, void *origin)
Definition: misc.c:3378
SCIP_RETCODE SCIPhashmapSetImage(SCIP_HASHMAP *hashmap, void *origin, void *image)
Definition: misc.c:3262
SCIP_EXPORT SCIP_Real SCIPbdchginfoGetNewbound(SCIP_BDCHGINFO *bdchginfo)
Definition: var.c:18259
SCIP callable library.
SCIP_Real SCIPgetSolOrigObj(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:1436
memory allocation routines