1    	/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2    	/*                                                                           */
3    	/*                  This file is part of the program and library             */
4    	/*         SCIP --- Solving Constraint Integer Programs                      */
5    	/*                                                                           */
6    	/*  Copyright (c) 2002-2023 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_sepa.h
26   	 * @ingroup PUBLICCOREAPI
27   	 * @brief  public methods for separator plugins
28   	 * @author Tobias Achterberg
29   	 * @author Timo Berthold
30   	 * @author Thorsten Koch
31   	 * @author Alexander Martin
32   	 * @author Marc Pfetsch
33   	 * @author Kati Wolter
34   	 * @author Gregor Hendel
35   	 * @author Leona Gottwald
36   	 */
37   	
38   	/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
39   	
40   	#ifndef __SCIP_SCIP_SEPA_H__
41   	#define __SCIP_SCIP_SEPA_H__
42   	
43   	
44   	#include "scip/def.h"
45   	#include "scip/type_result.h"
46   	#include "scip/type_retcode.h"
47   	#include "scip/type_scip.h"
48   	#include "scip/type_sepa.h"
49   	#include "scip/type_sol.h"
50   	
51   	/* In debug mode, we include the SCIP's structure in scip.c, such that no one can access
52   	 * this structure except the interface methods in scip.c.
53   	 * In optimized mode, the structure is included in scip.h, because some of the methods
54   	 * are implemented as defines for performance reasons (e.g. the numerical comparisons).
55   	 * Additionally, the internal "set.h" is included, such that the defines in set.h are
56   	 * available in optimized mode.
57   	 */
58   	#ifdef NDEBUG
59   	#include "scip/struct_scip.h"
60   	#include "scip/struct_set.h"
61   	#include "scip/tree.h"
62   	#endif
63   	
64   	#ifdef __cplusplus
65   	extern "C" {
66   	#endif
67   	
68   	/**@addtogroup PublicSeparatorMethods
69   	 *
70   	 * @{
71   	 */
72   	
73   	/** creates a separator and includes it in SCIP.
74   	 *
75   	 *  @note method has all separator callbacks as arguments and is thus changed every time a new
76   	 *        callback is added
77   	 *        in future releases; consider using SCIPincludeSepaBasic() and setter functions
78   	 *        if you seek for a method which is less likely to change in future releases
79   	 */
80   	SCIP_EXPORT
81   	SCIP_RETCODE SCIPincludeSepa(
82   	   SCIP*                 scip,               /**< SCIP data structure */
83   	   const char*           name,               /**< name of separator */
84   	   const char*           desc,               /**< description of separator */
85   	   int                   priority,           /**< priority of separator (>= 0: before, < 0: after constraint handlers) */
86   	   int                   freq,               /**< frequency for calling separator */
87   	   SCIP_Real             maxbounddist,       /**< maximal relative distance from current node's dual bound to primal bound compared
88   	                                              *   to best node's dual bound for applying separation */
89   	   SCIP_Bool             usessubscip,        /**< does the separator use a secondary SCIP instance? */
90   	   SCIP_Bool             delay,              /**< should separator be delayed, if other separators found cuts? */
91   	   SCIP_DECL_SEPACOPY    ((*sepacopy)),      /**< copy method of separator or NULL if you don't want to copy your plugin into sub-SCIPs */
92   	   SCIP_DECL_SEPAFREE    ((*sepafree)),      /**< destructor of separator */
93   	   SCIP_DECL_SEPAINIT    ((*sepainit)),      /**< initialize separator */
94   	   SCIP_DECL_SEPAEXIT    ((*sepaexit)),      /**< deinitialize separator */
95   	   SCIP_DECL_SEPAINITSOL ((*sepainitsol)),   /**< solving process initialization method of separator */
96   	   SCIP_DECL_SEPAEXITSOL ((*sepaexitsol)),   /**< solving process deinitialization method of separator */
97   	   SCIP_DECL_SEPAEXECLP  ((*sepaexeclp)),    /**< LP solution separation method of separator */
98   	   SCIP_DECL_SEPAEXECSOL ((*sepaexecsol)),   /**< arbitrary primal solution separation method of separator */
99   	   SCIP_SEPADATA*        sepadata            /**< separator data */
100  	   );
101  	
102  	/** creates a separator and includes it in SCIP with its most fundamental callbacks. All non-fundamental
103  	 *  (or optional) callbacks as, e.g., init and exit callbacks, will be set to NULL.
104  	 *  Optional callbacks can be set via specific setter functions, see SCIPsetSepaInit(), SCIPsetSepaFree(),
105  	 *  SCIPsetSepaInitsol(), SCIPsetSepaExitsol(), SCIPsetSepaCopy(), SCIPsetExit().
106  	 *
107  	 *  @note if you want to set all callbacks with a single method call, consider using SCIPincludeSepa() instead
108  	 */
109  	SCIP_EXPORT
110  	SCIP_RETCODE SCIPincludeSepaBasic(
111  	   SCIP*                 scip,               /**< SCIP data structure */
112  	   SCIP_SEPA**           sepa,               /**< reference to a separator, or NULL */
113  	   const char*           name,               /**< name of separator */
114  	   const char*           desc,               /**< description of separator */
115  	   int                   priority,           /**< priority of separator (>= 0: before, < 0: after constraint handlers) */
116  	   int                   freq,               /**< frequency for calling separator */
117  	   SCIP_Real             maxbounddist,       /**< maximal relative distance from current node's dual bound to primal bound compared
118  	                                              *   to best node's dual bound for applying separation */
119  	   SCIP_Bool             usessubscip,        /**< does the separator use a secondary SCIP instance? */
120  	   SCIP_Bool             delay,              /**< should separator be delayed, if other separators found cuts? */
121  	   SCIP_DECL_SEPAEXECLP  ((*sepaexeclp)),    /**< LP solution separation method of separator */
122  	   SCIP_DECL_SEPAEXECSOL ((*sepaexecsol)),   /**< arbitrary primal solution separation method of separator */
123  	   SCIP_SEPADATA*        sepadata            /**< separator data */
124  	   );
125  	
126  	/** sets copy method of separator */
127  	SCIP_EXPORT
128  	SCIP_RETCODE SCIPsetSepaCopy(
129  	   SCIP*                 scip,               /**< SCIP data structure */
130  	   SCIP_SEPA*            sepa,               /**< separator */
131  	   SCIP_DECL_SEPACOPY    ((*sepacopy))       /**< copy method of separator or NULL if you don't want to copy your plugin into sub-SCIPs */
132  	   );
133  	
134  	/** sets destructor method of separator */
135  	SCIP_EXPORT
136  	SCIP_RETCODE SCIPsetSepaFree(
137  	   SCIP*                 scip,               /**< SCIP data structure */
138  	   SCIP_SEPA*            sepa,               /**< separator */
139  	   SCIP_DECL_SEPAFREE    ((*sepafree))       /**< destructor of separator */
140  	   );
141  	
142  	/** sets initialization method of separator */
143  	SCIP_EXPORT
144  	SCIP_RETCODE SCIPsetSepaInit(
145  	   SCIP*                 scip,               /**< SCIP data structure */
146  	   SCIP_SEPA*            sepa,               /**< separator */
147  	   SCIP_DECL_SEPAINIT    ((*sepainit))       /**< initialize separator */
148  	   );
149  	
150  	/** sets deinitialization method of separator */
151  	SCIP_EXPORT
152  	SCIP_RETCODE SCIPsetSepaExit(
153  	   SCIP*                 scip,               /**< SCIP data structure */
154  	   SCIP_SEPA*            sepa,               /**< separator */
155  	   SCIP_DECL_SEPAEXIT    ((*sepaexit))       /**< deinitialize separator */
156  	   );
157  	
158  	/** sets solving process initialization method of separator */
159  	SCIP_EXPORT
160  	SCIP_RETCODE SCIPsetSepaInitsol(
161  	   SCIP*                 scip,               /**< SCIP data structure */
162  	   SCIP_SEPA*            sepa,               /**< separator */
163  	   SCIP_DECL_SEPAINITSOL ((*sepainitsol))    /**< solving process initialization method of separator */
164  	   );
165  	
166  	/** sets solving process deinitialization method of separator */
167  	SCIP_EXPORT
168  	SCIP_RETCODE SCIPsetSepaExitsol(
169  	   SCIP*                 scip,               /**< SCIP data structure */
170  	   SCIP_SEPA*            sepa,               /**< separator */
171  	   SCIP_DECL_SEPAEXITSOL ((*sepaexitsol))    /**< solving process deinitialization method of separator */
172  	   );
173  	
174  	/** returns the separator of the given name, or NULL if not existing */
175  	SCIP_EXPORT
176  	SCIP_SEPA* SCIPfindSepa(
177  	   SCIP*                 scip,               /**< SCIP data structure */
178  	   const char*           name                /**< name of separator */
179  	   );
180  	
181  	/** returns the array of currently available separators */
182  	SCIP_EXPORT
183  	SCIP_SEPA** SCIPgetSepas(
184  	   SCIP*                 scip                /**< SCIP data structure */
185  	   );
186  	
187  	/** returns the number of currently available separators */
188  	SCIP_EXPORT
189  	int SCIPgetNSepas(
190  	   SCIP*                 scip                /**< SCIP data structure */
191  	   );
192  	
193  	/** sets the priority of a separator */
194  	SCIP_EXPORT
195  	SCIP_RETCODE SCIPsetSepaPriority(
196  	   SCIP*                 scip,               /**< SCIP data structure */
197  	   SCIP_SEPA*            sepa,               /**< separator */
198  	   int                   priority            /**< new priority of the separator */
199  	   );
200  	
201  	/** declares separator to be a parent separator
202  	 *
203  	 *  Parent separators generate cuts of several types. To distinguish these cuts, they create child separators, which are
204  	 *  only needed to detect which cuts are applied.
205  	 */
206  	SCIP_EXPORT
207  	void SCIPsetSepaIsParentsepa(
208  	   SCIP*                 scip,               /**< SCIP data structure */
209  	   SCIP_SEPA*            sepa                /**< separator */
210  	   );
211  	
212  	/** sets the parent separator
213  	 *
214  	 *  Informs SCIP that the separator @p sepa depends on the parent separator @p parentsepa.
215  	 */
216  	SCIP_EXPORT
217  	void SCIPsetSepaParentsepa(
218  	   SCIP*                 scip,               /**< SCIP data structure */
219  	   SCIP_SEPA*            sepa,               /**< separator */
220  	   SCIP_SEPA*            parentsepa          /**< parent separator */
221  	   );
222  	
223  	/** gets value of minimal efficacy for a cut to enter the LP
224  	 *
225  	 *  @pre This method can be called if @p scip is in one of the following stages:
226  	 *       - \ref SCIP_STAGE_SOLVING
227  	 *
228  	 *  @return value of "separating/minefficacyroot" if at root node, otherwise value of "separating/minefficacy"
229  	 */
230  	SCIP_EXPORT
231  	SCIP_Real SCIPgetSepaMinEfficacy(
232  	   SCIP*                 scip                /**< SCIP data structure */
233  	   );
234  	
235  	#ifdef NDEBUG
236  	#define SCIPgetSepaMinEfficacy(scip)         (SCIPtreeGetCurrentDepth((scip)->tree) == 0 ? (scip)->set->sepa_minefficacyroot : (scip)->set->sepa_minefficacy)
237  	#endif
238  	
239  	/** @} */
240  	
241  	#ifdef __cplusplus
242  	}
243  	#endif
244  	
245  	#endif
246