Scippy

GCG

Branch-and-Price & Column Generation for Everyone

pricer_gcg.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 pricer_gcg.h
29  * @brief GCG variable pricer
30  * @author Gerald Gamrath
31  * @author Martin Bergner
32  * @ingroup PRICERS
33  */
34 
35 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
36 
37 #ifndef GCG_PRICER_GCG__
38 #define GCG_PRICER_GCG__
39 
40 #include "scip/scip.h"
41 #include "type_solver.h"
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 /**@defgroup GCGPRICER GCG Variable Pricer
48  * @ingroup PRICING_PUB
49  * @{
50  */
51 
53 {
54  GCG_PRICETYPE_UNKNOWN = -1, /**< unknown pricing type */
55  GCG_PRICETYPE_INIT = 0, /**< initial pricing */
56  GCG_PRICETYPE_FARKAS = 1, /**< farkas pricing */
57  GCG_PRICETYPE_REDCOST = 2 /**< redcost pricing */
58 };
60 
61 
62 
63 /** creates the GCG variable pricer and includes it in SCIP */
64 extern
65 SCIP_RETCODE SCIPincludePricerGcg(
66  SCIP* scip, /**< SCIP data structure */
67  SCIP* origprob /**< SCIP data structure of the original problem */
68  );
69 
70 /** returns the pointer to the scip instance representing the original problem */
71 extern
73  SCIP* scip /**< SCIP data structure */
74  );
75 
76 /** returns the array of variables that were priced in during the solving process */
77 extern
78 SCIP_VAR** GCGmasterGetPricedvars(
79  SCIP* scip /**< SCIP data structure */
80  );
81 
82 /** returns the number of variables that were priced in during the solving process */
83 extern
85  SCIP* scip /**< SCIP data structure */
86  );
87 
88 /** adds the given constraint and the given position to the hashmap of the pricer */
89 extern
91  SCIP* scip, /**< SCIP data structure */
92  SCIP_CONS* cons, /**< the constraint that should be added */
93  int pos /**< the position of the constraint in the relaxator's masterconss array */
94  );
95 
96 /** sets the optimal LP solution in the pricerdata */
97 extern
98 SCIP_RETCODE GCGmasterSetRootLPSol(
99  SCIP* scip, /**< SCIP data structure */
100  SCIP_SOL** sol /**< pointer to optimal solution to root LP */
101  );
102 
103 #ifdef SCIP_STATISTIC
104 /** gets the optimal LP solution in the pricerdata */
105 extern
106 SCIP_SOL* GCGmasterGetRootLPSol(
107  SCIP* scip /**< SCIP data structure */
108  );
109 #endif
110 
111 /** includes a solver into the pricer data */
112 extern
113 SCIP_RETCODE GCGpricerIncludeSolver(
114  SCIP* scip, /**< SCIP data structure */
115  const char* name, /**< name of solver */
116  const char* desc, /**< description of solver */
117  int priority, /**< priority of solver */
118  SCIP_Bool heurenabled, /**< flag to indicate whether heuristic solving method of the solver is enabled */
119  SCIP_Bool exactenabled, /**< flag to indicate whether exact solving method of the solver is enabled */
120  GCG_DECL_SOLVERUPDATE((*solverupdate)), /**< update method for solver */
121  GCG_DECL_SOLVERSOLVE ((*solversolve)), /**< solving method for solver */
122  GCG_DECL_SOLVERSOLVEHEUR((*solveheur)), /**< heuristic solving method for solver */
123  GCG_DECL_SOLVERFREE ((*solverfree)), /**< free method of solver */
124  GCG_DECL_SOLVERINIT ((*solverinit)), /**< init method of solver */
125  GCG_DECL_SOLVEREXIT ((*solverexit)), /**< exit method of solver */
126  GCG_DECL_SOLVERINITSOL((*solverinitsol)), /**< initsol method of solver */
127  GCG_DECL_SOLVEREXITSOL((*solverexitsol)), /**< exitsol method of solver */
128  GCG_SOLVERDATA* solverdata /**< pricing solver data */
129  );
130 
131 
132 /** returns the available pricing solvers */
133 extern
135  SCIP* scip /**< SCIP data structure */
136  );
137 
138 /** returns the number of available pricing solvers */
139 extern
141  SCIP* scip /**< SCIP data structure */
142  );
143 
144 /** writes out a list of all pricing problem solvers */
145 extern
147  SCIP* scip /**< SCIP data structure */
148  );
149 
150 /** prints pricing solver statistics */
151 extern
153  SCIP* scip, /**< SCIP data structure */
154  FILE* file /**< output file */
155  );
156 
157 extern
159  SCIP* scip, /**< SCIP data structure */
160  FILE* file /**< output file */
161  );
162 
163 /** method to get existence of rays */
164 extern
165 SCIP_RETCODE GCGpricerExistRays(
166  SCIP* scip, /**< master SCIP data structure */
167  SCIP_Bool* exist /**< pointer to store if there exists any ray */
168  );
169 
170 /** get the number of extreme points that a pricing problem has generated so far */
171 extern
173  SCIP* scip, /**< master SCIP data structure */
174  int probnr /**< index of pricing problem */
175  );
176 
177 /** get the number of extreme rays that a pricing problem has generated so far */
178 extern
180  SCIP* scip, /**< master SCIP data structure */
181  int probnr /**< index of pricing problem */
182  );
183 
184 /** get the number of columns to be added to the master LP in the current pricing round */
185 extern
187  SCIP* scip /**< master SCIP data structure */
188  );
189 
190 /** get the number of columns per pricing problem to be added to the master LP in the current pricing round */
191 extern
193  SCIP* scip /**< master SCIP data structure */
194  );
195 
196 /** add a new column to the pricing storage */
197 extern
198 SCIP_RETCODE GCGpricerAddCol(
199  SCIP* scip, /**< SCIP data structure */
200  GCG_COL* col /**< priced col */
201  );
202 
203 /** transfers a primal solution of the original problem into the master variable space,
204  * i.e. creates one master variable for each block and adds the solution to the master problem */
205 extern
207  SCIP* scip, /**< SCIP data structure */
208  SCIP_SOL* origsol, /**< the solution that should be transferred */
209  SCIP_Bool* stored /**< pointer to store if transferred solution is feasible (or NULL) */
210  );
211 
212 /** create initial master variables */
213 extern
215  SCIP* scip /**< master SCIP data structure */
216  );
217 
218 /** get root node degeneracy */
219 extern
220 SCIP_Real GCGmasterGetDegeneracy(
221  SCIP* scip /**< SCIP data structure */
222  );
223 
224 /** return if artifical variables are used in current solution */
225 extern
227  SCIP* scip /**< SCIP data structure */
228  );
229 
230 extern
231 SCIP_Bool GCGmasterIsBestsolValid(
232  SCIP* scip /**< SCIP data structure */
233  );
234 
235 extern
236 SCIP_Bool GCGmasterIsSolValid(
237  SCIP* scip, /**< SCIP data structure */
238  SCIP_SOL* mastersol /**< solution of the master problem, or NULL for current LP solution */
239  );
240 
241 
242 /** get number of iterations in pricing problems */
243 extern
245  SCIP* scip /**< SCIP data structure */
246  );
247 
248 /** print simplex iteration statistics */
249 extern
250 SCIP_RETCODE GCGmasterPrintSimplexIters(
251  SCIP* scip, /**< SCIP data structure */
252  FILE* file /**< output file */
253  );
254 
255 /** set pricing objectives */
256 extern
257 SCIP_RETCODE GCGsetPricingObjs(
258  SCIP* scip, /**< SCIP data structure */
259  SCIP_Real* dualsolconv /**< array of dual solutions corresponding to convexity constraints */
260  );
261 
262 /** creates a new master variable corresponding to the given gcg column */
263 extern
265  SCIP* scip, /**< SCIP data structure */
266  SCIP_Bool infarkas, /**< in Farkas pricing? */
267  GCG_COL* gcgcol, /**< GCG column data structure */
268  SCIP_Bool force, /**< should the given variable be added also if it has non-negative reduced cost? */
269  SCIP_Bool* added, /**< pointer to store whether the variable was successfully added */
270  SCIP_VAR** addedvar, /**< pointer to store the created variable */
271  SCIP_Real score /**< score of column (or -1.0 if not specified) */
272 
273  );
274 
275 /** computes the reduced cost of a column */
276 extern
277 SCIP_Real GCGcomputeRedCostGcgCol(
278  SCIP* scip, /**< SCIP data structure */
279  SCIP_Bool infarkas, /**< in Farkas pricing? */
280  GCG_COL* gcgcol, /**< gcg column to compute reduced cost for */
281  SCIP_Real* objvalptr /**< pointer to store the computed objective value */
282  );
283 
284 
285 /** compute master and cut coefficients of column */
286 extern
287 SCIP_RETCODE GCGcomputeColMastercoefs(
288  SCIP* scip, /**< SCIP data structure */
289  GCG_COL* gcgcol /**< GCG column data structure */
290  );
291 
292 /**@} */
293 #ifdef __cplusplus
294 }
295 
296 #endif
297 
298 #endif
#define GCG_DECL_SOLVERSOLVEHEUR(x)
Definition: type_solver.h:133
int GCGpricerGetMaxColsProb(SCIP *scip)
SCIP_Longint GCGmasterGetPricingSimplexIters(SCIP *scip)
SCIP_Bool GCGmasterIsSolValid(SCIP *scip, SCIP_SOL *mastersol)
int GCGpricerGetNPointsProb(SCIP *scip, int probnr)
SCIP_RETCODE GCGmasterSetRootLPSol(SCIP *scip, SCIP_SOL **sol)
SCIP_Real GCGmasterGetDegeneracy(SCIP *scip)
GCG_SOLVER ** GCGpricerGetSolvers(SCIP *scip)
void GCGpricerPrintListOfSolvers(SCIP *scip)
@ GCG_PRICETYPE_UNKNOWN
Definition: pricer_gcg.h:54
#define GCG_DECL_SOLVERINITSOL(x)
Definition: type_solver.h:86
@ GCG_PRICETYPE_INIT
Definition: pricer_gcg.h:55
int GCGpricerGetNRaysProb(SCIP *scip, int probnr)
int GCGpricerGetMaxColsRound(SCIP *scip)
#define GCG_DECL_SOLVEREXIT(x)
Definition: type_solver.h:75
SCIP_RETCODE GCGmasterAddMasterconsToHashmap(SCIP *scip, SCIP_CONS *cons, int pos)
@ GCG_PRICETYPE_FARKAS
Definition: pricer_gcg.h:56
enum GCG_Pricetype GCG_PRICETYPE
Definition: pricer_gcg.h:59
SCIP_Bool GCGmasterIsBestsolValid(SCIP *scip)
SCIP_RETCODE GCGmasterTransOrigSolToMasterVars(SCIP *scip, SCIP_SOL *origsol, SCIP_Bool *stored)
type definitions for pricing problem solvers in GCG project
GCG_Pricetype
Definition: pricer_gcg.h:52
SCIP * GCGmasterGetOrigprob(SCIP *scip)
SCIP_RETCODE GCGpricerExistRays(SCIP *scip, SCIP_Bool *exist)
@ GCG_PRICETYPE_REDCOST
Definition: pricer_gcg.h:57
SCIP_RETCODE GCGpricerIncludeSolver(SCIP *scip, const char *name, const char *desc, int priority, SCIP_Bool heurenabled, SCIP_Bool exactenabled, GCG_DECL_SOLVERUPDATE((*solverupdate)), GCG_DECL_SOLVERSOLVE((*solversolve)), GCG_DECL_SOLVERSOLVEHEUR((*solveheur)), GCG_DECL_SOLVERFREE((*solverfree)), GCG_DECL_SOLVERINIT((*solverinit)), GCG_DECL_SOLVEREXIT((*solverexit)), GCG_DECL_SOLVERINITSOL((*solverinitsol)), GCG_DECL_SOLVEREXITSOL((*solverexitsol)), GCG_SOLVERDATA *solverdata)
void GCGpricerPrintPricingStatistics(SCIP *scip, FILE *file)
void GCGpricerPrintStatistics(SCIP *scip, FILE *file)
#define GCG_DECL_SOLVEREXITSOL(x)
Definition: type_solver.h:97
#define GCG_DECL_SOLVERFREE(x)
Definition: type_solver.h:59
int GCGmasterGetNPricedvars(SCIP *scip)
#define GCG_DECL_SOLVERINIT(x)
Definition: type_solver.h:67
SCIP_Bool GCGmasterIsCurrentSolValid(SCIP *scip)
SCIP_RETCODE GCGmasterCreateInitialMastervars(SCIP *scip)
SCIP_Real GCGcomputeRedCostGcgCol(SCIP *scip, SCIP_Bool infarkas, GCG_COL *gcgcol, SCIP_Real *objvalptr)
SCIP_RETCODE GCGpricerAddCol(SCIP *scip, GCG_COL *col)
#define GCG_DECL_SOLVERUPDATE(x)
Definition: type_solver.h:105
SCIP_RETCODE GCGcreateNewMasterVarFromGcgCol(SCIP *scip, SCIP_Bool infarkas, GCG_COL *gcgcol, SCIP_Bool force, SCIP_Bool *added, SCIP_VAR **addedvar, SCIP_Real score)
int GCGpricerGetNSolvers(SCIP *scip)
#define GCG_DECL_SOLVERSOLVE(x)
Definition: type_solver.h:119
SCIP_RETCODE GCGsetPricingObjs(SCIP *scip, SCIP_Real *dualsolconv)
SCIP_RETCODE GCGmasterPrintSimplexIters(SCIP *scip, FILE *file)
SCIP_RETCODE SCIPincludePricerGcg(SCIP *scip, SCIP *origprob)
SCIP_RETCODE GCGcomputeColMastercoefs(SCIP *scip, GCG_COL *gcgcol)
SCIP_VAR ** GCGmasterGetPricedvars(SCIP *scip)