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