Scippy

GCG

Branch-and-Price & Column Generation for Everyone

gcgheur.c
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 gcgheur.c
29  * @brief public methods for GCG heuristics
30  * @author Christian Puchert
31  */
32 
33 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
34 
35 #include "gcg.h"
36 #include "pub_gcgheur.h"
37 
38 
39 /** resets the parameters to their default value */
40 static
41 SCIP_RETCODE setHeuristicsDefault(
42  SCIP* scip /**< SCIP data structure */
43  )
44 {
45  assert(scip != NULL);
46 
47  /* set specific parameters for LNS heuristics */
48  SCIP_CALL( SCIPresetParam(scip, "heuristics/gcgrens/nodesofs") );
49  SCIP_CALL( SCIPresetParam(scip, "heuristics/gcgrens/minfixingrate") );
50  SCIP_CALL( SCIPresetParam(scip, "heuristics/gcgrins/nodesofs") );
51  SCIP_CALL( SCIPresetParam(scip, "heuristics/gcgrins/minfixingrate") );
52  SCIP_CALL( SCIPresetParam(scip, "heuristics/xpcrossover/nodesofs") );
53  SCIP_CALL( SCIPresetParam(scip, "heuristics/xpcrossover/minfixingrate") );
54  SCIP_CALL( SCIPresetParam(scip, "heuristics/xprins/nodesofs") );
55  SCIP_CALL( SCIPresetParam(scip, "heuristics/xprins/minfixingrate") );
56 
57  return SCIP_OKAY;
58 }
59 
60 /** sets the parameters to aggressive values */
61 static
63  SCIP* scip /**< SCIP data structure */
64  )
65 {
66  assert(scip != NULL);
67 
68  /* set specific parameters for GCG RENS heuristic, if the heuristic is included */
69 #ifndef NDEBUG
70  if( SCIPfindHeur(scip, "gcgrens") != NULL )
71 #endif
72  {
73  SCIP_CALL( SCIPsetLongintParam(scip, "heuristics/gcgrens/nodesofs", (SCIP_Longint)2000) );
74  SCIP_CALL( SCIPsetRealParam(scip, "heuristics/gcgrens/minfixingrate", 0.3) );
75  }
76 
77  /* set specific parameters for GCG RINS heuristic, if the heuristic is included */
78 #ifndef NDEBUG
79  if( SCIPfindHeur(scip, "gcgrins") != NULL )
80 #endif
81  {
82  SCIP_CALL( SCIPsetIntParam(scip, "heuristics/gcgrins/nodesofs", 2000) );
83  SCIP_CALL( SCIPsetRealParam(scip, "heuristics/gcgrins/minfixingrate", 0.3) );
84  }
85 
86  /* set specific parameters for XP Crossover heuristic, if the heuristic is included */
87 #ifndef NDEBUG
88  if( SCIPfindHeur(scip, "xpcrossover") != NULL )
89 #endif
90  {
91  SCIP_CALL( SCIPsetLongintParam(scip, "heuristics/xpcrossover/nodesofs", (SCIP_Longint)2000) );
92  SCIP_CALL( SCIPsetRealParam(scip, "heuristics/xpcrossover/minfixingrate", 0.3) );
93  }
94 
95  /* set specific parameters for XP RINS heuristic, if the heuristic is included */
96 #ifndef NDEBUG
97  if( SCIPfindHeur(scip, "xprins") != NULL )
98 #endif
99  {
100  SCIP_CALL( SCIPsetLongintParam(scip, "heuristics/xprins/nodesofs", (SCIP_Longint)2000) );
101  SCIP_CALL( SCIPsetRealParam(scip, "heuristics/xprins/minfixingrate", 0.3) );
102  }
103 
104  return SCIP_OKAY;
105 }
106 
107 /** sets the parameters to fast values */
108 static
109 SCIP_RETCODE setHeuristicsFast(
110  SCIP* scip /**< SCIP data structure */
111  )
112 {
113  char paramname[SCIP_MAXSTRLEN];
114  int i;
115 
116 #define NEXPENSIVEHEURS 11
117  static const char* const expensiveheurs[NEXPENSIVEHEURS] = {
118  "gcgcoefdiving",
119  "gcgfeaspump",
120  "gcgfracdiving",
121  "gcgguideddiving",
122  "gcglinesdiving",
123  "gcgpscostdiving",
124  "gcgrens",
125  "gcgrins",
126  "gcgveclendiving",
127  "xpcrossover",
128  "xprins"
129  };
130 
131  assert(scip != NULL);
132 
133  SCIP_CALL( setHeuristicsDefault(scip) );
134 
135  /* explicitly turn off expensive heuristics, if included */
136  for( i = 0; i < NEXPENSIVEHEURS; ++i )
137  {
138  (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "heuristics/%s/freq", expensiveheurs[i]);
139  SCIP_CALL( SCIPsetIntParam(scip, paramname, -1) );
140  }
141 
142  return SCIP_OKAY;
143 }
144 
145 /** sets heuristic parameters values to
146  *
147  * - SCIP_PARAMSETTING_DEFAULT which are the default values of all heuristic parameters
148  * - SCIP_PARAMSETTING_FAST such that the time spend for heuristic is decreased
149  * - SCIP_PARAMSETTING_AGGRESSIVE such that the heuristic are called more aggregative
150  * - SCIP_PARAMSETTING_OFF which turns off all heuristics
151  */
152 SCIP_RETCODE GCGsetHeuristics(
153  SCIP* scip, /**< SCIP data structure */
154  SCIP_PARAMSETTING paramsetting /**< parameter settings */
155  )
156 {
157  assert(paramsetting == SCIP_PARAMSETTING_DEFAULT || paramsetting == SCIP_PARAMSETTING_FAST
158  || paramsetting == SCIP_PARAMSETTING_AGGRESSIVE || paramsetting == SCIP_PARAMSETTING_OFF);
159 
160  switch( paramsetting )
161  {
162  case SCIP_PARAMSETTING_AGGRESSIVE:
163  SCIP_CALL( setHeuristicsAggressive(scip) );
164  break;
165  case SCIP_PARAMSETTING_OFF:
166  break;
167  case SCIP_PARAMSETTING_FAST:
168  SCIP_CALL( setHeuristicsFast(scip) );
169  break;
170  case SCIP_PARAMSETTING_DEFAULT:
171  SCIP_CALL( setHeuristicsDefault(scip) );
172  break;
173  default:
174  SCIPerrorMessage("The given paramsetting is invalid!\n");
175  break;
176  }
177 
178  return SCIP_OKAY;
179 }
static SCIP_RETCODE setHeuristicsDefault(SCIP *scip)
Definition: gcgheur.c:41
GCG interface methods.
#define NEXPENSIVEHEURS
static SCIP_RETCODE setHeuristicsFast(SCIP *scip)
Definition: gcgheur.c:109
public methods for GCG heuristics
SCIP_RETCODE GCGsetHeuristics(SCIP *scip, SCIP_PARAMSETTING paramsetting)
Definition: gcgheur.c:152
static SCIP_RETCODE setHeuristicsAggressive(SCIP *scip)
Definition: gcgheur.c:62