Scippy

SCIP

Solving Constraint Integer Programs

heur_mutation.c File Reference

Detailed Description

LNS heuristic that tries to randomly mutate the incumbent solution.

Author
Timo Berthold

Definition in file heur_mutation.c.

#include "blockmemshell/memory.h"
#include "scip/heuristics.h"
#include "scip/heur_mutation.h"
#include "scip/pub_heur.h"
#include "scip/pub_message.h"
#include "scip/pub_misc.h"
#include "scip/pub_sol.h"
#include "scip/pub_var.h"
#include "scip/scip_branch.h"
#include "scip/scip_cons.h"
#include "scip/scip_copy.h"
#include "scip/scip_general.h"
#include "scip/scip_heur.h"
#include "scip/scip_mem.h"
#include "scip/scip_message.h"
#include "scip/scip_nodesel.h"
#include "scip/scip_numerics.h"
#include "scip/scip_param.h"
#include "scip/scip_prob.h"
#include "scip/scip_randnumgen.h"
#include "scip/scip_sol.h"
#include "scip/scip_solve.h"
#include "scip/scip_solvingstats.h"
#include <string.h>

Go to the source code of this file.

Macros

#define HEUR_NAME   "mutation"
 
#define HEUR_DESC   "mutation heuristic randomly fixing variables"
 
#define HEUR_DISPCHAR   'M'
 
#define HEUR_PRIORITY   -1103000
 
#define HEUR_FREQ   -1
 
#define HEUR_FREQOFS   8
 
#define HEUR_MAXDEPTH   -1
 
#define HEUR_TIMING   SCIP_HEURTIMING_AFTERNODE
 
#define HEUR_USESSUBSCIP   TRUE
 
#define DEFAULT_NODESOFS   500 /* number of nodes added to the contingent of the total nodes */
 
#define DEFAULT_MAXNODES   5000 /* maximum number of nodes to regard in the subproblem */
 
#define DEFAULT_MINIMPROVE   0.01 /* factor by which Mutation should at least improve the incumbent */
 
#define DEFAULT_MINNODES   500 /* minimum number of nodes to regard in the subproblem */
 
#define DEFAULT_MINFIXINGRATE   0.8 /* minimum percentage of integer variables that have to be fixed */
 
#define DEFAULT_NODESQUOT   0.1 /* subproblem nodes in relation to nodes of the original problem */
 
#define DEFAULT_NWAITINGNODES   200 /* number of nodes without incumbent change that heuristic should wait */
 
#define DEFAULT_USELPROWS
 
#define DEFAULT_COPYCUTS
 
#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 DEFAULT_RANDSEED   19 /* initial random seed */
 

Functions

static SCIP_RETCODE determineVariableFixings (SCIP *scip, SCIP_VAR **fixedvars, SCIP_Real *fixedvals, int *nfixedvars, SCIP_Real minfixingrate, SCIP_RANDNUMGEN *randnumgen, SCIP_Bool *success)
 
static SCIP_RETCODE createNewSol (SCIP *scip, SCIP *subscip, SCIP_VAR **subvars, SCIP_HEUR *heur, SCIP_SOL *subsol, SCIP_Bool *success)
 
static SCIP_RETCODE setupAndSolveSubscipMutation (SCIP *scip, SCIP *subscip, SCIP_HEUR *heur, SCIP_VAR **fixedvars, SCIP_Real *fixedvals, int nfixedvars, SCIP_Longint nsubnodes, SCIP_RESULT *result)
 
static SCIP_DECL_HEURCOPY (heurCopyMutation)
 
static SCIP_DECL_HEURFREE (heurFreeMutation)
 
static SCIP_DECL_HEURINIT (heurInitMutation)
 
static SCIP_DECL_HEUREXIT (heurExitMutation)
 
static SCIP_DECL_HEUREXEC (heurExecMutation)
 
SCIP_RETCODE SCIPincludeHeurMutation (SCIP *scip)
 

Macro Definition Documentation

◆ HEUR_NAME

#define HEUR_NAME   "mutation"

Definition at line 48 of file heur_mutation.c.

Referenced by SCIP_DECL_HEURCOPY(), and SCIPincludeHeurMutation().

