Scippy

SCIP

Solving Constraint Integer Programs

pattern.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and library */
4 /* SCIP --- Solving Constraint Integer Programs */
5 /* */
6 /* Copyright (C) 2002-2022 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not visit scipopt.org. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file pattern.h
17  * @brief pattern data for ringpacking problem
18  * @author Benjamin Mueller
19  */
20 
21 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
22 
23 #ifndef __SCIP_PATTERN__
24 #define __SCIP_PATTERN__
25 
26 #include "scip/scip.h"
27 
28 /*
29  * data structures
30  */
31 
33 {
34  SCIP_PACKABLE_NO = 0, /**< pattern is definitely packable */
35  SCIP_PACKABLE_YES = 1, /**< pattern is definitely not packable */
36  SCIP_PACKABLE_UNKNOWN = 2 /**< it is unknown whether pattern is packable */
37 };
39 
41 {
42  SCIP_PATTERNTYPE_CIRCULAR = 0, /**< circular pattern */
43  SCIP_PATTERNTYPE_RECTANGULAR = 1 /**< rectangular pattern */
44 };
46 
48 {
49  BMS_BLKMEM* blkmem; /**< block memory */
50  SCIP_PATTERNTYPE patterntype; /**< pattern type */
51  SCIP_PACKABLE packable; /**< packable status */
52  SCIP_Real* xs; /**< array containing the x-coordinate of each element */
53  SCIP_Real* ys; /**< array containing the y-coordinate of each element */
54  int* types; /**< array storing the type of each element */
55  int size; /**< size of types, xs, and ys arrays */
56  int nelems; /**< number of elements stored */
57  int nlocks; /**< number of locks */
58  int type; /**< type of the boundary circle */
59 };
60 typedef struct SCIP_Pattern SCIP_PATTERN;
61 
62 /** creates an empty circular pattern */
64  SCIP* scip, /**< SCIP data structure */
65  SCIP_PATTERN** pattern, /**< pointer to store pattern */
66  int type /**< circle type (not needed for rectangular patterns) */
67  );
68 
69 /** creates an empty rectangular pattern */
71  SCIP* scip, /**< SCIP data structure */
72  SCIP_PATTERN** pattern /**< pointer to store pattern */
73  );
74 
75 /** captures a pattern */
77  SCIP_PATTERN* pattern /**< pattern */
78  );
79 
80 /* frees a pattern */
82  SCIP* scip, /**< SCIP data structure */
83  SCIP_PATTERN** pattern /**< pointer to free pattern */
84  );
85 
86 /** copies a pattern */
88  SCIP* scip, /**< SCIP data structure */
89  SCIP_PATTERN* pattern, /**< pattern to copy */
90  SCIP_PATTERN** copy /**< pointer to store the copy */
91  );
92 
93 /** adds an element of a given type to a pattern; packable status does not change */
95  SCIP_PATTERN* pattern, /**< pattern */
96  int type, /**< element of a given type */
97  SCIP_Real x, /**< x-coordinate (SCIP_INVALID: unknown) */
98  SCIP_Real y /**< y-coordinate (SCIP_INVALID: unknown) */
99  );
100 
101 /** removes the last k elements */
103  SCIP_PATTERN* pattern, /**< pattern */
104  int k /**< number of elements to remove */
105  );
106 
107 /** returns the total number of elements of a given type in the pattern */
109  SCIP_PATTERN* pattern /**< pattern */
110  );
111 
112 /** returns the type of the i-th element */
114  SCIP_PATTERN* pattern, /**< pattern */
115  int i /**< i-th element */
116  );
117 
118 /** returns the total number of elements of a given type */
120  SCIP_PATTERN* pattern, /**< pattern */
121  int type /**< type */
122  );
123 
124 /** returns the x-coordinate of an element */
126  SCIP_PATTERN* pattern, /**< pattern */
127  int elem /**< index of the element */
128  );
129 
130 /** returns the y-coordinate of an element */
132  SCIP_PATTERN* pattern, /**< pattern */
133  int elem /**< index of the element */
134  );
135 
136 /** sets the (x,y) position of an element */
138  SCIP_PATTERN* pattern, /**< pattern */
139  int elem, /**< index of the element */
140  SCIP_Real x, /**< x-coordinate */
141  SCIP_Real y /**< y-coordinate */
142  );
143 
144 /** returns the type of a pattern */
146  SCIP_PATTERN* pattern /**< pattern */
147  );
148 
149 /** returns the type of the boundary circle
150  *
151  * @note this function can only be called for circular patterns
152  */
154  SCIP_PATTERN *pattern /**< pattern */
155 );
156 
157 /** sets the type of the boundary circle
158  *
159  * @note this function can only be called for circular patterns
160  */
161 void SCIPpatternSetType(
162  SCIP_PATTERN* pattern, /**< pattern */
163  int type /**< type */
164  );
165 
166 /** returns the packable status of a pattern */
168  SCIP_PATTERN* pattern /**< pattern */
169  );
170 
171 /** sets the packable status of a pattern */
173  SCIP_PATTERN* pattern, /**< pattern */
174  SCIP_PACKABLE packable /**< packable status */
175  );
176 
177 #endif /* __SCIP_PATTERN__ */
SCIP_RETCODE SCIPpatternCreateCircular(SCIP *scip, SCIP_PATTERN **pattern, int type)
Definition: pattern.c:88
int SCIPpatternGetCircleType(SCIP_PATTERN *pattern)
Definition: pattern.c:300
int SCIPpatternGetNElemens(SCIP_PATTERN *pattern)
Definition: pattern.c:206
SCIP_PACKABLE packable
Definition: pattern.h:51
SCIP_Patterntype
Definition: pattern.h:40
enum SCIP_Packable SCIP_PACKABLE
Definition: pattern.h:38
enum SCIP_Patterntype SCIP_PATTERNTYPE
Definition: pattern.h:45
void SCIPpatternCapture(SCIP_PATTERN *pattern)
Definition: pattern.c:107
int type
Definition: pattern.h:58
SCIP_PACKABLE SCIPpatternGetPackableStatus(SCIP_PATTERN *pattern)
Definition: pattern.c:326
SCIP_PATTERNTYPE patterntype
Definition: pattern.h:50
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:54
SCIP_RETCODE SCIPpatternCopy(SCIP *scip, SCIP_PATTERN *pattern, SCIP_PATTERN **copy)
Definition: pattern.c:143
SCIP_Real * xs
Definition: pattern.h:52
int nlocks
Definition: pattern.h:57
SCIP_VAR ** x
Definition: circlepacking.c:54
SCIP_Real * ys
Definition: pattern.h:53
SCIP_Real SCIPpatternGetElementPosY(SCIP_PATTERN *pattern, int elem)
Definition: pattern.c:260
int * types
Definition: pattern.h:54
void SCIPpatternRelease(SCIP *scip, SCIP_PATTERN **pattern)
Definition: pattern.c:117
int SCIPpatternCountElements(SCIP_PATTERN *pattern, int type)
Definition: pattern.c:228
void SCIPpatternRemoveLastElements(SCIP_PATTERN *pattern, int k)
Definition: pattern.c:194
void SCIPpatternSetType(SCIP_PATTERN *pattern, int type)
Definition: pattern.c:314
int SCIPpatternGetElementType(SCIP_PATTERN *pattern, int i)
Definition: pattern.c:216
SCIP_Real SCIPpatternGetElementPosX(SCIP_PATTERN *pattern, int elem)
Definition: pattern.c:248
SCIP_RETCODE SCIPpatternAddElement(SCIP_PATTERN *pattern, int type, SCIP_Real x, SCIP_Real y)
Definition: pattern.c:173
#define SCIP_Real
Definition: def.h:177
SCIP_VAR ** y
Definition: circlepacking.c:55
void SCIPpatternSetElementPos(SCIP_PATTERN *pattern, int elem, SCIP_Real x, SCIP_Real y)
Definition: pattern.c:272
SCIP_RETCODE SCIPpatternCreateRectangular(SCIP *scip, SCIP_PATTERN **pattern)
Definition: pattern.c:98
SCIP_Packable
Definition: pattern.h:32
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:430
int size
Definition: pattern.h:55
void SCIPpatternSetPackableStatus(SCIP_PATTERN *pattern, SCIP_PACKABLE packable)
Definition: pattern.c:336
SCIP callable library.
BMS_BLKMEM * blkmem
Definition: pattern.h:49
int nelems
Definition: pattern.h:56
SCIP_PATTERNTYPE SCIPpatternGetPatternType(SCIP_PATTERN *pattern)
Definition: pattern.c:287