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