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