Scippy

SCIP

Solving Constraint Integer Programs

objiisfinder.h
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 objiisfinder.h
26 * @brief C++ wrapper for iis finders
27 * @author Mark Turner
28 */
29
30/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
31
32#ifndef __SCIP_OBJIISFINDER_H__
33#define __SCIP_OBJIISFINDER_H__
34
35#include <cstring>
36#include <utility>
37
38#include "scip/scip.h"
40
41namespace scip
42{
43
44/** @brief C++ wrapper for iis finders
45 *
46 * This class defines the interface for iis finders implemented in C++.
47 *
48 * - \ref IISFINDER "Instructions for implementing an iis finder"
49 * - \ref IISFINDERS "List of available iis finders"
50 * - \ref type_iisfinder.h "Corresponding C interface"
51 */
53{
54public:
55 /*lint --e{1540}*/
56
57 /** SCIP data structure */
59
60 /** name of the iis finder */
62
63 /** description of the iis finder */
65
66 /** priority of the iis finder */
67 const int scip_priority_;
68
69 /** default constructor */
71 SCIP* scip, /**< SCIP data structure */
72 const char* name, /**< name of iis finder */
73 const char* desc, /**< description of iis finder */
74 int priority /**< priority of the iis finder */
75 )
76 : scip_(scip),
77 scip_name_(0),
78 scip_desc_(0),
79 scip_priority_(priority)
80 {
81 SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_name_, name, std::strlen(name)+1) );
82 SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_desc_, desc, std::strlen(desc)+1) );
83 }
84
85 /** copy constructor */
87
88 /** move constructor */
90 {
91 std::swap(scip_name_, o.scip_name_);
92 std::swap(scip_desc_, o.scip_desc_);
93 }
94
95 /** destructor */
96 virtual ~ObjIISfinder()
97 {
98 /*lint --e{64}*/
101 }
102
103 /** assignment of polymorphic classes causes slicing and is therefore disabled. */
105
106 /** assignment of polymorphic classes causes slicing and is therefore disabled. */
108
109 /** destructor of iis finder to free user data (called when SCIP is exiting)
110 *
111 * @see SCIP_DECL_IISFINDERFREE(x) in @ref type_iisfinder.h
112 */
113 virtual SCIP_DECL_IISFINDERFREE(scip_free)
114 { /*lint --e{715}*/
115 return SCIP_OKAY;
116 }
117
118 /** iis finder execution method of iis finder
119 *
120 * @see SCIP_DECL_IISFINDEREXEC(x) in @ref type_iisfinder.h
121 */
122 virtual SCIP_DECL_IISFINDEREXEC(scip_exec) = 0;
123};
124
125} /* namespace scip */
126
127
128
129/** creates the iis finder for the given iis finder object and includes it in SCIP
130 *
131 * The method should be called in one of the following ways:
132 *
133 * 1. The user is responsible for deleting the object:
134 * SCIP_CALL( SCIPcreate(&scip) );
135 * ...
136 * MyIISfinder* myiisfinder = new MyIISfinder(...);
137 * SCIP_CALL( SCIPincludeObjIISfinder(scip, &myiisfinder, FALSE) );
138 * ...
139 * SCIP_CALL( SCIPfree(&scip) );
140 * delete myiisfinder; // delete iisfinder AFTER SCIPfree() !
141 *
142 * 2. The object pointer is passed to SCIP and deleted by SCIP in the SCIPfree() call:
143 * SCIP_CALL( SCIPcreate(&scip) );
144 * ...
145 * SCIP_CALL( SCIPincludeObjIISfinder(scip, new MyIISfinder(...), TRUE) );
146 * ...
147 * SCIP_CALL( SCIPfree(&scip) ); // destructor of MyIISfinder is called here
148 */
149SCIP_EXPORT
151 SCIP* scip, /**< SCIP data structure */
152 scip::ObjIISfinder* objiisfinder, /**< iis finder object */
153 SCIP_Bool deleteobject /**< should the iis finder object be deleted when iis finder is freed? */
154 );
155
156/** returns the iis finder object of the given name, or 0 if not existing */
157SCIP_EXPORT
159 SCIP* scip, /**< SCIP data structure */
160 const char* name /**< name of iis finder */
161 );
162
163/** returns the iis finder object for the given iis finder */
164SCIP_EXPORT
166 SCIP* scip, /**< SCIP data structure */
167 SCIP_IISFINDER* iisfinder /**< iis finder */
168 );
169
170#endif
C++ wrapper for iis finders.
Definition: objiisfinder.h:53
virtual ~ObjIISfinder()
Definition: objiisfinder.h:96
ObjIISfinder & operator=(const ObjIISfinder &o)=delete
ObjIISfinder(const ObjIISfinder &o)
Definition: objiisfinder.h:86
ObjIISfinder(SCIP *scip, const char *name, const char *desc, int priority)
Definition: objiisfinder.h:70
const int scip_priority_
Definition: objiisfinder.h:67
ObjIISfinder(ObjIISfinder &&o)
Definition: objiisfinder.h:89
virtual SCIP_DECL_IISFINDERFREE(scip_free)
Definition: objiisfinder.h:113
ObjIISfinder & operator=(ObjIISfinder &&o)=delete
virtual SCIP_DECL_IISFINDEREXEC(scip_exec)=0
#define SCIP_Bool
Definition: def.h:91
#define SCIP_CALL_ABORT(x)
Definition: def.h:334
#define SCIPduplicateMemoryArray(scip, ptr, source, num)
Definition: scip_mem.h:76
#define SCIPfreeMemoryArray(scip, ptr)
Definition: scip_mem.h:80
definition of base class for all clonable classes
SCIP_RETCODE SCIPincludeObjIISfinder(SCIP *scip, scip::ObjIISfinder *objiisfinder, SCIP_Bool deleteobject)
scip::ObjIISfinder * SCIPgetObjIISfinder(SCIP *scip, SCIP_IISFINDER *iisfinder)
scip::ObjIISfinder * SCIPfindObjIISfinder(SCIP *scip, const char *name)
SCIP callable library.
Definition of base class for all clonable classes.
Definition: objcloneable.h:48
@ SCIP_OKAY
Definition: type_retcode.h:42
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:63