Scippy

SCIP

Solving Constraint Integer Programs

heur_rens.c File Reference

Detailed Description

LNS heuristic that finds the optimal rounding to a given point.

Author
Timo Berthold

Definition in file heur_rens.c.

#include <assert.h>
#include <string.h>
#include <stdio.h>
#include "scip/scip.h"
#include "scip/heur_rens.h"
#include "scip/scipdefplugins.h"
#include "scip/cons_linear.h"
#include "scip/pub_misc.h"

Go to the source code of this file.

Macros

#define HEUR_NAME   "rens"
 
#define HEUR_DESC   "LNS exploring fractional neighborhood of relaxation's optimum"
 
#define HEUR_DISPCHAR   'E'
 
#define HEUR_PRIORITY   -1100000
 
#define HEUR_FREQ   0
 
#define HEUR_FREQOFS   0
 
#define HEUR_MAXDEPTH   -1
 
#define HEUR_TIMING   SCIP_HEURTIMING_AFTERLPNODE
 
#define HEUR_USESSUBSCIP   TRUE
 
#define DEFAULT_BINARYBOUNDS   TRUE /* should general integers get binary bounds [floor(.),ceil(.)] ? */
 
#define DEFAULT_MAXNODES   5000LL /* maximum number of nodes to regard in the subproblem */
 
#define DEFAULT_MINFIXINGRATE   0.5 /* minimum percentage of integer variables that have to be fixed */
 
#define DEFAULT_MINIMPROVE   0.01 /* factor by which RENS should at least improve the incumbent */
 
#define DEFAULT_MINNODES   50LL /* minimum number of nodes to regard in the subproblem */
 
#define DEFAULT_NODESOFS   500LL /* number of nodes added to the contingent of the total nodes */
 
#define DEFAULT_NODESQUOT   0.1 /* subproblem nodes in relation to nodes of the original problem */
 
#define DEFAULT_LPLIMFAC   2.0 /* factor by which the limit on the number of LP depends on the node limit */
 
#define DEFAULT_STARTSOL   'l' /* solution that is used for fixing values */
 
#define STARTSOL_CHOICES   "nl" /* possible values for startsol ('l'p relaxation, 'n'lp relaxation) */
 
#define DEFAULT_USELPROWS
 
#define DEFAULT_COPYCUTS
 
#define DEFAULT_EXTRATIME
 
#define DEFAULT_ADDALLSOLS   FALSE /* should all subproblem solutions be added to the original SCIP? */
 
#define DEFAULT_FULLSCALE
 
#define DEFAULT_BESTSOLLIMIT   -1 /* limit on number of improving incumbent solutions in sub-CIP */
 
#define DEFAULT_USEUCT   FALSE /* should uct node selection be used at the beginning of the search? */
 
#define EVENTHDLR_NAME   "Rens"
 
#define EVENTHDLR_DESC   "LP event handler for " HEUR_NAME " heuristic"
 

Functions

static SCIP_RETCODE computeFixingrate (SCIP *scip, SCIP_VAR **fixedvars, SCIP_Real *fixedvals, int *nfixedvars, int fixedvarssize, SCIP_Real minfixingrate, char *startsol, SCIP_Real *fixingrate, SCIP_Bool *success)
 
static SCIP_RETCODE restrictToBinaryBounds (SCIP *scip, SCIP *subscip, SCIP_VAR **subvars, char startsol)
 
static SCIP_RETCODE createNewSol (SCIP *scip, SCIP *subscip, SCIP_VAR **subvars, SCIP_HEUR *heur, SCIP_SOL *subsol, SCIP_Bool *success)
 
static SCIP_DECL_EVENTEXEC (eventExecRens)
 
SCIP_RETCODE SCIPapplyRens (SCIP *scip, SCIP_HEUR *heur, SCIP_RESULT *result, SCIP_Real minfixingrate, SCIP_Real minimprove, SCIP_Longint maxnodes, SCIP_Longint nstallnodes, char startsol, SCIP_Bool binarybounds, SCIP_Bool uselprows)
 
static SCIP_DECL_HEURCOPY (heurCopyRens)
 
