GCG 4.1.1 (dev)

Generic Column Generation

Loading...
Searching...
No Matches
objpricer_gcg.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 objpricer_gcg.h
30 * @brief GCG variable pricer
31 * @author Martin Bergner
32 */
33
34/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
35
36#ifndef GCG_OBJPRICER_GCG_H_
37#define GCG_OBJPRICER_GCG_H_
38
39#include "objscip/objscip.h"
43#include "gcg/pub_gcgcol.h"
44#include "gcg/pub_colpool.h"
45#include "gcg/pricestore_gcg.h"
46#include "gcg/type_branchgcg.h"
47
50
51/**
52 * Pricer C++ Class
53 * @ingroup PRICING_PRIV
54 */
56{
57public:
58 /*lint --e{1540}*/
59
60 GCG* gcg; /**< GCG data structure */
61 SCIP* origprob; /**< the original program */
62 SCIP_PRICERDATA* pricerdata; /**< pricerdata data structure */
63 GCG_COLPOOL* colpool; /**< column pool */
64 GCG_PRICESTORE* pricestore; /**< price storage */
65
66 /** default constructor */
68 GCG* gcgstruct, /**< GCG data structure */
69 const char* name, /**< name of variable pricer */
70 const char* desc, /**< description of variable pricer */
71 int priority, /**< priority of the variable pricer */
72 unsigned int delay, /**< should the pricer be delayed until no other pricers or already existing*/
73 SCIP_PRICERDATA* p_pricerdata /**< pricerdata data structure */
74 );
75 /** destructor */
76 virtual ~ObjPricerGcg()
77 {}
78
79 /** destructor of variable pricer to free user data (called when SCIP is exiting) */
80 virtual SCIP_DECL_PRICERFREE(scip_free);
81 /** initialization method of variable pricer (called after problem was transformed) */
82 virtual SCIP_DECL_PRICERINIT(scip_init);
83 /** deinitialization method of variable pricer (called before transformed problem is freed) */
84 virtual SCIP_DECL_PRICEREXIT(scip_exit);
85 /** solving process initialization method of variable pricer (called when branch and bound process is about to begin) */
86 virtual SCIP_DECL_PRICERINITSOL(scip_initsol);
87 /** solving process deinitialization method of variable pricer (called before branch and bound process data is freed) */
88 virtual SCIP_DECL_PRICEREXITSOL(scip_exitsol);
89 /** reduced cost pricing method of variable pricer for feasible LPs */
90 virtual SCIP_DECL_PRICERREDCOST(scip_redcost);
91 /** farkas pricing method of variable pricer for infeasible LPs */
92 virtual SCIP_DECL_PRICERFARKAS(scip_farkas);
94 {
95 return pricerdata;
96 }
97
98 /** for a pricing problem, get the dual solution value or Farkas value of the convexity constraint */
100 PricingType* pricetype, /**< Farkas or Reduced cost pricing */
101 int probnr /**< index of corresponding pricing problem */
102 );
103
104 /** computes the pricing problem objectives */
106 PricingType* pricetype, /**< Farkas or Reduced cost pricing */
107 SCIP_Bool stabilize /**< do we use stabilization ? */
108 );
109
110 /** update reduced cost of columns in column pool */
112 PricingType* pricetype /**< type of pricing: reduced cost or Farkas */
113 );
114 /** method to price new columns from Column Pool */
116 PricingType* pricetype, /**< type of pricing: reduced cost or Farkas */
117 int* pnfoundvars /**< pointer to store number of priced variables */
118 );
119
120 /** performs the pricing routine, gets the type of pricing that should be done: farkas or redcost pricing */
122 PricingType* pricetype, /**< type of the pricing */
123 SCIP_RESULT* result, /**< result pointer */
124 double* lowerbound /**< lower bound of pricingproblems */
125 );
126
127 /** creates a new master variable corresponding to the given solution and problem */
129 PricingType* pricetype, /**< type of the pricing */
130 SCIP_SOL* sol, /**< solution to compute reduced cost for */
131 SCIP_VAR** solvars, /**< array of variables with non-zero value in the solution of the pricing problem */
132 double* solvals, /**< array of values in the solution of the pricing problem for variables in array solvars*/
133 int nsolvars, /**< number of variables in array solvars */
134 unsigned int solisray, /**< is the solution a ray? */
135 int prob, /**< number of the pricing problem the solution belongs to */
136 unsigned int force, /**< should the given variable be added also if it has non-negative reduced cost? */
137 unsigned int* added, /**< pointer to store whether the variable was successfully added */
138 SCIP_VAR** addedvar /**< pointer to store the created variable */
139 );
140
141 /** creates a new master variable corresponding to the given gcg column */
143 PricingType* pricetype, /**< type of pricing */
144 GCG_COL* gcgcol, /**< GCG column data structure */
145 SCIP_Bool force, /**< should the given variable be added also if it has non-negative reduced cost? */
146 SCIP_Bool* added, /**< pointer to store whether the variable was successfully added */
147 SCIP_VAR** addedvar, /**< pointer to store the created variable */
148 SCIP_Real score /**< score of column (or -1.0 if not specified) */
149 );
150
151 /* Compute difference of two dual solutions */
153 SCIP_Real** dualvals1, /**< array of dual values for each pricing problem */
154 SCIP_Real* dualconv1, /**< array of dual solutions for the convexity constraints */
155 SCIP_Real** dualvals2, /**< array of dual values for each pricing problem */
156 SCIP_Real* dualconv2, /**< array of dual solutions for the convexity constraints */
157 SCIP_Real* dualdiff /**< pointer to store difference of duals solutions */
158 );
159
160 /** the pricing loop: solve the pricing problems */
162 PricingType* pricetype, /**< type of pricing */
163 SCIP_RESULT* result, /**< result pointer */
164 int* nfoundvars, /**< pointer to store number of found variables */
165 SCIP_Real* lowerbound, /**< pointer to store lowerbound obtained due to lagrange bound */
166 SCIP_Bool* bestredcostvalid /**< pointer to store if bestredcost are valid (pp solvedoptimal) */
167 );
168
170 {
171 return farkaspricing;
172 }
173
175 {
176 return farkaspricing;
177 }
178
180 {
181 return reducedcostpricing;
182 }
183
185 {
186 return reducedcostpricing;
187 }
188
190 {
191 return origprob;
192 }
193
194 GCG* getGcg() const
195 {
196 return gcg;
197 }
198
199 /** get the number of columns to be added to the master LP in the current pricing round */
200 int getMaxColsRound() const;
201
202 /** get the number of columns per pricing problem to be added to the master LP in the current pricing round */
203 int getMaxColsProb() const;
204
205 /** add artificial vars */
207
208 /** create the pointers for the pricing types */
210
211 /** create the pricing controller */
213
214 /** create the pointers for the stabilization */
215 void createStabilization();
216
217 /** create the pointers for the colpool */
219
220 /** create the pointers for the pricestore */
222
223 /** add a new column to the pricer's column buffer that will be added to the pricing storage */
225 GCG_COL* col, /**< priced col */
226 SCIP_Bool* added /**< pointer to var that indicates whether the col was added */
227 );
228
229 /** for each pricing problem, get the best found column from the pricing storage */
230 void getBestCols(
231 GCG_COL** pricingprobcols /**< array to be filled with best column per pricing problem */
232 );
233
234 /** get the sum over the dual values of convexity constraints */
236 GCG_COL** bestcols /**< best columns found per pricing problem */
237 );
238
239 /* computes the objective value of the current (stabilized) dual variables) in the dual program */
241 PricingType* pricetype, /**< type of pricing */
242 SCIP_Real* stabdualval, /**< pointer to store stabilized dual objective value */
243 SCIP_Bool stabilize /**< stabilize? */
244 );
245
247 PricingType* pricetype, /**< type of pricing */
248 GCG_Col* gcgcol, /**< gcg column to compute reduced cost for */
249 SCIP_Real* objvalptr /**< pointer to store the computed objective value */
250 ) const;
251
252 /** compute master coefficients of column */
254 GCG_COL* gcgcol /**< GCG column data structure */
255 );
256
257 /** compute original separator master cut coefficients of column */
259 GCG_COL* gcgcol /**< GCG column data structure */
260 );
261
262 /** compute mastersepacut coefficients of column */
264 GCG_COL* gcgcol /**< GCG column data structure */
265 );
266
267 /** add variable with computed coefficients to the original separator cuts */
269 SCIP_VAR* newvar, /**< The new variable to add */
270 GCG_COL* gcgcol /**< GCG column data structure */
271 );
272
273 /** add variable with computed coefficients to the separator master cuts */
275 SCIP_VAR* newvar, /**< The new variable to add */
276 int prob, /**< number of the pricing problem the solution belongs to */
277 SCIP_VAR** solvars, /**< array of variables with non-zero value in the solution of the pricing problem */
278 SCIP_Real* solvals, /**< array of values in the solution of the pricing problem for variables in array solvars*/
279 int nsolvars /**< number of variables in array solvars */
280 );
281
282 GCG_SOLVER** getSolvers() const;
283
284 int getNumSolvers() const;
285
286private:
287 ReducedCostPricing* reducedcostpricing;
288 FarkasPricing* farkaspricing;
289 PricingType* pricingtype; /**< current pricing type, or NULL if we are not in pricing */
290 Pricingcontroller* pricingcontroller;
291 Stabilization* stabilization;
292
293 /** free pricing problems */
294 SCIP_RETCODE freePricingProblems();
295
296 SCIP_Real computeRedCost(
297 PricingType* pricetype, /**< type of pricing */
298 SCIP_SOL* sol, /**< solution to compute reduced cost for */
299 SCIP_Bool solisray, /**< is the solution a ray? */
300 int prob, /**< number of the pricing problem the solution belongs to */
301 SCIP_Real* objvalptr /**< pointer to store the computed objective value */
302 ) const;
303
304 /** for given columns, (re-)compute and update their reduced costs */
305 void updateRedcosts(
306 PricingType* pricetype, /**< type of pricing */
307 GCG_COL** cols, /**< columns to compute reduced costs for */
308 int ncols /**< number of columns */
309 ) const;
310
311 /** return TRUE or FALSE whether the master LP is solved to optimality */
312 SCIP_Bool isMasterLPOptimal() const;
313
314 /** ensures size of pricedvars array */
315 SCIP_RETCODE ensureSizePricedvars(
316 int size /**< needed size */
317 );
318
319 /** adds new variable to the end of the priced variables array */
320 SCIP_RETCODE addVariableToPricedvars(
321 SCIP_VAR* newvar /**< variable to add */
322 );
323
324 /** ensures size of root bounds arrays */
325 SCIP_RETCODE ensureSizeRootBounds(
326 int size /**< needed size */
327 );
328
329 /** adds new bounds to the bound arrays as well as some additional information on dual variables and root lp solution */
330 SCIP_RETCODE addRootBounds(
331 SCIP_Real primalbound, /**< new primal bound for the root master LP */
332 SCIP_Real dualbound /**< new dual bound for the root master LP */
333 );
334
335 /** add master variable to all constraints */
336 SCIP_RETCODE addVariableToMasterconstraints(
337 SCIP_VAR* newvar, /**< The new variable to add */
338 int prob, /**< number of the pricing problem the solution belongs to */
339 SCIP_VAR** solvars, /**< array of variables with non-zero value in the solution of the pricing problem */
340 SCIP_Real* solvals, /**< array of values in the solution of the pricing problem for variables in array solvars*/
341 int nsolvars /**< number of variables in array solvars */
342 );
343
344 /** add master variable to all constraints */
345 SCIP_RETCODE addVariableToMasterconstraintsFromGCGCol(
346 SCIP_VAR* newvar, /**< The new variable to add */
347 GCG_COL* gcgcol /**< GCG column data structure */
348 );
349
350 /** add variable with computed coefficients to the original separator master cuts */
351 SCIP_RETCODE addVariableToOriginalSepaCuts(
352 SCIP_VAR* newvar, /**< The new variable to add */
353 int prob, /**< number of the pricing problem the solution belongs to */
354 SCIP_VAR** solvars, /**< array of variables with non-zero value in the solution of the pricing problem */
355 SCIP_Real* solvals, /**< array of values in the solution of the pricing problem for variables in array solvars*/
356 int nsolvars /**< number of variables in array solvars */
357 );
358
359 /** add variable with computed coefficients to the original separator master cuts */
360 SCIP_RETCODE addVariableToOriginalSepaCutsFromGCGCol(
361 SCIP_VAR* newvar, /**< The new variable to add */
362 GCG_COL* gcgcol /**< GCG column data structure */
363 );
364
365 /** add variable to the extended master conss */
366 SCIP_RETCODE addVariableToExtendedmastercons(
367 SCIP_VAR* newvar /**< The new variable to add */
368 );
369
370 /**
371 * check whether pricing can be aborted:
372 * if objective value is always integral and the current node's current
373 * lowerbound rounded up equals the current lp objective value rounded
374 * up we don't need to continue pricing since the best possible feasible
375 * solution must have at least this value
376 */
377 SCIP_Bool canPricingBeAborted() const;
378
379 /** sorts pricing problems according to their score */
380 void sortPricingProblemsByScore() const;
381
382 /** returns the gegeneracy of the masterproblem */
383 SCIP_RETCODE computeCurrentDegeneracy(
384 double* degeneracy /**< pointer to store degeneracy */
385 );
386
387 /** set subproblem memory limit */
388 SCIP_RETCODE setPricingProblemMemorylimit(
389 SCIP* pricingscip /**< SCIP of the pricingproblem */
390 );
391
392#ifdef SCIP_DISABLED_CODE
393 /** generic method to generate feasible columns from the pricing problem
394 * @note This method has to be threadsafe!
395 */
396 SCIP_RETCODE generateColumnsFromPricingProblem(
397 GCG_PRICINGJOB* pricingjob, /**< pricing job to be performed */
398 PricingType* pricetype, /**< type of pricing: reduced cost or Farkas */
399 int maxcols /**< size of the cols array to indicate maximum columns */
400 );
401
402 /** solves a specific pricing problem
403 * @todo simplify
404 * @note This method has to be threadsafe!
405 */
406 SCIP_RETCODE solvePricingProblem(
407 GCG_PRICINGJOB* pricingjob, /**< pricing job to be performed */
408 PricingType* pricetype, /**< type of pricing: reduced cost or Farkas */
409 int maxcols /**< size of the cols array to indicate maximum columns */
410 );
411#endif
412
413 /** perform a pricing job, i.e. apply the corresponding solver to the pricing problem
414 * @note This method has to be threadsafe!
415 */
416 SCIP_RETCODE performPricingjob(
417 GCG_PRICINGJOB* pricingjob, /**< pricing job */
418 PricingType* pricetype, /**< type of pricing: reduced cost or Farkas */
419 GCG_PRICINGSTATUS* status, /**< pointer to store pricing status */
420 SCIP_Real* lowerbound /**< pointer to store the obtained lower bound */
421 );
422
423 /** frees all solvers */
424 SCIP_RETCODE solversFree();
425
426 /** calls the init method on all solvers */
427 SCIP_RETCODE solversInit();
428
429 /** calls the exit method on all solvers */
430 SCIP_RETCODE solversExit();
431
432 /** calls the initsol method on all solvers */
433 SCIP_RETCODE solversInitsol();
434
435 /** calls the exitsol method of all solvers */
436 SCIP_RETCODE solversExitsol();
437
438 /** frees all pricing callback plugins */
439 SCIP_RETCODE pricingcbsFree();
440
441 /** calls the init method on all pricing callback plugins */
442 SCIP_RETCODE pricingcbsInit();
443
444 /** calls the exit method on all pricing callback plugins */
445 SCIP_RETCODE pricingcbsExit();
446
447 /** calls the initsol method on all pricing callback plugins */
448 SCIP_RETCODE pricingcbsInitsol();
449
450 /** calls the exitsol method of all pricing callback plugins */
451 SCIP_RETCODE pricingcbsExitsol();
452
453 /** calls pre-pricing method of the pricing callback plugins */
454 SCIP_RETCODE pricingcbsPrepricing(
455 SCIP_PRICER* pricer, /**< the pointer to the calling pricer */
456 GCG_PRICETYPE type, /**< the type of pricing, either redcost or farkas */
457 SCIP_Bool* abort /**< flag to set whether the pricing should be aborted */
458 );
459
460 /** calls post-pricing method of the pricing callback plugins */
461 SCIP_RETCODE pricingcbsPostpricing(
462 SCIP_PRICER* pricer, /**< the pointer to the calling pricer */
463 GCG_PRICETYPE type /**< the type of pricing, either redcost or farkas */
464 );
465
466 /** add bounds change from constraint from the pricing problem at this node
467 * @note This method has to be threadsafe!
468 */
469 SCIP_RETCODE addBranchingBoundChangesToPricing(
470 int prob, /**< index of pricing problem */
471 SCIP_CONS* branchcons /**< branching constraints from which bound should applied */
472 ) const;
473
474 SCIP_RETCODE checkBranchingBoundChanges(
475 int prob, /**< index of pricing problem */
476 SCIP_SOL* sol, /**< solution to check */
477 SCIP_CONS* branchcons, /**< branching constraints from which bound should applied */
478 SCIP_Bool* feasible /**< check whether the solution is feasible */
479 ) const;
480
481 /** check bounds change from constraint from the pricing problem at this node
482 * @note This method has to be threadsafe!
483 */
484 SCIP_RETCODE checkBranchingBoundChangesGcgCol(
485 GCG_COL* gcgcol, /**< gcg column to check */
486 SCIP_CONS* branchcons, /**< branching constraints from which bound should applied */
487 SCIP_Bool* feasible /**< check whether the solution is feasible */
488 ) const;
489
490 SCIP_RETCODE ensureSizeArtificialvars(
491 int size /**< needed size */
492 );
493
494 /** activates all pricing modifications */
495 SCIP_RETCODE activatePricingModifications(
496 GCG_EXTENDEDMASTERCONSDATA* extendedmasterconsdata, /**< extended master cons data */
497 SCIP_Bool apply /**< should the modifications actually be activated */
498 );
499
500};
501
502#endif
virtual ~ObjPricerGcg()
SCIP_RETCODE createPricingcontroller()
SCIP_RETCODE computeColOriginalSepaCuts(GCG_COL *gcgcol)
SCIP_RETCODE priceColumnPoolOld(PricingType *pricetype, int *pnfoundvars)
GCG * getGcg() const
SCIP_RETCODE priceNewVariables(PricingType *pricetype, SCIP_RESULT *result, double *lowerbound)
const ReducedCostPricing * getReducedCostPricing() const
SCIP_Real computeRedCostGcgCol(PricingType *pricetype, GCG_Col *gcgcol, SCIP_Real *objvalptr) const
int getMaxColsRound() const
int getMaxColsProb() const
GCG_SOLVER ** getSolvers() const
void updateRedcostColumnPool(PricingType *pricetype)
void getBestCols(GCG_COL **pricingprobcols)
virtual SCIP_DECL_PRICERINIT(scip_init)
int getNumSolvers() const
SCIP_RETCODE createNewMasterVarFromGcgCol(PricingType *pricetype, GCG_COL *gcgcol, SCIP_Bool force, SCIP_Bool *added, SCIP_VAR **addedvar, SCIP_Real score)
virtual SCIP_DECL_PRICEREXIT(scip_exit)
SCIP_RETCODE createPricingTypes()
ReducedCostPricing * getReducedCostPricingNonConst()
SCIP_RETCODE createNewMasterVar(PricingType *pricetype, SCIP_SOL *sol, SCIP_VAR **solvars, double *solvals, int nsolvars, unsigned int solisray, int prob, unsigned int force, unsigned int *added, SCIP_VAR **addedvar)
ObjPricerGcg(GCG *gcgstruct, const char *name, const char *desc, int priority, unsigned int delay, SCIP_PRICERDATA *p_pricerdata)
SCIP_PRICERDATA * pricerdata
const FarkasPricing * getFarkasPricing() const
virtual SCIP_DECL_PRICEREXITSOL(scip_exitsol)
SCIP_RETCODE addArtificialVars()
SCIP_RETCODE getStabilizedDualObjectiveValue(PricingType *pricetype, SCIP_Real *stabdualval, SCIP_Bool stabilize)
SCIP_RETCODE createColpool()
SCIP_PRICERDATA * getPricerdata()
SCIP_RETCODE createPricestore()
SCIP_RETCODE setPricingObjs(PricingType *pricetype, SCIP_Bool stabilize)
SCIP_Real getDualconvsum(GCG_COL **bestcols)
virtual SCIP_DECL_PRICERFARKAS(scip_farkas)
virtual SCIP_DECL_PRICERFREE(scip_free)
GCG_PRICESTORE * pricestore
SCIP * getOrigprob() const
GCG_COLPOOL * colpool
SCIP_RETCODE pricingLoop(PricingType *pricetype, SCIP_RESULT *result, int *nfoundvars, SCIP_Real *lowerbound, SCIP_Bool *bestredcostvalid)
SCIP_RETCODE addColToPricestore(GCG_COL *col, SCIP_Bool *added)
SCIP_RETCODE computeDualDiff(SCIP_Real **dualvals1, SCIP_Real *dualconv1, SCIP_Real **dualvals2, SCIP_Real *dualconv2, SCIP_Real *dualdiff)
virtual SCIP_DECL_PRICERINITSOL(scip_initsol)
SCIP_Real getConvconsDualsol(PricingType *pricetype, int probnr)
virtual SCIP_DECL_PRICERREDCOST(scip_redcost)
FarkasPricing * getFarkasPricingNonConst()
SCIP_RETCODE addVariableToMastersepacutsFromGCGCol(SCIP_VAR *newvar, GCG_COL *gcgcol)
SCIP_RETCODE addVariableToMastersepacuts(SCIP_VAR *newvar, int prob, SCIP_VAR **solvars, SCIP_Real *solvals, int nsolvars)
void createStabilization()
SCIP_RETCODE computeColMastersepacutCoeffs(GCG_COL *gcgcol)
SCIP_RETCODE computeColMastercoefs(GCG_COL *gcgcol)
pricing controller managing the pricing strategy
abstraction for SCIP pricing types
class with functions for dual variable smoothing
#define SCIP_Bool
#define SCIP_Real
* result
SCIP_SOL * sol
methods for storing priced cols (based on SCIP's separation storage)
public methods for storing cols in a col pool
public methods for working with gcg columns
type definitions for branching rules in GCG projects
struct GCG_Colpool GCG_COLPOOL
struct SCIP_Cons SCIP_CONS
struct GCG_ExtendedMasterConsData GCG_EXTENDEDMASTERCONSDATA
struct Gcg GCG
Definition type_gcg.h:44
struct GCG_Col GCG_COL
Definition type_gcgcol.h:44
struct SCIP_Pricer SCIP_PRICER
struct SCIP_PricerData SCIP_PRICERDATA
struct GCG_PriceStore GCG_PRICESTORE
enum GCG_Pricetype GCG_PRICETYPE
struct GCG_PricingJob GCG_PRICINGJOB
enum GCG_PricingStatus GCG_PRICINGSTATUS
enum SCIP_Result SCIP_RESULT
enum SCIP_Retcode SCIP_RETCODE
struct Scip SCIP
struct SCIP_Sol SCIP_SOL
struct GCG_Solver GCG_SOLVER
Definition type_solver.h:51
struct SCIP_Var SCIP_VAR