Scippy

SCIP

Solving Constraint Integer Programs

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