Scippy

SCIP

Solving Constraint Integer Programs

cons_storeGraph.c File Reference

Detailed Description

constraint handler for storing the graph at each node of the tree

Author
Gerald Gamrath

This file implements the constraints that are used for the branching in the coloring algorithm.

For each node in the branch-and-bound tree, a constraint of this type is created, which stores all restrictions related to that branch-and-bound node.

First of all, it stores the type of the constraint ("same" or "differ", the root has type root) and the two nodes in the graph on which this restriction is applied. When the branch-and-bound node corresponding to the constraint is examined for the first time, the constraint creates a graph that takes into account all the restrictions, which are active at this node. At the root, this is the original (preprocessed) graph. At any other branch-and-bound node, it takes the graph of the constraint related to the branch-and-bound parent node of the current node and modifies it so that all restrictions up to this node are respected. Since the graph in the branch-and-bound parent respects all restrictions on the path to that node, only the last requirement, the one saved at the current branch-and-bound node, must be added. This is done as follows: Adding a DIFFER(v,w) constraint is easy, since it suffices to add an edge between v and w. For a SAME(v,w) constraint, the original idea is to collapse the nodes v and w into one single vertex. Since this is not possible in the tclique-graph data structure, we introduce new edges in the graph, so that v and w have the same neighborhood. Hence, in the pricing routine, each new stable set will either contain both nodes or none of them, since we create (inclusion-) maximal sets.

This does of course not hold for sets created in a higher level of the branch-and-bound tree or in another subtree. In order to forbid all of these sets, which do not fulfill the current restrictions, a propagation is started when the node is entered the first time and repeated later, if the node is reentered after the creation of new variables in another subtree. The propagation simply fixes all variables to 0 which represent a stable set that does not fulfill the restriction at the current node.

The information about all fusions of nodes (caused by the SAME() operation) is stored, so that the nodes constituting a union can be accessed easily. Each union has a representative and a set of nodes, whereas each node knows the representative of the union it belongs to. At the beginning, each node forms its own union and therefore each node also represents this union, consisting of only this node. Later on, some nodes represent unions of several nodes, while other nodes are part of a union which they do not represent, so they have another node as representative. The representatives of the nodes are returned by the methods COLORconsGetRepresentative() / COLORconsGetRepresentatives(), the union represented by a node is returned by COLORconsGetUnion(), the array of unions, indexed by the representing node, is returned by COLORconsGetUnions().

Definition in file cons_storeGraph.c.

#include <assert.h>
#include <string.h>
#include "scip/type_cons.h"
#include "cons_storeGraph.h"
#include "probdata_coloring.h"
#include "tclique/tclique.h"
#include "reader_col.h"
#include "scip/cons_linear.h"

Go to the source code of this file.

Macros

#define CONSHDLR_NAME   "storeGraph"
 
#define CONSHDLR_DESC   "storing graph at nodes of the tree constraint handler"
 
#define CONSHDLR_ENFOPRIORITY   0
 
#define CONSHDLR_CHECKPRIORITY   2000000
 
#define CONSHDLR_PROPFREQ   1
 
#define CONSHDLR_EAGERFREQ   100
 
#define CONSHDLR_DELAYPROP   FALSE
 
#define CONSHDLR_NEEDSCONS   TRUE
 
#define CONSHDLR_PROP_TIMING   SCIP_PROPTIMING_BEFORELP
 

Functions

static SCIP_RETCODE createConsStoreGraphAtRoot (SCIP *scip, SCIP_CONS **cons, const char *name, TCLIQUE_GRAPH *graph)
 
static SCIP_DECL_CONSFREE (consFreeStoreGraph)
 
static SCIP_DECL_CONSINITSOL (consInitsolStoreGraph)
 
static SCIP_DECL_CONSEXITSOL (consExitsolStoreGraph)
 
static SCIP_DECL_CONSDELETE (consDeleteStoreGraph)
 
static SCIP_DECL_CONSENFOLP (consEnfolpStoreGraph)
 