◆ HEUR_DESC

#define HEUR_DESC   "mutation heuristic randomly fixing variables"

Definition at line 49 of file heur_mutation.c.

Referenced by SCIPincludeHeurMutation().

◆ HEUR_DISPCHAR

#define HEUR_DISPCHAR   'M'

Definition at line 50 of file heur_mutation.c.

Referenced by SCIPincludeHeurMutation().

◆ HEUR_PRIORITY

#define HEUR_PRIORITY   -1103000

Definition at line 51 of file heur_mutation.c.

Referenced by SCIPincludeHeurMutation().

◆ HEUR_FREQ

#define HEUR_FREQ   -1

Definition at line 52 of file heur_mutation.c.

Referenced by SCIPincludeHeurMutation().

◆ HEUR_FREQOFS

#define HEUR_FREQOFS   8

Definition at line 53 of file heur_mutation.c.

Referenced by SCIPincludeHeurMutation().

◆ HEUR_MAXDEPTH

#define HEUR_MAXDEPTH   -1

Definition at line 54 of file heur_mutation.c.

Referenced by SCIPincludeHeurMutation().

◆ HEUR_TIMING

#define HEUR_TIMING   SCIP_HEURTIMING_AFTERNODE

Definition at line 55 of file heur_mutation.c.

Referenced by SCIPincludeHeurMutation().

◆ HEUR_USESSUBSCIP

#define HEUR_USESSUBSCIP   TRUE

does the heuristic use a secondary SCIP instance?

Definition at line 56 of file heur_mutation.c.

Referenced by SCIPincludeHeurMutation().

◆ DEFAULT_NODESOFS

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

Definition at line 58 of file heur_mutation.c.

Referenced by SCIPincludeHeurMutation().

◆ DEFAULT_MAXNODES

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

Definition at line 59 of file heur_mutation.c.

Referenced by SCIPincludeHeurMutation().

◆ DEFAULT_MINIMPROVE

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

Definition at line 60 of file heur_mutation.c.

Referenced by SCIPincludeHeurMutation().

◆ DEFAULT_MINNODES

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

Definition at line 61 of file heur_mutation.c.

Referenced by SCIPincludeHeurMutation().

◆ DEFAULT_MINFIXINGRATE

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

Definition at line 62 of file heur_mutation.c.

Referenced by SCIPincludeHeurMutation().

◆ DEFAULT_NODESQUOT

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

Definition at line 63 of file heur_mutation.c.

Referenced by SCIPincludeHeurMutation().

◆ DEFAULT_NWAITINGNODES

#define DEFAULT_NWAITINGNODES   200 /* number of nodes without incumbent change that heuristic should wait */

Definition at line 64 of file heur_mutation.c.

Referenced by SCIPincludeHeurMutation().

◆ 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:65

Definition at line 65 of file heur_mutation.c.

Referenced by SCIPincludeHeurMutation().

◆ 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:64

Definition at line 67 of file heur_mutation.c.

Referenced by SCIPincludeHeurMutation().

◆ DEFAULT_BESTSOLLIMIT

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

Definition at line 69 of file heur_mutation.c.

Referenced by SCIPincludeHeurMutation().

◆ DEFAULT_USEUCT

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

Definition at line 70 of file heur_mutation.c.

Referenced by SCIPincludeHeurMutation().

◆ DEFAULT_RANDSEED

#define DEFAULT_RANDSEED   19 /* initial random seed */

Definition at line 71 of file heur_mutation.c.

Referenced by SCIP_DECL_HEURINIT().

Function Documentation

◆ determineVariableFixings()

static SCIP_RETCODE determineVariableFixings ( SCIP scip,
SCIP_VAR **  fixedvars,
SCIP_Real fixedvals,
int *  nfixedvars,
SCIP_Real  minfixingrate,
SCIP_RANDNUMGEN randnumgen,
SCIP_Bool success 
)
static

determine variables and values which should be fixed in the mutation subproblem

Parameters
sciporiginal SCIP data structure
fixedvarsarray to store the variables that should be fixed in the subproblem
fixedvalsarray to store the fixing values to fix variables in the subproblem
nfixedvarspointer to store the number of variables that should be fixed
minfixingratepercentage of integer variables that have to be fixed
randnumgenrandom number generator
successused to store whether the creation of the subproblem worked

