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