GCG 4.1.1 (dev)

Generic Column Generation

Loading...
Searching...
No Matches
heur_mastervecldiving.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_mastervecldiving.c
30 * @brief master LP diving heuristic that rounds variables with long column vectors
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 "mastervecldiving"
45#define HEUR_DESC "master LP diving heuristic that rounds variables with long column vectors"
46#define HEUR_DISPCHAR 'v'
47#define HEUR_PRIORITY -1003100
48#define HEUR_FREQ 10
49#define HEUR_FREQOFS 4
50#define HEUR_MAXDEPTH -1
51
52
53/*
54 * Callback methods
55 */
56
57
58/** variable selection method of diving heuristic;
59 * finds best candidate variable w.r.t. vector length:
60 * - round variables in direction where objective value gets worse; for zero objective coefficient, round upwards
61 * - round variable with least objective value deficit per row the variable appears in
62 * (we want to "fix" as many rows as possible with the least damage to the objective function)
63 */
64static
65GCG_DECL_MASTER_DIVINGSELECTVAR(heurSelectVarMastervecldiving) /*lint --e{715}*/
66{ /*lint --e{715}*/
72 int c;
74
75 /* check preconditions */
77 assert(heur != NULL);
78 assert(bestcand != NULL);
80
81 /* get fractional variables that should be integral */
86
89
90 /* get best candidate */
91 for( c = 0; c < nlpcands; ++c )
92 {
94
96 SCIP_Real objdelta;
98 SCIP_Real score;
99 int colveclen;
100
101 int i;
102
103 var = lpcands[c];
104
105 /* if the variable is on the tabu list, do not choose it */
106 for( i = 0; i < tabulistsize; ++i )
107 if( tabulist[i] == var )
108 break;
109 if( i < tabulistsize )
110 continue;
111
112 frac = lpcandsfrac[c];
114 objdelta = (1.0 - frac) * obj;
115
117
118 /* check whether the variable is roundable */
120
121 /* smaller score is better */
122 score = (objdelta + SCIPsumepsilon(masterprob))/((SCIP_Real)colveclen+1.0);
123
124 /* penalize negative scores (i.e. improvements in the objective) */
125 if( score <= 0.0 )
126 score *= 100.0;
127
128 /* prefer decisions on binary variables */
130 score *= 1000.0;
131
132 /* check, if candidate is new best candidate */
133 if( score < bestscore )
134 {
135 *bestcand = var;
136 bestscore = score;
137 }
138 }
139
140 return SCIP_OKAY;
141}
142
143
144/*
145 * heuristic specific interface methods
146 */
147
148/** creates the mastervecldiving heuristic and includes it in GCG */
150 GCG* gcg /**< GCG data structure */
151 )
152{
153 SCIP_HEUR* heur;
154
155 /* include diving heuristic */
158 HEUR_MAXDEPTH, NULL, NULL, NULL, NULL, NULL, NULL, NULL, heurSelectVarMastervecldiving, NULL) );
159
160 assert(heur != NULL);
161
162 return SCIP_OKAY;
163}
164
#define SCIP_REAL_MAX
#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)
int SCIPcolGetNNonz(SCIP_COL *col)
SCIP_Real SCIPsumepsilon(SCIP *scip)
SCIP_COL * SCIPvarGetCol(SCIP_VAR *var)
SCIP_Bool SCIPvarMayRoundUp(SCIP_VAR *var)
SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
SCIP_Bool SCIPvarMayRoundDown(SCIP_VAR *var)
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
SCIP_VARTYPE SCIPvarGetType(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 frac
int i
SCIP_Real bestscore
SCIP_Real * lpcandsfrac
SCIP_Real obj
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 GCGincludeHeurMastervecldiving(GCG *gcg)
master LP diving heuristic that rounds variables with long column vectors
#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
SCIP_VARTYPE_BINARY
SCIP_VARSTATUS_COLUMN