static SCIP_DECL_CONSENFOPS (consEnfopsStoreGraph)
 
static SCIP_DECL_CONSCHECK (consCheckStoreGraph)
 
static SCIP_DECL_CONSLOCK (consLockStoreGraph)
 
static SCIP_DECL_CONSACTIVE (consActiveStoreGraph)
 
static SCIP_DECL_CONSDEACTIVE (consDeactiveStoreGraph)
 
static SCIP_DECL_CONSPROP (consPropStoreGraph)
 
SCIP_RETCODE COLORincludeConshdlrStoreGraph (SCIP *scip)
 
SCIP_RETCODE COLORcreateConsStoreGraph (SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_CONS *fatherconstraint, COLOR_CONSTYPE type, int node1, int node2, SCIP_NODE *stickingnode)
 
SCIP_CONSCOLORconsGetActiveStoreGraphConsFromHandler (SCIP_CONSHDLR *conshdlr)
 
SCIP_CONSCOLORconsGetActiveStoreGraphCons (SCIP *scip)
 
TCLIQUE_GRAPHCOLORconsGetCurrentGraph (SCIP *scip)
 
TCLIQUE_GRAPHCOLORconsGetComplementaryGraph (SCIP *scip)
 
int * COLORconsGetRepresentatives (SCIP *scip)
 
int COLORconsGetRepresentative (SCIP *scip, int node)
 
void COLORconsGetUnions (SCIP *scip, int ***unions, int **lengths)
 
void COLORconsGetUnion (SCIP *scip, int **nodesinunion, int *nnodesinunion, int node)
 
void COLORconsGetStack (SCIP *scip, SCIP_CONS ***stack, int *nstackelements)
 

Macro Definition Documentation

◆ CONSHDLR_NAME

◆ CONSHDLR_DESC

#define CONSHDLR_DESC   "storing graph at nodes of the tree constraint handler"

Definition at line 81 of file cons_storeGraph.c.

Referenced by COLORincludeConshdlrStoreGraph().

◆ CONSHDLR_ENFOPRIORITY

#define CONSHDLR_ENFOPRIORITY   0

priority of the constraint handler for constraint enforcing

Definition at line 82 of file cons_storeGraph.c.

Referenced by COLORincludeConshdlrStoreGraph().

◆ CONSHDLR_CHECKPRIORITY

#define CONSHDLR_CHECKPRIORITY   2000000

priority of the constraint handler for checking feasibility

Definition at line 83 of file cons_storeGraph.c.

Referenced by COLORincludeConshdlrStoreGraph().

◆ CONSHDLR_PROPFREQ

#define CONSHDLR_PROPFREQ   1

frequency for propagating domains; zero means only preprocessing propagation

Definition at line 84 of file cons_storeGraph.c.

Referenced by COLORincludeConshdlrStoreGraph().

◆ CONSHDLR_EAGERFREQ

#define CONSHDLR_EAGERFREQ   100

frequency for using all instead of only the useful constraints in separation, propagation and enforcement, -1 for no eager evaluations, 0 for first only

Definition at line 85 of file cons_storeGraph.c.

Referenced by COLORincludeConshdlrStoreGraph().

◆ CONSHDLR_DELAYPROP

#define CONSHDLR_DELAYPROP   FALSE

should propagation method be delayed, if other propagators found reductions?

Definition at line 88 of file cons_storeGraph.c.

Referenced by COLORincludeConshdlrStoreGraph().

◆ CONSHDLR_NEEDSCONS

#define CONSHDLR_NEEDSCONS   TRUE

should the constraint handler be skipped, if no constraints are available?

Definition at line 89 of file cons_storeGraph.c.

Referenced by COLORincludeConshdlrStoreGraph().

◆ CONSHDLR_PROP_TIMING

#define CONSHDLR_PROP_TIMING   SCIP_PROPTIMING_BEFORELP

Definition at line 91 of file cons_storeGraph.c.

Referenced by COLORincludeConshdlrStoreGraph().

Function Documentation

◆ createConsStoreGraphAtRoot()