static SCIP_DECL_HEURFREE (heurFreeRens)
 
static SCIP_DECL_HEURINIT (heurInitRens)
 
static SCIP_DECL_HEUREXEC (heurExecRens)
 
SCIP_RETCODE SCIPincludeHeurRens (SCIP *scip)
 

Macro Definition Documentation

◆ HEUR_NAME

#define HEUR_NAME   "rens"

Definition at line 33 of file heur_rens.c.

Referenced by SCIP_DECL_HEURCOPY(), SCIPapplyRens(), and SCIPincludeHeurRens().

◆ HEUR_DESC

#define HEUR_DESC   "LNS exploring fractional neighborhood of relaxation's optimum"

Definition at line 34 of file heur_rens.c.

Referenced by SCIPincludeHeurRens().

◆ HEUR_DISPCHAR

#define HEUR_DISPCHAR   'E'

Definition at line 35 of file heur_rens.c.

Referenced by SCIPincludeHeurRens().

◆ HEUR_PRIORITY

#define HEUR_PRIORITY   -1100000

Definition at line 36 of file heur_rens.c.

Referenced by SCIPincludeHeurRens().

◆ HEUR_FREQ

#define HEUR_FREQ   0

Definition at line 37 of file heur_rens.c.

Referenced by SCIPincludeHeurRens().

◆ HEUR_FREQOFS

#define HEUR_FREQOFS   0

Definition at line 38 of file heur_rens.c.

Referenced by SCIPincludeHeurRens().

◆ HEUR_MAXDEPTH

#define HEUR_MAXDEPTH   -1

Definition at line 39 of file heur_rens.c.

Referenced by SCIPincludeHeurRens().

◆ HEUR_TIMING

#define HEUR_TIMING   SCIP_HEURTIMING_AFTERLPNODE

Definition at line 40 of file heur_rens.c.

Referenced by SCIPincludeHeurRens().

◆ HEUR_USESSUBSCIP

#define HEUR_USESSUBSCIP   TRUE

does the heuristic use a secondary SCIP instance?

Definition at line 41 of file heur_rens.c.

Referenced by SCIPincludeHeurRens().

◆ DEFAULT_BINARYBOUNDS

#define DEFAULT_BINARYBOUNDS   TRUE /* should general integers get binary bounds [floor(.),ceil(.)] ? */

Definition at line 44 of file heur_rens.c.

Referenced by SCIPincludeHeurRens().

◆ DEFAULT_MAXNODES

#define DEFAULT_MAXNODES   5000LL /* maximum number of nodes to regard in the subproblem */

Definition at line 45 of file heur_rens.c.

Referenced by SCIPincludeHeurRens().

◆ DEFAULT_MINFIXINGRATE

#define DEFAULT_MINFIXINGRATE   0.5 /* minimum percentage of integer variables that have to be fixed */

Definition at line 46 of file heur_rens.c.

Referenced by SCIPincludeHeurRens().

◆ DEFAULT_MINIMPROVE

#define DEFAULT_MINIMPROVE   0.01 /* factor by which RENS should at least improve the incumbent */

Definition at line 47 of file heur_rens.c.

Referenced by SCIPincludeHeurRens().

◆ DEFAULT_MINNODES

#define DEFAULT_MINNODES   50LL /* minimum number of nodes to regard in the subproblem */

Definition at line 48 of file heur_rens.c.

Referenced by SCIPincludeHeurRens().

◆ DEFAULT_NODESOFS

#define DEFAULT_NODESOFS   500LL /* number of nodes added to the contingent of the total nodes */

Definition at line 49 of file heur_rens.c.

Referenced by SCIPincludeHeurRens().

◆ DEFAULT_NODESQUOT

#define DEFAULT_NODESQUOT   0.1 /* subproblem nodes in relation to nodes of the original problem */

Definition at line 50 of file heur_rens.c.

Referenced by SCIPincludeHeurRens().

◆ DEFAULT_LPLIMFAC

#define DEFAULT_LPLIMFAC   2.0 /* factor by which the limit on the number of LP depends on the node limit */

Definition at line 51 of file heur_rens.c.

Referenced by SCIPincludeHeurRens().

