1    	/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2    	/*                                                                           */
3    	/*                  This file is part of the program and library             */
4    	/*         SCIP --- Solving Constraint Integer Programs                      */
5    	/*                                                                           */
6    	/*  Copyright (c) 2002-2023 Zuse Institute Berlin (ZIB)                      */
7    	/*                                                                           */
8    	/*  Licensed under the Apache License, Version 2.0 (the "License");          */
9    	/*  you may not use this file except in compliance with the License.         */
10   	/*  You may obtain a copy of the License at                                  */
11   	/*                                                                           */
12   	/*      http://www.apache.org/licenses/LICENSE-2.0                           */
13   	/*                                                                           */
14   	/*  Unless required by applicable law or agreed to in writing, software      */
15   	/*  distributed under the License is distributed on an "AS IS" BASIS,        */
16   	/*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17   	/*  See the License for the specific language governing permissions and      */
18   	/*  limitations under the License.                                           */
19   	/*                                                                           */
20   	/*  You should have received a copy of the Apache-2.0 license                */
21   	/*  along with SCIP; see the file LICENSE. If not visit scipopt.org.         */
22   	/*                                                                           */
23   	/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24   	
25   	/**@file   struct_symmetry.h
26   	 * @brief  structs for symmetry computations
27   	 * @author Marc Pfetsch
28   	 * @author Christopher Hojny
29   	 */
30   	
31   	/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
32   	
33   	#ifndef __SCIP_STRUCT_SYMMETRY_H_
34   	#define __SCIP_STRUCT_SYMMETRY_H_
35   	
36   	#include "scip/scip.h"
37   	#include "symmetry/type_symmetry.h"
38   	#include "scip/type_expr.h"
39   	
40   	#ifdef __cplusplus
41   	extern "C" {
42   	#endif
43   	
44   	/** data to encode a symmetry detection graph */
45   	struct SYM_Graph
46   	{
47   	   /* general information about graph */
48   	   SYM_SYMTYPE           symtype;            /**< type of symmetries encoded in graph */
49   	   SCIP_Bool             islocked;           /**< whether graph is locked, i.e., cannot be modified anymore
50   	                                              *   (computing colors will lock the graph to avoid inconsistencies) */
51   	   SCIP_Real             infinity;           /**< values as least as large as this are regarded as infinite */
52   	
53   	   /* information about nodes and node arrays */
54   	   int                   nnodes;             /**< number of nodes in graph */
55   	   int                   maxnnodes;          /**< maximum number of entries in node-based arrays */
56   	   int                   nopnodes;           /**< number of operator nodes in graph */
57   	   int                   maxnopnodes;        /**< maximum number of entries in operator-based arrays */
58   	   int                   nvalnodes;          /**< number of value nodes in graph */
59   	   int                   maxnvalnodes;       /**< maximum number of entries in value-based arrays */
60   	   int                   nconsnodes;         /**< number of constraint nodes */
61   	   int                   maxnconsnodes;      /**< maximum number of constraint-based arrays */
62   	   int                   nvarcolors;         /**< number of variable colors */
63   	
64   	   /* node-based arrays */
65   	   SYM_NODETYPE*         nodetypes;          /**< array storing each node's type */
66   	   int*                  nodeinfopos;        /**< array assigning each node the position in the corresponding array
67   	                                              *   containing its information (operator, variable, or value) */
68   	   int*                  consnodeperm;       /**< array to hold permutation to sort constraint nodes
69   	                                              *   (graph needs to be locked to avoid inconsistencies) */
70   	
71   	   /* information-based arrays */
72   	   int*                  ops;                /**< operators corresponding to nodes in graph */
73   	   SCIP_Real*            vals;               /**< values corresponding to nodes in graph */
74   	   SCIP_CONS**           conss;              /**< constraints corresponding to cons nodes */
75   	   SCIP_Real*            lhs;                /**< array of left-hand sides for cons nodes */
76   	   SCIP_Real*            rhs;                /**< array of right-hand sides for cons nodes */
77   	
78   	   /* information about edges and edge arrays */
79   	   int                   nedges;             /**< number of edges in graph */
80   	   int                   maxnedges;          /**< maximum number of entries in edge-based arrays */
81   	
82   	   /* edge-based arrays; negative entries in edge-first and edge-second correspond to variables */
83   	   int*                  edgefirst;          /**< array of first nodes of edges */
84   	   int*                  edgesecond;         /**< array of second nodes of edges */
85   	   SCIP_Real*            edgevals;           /**< array assigning each edge a value (SCIPinfinity if unassigned) */
86   	
87   	   /* information about variables */
88   	   SCIP_VAR**            symvars;            /**< variables on which symmetries act */
89   	   int                   nsymvars;           /**< number of variables in symvars */
90   	   SCIP_Bool*            isfixedvar;         /**< whether a variable needs to be fixed */
91   	
92   	   /* arrays of colors used for symmetry detection */
93   	   int*                  varcolors;          /**< variable colors for symmetry detection */
94   	   int*                  opcolors;           /**< operator colors for symmetry detection */
95   	   int*                  valcolors;          /**< value colors for symmetry detection */
96   	   int*                  conscolors;         /**< constraint colors for symmetry detection */
97   	   int*                  edgecolors;         /**< edge colors used for symmetry detection (-1 uncolored) */
98   	   SCIP_Bool             uniqueedgetype;     /**< whether all edges are equivalent */
99   	};
100  	
101  	/** (additional) data used to encode an expression, which is not encoded as another expression */
102  	struct SYM_ExprData
103  	{
104  	   SCIP_Real*            constants;          /**< constants used in an expression */
105  	   int                   nconstants;         /**< number of constants */
106  	   SCIP_Real*            coefficients;       /**< coefficients of children */
107  	   int                   ncoefficients;      /**< number of coefficients */
108  	   SCIP_EXPR**           children;           /**< children of expression with a coefficient */
109  	};
110  	
111  	#ifdef __cplusplus
112  	}
113  	#endif
114  	
115  	#endif
116