1 package org.sat4j.csp.xml;
2 public interface ICSPCallback {
3
4 /**
5 * signal the beginning of parsing
6 *
7 * @param name
8 * name of the instance
9 */
10 void beginInstance(String name);
11
12 /** ***************************************************************** */
13
14 /**
15 * callback called at the beginning of the domains declarations
16 *
17 * @param nbDomains
18 * number of domains that will be declared
19 */
20 void beginDomainsSection(int nbDomains);
21
22 /**
23 * callback called at the beginning of the declaration of one domain
24 *
25 * @param name
26 * identifier of the domain
27 * @param nbValue
28 * number of values in the domain
29 */
30 void beginDomain(String name, int nbValue);
31
32 /**
33 * add a single value to the current domain
34 *
35 * @param v
36 * value to add to the domain
37 */
38 void addDomainValue(int v);
39
40 /**
41 * add the range of values [first..last] to the current domain
42 *
43 * @param first
44 * first value to add to the domain
45 * @param last
46 * last value to add to the domain
47 */
48 void addDomainValue(int first, int last);
49
50 /**
51 * ends the definition of the current domain
52 */
53 void endDomain();
54
55 /**
56 * end the definition of all domains
57 */
58 void endDomainsSection();
59
60 /** ***************************************************************** */
61
62 /**
63 * callback called at the beginning of the variables declarations
64 *
65 * @param nbVariables
66 * number of variables that will be declared
67 */
68 void beginVariablesSection(int nbVariables);
69
70 /**
71 * callback called to define a new variable
72 *
73 * @param name
74 * identifier of the variable
75 * @param domain
76 * identifier of the variable domain
77 */
78 void addVariable(String name, String domain);
79
80 /**
81 * end the definition of all variables
82 */
83 void endVariablesSection();
84
85 /** ***************************************************************** */
86
87 /**
88 * callback called at the beginning of the relations declarations
89 *
90 * @param nbRelations
91 * number of relations that will be declared
92 */
93 void beginRelationsSection(int nbRelations);
94
95 /**
96 * callback called at the beginning of the declaration of one relation
97 *
98 * @param name
99 * identifier of the relation
100 * @param arity
101 * arity of the relation
102 * @param nbTuples
103 * number of tuples in the relation
104 * @param isSupport
105 * true if tuples represent support, false if tuples represent
106 * conflicts
107 */
108 void beginRelation(String name, int arity, int nbTuples, boolean isSupport);
109
110 /**
111 * add a single tuple to the current relation
112 *
113 * @param tuple
114 * tuple to add to the relation (contains arity elements)
115 */
116 void addRelationTuple(int tuple[]);
117
118 /**
119 * ends the definition of the current relation
120 */
121 void endRelation();
122
123 /**
124 * end the definition of all relations
125 */
126 void endRelationsSection();
127
128 /** ***************************************************************** */
129
130 /**
131 * callback called at the beginning of the predicates declarations
132 *
133 * @param nbPredicates
134 * number of predicates that will be declared
135 */
136 void beginPredicatesSection(int nbPredicates);
137
138 /**
139 * callback called at the beginning of the declaration of one predicate
140 *
141 * @param name
142 * identifier of the predicate
143 */
144 void beginPredicate(String name);
145
146 /**
147 * add a formal parameter to the current predicate
148 *
149 * @param name
150 * name of the parameter
151 * @param type
152 * type of the parameter
153 */
154 void addFormalParameter(String name, String type);
155
156 /**
157 * provide the expression of the current predicate
158 *
159 * @param expr
160 * the abstract syntax tree representing the expression
161 */
162 void predicateExpression(String expr);
163
164 /**
165 * ends the definition of the current predicate
166 */
167 void endPredicate();
168
169 /**
170 * end the definition of all predicates
171 */
172 void endPredicatesSection();
173
174 /** ***************************************************************** */
175
176 /**
177 * callback called at the beginning of the constraints declarations
178 *
179 * @param nbConstraints
180 * number of constraints that will be declared
181 */
182 void beginConstraintsSection(int nbConstraints);
183
184 /**
185 * callback called at the beginning of the declaration of one constraint
186 *
187 * @param name
188 * identifier of the constraint
189 * @param arity
190 * arity of the constraint
191 */
192 void beginConstraint(String name, int arity);
193
194 /**
195 * provide the definition of the current constraint
196 *
197 * @param name
198 * the refererence to the definition of this constraint. May be a
199 * relation, a predicate or the name of a global constraint
200 */
201 void constraintReference(String name);
202
203 /**
204 * declares that a variable is in the constraint scope
205 *
206 * @param name
207 * name of the variable
208 */
209 void addVariableToConstraint(String name);
210
211 /**
212 * add an effective parameter which is a simple variable to the current
213 * constraint
214 *
215 * @param name
216 * name of the variable passed as parameter
217 */
218 void addEffectiveParameter(String name);
219
220 /**
221 * add an effective parameter which is a simple integer
222 *
223 * @param value
224 * value of the parameter
225 */
226 void addEffectiveParameter(int value);
227
228 /**
229 * begins the list tag for parameters of a constraint
230 */
231 void beginParameterList();
232
233 /**
234 * provides an integer value in a parameter list of a constraint
235 * @param value
236 * value of current list item
237 */
238 void addIntegerItem(int value);
239
240 /**
241 * provides the name of a variable in a parameter list of a constraint
242 * @param name
243 * name of the current list item
244 */
245 void addVariableItem(String name);
246
247 /**
248 * ends the list tag for parameters of a constraint
249 */
250 void endParamaterList();
251
252 /**
253 * provides a constant value
254 */
255 void addConstantParameter(String name, int value);
256
257
258 /**
259 * provide the expression of the current constraint as an expression in a
260 * syntac chosen by the solver
261 *
262 * @param expr
263 * the expression
264 */
265 void constraintExpression(String expr);
266
267 /**
268 * ends the definition of the current constraint
269 */
270 void endConstraint();
271
272 /**
273 * end the definition of all constraints
274 */
275 void endConstraintsSection();
276
277 /** ***************************************************************** */
278
279 /**
280 * signal the end of parsing
281 */
282 void endInstance();
283 };