static SCIP_RETCODE createConsStoreGraphAtRoot ( SCIP scip,
SCIP_CONS **  cons,
const char *  name,
TCLIQUE_GRAPH graph 
)
static

creates and captures the storeGraph constraint for the root node

Parameters
scipSCIP data structure
conspointer to hold the created constraint
namename of constraint
graphthe original graph

Definition at line 129 of file cons_storeGraph.c.

References COLOR_CONSTYPE_ROOT, COLORprobGetComplementaryGraph(), CONSHDLR_NAME, FALSE, nnodes, NULL, SCIP_CALL, SCIP_DECL_CONSFREE(), SCIP_ERROR, SCIP_OKAY, SCIP_PLUGINNOTFOUND, SCIPallocBlockMemory, SCIPallocBlockMemoryArray, SCIPcreateCons(), SCIPdebugMessage, SCIPerrorMessage, SCIPfindConshdlr(), tcliqueCreate(), and TRUE.

Referenced by SCIP_DECL_CONSINITSOL().

◆ SCIP_DECL_CONSFREE()

static SCIP_DECL_CONSFREE ( consFreeStoreGraph  )
static

destructor of constraint handler to free constraint handler data (called when SCIP is exiting)

Definition at line 211 of file cons_storeGraph.c.

References CONSHDLR_NAME, NULL, SCIP_DECL_CONSINITSOL(), SCIP_OKAY, SCIPconshdlrGetData(), SCIPconshdlrGetName(), SCIPdebugMessage, and SCIPfreeBlockMemory.

Referenced by createConsStoreGraphAtRoot().

◆ SCIP_DECL_CONSINITSOL()

static SCIP_DECL_CONSINITSOL ( consInitsolStoreGraph  )
static

solving process initialization method of constraint handler (called when branch and bound process is about to begin)

Definition at line 234 of file cons_storeGraph.c.

References COLORprobGetGraph(), CONSHDLR_NAME, createConsStoreGraphAtRoot(), NULL, SCIP_CALL, SCIP_DECL_CONSEXITSOL(), SCIP_OKAY, SCIPallocBlockMemoryArray, SCIPconshdlrGetData(), and SCIPconshdlrGetName().

Referenced by SCIP_DECL_CONSFREE().

◆ SCIP_DECL_CONSEXITSOL()

static SCIP_DECL_CONSEXITSOL ( consExitsolStoreGraph  )
static

solving process deinitialization method of constraint handler (called before branch and bound process data is freed)

Definition at line 259 of file cons_storeGraph.c.

References CONSHDLR_NAME, NULL, SCIP_CALL, SCIP_DECL_CONSDELETE(), SCIP_OKAY, SCIPconshdlrGetData(), SCIPconshdlrGetName(), SCIPdebugMessage, SCIPfreeBlockMemoryArray, and SCIPreleaseCons().

Referenced by SCIP_DECL_CONSINITSOL().

◆ SCIP_DECL_CONSDELETE()

static SCIP_DECL_CONSDELETE ( consDeleteStoreGraph  )
static

◆ SCIP_DECL_CONSENFOLP()

static SCIP_DECL_CONSENFOLP ( consEnfolpStoreGraph  )
static

constraint enforcing method of constraint handler for LP solutions

Definition at line 347 of file cons_storeGraph.c.

References CONSHDLR_NAME, NULL, SCIP_DECL_CONSENFOPS(), SCIP_FEASIBLE, SCIP_OKAY, and SCIPconshdlrGetName().

Referenced by SCIP_DECL_CONSDELETE().

◆ SCIP_DECL_CONSENFOPS()

static SCIP_DECL_CONSENFOPS ( consEnfopsStoreGraph  )
static

constraint enforcing method of constraint handler for pseudo solutions

Definition at line 363 of file cons_storeGraph.c.

References CONSHDLR_NAME, NULL, SCIP_DECL_CONSCHECK(), SCIP_FEASIBLE, SCIP_OKAY, and SCIPconshdlrGetName().

Referenced by SCIP_DECL_CONSENFOLP().

