GCG 4.1.1 (dev)

Generic Column Generation

Loading...
Searching...
No Matches
pub_gcg.h
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2/* */
3/* This file is part of the program and library */
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-2026 Operations Research, RWTH Aachen University */
10/* Zuse Institute Berlin (ZIB) */
11/* */
12/* Licensed under the Apache License, Version 2.0 (the "License"); */
13/* you may not use this file except in compliance with the License. */
14/* You may obtain a copy of the License at */
15/* */
16/* http://www.apache.org/licenses/LICENSE-2.0 */
17/* */
18/* Unless required by applicable law or agreed to in writing, software */
19/* distributed under the License is distributed on an "AS IS" BASIS, */
20/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
21/* See the License for the specific language governing permissions and */
22/* limitations under the License. */
23/* */
24/* You should have received a copy of the Apache-2.0 license */
25/* along with GCG; see the file LICENSE. If not visit gcg.or.rwth-aachen.de.*/
26/* */
27/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
28
29/**@file pub_gcg.h
30 * @ingroup PUBLICCOREAPI
31 * @brief public methods for working with gcg structure
32 * @author Erik Muehmer
33 */
34
35/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
36#ifndef GCG_PUB_GCG_H__
37#define GCG_PUB_GCG_H__
38
39#include "scip/def.h"
40#include "scip/type_scip.h"
41#include "scip/type_retcode.h"
42#include "gcg/def.h"
43#include "gcg/type_gcg.h"
44
45
46#ifdef NDEBUG
47#include "gcg/struct_gcg.h"
48#endif
49
50#ifdef __cplusplus
51extern "C" {
52#endif
53
54/*
55 * GCG structure
56 */
57
58/**@defgroup GCG GCG Struct
59 * @ingroup DATASTRUCTURES
60 * @{
61 */
62
63/** create a gcg struct */
66 GCG** gcg /**< pointer to store GCG data structure */
67 );
68
69/** free a gcg column */
72 GCG** gcgcol /**< pointer to gcg structure */
73 );
74
75/** checks whether the scip is the original scip instance
76 * @returns whether the scip is the original scip instance */
79 SCIP* scip /**< SCIP data structure */
80 );
81
82/** checks whether the scip is the master problem scip
83 * @returns whether the scip is the master problem scip */
86 SCIP* scip /**< SCIP data structure */
87 );
88
89/** print out GCG statistics
90 * @returns SCIP return code */
93 GCG* gcg, /**< GCG data structure */
94 FILE* file /**< output file or NULL for standard output */
95 );
96
97/** print out complete detection statistics
98 * @returns SCIP return code */
101 GCG* gcg, /**< GCG data structure */
102 FILE* file /**< output file or NULL for standard output */
103 );
104
105/** print name of current instance to given output
106 * @returns SCIP return code */
109 GCG* gcg, /**< GCG data structure */
110 FILE* file /**< output file or NULL for standard output */
111 );
112
115 GCG* gcg, /**< GCG data structure */
116 FILE* file /**< output file or NULL for standard output */
117 );
118
121 GCG* gcg, /**< GCG data structure */
122 FILE* file /**< output file or NULL for standard output */
123 );
124
127 GCG* gcg, /**< GCG data structure */
128 FILE* file /**< output file or NULL for standard output */
129 );
130
133 GCG* gcg, /**< GCG data structure */
134 FILE* file /**< output file or NULL for standard output */
135 );
136
137/** gets the total memory used after problem creation stage for all pricingproblems */
140 GCG* gcg /**< GCG data structure */
141 );
142
143/** returns the average degeneracy */
146 GCG* gcg /**< GCG data structure */
147 );
148
149/** transforms given values of the given original variables into values of the given master variables
150 * @returns the sum of the values of the corresponding master variables that are fixed */
153 GCG* gcg, /**< GCG data structure */
154 SCIP_VAR** origvars, /**< array with (subset of the) original variables */
155 SCIP_Real* origvals, /**< array with values for the given original variables */
156 int norigvars, /**< number of given original variables */
157 SCIP_VAR** mastervars, /**< array of (all present) master variables */
158 SCIP_Real* mastervals, /**< array to store the values of the master variables */
159 int nmastervars /**< number of master variables */
160 );
161
162/** transforms given solution of the master problem into solution of the original problem
163 * @returns SCIP return code */
166 GCG* gcg, /**< GCG data structure */
167 SCIP_SOL* mastersol, /**< solution of the master problem */
168 SCIP_SOL** origsol, /**< pointer to store the new created original problem's solution */
169 SCIP_Bool ignorelocalvarbnds, /**< check global or local varbounds */
170 SCIP_Bool* violatesvarbnds /**< pointer to variable to store whether the solution violates orig varbnds (can be NULL) */
171 );
172
173/** Checks whether the constraint belongs to GCG or not
174 * @returns whether the constraint belongs to GCG or not */
177 SCIP_CONS* cons /**< constraint to check */
178 );
179
180
181/** returns the pricing problem of the given number */
184 GCG* gcg, /**< GCG data structure */
185 int pricingprobnr /**< number of the pricing problem */
186 );
187
188/** returns the number of pricing problems */
191 GCG* gcg /**< GCG data structure */
192 );
193
194/** returns TRUE iff the pricingproblem of the given number is relevant, that means is not identical to
195 * another and represented by it */
198 GCG* gcg, /**< GCG data structure */
199 int pricingprobnr /**< number of the pricing problem */
200 );
201
202/**
203 * for a given block, return the block by which it is represented
204 */
207 GCG* gcg, /**< GCG data structure */
208 int pricingprobnr /**< number of the pricing problem */
209 );
210
211/** returns the number of relevant pricing problems */
214 GCG* gcg /**< GCG data structure */
215 );
216
217/** returns the number of blocks in the original formulation, that are represented by
218 * the pricingprob with the given number */
221 GCG* gcg, /**< GCG data structure */
222 int pricingprobnr /**< number of the pricing problem */
223 );
224
225/** returns the number of constraints in the master problem */
228 GCG* gcg /**< GCG data structure */
229 );
230
231/** returns the contraints in the master problem */
234 GCG* gcg /**< GCG data structure */
235 );
236
237/** returns the contraints in the original problem that correspond to the constraints in the master problem */
240 GCG* gcg /**< GCG data structure */
241 );
242
243/** returns the convexity constraint for the given block */
246 GCG* gcg, /**< GCG data structure */
247 int blocknr /**< the number of the block for which we
248 * need the convexity constraint */
249 );
250
251/** returns whether the master problem is a set covering problem */
254 GCG* gcg /**< GCG data structure */
255 );
256
257/** returns whether the master problem is a set partitioning problem */
260 GCG* gcg /**< GCG data structure */
261 );
262
263/** returns whether the relaxator has been initialized */
266 GCG* gcg /**< GCG data structure */
267 );
268
269/** return linking constraints for variables */
272 GCG* gcg /**< GCG data structure */
273 );
274
275/** return blocks of linking constraints for variables */
278 GCG* gcg /**< GCG data structure */
279 );
280
281/** return number of linking constraints for variables */
284 GCG* gcg /**< GCG data structure */
285 );
286
287/** return number of linking variables */
290 GCG* gcg /**< GCG data structure */
291 );
292
293/** return number of variables directly transferred to the master problem */
296 GCG* gcg /**< GCG data structure */
297 );
298
299/** returns the relaxation solution from the Benders' decomposition */
302 GCG* gcg /**< GCG data structure */
303 );
304
305#ifdef NDEBUG
306#define GCGgetOrigprob(gcg) (gcg->origprob)
307#else
308/** returns the original problem */
311 GCG* gcg /**< GCG data structure */
312 );
313#endif
314
315#ifdef NDEBUG
316#define GCGgetMasterprob(gcg) (gcg->masterprob)
317#else
318/** returns the active master problem (may change until solving is initiated) */
321 GCG* gcg /**< GCG data structure */
322 );
323#endif
324
325#ifdef NDEBUG
326#define GCGgetBendersMasterprob(gcg) (gcg->bendersmasterprob)
327#else
328/** returns the benders master problem (also used to solve the original problem directly) */
331 GCG* gcg /**< GCG data structure */
332 );
333#endif
334
335#ifdef NDEBUG
336#define GCGgetDwMasterprob(gcg) (gcg->dwmasterprob)
337#else
338/** returns the dw master problem */
341 GCG* gcg /**< GCG data structure */
342 );
343#endif
344
345/** returns the GCG data structure */
348 SCIP* masterprob /**< SCIP data structure */
349 );
350
351/** returns the GCG data structure */
354 SCIP* origprob /**< SCIP data structure */
355 );
356
357/** returns the decomposition mode */
360 GCG* gcg /**< GCG data structure */
361 );
362
363/** gets the structure information */
366 GCG* gcg /**< GCG data structure */
367 );
368
369/** returns the visualization parameters */
372 GCG* gcg /**< GCG data structure */
373 );
374
375
376/** return root node clock */
379 GCG* gcg /**< GCG data structure */
380 );
381
382
383/** initializes solving data structures and transforms problem for solving with GCG
384 *
385 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
386 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
387 *
388 * @pre This method can be called if @p scip is in one of the following stages:
389 * - \ref SCIP_STAGE_PROBLEM
390 * - \ref SCIP_STAGE_TRANSFORMED
391 * - \ref SCIP_STAGE_INITPRESOLVE
392 * - \ref SCIP_STAGE_PRESOLVING
393 * - \ref SCIP_STAGE_EXITPRESOLVE
394 * - \ref SCIP_STAGE_PRESOLVED
395 * - \ref SCIP_STAGE_INITSOLVE
396 * - \ref SCIP_STAGE_SOLVING
397 * - \ref SCIP_STAGE_SOLVED
398 * - \ref SCIP_STAGE_EXITSOLVE
399 * - \ref SCIP_STAGE_FREETRANS
400 * - \ref SCIP_STAGE_FREE
401 *
402 * @post When calling this method in the \ref SCIP_STAGE_PROBLEM stage, the \SCIP stage is changed to \ref
403 * SCIP_STAGE_TRANSFORMED; otherwise, the stage is not changed
404 *
405 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
406 */
409 GCG* gcg /**< GCG data structure */
410 );
411
412/** transforms and presolves the problem suitable for GCG
413 *
414 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
415 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
416 *
417 * @pre This method can be called if @p scip is in one of the following stages:
418 * - \ref SCIP_STAGE_PROBLEM
419 * - \ref SCIP_STAGE_TRANSFORMED
420 * - \ref SCIP_STAGE_PRESOLVING
421 * - \ref SCIP_STAGE_PRESOLVED
422 *
423 * @post After calling this method \SCIP reaches one of the following stages:
424 * - \ref SCIP_STAGE_PRESOLVING if the presolving process was interrupted
425 * - \ref SCIP_STAGE_PRESOLVED if the presolving process was finished and did not solve the problem
426 * - \ref SCIP_STAGE_SOLVED if the problem was solved during presolving
427 *
428 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
429 */
432 GCG* gcg /**< GCG data structure */
433 );
434
435/** transforms and detects the problem
436 *
437 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
438 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
439 *
440 * @pre This method can be called if @p scip is in one of the following stages:
441 * - \ref SCIP_STAGE_PROBLEM
442 * - \ref SCIP_STAGE_TRANSFORMED
443 * - \ref SCIP_STAGE_PRESOLVING
444 * - \ref SCIP_STAGE_PRESOLVED
445 *
446 * @post When calling this method in the \ref SCIP_STAGE_PROBLEM stage, the \SCIP stage is changed to \ref
447 * SCIP_STAGE_TRANSFORMED; otherwise, the stage is not changed
448 *
449 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
450 */
453 GCG* gcg /**< GCG data structure */
454 );
455
456/** transforms, resolves, detects, and solves the problem using GCG
457 *
458 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
459 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
460 *
461 * @pre This method can be called if @p scip is in one of the following stages:
462 * - \ref SCIP_STAGE_PROBLEM
463 * - \ref SCIP_STAGE_TRANSFORMED
464 * - \ref SCIP_STAGE_PRESOLVING
465 * - \ref SCIP_STAGE_PRESOLVED
466 * - \ref SCIP_STAGE_SOLVING
467 * - \ref SCIP_STAGE_SOLVED
468 *
469 * @post After calling this method \SCIP reaches one of the following stages depending on if and when the solution
470 * process was interrupted:
471 * - \ref SCIP_STAGE_PRESOLVING if the solution process was interrupted during presolving
472 * - \ref SCIP_STAGE_SOLVING if the solution process was interrupted during the tree search
473 * - \ref SCIP_STAGE_SOLVED if the solving process was not interrupted
474 *
475 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
476 */
479 GCG* gcg /**< GCG data structure */
480 );
481
482/** @} */
483
484/** gets GCG's global dual bound
485 *
486 * Computes the global dual bound while considering the original
487 * problem SCIP instance and the master problem SCIP instance.
488 *
489 * @return the global dual bound
490 */
493 GCG* gcg /**< GCG data structure */
494 );
495
496/** gets GCG's global primal bound
497 *
498 * Computes the global primal bound while considering the original
499 * problem SCIP instance and the master problem SCIP instance.
500 *
501 * @return the global dual bound
502 */
505 GCG* gcg /**< GCG data structure */
506 );
507
508/** gets GCG's global gap
509 *
510 * Computes the global gap based on the gloal dual bound and the
511 * global primal bound.
512 *
513 * @return the global dual bound
514 *
515 * @see GCGgetDualbound()
516 * @see GCGgetPrimalbound()
517 */
520 GCG* gcg /**< GCG data structure */
521 );
522
523#ifdef NDEBUG
524#define GCGgetRelax(gcg) (gcg->relax)
525#else
526/** gets GCG's relaxator */
529 GCG* gcg /**< GCG data structure */
530 );
531#endif
532
533#ifdef NDEBUG
534#define GCGgetSepaorig(gcg) (gcg->sepaorig)
535#else
536/** gets the orig separator */
539 GCG* gcg /**< GCG data structure */
540 );
541#endif
542
543#ifdef NDEBUG
544#define GCGgetMastersepacutEventhdlr(gcg) (gcg->mastersepacuthdlr)
545#else
546/** gets the master separator cut event handler */
549 GCG* gcg /**< GCG data structure */
550 );
551#endif
552
553
554/**@} */
555
556#ifdef __cplusplus
557}
558#endif
559#endif
common defines and data types used in all packages of GCG
#define GCG_EXPORT
Definition def.h:59
#define SCIP_Bool
#define SCIP_Real
SCIP_EVENTHDLR * GCGgetMastersepacutEventhdlr(GCG *gcg)
Definition gcg.cpp:209
SCIP_SEPA * GCGgetSepaorig(GCG *gcg)
Definition gcg.cpp:198
SCIP_RELAX * GCGgetRelax(GCG *gcg)
Definition gcg.cpp:176
GCG * GCGorigGetGcg(SCIP *origprob)
Definition gcg.cpp:165
GCG_EXPORT SCIP_RETCODE GCGtransformProb(GCG *gcg)
Definition relax_gcg.c:5331
GCG_EXPORT SCIP_Bool GCGisMasterSetPartitioning(GCG *gcg)
Definition relax_gcg.c:4366
SCIP_RETCODE GCGtransformMastersolToOrigsol(GCG *gcg, SCIP_SOL *mastersol, SCIP_SOL **origsol, SCIP_Bool ignorelocalvarbnds, SCIP_Bool *violatesvarbnds)
Definition misc.c:135
SCIP_RETCODE GCGprintStatistics(GCG *gcg, FILE *file)
Definition misc.c:719
GCG_EXPORT SCIP * GCGgetPricingprob(GCG *gcg, int pricingprobnr)
Definition relax_gcg.c:4075
GCG_EXPORT SCIP_CONS ** GCGgetMasterConss(GCG *gcg)
Definition relax_gcg.c:4228
GCG * GCGmasterGetGcg(SCIP *masterprob)
Definition gcg.cpp:134
GCG_EXPORT int GCGgetNTransvars(GCG *gcg)
Definition relax_gcg.c:5256
GCG_EXPORT SCIP_CONS ** GCGgetOrigMasterConss(GCG *gcg)
Definition relax_gcg.c:4245
SCIP * GCGgetBendersMasterprob(GCG *gcg)
Definition gcg.cpp:111
GCG_EXPORT SCIP_RETCODE GCGdetect(GCG *gcg)
Definition relax_gcg.c:5421
GCG_EXPORT SCIP_CONS * GCGgetConvCons(GCG *gcg, int blocknr)
Definition relax_gcg.c:4262
GCG_EXPORT int GCGgetNMasterConss(GCG *gcg)
Definition relax_gcg.c:4211
SCIP_Bool GCGisConsGCGCons(SCIP_CONS *cons)
Definition misc.c:836
SCIP_Bool GCGisOriginal(SCIP *scip)
Definition misc.c:699
SCIP * GCGgetDwMasterprob(GCG *gcg)
Definition gcg.cpp:123
GCG_EXPORT SCIP_CONS ** GCGgetVarLinkingconss(GCG *gcg)
Definition relax_gcg.c:5188
GCG_EXPORT int GCGgetNVarLinkingconss(GCG *gcg)
Definition relax_gcg.c:5222
GCG_EXPORT SCIP_Bool GCGrelaxIsInitialized(GCG *gcg)
Definition relax_gcg.c:5145
GCG_EXPORT SCIP_Real GCGgetPricingprobsMemUsed(GCG *gcg)
Definition relax_gcg.c:5114
GCG_EXPORT int GCGgetNRelPricingprobs(GCG *gcg)
Definition relax_gcg.c:4095
SCIP_RETCODE GCGprintPartitionInformation(GCG *gcg, FILE *file)
SCIP_RETCODE GCGprintBlockcandidateInformation(GCG *gcg, FILE *file)
GCG_EXPORT GCG_DECOMP * GCGgetStructDecomp(GCG *gcg)
Definition relax_gcg.c:2331
SCIP_RETCODE GCGprintCompleteDetectionTime(GCG *gcg, FILE *file)
GCG_EXPORT SCIP_Bool GCGisMasterSetCovering(GCG *gcg)
Definition relax_gcg.c:4347
GCG_EXPORT GCG_PARAMDATA * GCGgetParamsVisu(GCG *gcg)
Definition relax_gcg.c:4285
GCG_EXPORT SCIP_CLOCK * GCGgetRootNodeTime(GCG *gcg)
Definition relax_gcg.c:5313
SCIP * GCGgetOrigprob(GCG *gcg)
Definition gcg.cpp:87
GCG_EXPORT int GCGgetNIdenticalBlocks(GCG *gcg, int pricingprobnr)
Definition relax_gcg.c:4185
GCG_EXPORT int GCGgetNLinkingvars(GCG *gcg)
Definition relax_gcg.c:5239
SCIP_Bool GCGisMaster(SCIP *scip)
Definition misc.c:709
SCIP_RETCODE GCGprintDecompInformation(GCG *gcg, FILE *file)
GCG_EXPORT SCIP_SOL * GCGgetBendersRelaxationSol(GCG *gcg)
Definition relax_gcg.c:5273
GCG_EXPORT int GCGgetNPricingprobs(GCG *gcg)
Definition relax_gcg.c:4113
GCG_EXPORT int GCGgetBlockRepresentative(GCG *gcg, int pricingprobnr)
Definition relax_gcg.c:4155
SCIP * GCGgetMasterprob(GCG *gcg)
Definition gcg.cpp:99
SCIP_RETCODE GCGcreate(GCG **gcg)
Definition gcg.cpp:45
SCIP_Real GCGtransformOrigvalsToMastervals(GCG *gcg, SCIP_VAR **origvars, SCIP_Real *origvals, int norigvars, SCIP_VAR **mastervars, SCIP_Real *mastervals, int nmastervars)
Definition misc.c:576
GCG_EXPORT SCIP_Real GCGgetDegeneracy(GCG *gcg)
Definition relax_gcg.c:5163
SCIP_RETCODE GCGfree(GCG **gcg)
Definition gcg.cpp:68
GCG_EXPORT GCG_DECMODE GCGgetDecompositionMode(GCG *gcg)
Definition relax_gcg.c:5294
GCG_EXPORT int * GCGgetVarLinkingconssBlock(GCG *gcg)
Definition relax_gcg.c:5205
GCG_EXPORT SCIP_Bool GCGisPricingprobRelevant(GCG *gcg, int pricingprobnr)
Definition relax_gcg.c:4132
GCG_EXPORT SCIP_RETCODE GCGsolve(GCG *gcg)
Definition relax_gcg.c:5480
SCIP_RETCODE GCGprintCompleteDetectionStatistics(GCG *gcg, FILE *file)
Definition misc.c:801
SCIP_RETCODE GCGprintInstanceName(GCG *gcg, FILE *file)
Definition misc.c:783
GCG_EXPORT SCIP_RETCODE GCGpresolve(GCG *gcg)
Definition relax_gcg.c:5370
SCIP * origprob
SCIP_VAR ** mastervars
int nmastervars
GCG_EXPORT SCIP_Real GCGgetGap(GCG *gcg)
Definition relax_gcg.c:5651
GCG_EXPORT SCIP_Real GCGgetPrimalbound(GCG *gcg)
Definition relax_gcg.c:5620
GCG_EXPORT SCIP_Real GCGgetDualbound(GCG *gcg)
Definition relax_gcg.c:5589
gcg data structure
struct SCIP_Clock SCIP_CLOCK
struct SCIP_Cons SCIP_CONS
struct GCG_Decomp GCG_DECOMP
Definition type_decomp.h:45
enum Decmode GCG_DECMODE
Definition type_decomp.h:69
struct SCIP_Eventhdlr SCIP_EVENTHDLR
struct Gcg GCG
Definition type_gcg.h:44
struct GCG_ParamData GCG_PARAMDATA
struct SCIP_Relax SCIP_RELAX
enum SCIP_Retcode SCIP_RETCODE
struct Scip SCIP
struct SCIP_Sepa SCIP_SEPA
struct SCIP_Sol SCIP_SOL
struct SCIP_Var SCIP_VAR