constraints.h
1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
extern int _fd_constraint_count;
extern fd_constraint _fd_constraints[];
#define CONSTRAINT(v,c) _fd_constraints[(v)->constraints[c]]
#ifdef CONSTRAINT_CLASS
typedef enum {
FD_CONSTR_NE = 0,
FD_CONSTR_EQ,
FD_CONSTR_LT,
FD_CONSTR_GT = FD_CONSTR_LT, // XXX: is this standard C?
FD_CONSTR_LE,
FD_CONSTR_GE = FD_CONSTR_LE, // XXX: is this standard C?
FD_CONSTR_MINUS_NE,
FD_CONSTR_MINUS_EQ,
FD_CONSTR_PLUS_GT,
FD_CONSTR_VAR_EQ_MINUS,
FD_CONSTR_ALL_DIFFERENT,
FD_CONSTR_EXACTLY_ONE,
FD_CONSTR_NOGOODS,
FD_CONSTR_EXACTLY,
FD_CONSTR_EXACTLY_VAR,
FD_CONSTR_SUM,
FD_CONSTR_VAR_EQ_TIMES,
FD_CONSTR_SUM_PROD,
FD_CONSTR_ELEMENT,
FD_CONSTR_KNAPSACK2,
FD_CONSTR_SUM2,
FD_CONSTR_MIN,
FD_CONSTR_MAX,
FD_CONSTR_POLY_EQ,
FD_CONSTR_ELEMENT_VAR,
FD_CONSTR_EXACTLY_VARS,
FD_CONSTR_POLY_EQ_K,
FD_CONSTR_POLY_NE,
FD_CONSTR_POLY_NE_K,
FD_CONSTR_KINDS // number of kinds of constraints
} _fd_constraint_kind;
typedef struct _fd_constraint_class {
int (*propagator2)(fd_constraint, fd_int);
int (*filter)(fd_constraint);
} _fd_constraint_class;
extern _fd_constraint_class _fd_constraint_data[FD_CONSTR_KINDS];
#define _FD_CONSTRAINT_INITIALISATION(name, code) \
static void _fd_ ## name ## _init(_fd_constraint_class data[]) \
{ \
data[code].propagator2 = fd_ ## name ## _propagate2; \
data[code].filter = fd_ ## name ## _filter; \
}
#define _fd_init_constraint(name) _fd_ ## name ## _init(_fd_constraint_data)
#define _fd_propagate(c,v) (_fd_constraint_data[(c)->kind].propagator2(c, v))
#define _fd_filter(c) (_fd_constraint_data[(c)->kind].filter(c))
#else /* CONSTRAINT_CLASS */
#define _fd_propagate(c,v) ((c)->propagator2(c, v))
#define _fd_filter(c) ((c)->filter(c))
#endif /* CONSTRAINT_CLASS */
#if defined(CONSTRAINT_TEMPS) && !defined(DISABLE_ENTAILED)
int fd__constraint_entailed(fd_constraint);
#else
#define fd__constraint_entailed(_) 0
#endif