41#include "nauty/nauty.h"
42#include "nauty/nausparse.h"
44#include "nauty/traces.h"
49#pragma GCC diagnostic ignored "-Wshadow"
50#pragma GCC diagnostic ignored "-Wunused-variable"
51#pragma GCC diagnostic ignored "-Wsign-compare"
52#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
57# pragma warning(disable: 4189)
58# pragma warning(disable: 4388)
59# pragma warning(disable: 4456)
60# pragma warning(disable: 4430)
63#include <sassy/preprocessor.h>
65#include "sassy/tools/nauty_converter.h"
67#include "sassy/tools/traces_converter.h"
71#pragma GCC diagnostic warning "-Wunused-but-set-variable"
72#pragma GCC diagnostic warning "-Wsign-compare"
73#pragma GCC diagnostic warning "-Wunused-variable"
74#pragma GCC diagnostic warning "-Wshadow"
144 bool isIdentity =
true;
163 for (
int j = 0; j < permlen; ++j)
165 if ( (
int) aut[j] != j )
177 for (
int j = 0; j < permlen; ++j)
222 SCIP_Bool terminate =
FALSE;
230 "symmetry computation terminated early, because number of cells %d in Nauty exceeds limit of %d\n",
233 "for running full symmetry detection, increase value of parameter propagating/symmetry/nautymaxncells\n");
239 "symmetry computation terminated early, because number of"
242 "for running full symmetry detection, increase value of"
243 " parameter propagating/symmetry/nautymaxnnodes\n");
249 nauty_kill_request = 1;
270 (void)
SCIPsnprintf(
nautyname, (
int)
sizeof(
nautyname),
"Nauty %d.%d.%d", NAUTYVERSIONID/10000, (NAUTYVERSIONID%10000)/1000, (NAUTYVERSIONID%1000)/10);
272 (void)
SCIPsnprintf(
nautyname, (
int)
sizeof(
nautyname),
"Traces %d.%d.%d", NAUTYVERSIONID/10000, (NAUTYVERSIONID%10000)/1000, (NAUTYVERSIONID%1000)/10);
281 return "Computing Graph Automorphism Groups by Brendan D. McKay (users.cecs.anu.edu.au/~bdm/nauty)";
283 return "Computing Graph Automorphism Groups by Adolfo Piperno (pallini.di.uniroma1.it)";
288#define XSTR(x) STR(x)
293 return "sassy " XSTR(SASSY_VERSION_MAJOR)
"." XSTR(SASSY_VERSION_MINOR);
299 return "Symmetry preprocessor by Markus Anders (github.com/markusa4/sassy)";
307 sassy::static_graph* G,
314 SCIP_Real* log10groupsize,
316 SCIP_Real* symcodetime,
317 SCIP_Bool canterminateearly
360 sassy::preprocessor sassy;
363 sassy::configstruct sconfig;
364 sconfig.CONFIG_PREP_DEACT_PROBE =
true;
365 sassy.configure(&sconfig);
368 sassy::sassy_hook sassyglue = [&](
int n,
const int* p,
int nsupp,
const int* suppa) {
369 sassyhook((
void*)&data, n, p, nsupp, suppa);
373 sassy.reduce(G, &sassyglue);
377 DYNALLSTAT(
int, lab, lab_sz);
378 DYNALLSTAT(
int, ptn, ptn_sz);
381 convert_sassy_to_nauty(G, &sg, &lab, &lab_sz, &ptn, &ptn_sz);
383 DYNALLSTAT(
int, orbits, orbits_sz);
384 DYNALLOC1(
int, orbits, orbits_sz, sg.nv,
"malloc");
385 DEFAULTOPTIONS_SPARSEGRAPH(options);
387 options.writeautoms =
FALSE;
388 options.userautomproc = sassy::preprocessor::nauty_hook;
389 options.defaultptn =
FALSE;
390 if ( canterminateearly )
392 *log10groupsize = 0.0;
394 sparsenauty(&sg, lab, ptn, orbits, &options, &stats,
NULL);
395 *log10groupsize = (
SCIP_Real) stats.grpsize2;
398 convert_sassy_to_traces(&sassygraph, &sg, &lab, &lab_sz, &ptn, &ptn_sz);
400 DYNALLSTAT(
int, orbits, orbits_sz);
401 DYNALLOC1(
int, orbits, orbits_sz, sg.nv,
"malloc");
402 DEFAULTOPTIONS_TRACES(options);
404 options.writeautoms =
FALSE;
405 options.userautomproc = sassy::preprocessor::traces_hook;
406 options.defaultptn =
FALSE;
408 Traces(&sg, lab, ptn, orbits, &options, &stats,
NULL);
413 DYNFREE(lab, lab_sz);
414 DYNFREE(ptn, ptn_sz);
447 SCIP_Real* log10groupsize,
448 SCIP_Real* symcodetime
451 SCIP_Bool success =
FALSE;
470 sassy::static_graph sassygraph;
494 SCIP_Real symcodetime = 0.0;
495 SCIP_Real log10groupsize;
499 sassy::static_graph sassygraph;
514 for (
int p = 0; p <
nperms && ! success; ++p)
516 for (
int i = 0;
i < nnodesfromG1; ++
i)
518 if (
perms[p][
i] >= nnodesfromG1 )
526 for (
int p = 0; p <
nperms; ++p)
SCIP_RETCODE SYMbuildSassyGraph(SCIP *scip, sassy::static_graph *sassygraph, SYM_GRAPH *graph, SCIP_Bool *success)
SCIP_RETCODE SYMbuildSassyGraphCheck(SCIP *scip, sassy::static_graph *sassygraph, SYM_GRAPH *G1, SYM_GRAPH *G2, int *nnodes, int *nnodesfromG1, SCIP_Bool *success)
methods to build sassy graph for symmetry detection
interface for symmetry computations
SCIP_Bool SYMcheckGraphsAreIdentical(SCIP *scip, SYM_SYMTYPE symtype, SYM_GRAPH *G1, SYM_GRAPH *G2)
const char * SYMsymmetryGetName(void)
const char * SYMsymmetryGetAddName(void)
SCIP_Bool SYMcanComputeSymmetry(void)
const char * SYMsymmetryGetDesc(void)
static TLS_ATTR char nautyname[20]
static struct NAUTY_Data nautydata_
static void sassyhook(void *user_param, int n, const int *aut, int nsupp, const int *suppa)
static void nautyterminationhook(graph *g, int *lab, int *ptn, int level, int numcells, int tc, int code, int m, int n)
static SCIP_RETCODE computeAutomorphisms(SCIP *scip, SYM_SYMTYPE symtype, sassy::static_graph *G, int nsymvars, int maxgenerators, int ***perms, int *nperms, int *nmaxperms, SCIP_Real *log10groupsize, SCIP_Bool restricttovars, SCIP_Real *symcodetime, SCIP_Bool canterminateearly)
const char * SYMsymmetryGetAddDesc(void)
SCIP_RETCODE SYMcomputeSymmetryGenerators(SCIP *scip, int maxgenerators, SYM_GRAPH *symgraph, int *nperms, int *nmaxperms, int ***perms, SCIP_Real *log10groupsize, SCIP_Real *symcodetime)
Constraint handler for linear constraints in their most general form, .
constraint handler for nonlinear constraints specified by algebraic expressions
#define SCIP_CALL_ABORT(x)
private functions to work with algebraic expressions
power and signed power expression handlers
variable expression handler
void SCIPverbMessage(SCIP *scip, SCIP_VERBLEVEL msgverblevel, FILE *file, const char *formatstr,...)
SCIP_RETCODE SCIPgetIntParam(SCIP *scip, const char *name, int *value)
#define SCIPfreeBlockMemoryArray(scip, ptr, num)
int SCIPcalcMemGrowSize(SCIP *scip, int num)
#define SCIPallocBlockMemoryArray(scip, ptr, num)
#define SCIPreallocBlockMemoryArray(scip, ptr, oldnum, newnum)
#define SCIPfreeBlockMemoryArrayNull(scip, ptr, num)
SCIP_Real SCIPgetSolvingTime(SCIP *scip)
int SCIPsnprintf(char *t, int len, const char *s,...)
SYM_SYMTYPE SCIPgetSymgraphSymtype(SYM_GRAPH *graph)
int SCIPgetSymgraphNVars(SYM_GRAPH *graph)
assert(minobj< SCIPgetCutoffbound(scip))
public methods for memory management
methods for dealing with symmetry detection graphs
enum SCIP_Retcode SCIP_RETCODE
enum SYM_Symtype SYM_SYMTYPE