Definition at line 103 of file heur_mutation.c.

References BMScopyMemoryArray, FALSE, NULL, REALABS, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPgetBestSol(), SCIPgetSolVal(), SCIPgetVarsData(), SCIPisGT(), SCIPisInfinity(), SCIPisLE(), SCIPisLT(), SCIPrandomPermuteArray(), SCIPvarGetLbGlobal(), SCIPvarGetUbGlobal(), and TRUE.

Referenced by SCIP_DECL_HEUREXEC().

◆ 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
heurmutation heuristic structure
subsolsolution of the subproblem
successused to store whether new solution was found or not

Definition at line 185 of file heur_mutation.c.

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

Referenced by setupAndSolveSubscipMutation().

◆ setupAndSolveSubscipMutation()

static SCIP_RETCODE setupAndSolveSubscipMutation ( SCIP scip,
SCIP subscip,
SCIP_HEUR heur,
SCIP_VAR **  fixedvars,
SCIP_Real fixedvals,
int  nfixedvars,
SCIP_Longint  nsubnodes,
SCIP_RESULT result 
)
static

setup and solve mutation sub-SCIP

Parameters
scipSCIP data structure
subscipsub-SCIP data structure
heurmutation heuristic
fixedvarsarray to store the variables that should be fixed in the subproblem
fixedvalsarray to store the fixing values to fix variables in the subproblem
nfixedvarsthe number of variables that should be fixed
nsubnodesnode limit for the subproblem
resultpointer to store the result

Definition at line 230 of file heur_mutation.c.

References createNewSol(), FALSE, MIN, NULL, SCIP_Bool, SCIP_CALL, SCIP_CALL_ABORT, SCIP_FOUNDSOL, SCIP_OKAY, SCIP_PARAMSETTING_FAST, SCIP_PARAMSETTING_OFF, SCIP_Real, SCIPallocBufferArray, SCIPblkmem(), SCIPcopyLargeNeighborhoodSearch(), SCIPcopyLimits(), SCIPdebug, SCIPdebugMsg, SCIPfindBranchrule(), SCIPfindConshdlr(), SCIPfindNodesel(), SCIPfreeBufferArray, SCIPgetLowerbound(), SCIPgetNNodes(), SCIPgetNSols(), SCIPgetNVars(), SCIPgetSols(), SCIPgetUpperbound(), SCIPgetVars(), SCIPhashmapCreate(), SCIPhashmapFree(), SCIPhashmapGetImage(), SCIPheurGetData(), SCIPisInfinity(), SCIPisParamFixed(), SCIPmergeVariableStatistics(), SCIPprintStatistics(), SCIPsetBoolParam(), SCIPsetCharParam(), SCIPsetIntParam(), SCIPsetLongintParam(), SCIPsetObjlimit(), SCIPsetPresolving(), SCIPsetSeparating(), SCIPsetSubscipsOff(), SCIPsolve(), SCIPsumepsilon(), and TRUE.

Referenced by SCIP_DECL_HEUREXEC().

◆ SCIP_DECL_HEURCOPY()

static SCIP_DECL_HEURCOPY ( heurCopyMutation  )
static

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

Definition at line 419 of file heur_mutation.c.

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

◆ SCIP_DECL_HEURFREE()

static SCIP_DECL_HEURFREE ( heurFreeMutation  )
static

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

Definition at line 433 of file heur_mutation.c.

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

◆ SCIP_DECL_HEURINIT()

static SCIP_DECL_HEURINIT ( heurInitMutation  )
static

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

Definition at line 453 of file heur_mutation.c.

References DEFAULT_RANDSEED, NULL, SCIP_CALL, SCIP_OKAY, SCIPcreateRandom(), SCIPheurGetData(), and TRUE.

◆ SCIP_DECL_HEUREXIT()

static SCIP_DECL_HEUREXIT ( heurExitMutation  )
static

deinitialization method of primal heuristic

Definition at line 476 of file heur_mutation.c.

References NULL, SCIP_OKAY, SCIPfreeRandom(), and SCIPheurGetData().

◆ SCIP_DECL_HEUREXEC()