◆ SCIP_DECL_CONSCHECK()

static SCIP_DECL_CONSCHECK ( consCheckStoreGraph  )
static

feasibility check method of constraint handler for integral solutions

Definition at line 379 of file cons_storeGraph.c.

References CONSHDLR_NAME, NULL, SCIP_DECL_CONSLOCK(), SCIP_FEASIBLE, SCIP_OKAY, and SCIPconshdlrGetName().

Referenced by SCIP_DECL_CONSENFOPS().

◆ SCIP_DECL_CONSLOCK()

static SCIP_DECL_CONSLOCK ( consLockStoreGraph  )
static

variable rounding lock method of constraint handler

Definition at line 395 of file cons_storeGraph.c.

References CONSHDLR_NAME, NULL, SCIP_DECL_CONSACTIVE(), SCIP_OKAY, SCIPconsGetName(), SCIPconshdlrGetName(), and SCIPdebugMessage.

Referenced by SCIP_DECL_CONSCHECK().

◆ SCIP_DECL_CONSACTIVE()

◆ SCIP_DECL_CONSDEACTIVE()

static SCIP_DECL_CONSDEACTIVE ( consDeactiveStoreGraph  )
static

constraint deactivation notification method of constraint handler

Definition at line 647 of file cons_storeGraph.c.

References CONSHDLR_NAME, NULL, SCIP_DECL_CONSPROP(), SCIP_OKAY, SCIPconsGetData(), SCIPconsGetName(), SCIPconshdlrGetData(), SCIPconshdlrGetName(), and SCIPdebugMessage.

Referenced by SCIP_DECL_CONSACTIVE().

◆ SCIP_DECL_CONSPROP()

◆ COLORincludeConshdlrStoreGraph()

◆ COLORcreateConsStoreGraph()

SCIP_RETCODE COLORcreateConsStoreGraph ( SCIP scip,
SCIP_CONS **  cons,
const char *  name,
SCIP_CONS fatherconstraint,
COLOR_CONSTYPE  type,
int  node1,
int  node2,
SCIP_NODE stickingnode 
)

creates and captures a storeGraph constraint, uses knowledge of the B&B-father

Parameters
scipSCIP data structure
conspointer to hold the created constraint
namename of constraint
fatherconstraintconstraint in B&B-father
typetype of the constraint: COLOR_CONSTYPE_SAME or COLOR_CONSTYPE_DIFFER
node1the first node of the constraint
node2the second node of the constraint
stickingnodethe B&B-tree node at which the constraint will be sticking

Definition at line 793 of file cons_storeGraph.c.

References COLOR_CONSTYPE_DIFFER, COLOR_CONSTYPE_SAME, COLORconsGetActiveStoreGraphConsFromHandler(), CONSHDLR_NAME, FALSE, NULL, SCIP_CALL, SCIP_OKAY, SCIP_PLUGINNOTFOUND, SCIPallocBlockMemory, SCIPcreateCons(), SCIPdebugMessage, SCIPerrorMessage, SCIPfindConshdlr(), SCIP_Cons::stickingatnode, and TRUE.

Referenced by COLORincludeConshdlrStoreGraph(), executeStrongBranching(), SCIP_DECL_BRANCHEXECLP(), and SCIP_DECL_BRANCHEXECPS().

◆ COLORconsGetActiveStoreGraphConsFromHandler()

SCIP_CONS* COLORconsGetActiveStoreGraphConsFromHandler ( SCIP_CONSHDLR conshdlr)

returns the store graph constraint of the current node, needs the pointer to the constraint handler

Parameters
conshdlrconstaint handler for store-graph constraints

Definition at line 854 of file cons_storeGraph.c.

References COLORconsGetActiveStoreGraphCons(), NULL, and SCIPconshdlrGetData().

Referenced by COLORcreateConsStoreGraph().

◆ COLORconsGetActiveStoreGraphCons()

SCIP_CONS* COLORconsGetActiveStoreGraphCons ( SCIP scip)

