GCG 4.1.1 (dev)

Generic Column Generation

Loading...
Searching...
No Matches
heur_masterlinesdiving.c
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 heur_masterlinesdiving.c
30 * @brief LP diving heuristic that fixes variables with a large difference to their root solution
31 * @author Tobias Achterberg
32 * @author Christian Puchert
33 */
34
35/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
36
37#include <assert.h>
38#include <string.h>
39
42
43
44#define HEUR_NAME "masterlinesdiving"
45#define HEUR_DESC "master LP diving heuristic that chooses fixings following the line from root solution to current solution"
46#define HEUR_DISPCHAR 'l'
47#define HEUR_PRIORITY -1006000
48#define HEUR_FREQ 10
49#define HEUR_FREQOFS 6
50#define HEUR_MAXDEPTH -1
51
52
53/*
54 * Callback methods
55 */
56
57/** variable selection method of diving heuristic;
58 * finds best candidate variable w.r.t. the root LP solution:
59 * - in the projected space of fractional variables, extend the line segment connecting the root solution and
60 * the current LP solution up to the point, where one of the fractional variables becomes integral
61 * - round this variable to the integral value
62 */
63static
64GCG_DECL_MASTER_DIVINGSELECTVAR(heurSelectVarMasterlinesdiving) /*lint --e{715}*/
65{ /*lint --e{715}*/
71 int c;
73
74 /* check preconditions */
76 assert(heur != NULL);
77 assert(bestcand != NULL);
79
80 /* get fractional variables that should be integral */
85
88
89 /* get best candidate */
90 for( c = 0; c < nlpcands; ++c )
91 {
94 SCIP_Real rootsolval;
95 SCIP_Real distquot;
96
97 int i;
98
99 var = lpcands[c];
101 rootsolval = SCIPvarGetRootSol(var);
102
103 /* if the variable is on the tabu list, do not choose it */
104 for( i = 0; i < tabulistsize; ++i )
105 if( tabulist[i] == var )
106 break;
107 if( i < tabulistsize )
108 continue;
109
110 if( SCIPisGT(masterprob, solval, rootsolval) )
111 {
112 distquot = (SCIPfeasCeil(masterprob, solval) - solval) / (solval - rootsolval);
113
114 /* avoid roundable candidates */
116 distquot *= 1000.0;
117 }
118 else
119 distquot = SCIPinfinity(masterprob);
120
121 /* check whether the variable is roundable */
123
124 /* check, if candidate is new best candidate */
125 if( distquot < bestdistquot )
126 {
127 *bestcand = var;
128 bestdistquot = distquot;
129 }
130 }
131
132 return SCIP_OKAY;
133}
134
135
136/*
137 * heuristic specific interface methods
138 */
139
140/** creates the masterlinesdiving heuristic and includes it in GCG */
142 GCG* gcg /**< GCG data structure */
143 )
144{
145 SCIP_HEUR* heur;
146
147 /* include diving heuristic */
150 HEUR_MAXDEPTH, NULL, NULL, NULL, NULL, NULL, NULL, NULL, heurSelectVarMasterlinesdiving, NULL) );
151
152 assert(heur != NULL);
153
154 return SCIP_OKAY;
155}
#define SCIP_Real
#define TRUE
SCIP * GCGgetMasterprob(GCG *gcg)
Definition gcg.cpp:99
SCIP_RETCODE SCIPgetLPBranchCands(SCIP *scip, SCIP_VAR ***lpcands, SCIP_Real **lpcandssol, SCIP_Real **lpcandsfrac, int *nlpcands, int *npriolpcands, int *nfracimplvars)
SCIP_Real SCIPinfinity(SCIP *scip)
SCIP_Real SCIPfeasCeil(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPvarMayRoundUp(SCIP_VAR *var)
SCIP_Bool SCIPvarMayRoundDown(SCIP_VAR *var)
SCIP_Real SCIPvarGetRootSol(SCIP_VAR *var)
* bestcandmayround
static assert(heur !=NULL)
SCIP_CALL(SCIPgetExternBranchCands(origprob, &lpcands, &lpcandssol, NULL, &nlpcands, NULL, NULL, NULL, NULL))
#define HEUR_FREQOFS
#define HEUR_DESC
#define HEUR_DISPCHAR
#define HEUR_MAXDEPTH
#define HEUR_PRIORITY
SCIP_Real * lpcandssol
#define HEUR_NAME
static SCIP_VAR ** lpcands
int nlpcands
#define HEUR_FREQ
SCIP_VAR * var
SCIP_Real solval
int i
SCIP_Real * lpcandsfrac
SCIP_Real bestdistquot
SCIP_RETCODE GCGincludeDivingHeurMaster(GCG *gcg, SCIP_HEUR **heur, const char *name, const char *desc, char dispchar, int priority, int freq, int freqofs, int maxdepth, GCG_DECL_MASTER_DIVINGFREE((*divingfree)), GCG_DECL_MASTER_DIVINGINIT((*divinginit)), GCG_DECL_MASTER_DIVINGEXIT((*divingexit)), GCG_DECL_MASTER_DIVINGINITSOL((*divinginitsol)), GCG_DECL_MASTER_DIVINGEXITSOL((*divingexitsol)), GCG_DECL_MASTER_DIVINGINITEXEC((*divinginitexec)), GCG_DECL_MASTER_DIVINGEXITEXEC((*divingexitexec)), GCG_DECL_MASTER_DIVINGSELECTVAR((*divingselectvar)), GCG_MASTER_DIVINGDATA *divingdata)
SCIP_VAR ** tabulist
primal heuristic interface for LP diving heuristics on the master variables
SCIP_RETCODE GCGincludeHeurMasterlinesdiving(GCG *gcg)
master LP diving heuristic that fixes variables with a large difference to their root solution
#define NULL
struct Gcg GCG
Definition type_gcg.h:44
struct SCIP_Heur SCIP_HEUR
#define GCG_DECL_MASTER_DIVINGSELECTVAR(x)
enum SCIP_Retcode SCIP_RETCODE
struct Scip SCIP
struct SCIP_Var SCIP_VAR