Scippy

GCG

Branch-and-Price & Column Generation for Everyone

class_pricingcontroller.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_pricingcontroller.h
29  * @brief pricing controller managing the pricing strategy
30  * @author Christian Puchert
31  */
32 
33 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
34 
35 #ifndef CLASS_PRICINGCONTROLLER_H_
36 #define CLASS_PRICINGCONTROLLER_H_
37 
38 #include "colpool.h"
39 #include "pricestore_gcg.h"
40 #include "class_pricingtype.h"
41 #include "type_gcgpqueue.h"
42 #include "type_pricingjob.h"
43 #include "type_pricingprob.h"
44 #include "objscip/objscip.h"
45 
46 namespace gcg {
47 
49 {
50 
51 private:
52  SCIP* scip_; /**< SCIP instance (master problem) */
53  GCG_PRICINGPROB** pricingprobs; /**< pricing problems */
54  int npricingprobs; /**< number of pricing problems */
55  int maxpricingprobs; /**< capacity of pricingprobs */
56  GCG_PRICINGJOB** pricingjobs; /**< pricing jobs */
57  int npricingjobs; /**< number of pricing jobs */
58  int maxpricingjobs; /**< capacity of pricingjobs */
59 
60  /* parameters */
61  int heurpricingiters; /**< maximum number of heuristic pricing iterations per pricing call and problem */
62  int maxheurdepth; /**< maximum depth at which heuristic pricing should be performed (-1 for infinity) */
63  char sorting; /**< order by which the pricing problems should be sorted */
64  int nroundscol; /**< number of previous pricing rounds for which the number of improving columns should be counted */
65  int chunksize; /**< maximal number of pricing problems to be solved during one pricing loop */
66  int eagerfreq; /**< frequency at which all pricing problems should be solved */
67 
68  /* strategy */
69  GCG_PQUEUE* pqueue; /**< priority queue containing the pricing jobs */
70  SCIP_Real* score; /**< scores of the pricing problems */
71  int maxniters; /**< maximal possible number of pricing iterations */
72  int nchunks; /**< number of pricing problem 'chunks' */
73  int curchunk; /**< index of current chunk of pricing problems */
74  int startchunk; /**< first chunk considered in a pricing call */
75  PricingType* pricingtype_; /**< current pricing type */
76 
77  /* statistics */
78  int eagerage; /**< iterations since last eager iteration */
79  int nsolvedprobs; /**< number of completely solved pricing problems during the current pricing loop */
80 
81 
82 public:
83  /** default constructor */
85 
86  /** constructor */
87  Pricingcontroller(SCIP* scip);
88 
89  /** destructor */
90  virtual ~Pricingcontroller();
91 
92  SCIP_RETCODE addParameters();
93 
94  SCIP_RETCODE initSol();
95 
96  SCIP_RETCODE exitSol();
97 
98  /** pricing initialization, called right at the beginning of pricing */
99  SCIP_RETCODE initPricing(
100  PricingType* pricingtype /**< type of pricing */
101  );
102 
103  /** pricing deinitialization, called when pricing is finished */
104  void exitPricing();
105 
106  /** setup the priority queue (done once per stabilization round): add all pricing jobs to be performed */
107  SCIP_RETCODE setupPriorityQueue(
108  SCIP_Real* dualsolconv /**< dual solution values / Farkas coefficients of convexity constraints */
109  );
110 
111  /** get the next pricing job to be performed */
113 
114  /** add the information that the next branching constraint must be added,
115  * and for the pricing job, reset heuristic pricing counter and flag
116  */
117  SCIP_RETCODE pricingprobNextBranchcons(
118  GCG_PRICINGPROB* pricingprob /**< pricing problem structure */
119  );
120 
121  /** set an individual time limit for a pricing job */
122  SCIP_RETCODE setPricingjobTimelimit(
123  GCG_PRICINGJOB* pricingjob /**< pricing job */
124  );
125 
126  /** update solution information of a pricing problem */
127  void updatePricingprob(
128  GCG_PRICINGPROB* pricingprob, /**< pricing problem structure */
129  GCG_PRICINGSTATUS status, /**< new pricing status */
130  SCIP_Real lowerbound, /**< new lower bound */
131  int nimpcols /**< number of new improving columns */
132  );
133 
134  /** update solution statistics of a pricing job */
136  GCG_PRICINGJOB* pricingjob /**< pricing job */
137  );
138 
139  /** decide whether a pricing job must be treated again */
140  void evaluatePricingjob(
141  GCG_PRICINGJOB* pricingjob, /**< pricing job */
142  GCG_PRICINGSTATUS status /**< status of pricing job */
143  );
144 
145  /** collect solution results from all pricing problems */
146  void collectResults(
147  GCG_COL** bestcols, /**< best found columns per pricing problem */
148  SCIP_Bool* infeasible, /**< pointer to store whether pricing is infeasible */
149  SCIP_Bool* optimal, /**< pointer to store whether all pricing problems were solved to optimality */
150  SCIP_Real* bestobjvals, /**< array to store best lower bounds */
151  SCIP_Real* beststabobj, /**< pointer to store total lower bound */
152  SCIP_Real* bestredcost, /**< pointer to store best total reduced cost */
153  SCIP_Bool* bestredcostvalid /**< pointer to store whether best reduced cost is valid */
154  );
155 
156  /** check if the next chunk of pricing problems is to be used */
157  SCIP_Bool checkNextChunk();
158 
159  /** decide whether the pricing loop can be aborted */
160  SCIP_Bool canPricingloopBeAborted(
161  PricingType* pricingtype, /**< type of pricing (reduced cost or Farkas) */
162  int nfoundcols, /**< number of negative reduced cost columns found so far */
163  int nsuccessfulprobs /**< number of pricing problems solved successfully so far */
164  ) const;
165 
166  void resetEagerage();
167 
168  void increaseEagerage();
169 
170  /** for a given problem index, get the corresponding pricing problem (or NULL, if it does not exist) */
172  int probnr /**< index of the pricing problem */
173  );
174 
175  /** get maximal possible number of pricing iterations */
176  int getMaxNIters() const;
177 
178 
179 private:
180  /** comparison operator for pricing jobs w.r.t. their solution priority */
181  static
182  SCIP_DECL_SORTPTRCOMP(comparePricingjobs);
183 
184  /** for each pricing problem, get its corresponding generic branching constraints */
185  SCIP_RETCODE getGenericBranchconss();
186 
187  /** check if a pricing job is done */
188  SCIP_Bool pricingprobIsDone(
189  GCG_PRICINGPROB* pricingprob /**< pricing problem structure */
190  ) const;
191 
192  /** check whether the next generic branching constraint of a pricing problem must be considered */
193  SCIP_Bool pricingprobNeedsNextBranchingcons(
194  GCG_PRICINGPROB* pricingprob /**< pricing problem structure */
195  ) const;
196 };
197 
198 } /* namespace gcg */
199 #endif /* CLASS_PRICINGCONTROLLER_H_ */
void collectResults(GCG_COL **bestcols, SCIP_Bool *infeasible, SCIP_Bool *optimal, SCIP_Real *bestobjvals, SCIP_Real *beststabobj, SCIP_Real *bestredcost, SCIP_Bool *bestredcostvalid)
SCIP_RETCODE initPricing(PricingType *pricingtype)
void evaluatePricingjob(GCG_PRICINGJOB *pricingjob, GCG_PRICINGSTATUS status)
GCG_PRICINGPROB * getPricingprob(int probnr)
type definitions for priority queue
priority queue data structure
SCIP_RETCODE setupPriorityQueue(SCIP_Real *dualsolconv)
SCIP_RETCODE pricingprobNextBranchcons(GCG_PRICINGPROB *pricingprob)
enum GCG_PricingStatus GCG_PRICINGSTATUS
internal methods for storing cols in a col pool
void updatePricingprob(GCG_PRICINGPROB *pricingprob, GCG_PRICINGSTATUS status, SCIP_Real lowerbound, int nimpcols)
void updatePricingjobSolvingStats(GCG_PRICINGJOB *pricingjob)
type definitions for pricing problem data structure
GCG_PRICINGJOB * getNextPricingjob()
SCIP_Bool canPricingloopBeAborted(PricingType *pricingtype, int nfoundcols, int nsuccessfulprobs) const
SCIP_RETCODE setPricingjobTimelimit(GCG_PRICINGJOB *pricingjob)
abstraction for SCIP pricing types
methods for storing priced cols (based on SCIP's separation storage)
type definitions for pricing job data structure