returns the store graph constraint of the current node, only needs the pointer to scip

Parameters
scipSCIP data structure

Definition at line 870 of file cons_storeGraph.c.

References COLORconsGetCurrentGraph(), NULL, SCIPconshdlrGetData(), SCIPerrorMessage, and SCIPfindConshdlr().

Referenced by COLORconsGetActiveStoreGraphConsFromHandler(), executeStrongBranching(), SCIP_DECL_BRANCHEXECLP(), SCIP_DECL_BRANCHEXECPS(), and SCIP_DECL_CONSPROP().

◆ COLORconsGetCurrentGraph()

◆ COLORconsGetComplementaryGraph()

TCLIQUE_GRAPH* COLORconsGetComplementaryGraph ( SCIP scip)

returns the complementary graph

Parameters
scipSCIP data structure

Definition at line 922 of file cons_storeGraph.c.

References COLORconsGetRepresentatives(), NULL, SCIPconsGetData(), SCIPconshdlrGetData(), SCIPerrorMessage, and SCIPfindConshdlr().

Referenced by COLORconsGetCurrentGraph(), and SCIP_DECL_PRICERREDCOST().

◆ COLORconsGetRepresentatives()

int* COLORconsGetRepresentatives ( SCIP scip)

returns array of representatives of all nodes

Parameters
scipSCIP data structure

Definition at line 953 of file cons_storeGraph.c.

References COLORconsGetRepresentative(), NULL, SCIPconsGetData(), SCIPconshdlrGetData(), SCIPerrorMessage, and SCIPfindConshdlr().

Referenced by COLORconsGetComplementaryGraph().

◆ COLORconsGetRepresentative()

int COLORconsGetRepresentative ( SCIP scip,
int  node 
)

returns the representative of the union which contains a given node

Parameters
scipSCIP data structure
nodethe node, for wich the representative is searched

Definition at line 981 of file cons_storeGraph.c.

References COLORconsGetUnions(), NULL, SCIPconsGetData(), SCIPconshdlrGetData(), SCIPerrorMessage, and SCIPfindConshdlr().

Referenced by COLORconsGetRepresentatives(), computeBranchingPriorities(), SCIP_DECL_BRANCHEXECLP(), and SCIP_DECL_BRANCHEXECPS().

◆ COLORconsGetUnions()

void COLORconsGetUnions ( SCIP scip,
int ***  unions,
int **  lengths 
)

returns the array of all unions, a union is saved in the array at the position of its representative

Parameters
scipSCIP data structure
unionsoutput: array containing array which contains nodes in the union
lengthsoutput: lengths of the unions

Definition at line 1014 of file cons_storeGraph.c.

References COLORconsGetUnion(), NULL, SCIPconsGetData(), SCIPconshdlrGetData(), SCIPerrorMessage, and SCIPfindConshdlr().

Referenced by COLORconsGetRepresentative().

◆ COLORconsGetUnion()

void COLORconsGetUnion ( SCIP scip,
int **  nodesinunion,
int *  nnodesinunion,
int  node 
)

returns the union which has a given node as representative

Parameters
scipSCIP data structure
nodesinunionoutput: array containig nodes in the union
nnodesinunionoutput: length of the union
nodethe node, whose union we want to get

Definition at line 1046 of file cons_storeGraph.c.

References COLORconsGetStack(), NULL, SCIPconsGetData(), SCIPconshdlrGetData(), SCIPerrorMessage, and SCIPfindConshdlr().

Referenced by COLORconsGetUnions().

◆ COLORconsGetStack()

void COLORconsGetStack ( SCIP scip,
SCIP_CONS ***  stack,
int *  nstackelements 
)

returns the stack and the number of elements on it

Parameters
scipSCIP data structure
stackreturn value: pointer to the stack
nstackelementsreturn value: pointer to int, for number of elements on the stack

Definition at line 1077 of file cons_storeGraph.c.

References NULL, SCIPconshdlrGetData(), SCIPerrorMessage, and SCIPfindConshdlr().

Referenced by COLORconsGetUnion().