◆ DEFAULT_STARTSOL

#define DEFAULT_STARTSOL   'l' /* solution that is used for fixing values */

Definition at line 52 of file heur_rens.c.

Referenced by SCIPincludeHeurRens().

◆ STARTSOL_CHOICES

#define STARTSOL_CHOICES   "nl" /* possible values for startsol ('l'p relaxation, 'n'lp relaxation) */

Definition at line 53 of file heur_rens.c.

Referenced by SCIPincludeHeurRens().

◆ DEFAULT_USELPROWS

#define DEFAULT_USELPROWS
Value:
FALSE /* should subproblem be created out of the rows in the LP rows,
* otherwise, the copy constructors of the constraints handlers are used */
#define FALSE
Definition: def.h:64

Definition at line 54 of file heur_rens.c.

Referenced by SCIPincludeHeurRens().

◆ DEFAULT_COPYCUTS

#define DEFAULT_COPYCUTS
Value:
TRUE /* if DEFAULT_USELPROWS is FALSE, then should all active cuts from the cutpool
* of the original scip be copied to constraints of the subscip
*/
#define TRUE
Definition: def.h:63

Definition at line 56 of file heur_rens.c.

Referenced by SCIPincludeHeurRens().

◆ DEFAULT_EXTRATIME

#define DEFAULT_EXTRATIME
Value:
FALSE /* should the RENS sub-CIP get its own full time limit? This is only
* implemented for testing and not recommended to be used!
*/
#define FALSE
Definition: def.h:64

Definition at line 59 of file heur_rens.c.

Referenced by SCIPincludeHeurRens().

◆ DEFAULT_ADDALLSOLS

#define DEFAULT_ADDALLSOLS   FALSE /* should all subproblem solutions be added to the original SCIP? */

Definition at line 62 of file heur_rens.c.

Referenced by SCIPincludeHeurRens().

◆ DEFAULT_FULLSCALE

#define DEFAULT_FULLSCALE
Value:
FALSE /* should the RENS sub-CIP be solved with full-scale SCIP settings, including
* techniques that merely work on the dual bound, e.g., cuts? This is only
* implemented for testing and not recommended to be used!
*/
#define FALSE
Definition: def.h:64

Definition at line 64 of file heur_rens.c.

Referenced by SCIPincludeHeurRens().

◆ DEFAULT_BESTSOLLIMIT

#define DEFAULT_BESTSOLLIMIT   -1 /* limit on number of improving incumbent solutions in sub-CIP */

Definition at line 68 of file heur_rens.c.

Referenced by SCIPincludeHeurRens().

◆ DEFAULT_USEUCT

#define DEFAULT_USEUCT   FALSE /* should uct node selection be used at the beginning of the search? */

Definition at line 69 of file heur_rens.c.

Referenced by SCIPincludeHeurRens().

◆ EVENTHDLR_NAME

#define EVENTHDLR_NAME   "Rens"

Definition at line 72 of file heur_rens.c.

Referenced by SCIP_DECL_EVENTEXEC(), and SCIPapplyRens().

◆ EVENTHDLR_DESC

#define EVENTHDLR_DESC   "LP event handler for " HEUR_NAME " heuristic"

Definition at line 73 of file heur_rens.c.

Referenced by SCIPapplyRens().

Function Documentation

◆ computeFixingrate()

static SCIP_RETCODE computeFixingrate ( SCIP scip,
SCIP_VAR **  fixedvars,
SCIP_Real fixedvals,
int *  nfixedvars,
int  fixedvarssize,
SCIP_Real  minfixingrate,
char *  startsol,
SCIP_Real fixingrate,
SCIP_Bool success 
)
static

compute the number of initial fixings and check whether the fixing rate exceeds the minimum fixing rate

Parameters
scipSCIP data structure
fixedvarsarray to store source SCIP variables whose copies should be fixed in the sub-SCIP
fixedvalsarray to store solution values for variable fixing
nfixedvarspointer to store the number of fixed variables
fixedvarssizesize of the arrays to store fixing variables
minfixingratepercentage of integer variables that have to be fixed
startsolpointer to solution used for fixing values ('l'p relaxation, 'n'lp relaxation)
fixingratepercentage of integers that get actually fixed
successpointer to store whether minimum fixingrate is exceeded

