Scippy

GCG

Branch-and-Price & Column Generation for Everyone

class_pricingtype.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 class_pricingtype.h
29  * @brief abstraction for SCIP pricing types
30  * @author Martin Bergner
31  * @author Christian Puchert
32  */
33 
34 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
35 #ifndef GCG_CLASS_PRICINGTYPE_H__
36 #define GCG_CLASS_PRICINGTYPE_H__
37 
38 #include "objscip/objscip.h"
39 #include "pricer_gcg.h"
40 
42 {
43 protected:
44  SCIP* scip_; /**< SCIP instance (master problem) */
45  GCG_PRICETYPE type; /**< type of pricing */
46  SCIP_CLOCK* clock; /**< CPU clock */
47 
48  int calls; /**< number of times this type of pricing was called */
49  int maxrounds; /**< maximal number of pricing rounds */
50  int maxcolsroundroot; /**< maximal number of columns per pricing round at root node */
51  int maxcolsround; /**< maximal number of columns per pricing round */
52  int maxcolsprobroot; /**< maximal number of columns per problem to be generated at root node */
53  int maxcolsprob; /**< maximal number of columns per problem to be generated */
54  int maxsuccessfulprobs; /**< maximal number of successfully solved pricing problems until pricing
55  * loop is aborted */
56  SCIP_Real relmaxprobsroot; /**< maximal percentage of pricing problems that are solved at root node if
57  * variables have already been found */
58  SCIP_Real relmaxprobs; /**< maximal percentage of pricing problems that are solved if variables
59  * have already been found */
60  SCIP_Real relmaxsuccessfulprobs; /**< maximal percentage of pricing problems that need to be solved successfully */
61 
62 public:
63  /** constructor */
64  PricingType();
65 
67  SCIP* p_scip
68  );
69 
70  /** destructor */
71  virtual ~PricingType();
72 
73  /** get dual value of a constraint */
74  virtual SCIP_Real consGetDual(
75  SCIP* scip, /**< SCIP data structure */
76  SCIP_CONS* cons /**< constraint to get dual for */
77  ) const = 0;
78 
79  /** get dual value of a row */
80  virtual SCIP_Real rowGetDual(
81  SCIP_ROW* row /**< row to get dual value for */
82  ) const = 0;
83 
84  /** get objective value of variable */
85  virtual SCIP_Real varGetObj(
86  SCIP_VAR* var /**< variable to get objective value for */
87  ) const = 0;
88 
89  /** adds parameters to the SCIP data structure */
90  virtual SCIP_RETCODE addParameters() = 0;
91 
92  /** starts the clock */
93  virtual SCIP_RETCODE startClock();
94 
95  /** stops the clock */
96  virtual SCIP_RETCODE stopClock();
97 
98  /** returns the time of the clock */
99  virtual SCIP_Real getClockTime() const;
100 
101  /** returns the maximal number of rounds */
102  virtual int getMaxrounds() const
103  {
104  return maxrounds;
105  }
106 
107  /** returns the maximal number of columns per pricing round */
108  virtual int getMaxcolsround() const = 0;
109 
110  /** returns the maximal number of columns per problem to be generated during pricing */
111  virtual int getMaxcolsprob() const = 0;
112 
113  /** returns the maximal number of successfully solved pricing problems */
115  {
116  return maxsuccessfulprobs;
117  }
118 
119  /** returns the maximal percentage of pricing problems that are solved if variables have already been found */
120  virtual SCIP_Real getRelmaxprobs() const = 0;
121 
122  /** returns the maximal percentage of pricing problems that need to be solved successfully */
123  SCIP_Real getRelmaxsuccessfulprobs() const
124  {
125  return relmaxsuccessfulprobs;
126  }
127 
128  /** returns the type of this pricing type */
130  {
131  return type;
132  }
133 
134  /** returns the number of calls so far */
135  int getCalls() const
136  {
137  return calls;
138  }
139 
140  /** increases the number of calls */
141  virtual void incCalls()
142  {
143  calls++;
144  }
145 
146  /** resets the number of calls and the clock for a restart */
147  SCIP_RETCODE resetCalls()
148  {
149  calls = 0;
150  SCIP_CALL( SCIPresetClock(scip_, clock) );
151  return SCIP_OKAY;
152  }
153 
154 };
155 
157 {
158 public:
159  /** constructor */
161 
163  SCIP* p_scip
164  );
165 
166  /** destructor */
167  virtual ~ReducedCostPricing() {}
168 
169  virtual SCIP_RETCODE addParameters();
170 
171  virtual SCIP_Real consGetDual(
172  SCIP* scip,
173  SCIP_CONS* cons
174  ) const;
175 
176  virtual SCIP_Real rowGetDual(
177  SCIP_ROW* row
178  ) const;
179 
180  virtual SCIP_Real varGetObj(
181  SCIP_VAR* var
182  ) const ;
183 
184  /** returns the maximal number of columns per pricing round */
185  virtual int getMaxcolsround() const;
186 
187  /** returns the maximal number of columns per problem to be generated during pricing */
188  virtual int getMaxcolsprob() const;
189 
190  /** returns the maximal percentage of pricing problems that are solved if variables have already been found */
191  virtual SCIP_Real getRelmaxprobs() const;
192 };
193 
195 {
196 public:
197  /** constructor */
198  FarkasPricing();
199 
201  SCIP* p_scip
202  );
203 
204  /** destructor */
205  virtual ~FarkasPricing() {}
206 
207  virtual SCIP_RETCODE addParameters();
208 
209  virtual SCIP_Real consGetDual(
210  SCIP* scip,
211  SCIP_CONS* cons
212  ) const;
213 
214  virtual SCIP_Real rowGetDual(
215  SCIP_ROW* row
216  ) const;
217 
218  virtual SCIP_Real varGetObj(
219  SCIP_VAR* var
220  ) const;
221 
222  /** returns the maximal number of columns per pricing round */
223  virtual int getMaxcolsround() const;
224 
225  /** returns the maximal number of columns per problem to be generated during pricing */
226  virtual int getMaxcolsprob() const;
227 
228  /** returns the maximal percentage of pricing problems that are solved if variables have already been found */
229  virtual SCIP_Real getRelmaxprobs() const;
230 };
231 
232 #endif /* CLASS_PRICINGTYPE_H_ */
virtual ~PricingType()
virtual int getMaxcolsprob() const
virtual int getMaxrounds() const
int getCalls() const
virtual int getMaxcolsround() const =0
virtual SCIP_RETCODE stopClock()
SCIP_Real relmaxsuccessfulprobs
virtual SCIP_Real rowGetDual(SCIP_ROW *row) const =0
virtual int getMaxcolsround() const
virtual int getMaxcolsround() const
SCIP_Real getRelmaxsuccessfulprobs() const
virtual SCIP_Real varGetObj(SCIP_VAR *var) const
virtual SCIP_Real rowGetDual(SCIP_ROW *row) const
GCG variable pricer.
SCIP_RETCODE resetCalls()
virtual SCIP_Real varGetObj(SCIP_VAR *var) const =0
virtual SCIP_Real getRelmaxprobs() const
virtual SCIP_Real varGetObj(SCIP_VAR *var) const
virtual SCIP_RETCODE addParameters()
virtual SCIP_RETCODE startClock()
virtual SCIP_RETCODE addParameters()
GCG_PRICETYPE getType() const
enum GCG_Pricetype GCG_PRICETYPE
Definition: pricer_gcg.h:59
virtual SCIP_Real getRelmaxprobs() const
virtual int getMaxcolsprob() const =0
int getMaxsuccessfulprobs() const
virtual int getMaxcolsprob() const
virtual SCIP_Real consGetDual(SCIP *scip, SCIP_CONS *cons) const
SCIP_CLOCK * clock
virtual SCIP_RETCODE addParameters()=0
virtual void incCalls()
virtual SCIP_Real consGetDual(SCIP *scip, SCIP_CONS *cons) const =0
virtual SCIP_Real getClockTime() const
virtual SCIP_Real consGetDual(SCIP *scip, SCIP_CONS *cons) const
virtual SCIP_Real rowGetDual(SCIP_ROW *row) const
virtual SCIP_Real getRelmaxprobs() const =0
SCIP_Real relmaxprobs
SCIP_Real relmaxprobsroot
virtual ~FarkasPricing()
GCG_PRICETYPE type