Scippy

SCIP

Solving Constraint Integer Programs

scip_iisfinder.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-2025 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_iisfinder.c
26 * @ingroup OTHER_CFILES
27 * @brief public methods for IIS plugins
28 * @author Mark Turner
29 *
30 */
31
32/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
33
34#include "scip/debug.h"
35#include "scip/iisfinder.h"
36#include "scip/pub_message.h"
37#include "scip/scip_iisfinder.h"
38#include "scip/set.h"
39#include "scip/struct_mem.h"
40#include "scip/struct_scip.h"
41
42/** creates an IIS finder and includes it in SCIP
43 *
44 * @note this method has all IIS finder callbacks as arguments and is thus changed every time a new
45 * callback is added in future releases; consider using SCIPincludeIISfinderBasic() and setter functions
46 * if you seek for a method which is less likely to change in future releases
47 */
49 SCIP* scip, /**< SCIP data structure */
50 const char* name, /**< name of IIS finder */
51 const char* desc, /**< description of IIS finder */
52 int priority, /**< priority of the IIS finder */
53 SCIP_DECL_IISFINDERCOPY ((*iisfindercopy)), /**< copy method of IIS finder or NULL if you don't want to copy your plugin into sub-SCIPs */
54 SCIP_DECL_IISFINDERFREE ((*iisfinderfree)), /**< destructor of IIS finder */
55 SCIP_DECL_IISFINDEREXEC ((*iisfinderexec)), /**< IIS finder execution method */
56 SCIP_IISFINDERDATA* iisfinderdata /**< IIS finder data */
57 )
58{
59 SCIP_IISFINDER* iisfinder;
60
62
63 /* check whether the IIS is already present */
64 if( SCIPfindIISfinder(scip, name) != NULL )
65 {
66 SCIPerrorMessage("IIS <%s> already included.\n", name);
67 return SCIP_INVALIDDATA;
68 }
69
70 SCIP_CALL( SCIPiisfinderCreate(&iisfinder, scip->set, scip->messagehdlr, scip->mem->setmem, name, desc, priority,
71 iisfindercopy, iisfinderfree, iisfinderexec, iisfinderdata) );
72 SCIP_CALL( SCIPsetIncludeIISfinder(scip->set, iisfinder) );
73
74 return SCIP_OKAY;
75}
76
77/** Creates an IIS finder and includes it in SCIP with its most fundamental callbacks.
78 *
79 * All non-fundamental (or optional) callbacks as, e.g., copy and free callbacks, will be set to NULL. Optional
80 * callbacks can be set via specific setter functions, see SCIPsetIISfinderCopy(), and SCIPsetIISfinderFree()
81 *
82 * @note if you want to set all callbacks with a single method call, consider using SCIPincludeIISfinder() instead
83 */
85 SCIP* scip, /**< SCIP data structure */
86 SCIP_IISFINDER** iisfinder, /**< reference to an IIS finder, or NULL */
87 const char* name, /**< name of IIS finder */
88 const char* desc, /**< description of IIS finder */
89 int priority, /**< priority of the IIS finder in standard mode */
90 SCIP_DECL_IISFINDEREXEC((*iisfinderexec)), /**< IIS finder execution method */
91 SCIP_IISFINDERDATA* iisfinderdata /**< IIS finder data */
92 )
93{
94 SCIP_IISFINDER* iisfinderptr;
95
96 SCIP_CALL( SCIPcheckStage(scip, "SCIPincludeIISfinderBasic", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
97
98 /* check whether the IIS is already present */
99 if( SCIPfindIISfinder(scip, name) != NULL )
100 {
101 SCIPerrorMessage("IIS finder <%s> already included.\n", name);
102 return SCIP_INVALIDDATA;
103 }
104
105 SCIP_CALL( SCIPiisfinderCreate(&iisfinderptr, scip->set, scip->messagehdlr, scip->mem->setmem, name, desc, priority,
106 NULL, NULL, iisfinderexec, iisfinderdata) );
107 SCIP_CALL( SCIPsetIncludeIISfinder(scip->set, iisfinderptr) );
108
109 if( iisfinder != NULL )
110 *iisfinder = iisfinderptr;
111
112 return SCIP_OKAY;
113}
114
115/** sets copy method of IIS finder */
117 SCIP* scip, /**< SCIP data structure */
118 SCIP_IISFINDER* iisfinder, /**< IIS finder */
119 SCIP_DECL_IISFINDERCOPY ((*iisfindercopy)) /**< copy method of IIS finder or NULL if you don't want to copy your plugin into sub-SCIPs */
120 )
121{
122 SCIP_CALL( SCIPcheckStage(scip, "SCIPsetIISfinderCopy", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
123
124 assert(iisfinder != NULL);
125
126 SCIPiisfinderSetCopy(iisfinder, iisfindercopy);
127
128 return SCIP_OKAY;
129}
130
131/** sets destructor method of IIS finder */
133 SCIP* scip, /**< SCIP data structure */
134 SCIP_IISFINDER* iisfinder, /**< IIS finder */
135 SCIP_DECL_IISFINDERFREE ((*iisfinderfree)) /**< destructor of IIS finder */
136 )
137{
138 SCIP_CALL( SCIPcheckStage(scip, "SCIPsetIISfinderFree", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
139
140 assert(iisfinder != NULL);
141
142 SCIPiisfinderSetFree(iisfinder, iisfinderfree);
143
144 return SCIP_OKAY;
145}
146
147/** the execution method that iterates over the IIS finder plugins */
149 SCIP* scip /**< SCIP data structure */
150 )
151{
152 assert(scip != NULL);
154
155 return SCIP_OKAY;
156}
157
158/** returns the IIS finder of the given name, or NULL if not existing */
160 SCIP* scip, /**< SCIP data structure */
161 const char* name /**< name of the IIS finder */
162 )
163{
164 assert(scip != NULL);
165 assert(scip->set != NULL);
166 assert(name != NULL);
167
168 return SCIPsetFindIISfinder(scip->set, name);
169}
170
171/** returns the array of currently available IIS finders */
173 SCIP* scip /**< SCIP data structure */
174 )
175{
176 assert(scip != NULL);
177 assert(scip->set != NULL);
178
180
181 return scip->set->iisfinders;
182}
183
184/** returns the number of currently available IIS finders */
186 SCIP* scip /**< SCIP data structure */
187 )
188{
189 assert(scip != NULL);
190 assert(scip->set != NULL);
191
192 return scip->set->niisfinders;
193}
194
195/** sets the priority of an IIS finder */
197 SCIP* scip, /**< SCIP data structure */
198 SCIP_IISFINDER* iisfinder, /**< IIS finder */
199 int priority /**< new priority of the IIS finder */
200 )
201{
202 assert(scip != NULL);
203 assert(scip->set != NULL);
204 assert( iisfinder != NULL );
205
206 SCIPiisfinderSetPriority(iisfinder, scip->set, priority);
207
208 return SCIP_OKAY;
209}
210
211/** Gets the IIS.
212 *
213 * @return the \ref SCIP_IIS iis storage.
214 *
215 * @pre This method can be called if @p scip is in one of the following stages:
216 * - \ref SCIP_STAGE_INIT
217 * - \ref SCIP_STAGE_PROBLEM
218 * - \ref SCIP_STAGE_TRANSFORMING
219 * - \ref SCIP_STAGE_TRANSFORMED
220 * - \ref SCIP_STAGE_INITPRESOLVE
221 * - \ref SCIP_STAGE_PRESOLVING
222 * - \ref SCIP_STAGE_EXITPRESOLVE
223 * - \ref SCIP_STAGE_PRESOLVED
224 * - \ref SCIP_STAGE_INITSOLVE
225 * - \ref SCIP_STAGE_SOLVING
226 * - \ref SCIP_STAGE_SOLVED
227 * - \ref SCIP_STAGE_EXITSOLVE
228 * - \ref SCIP_STAGE_FREETRANS
229 *
230 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
231 */
233 SCIP* scip /**< SCIP data structure */
234 )
235{
237
238 return scip->iis;
239}
methods for debugging
#define SCIPcheckStage(scip, method, init, problem, transforming, transformed, initpresolve, presolving, exitpresolve, presolved, initsolve, solving, solved, exitsolve, freetrans, freescip)
Definition: debug.h:364
#define NULL
Definition: def.h:248
#define TRUE
Definition: def.h:93
#define FALSE
Definition: def.h:94
#define SCIP_CALL_ABORT(x)
Definition: def.h:334
#define SCIP_CALL(x)
Definition: def.h:355
SCIP_IISFINDER ** SCIPgetIISfinders(SCIP *scip)
SCIP_IISFINDER * SCIPfindIISfinder(SCIP *scip, const char *name)
SCIP_RETCODE SCIPsetIISfinderCopy(SCIP *scip, SCIP_IISFINDER *iisfinder, SCIP_DECL_IISFINDERCOPY((*iisfindercopy)))
int SCIPgetNIISfinders(SCIP *scip)
SCIP_RETCODE SCIPsetIISfinderPriority(SCIP *scip, SCIP_IISFINDER *iisfinder, int priority)
SCIP_RETCODE SCIPgenerateIIS(SCIP *scip)
SCIP_RETCODE SCIPincludeIISfinderBasic(SCIP *scip, SCIP_IISFINDER **iisfinder, const char *name, const char *desc, int priority, SCIP_DECL_IISFINDEREXEC((*iisfinderexec)), SCIP_IISFINDERDATA *iisfinderdata)
SCIP_RETCODE SCIPsetIISfinderFree(SCIP *scip, SCIP_IISFINDER *iisfinder, SCIP_DECL_IISFINDERFREE((*iisfinderfree)))
SCIP_RETCODE SCIPincludeIISfinder(SCIP *scip, const char *name, const char *desc, int priority, SCIP_DECL_IISFINDERCOPY((*iisfindercopy)), SCIP_DECL_IISFINDERFREE((*iisfinderfree)), SCIP_DECL_IISFINDEREXEC((*iisfinderexec)), SCIP_IISFINDERDATA *iisfinderdata)
SCIP_IIS * SCIPgetIIS(SCIP *scip)
SCIP_RETCODE SCIPiisfinderCreate(SCIP_IISFINDER **iisfinder, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, BMS_BLKMEM *blkmem, const char *name, const char *desc, int priority, SCIP_DECL_IISFINDERCOPY((*iisfindercopy)), SCIP_DECL_IISFINDERFREE((*iisfinderfree)), SCIP_DECL_IISFINDEREXEC((*iisfinderexec)), SCIP_IISFINDERDATA *iisfinderdata)
Definition: iisfinder.c:285
void SCIPiisfinderSetPriority(SCIP_IISFINDER *iisfinder, SCIP_SET *set, int priority)
Definition: iisfinder.c:689
void SCIPiisfinderSetFree(SCIP_IISFINDER *iisfinder, SCIP_DECL_IISFINDERFREE((*iisfinderfree)))
Definition: iisfinder.c:678
void SCIPiisfinderSetCopy(SCIP_IISFINDER *iisfinder, SCIP_DECL_IISFINDERCOPY((*iisfindercopy)))
Definition: iisfinder.c:667
SCIP_RETCODE SCIPiisGenerate(SCIP_SET *set)
Definition: iisfinder.c:321
internal methods for IIS finder
public methods for message output
#define SCIPerrorMessage
Definition: pub_message.h:64
public methods for IIS finder plugins
SCIP_IISFINDER * SCIPsetFindIISfinder(SCIP_SET *set, const char *name)
Definition: set.c:5217
SCIP_RETCODE SCIPsetIncludeIISfinder(SCIP_SET *set, SCIP_IISFINDER *iisfinder)
Definition: set.c:5194
void SCIPsetSortIISfinders(SCIP_SET *set)
Definition: set.c:5237
internal methods for global SCIP settings
datastructures for block memory pools and memory buffers
SCIP main data structure.
#define SCIP_DECL_IISFINDERFREE(x)
#define SCIP_DECL_IISFINDEREXEC(x)
struct SCIP_IISfinderData SCIP_IISFINDERDATA
#define SCIP_DECL_IISFINDERCOPY(x)
@ SCIP_INVALIDDATA
Definition: type_retcode.h:52
@ SCIP_OKAY
Definition: type_retcode.h:42
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:63