Definition at line 113 of file heur_rens.c.

References FALSE, MAX, NULL, SCIP_CALL, SCIP_NLPPAR_VERBLEVEL, SCIP_NLPSOLSTAT_FEASIBLE, SCIP_NLPSOLSTAT_GLOBOPT, SCIP_NLPSOLSTAT_LOCOPT, SCIP_OKAY, SCIP_Real, SCIPdebug, SCIPdebugMsg, SCIPfloor(), SCIPgetNLPIntPar(), SCIPgetNLPSolstat(), SCIPgetVarsData(), SCIPisFeasIntegral(), SCIPisNLPConstructed(), SCIPsetNLPInitialGuessSol(), SCIPsetNLPIntPar(), SCIPsolveNLP(), SCIPvarGetLPSol(), SCIPvarGetNLPSol(), and TRUE.

Referenced by SCIPapplyRens().

◆ restrictToBinaryBounds()

static SCIP_RETCODE restrictToBinaryBounds ( SCIP scip,
SCIP subscip,
SCIP_VAR **  subvars,
char  startsol 
)
static

fixes bounds of unfixed integer variables to binary bounds

Parameters
sciporiginal SCIP data structure
subscipSCIP data structure for the subproblem
subvarsthe variables of the subproblem
startsolsolution used for fixing values ('l'p relaxation, 'n'lp relaxation)

Definition at line 226 of file heur_rens.c.

References NULL, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPchgVarLbGlobal(), SCIPchgVarUbGlobal(), SCIPfeasCeil(), SCIPfeasFloor(), SCIPgetVarsData(), SCIPisFeasEQ(), SCIPisFeasIntegral(), SCIPvarGetLbGlobal(), SCIPvarGetLPSol(), SCIPvarGetNLPSol(), and SCIPvarGetUbGlobal().

Referenced by SCIPapplyRens().

◆ createNewSol()

static SCIP_RETCODE createNewSol ( SCIP scip,
SCIP subscip,
SCIP_VAR **  subvars,
SCIP_HEUR heur,
SCIP_SOL subsol,
SCIP_Bool success 
)
static

creates a new solution for the original problem by copying the solution of the subproblem

Parameters
sciporiginal SCIP data structure
subscipSCIP structure of the subproblem
subvarsthe variables of the subproblem
heurRENS heuristic structure
subsolsolution of the subproblem
successused to store whether new solution was found or not

Definition at line 285 of file heur_rens.c.

References FALSE, NULL, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPcreateSol(), SCIPfreeBufferArray, SCIPgetNOrigVars(), SCIPgetSolVals(), SCIPgetVarsData(), SCIPsetSolVals(), SCIPtrySolFree(), and TRUE.

Referenced by SCIPapplyRens().

◆ SCIP_DECL_EVENTEXEC()

static SCIP_DECL_EVENTEXEC ( eventExecRens  )
static

◆ SCIP_DECL_HEURCOPY()

static SCIP_DECL_HEURCOPY ( heurCopyRens  )
static

copy method for primal heuristic plugins (called when SCIP copies plugins)

Definition at line 681 of file heur_rens.c.

References HEUR_NAME, NULL, SCIP_CALL, SCIP_OKAY, SCIPheurGetName(), and SCIPincludeHeurRens().

◆ SCIP_DECL_HEURFREE()

static SCIP_DECL_HEURFREE ( heurFreeRens  )
static

destructor of primal heuristic to free user data (called when SCIP is exiting)

Definition at line 695 of file heur_rens.c.

References NULL, SCIP_OKAY, SCIPfreeBlockMemory, SCIPheurGetData(), and SCIPheurSetData().

◆ SCIP_DECL_HEURINIT()

static SCIP_DECL_HEURINIT ( heurInitRens  )
static

initialization method of primal heuristic (called after problem was transformed)

Definition at line 715 of file heur_rens.c.

References NULL, SCIP_OKAY, and SCIPheurGetData().

◆ SCIP_DECL_HEUREXEC()