Detailed Description
constraint handler for storing the graph at each node of the tree
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_CONS * | COLORconsGetActiveStoreGraphConsFromHandler (SCIP_CONSHDLR *conshdlr) |
SCIP_CONS * | COLORconsGetActiveStoreGraphCons (SCIP *scip) |
TCLIQUE_GRAPH * | COLORconsGetCurrentGraph (SCIP *scip) |
TCLIQUE_GRAPH * | COLORconsGetComplementaryGraph (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
#define CONSHDLR_NAME "storeGraph" |
Definition at line 71 of file cons_storeGraph.c.
Referenced by COLORcreateConsStoreGraph(), COLORincludeConshdlrStoreGraph(), createConsStoreGraphAtRoot(), SCIP_DECL_CONSACTIVE(), SCIP_DECL_CONSCHECK(), SCIP_DECL_CONSDEACTIVE(), SCIP_DECL_CONSDELETE(), SCIP_DECL_CONSENFOLP(), SCIP_DECL_CONSENFOPS(), SCIP_DECL_CONSEXITSOL(), SCIP_DECL_CONSFREE(), SCIP_DECL_CONSINITSOL(), and SCIP_DECL_CONSLOCK().
◆ CONSHDLR_DESC
#define CONSHDLR_DESC "storing graph at nodes of the tree constraint handler" |
Definition at line 72 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 73 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 74 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 75 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 76 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 79 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 80 of file cons_storeGraph.c.
Referenced by COLORincludeConshdlrStoreGraph().
◆ CONSHDLR_PROP_TIMING
#define CONSHDLR_PROP_TIMING SCIP_PROPTIMING_BEFORELP |
Definition at line 82 of file cons_storeGraph.c.
Referenced by COLORincludeConshdlrStoreGraph().
Function Documentation
◆ createConsStoreGraphAtRoot()
|
static |
creates and captures the storeGraph constraint for the root node
- Parameters
-
scip SCIP data structure cons pointer to hold the created constraint name name of constraint graph the original graph
Definition at line 120 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 |
destructor of constraint handler to free constraint handler data (called when SCIP is exiting)
Definition at line 202 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 |
solving process initialization method of constraint handler (called when branch and bound process is about to begin)
Definition at line 225 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 |
solving process deinitialization method of constraint handler (called before branch and bound process data is freed)
Definition at line 250 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 |
frees specific constraint data
Definition at line 274 of file cons_storeGraph.c.
References COLOR_CONSTYPE_ROOT, CONSHDLR_NAME, NULL, SCIP_DECL_CONSENFOLP(), SCIP_OKAY, SCIPconsGetName(), SCIPconshdlrGetName(), SCIPdebugMessage, SCIPfreeBlockMemory, SCIPfreeBlockMemoryArray, and tcliqueFree().
Referenced by SCIP_DECL_CONSEXITSOL().
◆ SCIP_DECL_CONSENFOLP()
|
static |
constraint enforcing method of constraint handler for LP solutions
Definition at line 338 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 |
constraint enforcing method of constraint handler for pseudo solutions
Definition at line 354 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 |
feasibility check method of constraint handler for integral solutions
Definition at line 370 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 |
variable rounding lock method of constraint handler
Definition at line 386 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()
|
static |
constraint activation notification method of constraint handler
Definition at line 401 of file cons_storeGraph.c.
References COLOR_CONSTYPE_DIFFER, COLOR_CONSTYPE_ROOT, COLOR_CONSTYPE_SAME, COLORprobGetComplementaryGraph(), COLORprobGetConstraint(), CONSHDLR_NAME, FALSE, nnodes, NULL, SCIP_CALL, SCIP_DECL_CONSDEACTIVE(), SCIP_ERROR, SCIP_OKAY, SCIPallocBlockMemoryArray, SCIPcalcMemGrowSize(), SCIPconsGetData(), SCIPconsGetName(), SCIPconshdlrGetData(), SCIPconshdlrGetName(), SCIPdebugMessage, SCIPdelConsLocal(), SCIPerrorMessage, SCIPfreeBlockMemoryArray, SCIPgetNTotalVars(), SCIPreallocBlockMemoryArray, SCIPrepropagateNode(), tcliqueAddEdge(), tcliqueAddNode(), tcliqueCreate(), tcliqueFlush(), tcliqueGetFirstAdjedge(), tcliqueGetLastAdjedge(), and TRUE.
Referenced by SCIP_DECL_CONSLOCK().
◆ SCIP_DECL_CONSDEACTIVE()
|
static |
constraint deactivation notification method of constraint handler
Definition at line 638 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()
|
static |
domain propagation method of constraint handler
Definition at line 672 of file cons_storeGraph.c.
References COLOR_CONSTYPE_DIFFER, COLOR_CONSTYPE_SAME, COLORconsGetActiveStoreGraphCons(), COLORincludeConshdlrStoreGraph(), COLORprobGetStableSets(), COLORprobGetVarForStableSet(), COLORprobIsNodeInStableSet(), NULL, SCIP_CALL, SCIP_DIDNOTFIND, SCIP_OKAY, SCIPchgVarUb(), SCIPconsGetData(), SCIPconsGetName(), SCIPconshdlrGetData(), SCIPdebugMessage, SCIPgetNTotalVars(), SCIPisFeasZero(), and SCIPvarGetUbLocal().
Referenced by SCIP_DECL_CONSDEACTIVE().
◆ COLORincludeConshdlrStoreGraph()
SCIP_RETCODE COLORincludeConshdlrStoreGraph | ( | SCIP * | scip | ) |
creates the handler for storeGraph constraints and includes it in SCIP
- Parameters
-
scip SCIP data structure
Definition at line 749 of file cons_storeGraph.c.
References COLORcreateConsStoreGraph(), CONSHDLR_CHECKPRIORITY, CONSHDLR_DELAYPROP, CONSHDLR_DESC, CONSHDLR_EAGERFREQ, CONSHDLR_ENFOPRIORITY, CONSHDLR_NAME, CONSHDLR_NEEDSCONS, CONSHDLR_PROP_TIMING, CONSHDLR_PROPFREQ, NULL, SCIP_CALL, SCIP_OKAY, SCIPallocBlockMemory(), SCIPdebugMessage, SCIPincludeConshdlrBasic(), SCIPsetConshdlrActive(), SCIPsetConshdlrDeactive(), SCIPsetConshdlrDelete(), SCIPsetConshdlrExitsol(), SCIPsetConshdlrFree(), SCIPsetConshdlrInitsol(), and SCIPsetConshdlrProp().
Referenced by SCIP_DECL_CONSPROP(), and SCIPincludeColoringPlugins().
◆ 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
-
scip SCIP data structure cons pointer to hold the created constraint name name of constraint fatherconstraint constraint in B&B-father type type of the constraint: COLOR_CONSTYPE_SAME or COLOR_CONSTYPE_DIFFER node1 the first node of the constraint node2 the second node of the constraint stickingnode the B&B-tree node at which the constraint will be sticking
Definition at line 784 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
-
conshdlr constaint handler for store-graph constraints
Definition at line 845 of file cons_storeGraph.c.
References COLORconsGetActiveStoreGraphCons(), NULL, and SCIPconshdlrGetData().
Referenced by COLORcreateConsStoreGraph().
◆ COLORconsGetActiveStoreGraphCons()
returns the store graph constraint of the current node, only needs the pointer to scip
- Parameters
-
scip SCIP data structure
Definition at line 861 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()
TCLIQUE_GRAPH* COLORconsGetCurrentGraph | ( | SCIP * | scip | ) |
returns the current graph
- Parameters
-
scip SCIP data structure
Definition at line 885 of file cons_storeGraph.c.
References COLORconsGetComplementaryGraph(), NULL, SCIPconsGetData(), SCIPconshdlrGetData(), SCIPerrorMessage, and SCIPfindConshdlr().
Referenced by COLORconsGetActiveStoreGraphCons(), computeBranchingPriorities(), SCIP_DECL_BRANCHEXECLP(), SCIP_DECL_BRANCHEXECPS(), SCIP_DECL_PRICERFARKAS(), and SCIP_DECL_PRICERREDCOST().
◆ COLORconsGetComplementaryGraph()
TCLIQUE_GRAPH* COLORconsGetComplementaryGraph | ( | SCIP * | scip | ) |
returns the complementary graph
- Parameters
-
scip SCIP data structure
Definition at line 913 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
-
scip SCIP data structure
Definition at line 944 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
-
scip SCIP data structure node the node, for wich the representative is searched
Definition at line 972 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
-
scip SCIP data structure unions output: array containing array which contains nodes in the union lengths output: lengths of the unions
Definition at line 1005 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
-
scip SCIP data structure nodesinunion output: array containig nodes in the union nnodesinunion output: length of the union node the node, whose union we want to get
Definition at line 1037 of file cons_storeGraph.c.
References COLORconsGetStack(), NULL, SCIPconsGetData(), SCIPconshdlrGetData(), SCIPerrorMessage, and SCIPfindConshdlr().
Referenced by COLORconsGetUnions().
◆ COLORconsGetStack()
returns the stack and the number of elements on it
- Parameters
-
scip SCIP data structure stack return value: pointer to the stack nstackelements return value: pointer to int, for number of elements on the stack
Definition at line 1068 of file cons_storeGraph.c.
References NULL, SCIPconshdlrGetData(), SCIPerrorMessage, and SCIPfindConshdlr().
Referenced by COLORconsGetUnion().