Blame view

src/constraints.h 1.9 KB
965dadaa   Salvador Abreu   initial commit fr...
1
2
3
4
5
6

extern int _fd_constraint_count;
extern fd_constraint _fd_constraints[];

#define CONSTRAINT(v,c) _fd_constraints[(v)->constraints[c]]

965dadaa   Salvador Abreu   initial commit fr...
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
#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,
659ea9b8   Vasco Pedro   new constraints p...
34
35
36
  FD_CONSTR_ELEMENT_VAR,
  FD_CONSTR_EXACTLY_VARS,
  FD_CONSTR_POLY_EQ_K,
eef94371   Vasco Pedro   Update to PaCCS v...
37
  FD_CONSTR_POLY_NE,
965dadaa   Salvador Abreu   initial commit fr...
38
39
40
41
42
  FD_CONSTR_POLY_NE_K,
  FD_CONSTR_KINDS		// number of kinds of constraints
} _fd_constraint_kind;

typedef struct _fd_constraint_class {
eef94371   Vasco Pedro   Update to PaCCS v...
43
44
45
46
47
48
  int (*propagator2)(fd_constraint, fd_int);
  int (*filter)(fd_constraint);
} _fd_constraint_class;

extern _fd_constraint_class _fd_constraint_data[FD_CONSTR_KINDS];

965dadaa   Salvador Abreu   initial commit fr...
49

eef94371   Vasco Pedro   Update to PaCCS v...
50
51
#define _FD_CONSTRAINT_INITIALISATION(name, code) \
  static void _fd_ ## name ## _init(_fd_constraint_class data[]) \
965dadaa   Salvador Abreu   initial commit fr...
52
53
  { \
    data[code].propagator2 = fd_ ## name ## _propagate2; \
eef94371   Vasco Pedro   Update to PaCCS v...
54
    data[code].filter = fd_ ## name ## _filter; \
965dadaa   Salvador Abreu   initial commit fr...
55
56
57
58
  }

#define _fd_init_constraint(name) _fd_ ## name ## _init(_fd_constraint_data)

eef94371   Vasco Pedro   Update to PaCCS v...
59
#define _fd_propagate(c,v) (_fd_constraint_data[(c)->kind].propagator2(c, v))
965dadaa   Salvador Abreu   initial commit fr...
60
#define _fd_filter(c) (_fd_constraint_data[(c)->kind].filter(c))
965dadaa   Salvador Abreu   initial commit fr...
61

eef94371   Vasco Pedro   Update to PaCCS v...
62
63
64
65
66
67
68
69
70
#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);
965dadaa   Salvador Abreu   initial commit fr...
71
#else
eef94371   Vasco Pedro   Update to PaCCS v...
72
#define fd__constraint_entailed(_) 0
965dadaa   Salvador Abreu   initial commit fr...
73
#endif