class_pricingtype.cpp
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-2018 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 
34 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
35 
36 #include "scip/scip.h"
37 #include "class_pricingtype.h"
38 #include "scip/cons_linear.h"
39 #include "pub_gcgvar.h"
40 #include "scip/pub_lp.h"
41 #include "scip/clock.h"
42 #include "scip_misc.h"
43 
44 #include <exception>
45 
46 #define DEFAULT_MAXROUNDSREDCOST INT_MAX
47 #define DEFAULT_MAXCOLSROUNDREDCOSTROOT 100
48 #define DEFAULT_MAXCOLSROUNDREDCOST 100
49 #define DEFAULT_MAXCOLSPROBREDCOSTROOT 10
50 #define DEFAULT_MAXCOLSPROBREDCOST 10
51 #define DEFAULT_MAXSUCCESSFULPROBSREDCOST INT_MAX
52 #define DEFAULT_RELMAXPROBSREDCOSTROOT 1.0
53 #define DEFAULT_RELMAXPROBSREDCOST 1.0
54 #define DEFAULT_RELMAXSUCCESSFULPROBSREDCOST 1.0
56 #define DEFAULT_MAXCOLSROUNDFARKAS 10
57 #define DEFAULT_MAXCOLSPROBFARKAS 10
58 #define DEFAULT_RELMAXPROBSFARKAS 1.0
61 #define SCIP_CALL_EXC(x) do \
62  { \
63  SCIP_RETCODE _restat_; \
64  if( (_restat_ = (x)) != SCIP_OKAY ) \
65  { \
66  SCIPerrorMessage("Error <%d> in function call\n", _restat_); \
67  throw std::exception(); \
68  } \
69  } \
70  while( FALSE )
71 
73  SCIP* scip
74  )
75 {
76  scip_ = scip;
79  /* statistical values */
80  calls = 0;
82  /* parameters */
83  maxrounds = INT_MAX;
84  maxcolsroundroot = INT_MAX;
85  maxcolsround = INT_MAX;
86  maxcolsprobroot = INT_MAX;
87  maxcolsprob = INT_MAX;
88  maxsuccessfulprobs = INT_MAX;
89  relmaxprobsroot = 1.0;
90  relmaxprobs = 1.0;
91  relmaxsuccessfulprobs = 1.0;
93  SCIP_CALL_EXC( SCIPcreateCPUClock(scip, &(clock)) );
94 }
95 
97 {
98  SCIP_CALL_ABORT( SCIPfreeClock(scip_, &(clock)) );
99 
100  scip_ = (SCIP*) NULL;
101 }
102 
104 {
105  SCIP_CALL( SCIPstartClock(scip_, clock) );
106  return SCIP_OKAY;
107 }
108 
110 {
111  SCIP_CALL( SCIPstopClock(scip_, clock) );
112  return SCIP_OKAY;
113 }
114 
115 SCIP_Real PricingType::getClockTime() const
116 {
117  return SCIPgetClockTime(scip_, clock);
118 }
119 
121  SCIP* scip
122  ) : PricingType(scip)
123 {
125 }
126 
128  SCIP* scip,
129  SCIP_CONS* cons
130  ) const
131 {
132  return SCIPgetDualfarkasLinear(scip, cons);
133 }
134 
136  SCIP_ROW* row
137  ) const
138 {
139  return SCIProwGetDualfarkas(row);
140 }
141 
143  SCIP_VAR* var
144  ) const
145 {
146  assert(var != NULL);
147  return 0.0;
148 }
149 
152 {
153  return maxcolsround;
154 }
155 
158 {
159  return maxcolsprob;
160 }
161 
164 {
165  return relmaxprobs;
166 }
167 
169 {
170  SCIP* origprob = GCGmasterGetOrigprob(scip_);
171 
172  SCIP_CALL( SCIPaddIntParam(origprob, "pricing/masterpricer/maxcolsroundfarkas",
173  "maximal number of columns per Farkas pricing round",
174  &maxcolsround, FALSE, DEFAULT_MAXCOLSROUNDFARKAS, 1, INT_MAX, NULL, (SCIP_PARAMDATA*) NULL) );
175 
176  SCIP_CALL( SCIPaddIntParam(origprob, "pricing/masterpricer/maxcolsprobfarkas",
177  "maximal number of columns per problem to be generated during Farkas pricing",
178  &maxcolsprob, FALSE, DEFAULT_MAXCOLSPROBFARKAS, 1, INT_MAX, NULL, (SCIP_PARAMDATA*) NULL) );
179 
180  SCIP_CALL( SCIPaddRealParam(origprob, "pricing/masterpricer/relmaxprobsfarkas",
181  "maximal percentage of Farkas pricing problems that are solved if variables have already been found",
182  &relmaxprobs, FALSE, DEFAULT_RELMAXPROBSFARKAS, 0.0, 1.0, NULL, (SCIP_PARAMDATA*) NULL) );
183 
184  return SCIP_OKAY;
185 }
186 
188  SCIP* scip,
189  SCIP_CONS* cons
190  ) const
191 {
192  return SCIPgetDualsolLinear(scip, cons);
193 }
194 
196  SCIP_ROW* row
197  ) const
198 {
199  return SCIProwGetDualsol(row);
200 }
201 
203  SCIP* p_scip
204  ) : PricingType(p_scip)
205 {
207 }
208 
210  SCIP_VAR* var
211  ) const
212 {
213  SCIP_VAR* origvar;
214  assert(var != NULL);
215 
216  origvar = GCGpricingVarGetOrigvars(var)[0];
217 
218  if( GCGoriginalVarIsLinking(origvar) )
219  return 0.0;
220  else
221  return SCIPvarGetObj(origvar);
222 }
223 
226 {
228 }
229 
232 {
234 }
235 
238 {
240 }
241 
243 {
244  SCIP* origprob = GCGmasterGetOrigprob(scip_);
245 
246  SCIP_CALL( SCIPaddIntParam(origprob, "pricing/masterpricer/maxroundsredcost",
247  "maximal number of pricing rounds per node after the root node",
248  &maxrounds, FALSE, DEFAULT_MAXROUNDSREDCOST, 0, INT_MAX, NULL, (SCIP_PARAMDATA*) NULL) );
249 
250  SCIP_CALL( SCIPaddIntParam(origprob, "pricing/masterpricer/maxcolsroundredcostroot",
251  "maximal number of columns per reduced cost pricing round at root node",
253  NULL, (SCIP_PARAMDATA*) NULL) );
254 
255  SCIP_CALL( SCIPaddIntParam(origprob, "pricing/masterpricer/maxcolsroundredcost",
256  "maximal number of columns per reduced cost pricing round",
257  &maxcolsround, FALSE, DEFAULT_MAXCOLSROUNDREDCOST, 0, INT_MAX,
258  NULL, (SCIP_PARAMDATA*) NULL) );
259 
260  SCIP_CALL( SCIPaddIntParam(origprob, "pricing/masterpricer/maxcolsprobredcostroot",
261  "maximal number of columns per problem to be generated during red. cost pricing at root node",
262  &maxcolsprobroot, FALSE, DEFAULT_MAXCOLSPROBREDCOSTROOT, 0, INT_MAX,
263  NULL, (SCIP_PARAMDATA*) NULL) );
264 
265  SCIP_CALL( SCIPaddIntParam(origprob, "pricing/masterpricer/maxcolsprobredcost",
266  "maximal number of columns per problem to be generated during red. cost pricing",
267  &maxcolsprob, FALSE, DEFAULT_MAXCOLSPROBREDCOST, 0, INT_MAX,
268  NULL, (SCIP_PARAMDATA*) NULL) );
269 
270  SCIP_CALL( SCIPaddIntParam(origprob, "pricing/masterpricer/maxsuccessfulprobsredcost",
271  "maximal number of successfully solved red. cost pricing problems until pricing loop is aborted",
272  &maxsuccessfulprobs, FALSE, DEFAULT_MAXSUCCESSFULPROBSREDCOST, 1, INT_MAX, NULL, (SCIP_PARAMDATA*) NULL) );
273 
274  SCIP_CALL( SCIPaddRealParam(origprob, "pricing/masterpricer/relmaxprobsredcostroot",
275  "maximal percentage of red. cost pricing problems that are solved at root node if variables have already been found",
276  &relmaxprobsroot, FALSE, DEFAULT_RELMAXPROBSREDCOSTROOT, 0.0, 1.0, NULL, (SCIP_PARAMDATA*) NULL) );
277 
278  SCIP_CALL( SCIPaddRealParam(origprob, "pricing/masterpricer/relmaxprobsredcost",
279  "maximal percentage of red. cost pricing problems that are solved if variables have already been found",
280  &relmaxprobs, FALSE, DEFAULT_RELMAXPROBSREDCOST, 0.0, 1.0, NULL, (SCIP_PARAMDATA*) NULL) );
281 
282  SCIP_CALL( SCIPaddRealParam(origprob, "pricing/masterpricer/relmaxsuccessfulprobsredcost",
283  "maximal percentage of successfully solved red. cost pricing problems until pricing loop is aborted",
284  &relmaxsuccessfulprobs, FALSE, DEFAULT_RELMAXSUCCESSFULPROBSREDCOST, 0.0, 1.0, NULL, NULL) );
285 
286  return SCIP_OKAY;
287 }
virtual SCIP_Real rowGetDual(SCIP_ROW *row) const
GCG_PRICETYPE type
virtual SCIP_RETCODE addParameters()
virtual SCIP_Real varGetObj(SCIP_VAR *var) const
abstraction for SCIP pricing types
SCIP_Bool GCGisRootNode(SCIP *scip)
Definition: scip_misc.c:920
#define DEFAULT_MAXCOLSPROBREDCOSTROOT
#define DEFAULT_RELMAXPROBSREDCOST
#define DEFAULT_RELMAXPROBSREDCOSTROOT
virtual ~PricingType()
SCIP_Real relmaxsuccessfulprobs
virtual SCIP_RETCODE stopClock()
virtual SCIP_Real getRelmaxprobs() const
#define DEFAULT_MAXCOLSPROBFARKAS
virtual SCIP_RETCODE addParameters()
#define SCIP_CALL_EXC(x)
virtual SCIP_Real rowGetDual(SCIP_ROW *row) const
virtual SCIP_RETCODE startClock()
#define DEFAULT_MAXROUNDSREDCOST
SCIP_VAR ** GCGpricingVarGetOrigvars(SCIP_VAR *var)
Definition: gcgvar.c:920
various SCIP helper methods
SCIP_Bool GCGoriginalVarIsLinking(SCIP_VAR *var)
Definition: gcgvar.c:176
#define DEFAULT_MAXCOLSROUNDFARKAS
#define DEFAULT_RELMAXSUCCESSFULPROBSREDCOST
#define DEFAULT_MAXCOLSPROBREDCOST
virtual int getMaxcolsprob() const
virtual SCIP_Real consGetDual(SCIP *scip, SCIP_CONS *cons) const
SCIP * GCGmasterGetOrigprob(SCIP *scip)
SCIP_CLOCK * clock
#define DEFAULT_MAXCOLSROUNDREDCOST
public methods for GCG variables
virtual SCIP_Real getClockTime() const
#define DEFAULT_MAXSUCCESSFULPROBSREDCOST
SCIP_Real relmaxprobs
#define DEFAULT_RELMAXPROBSFARKAS
virtual int getMaxcolsround() const
virtual int getMaxcolsprob() const
virtual SCIP_Real varGetObj(SCIP_VAR *var) const
#define DEFAULT_MAXCOLSROUNDREDCOSTROOT
virtual int getMaxcolsround() const
virtual SCIP_Real getRelmaxprobs() const
SCIP_Real relmaxprobsroot
virtual SCIP_Real consGetDual(SCIP *scip, SCIP_CONS *cons) const