Scippy

GCG

Branch-and-Price & Column Generation for Everyone

pub_automorphism.h
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2/* */
3/* This file is part of the program and library */
4/* GCG --- Generic Column Generation */
5/* a Dantzig-Wolfe decomposition based extension */
6/* of the branch-cut-and-price framework */
7/* SCIP --- Solving Constraint Integer Programs */
8/* */
9/* Copyright (C) 2010-2026 Operations Research, RWTH Aachen University */
10/* Zuse Institute Berlin (ZIB) */
11/* */
12/* Licensed under the Apache License, Version 2.0 (the "License"); */
13/* you may not use this file except in compliance with the License. */
14/* You may obtain a copy of the License at */
15/* */
16/* http://www.apache.org/licenses/LICENSE-2.0 */
17/* */
18/* Unless required by applicable law or agreed to in writing, software */
19/* distributed under the License is distributed on an "AS IS" BASIS, */
20/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
21/* See the License for the specific language governing permissions and */
22/* limitations under the License. */
23/* */
24/* You should have received a copy of the Apache-2.0 license */
25/* along with GCG; see the file LICENSE. If not visit gcg.or.rwth-aachen.de.*/
26/* */
27/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
28
29/**@file pub_automorphism.h
30 * @ingroup PUBLICCOREAPI
31 * @brief helper functions for automorphism detection
32 *
33 * @author Martin Bergner
34 * @author Daniel Peters
35 * @author Jonas Witt
36 *
37 */
38
39/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
40
41#ifndef PUB_AUTOMORPHISM_H_
42#define PUB_AUTOMORPHISM_H_
43
44#include "gcg/def.h"
45#include "scip/scip.h"
46
47#ifdef __cplusplus
48extern "C" {
49#endif
50
51typedef struct struct_graph AUT_GRAPH;
53typedef struct struct_cons AUT_CONS;
54typedef struct struct_var AUT_VAR;
55typedef struct struct_coef AUT_COEF;
56typedef struct struct_colorinformation AUT_COLOR;
57/**
58* @ingroup AUTOMORPHISM
59* @{
60 */
61
62#ifdef WITH_BLISS
63/** returns bliss version */
65void GCGgetBlissName(char* buffer, int len);
66#endif
67
68#ifdef WITH_NAUTY
69/** returns nauty version */
71void GCGgetNautyName(char* buffer, int len);
72#endif
73
74#ifdef __cplusplus
75}
76#endif
77
78#ifdef __cplusplus
79/**
80 * graph structure used to search for automorphisms
81 */
82struct struct_graph
83{
84 /** initializes the graph */
85 SCIP_RETCODE init(
86 SCIP* scip, /**< SCIP struct */
87 int nvertices /**< number of vertices */
88 );
89
90 /** destroys the graph */
91 SCIP_RETCODE destroy();
92
93 /** sets the color of a vertex */
94 void setColor(
95 int vertex, /**< vertex */
96 int color /**< color */
97 );
98
99 /** adds an edge */
100 void addEdge(
101 int v1, /**< first vertex */
102 int v2 /**< second vertex */
103 );
104
105 /** returns the number of vertices */
106 unsigned int getNVertices();
107
108 /** found automorphisms */
109 SCIP_RETCODE findAutomorphisms(
110 void* userdata, /**< pointer to user data that will be passed to fhook */
111 void (*fhook)(void*, unsigned int, const unsigned int*), /**< pointer to function that will be called for each found generator */
112 unsigned int searchnodelimit, /**< search node limit (requires patched bliss version) */
113 unsigned int generatorlimit /**< generator limit (requires patched bliss version or version >=0.76) */
114 );
115
116 /** signals that the search should be terminated */
117 void terminateSearch();
118
119 AUT_GRAPH_DATA* graphdata;
120};
121
122/** saves a constraint with its corresponding scip */
123struct struct_cons
124{
125 SCIP* scip; /**< SCIP data structure */
126 SCIP_CONS* cons; /**< pointer to SCIP constraint */
127
128 /** constructor for the constraint struct */
129 struct_cons(
130 SCIP* scip_, /**< SCIP data structure */
131 SCIP_CONS* scons_ /**< SCIP constraint */
132 );
133
134 /** getter for the SCIP constraint */
135 SCIP_CONS* getCons();
136
137 /** getter for the SCIP itself */
138 SCIP* getScip();
139};
140
141/** saves a variable with its corresponding scip */
142struct struct_var
143{
144 SCIP* scip; /**< SCIP data structure */
145 SCIP_VAR* var; /**< pointer to SCIP variable */
146
147 /** constructor for the variable struct */
148 struct_var(
149 SCIP* scip_, /**< SCIP data structure */
150 SCIP_VAR* svar_ /**< SCIP variable */
151 );
152
153 /** getter for the SCIP variable */
154 SCIP_VAR* getVar();
155
156 /** getter for the SCIP itself */
157 SCIP* getScip();
158};
159
160/** saves a coefficient with its corresponding scip */
161struct struct_coef
162{
163 SCIP* scip; /**< SCIP data structure */
164 SCIP_Real val; /**< SCIP Real value */
165
166 /** constructor for the coefficient struct */
167 struct_coef(
168 SCIP* scip_, /**< SCIP data structure */
169 SCIP_Real val_ /**< SCIP value */
170 );
171
172 /** getter for the SCIP Real value */
173 SCIP_Real getVal();
174
175 /** getter for the SCIP itself */
176 SCIP* getScip();
177};
178
179/** saves helping information for creating the graph */
180struct struct_colorinformation
181{
182 int color; /**< color of the nodes of the graph */
183 int lenconssarray; /**< size of ptrarrayconss */
184 int lenvarsarray; /**< size of ptrarrayvars */
185 int lencoefsarray; /**< size of ptrarraycoefs */
186 int alloccoefsarray; /**< allocated size of ptrarraycoefs */
187
188 void** ptrarraycoefs; /**< array of pointers to coefficient */
189 void** ptrarrayvars; /**< array of pointers to variables */
190 void** ptrarrayconss; /**< array of pointers to constraints */
191
192 SCIP_Bool onlysign; /**< use sign of values instead of values? (should be FALSE if we check whether pricin problems can be aggregated) */
193
194 /** default constructor */
195 struct_colorinformation();
196
197 /** insert a variable to its pointer array */
198 SCIP_RETCODE insert( AUT_VAR* svar, SCIP_Bool* added);
199
200 /** insert a constraint to its pointer array */
201 SCIP_RETCODE insert( AUT_CONS* scons, SCIP_Bool* added);
202
203 /** insert a coefficient to its pointer array */
204 SCIP_RETCODE insert( AUT_COEF* scoef, SCIP_Bool* added);
205
206 /** getter for the length of the variable array */
207 int getLenVar();
208
209 /** getter for the length of the constraint array */
210 int getLenCons();
211
212 /** getter for the variable struct */
213 int get( AUT_VAR svar);
214
215 /** getter for the constraint struct */
216 int get( AUT_CONS scons);
217
218 /** getter for the coefficient struct */
219 int get( AUT_COEF scoef);
220
221 /** set onlysign bool */
222 SCIP_RETCODE setOnlySign(SCIP_Bool onlysign_);
223
224 /** get onlysign bool */
225 SCIP_Bool getOnlySign();
226};
227
228
229#endif
230/** @} */
231#endif /* PUB_AUTOMORPHISM_H_ */
static void fhook(void *user_param, unsigned int N, const unsigned int *aut)
void GCGgetBlissName(char *buffer, int len)
void GCGgetNautyName(char *buffer, int len)
common defines and data types used in all packages of GCG
#define GCG_EXPORT
Definition: def.h:59
#define SCIP_Bool
#define SCIP_Real
struct struct_cons AUT_CONS
struct struct_colorinformation AUT_COLOR
struct struct_graph AUT_GRAPH
struct struct_coef AUT_COEF
struct struct_var AUT_VAR
enum SCIP_Retcode SCIP_RETCODE