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