compute_symmetry_nauty.c
Go to the documentation of this file.
30 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
89 * Compare the types of two operators according to their name, level and, in case of power, exponent.
131 result = SCIPhashThree(SCIPrealHashCode(exponent), k->level, SCIPhashKeyValString(NULL, (char*) SCIPexprhdlrGetName(SCIPexprGetHdlr(k->expr))));
272 if ( SCIPreallocBlockMemoryArray(data_.scip, &data_.perms, data_.nmaxperms, newsize) != SCIP_OKAY )
338 if ( SCIPreallocBlockMemoryArray(data_.scip, &data_.perms, data_.nmaxperms, newsize) != SCIP_OKAY )
363 int* nnonlinearnodes, /**< pointer to store the number of internal nodes for nonlinear constraints */
417 /* Determine grouping depending on the number of rhs vs. variables; see fillGraphByLinearConss(). */
450 assert( 0 <= matrixdata->matvaridx[idx] && matrixdata->matvaridx[idx] < matrixdata->npermvars );
454 assert( matrixdata->npermvars <= rhsnode && rhsnode < matrixdata->npermvars + matrixdata->nrhscoef );
562 maxvisitednodes = exprdata->nuniqueoperators + exprdata->nuniqueconstants + exprdata->nuniquecoefs;
582 for (expr = SCIPexpriterGetCurrent(it); ! SCIPexpriterIsEnd(it); expr = SCIPexpriterGetNext(it)) /*lint !e441*/ /*lint !e440*/
601 /* Check whether the variable is active; if not, then replace the inactive variable by its aggregation
602 * or its fixed value; note that this step is equivalent as representing an inactive variable as sum
628 SCIP_CALL( SCIPgetProbvarLinearSum(scip, vars, vals, &nvars, varssize, &constant, &requiredsize, TRUE) );
635 /* create nodes for all aggregation variables and coefficients and connect them to the parent node */
681 SCIP_CALL( SCIPensureBlockMemoryArray(scip, &visitednodes, &maxvisitednodes, numvisitednodes+1) );
682 SCIP_CALL( SCIPensureBlockMemoryArray(scip, &ischildofsum, &maxischildofsum, numischildofsum+1) );
697 /* if this is the root expression, add the constraint side node (will be parent of expression node) */
715 /* in all cases apart from variable expressions, the new node is added with the corresponding color */
727 SCIP_CALL( SCIPensureBlockMemoryArray(scip, &visitednodes, &maxvisitednodes, numvisitednodes+1) );
728 SCIP_CALL( SCIPensureBlockMemoryArray(scip, &ischildofsum, &maxischildofsum, numischildofsum+1) );
746 /* iterate over children from last to first, such that visitednodes array is in correct order */
753 SCIP_CALL( SCIPensureBlockMemoryArray(scip, &visitednodes, &maxvisitednodes, numvisitednodes+1) );
754 SCIP_CALL( SCIPensureBlockMemoryArray(scip, &ischildofsum, &maxischildofsum, numischildofsum+1) );
789 /* when leaving an expression, the nodes that are not needed anymore are erased from the respective arrays */
796 /* When leaving the child of a sum expression, we have to pop again to get rid of the intermediate nodes
827 assert( *nnodes == matrixdata->npermvars + matrixdata->nrhscoef + *nlinearnodes + *nnonlinearnodes );
847 * - Each different variable, rhs, matrix coefficient gets a different color that is attached to the corresponding entries.
851 * - Each coefficient of a sum expression gets its own node connected to the node of the corresponding child.
852 * - Each constraint (with lhs and (!) rhs) gets its own node connected to the corresponding node of the root expression.
854 * @note: In contrast to the linear part, lhs and rhs are treated together here, so that each unique combination of lhs
855 * and rhs gets its own node. This makes the implementation a lot simpler with the small downside, that different
862 * Each different constraint (sides), sum-expression coefficient, constant and operator type gets a
939 assert( 0 <= matrixdata->permvarcolors[j] && matrixdata->permvarcolors[j] < matrixdata->nuniquevars );
947 assert( 0 <= matrixdata->rhscoefcolors[i] && matrixdata->rhscoefcolors[i] < matrixdata->nuniquerhs );
964 /* Grouping of nodes depends on the number of nodes in the bipartite graph class. If there are more variables than
965 * constraints, we group by constraints. That is, given several variable nodes which are incident to one constraint
966 * node by the same color, we join these variable nodes to the constraint node by only one intermediate node.
973 /* "colored" edges based on all matrix coefficients - loop through ordered matrix coefficients */
983 /* We pass through the matrix coeficients, grouped by color, i.e., different coefficients. If the coeffients appear
984 * in the same row or column, it suffices to only generate a single node (depending on groupByConstraints). We store
985 * this node in the array internodes. In order to avoid reinitialization, we store the node number with increasing
986 * numbers for each color. The smallest number for the current color is stored in firstcolornodenumber. */
1002 assert( 0 <= matrixdata->matrhsidx[idx] && matrixdata->matrhsidx[idx] < matrixdata->nrhscoef );
1003 assert( 0 <= matrixdata->matvaridx[idx] && matrixdata->matvaridx[idx] < matrixdata->npermvars );
1007 assert( matrixdata->npermvars <= rhsnode && rhsnode < matrixdata->npermvars + matrixdata->nrhscoef );
1113 SCIP_CALL( SCIPhashtableCreate(&consttypemap, SCIPblkmem(scip), constarraysize, SYMhashGetKeyConsttype,
1115 SCIP_CALL( SCIPhashtableCreate(&sumcoefmap, SCIPblkmem(scip), coefarraysize, SYMhashGetKeyConsttype,
1117 SCIP_CALL( SCIPhashtableCreate(&rhstypemap, SCIPblkmem(scip), rhsarraysize, SYMhashGetKeyRhstype,
1153 for (expr = SCIPexpriterGetCurrent(it); ! SCIPexpriterIsEnd(it); expr = SCIPexpriterGetNext(it)) /*lint !e441*/ /*lint !e440*/
1171 /* Check whether the variable is active; if not, then replace the inactive variable by its aggregation
1172 * or its fixed value; note that this step is equivalent as representing an inactive variable as sum
1198 SCIP_CALL( SCIPgetProbvarLinearSum(scip, vars, vals, &nvars, varssize, &constant, &requiredsize, TRUE) );
1205 /* create nodes for all aggregation variables and coefficients and connect them to the parent node */
1259 SCIP_CALL( SCIPensureBlockMemoryArray(scip, &uniquerhsarray, &constarraysize, nuniqueconsts+1) );
1290 SCIP_CALL( SCIPensureBlockMemoryArray(scip, &visitednodes, &maxvisitednodes, numvisitednodes+1) );
1291 SCIP_CALL( SCIPensureBlockMemoryArray(scip, &ischildofsum, &maxischildofsum, numischildofsum+1) );
1345 /* if this is the root expression, add the constraint side node (will be parent of expression node) */
1380 /* in all cases apart from variable expressions, the new node is added with the corresponding color */
1390 SCIP_CALL( SCIPensureBlockMemoryArray(scip, &visitednodes, &maxvisitednodes, numvisitednodes+1) );
1391 SCIP_CALL( SCIPensureBlockMemoryArray(scip, &ischildofsum, &maxischildofsum, numischildofsum+1) );
1416 /* iterate over children from last to first, such that visitednodes array is in correct order */
1440 SCIP_CALL( SCIPensureBlockMemoryArray(scip, &visitednodes, &maxvisitednodes, numvisitednodes+1) );
1441 SCIP_CALL( SCIPensureBlockMemoryArray(scip, &ischildofsum, &maxischildofsum, numischildofsum+1) );
1463 SCIP_CALL( SCIPensureBlockMemoryArray(scip, &uniqueconstarray, &constarraysize, nuniqueconsts + 1) );
1497 /* when leaving an expression, the nodes that are not needed anymore are erased from the respective arrays */
1504 /* When leaving the child of a sum expression, we have to pop again to get rid of the intermediate nodes
1579 return "Computing Graph Automorphism Groups by Brendan D. McKay (https://users.cecs.anu.edu.au/~bdm/nauty/)";
1581 return "Computing Graph Automorphism Groups by Adolfo Piperno (https://pallini.di.uniroma1.it/)";
1604 int* nmaxperms, /**< pointer to store maximal number of permutations (needed for freeing storage) */
1675 SCIPverbMessage(scip, SCIP_VERBLEVEL_MINIMAL, 0, "Stopped symmetry computation: Symmetry graph would become too large.\n");
#define SCIPreallocBlockMemoryArray(scip, ptr, oldnum, newnum)
Definition: scip_mem.h:99
SCIP_RETCODE SCIPexpriterInit(SCIP_EXPRITER *iterator, SCIP_EXPR *expr, SCIP_EXPRITER_TYPE type, SCIP_Bool allowrevisit)
Definition: expriter.c:500
Definition: struct_symmetry.h:63
Definition: struct_scip.h:68
SCIP_RETCODE SCIPhashtableInsert(SCIP_HASHTABLE *hashtable, void *element)
Definition: misc.c:2497
public methods for memory management
SCIP_CONSHDLR * SCIPfindConshdlr(SCIP *scip, const char *name)
Definition: scip_cons.c:886
SCIP_EXPR * SCIPexpriterGetParentDFS(SCIP_EXPRITER *iterator)
Definition: expriter.c:739
Definition: struct_var.h:207
static SCIP_RETCODE fillGraphByConss(SCIP *scip, sparsegraph *SG, SYM_MATRIXDATA *matrixdata, SYM_EXPRDATA *exprdata, int nnodes, int nedges, int nlinearnodes, int nnonlinearnodes, int nlinearedges, int nnonlinearedges, int *degrees, int *colors, int *nusedcolors)
Definition: compute_symmetry_nauty.c:866
SCIP_CONS ** SCIPconshdlrGetConss(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4554
private functions to work with algebraic expressions
Definition: struct_symmetry.h:55
Definition: struct_symmetry.h:70
const char * SYMsymmetryGetAddName(void)
Definition: compute_symmetry_nauty.c:1586
SCIP_Bool SCIPisEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip_numerics.c:445
static void nautyhook(int count, int *p, int *orbits, int numorbits, int stabvertex, int n)
Definition: compute_symmetry_nauty.c:218
variable expression handler
SCIP_EXPR * SCIPexpriterGetCurrent(SCIP_EXPRITER *iterator)
Definition: expriter.c:682
SCIP_RETCODE SCIPhashtableCreate(SCIP_HASHTABLE **hashtable, BMS_BLKMEM *blkmem, int tablesize, SCIP_DECL_HASHGETKEY((*hashgetkey)), SCIP_DECL_HASHKEYEQ((*hashkeyeq)), SCIP_DECL_HASHKEYVAL((*hashkeyval)), void *userptr)
Definition: misc.c:2246
interface for symmetry computations
#define SCIPduplicateBlockMemoryArray(scip, ptr, source, num)
Definition: scip_mem.h:105
Definition: struct_cons.h:46
Definition: compute_symmetry_nauty.c:64
void SCIPsortIntInt(int *intarray1, int *intarray2, int len)
Definition: struct_cons.h:126
Definition: type_expr.h:700
const char * SYMsymmetryGetAddDesc(void)
Definition: compute_symmetry_nauty.c:1592
static SCIP_DECL_HASHKEYVAL(SYMhashKeyValOptype)
Definition: compute_symmetry_nauty.c:118
SCIP_EXPR * SCIPgetExprNonlinear(SCIP_CONS *cons)
Definition: cons_nonlinear.c:12268
power and signed power expression handlers
static SCIP_DECL_HASHGETKEY(SYMhashGetKeyOptype)
Definition: compute_symmetry_nauty.c:82
Definition: type_retcode.h:42
#define SCIPensureBlockMemoryArray(scip, ptr, arraysizeptr, minsize)
Definition: scip_mem.h:107
SCIP_RETCODE SCIPgetProbvarLinearSum(SCIP *scip, SCIP_VAR **vars, SCIP_Real *scalars, int *nvars, int varssize, SCIP_Real *constant, int *requiredsize, SCIP_Bool mergemultiples)
Definition: scip_var.c:1738
void SCIPverbMessage(SCIP *scip, SCIP_VERBLEVEL msgverblevel, FILE *file, const char *formatstr,...)
Definition: scip_message.c:225
Definition: struct_expr.h:202
static SCIP_DECL_HASHKEYEQ(SYMhashKeyEQOptype)
Definition: compute_symmetry_nauty.c:92
SCIP_RETCODE SCIPcreateExpriter(SCIP *scip, SCIP_EXPRITER **iterator)
Definition: scip_expr.c:2296
Definition: struct_expr.h:104
constraint handler for nonlinear constraints specified by algebraic expressions
Definition: type_message.h:52
SCIP_EXPR * SCIPexpriterGetNext(SCIP_EXPRITER *iterator)
Definition: expriter.c:857
Constraint handler for linear constraints in their most general form, .
void * SCIPhashtableRetrieve(SCIP_HASHTABLE *hashtable, void *key)
Definition: misc.c:2558
void SCIPexpriterSetStagesDFS(SCIP_EXPRITER *iterator, SCIP_EXPRITER_STAGE stopstages)
Definition: expriter.c:663
Definition: struct_misc.h:89
SCIP_EXPRITER_STAGE SCIPexpriterGetStageDFS(SCIP_EXPRITER *iterator)
Definition: expriter.c:695
SCIP_Bool SCIPhashtableExists(SCIP_HASHTABLE *hashtable, void *element)
Definition: misc.c:2609
Definition: struct_symmetry.h:78
sum expression handler
#define SCIPfreeBlockMemoryArrayNull(scip, ptr, num)
Definition: scip_mem.h:111
Definition: objbenders.h:43
static SCIP_RETCODE determineGraphSize(SCIP *scip, SYM_MATRIXDATA *matrixdata, SYM_EXPRDATA *exprdata, int *nnodes, int *nedges, int *nlinearnodes, int *nnonlinearnodes, int *nlinearedges, int *nnonlinearedges, int **degrees, int *maxdegrees, SCIP_Bool *success)
Definition: compute_symmetry_nauty.c:356
Definition: struct_symmetry.h:101
SCIP_RETCODE SYMcomputeSymmetryGenerators(SCIP *scip, int maxgenerators, SYM_MATRIXDATA *matrixdata, SYM_EXPRDATA *exprdata, int *nperms, int *nmaxperms, int ***perms, SCIP_Real *log10groupsize, SCIP_Real *symcodetime)
Definition: compute_symmetry_nauty.c:1598