1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /*                                                                           */
3 /*                  This file is part of the program and library             */
4 /*         SCIP --- Solving Constraint Integer Programs                      */
5 /*                                                                           */
6 /*    Copyright (C) 2002-2021 Konrad-Zuse-Zentrum                            */
7 /*                            fuer Informationstechnik Berlin                */
8 /*                                                                           */
9 /*  SCIP is distributed under the terms of the ZIB Academic License.         */
10 /*                                                                           */
11 /*  You should have received a copy of the ZIB Academic License              */
12 /*  along with SCIP; see the file COPYING. If not visit scipopt.org.         */
13 /*                                                                           */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file   pub_reopt.h
17  * @ingroup PUBLICCOREAPI
18  * @brief  public methods for reoptimization
19  * @author Jakob Witzig
20  */
21 
22 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
23 
24 #ifndef __SCIP_PUB_REOPT_H__
25 #define __SCIP_PUB_REOPT_H__
26 
27 #include "scip/def.h"
28 #include "scip/type_lp.h"
29 #include "scip/type_reopt.h"
30 #include "scip/type_var.h"
31 
32 #ifdef NDEBUG
33 #include "scip/struct_reopt.h"
34 #endif
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 /*
41  * ReoptNode methods
42  */
43 
44 /** returns the number of bound changes stored in the reoptnode */
45 SCIP_EXPORT
46 int SCIPreoptnodeGetNVars(
47    SCIP_REOPTNODE*       reoptnode           /**< node of the reoptimization tree */
48    );
49 
50 /** returns the number of bound changes at the node stored at ID id */
51 SCIP_EXPORT
52 int SCIPreoptnodeGetNConss(
53    SCIP_REOPTNODE*       reoptnode           /**< node of the reoptimization tree */
54    );
55 
56 /** returns the number of stored bound changes based on dual information in the reopttree at ID id */
57 SCIP_EXPORT
58 int SCIPreoptnodeGetNDualBoundChgs(
59    SCIP_REOPTNODE*       reoptnode           /**< node of the reoptimization tree */
60    );
61 
62 /** returns the number of child nodes of @p reoptnode */
63 SCIP_EXPORT
64 int SCIPreoptnodeGetNChildren(
65    SCIP_REOPTNODE*       reoptnode           /**< node of the reoptimizzation tree */
66    );
67 
68 /* return the lower bound stored at @p ID id */
69 SCIP_EXPORT
70 SCIP_Real SCIPreoptnodeGetLowerbound(
71    SCIP_REOPTNODE*       reoptnode           /**< node of the reoptimization tree */
72    );
73 
74 /** returns the type of the @p reoptnode */
75 SCIP_EXPORT
76 SCIP_REOPTTYPE SCIPreoptnodeGetType(
77    SCIP_REOPTNODE*       reoptnode           /**< node of the reoptimization tree */
78    );
79 
80 /** create the constraint which splits the node stored at ID id on the basis of the stored dual information. */
81 SCIP_EXPORT
82 void SCIPreoptnodeGetSplitCons(
83    SCIP_REOPTNODE*       reoptnode,          /**< node of the reoptimization tree */
84    SCIP_VAR**            vars,               /**< array to store the variables of the constraint */
85    SCIP_Real*            vals,               /**< array to store the coefficients of the variables */
86    REOPT_CONSTYPE*       constype,           /**< type of the constraint */
87    int                   conssize,           /**< size of the arrays */
88    int*                  nvars               /**< pointer to store the size of the constraints */
89    );
90 
91 /** returns all added constraints at ID id */
92 SCIP_EXPORT
93 void SCIPreoptnodeGetConss(
94    SCIP_REOPTNODE*       reoptnode,          /**< reoptimization data structure */
95    SCIP_VAR***           vars,               /**< 2-dim array of variables */
96    SCIP_Real**           bounds,             /**< 2-dim array of bounds */
97    SCIP_BOUNDTYPE**      boundtypes,         /**< 2-dim array of boundtypes */
98    int                   mem,                /**< allocated memory for constraints */
99    int*                  nconss,             /**< pointer to store the number of constraints */
100    int*                  nvars               /**< pointer to store the number of variables */
101    );
102 
103 /** set the parent id */
104 SCIP_EXPORT
105 void SCIPreoptnodeSetParentID(
106    SCIP_REOPTNODE*       reoptnode,          /**< node of the reopttree */
107    unsigned int          parentid            /**< id of the parent node */
108    );
109 
110 /*
111  * Reopt methods
112  */
113 
114 /** returns the number of global restarts */
115 SCIP_EXPORT
116 int SCIPreoptGetNRestartsGlobal(
117    SCIP_REOPT*           reopt               /**< reoptimization data */
118    );
119 
120 /** returns the number of local restarts in the current run */
121 int SCIPreoptGetNRestartsLocal(
122    SCIP_REOPT*           reopt               /**< reoptimization data structure */
123    );
124 
125 /** returns the number of local restarts over all runs */
126 int SCIPreoptGetNTotalRestartsLocal(
127    SCIP_REOPT*           reopt               /**< reoptimization data structure */
128    );
129 
130 /** returns the number of iteration with the first global restarts */
131 SCIP_EXPORT
132 int SCIPreoptGetFirstRestarts(
133    SCIP_REOPT*           reopt               /**< reoptimization data structure */
134    );
135 
136 /** returns the number of iteration with the last global restarts */
137 SCIP_EXPORT
138 int SCIPreoptGetLastRestarts(
139    SCIP_REOPT*           reopt               /**< reoptimization data structure */
140    );
141 
142 /** returns the number of nodes providing an improving feasible LP solution in the current run */
143 SCIP_EXPORT
144 int SCIPreoptGetNFeasNodes(
145    SCIP_REOPT*           reopt               /**< reoptimization data structure */
146    );
147 
148 /** returns the number of nodes providing an improving feasible LP solution over all runs */
149 SCIP_EXPORT
150 int SCIPreoptGetNTotalFeasNodes(
151    SCIP_REOPT*           reopt               /**< reoptimization data structure */
152    );
153 
154 /** returns the number of nodes that exceeded the cutoff bound in the current run */
155 SCIP_EXPORT
156 int SCIPreoptGetNPrunedNodes(
157    SCIP_REOPT*           reopt               /**< reoptimization data structure */
158    );
159 
160 /** returns the number of nodes that exceeded the cutoff bound over all runs */
161 SCIP_EXPORT
162 int SCIPreoptGetNTotalPrunedNodes(
163    SCIP_REOPT*           reopt               /**< reoptimization data structure */
164    );
165 
166 /** returns the number of reoptimized nodes that were cut off in the current run */
167 SCIP_EXPORT
168 int SCIPreoptGetNCutoffReoptnodes(
169    SCIP_REOPT*           reopt               /*< reoptimization data structure */
170    );
171 
172 /** returns the number of reoptimized nodes that were cut off over all runs */
173 SCIP_EXPORT
174 int SCIPreoptGetNTotalCutoffReoptnodes(
175    SCIP_REOPT*           reopt               /*< reoptimization data structure */
176    );
177 
178 /** returns the number of stored nodes with an infeasible LP in the current run */
179 SCIP_EXPORT
180 int SCIPreoptGetNInfNodes(
181    SCIP_REOPT*           reopt               /*< reoptimization data structure */
182    );
183 
184 /** returns the number of stored nodes with an infeasible LP over all runs */
185 SCIP_EXPORT
186 int SCIPreoptGetNTotalInfNodes(
187    SCIP_REOPT*           reopt               /*< reoptimization data structure */
188    );
189 
190 #ifdef NDEBUG
191 
192 /* In optimized mode, the function calls are overwritten by defines to reduce the number of function calls and
193  * speed up the algorithms.
194  */
195 
196 #define SCIPreoptnodeGetNVars(reoptnode)          (reoptnode->nvars)
197 #define SCIPreoptnodeGetNConss(reoptnode)         (reoptnode->nconss)
198 #define SCIPreoptnodeGetNDualBoundChgs(reoptnode) (reoptnode->dualconscur->nvars)
199 #define SCIPreoptnodeGetNChildren(reoptnode)      (reoptnode->nchilds)
200 #define SCIPreoptnodeGetLowerbound(reoptnode)     (reoptnode->lowerbound)
201 #define SCIPreoptnodeGetType(reoptnode)           (reoptnode->reopttype)
202 
203 #define SCIPreoptGetNRestartsGlobal(reopt)        (reopt->nglbrestarts)
204 #define SCIPreoptGetNRestartsLocal(reopt)         (reopt->nlocrestarts)
205 #define SCIPreoptGetNTotalRestartsLocal(reopt)    (reopt->ntotallocrestarts)
206 #define SCIPreoptGetFirstRestarts(reopt)          (reopt->firstrestart)
207 #define SCIPreoptGetLastRestarts(reopt)           (reopt->lastrestart)
208 #define SCIPreoptGetNFeasNodes(reopt)             (reopt->reopttree->nfeasnodes)
209 #define SCIPreoptGetNTotalFeasNodes(reopt)        (reopt->reopttree->ntotalfeasnodes)
210 #define SCIPreoptGetNPrunedNodes(reopt)           (reopt->reopttree->nprunednodes)
211 #define SCIPreoptGetNTotalPrunedNodes(reopt)      (reopt->reopttree->ntotalprunednodes)
212 #define SCIPreoptGetNCutoffReoptnodes(reopt)      (reopt->reopttree->ncutoffreoptnodes)
213 #define SCIPreoptGetNTotalCutoffReoptnodes(reopt) (reopt->reopttree->ntotalcutoffreoptnodes)
214 #define SCIPreoptGetNInfNodes(reopt)              (reopt->reopttree->ninfsubtrees)
215 #define SCIPreoptGetNTotalInfNodes(reopt)         (reopt->reopttree->ntotalinfnodes)
216 
217 #endif
218 
219 #ifdef __cplusplus
220 }
221 #endif
222 
223 #endif
224