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   relax.h
26   	 * @ingroup INTERNALAPI
27   	 * @brief  internal methods for relaxators
28   	 * @author Tobias Achterberg
29   	 */
30   	
31   	/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
32   	
33   	#ifndef __SCIP_RELAX_H__
34   	#define __SCIP_RELAX_H__
35   	
36   	
37   	#include "scip/def.h"
38   	#include "blockmemshell/memory.h"
39   	#include "scip/type_primal.h"
40   	#include "scip/type_relax.h"
41   	#include "scip/type_result.h"
42   	#include "scip/type_retcode.h"
43   	#include "scip/type_set.h"
44   	#include "scip/type_sol.h"
45   	#include "scip/type_stat.h"
46   	#include "scip/type_tree.h"
47   	#include "scip/type_var.h"
48   	#include "scip/pub_relax.h"
49   	
50   	#ifdef __cplusplus
51   	extern "C" {
52   	#endif
53   	
54   	/** copies the given relaxator to a new scip */
55   	SCIP_RETCODE SCIPrelaxCopyInclude(
56   	   SCIP_RELAX*           relax,              /**< relaxator */
57   	   SCIP_SET*             set                 /**< SCIP_SET of SCIP to copy to */
58   	   );
59   	
60   	/** creates a relaxator */
61   	SCIP_RETCODE SCIPrelaxCreate(
62   	   SCIP_RELAX**          relax,              /**< pointer to relaxator data structure */
63   	   SCIP_SET*             set,                /**< global SCIP settings */
64   	   SCIP_MESSAGEHDLR*     messagehdlr,        /**< message handler */
65   	   BMS_BLKMEM*           blkmem,             /**< block memory for parameter settings */
66   	   const char*           name,               /**< name of relaxator */
67   	   const char*           desc,               /**< description of relaxator */
68   	   int                   priority,           /**< priority of the relaxator (negative: after LP, non-negative: before LP) */
69   	   int                   freq,               /**< frequency for calling relaxator */
70   	   SCIP_DECL_RELAXCOPY   ((*relaxcopy)),     /**< copy method of relaxator or NULL if you don't want to copy your plugin into sub-SCIPs */
71   	   SCIP_DECL_RELAXFREE   ((*relaxfree)),     /**< destructor of relaxator */
72   	   SCIP_DECL_RELAXINIT   ((*relaxinit)),     /**< initialize relaxator */
73   	   SCIP_DECL_RELAXEXIT   ((*relaxexit)),     /**< deinitialize relaxator */
74   	   SCIP_DECL_RELAXINITSOL((*relaxinitsol)),  /**< solving process initialization method of relaxator */
75   	   SCIP_DECL_RELAXEXITSOL((*relaxexitsol)),  /**< solving process deinitialization method of relaxator */
76   	   SCIP_DECL_RELAXEXEC   ((*relaxexec)),     /**< execution method of relaxator */
77   	   SCIP_RELAXDATA*       relaxdata           /**< relaxator data */
78   	   );
79   	
80   	/** calls destructor and frees memory of relaxator */
81   	SCIP_RETCODE SCIPrelaxFree(
82   	   SCIP_RELAX**          relax,              /**< pointer to relaxator data structure */
83   	   SCIP_SET*             set                 /**< global SCIP settings */
84   	   );
85   	
86   	/** initializes relaxator */
87   	SCIP_RETCODE SCIPrelaxInit(
88   	   SCIP_RELAX*           relax,              /**< relaxator */
89   	   SCIP_SET*             set                 /**< global SCIP settings */
90   	   );
91   	
92   	/** calls exit method of relaxator */
93   	SCIP_RETCODE SCIPrelaxExit(
94   	   SCIP_RELAX*           relax,              /**< relaxator */
95   	   SCIP_SET*             set                 /**< global SCIP settings */
96   	   );
97   	
98   	/** informs relaxator that the branch and bound process is being started */
99   	SCIP_RETCODE SCIPrelaxInitsol(
100  	   SCIP_RELAX*           relax,              /**< relaxator */
101  	   SCIP_SET*             set                 /**< global SCIP settings */
102  	   );
103  	
104  	/** informs relaxator that the branch and bound process data is being freed */
105  	SCIP_RETCODE SCIPrelaxExitsol(
106  	   SCIP_RELAX*           relax,              /**< relaxator */
107  	   SCIP_SET*             set                 /**< global SCIP settings */
108  	   );
109  	
110  	/** calls execution method of relaxator */
111  	SCIP_RETCODE SCIPrelaxExec(
112  	   SCIP_RELAX*           relax,              /**< relaxator */
113  	   SCIP_SET*             set,                /**< global SCIP settings */
114  	   SCIP_TREE*            tree,               /**< branch and bound tree */
115  	   SCIP_STAT*            stat,               /**< dynamic problem statistics */
116  	   int                   depth,              /**< depth of current node */
117  	   SCIP_Real*            lowerbound,         /**< pointer to lower bound computed by the relaxator */
118  	   SCIP_RESULT*          result              /**< pointer to store the result of the callback method */
119  	   );
120  	
121  	/** sets priority of relaxator */
122  	void SCIPrelaxSetPriority(
123  	   SCIP_RELAX*           relax,              /**< relaxator */
124  	   SCIP_SET*             set,                /**< global SCIP settings */
125  	   int                   priority            /**< new priority of the relaxator */
126  	   );
127  	
128  	/** set copy callback of relaxation handler */
129  	void SCIPrelaxSetCopy(
130  	   SCIP_RELAX*           relax,              /**< relaxation handler  */
131  	   SCIP_DECL_RELAXCOPY   ((*relaxcopy))      /**< copy method of relaxation handler */
132  	   );
133  	
134  	/** set destructor callback of relaxation handler */
135  	void SCIPrelaxSetFree(
136  	   SCIP_RELAX*           relax,              /**< relaxation handler  */
137  	   SCIP_DECL_RELAXFREE   ((*relaxfree))      /**< destructor of relaxation handler */
138  	   );
139  	
140  	/** set initialization callback of relaxation handler */
141  	void SCIPrelaxSetInit(
142  	   SCIP_RELAX*           relax,              /**< relaxation handler  */
143  	   SCIP_DECL_RELAXINIT   ((*relaxinit))      /**< initialize relaxation handler */
144  	   );
145  	
146  	/** set deinitialization callback of relaxation handler */
147  	void SCIPrelaxSetExit(
148  	   SCIP_RELAX*           relax,              /**< relaxation handler  */
149  	   SCIP_DECL_RELAXEXIT   ((*relaxexit))      /**< deinitialize relaxation handler */
150  	   );
151  	
152  	/** set solving process initialization callback of relaxation handler */
153  	void SCIPrelaxSetInitsol(
154  	   SCIP_RELAX*           relax,              /**< relaxation handler  */
155  	   SCIP_DECL_RELAXINITSOL((*relaxinitsol))   /**< solving process initialization method of relaxation handler */
156  	   );
157  	
158  	/** set solving process deinitialization callback of relaxation handler */
159  	void SCIPrelaxSetExitsol(
160  	   SCIP_RELAX*           relax,              /**< relaxation handler  */
161  	   SCIP_DECL_RELAXEXITSOL((*relaxexitsol))   /**< solving process deinitialization callback relaxation handler */
162  	   );
163  	
164  	/** returns whether the relaxation was completely solved at the current node */
165  	SCIP_Bool SCIPrelaxIsSolved(
166  	   SCIP_RELAX*           relax,              /**< relaxator */
167  	   SCIP_STAT*            stat                /**< dynamic problem statistics */
168  	   );
169  	
170  	/*
171  	 *  methods for the global relaxation data
172  	 */
173  	
174  	/** enables or disables all clocks of \p relax, depending on the value of the flag */
175  	void SCIPrelaxEnableOrDisableClocks(
176  	   SCIP_RELAX*           relax,              /**< the relaxation handler for which all clocks should be enabled or disabled */
177  	   SCIP_Bool             enable              /**< should the clocks of the relaxation handler be enabled? */
178  	   );
179  	
180  	/** creates global relaxation data */
181  	SCIP_RETCODE SCIPrelaxationCreate(
182  	   SCIP_RELAXATION**     relaxation,         /**< global relaxation data */
183  	   BMS_BLKMEM*           blkmem,             /**< block memory */
184  	   SCIP_SET*             set,                /**< global SCIP settings */
185  	   SCIP_STAT*            stat,               /**< problem statistics data */
186  	   SCIP_PRIMAL*          primal,             /**< primal data */
187  	   SCIP_TREE*            tree                /**< branch and bound tree */
188  	   );
189  	
190  	/** frees global relaxation data */
191  	SCIP_RETCODE SCIPrelaxationFree(
192  	   SCIP_RELAXATION**     relaxation          /**< global relaxation data */
193  	   );
194  	
195  	/** sets the relaxsolzero flag in the relaxation data to the given value */
196  	void SCIPrelaxationSetSolZero(
197  	   SCIP_RELAXATION*      relaxation,         /**< global relaxation data */
198  	   SCIP_Bool             iszero              /**< are all values of the relaxation solution set to zero? */
199  	   );
200  	
201  	/** returns whether the global relaxation solution is cleared and all values are set to zero */
202  	SCIP_Bool SCIPrelaxationIsSolZero(
203  	   SCIP_RELAXATION*      relaxation          /**< global relaxation data */
204  	   );
205  	
206  	/** sets the relaxsolvalid and includeslp flags in the relaxation data to the given values */
207  	void SCIPrelaxationSetSolValid(
208  	   SCIP_RELAXATION*      relaxation,         /**< global relaxation data */
209  	   SCIP_Bool             isvalid,            /**< is the stored solution valid? */
210  	   SCIP_Bool             includeslp          /**< does the relaxator contain all cuts in the LP? */
211  	   );
212  	
213  	/** returns whether the global relaxation solution is valid */
214  	SCIP_Bool SCIPrelaxationIsSolValid(
215  	   SCIP_RELAXATION*      relaxation          /**< global relaxation data */
216  	   );
217  	
218  	/** returns whether the global relaxation solution was computed by a relaxator which included all LP cuts */
219  	SCIP_Bool SCIPrelaxationIsLpIncludedForSol(
220  	   SCIP_RELAXATION*      relaxation          /**< global relaxation data */
221  	   );
222  	
223  	/** sets the objective value of the global relaxation solution */
224  	void SCIPrelaxationSetSolObj(
225  	   SCIP_RELAXATION*      relaxation,         /**< global relaxation data */
226  	   SCIP_Real             obj                 /**< objective value */
227  	   );
228  	
229  	/** returns the objective value of the global relaxation solution w.r.t. the transformed problem */
230  	SCIP_Real SCIPrelaxationGetSolObj(
231  	   SCIP_RELAXATION*      relaxation          /**< global relaxation data */
232  	   );
233  	
234  	/** adds the given value to the global relaxation solution's objective value */
235  	void SCIPrelaxationSolObjAdd(
236  	   SCIP_RELAXATION*      relaxation,         /**< global relaxation data */
237  	   SCIP_Real             val                 /**< value to add to the objective value */
238  	   );
239  	
240  	/** updates objective value of current relaxation solution after change of objective coefficient */
241  	void SCIPrelaxationUpdateVarObj(
242  	   SCIP_RELAXATION*      relaxation,         /**< global relaxation data */
243  	   SCIP_SET*             set,                /**< global SCIP settings */
244  	   SCIP_VAR*             var,                /**< variable with changed objective coefficient */
245  	   SCIP_Real             oldobj,             /**< old objective coefficient */
246  	   SCIP_Real             newobj              /**< new objective coefficient */
247  	   );
248  	
249  	/** store the most recent relaxation handler \p relax responsible for the solution */
250  	void SCIPrelaxationSetSolRelax(
251  	   SCIP_RELAXATION*      relaxation,         /**< global relaxation data */
252  	   SCIP_RELAX*           relax               /**< relaxation handler responsible for the most recent relaxation solution */
253  	   );
254  	
255  	/** returns the most recent relaxation handler responsible for the solution, or NULL if unspecified */
256  	SCIP_RELAX* SCIPrelaxationGetSolRelax(
257  	   SCIP_RELAXATION*      relaxation          /**< global relaxation data */
258  	   );
259  	
260  	#ifdef __cplusplus
261  	}
262  	#endif
263  	
264  	#endif
265