Scippy

GCG

Branch-and-Price & Column Generation for Everyone

relax_gcg.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program */
4 /* GCG --- Generic Column Generation */
5 /* a Dantzig-Wolfe decomposition based extension */
6 /* of the branch-cut-and-price framework */
7 /* SCIP --- Solving Constraint Integer Programs */
8 /* */
9 /* Copyright (C) 2010-2021 Operations Research, RWTH Aachen University */
10 /* Zuse Institute Berlin (ZIB) */
11 /* */
12 /* This program is free software; you can redistribute it and/or */
13 /* modify it under the terms of the GNU Lesser General Public License */
14 /* as published by the Free Software Foundation; either version 3 */
15 /* of the License, or (at your option) any later version. */
16 /* */
17 /* This program is distributed in the hope that it will be useful, */
18 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
19 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
20 /* GNU Lesser General Public License for more details. */
21 /* */
22 /* You should have received a copy of the GNU Lesser General Public License */
23 /* along with this program; if not, write to the Free Software */
24 /* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/
25 /* */
26 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
27 
28 /**@file relax_gcg.h
29  * @brief GCG relaxator
30  * @author Gerald Gamrath
31  * @author Christian Puchert
32  * @author Martin Bergner
33  * @author Oliver Gaul
34  */
35 
36 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
37 
38 #ifndef GCG_RELAX_GCG_H__
39 #define GCG_RELAX_GCG_H__
40 
41 #include "scip/scip.h"
42 #include "type_branchgcg.h"
43 #include "type_decomp.h"
44 #include "type_parameter.h"
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
50 /**
51  * @ingroup RELAXATORS
52  * @{
53  */
54 
55 /** creates the GCG relaxator and includes it in SCIP */
56 extern
57 SCIP_RETCODE SCIPincludeRelaxGcg(
58  SCIP* scip /**< SCIP data structure */
59  );
60 
61 /** includes a branching rule into the relaxator data */
62 extern
63 SCIP_RETCODE GCGrelaxIncludeBranchrule(
64  SCIP* scip, /**< SCIP data structure */
65  SCIP_BRANCHRULE* branchrule, /**< branching rule for which callback methods are saved */
66  GCG_DECL_BRANCHACTIVEMASTER((*branchactivemaster)),/**< activation method for branchrule */
67  GCG_DECL_BRANCHDEACTIVEMASTER ((*branchdeactivemaster)),/**< deactivation method for branchrule */
68  GCG_DECL_BRANCHPROPMASTER((*branchpropmaster)),/**< propagation method for branchrule */
69  GCG_DECL_BRANCHMASTERSOLVED((*branchmastersolved)),/**< master solved method for branchrule */
70  GCG_DECL_BRANCHDATADELETE((*branchdatadelete))/**< branchdata deletion method for branchrule */
71  );
72 
73 /** perform activation method of the given branchrule for the given branchdata */
74 extern
75 SCIP_RETCODE GCGrelaxBranchActiveMaster(
76  SCIP* scip, /**< SCIP data structure */
77  SCIP_BRANCHRULE* branchrule, /**< branching rule that did the branching */
78  GCG_BRANCHDATA* branchdata /**< data representing the branching decision */
79  );
80 
81 /** perform deactivation method of the given branchrule for the given branchdata */
82 extern
83 SCIP_RETCODE GCGrelaxBranchDeactiveMaster(
84  SCIP* scip, /**< SCIP data structure */
85  SCIP_BRANCHRULE* branchrule, /**< branching rule that did the branching */
86  GCG_BRANCHDATA* branchdata /**< data representing the branching decision */
87  );
88 
89 /** perform propagation method of the given branchrule for the given branchdata */
90 extern
91 SCIP_RETCODE GCGrelaxBranchPropMaster(
92  SCIP* scip, /**< SCIP data structure */
93  SCIP_BRANCHRULE* branchrule, /**< branching rule that did the branching */
94  GCG_BRANCHDATA* branchdata, /**< data representing the branching decision */
95  SCIP_RESULT* result /**< pointer to store the result of the propagation call */
96  );
97 
98 /** perform method of the given branchrule that is called after the master LP is solved */
99 extern
100 SCIP_RETCODE GCGrelaxBranchMasterSolved(
101  SCIP* scip, /**< SCIP data structure */
102  SCIP_BRANCHRULE* branchrule, /**< branching rule that did the branching */
103  GCG_BRANCHDATA* branchdata, /**< data representing the branching decision */
104  SCIP_Real newlowerbound /**< the new local lowerbound */
105  );
106 
107 /** frees branching data created by the given branchrule */
108 extern
109 SCIP_RETCODE GCGrelaxBranchDataDelete(
110  SCIP* scip, /**< SCIP data structure */
111  SCIP_BRANCHRULE* branchrule, /**< branching rule that did the branching */
112  GCG_BRANCHDATA** branchdata /**< data representing the branching decision */
113  );
114 
115 /** transformes a constraint of the original problem into the master variable space and
116  * adds it to the master problem */
117 extern
118 SCIP_RETCODE GCGrelaxTransOrigToMasterCons(
119  SCIP* scip, /**< SCIP data structure */
120  SCIP_CONS* cons, /**< the constraint that should be transformed */
121  SCIP_CONS** transcons /**< pointer to the transformed constraint */
122  );
123 
124 /** returns the current solution for the original problem */
125 extern
126 SCIP_SOL* GCGrelaxGetCurrentOrigSol(
127  SCIP* scip /**< SCIP data structure */
128  );
129 
130 /** returns whether the current solution is primal feasible in the original problem */
131 extern
132 SCIP_Bool GCGrelaxIsOrigSolFeasible(
133  SCIP* scip /**< SCIP data structure */
134  );
135 
136 /** start probing mode on both the original and master problems
137  *
138  * @note This mode is intended for working on the original variables but using the master LP;
139  * it currently only supports bound changes on the original variables,
140  * but no additional rows
141  */
142 extern
143 SCIP_RETCODE GCGrelaxStartProbing(
144  SCIP* scip, /**< SCIP data structure */
145  SCIP_HEUR* probingheur /**< heuristic that started probing mode, or NULL */
146  );
147 
148 /** returns the heuristic that started probing in the master problem, or NULL */
149 extern
150 SCIP_HEUR* GCGrelaxGetProbingheur(
151  SCIP* scip /**< SCIP data structure */
152  );
153 
154 /** add a new probing node the original problem together with an original branching constraint
155  *
156  * @note A corresponding probing node must be added to the master problem right before solving the probing LP
157  */
158 extern
159 SCIP_RETCODE GCGrelaxNewProbingnodeOrig(
160  SCIP* scip /**< SCIP data structure */
161  );
162 
163 /** add a new probing node the master problem together with a master branching constraint
164  * which ensures that bound changes are transferred to master and pricing problems
165  *
166  * @note A corresponding probing node must have been added to the original problem beforehand;
167  * furthermore, this method must be called after bound changes to the original problem have been made
168  */
169 extern
170 SCIP_RETCODE GCGrelaxNewProbingnodeMaster(
171  SCIP* scip /**< SCIP data structure */
172  );
173 
174 /** add a new probing node the master problem together with a master branching constraint
175  * which ensures that bound changes are transferred to master and pricing problems as well as additional
176  * constraints
177  *
178  * @note A corresponding probing node must have been added to the original problem beforehand;
179  * furthermore, this method must be called after bound changes to the original problem have been made
180  */
181 extern
183  SCIP* scip, /**< SCIP data structure */
184  SCIP_BRANCHRULE* branchrule, /**< pointer to the branching rule */
185  GCG_BRANCHDATA* branchdata, /**< branching data */
186  SCIP_CONS** origbranchconss, /**< original constraints enforcing the branching decision */
187  int norigbranchconss, /**< number of original constraints */
188  int maxorigbranchconss /**< capacity of origbranchconss */
189  );
190 
191 /** add probing nodes to both the original and master problem;
192  * furthermore, add origbranch and masterbranch constraints to transfer branching decisions
193  * from the original to the master problem
194  */
195 extern
196 SCIP_RETCODE GCGrelaxBacktrackProbing(
197  SCIP* scip, /**< SCIP data structure */
198  int probingdepth /**< probing depth of the node in the probing path that should be reactivated */
199  );
200 
201 /** solve the master probing LP without pricing */
202 extern
203 SCIP_RETCODE GCGrelaxPerformProbing(
204  SCIP* scip, /**< SCIP data structure */
205  int maxlpiterations, /**< maximum number of lp iterations allowed */
206  SCIP_Longint* nlpiterations, /**< pointer to store the number of performed LP iterations (or NULL) */
207  SCIP_Real* lpobjvalue, /**< pointer to store the lp obj value if lp was solved */
208  SCIP_Bool* lpsolved, /**< pointer to store whether the lp was solved */
209  SCIP_Bool* lperror, /**< pointer to store whether an unresolved LP error occured or the
210  * solving process should be stopped (e.g., due to a time limit) */
211  SCIP_Bool* cutoff /**< pointer to store whether the probing direction is infeasible */
212  );
213 
214 /** solve the master probing LP with pricing */
215 extern
217  SCIP* scip, /**< SCIP data structure */
218  int maxpricerounds, /**< maximum number of pricing rounds allowed */
219  SCIP_Longint* nlpiterations, /**< pointer to store the number of performed LP iterations (or NULL) */
220  int* npricerounds, /**< pointer to store the number of performed pricing rounds (or NULL) */
221  SCIP_Real* lpobjvalue, /**< pointer to store the lp obj value if lp was solved */
222  SCIP_Bool* lpsolved, /**< pointer to store whether the lp was solved */
223  SCIP_Bool* lperror, /**< pointer to store whether an unresolved LP error occured or the
224  * solving process should be stopped (e.g., due to a time limit) */
225  SCIP_Bool* cutoff /**< pointer to store whether the probing direction is infeasible */
226  );
227 
228 /** end probing mode in both the original and master problems */
229 extern
230 SCIP_RETCODE GCGrelaxEndProbing(
231  SCIP* scip /**< SCIP data structure */
232  );
233 
234 /** transforms the current solution of the master problem into the original problem's space
235  * and saves this solution as currentsol in the relaxator's data */
236 extern
237 SCIP_RETCODE GCGrelaxUpdateCurrentSol(
238  SCIP* scip /**< SCIP data structure */
239  );
240 
241 /** returns the decomposition mode */
242 extern
244  SCIP* scip /**< SCIP data structure */
245  );
246 
247 /** returns the decomposition mode of the master problem. The mode is given by the existence of either the GCG pricer or
248  * the GCG Benders' decomposition plugins.
249  */
250 extern
252  SCIP* masterprob /**< the master problem SCIP instance */
253  );
254 
255 /** gets the structure information */
256 extern
258  SCIP* scip /**< SCIP data structure */
259  );
260 
261 /** returns the visualization parameters */
262 extern
264  SCIP* scip /**< SCIP data structure */
265  );
266 
267 
268 /** return root node clock */
269 extern
270 SCIP_CLOCK* GCGgetRootNodeTime(
271  SCIP* scip /**< SCIP data structure */
272  );
273 
274 
275 /** initializes solving data structures and transforms problem for solving with GCG
276  *
277  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
278  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
279  *
280  * @pre This method can be called if @p scip is in one of the following stages:
281  * - \ref SCIP_STAGE_PROBLEM
282  * - \ref SCIP_STAGE_TRANSFORMED
283  * - \ref SCIP_STAGE_INITPRESOLVE
284  * - \ref SCIP_STAGE_PRESOLVING
285  * - \ref SCIP_STAGE_EXITPRESOLVE
286  * - \ref SCIP_STAGE_PRESOLVED
287  * - \ref SCIP_STAGE_INITSOLVE
288  * - \ref SCIP_STAGE_SOLVING
289  * - \ref SCIP_STAGE_SOLVED
290  * - \ref SCIP_STAGE_EXITSOLVE
291  * - \ref SCIP_STAGE_FREETRANS
292  * - \ref SCIP_STAGE_FREE
293  *
294  * @post When calling this method in the \ref SCIP_STAGE_PROBLEM stage, the \SCIP stage is changed to \ref
295  * SCIP_STAGE_TRANSFORMED; otherwise, the stage is not changed
296  *
297  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
298  */
299 SCIP_RETCODE GCGtransformProb(
300  SCIP* scip /**< SCIP data structure */
301  );
302 
303 /** transforms and presolves the problem suitable for GCG
304  *
305  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
306  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
307  *
308  * @pre This method can be called if @p scip is in one of the following stages:
309  * - \ref SCIP_STAGE_PROBLEM
310  * - \ref SCIP_STAGE_TRANSFORMED
311  * - \ref SCIP_STAGE_PRESOLVING
312  * - \ref SCIP_STAGE_PRESOLVED
313  *
314  * @post After calling this method \SCIP reaches one of the following stages:
315  * - \ref SCIP_STAGE_PRESOLVING if the presolving process was interrupted
316  * - \ref SCIP_STAGE_PRESOLVED if the presolving process was finished and did not solve the problem
317  * - \ref SCIP_STAGE_SOLVED if the problem was solved during presolving
318  *
319  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
320  */
321 SCIP_RETCODE GCGpresolve(
322  SCIP* scip /**< SCIP data structure */
323  );
324 
325 /** transforms and detects the problem
326  *
327  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
328  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
329  *
330  * @pre This method can be called if @p scip is in one of the following stages:
331  * - \ref SCIP_STAGE_PROBLEM
332  * - \ref SCIP_STAGE_TRANSFORMED
333  * - \ref SCIP_STAGE_PRESOLVING
334  * - \ref SCIP_STAGE_PRESOLVED
335  *
336  * @post When calling this method in the \ref SCIP_STAGE_PROBLEM stage, the \SCIP stage is changed to \ref
337  * SCIP_STAGE_TRANSFORMED; otherwise, the stage is not changed
338  *
339  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
340  */
341 SCIP_RETCODE GCGdetect(
342  SCIP* scip /**< SCIP data structure */
343  );
344 
345 /** transforms, resolves, detects, and solves the problem using GCG
346  *
347  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
348  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
349  *
350  * @pre This method can be called if @p scip is in one of the following stages:
351  * - \ref SCIP_STAGE_PROBLEM
352  * - \ref SCIP_STAGE_TRANSFORMED
353  * - \ref SCIP_STAGE_PRESOLVING
354  * - \ref SCIP_STAGE_PRESOLVED
355  * - \ref SCIP_STAGE_SOLVING
356  * - \ref SCIP_STAGE_SOLVED
357  *
358  * @post After calling this method \SCIP reaches one of the following stages depending on if and when the solution
359  * process was interrupted:
360  * - \ref SCIP_STAGE_PRESOLVING if the solution process was interrupted during presolving
361  * - \ref SCIP_STAGE_SOLVING if the solution process was interrupted during the tree search
362  * - \ref SCIP_STAGE_SOLVED if the solving process was not interrupted
363  *
364  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
365  */
366 SCIP_RETCODE GCGsolve(
367  SCIP* scip /**< SCIP data structure */
368  );
369 
370 /** @} */
371 
372 /** gets GCG's global dual bound
373  *
374  * Computes the global dual bound while considering the original
375  * problem SCIP instance and the master problem SCIP instance.
376  *
377  * @return the global dual bound
378  */
379 SCIP_Real GCGgetDualbound(
380  SCIP* scip /**< SCIP data structure */
381  );
382 
383 /** gets GCG's global primal bound
384  *
385  * Computes the global primal bound while considering the original
386  * problem SCIP instance and the master problem SCIP instance.
387  *
388  * @return the global dual bound
389  */
390 SCIP_Real GCGgetPrimalbound(
391  SCIP* scip /**< SCIP data structure */
392  );
393 
394 /** gets GCG's global gap
395  *
396  * Computes the global gap based on the gloal dual bound and the
397  * global primal bound.
398  *
399  * @return the global dual bound
400  *
401  * @see GCGgetDualbound()
402  * @see GCGgetPrimalbound()
403  */
404 SCIP_Real GCGgetGap(
405  SCIP* scip /**< SCIP data structure */
406  );
407 
408 #ifdef __cplusplus
409 }
410 
411 #endif
412 
413 #endif
type definitions for branching rules in GCG projects
SCIP_Real GCGgetGap(SCIP *scip)
Definition: relax_gcg.c:5501
#define GCG_DECL_BRANCHPROPMASTER(x)
SCIP_RETCODE GCGrelaxBranchMasterSolved(SCIP *scip, SCIP_BRANCHRULE *branchrule, GCG_BRANCHDATA *branchdata, SCIP_Real newlowerbound)
Definition: relax_gcg.c:3749
SCIP_RETCODE GCGrelaxBacktrackProbing(SCIP *scip, int probingdepth)
Definition: relax_gcg.c:4484
SCIP_RETCODE GCGrelaxPerformProbingWithPricing(SCIP *scip, int maxpricerounds, SCIP_Longint *nlpiterations, int *npricerounds, SCIP_Real *lpobjvalue, SCIP_Bool *lpsolved, SCIP_Bool *lperror, SCIP_Bool *cutoff)
Definition: relax_gcg.c:4639
SCIP_RETCODE GCGtransformProb(SCIP *scip)
Definition: relax_gcg.c:5199
SCIP_RETCODE GCGrelaxBranchActiveMaster(SCIP *scip, SCIP_BRANCHRULE *branchrule, GCG_BRANCHDATA *branchdata)
Definition: relax_gcg.c:3586
SCIP_RETCODE GCGsolve(SCIP *scip)
Definition: relax_gcg.c:5341
SCIP_Bool GCGrelaxIsOrigSolFeasible(SCIP *scip)
Definition: relax_gcg.c:4202
#define GCG_DECL_BRANCHDATADELETE(x)
SCIP_RETCODE GCGdetect(SCIP *scip)
Definition: relax_gcg.c:5283
GCG_PARAMDATA * GCGgetParamsVisu(SCIP *scip)
Definition: relax_gcg.c:4159
#define GCG_DECL_BRANCHDEACTIVEMASTER(x)
DEC_DECOMP * GCGgetStructDecomp(SCIP *scip)
Definition: relax_gcg.c:2397
SCIP_RETCODE GCGpresolve(SCIP *scip)
Definition: relax_gcg.c:5237
SCIP_RETCODE GCGrelaxStartProbing(SCIP *scip, SCIP_HEUR *probingheur)
Definition: relax_gcg.c:4264
SCIP_RETCODE GCGrelaxBranchPropMaster(SCIP *scip, SCIP_BRANCHRULE *branchrule, GCG_BRANCHDATA *branchdata, SCIP_RESULT *result)
Definition: relax_gcg.c:3662
SCIP_RETCODE GCGrelaxNewProbingnodeMaster(SCIP *scip)
Definition: relax_gcg.c:4378
SCIP_RETCODE GCGrelaxNewProbingnodeOrig(SCIP *scip)
Definition: relax_gcg.c:4331
SCIP_RETCODE GCGrelaxUpdateCurrentSol(SCIP *scip)
Definition: relax_gcg.c:4796
type definitions for parameters in GCG project
SCIP_Real GCGgetDualbound(SCIP *scip)
Definition: relax_gcg.c:5445
SCIP_RETCODE GCGrelaxEndProbing(SCIP *scip)
Definition: relax_gcg.c:4658
SCIP_RETCODE GCGrelaxTransOrigToMasterCons(SCIP *scip, SCIP_CONS *cons, SCIP_CONS **transcons)
Definition: relax_gcg.c:3789
SCIP_RETCODE GCGrelaxBranchDeactiveMaster(SCIP *scip, SCIP_BRANCHRULE *branchrule, GCG_BRANCHDATA *branchdata)
Definition: relax_gcg.c:3624
#define GCG_DECL_BRANCHMASTERSOLVED(x)
enum Decmode DEC_DECMODE
Definition: type_decomp.h:68
SCIP_RETCODE SCIPincludeRelaxGcg(SCIP *scip)
Definition: relax_gcg.c:3422
DEC_DECMODE GCGgetDecompositionMode(SCIP *scip)
Definition: relax_gcg.c:5123
SCIP_CLOCK * GCGgetRootNodeTime(SCIP *scip)
Definition: relax_gcg.c:5181
SCIP_RETCODE GCGrelaxBranchDataDelete(SCIP *scip, SCIP_BRANCHRULE *branchrule, GCG_BRANCHDATA **branchdata)
Definition: relax_gcg.c:3704
DEC_DECMODE GCGgetMasterDecompMode(SCIP *masterprob)
Definition: relax_gcg.c:5144
SCIP_RETCODE GCGrelaxNewProbingnodeMasterCons(SCIP *scip, SCIP_BRANCHRULE *branchrule, GCG_BRANCHDATA *branchdata, SCIP_CONS **origbranchconss, int norigbranchconss, int maxorigbranchconss)
Definition: relax_gcg.c:4430
SCIP_SOL * GCGrelaxGetCurrentOrigSol(SCIP *scip)
Definition: relax_gcg.c:4183
SCIP_RETCODE GCGrelaxIncludeBranchrule(SCIP *scip, SCIP_BRANCHRULE *branchrule, GCG_DECL_BRANCHACTIVEMASTER((*branchactivemaster)), GCG_DECL_BRANCHDEACTIVEMASTER((*branchdeactivemaster)), GCG_DECL_BRANCHPROPMASTER((*branchpropmaster)), GCG_DECL_BRANCHMASTERSOLVED((*branchmastersolved)), GCG_DECL_BRANCHDATADELETE((*branchdatadelete)))
Definition: relax_gcg.c:3545
SCIP_HEUR * GCGrelaxGetProbingheur(SCIP *scip)
Definition: relax_gcg.c:4309
SCIP_Real GCGgetPrimalbound(SCIP *scip)
Definition: relax_gcg.c:5473
#define GCG_DECL_BRANCHACTIVEMASTER(x)
SCIP_RETCODE GCGrelaxPerformProbing(SCIP *scip, int maxlpiterations, SCIP_Longint *nlpiterations, SCIP_Real *lpobjvalue, SCIP_Bool *lpsolved, SCIP_Bool *lperror, SCIP_Bool *cutoff)
Definition: relax_gcg.c:4620
type definitions for decomposition information in GCG projects