Scippy

GCG

Branch-and-Price & Column Generation for Everyone

class_pricingtype.cpp
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 class_pricingtype.cpp
30 * @brief abstraction for SCIP pricing types
31 * @author Martin Bergner
32 * @author Christian Puchert
33 */
34
35/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
36
37#include "scip/scip.h"
39#include "scip/cons_linear.h"
40#include "gcg/pub_gcgvar.h"
42#include "scip/pub_lp.h"
43#include "scip/clock.h"
44#include "gcg/scip_misc.h"
45
46#include <exception>
47
48#define DEFAULT_MAXROUNDSREDCOST INT_MAX /**< maximal number of reduced cost pricing rounds */
49#define DEFAULT_MAXCOLSROUNDREDCOSTROOT 100 /**< maximal number of columns per reduced cost pricing round at root node */
50#define DEFAULT_MAXCOLSROUNDREDCOST 100 /**< maximal number of columns per reduced cost pricing round */
51#define DEFAULT_MAXCOLSPROBREDCOSTROOT 10 /**< maximal number of columns per problem to be generated during red. cost pricing at root node */
52#define DEFAULT_MAXCOLSPROBREDCOST 10 /**< maximal number of columns per problem to be generated during red. cost pricing */
53#define DEFAULT_MAXSUCCESSFULPROBSREDCOST INT_MAX /**< maximal number of successfully solved red. cost pricing problems until pricing loop is aborted */
54#define DEFAULT_RELMAXPROBSREDCOSTROOT 1.0 /**< maximal percentage of red. cost pricing problems that are solved at root node if variables have already been found */
55#define DEFAULT_RELMAXPROBSREDCOST 1.0 /**< maximal percentage of red. cost pricing problems that are solved if variables have already been found */
56#define DEFAULT_RELMAXSUCCESSFULPROBSREDCOST 1.0 /**< maximal percentage of successfully solved red. cost pricing problems until pricing loop is aborted */
57
58#define DEFAULT_MAXCOLSROUNDFARKAS 10 /**< maximal number of columns per Farkas pricing round */
59#define DEFAULT_MAXCOLSPROBFARKAS 10 /**< maximal number of columns per problem to be generated during Farkas pricing */
60#define DEFAULT_RELMAXPROBSFARKAS 1.0 /**< maximal percentage of Farkas pricing problems that are solved if variables have already been found */
61
62
63#define SCIP_CALL_EXC(x) do \
64 { \
65 SCIP_RETCODE _restat_; \
66 if( (_restat_ = (x)) != SCIP_OKAY ) \
67 { \
68 SCIPerrorMessage("Error <%d> in function call\n", _restat_); \
69 throw std::exception(); \
70 } \
71 } \
72 while( FALSE )
73
75 GCG* gcgstruct
76 ) : gcg(gcgstruct)
77{
78 masterprob = GCGgetMasterprob(gcg); /* SCIP instance (master problem) */
79 type = GCG_PRICETYPE_UNKNOWN; /* type of pricing */
80
81 /* statistical values */
82 calls = 0; /* number of times this type of pricing was called */
83
84 /* parameters */
85 maxrounds = INT_MAX; /* maximal number of pricing rounds */
86 maxcolsroundroot = INT_MAX; /* maximal number of columns per pricing round at root node */
87 maxcolsround = INT_MAX; /* maximal number of columns per pricing round */
88 maxcolsprobroot = INT_MAX; /* maximal number of columns per problem to be generated at root node */
89 maxcolsprob = INT_MAX; /* maximal number of columns per problem to be generated */
90 maxsuccessfulprobs = INT_MAX; /* maximal number of successfully solved pricing problems until pricing loop is aborted */
91 relmaxprobsroot = 1.0; /* maximal percentage of pricing problems that are solved at root node if variables have already been found */
92 relmaxprobs = 1.0; /* maximal percentage of pricing problems that are solved if variables have already been found */
93 relmaxsuccessfulprobs = 1.0; /* maximal percentage of successfully solved pricing problems until pricing loop is aborted */
94
96}
97
99{
101
102 masterprob = (SCIP*) NULL;
103}
104
106{
108 return SCIP_OKAY;
109}
110
112{
114 return SCIP_OKAY;
115}
116
118{
120}
121
123 GCG* gcgstruct
124 ) : PricingType(gcgstruct)
125{
127}
128
130 SCIP_CONS* cons
131 ) const
132{
134}
135
137 SCIP_ROW* row
138 ) const
139{
140 return SCIProwGetDualfarkas(row);
141}
142
144 GCG_EXTENDEDMASTERCONSDATA* extendedmasterconsdata
145 ) const
146{
147 assert(extendedmasterconsdata != NULL);
148 switch( GCGextendedmasterconsGetType(extendedmasterconsdata) )
149 {
151 return SCIPgetDualfarkasLinear(masterprob, GCGextendedmasterconsGetCons(extendedmasterconsdata));
153 return SCIProwGetDualfarkas(GCGextendedmasterconsGetRow(extendedmasterconsdata));
154 default:
156 return 0.0;
157 }
158}
159
161 SCIP_VAR* var
162 ) const
163{
164 assert(var != NULL);
165 return 0.0;
166}
167
168/** returns the maximal number of columns per pricing round */
170{
171 return maxcolsround;
172}
173
174/** returns the maximal number of columns per problem to be generated during pricing */
176{
177 return maxcolsprob;
178}
179
180/** returns the maximal percentage of pricing problems that are solved if variables have already been found */
182{
183 return relmaxprobs;
184}
185
187{
188 SCIP* origprob = GCGgetOrigprob(gcg);
189
190 SCIP_CALL( SCIPaddIntParam(origprob, "pricing/masterpricer/maxcolsroundfarkas",
191 "maximal number of columns per Farkas pricing round",
193
194 SCIP_CALL( SCIPaddIntParam(origprob, "pricing/masterpricer/maxcolsprobfarkas",
195 "maximal number of columns per problem to be generated during Farkas pricing",
197
198 SCIP_CALL( SCIPaddRealParam(origprob, "pricing/masterpricer/relmaxprobsfarkas",
199 "maximal percentage of Farkas pricing problems that are solved if variables have already been found",
201
202 return SCIP_OKAY;
203}
204
206 SCIP_CONS* cons
207 ) const
208{
209 return SCIPgetDualsolLinear(masterprob, cons);
210}
211
213 SCIP_ROW* row
214 ) const
215{
216 return SCIProwGetDualsol(row);
217}
218
220 GCG_EXTENDEDMASTERCONSDATA* extendedmasterconsdata
221 ) const
222{
223 assert(extendedmasterconsdata != NULL);
224 switch( GCGextendedmasterconsGetType(extendedmasterconsdata) )
225 {
227 return SCIPgetDualsolLinear(masterprob, GCGextendedmasterconsGetCons(extendedmasterconsdata));
229 return SCIProwGetDualsol(GCGextendedmasterconsGetRow(extendedmasterconsdata));
230 default:
232 return 0.0;
233 }
234}
235
237 GCG* gcgstruct
238 ) : PricingType(gcgstruct)
239{
241}
242
244 SCIP_VAR* var
245 ) const
246{
247 SCIP_VAR* origvar;
248 assert(var != NULL);
249
250 origvar = GCGpricingVarGetOrigvars(var)[0];
251
252 if( GCGoriginalVarIsLinking(origvar) )
253 return 0.0;
254 else
255 return SCIPvarGetObj(origvar);
256}
257
258/** returns the maximal number of columns per pricing round */
260{
262}
263
264/** returns the maximal number of columns per problem to be generated during pricing */
266{
268}
269
270/** returns the maximal percentage of pricing problems that are solved if variables have already been found */
272{
274}
275
277{
278 SCIP* origprob = GCGgetOrigprob(gcg);
279
280 SCIP_CALL( SCIPaddIntParam(origprob, "pricing/masterpricer/maxroundsredcost",
281 "maximal number of pricing rounds per node after the root node",
283
284 SCIP_CALL( SCIPaddIntParam(origprob, "pricing/masterpricer/maxcolsroundredcostroot",
285 "maximal number of columns per reduced cost pricing round at root node",
287 NULL, (SCIP_PARAMDATA*) NULL) );
288
289 SCIP_CALL( SCIPaddIntParam(origprob, "pricing/masterpricer/maxcolsroundredcost",
290 "maximal number of columns per reduced cost pricing round",
292 NULL, (SCIP_PARAMDATA*) NULL) );
293
294 SCIP_CALL( SCIPaddIntParam(origprob, "pricing/masterpricer/maxcolsprobredcostroot",
295 "maximal number of columns per problem to be generated during red. cost pricing at root node",
297 NULL, (SCIP_PARAMDATA*) NULL) );
298
299 SCIP_CALL( SCIPaddIntParam(origprob, "pricing/masterpricer/maxcolsprobredcost",
300 "maximal number of columns per problem to be generated during red. cost pricing",
302 NULL, (SCIP_PARAMDATA*) NULL) );
303
304 SCIP_CALL( SCIPaddIntParam(origprob, "pricing/masterpricer/maxsuccessfulprobsredcost",
305 "maximal number of successfully solved red. cost pricing problems until pricing loop is aborted",
307
308 SCIP_CALL( SCIPaddRealParam(origprob, "pricing/masterpricer/relmaxprobsredcostroot",
309 "maximal percentage of red. cost pricing problems that are solved at root node if variables have already been found",
311
312 SCIP_CALL( SCIPaddRealParam(origprob, "pricing/masterpricer/relmaxprobsredcost",
313 "maximal percentage of red. cost pricing problems that are solved if variables have already been found",
315
316 SCIP_CALL( SCIPaddRealParam(origprob, "pricing/masterpricer/relmaxsuccessfulprobsredcost",
317 "maximal percentage of successfully solved red. cost pricing problems until pricing loop is aborted",
319
320 return SCIP_OKAY;
321}
virtual SCIP_Real rowGetDual(SCIP_ROW *row) const
virtual SCIP_RETCODE addParameters()
virtual int getMaxcolsround() const
virtual SCIP_Real getRelmaxprobs() const
virtual SCIP_Real varGetObj(SCIP_VAR *var) const
FarkasPricing()=delete
virtual SCIP_Real extendedmasterconsGetDual(GCG_EXTENDEDMASTERCONSDATA *extendedmasterconsdata) const
virtual SCIP_Real consGetDual(SCIP_CONS *cons) const
virtual int getMaxcolsprob() const
SCIP_Real relmaxprobs
virtual SCIP_RETCODE stopClock()
virtual ~PricingType()
virtual SCIP_RETCODE startClock()
SCIP_Real relmaxprobsroot
SCIP_CLOCK * clock
PricingType()=delete
virtual SCIP_Real getClockTime() const
SCIP_Real relmaxsuccessfulprobs
GCG_PRICETYPE type
virtual SCIP_Real extendedmasterconsGetDual(GCG_EXTENDEDMASTERCONSDATA *extendedmasterconsdata) const
virtual SCIP_Real getRelmaxprobs() const
virtual SCIP_RETCODE addParameters()
virtual SCIP_Real varGetObj(SCIP_VAR *var) const
ReducedCostPricing()=delete
virtual SCIP_Real consGetDual(SCIP_CONS *cons) const
virtual int getMaxcolsprob() const
virtual int getMaxcolsround() const
virtual SCIP_Real rowGetDual(SCIP_ROW *row) const
#define DEFAULT_MAXCOLSROUNDREDCOST
#define SCIP_CALL_EXC(x)
#define DEFAULT_RELMAXPROBSREDCOSTROOT
#define DEFAULT_MAXCOLSPROBREDCOST
#define DEFAULT_MAXCOLSPROBFARKAS
#define DEFAULT_RELMAXPROBSREDCOST
#define DEFAULT_RELMAXPROBSFARKAS
#define DEFAULT_RELMAXSUCCESSFULPROBSREDCOST
#define DEFAULT_MAXCOLSROUNDFARKAS
#define DEFAULT_MAXROUNDSREDCOST
#define DEFAULT_MAXSUCCESSFULPROBSREDCOST
#define DEFAULT_MAXCOLSPROBREDCOSTROOT
#define DEFAULT_MAXCOLSROUNDREDCOSTROOT
abstraction for SCIP pricing types
#define SCIP_Real
#define SCIP_CALL_ABORT(x)
#define SCIP_CALL(x)
#define FALSE
SCIP_ROW * GCGextendedmasterconsGetRow(GCG_EXTENDEDMASTERCONSDATA *extendedmasterconsdata)
GCG_EXTENDEDMASTERCONSTYPE GCGextendedmasterconsGetType(GCG_EXTENDEDMASTERCONSDATA *extendedmasterconsdata)
SCIP_CONS * GCGextendedmasterconsGetCons(GCG_EXTENDEDMASTERCONSDATA *extendedmasterconsdata)
SCIP_VAR ** GCGpricingVarGetOrigvars(SCIP_VAR *var)
Definition: gcgvar.c:1100
SCIP_Bool GCGoriginalVarIsLinking(SCIP_VAR *var)
Definition: gcgvar.c:247
SCIP_Real SCIPgetDualsolLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_Real SCIPgetDualfarkasLinear(SCIP *scip, SCIP_CONS *cons)
SCIP * GCGgetOrigprob(GCG *gcg)
Definition: gcg.cpp:87
SCIP * GCGgetMasterprob(GCG *gcg)
Definition: gcg.cpp:99
SCIP_Bool GCGisRootNode(GCG *gcg)
Definition: scip_misc.c:918
SCIP_RETCODE SCIPaddIntParam(SCIP *scip, const char *name, const char *desc, int *valueptr, SCIP_Bool isadvanced, int defaultvalue, int minvalue, int maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
SCIP_RETCODE SCIPaddRealParam(SCIP *scip, const char *name, const char *desc, SCIP_Real *valueptr, SCIP_Bool isadvanced, SCIP_Real defaultvalue, SCIP_Real minvalue, SCIP_Real maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
SCIP_Real SCIProwGetDualfarkas(SCIP_ROW *row)
SCIP_Real SCIProwGetDualsol(SCIP_ROW *row)
SCIP_RETCODE SCIPcreateCPUClock(SCIP *scip, SCIP_CLOCK **clck)
SCIP_RETCODE SCIPstopClock(SCIP *scip, SCIP_CLOCK *clck)
SCIP_RETCODE SCIPfreeClock(SCIP *scip, SCIP_CLOCK **clck)
SCIP_Real SCIPgetClockTime(SCIP *scip, SCIP_CLOCK *clck)
SCIP_RETCODE SCIPstartClock(SCIP *scip, SCIP_CLOCK *clck)
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
#define NULL
public methods for interacting with GCG_EXTENDEDMASTERCONSDATA
public methods for GCG variables
various SCIP helper methods
Definition: struct_gcg.h:55
@ GCG_EXTENDEDMASTERCONSTYPE_SEPA_ROW
@ GCG_EXTENDEDMASTERCONSTYPE_BRANCH_CONS
struct SCIP_ParamData SCIP_PARAMDATA
@ GCG_PRICETYPE_UNKNOWN
@ GCG_PRICETYPE_FARKAS
@ GCG_PRICETYPE_REDCOST
SCIP_OKAY
SCIP_ERROR
enum SCIP_Retcode SCIP_RETCODE