# SCIP

Solving Constraint Integer Programs

cons_storeGraph.c File Reference

## 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_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)

## ◆ CONSHDLR_NAME

 #define CONSHDLR_NAME   "storeGraph"

## ◆ 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().

## ◆ 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
 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.

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 202 of file cons_storeGraph.c.

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 225 of file cons_storeGraph.c.

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 250 of file cons_storeGraph.c.

Referenced by SCIP_DECL_CONSINITSOL().

## ◆ SCIP_DECL_CONSDELETE()

 static SCIP_DECL_CONSDELETE ( consDeleteStoreGraph )
static

frees specific constraint data

Definition at line 274 of file cons_storeGraph.c.

Referenced by SCIP_DECL_CONSEXITSOL().

## ◆ SCIP_DECL_CONSENFOLP()

 static SCIP_DECL_CONSENFOLP ( consEnfolpStoreGraph )
static

constraint enforcing method of constraint handler for LP solutions

Definition at line 338 of file cons_storeGraph.c.

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 354 of file cons_storeGraph.c.

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 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 SCIP_DECL_CONSLOCK ( consLockStoreGraph )
static

variable rounding lock method of constraint handler

Definition at line 386 of file cons_storeGraph.c.

Referenced by SCIP_DECL_CONSCHECK().

## ◆ SCIP_DECL_CONSACTIVE()

 static SCIP_DECL_CONSACTIVE ( consActiveStoreGraph )
static

constraint activation notification method of constraint handler

Definition at line 401 of file cons_storeGraph.c.

Referenced by SCIP_DECL_CONSLOCK().

## ◆ SCIP_DECL_CONSDEACTIVE()

 static SCIP_DECL_CONSDEACTIVE ( consDeactiveStoreGraph )
static

constraint deactivation notification method of constraint handler

Definition at line 635 of file cons_storeGraph.c.

Referenced by SCIP_DECL_CONSACTIVE().

## ◆ SCIP_DECL_CONSPROP()

 static SCIP_DECL_CONSPROP ( consPropStoreGraph )
static

domain propagation method of constraint handler

Definition at line 669 of file cons_storeGraph.c.

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 746 of file cons_storeGraph.c.

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 781 of file cons_storeGraph.c.

## ◆ 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 842 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
 scip SCIP data structure

Definition at line 858 of file cons_storeGraph.c.

## ◆ COLORconsGetCurrentGraph()

 TCLIQUE_GRAPH* COLORconsGetCurrentGraph ( SCIP * scip )

returns the current graph

Parameters
 scip SCIP data structure

Definition at line 882 of file cons_storeGraph.c.

## ◆ COLORconsGetComplementaryGraph()

 TCLIQUE_GRAPH* COLORconsGetComplementaryGraph ( SCIP * scip )

returns the complementary graph

Parameters
 scip SCIP data structure

Definition at line 910 of file cons_storeGraph.c.

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 941 of file cons_storeGraph.c.

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 969 of file cons_storeGraph.c.

## ◆ 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 1002 of file cons_storeGraph.c.

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 1034 of file cons_storeGraph.c.

Referenced by COLORconsGetUnions().

## ◆ COLORconsGetStack()

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

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 1065 of file cons_storeGraph.c.

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

Referenced by COLORconsGetUnion().