Scippy

GCG

Branch-and-Price & Column Generation for Everyone

branchgcg.c
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 branchgcg.c
30 * @brief methods for branching rules in GCG projects
31 * @author Erik Muehmer
32 */
33
34/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
35
36#include "gcg/branchgcg.h"
39
40/** creates an extended master cons for a cons created by a branch rule */
42 GCG* gcg, /**< GCG data structure */
43 GCG_BRANCHRULE* branchrule, /**< GCG branch rule */
44 GCG_EXTENDEDMASTERCONSDATA** extendedmasterconsdata, /**< pointer to store the extended master cons data */
45 SCIP_CONS* cons, /**< constraint in the master problem that represents the extended master cons */
46 GCG_PRICINGMODIFICATION** pricingmodifications, /**< pricing modifications for the extended master cons */
47 int npricingmodifications, /**< number of pricing modifications for the extended master cons */
48 GCG_BRANCHDATA* branchdata /**< any data that might be required to calculate the coefficient of a column solution */
49 )
50{
52
54 data->branchrule = branchrule;
55 data->branchdata = branchdata;
56 SCIP_CALL( GCGextendedmasterconsCreateFromCons(gcg, extendedmasterconsdata, GCG_EXTENDEDMASTERCONSTYPE_BRANCH_CONS, cons, pricingmodifications, npricingmodifications, data) );
57 return SCIP_OKAY;
58}
59
60/** calculate the coefficient of a column solution in the extended master cons */
62 GCG* gcg, /**< GCG data structure */
63 GCG_EXTENDEDMASTERCONSDATA* extendedmasterconsdata, /**< extended master cons data */
64 SCIP_VAR** solvars, /**< array of column solution variables */
65 SCIP_Real* solvals, /**< array of column solution values */
66 int nsolvars, /**< number of column solution variables and values */
67 int probnr, /**< the pricing problem that the column belongs to */
68 GCG_COL* gcgcol, /**< gcg column if available (or NULL) */
69 SCIP_Real* coeff /**< pointer to store the coefficient */
70 )
71{
73 assert(extendedmasterconsdata != NULL);
75
76 data = extendedmasterconsdata->data.branchconsdata;
77 assert(data != NULL);
78 SCIP_CALL( data->branchrule->branchgetextendedmasterconscoeff(gcg, data->branchdata, extendedmasterconsdata, solvars, solvals, nsolvars, probnr, gcgcol, coeff) );
79 return SCIP_OKAY;
80}
81
82/** frees the branch data stored in the extened master cons data */
84 GCG* gcg, /**< GCG data structure */
85 GCG_EXTENDEDMASTERCONSDATA** extendedmasterconsdata /**< extended master cons data */
86 )
87{
89 assert(extendedmasterconsdata != NULL);
90 assert(*extendedmasterconsdata != NULL);
92
93 data = (*extendedmasterconsdata)->data.branchconsdata;
94 assert(data != NULL);
96 SCIP_CALL( GCGextendedmasterconsFree(gcg, extendedmasterconsdata) );
97 return SCIP_OKAY;
98}
99
100#ifndef NDEBUG
101/** returns the pointer to the SCIP_BRNACHRULE object */
103 GCG_BRANCHRULE* branchrule
104 )
105{
106 assert(branchrule != NULL);
107 return branchrule->branchrule;
108}
109#endif
110
111#ifndef NDEBUG
112/** returns the pointer to the SCIP_BRNACHRULEDATA object */
114 GCG_BRANCHRULE* branchrule
115 )
116{
117 assert(branchrule != NULL);
118 return SCIPbranchruleGetData(branchrule->branchrule);
119}
120#endif
SCIP_BRANCHRULEDATA * GCGbranchGetScipBranchruledata(GCG_BRANCHRULE *branchrule)
Definition: branchgcg.c:113
SCIP_RETCODE GCGbranchFreeExtendedmasterconsBranchData(GCG *gcg, GCG_EXTENDEDMASTERCONSDATA **extendedmasterconsdata)
Definition: branchgcg.c:83
SCIP_RETCODE GCGbranchCreateExtendedmastercons(GCG *gcg, GCG_BRANCHRULE *branchrule, GCG_EXTENDEDMASTERCONSDATA **extendedmasterconsdata, SCIP_CONS *cons, GCG_PRICINGMODIFICATION **pricingmodifications, int npricingmodifications, GCG_BRANCHDATA *branchdata)
Definition: branchgcg.c:41
SCIP_BRANCHRULE * GCGbranchGetScipBranchrule(GCG_BRANCHRULE *branchrule)
Definition: branchgcg.c:102
SCIP_RETCODE GCGbranchGetExtendedmasterconsCoeff(GCG *gcg, GCG_EXTENDEDMASTERCONSDATA *extendedmasterconsdata, SCIP_VAR **solvars, SCIP_Real *solvals, int nsolvars, int probnr, GCG_COL *gcgcol, SCIP_Real *coeff)
Definition: branchgcg.c:61
methods for branching rules in GCG projects
#define SCIP_CALL(x)
SCIP_RETCODE GCGextendedmasterconsFree(GCG *gcg, GCG_EXTENDEDMASTERCONSDATA **extendedmasterconsdata)
GCG_EXTENDEDMASTERCONSTYPE GCGextendedmasterconsGetType(GCG_EXTENDEDMASTERCONSDATA *extendedmasterconsdata)
SCIP_RETCODE GCGextendedmasterconsCreateFromCons(GCG *gcg, GCG_EXTENDEDMASTERCONSDATA **extendedmasterconsdata, GCG_EXTENDEDMASTERCONSTYPE type, SCIP_CONS *cons, GCG_PRICINGMODIFICATION **pricingmodifications, int npricingmodifications, GCG_BRANCHCONSDATA *data)
SCIP * GCGgetMasterprob(GCG *gcg)
Definition: gcg.cpp:99
SCIP_BRANCHRULEDATA * SCIPbranchruleGetData(SCIP_BRANCHRULE *branchrule)
#define SCIPfreeBlockMemory(scip, ptr)
#define SCIPallocBlockMemory(scip, ptr)
#define NULL
GCG_BRANCHRULE * branchrule
GCG_BRANCHDATA * branchdata
SCIP_BRANCHRULE * branchrule
union GCG_ExtendedMasterConsData::@0 data
Definition: struct_gcg.h:55
data structures for branching rules
data structures for GCG extended master cons data
@ GCG_EXTENDEDMASTERCONSTYPE_BRANCH_CONS
SCIP_OKAY
enum SCIP_Retcode SCIP_RETCODE