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