Scippy

SCIP

Solving Constraint Integer Programs

scip_general.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 scip_general.c
17  * @brief general public methods
18  * @author Tobias Achterberg
19  * @author Timo Berthold
20  * @author Gerald Gamrath
21  * @author Robert Lion Gottwald
22  * @author Stefan Heinz
23  * @author Gregor Hendel
24  * @author Thorsten Koch
25  * @author Alexander Martin
26  * @author Marc Pfetsch
27  * @author Michael Winkler
28  * @author Kati Wolter
29  *
30  * @todo check all SCIP_STAGE_* switches, and include the new stages TRANSFORMED and INITSOLVE
31  */
32 
33 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
34 
35 #include <ctype.h>
36 #include <stdarg.h>
37 #include <assert.h>
38 #include <string.h>
39 #if defined(_WIN32) || defined(_WIN64)
40 #else
41 #include <strings.h> /*lint --e{766}*/
42 #endif
43 
44 #ifdef WITH_ZLIB
45 #include <zlib.h>
46 #endif
47 
48 #include "lpi/lpi.h"
49 #include "nlpi/exprinterpret.h"
50 #include "nlpi/nlpi.h"
51 #include "scip/benders.h"
52 #include "scip/benderscut.h"
53 #include "scip/branch.h"
54 #include "scip/branch_nodereopt.h"
55 #include "scip/clock.h"
56 #include "scip/compr.h"
57 #include "scip/concsolver.h"
58 #include "scip/concurrent.h"
59 #include "scip/conflict.h"
60 #include "scip/conflictstore.h"
61 #include "scip/cons.h"
62 #include "scip/cons_linear.h"
63 #include "scip/cutpool.h"
64 #include "scip/cuts.h"
65 #include "scip/debug.h"
66 #include "scip/def.h"
67 #include "scip/dialog.h"
68 #include "scip/dialog_default.h"
69 #include "scip/disp.h"
70 #include "scip/event.h"
71 #include "scip/heur.h"
72 #include "scip/heur_ofins.h"
73 #include "scip/heur_reoptsols.h"
75 #include "scip/heuristics.h"
76 #include "scip/history.h"
77 #include "scip/implics.h"
78 #include "scip/interrupt.h"
79 #include "scip/lp.h"
80 #include "scip/mem.h"
81 #include "scip/message_default.h"
82 #include "scip/misc.h"
83 #include "scip/nlp.h"
84 #include "scip/nodesel.h"
85 #include "scip/paramset.h"
86 #include "scip/presol.h"
87 #include "scip/presolve.h"
88 #include "scip/pricer.h"
89 #include "scip/pricestore.h"
90 #include "scip/primal.h"
91 #include "scip/prob.h"
92 #include "scip/prop.h"
93 #include "scip/reader.h"
94 #include "scip/relax.h"
95 #include "scip/reopt.h"
96 #include "scip/retcode.h"
97 #include "scip/scipbuildflags.h"
98 #include "scip/scipcoreplugins.h"
99 #include "scip/scipgithash.h"
100 #include "scip/sepa.h"
101 #include "scip/sepastore.h"
102 #include "scip/set.h"
103 #include "scip/sol.h"
104 #include "scip/solve.h"
105 #include "scip/stat.h"
106 #include "scip/syncstore.h"
107 #include "scip/table.h"
108 #include "scip/tree.h"
109 #include "scip/var.h"
110 #include "scip/visual.h"
111 #include "xml/xml.h"
112 
113 #include "scip/scip_general.h"
114 #include "scip/scip_mem.h"
115 #include "scip/scip_message.h"
116 #include "scip/scip_numerics.h"
117 #include "scip/scip_prob.h"
118 #include "scip/scip_solvingstats.h"
119 
120 #include "scip/pub_message.h"
121 
122 
123 /* In debug mode, we include the SCIP's structure in scip.c, such that no one can access
124  * this structure except the interface methods in scip.c.
125  * In optimized mode, the structure is included in scip.h, because some of the methods
126  * are implemented as defines for performance reasons (e.g. the numerical comparisons)
127  */
128 #ifndef NDEBUG
129 #include "scip/struct_scip.h"
130 #endif
131 
132 
133 /* In debug mode, the following methods are implemented as function calls to ensure
134  * type validity.
135  * In optimized mode, the methods are implemented as defines to improve performance.
136  * However, we want to have them in the library anyways, so we have to undef the defines.
137  */
138 
139 #undef SCIPgetStage
140 #undef SCIPhasPerformedPresolve
141 #undef SCIPisStopped
142 
143 /** returns complete SCIP version number in the format "major . minor tech"
144  *
145  * @return complete SCIP version
146  */
148  void
149  )
150 {
151  return (SCIP_Real)(SCIP_VERSION)/100.0;
152 }
153 
154 /** returns SCIP major version
155  *
156  * @return major SCIP version
157  */
159  void
160  )
161 {
162  return SCIP_VERSION/100;
163 }
164 
165 /** returns SCIP minor version
166  *
167  * @return minor SCIP version
168  */
170  void
171  )
172 {
173  return (SCIP_VERSION/10) % 10; /*lint !e778*/
174 }
175 
176 /** returns SCIP technical version
177  *
178  * @return technical SCIP version
179  */
181  void
182  )
183 {
184  return SCIP_VERSION % 10; /*lint !e778*/
185 }
186 
187 /** returns SCIP sub version number
188  *
189  * @return subversion SCIP version
190  */
192  void
193  )
194 {
195  return SCIP_SUBVERSION;
196 }
197 
198 /** prints a version information line to a file stream via the message handler system
199  *
200  * @note If the message handler is set to a NULL pointer nothing will be printed
201  */
203  SCIP* scip, /**< SCIP data structure */
204  FILE* file /**< output file (or NULL for standard output) */
205  )
206 {
207  assert( scip != NULL );
208 
209  SCIPmessageFPrintInfo(scip->messagehdlr, file, "SCIP version %d.%d.%d",
211 #if SCIP_SUBVERSION > 0
212  SCIPmessageFPrintInfo(scip->messagehdlr, file, ".%d", SCIPsubversion());
213 #endif
214 
215  SCIPmessageFPrintInfo(scip->messagehdlr, file, " [precision: %d byte]", (int)sizeof(SCIP_Real));
216 
217 #ifndef BMS_NOBLOCKMEM
218  SCIPmessageFPrintInfo(scip->messagehdlr, file, " [memory: block]");
219 #else
220  SCIPmessageFPrintInfo(scip->messagehdlr, file, " [memory: standard]");
221 #endif
222 #ifndef NDEBUG
223  SCIPmessageFPrintInfo(scip->messagehdlr, file, " [mode: debug]");
224 #else
225  SCIPmessageFPrintInfo(scip->messagehdlr, file, " [mode: optimized]");
226 #endif
227  SCIPmessageFPrintInfo(scip->messagehdlr, file, " [LP solver: %s]", SCIPlpiGetSolverName());
228  SCIPmessageFPrintInfo(scip->messagehdlr, file, " [GitHash: %s]", SCIPgetGitHash());
229  SCIPmessageFPrintInfo(scip->messagehdlr, file, "\n");
230  SCIPmessageFPrintInfo(scip->messagehdlr, file, "%s\n", SCIP_COPYRIGHT);
231 }
232 
233 /** prints detailed information on the compile-time flags
234  *
235  * @note If the message handler is set to a NULL pointer nothing will be printed
236  */
238  SCIP* scip, /**< SCIP data structure */
239  FILE* file /**< output file (or NULL for standard output) */
240  )
241 {
242  assert( scip != NULL );
243 
244  /* compiler */
245  SCIPmessageFPrintInfo(scip->messagehdlr, file, "Compiler: ");
246 #if defined(__INTEL_COMPILER)
247  SCIPmessageFPrintInfo(scip->messagehdlr, file, "Intel %d\n", __INTEL_COMPILER);
248 #elif defined(__clang__)
249  SCIPmessageFPrintInfo(scip->messagehdlr, file, "clang %d.%d.%d\n", __clang_major__, __clang_minor__, __clang_patchlevel__);
250 #elif defined(_MSC_VER)
251  SCIPmessageFPrintInfo(scip->messagehdlr, file, "microsoft visual c %d\n", _MSC_FULL_VER);
252 #elif defined(__GNUC__)
253 #if defined(__GNUC_PATCHLEVEL__)
254  SCIPmessageFPrintInfo(scip->messagehdlr, file, "gcc %d.%d.%d\n", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
255 #else
256  SCIPmessageFPrintInfo(scip->messagehdlr, file, "gcc %d.%d\n", __GNUC__, __GNUC_MINOR__);
257 #endif
258 #else
259  SCIPmessageFPrintInfo(scip->messagehdlr, file, "unknown\n");
260 #endif
261 
262  /* build flags */
263  SCIPmessageFPrintInfo(scip->messagehdlr, file, "\nBuild options:\n%s", SCIPgetBuildFlags());
264 }
265 
266 /** prints error message for the given SCIP_RETCODE via the error prints method */
268  SCIP_RETCODE retcode /**< SCIP return code causing the error */
269  )
270 {
271  SCIPmessagePrintError("SCIP Error (%d): ", retcode);
272  SCIPretcodePrintError(retcode);
273  SCIPmessagePrintError("\n");
274 }
275 
276 /*
277  * general SCIP methods
278  */
279 
280 /** internal method to create SCIP */
281 static
283  SCIP** scip /**< pointer to SCIP data structure */
284  )
285 {
286  assert(scip != NULL);
287 
288  SCIP_ALLOC( BMSallocMemory(scip) );
289 
290  /* all members are initialized to NULL */
291  BMSclearMemory(*scip);
292 
293  /* create a default message handler */
294  SCIP_CALL( SCIPcreateMessagehdlrDefault(&(*scip)->messagehdlr, TRUE, NULL, FALSE) );
295 
296  SCIP_CALL( SCIPmemCreate(&(*scip)->mem) );
297  SCIP_CALL( SCIPsetCreate(&(*scip)->set, (*scip)->messagehdlr, (*scip)->mem->setmem, *scip) );
298  SCIP_CALL( SCIPinterruptCreate(&(*scip)->interrupt) );
299  SCIP_CALL( SCIPdialoghdlrCreate((*scip)->set, &(*scip)->dialoghdlr) );
300  SCIP_CALL( SCIPclockCreate(&(*scip)->totaltime, SCIP_CLOCKTYPE_DEFAULT) );
301  SCIP_CALL( SCIPsyncstoreCreate( &(*scip)->syncstore ) );
302 
303  /* include additional core functionality */
305 
306  SCIPclockStart((*scip)->totaltime, (*scip)->set);
307 
308  SCIP_CALL( SCIPnlpInclude((*scip)->set, SCIPblkmem(*scip)) );
309 
310  if( strcmp(SCIPlpiGetSolverName(), "NONE") != 0 )
311  {
313  }
314  if( strcmp(SCIPexprintGetName(), "NONE") != 0 )
315  {
317  }
318 
319 #ifdef WITH_ZLIB
320  SCIP_CALL( SCIPsetIncludeExternalCode((*scip)->set, "ZLIB " ZLIB_VERSION, "General purpose compression library by J. Gailly and M. Adler (zlib.net)") );
321 #endif
322 
323  return SCIP_OKAY;
324 }
325 
326 /** creates and initializes SCIP data structures
327  *
328  * @note The SCIP default message handler is installed. Use the method SCIPsetMessagehdlr() to install your own
329  * message handler or SCIPsetMessagehdlrLogfile() and SCIPsetMessagehdlrQuiet() to write into a log
330  * file and turn off/on the display output, respectively.
331  *
332  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
333  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
334  *
335  * @post After calling this method \SCIP reached the solving stage \ref SCIP_STAGE_INIT
336  *
337  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
338  */
340  SCIP** scip /**< pointer to SCIP data structure */
341  )
342 {
343  assert(scip != NULL);
344 
345  SCIP_CALL_FINALLY( doScipCreate(scip), (void)SCIPfree(scip) );
346 
347  return SCIP_OKAY;
348 }
349 
350 /** frees SCIP data structures
351  *
352  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
353  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
354  *
355  * @pre This method can be called if @p scip is in one of the following stages:
356  * - \ref SCIP_STAGE_INIT
357  * - \ref SCIP_STAGE_PROBLEM
358  * - \ref SCIP_STAGE_TRANSFORMED
359  * - \ref SCIP_STAGE_INITPRESOLVE
360  * - \ref SCIP_STAGE_PRESOLVING
361  * - \ref SCIP_STAGE_PRESOLVED
362  * - \ref SCIP_STAGE_EXITPRESOLVE
363  * - \ref SCIP_STAGE_SOLVING
364  * - \ref SCIP_STAGE_SOLVED
365  * - \ref SCIP_STAGE_FREE
366  *
367  * @post After calling this method \SCIP reached the solving stage \ref SCIP_STAGE_FREE
368  *
369  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
370  */
372  SCIP** scip /**< pointer to SCIP data structure */
373  )
374 {
375  assert(scip != NULL);
376  if( *scip == NULL )
377  return SCIP_OKAY;
378 
379  SCIP_CALL( SCIPcheckStage(*scip, "SCIPfree", TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE) );
380 
381  SCIP_CALL( SCIPfreeProb(*scip) );
382  assert((*scip)->set->stage == SCIP_STAGE_INIT);
383 
384  /* switch stage to FREE */
385  (*scip)->set->stage = SCIP_STAGE_FREE;
386 
387  SCIP_CALL( SCIPsyncstoreRelease(&(*scip)->syncstore) );
388  SCIP_CALL( SCIPsetFree(&(*scip)->set, (*scip)->mem->setmem) );
389  SCIP_CALL( SCIPdialoghdlrFree(*scip, &(*scip)->dialoghdlr) );
390  SCIPclockFree(&(*scip)->totaltime);
391  SCIPinterruptFree(&(*scip)->interrupt);
392  SCIP_CALL( SCIPmemFree(&(*scip)->mem) );
393 
394  /* release message handler */
395  SCIP_CALL( SCIPmessagehdlrRelease(&(*scip)->messagehdlr) );
396 
397  BMSfreeMemory(scip);
398 
399  return SCIP_OKAY;
400 }
401 
402 #undef SCIPgetStage
403 #undef SCIPhasPerformedPresolve
404 #undef SCIPisStopped
405 
406 /** returns current stage of SCIP
407  *
408  * @return the current SCIP stage
409  *
410  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
411  */
413  SCIP* scip /**< SCIP data structure */
414  )
415 {
416  assert(scip != NULL);
417  assert(scip->set != NULL);
418 
419  return scip->set->stage;
420 }
421 
422 /** outputs SCIP stage and solution status if applicable via the message handler
423  *
424  * @note If the message handler is set to a NULL pointer nothing will be printed
425  *
426  * @note If limits have been changed between the solution and the call to this function, the status is recomputed and
427  * thus may to correspond to the original status.
428  *
429  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
430  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
431  *
432  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
433  */
435  SCIP* scip, /**< SCIP data structure */
436  FILE* file /**< output file (or NULL for standard output) */
437  )
438 {
439  SCIP_CALL( SCIPcheckStage(scip, "SCIPprintStage", TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE) );
440 
441  switch( scip->set->stage )
442  {
443  case SCIP_STAGE_INIT:
444  SCIPmessageFPrintInfo(scip->messagehdlr, file, "initialization");
445  break;
446  case SCIP_STAGE_PROBLEM:
447  SCIPmessageFPrintInfo(scip->messagehdlr, file, "problem creation / modification");
448  break;
450  SCIPmessageFPrintInfo(scip->messagehdlr, file, "problem transformation");
451  break;
453  SCIPmessageFPrintInfo(scip->messagehdlr, file, "problem transformed");
454  break;
456  SCIPmessageFPrintInfo(scip->messagehdlr, file, "presolving is being initialized");
457  break;
459  if( SCIPsolveIsStopped(scip->set, scip->stat, TRUE) )
460  {
461  SCIPmessageFPrintInfo(scip->messagehdlr, file, "solving was interrupted [");
462  SCIP_CALL( SCIPprintStatus(scip, file) );
463  SCIPmessageFPrintInfo(scip->messagehdlr, file, "]");
464  }
465  else
466  SCIPmessageFPrintInfo(scip->messagehdlr, file, "presolving process is running");
467  break;
469  SCIPmessageFPrintInfo(scip->messagehdlr, file, "presolving is being exited");
470  break;
472  SCIPmessageFPrintInfo(scip->messagehdlr, file, "problem is presolved");
473  break;
475  SCIPmessageFPrintInfo(scip->messagehdlr, file, "solving process initialization");
476  break;
477  case SCIP_STAGE_SOLVING:
478  if( SCIPsolveIsStopped(scip->set, scip->stat, TRUE) )
479  {
480  SCIPmessageFPrintInfo(scip->messagehdlr, file, "solving was interrupted [");
481  SCIP_CALL( SCIPprintStatus(scip, file) );
482  SCIPmessageFPrintInfo(scip->messagehdlr, file, "]");
483  }
484  else
485  SCIPmessageFPrintInfo(scip->messagehdlr, file, "solving process is running");
486  break;
487  case SCIP_STAGE_SOLVED:
488  SCIPmessageFPrintInfo(scip->messagehdlr, file, "problem is solved [");
489  SCIP_CALL( SCIPprintStatus(scip, file) );
490  SCIPmessageFPrintInfo(scip->messagehdlr, file, "]");
491 
492  if( scip->primal->nlimsolsfound == 0 && !SCIPisInfinity(scip, (int)SCIPgetObjsense(scip) * SCIPgetPrimalbound(scip)) )
493  SCIPmessageFPrintInfo(scip->messagehdlr, file, " (objective limit reached)");
494 
495  break;
497  SCIPmessageFPrintInfo(scip->messagehdlr, file, "solving process deinitialization");
498  break;
500  SCIPmessageFPrintInfo(scip->messagehdlr, file, "freeing transformed problem");
501  break;
502  case SCIP_STAGE_FREE:
503  SCIPmessageFPrintInfo(scip->messagehdlr, file, "freeing SCIP");
504  break;
505  default:
506  SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
507  return SCIP_INVALIDDATA;
508  }
509 
510  return SCIP_OKAY;
511 }
512 
513 /** gets solution status
514  *
515  * @return SCIP solution status
516  *
517  * See \ref SCIP_Status "SCIP_STATUS" for a complete list of all possible solving status.
518  */
520  SCIP* scip /**< SCIP data structure */
521  )
522 {
523  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetStatus", TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE) );
524 
525  if( scip->set->stage == SCIP_STAGE_INIT || scip->set->stage == SCIP_STAGE_FREE )
526  return SCIP_STATUS_UNKNOWN;
527  else
528  {
529  assert(scip->stat != NULL);
530 
531  return scip->stat->status;
532  }
533 }
534 
535 /** outputs solution status
536  *
537  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
538  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
539  *
540  * See \ref SCIP_Status "SCIP_STATUS" for a complete list of all possible solving status.
541  */
543  SCIP* scip, /**< SCIP data structure */
544  FILE* file /**< output file (or NULL for standard output) */
545  )
546 {
547  SCIP_CALL( SCIPcheckStage(scip, "SCIPprintStatus", TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE) );
548 
549  switch( SCIPgetStatus(scip) )
550  {
551  case SCIP_STATUS_UNKNOWN:
552  SCIPmessageFPrintInfo(scip->messagehdlr, file, "unknown");
553  break;
555  SCIPmessageFPrintInfo(scip->messagehdlr, file, "user interrupt");
556  break;
558  SCIPmessageFPrintInfo(scip->messagehdlr, file, "node limit reached");
559  break;
561  SCIPmessageFPrintInfo(scip->messagehdlr, file, "total node limit reached");
562  break;
564  SCIPmessageFPrintInfo(scip->messagehdlr, file, "stall node limit reached");
565  break;
567  SCIPmessageFPrintInfo(scip->messagehdlr, file, "time limit reached");
568  break;
570  SCIPmessageFPrintInfo(scip->messagehdlr, file, "memory limit reached");
571  break;
573  SCIPmessageFPrintInfo(scip->messagehdlr, file, "gap limit reached");
574  break;
576  SCIPmessageFPrintInfo(scip->messagehdlr, file, "solution limit reached");
577  break;
579  SCIPmessageFPrintInfo(scip->messagehdlr, file, "solution improvement limit reached");
580  break;
582  SCIPmessageFPrintInfo(scip->messagehdlr, file, "restart limit reached");
583  break;
584  case SCIP_STATUS_OPTIMAL:
585  SCIPmessageFPrintInfo(scip->messagehdlr, file, "optimal solution found");
586  break;
588  SCIPmessageFPrintInfo(scip->messagehdlr, file, "infeasible");
589  break;
591  SCIPmessageFPrintInfo(scip->messagehdlr, file, "unbounded");
592  break;
594  SCIPmessageFPrintInfo(scip->messagehdlr, file, "infeasible or unbounded");
595  break;
597  SCIPmessageFPrintInfo(scip->messagehdlr, file, "termination signal received");
598  break;
599  default:
600  SCIPerrorMessage("invalid status code <%d>\n", SCIPgetStatus(scip));
601  return SCIP_INVALIDDATA;
602  }
603 
604  return SCIP_OKAY;
605 }
606 
607 /** returns whether the current stage belongs to the transformed problem space
608  *
609  * @return Returns TRUE if the \SCIP instance is transformed, otherwise FALSE
610  */
612  SCIP* scip /**< SCIP data structure */
613  )
614 {
615  assert(scip != NULL);
616 
617  return ((int)scip->set->stage >= (int)SCIP_STAGE_TRANSFORMING);
618 }
619 
620 /** returns whether the solution process should be probably correct
621  *
622  * @note This feature is not supported yet!
623  *
624  * @return Returns TRUE if \SCIP is exact solving mode, otherwise FALSE
625  */
627  SCIP* scip /**< SCIP data structure */
628  )
629 {
630  assert(scip != NULL);
631  assert(scip->set != NULL);
632 
633  return (scip->set->misc_exactsolve);
634 }
635 
636 /** returns whether the presolving process would be finished given no more presolving reductions are found in this
637  * presolving round
638  *
639  * Checks whether the number of presolving rounds is not exceeded and the presolving reductions found in the current
640  * presolving round suffice to trigger another presolving round.
641  *
642  * @note if subsequent presolvers find more reductions, presolving might continue even if the method returns FALSE
643  * @note does not check whether infeasibility or unboundedness was already detected in presolving (which would result
644  * in presolving being stopped although the method returns TRUE)
645  *
646  * @return Returns TRUE if presolving is finished if no further reductions are detected
647  */
649  SCIP* scip /**< SCIP data structure */
650  )
651 {
652  int maxnrounds;
653  SCIP_Bool finished;
654 
655  assert(scip != NULL);
656  assert(scip->stat != NULL);
657  assert(scip->transprob != NULL);
658 
659  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPisPresolveFinished", FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
660 
661  /* get maximum number of presolving rounds */
662  maxnrounds = scip->set->presol_maxrounds;
663  if( maxnrounds == -1 )
664  maxnrounds = INT_MAX;
665 
666  /* don't abort, if enough changes were applied to the variables */
667  finished = (scip->transprob->nvars == 0
668  || (scip->stat->npresolfixedvars - scip->stat->lastnpresolfixedvars
669  + scip->stat->npresolaggrvars - scip->stat->lastnpresolaggrvars
671  + (scip->stat->npresolchgbds - scip->stat->lastnpresolchgbds)/10.0
672  + (scip->stat->npresoladdholes - scip->stat->lastnpresoladdholes)/10.0
673  <= scip->set->presol_abortfac * scip->transprob->nvars)); /*lint !e653*/
674 
675  /* don't abort, if enough changes were applied to the constraints */
676  finished = finished
677  && (scip->transprob->nconss == 0
678  || (scip->stat->npresoldelconss - scip->stat->lastnpresoldelconss
679  + scip->stat->npresoladdconss - scip->stat->lastnpresoladdconss
681  + scip->stat->npresolchgsides - scip->stat->lastnpresolchgsides
682  <= scip->set->presol_abortfac * scip->transprob->nconss));
683 
684  /* don't abort, if enough changes were applied to the coefficients (assume a 1% density of non-zero elements) */
685  finished = finished
686  && (scip->transprob->nvars == 0 || scip->transprob->nconss == 0
687  || (scip->stat->npresolchgcoefs - scip->stat->lastnpresolchgcoefs
688  <= scip->set->presol_abortfac * 0.01 * scip->transprob->nvars * scip->transprob->nconss));
689 
690 #ifdef SCIP_DISABLED_CODE
691  /* since 2005, we do not take cliques and implications into account when deciding whether to stop presolving */
692  /* don't abort, if enough new implications or cliques were found (assume 100 implications per variable) */
693  finished = finished
694  && (scip->stat->nimplications - scip->stat->lastnpresolimplications
695  <= scip->set->presol_abortfac * 100 * scip->transprob->nbinvars)
696  && (SCIPcliquetableGetNCliques(scip->cliquetable) - scip->stat->lastnpresolcliques
697  <= scip->set->presol_abortfac * scip->transprob->nbinvars);
698 #endif
699 
700  /* abort if maximal number of presolving rounds is reached */
701  finished = finished || (scip->stat->npresolrounds + 1 >= maxnrounds);
702 
703  return finished;
704 }
705 
706 /** returns whether SCIP has performed presolving during the last solve
707  *
708  * @return Returns TRUE if presolving was performed during the last solve
709  */
711  SCIP* scip /**< SCIP data structure */
712  )
713 {
714  assert(scip != NULL);
715  assert(scip->stat != NULL);
716 
717  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPhasPerformedPresolve", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
718 
719  return scip->stat->performpresol;
720 }
721 
722 /** returns whether the user pressed CTRL-C to interrupt the solving process
723  *
724  * @return Returns TRUE if Ctrl-C was pressed, otherwise FALSE.
725  */
727  SCIP* scip /**< SCIP data structure */
728  )
729 {
730  return SCIPinterrupted();
731 }
732 
733 /** returns whether the solving process should be / was stopped before proving optimality;
734  * if the solving process should be / was stopped, the status returned by SCIPgetStatus() yields
735  * the reason for the premature abort
736  *
737  * @return Returns TRUE if solving process is stopped/interrupted, otherwise FALSE.
738  */
740  SCIP* scip /**< SCIP data structure */
741  )
742 {
743  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPisStopped", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
744 
745  return SCIPsolveIsStopped(scip->set, scip->stat, FALSE);
746 }
747 
748 /** includes information about an external code linked into the SCIP library */
750  SCIP* scip, /**< SCIP data structure */
751  const char* name, /**< name of external code */
752  const char* description /**< description of external code, or NULL */
753  )
754 {
755  assert(scip != NULL);
756  assert(name != NULL);
757 
758  SCIP_CALL( SCIPcheckStage(scip, "SCIPincludeExternalCodeInformation", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
759 
760  SCIP_CALL( SCIPsetIncludeExternalCode(scip->set, name, description) );
761 
762  return SCIP_OKAY;
763 }
764 
765 /** returns an array of names of currently included external codes */
767  SCIP* scip /**< SCIP data structure */
768  )
769 {
770  assert(scip != NULL);
771  assert(scip->set != NULL);
772 
773  return scip->set->extcodenames;
774 }
775 
776 /** returns an array of the descriptions of currently included external codes
777  *
778  * @note some descriptions may be NULL
779  */
781  SCIP* scip /**< SCIP data structure */
782  )
783 {
784  assert(scip != NULL);
785  assert(scip->set != NULL);
786 
787  return scip->set->extcodedescs;
788 }
789 
790 /** returns the number of currently included information on external codes */
792  SCIP* scip /**< SCIP data structure */
793  )
794 {
795  assert(scip != NULL);
796  assert(scip->set != NULL);
797 
798  return scip->set->nextcodes;
799 }
800 
801 /** prints information on external codes to a file stream via the message handler system
802  *
803  * @note If the message handler is set to a NULL pointer nothing will be printed
804  */
806  SCIP* scip, /**< SCIP data structure */
807  FILE* file /**< output file (or NULL for standard output) */
808  )
809 {
810  int i;
811 
812  SCIPmessageFPrintInfo(scip->messagehdlr, file, "External codes: ");
813  if( scip->set->nextcodes == 0 )
814  {
815  SCIPinfoMessage(scip, file, "none\n");
816  return;
817  }
818  SCIPinfoMessage(scip, file, "\n");
819 
820  for( i = 0; i < scip->set->nextcodes; ++i )
821  {
822  SCIPinfoMessage(scip, file, " %-20s %s\n", scip->set->extcodenames[i], scip->set->extcodedescs[i] != NULL ? scip->set->extcodedescs[i] : "");
823  }
824 }
internal methods for separators
SCIP_STAT * stat
Definition: struct_scip.h:69
SCIP_Bool SCIPsolveIsStopped(SCIP_SET *set, SCIP_STAT *stat, SCIP_Bool checknodelimits)
Definition: solve.c:91
int npresoladdconss
Definition: struct_stat.h:235
#define NULL
Definition: def.h:239
internal methods for managing events
const char * SCIPexprintGetName(void)
default message handler
trivialnegation primal heuristic
internal methods for storing primal CIP solutions
SCIP_RETCODE SCIPsyncstoreRelease(SCIP_SYNCSTORE **syncstore)
Definition: syncstore.c:77
SCIP_STATUS status
Definition: struct_stat.h:170
SCIP_STAGE SCIPgetStage(SCIP *scip)
Definition: scip_general.c:412
methods to interpret (evaluate) an expression tree "fast"
internal methods for branch and bound tree
public methods for memory management
SCIP_Real SCIPgetPrimalbound(SCIP *scip)
methods for implications, variable bounds, and cliques
int presol_maxrounds
Definition: struct_set.h:415
internal methods for clocks and timing issues
SCIP_RETCODE SCIPsetCreate(SCIP_SET **set, SCIP_MESSAGEHDLR *messagehdlr, BMS_BLKMEM *blkmem, SCIP *scip)
Definition: set.c:1116
int npresolaggrvars
Definition: struct_stat.h:230
#define SCIP_CALL_FINALLY(x, y)
Definition: def.h:393
internal methods for NLPI solver interfaces
char ** SCIPgetExternalCodeDescriptions(SCIP *scip)
Definition: scip_general.c:780
int npresolfixedvars
Definition: struct_stat.h:229
SCIP_PRIMAL * primal
Definition: struct_scip.h:83
#define SCIP_SUBVERSION
Definition: def.h:112
interface methods for specific LP solvers
internal methods for displaying statistics tables
int npresoldelconss
Definition: struct_stat.h:234
int SCIPmajorVersion(void)
Definition: scip_general.c:158
int lastnpresolchgvartypes
Definition: struct_stat.h:241
#define FALSE
Definition: def.h:65
methods for the aggregation rows
internal methods for Benders&#39; decomposition
void SCIPclockStart(SCIP_CLOCK *clck, SCIP_SET *set)
Definition: clock.c:280
void SCIPprintExternalCodes(SCIP *scip, FILE *file)
Definition: scip_general.c:805
SCIP_STAGE stage
Definition: struct_set.h:63
#define TRUE
Definition: def.h:64
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
methods commonly used by primal heuristics
char ** SCIPgetExternalCodeNames(SCIP *scip)
Definition: scip_general.c:766
const char * SCIPgetGitHash(void)
Definition: scipgithash.c:27
internal methods for branching rules and branching candidate storage
const char * SCIPexprintGetDesc(void)
datastructures for concurrent solvers
SCIP_RETCODE SCIPinterruptCreate(SCIP_INTERRUPT **interrupt)
Definition: interrupt.c:79
internal methods for handling parameter settings
SCIP_PROB * transprob
Definition: struct_scip.h:87
methods for creating output for visualization tools (VBC, BAK)
nodereopt branching rule
SCIP_RETCODE SCIPcreate(SCIP **scip)
Definition: scip_general.c:339
#define BMSfreeMemory(ptr)
Definition: memory.h:127
SCIP_Bool SCIPisTransformed(SCIP *scip)
Definition: scip_general.c:611
SCIP_Bool SCIPpressedCtrlC(SCIP *scip)
Definition: scip_general.c:726
int lastnpresoladdconss
Definition: struct_stat.h:245
internal methods for LP management
void SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...)
Definition: scip_message.c:279
internal methods for branching and inference history
public methods for numerical tolerances
internal methods for collecting primal CIP solutions and primal informations
SCIP_DIALOGHDLR * dialoghdlr
Definition: struct_scip.h:64
public methods for querying solving statistics
internal methods for propagators
SCIP_RETCODE SCIPsetFree(SCIP_SET **set, BMS_BLKMEM *blkmem)
Definition: set.c:2674
char ** extcodedescs
Definition: struct_set.h:96
int SCIPcliquetableGetNCliques(SCIP_CLIQUETABLE *cliquetable)
Definition: implics.c:3469
int npresolchgcoefs
Definition: struct_stat.h:237
int npresolchgvartypes
Definition: struct_stat.h:231
SCIP_Bool SCIPisPresolveFinished(SCIP *scip)
Definition: scip_general.c:648
int lastnpresolfixedvars
Definition: struct_stat.h:239
git hash methods
int lastnpresoladdholes
Definition: struct_stat.h:243
internal methods for storing and manipulating the main problem
void SCIPmessagePrintError(const char *formatstr,...)
Definition: message.c:781
#define SCIPerrorMessage
Definition: pub_message.h:45
methods for block memory pools and memory buffers
SCIP_RETCODE SCIPfreeProb(SCIP *scip)
Definition: scip_prob.c:745
int npresolchgsides
Definition: struct_stat.h:238
int lastnpresolchgbds
Definition: struct_stat.h:242
register additional core functionality that is designed as plugins
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
SCIP_STATUS SCIPgetStatus(SCIP *scip)
Definition: scip_general.c:519
SCIP_Real SCIPversion(void)
Definition: scip_general.c:147
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
Definition: scip_mem.c:128
void SCIPretcodePrintError(SCIP_RETCODE retcode)
Definition: retcode.c:100
internal methods for presolvers
SCIP_RETCODE SCIPprintStage(SCIP *scip, FILE *file)
Definition: scip_general.c:434
SCIP_RETCODE SCIPdialoghdlrCreate(SCIP_SET *set, SCIP_DIALOGHDLR **dialoghdlr)
Definition: dialog.c:325
internal methods for NLP management
internal miscellaneous methods
SCIP_RETCODE SCIPmessagehdlrRelease(SCIP_MESSAGEHDLR **messagehdlr)
Definition: message.c:338
const char * SCIPlpiGetSolverDesc(void)
internal methods for node selectors and node priority queues
internal methods for variable pricers
int npresolchgbds
Definition: struct_stat.h:232
internal methods for global SCIP settings
internal methods for storing conflicts
#define SCIP_CALL(x)
Definition: def.h:351
int npresoladdholes
Definition: struct_stat.h:233
SCIP main data structure.
SCIP_RETCODE SCIPprintStatus(SCIP *scip, FILE *file)
Definition: scip_general.c:542
internal methods for storing priced variables
internal methods for relaxators
internal methods for storing separated cuts
int lastnpresoldelconss
Definition: struct_stat.h:244
SCIP_RETCODE SCIPclockCreate(SCIP_CLOCK **clck, SCIP_CLOCKTYPE clocktype)
Definition: clock.c:160
methods commonly used for presolving
methods for catching the user CTRL-C interrupt
SCIP_CLIQUETABLE * cliquetable
Definition: struct_scip.h:86
SCIP_RETCODE SCIPmemCreate(SCIP_MEM **mem)
Definition: mem.c:33
#define SCIP_COPYRIGHT
Definition: def.h:114
internal methods for problem variables
data structures and methods for collecting reoptimization information
the function declarations for the synchronization store
internal methods for user interface dialog
int SCIPgetNExternalCodes(SCIP *scip)
Definition: scip_general.c:791
#define SCIP_Bool
Definition: def.h:62
SCIP_Bool SCIPinterrupted(void)
Definition: interrupt.c:151
static SCIP_RETCODE doScipCreate(SCIP **scip)
Definition: scip_general.c:282
void SCIPprintVersion(SCIP *scip, FILE *file)
Definition: scip_general.c:202
void SCIPinterruptFree(SCIP_INTERRUPT **interrupt)
Definition: interrupt.c:92
int nbinvars
Definition: struct_prob.h:62
enum SCIP_Status SCIP_STATUS
Definition: type_stat.h:58
int npresolrounds
Definition: struct_stat.h:225
internal methods for input file readers
void SCIPclockFree(SCIP_CLOCK **clck)
Definition: clock.c:175
SCIP_RETCODE SCIPsetIncludeExternalCode(SCIP_SET *set, const char *name, const char *description)
Definition: set.c:4984
methods for debugging
int SCIPsubversion(void)
Definition: scip_general.c:191
SCIP_RETCODE SCIPincludeCorePlugins(SCIP *scip)
int lastnpresolchgcoefs
Definition: struct_stat.h:247
int SCIPtechVersion(void)
Definition: scip_general.c:180
reoptsols primal heuristic
internal methods for storing cuts in a cut pool
Constraint handler for linear constraints in their most general form, .
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
#define BMSclearMemory(ptr)
Definition: memory.h:111
helper functions for concurrent scip solvers
SCIP_RETCODE SCIPsyncstoreCreate(SCIP_SYNCSTORE **syncstore)
Definition: syncstore.c:56
internal methods for return codes for SCIP methods
#define SCIP_VERSION
Definition: def.h:111
SCIP_Bool misc_exactsolve
Definition: struct_set.h:361
general public methods
SCIP_RETCODE SCIPcreateMessagehdlrDefault(SCIP_MESSAGEHDLR **messagehdlr, SCIP_Bool bufferedoutput, const char *filename, SCIP_Bool quiet)
char ** extcodenames
Definition: struct_set.h:95
internal methods for conflict analysis
internal methods for tree compressions
internal methods for main solving loop and node processing
int nconss
Definition: struct_prob.h:73
SCIP_SET * set
Definition: struct_scip.h:62
public methods for message output
void SCIPmessageFPrintInfo(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char *formatstr,...)
Definition: message.c:608
SCIP_MESSAGEHDLR * messagehdlr
Definition: struct_scip.h:65
default user interface dialog
#define SCIP_Real
Definition: def.h:150
internal methods for problem statistics
SCIP_RETCODE SCIPmemFree(SCIP_MEM **mem)
Definition: mem.c:59
enum SCIP_Stage SCIP_STAGE
Definition: type_set.h:50
SCIP_Bool SCIPisStopped(SCIP *scip)
Definition: scip_general.c:739
public methods for message handling
#define BMSallocMemory(ptr)
Definition: memory.h:101
internal methods for constraints and constraint handlers
int nextcodes
Definition: struct_set.h:139
declarations for XML parsing
SCIP_OBJSENSE SCIPgetObjsense(SCIP *scip)
Definition: scip_prob.c:1281
build flags methods
SCIP_RETCODE SCIPincludeExternalCodeInformation(SCIP *scip, const char *name, const char *description)
Definition: scip_general.c:749
SCIP_Bool performpresol
Definition: struct_stat.h:264
SCIP_Bool SCIPhasPerformedPresolve(SCIP *scip)
Definition: scip_general.c:710
common defines and data types used in all packages of SCIP
SCIP_RETCODE SCIPnlpInclude(SCIP_SET *set, BMS_BLKMEM *blkmem)
Definition: nlp.c:5038
SCIP_RETCODE SCIPdialoghdlrFree(SCIP *scip, SCIP_DIALOGHDLR **dialoghdlr)
Definition: dialog.c:355
#define SCIP_CALL_ABORT(x)
Definition: def.h:330
void SCIPprintError(SCIP_RETCODE retcode)
Definition: scip_general.c:267
internal methods for primal heuristics
#define SCIP_ALLOC(x)
Definition: def.h:362
int lastnpresolchgsides
Definition: struct_stat.h:248
public methods for global and local (sub)problems
const char * SCIPlpiGetSolverName(void)
SCIP_Real presol_abortfac
Definition: struct_set.h:414
int SCIPminorVersion(void)
Definition: scip_general.c:169
SCIP_Longint nlimsolsfound
Definition: struct_primal.h:40
int npresolupgdconss
Definition: struct_stat.h:236
void SCIPprintBuildOptions(SCIP *scip, FILE *file)
Definition: scip_general.c:237
SCIP_Bool SCIPisExactSolve(SCIP *scip)
Definition: scip_general.c:626
int lastnpresolaggrvars
Definition: struct_stat.h:240
internal methods for Benders&#39; decomposition cuts
int lastnpresolupgdconss
Definition: struct_stat.h:246
SCIP_RETCODE SCIPfree(SCIP **scip)
Definition: scip_general.c:371
internal methods for displaying runtime statistics
int nimplications
Definition: struct_stat.h:224
const char * SCIPgetBuildFlags(void)
OFINS - Objective Function Induced Neighborhood Search - a primal heuristic for reoptimization.