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