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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019 | /*=============================================================================
* parser for CSP instances represented in XCSP3 Format
*
* Copyright (c) 2015 xcsp.org (contact <at> xcsp.org)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*=============================================================================
*/
#ifndef COSOCO_XCSP3CORECALLBACKS_H
#define COSOCO_XCSP3CORECALLBACKS_H
#include "XCSP3Constants.h"
#include "XCSP3Variable.h"
#include "XCSP3Constraint.h"
#include "XCSP3Tree.h"
#include <vector>
#include <string>
namespace XCSP3Core {
using namespace std;
class XCSP3CoreCallbacks {
protected :
vector<string> classesToDiscard;
public :
/**
* If true, the intension constraint are retrieved with an expression (nothing is done in order to help you)
* (false by default)
* Otherwise, the callback that take a canonized tree of the expression is called
*/
bool intensionUsingString;
/**
* If true, the parse recognizes special intensional constraints such as x + k op y and call a specific callback.
*/
bool recognizeSpecialIntensionCases;
/**
* If true, the parser recognizes special count constraints: atleast, atmost, exactly, among, exctalyVariable
* and call a specific callback
*/
bool recognizeSpecialCountCases;
/**
* If true, the parser recognizes special nvalues constraints: AllEqual, NotAllEqual, AllDiff
* and call a specific callback
*/
bool recognizeNValuesCases;
/**
* if true, sum are normalized: merge same variables, remove variables with coef equal to zero..
*/
bool normalizeSum;
XCSP3CoreCallbacks() {
intensionUsingString = false;
recognizeSpecialIntensionCases = true;
recognizeSpecialCountCases = true;
recognizeNValuesCases = true;
normalizeSum = true;
}
/**
* remove specific classes such as symmetryBreaking, clues...
* @param cl
*/
void addClassToDiscard(string cl) {
classesToDiscard.push_back(cl);
}
bool discardedClasses(string classes) {
if(classes == "")
return false;
for(string c : classesToDiscard)
if(classes.find(c) != std::string::npos)
return true;
return false;
}
// All these callbacks are called when the tag starts and when it ends.
// This is not necessary to override them.
/**
* Start to parse a XCSP instance.
* Related to tag <instance type="CSP/COP">
* See http://xcsp.org/specifications/skeleton
* @param type COP or CSP
*/
virtual void beginInstance(InstanceType type) {}
/**
* End of parsing
* Related to tag </instance>
* See http://xcsp.org/specifications/skeleton
*/
virtual void endInstance() {}
/**
* Start to parse variables
* Related to tag <variables>
* See http://xcsp.org/specifications/skeleton
*/
virtual void beginVariables() {}
/**
* The end of parsing variables
* Related to tag </variables>
* See http://xcsp.org/specifications/skeleton
*/
virtual void endVariables() {}
/**
* Start to parse an array of variables
* Related to tag <array>
* See http://xcsp.org/specifications/arrays
* Note that for each variable in the array a call is done to one of the functions #buildVariableInteger
*
* @param id the id (name) of the array variable
*/
virtual void beginVariableArray(string id) {} //beginArray
/**
* End of parsing an array of variables
* Related to tag </array>
* See http://xcsp.org/specifications/arrays
*/
virtual void endVariableArray() {}
/**
* Start to parse constraints
* Related to tag <constraints>
* See http://xcsp.org/specifications/skeleton
*/
virtual void beginConstraints() {}
/**
* The end of parsing constraints
* Related to tag </constraints>
* See http://xcsp.org/specifications/skeleton
*/
virtual void endConstraints() {}
/**
* Start to parse a group of constraints
* Related to tag <group>
* See http://xcsp.org/specifications/groups
* Note that for each constraint of the group a call is done to the related callback
*
* @param id the id (name) of the group
*/
virtual void beginGroup(string id) {}
/**
* The end of parsing group of constraints
* Related to tag </group>
* See http://xcsp.org/specifications/groups
*/
virtual void endGroup() {}
/**
* Start to parse a block of constraints
* Related to tag <block>
* See http://xcsp.org/specifications/blocks
* Note that for each constraint of the block a call is done to the related callback
*
* Note that if you want to discard some blocks, you need to call the function addClassToDiscard with the related class
*
* @param classes the classes related to the block symmetryBreaking, clues...
*/
virtual void beginBlock(string classes) {}
/**
* The end of parsing a block of constraints
* Related to tag </block>
* See http://xcsp.org/specifications/blocks
*/
virtual void endBlock() {}
/**
* Start to parse a slide constraint
* Related to tag <slide>
* See http://xcsp.org/specifications/slide
* Note that for each constraint of the block a call is done to the related callback
*
* @param id the id (name) of the slide
* @param circular is the slide circular?
*/
virtual void beginSlide(string id, bool circular) {}
/**
* The end of parsing a slide constraint
* Related to tag </slide>
* See http://xcsp.org/specifications/slide
*/
virtual void endSlide() {}
/**
* Start to parse objectives
* Related to tag <objectives>
* See http://xcsp.org/specifications/objectives
*/
virtual void beginObjectives() {}
/**
* The end of parsing objectives
* Related to tag </objectives>
* See http://xcsp.org/specifications/objectives
*/
virtual void endObjectives() {}
/**
* The start of parsing annotations
* Related to tag </annotations>
*/
virtual void beginAnnotations() {}
/**
* The end of parsing annotations
* Related to tag </annotations>
*/
virtual void endAnnotations() {}
//--------------------------------------------------------------------------------------
// Build Variable. Must be implemented.
//--------------------------------------------------------------------------------------
/**
* The callback function related to an integer variable with a range domain
* See http://xcsp.org/specifications/integers
*
* Example: <var id="bar"> 0..6 </var>
*
* @param id the id (name) of the group
* @param minValue the minimum value in the range
* @param maxValue the maxnimum value in the range
*/
virtual void buildVariableInteger(string id, int minValue, int maxValue) = 0;
/**
* The callback function related to an integer variable with a domain consisting in a sequence of integers
* See http://xcsp.org/specifications/integers
*
* Example <var id="bar"> 1 3 5 10 </var>
*
* @param id the id (name) of the group
* @param values the set of values in the domain
*/
virtual void buildVariableInteger(string id, vector<int> &values) = 0;
/**
* All callbacks related to constraints.
* Note that the variables related to a constraint are #XVariable instances. A XVariable contains an id and
* the related domain.
* (see XCSP3Variable.h)
*
*/
//--------------------------------------------------------------------------------------
// Universal Constraints
//--------------------------------------------------------------------------------------
/**
* The special constraint always true
* Nothing to do
* @param id
* @param list
*/
virtual void buildConstraintTrue(string id) {}
/**
* The special constraint always false
* The problem is unsatisfiable
* @param id
* @param list
*/
virtual void buildConstraintFalse(string id) {
std::cout << "c constraint " + id + " is always false (see during parsing)\n";
std::cout << "s UNSATISFIABLE\n";
}
//--------------------------------------------------------------------------------------
// Basic constraints
//--------------------------------------------------------------------------------------
/**
* The callback function related to an constraint in extension
* See http://xcsp.org/specifications/extension
*
* Example:
* <extension>
* <list> y1 y2 y3 y4 </list>
* <conflicts> (1,2,3,4)(3,1,3,4) </conflicts>
* </extension>
*
* @param id the id (name) of the constraint
* @param list the scope of the constraint
* @param tuples the set of tuples in the constraint
* @param support support or conflicts?
* @param hasStar is the tuples contain star values?
*/
virtual void buildConstraintExtension(string id, vector<XVariable *> list, vector<vector<int>> &tuples, bool support, bool hasStar) {
std::cout << "WARNING: tuples are not checked wrt domains" << std::endl;
throw runtime_error("extension constraint is not yet supported");
}
/*
* The callback function related to an constraint in extension
* Note that this callback is related to an unary constraint
* See http://xcsp.org/specifications/extension
* Example:
* <extension>
* <list> x </list>
* <conflicts> 2 6 </conflicts>
* </extension>
*
* @param id the id (name) of the constraint
* @param variable the variable
* @param tuples the set of tuple (here just set of ints)
* @param support support or conflicts?
* @param hasStar is the tuples contain star values?
*/
virtual void buildConstraintExtension(string id, XVariable *variable, vector<int> &tuples, bool support, bool hasStar) {
throw runtime_error("unary extension constraint is not yet supported");
}
/**
* The callback function related to a constraint in extension where the set of tuples is exactly the same
* than the previous one.
* It is the case when a group of constraint contains an extension constraint.
* This is useful to save space and share the set of tuples of all constraints.
*
* @param id the id (name) of the constraint
* @param list the scope of the constraint
* @param support support or conflicts?
* @param hasStar is the tuples contain star values?
*/
virtual void buildConstraintExtensionAs(string id, vector<XVariable *> list, bool support, bool hasStar) {
throw runtime_error("This extension constraint contains exactly the same tuples than previous one");
}
/**
* The callback function related to a constraint in intension
* Only called if intensionUsingString is set to true (otherwise the next function is called
* See http://xcsp.org/specifications/intension
* Example:
* <intension> eq(add(x,y),z) </intension>
* If you need a class that is able to manage expressions you can use the class Tree (see includes/XCS3Tree.h)
* And an example is given in samples/testTree.cc
* In such a case, set intensionUsingString to false and make a callback to the next function
*
* @param id the id (name) of the constraint
* @param expr the expression
*/
virtual void buildConstraintIntension(string id, string expr) {
throw runtime_error("intension constraint is not yet supported");
}
/**
* The callback function related to a constraint in intension
* Only called if intensionUsingString is set to false (otherwise the previous function is called
* See http://xcsp.org/specifications/intension
* Example:
* <intension> eq(add(x,y),z) </intension>
*
* @param id the id (name) of the constraint
* @param tree the canonized form related to the tree
*/
virtual void buildConstraintIntension(string id, Tree *tree) {
throw runtime_error("intension constraint using a tree is not yet supported (choose the right way)");
}
/**
* If #recognizeSpecialIntensionCases is enabled (this is the case by default)
* intensional constraint of the form : x +-k op y is recognized.
* If such a intensional constraint is recognized, a callback to this function is done and not to #buildConstraintIntension
*
* @param id the id (name) of the constraint
* @param op the order LE, LT...
* @param x the variable
* @param k the constant
* @param y the other variable
*/
virtual void buildConstraintPrimitive(string id, OrderType op, XVariable *x, int k, XVariable *y) {
throw runtime_error("primitive constraint x +-k op y is not yet supported. "
"You can use classical intension constrain by assigning recognizeSpecialIntensionCases to false ");
}
/**
* If #recognizeSpecialIntensionCases is enabled (this is the case by default)
* intensional constraint of the form : x op k is recognized.
* If such a intensional constraint is recognized, a callback to this function is done and not to #buildConstraintIntension
*
* @param id the id (name) of the constraint
* @param op the order LE or GE (EQ and NE are performed using #buildConstrantExtension)
* @param x the variable
* @param k the constant
*/
virtual void buildConstraintPrimitive(string id, OrderType op, XVariable *x, int k) {
throw runtime_error("primitive constraint x op k is not yet supported. "
"You can use classical intension constrain by assigning recognizeSpecialIntensionCases to false ");
}
/**
* If #recognizeSpecialIntensionCases is enabled (this is the case by default)
* intensional constraint of the form : x in/notin [min max] are recognized
* If such a intensional constraint is recognized, a callback to this function is done and not to #buildConstraintIntension
*
* @param id the id (name) of the constraint
* @param x the variable
* @param in true if x is in this interval
* @param min the constant
* @param max the constant
*
*/
virtual void buildConstraintPrimitive(string id, XVariable *x, bool in, int min, int max) {
throw runtime_error("primitive constraint x in/notin [min,max] is not yet supported. "
"You can use classical intension constrain by assigning recognizeSpecialIntensionCases to false ");
}
//--------------------------------------------------------------------------------------
// Language constraints
//--------------------------------------------------------------------------------------
/**
* The callback function related to a regular constraint.
* See http://xcsp.org/specifications/regular
* Example:
* <regular>
* <list> x1 x2 x3 x4 x5 x6 x7 </list>
* <transitions>
* (a,0,a)(a,1,b)(b,1,c)(c,0,d)(d,0,d)(d,1,e)(e,0,e)
* </transitions>
* <start> a </start>
* <final> e </final>
* </regular>
* XTransition is an object with 3 fields: from (string), val(int) and to(string)
* Then, in the first transition of the example from=a, to=a and val=0
*
* @param id the id (name) of the constraint
* @param list the scope of the constraint
* @param start the starting node
* @param final the set of final nodes
* @param transitions the set of transitions
*/
virtual void buildConstraintRegular(string id, vector<XVariable *> &list, string start, vector<string> &final, vector<XTransition> &transitions) {
throw runtime_error("regular constraint is not yet supported");
}
/**
* The callback function related to a MDD constraint.
* See http://xcsp.org/specifications/mdd
*
* Example:
* <mdd>
* <list> x1 x2 x3 </list>
* <transitions>
* (r,0,n1)(r,1,n2)(r,2,n3)
* (n1,2,n4)(n2,2,n4)(n3,0,n5)
* (n4,0,t)(n5,0,t)
* </transitions>
* </mdd>
*
* @param id the id (name) of the constraint
* @param list the scope of the constraint
* @param transitions the set of transitions
*/
virtual void buildConstraintMDD(string id, vector<XVariable *> &list, vector<XTransition> &transitions) {
throw runtime_error("MDD constraint is not yet supported");
}
//--------------------------------------------------------------------------------------
// Comparison constraints
//--------------------------------------------------------------------------------------
/**
* The callback function related to a alldifferent constraint.
* See http://xcsp.org/specifications/alldifferent
*
* Example:
* <allDifferent>
* x1 x2 x3 x4 x5
* </allDifferent>
*
* @param id the id (name) of the constraint
* @param list the scope of the constraint
*/
virtual void buildConstraintAlldifferent(string id, vector<XVariable *> &list) {
throw runtime_error("AllDiff constraint is not yet supported");
}
/**
* The callback function related to a alldifferent constraint with expression
* See http://xcsp.org/specifications/alldifferent
*
* Example:
* <allDifferent>
* add(q[0],0) add(q[1],1) add(q[2],2) add(q[3],3) add(q[4],4) add(q[5],5) add(q[6],6) add(q[7],7)
* </allDifferent>
*
* @param id the id (name) of the constraint
* @param list the trees of the constraint
*/
virtual void buildConstraintAlldifferent(string id, vector<Tree *> &list) {
throw runtime_error("AllDiff constraint with expression is not yet supported");
}
/**
* The callback function related to a alldifferent with some excepted values constraint
* See http://xcsp.org/specifications/alldifferent
*
* Example:
* <allDifferent>
* x1 x2 x3 x4 x5
* <except>0</except>
* </allDifferent>
*
* @param id the id (name) of the constraint
* @param list the scope of the constraint
* @param except the set of excepted values
*/
virtual void buildConstraintAlldifferentExcept(string id, vector<XVariable *> &list, vector<int> &except) {
throw runtime_error("AllDiff constraint with exception is not yet supported");
}
/**
* The callback function related to a alldifferent list constraint
* See http://xcsp.org/specifications/alldifferent
*
* Example:
* <allDifferent id="c1">
* <list> x1 x2 x3 x4 </list>
* <list> y1 y2 y3 y4 </list>
* </allDifferent>
*
* @param id the id (name) of the constraint
* @param lists the set of lists (not the scope, a variable may appear at different place!)
*/
virtual void buildConstraintAlldifferentList(string id, vector<vector<XVariable *>> &lists) {
throw runtime_error("AllDiff list constraint is not yet supported");
}
/**
* The callback function related to a alldifferent matrix constraint
* See http://xcsp.org/specifications/alldifferent
*
* Example:
* <allDifferent id="c1">
* <matrix>
* (x1,x2,x3,x4,x5)
* (y1,y2,y3,y4,y5)
* (z1,z2,z3,z4,z5)
* </matrix>
* </allDifferent>
*
* @param id the id (name) of the constraint
* @param matrix the matrix (not the scope, a variable may appear at different place!)
*/
virtual void buildConstraintAlldifferentMatrix(string id, vector<vector<XVariable *>> &matrix) {
throw runtime_error("AllDiff matrix constraint is not yet supported");
}
/**
* The callback function related to a allequal constraint
* See http://xcsp.org/specifications/allEqual
*
* Example:
* <allEqual>
* x1 x2 x3 x4 x5
* </allEqual>
*
* @param id the id (name) of the constraint
* @param list the scope of the constraint
*
*/
virtual void buildConstraintAllEqual(string id, vector<XVariable *> &list) {
throw runtime_error("Allequal constraint is not yet supported");
}
/**
* The callback function related to a not all equal constraint
* This is a special case of nvalues constraint
* Recognized if #recognizeNValuesCases is enabled (this is the case by default)
* See http://xcsp.org/specifications/nValues
*
* Example:
* <nValues id="c1">
* <list> x1 x2 x3 x4 </list>
* <condition> (gt,1) </condition>
* </nValues>
*
* @param id the id (name) of the constraint
* @param list the scope of the constraint
*/
virtual void buildConstraintNotAllEqual(string id, vector<XVariable *> &list) {
throw runtime_error("NotAllequal constraint is not yet supported");
}
/**
* The callback function related to an ordered constraint
* See http://xcsp.org/specifications/ordered
*
* Ordered is LE, LT, GE, GT... See OrderType in XCSPConstants.h
*
* Example:
* <ordered>
* <list> x1 x2 x3 x4 </list>
* <operator> lt </operator>
* </ordered>
*
* @param id the id (name) of the constraint
* @param list the scope of the constraint
* @param order the order LT, LE...
*/
virtual void buildConstraintOrdered(string id, vector<XVariable *> &list, OrderType order) {
throw runtime_error("Ordered constraint is not yet supported");
}
/**
* The callback function related to an ordered constraint
* See http://xcsp.org/specifications/ordered
*
* Ordered is LE, LT, GE, GT... See OrderType in XCSPConstants.h
*
* Example:
* <ordered>
* <list> x1 x2 x3 x4 </list>
* <operator> lt </operator>
* </ordered>
*
* @param id the id (name) of the constraint
* @param list the scope of the constraint
* @param order the order LT, LE...
*/
virtual void buildConstraintOrdered(string id, vector<XVariable *> &list, vector<int> &lengths, OrderType order) {
throw runtime_error("Ordered constraint with lengths is not yet supported");
}
/**
* The callback function related to an ordered list constraint (this is a lex constraint)
* See http://xcsp.org/specifications/ordered
*
*
* Example:
* <ordered>
* <list> x1 x2 x3 x4 </list>
* <list> y1 y2 y3 y4 </list>
* <operator> lt </operator>
* </ordered>
*
* @param id the id (name) of the constraint
* @param lists the set of lists (not the scope, a variable may appear at different place!)
* @param order the order LT, LE...
*/
virtual void buildConstraintLex(string id, vector<vector<XVariable *>> &lists, OrderType order) {
throw runtime_error("Lex constraint is not yet supported");
}
/**
* The callback function related to an ordered matrix constraint
* See http://xcsp.org/specifications/ordered
*
*
* Example:
* <ordered>
* <matrix>
* (z1,z2,z3)
* (z4,z5,z6)
* (z7,z8,z9)
* </matrix>
* <operator> lt </operator>
* </ordered>
*
* @param id the id (name) of the constraint
* @param matrix the matrix (not the scope, a variable may appear at different place!)
* @param order the order LT, LE...
*/
virtual void buildConstraintLexMatrix(string id, vector<vector<XVariable *>> &matrix, OrderType order) {
throw runtime_error("Lex matrix constraint is not yet supported");
}
//--------------------------------------------------------------------------------------
// Summing and counting constraints
//--------------------------------------------------------------------------------------
/**
* The callback function related to an sum constraint
* See http://xcsp.org/specifications/sum
*
* XCondition is an object with on OrderType (LE, LT...) an operandType (INTEGER, INTERVAL or VARIABLE)
* depending the value of this field, either val (if operandType is INTEGER), min/max (INTERVAL) or var (VARIABLE)
* is useful.
* Example:
* <sum>
* <list> x1 x2 x3 </list>
* <coeffs> 1 2 3 </coeffs>
* <condition> (gt,y) </condition>
* </sum>
*
* @param id the id (name) of the constraint
* @param list the scope of the constraint
* @param coeffs the coefficients (here int)
* @param cond the condition (See XCondition object)
*/
virtual void buildConstraintSum(string id, vector<XVariable *> &list, vector<int> &coeffs, XCondition &cond) {
throw runtime_error("sum constraint is not yet supported");
}
/**
* The callback function related to an sum constraint with all coefs are equal to one
* See http://xcsp.org/specifications/sum
*
* Example:
* <sum>
* <list> x1 x2 x3 </list>
* <condition> (gt,y) </condition>
* </sum>
*
* @param id the id (name) of the constraint
* @param list the scope of the constraint
* @param cond the condition (See XCondition object)
*/
virtual void buildConstraintSum(string id, vector<XVariable *> &list, XCondition &cond) {
throw runtime_error("unweighted sum constraint is not yet supported");
}
/**
* The callback function related to a sum constraint with all coefs are variables
* See http://xcsp.org/specifications/sum
*
* Example:
* <sum>
* <list> x1 x2 x3 </list>
* <coeffs> y1 y2 y3 </coeffs>
* <condition> (gt,y) </condition>
* </sum>
*
* @param id the id (name) of the constraint
* @param list the scope of the constraint
* @param coeffs the coefficients (here XVariable)
* @param cond the condition (See XCondition object)
*/
virtual void buildConstraintSum(string id, vector<XVariable *> &list, vector<XVariable *> &coeffs, XCondition &cond) {
throw runtime_error("sum constraint with variables weights is not yet supported");
}
/**
* The callback function related to a sum constraint with trees in list
*
* Example:
* <sum>
* <list>or(eq(x[5],0),eq(x[7],0)) or(eq(x[1],0),eq(x[2],0),eq(x[8],0)) or(eq(x[0],0),eq(x[3],0),eq(x[4],0),eq(x[6],0),eq(x[9],0))</list>
* <condition> (gt,y) </condition>
* </sum>
*
* @param id the id (name) of the constraint
* @param list the different trees
* @param cond the condition (See XCondition object)
*/
virtual void buildConstraintSum(string id, vector<Tree *> &trees, XCondition &cond) {
throw runtime_error("sum constraint with expressions not yet supported");
}
/**
* The callback function related to a sum constraint with trees in list
*
* Example:
* <sum>
* <list>or(eq(x[5],0),eq(x[7],0)) or(eq(x[1],0),eq(x[2],0),eq(x[8],0)) or(eq(x[0],0),eq(x[3],0),eq(x[4],0),eq(x[6],0),eq(x[9],0))</list>
* <coeffs>1 2 3</coeffs>
* <condition> (gt,y) </condition>
* </sum>
*
* @param id the id (name) of the constraint
* @param list the different trees
* @param coefs the coefs.
* @param cond the condition (See XCondition object)
*/
virtual void buildConstraintSum(string id, vector<Tree *> &trees, vector<int> &coefs, XCondition &cond) {
throw runtime_error("sum constraint with expressions and coefs not yet supported");
}
/**
* The callback function related to a atmost constraint
* This is a special count constraint
* This callback is called if #recognizeSpecialCountCases is enabled (this is the case by default)
* See http://xcsp.org/specifications/count
*
*
* Example:
* <count id="c4">
* <list> y1 y2 y3 y4 </list>
* <values> 0 </values>
* <condition> (le,2) </condition>
* </count>
*
* Here at most 2 variables from y1...y4 can have value 0
*
*
* @param id the id (name) of the constraint
* @param list the scope of the constraint
* @param value the value
* @param k the maximum number of variables that can take the value
*/
virtual void buildConstraintAtMost(string id, vector<XVariable *> &list, int value, int k) {
throw runtime_error("atmost constraint is not yet supported");
}
/**
* The callback function related to a atleast constraint
* This is a special count constraint
* This callback is called if #recognizeSpecialCountCases is enabled
* See http://xcsp.org/specifications/count
*
*
* Example:
* <count id="c3">
* <list> x1 x2 x3 x4 x5 </list>
* <values> 1 </values>
* <condition> (ge,3) </condition>
* </count>
*
* Here at least 3 variables from x1...x5 must have value 1
*
* @param id the id (name) of the constraint
* @param list the scope of the constraint
* @param value the value
* @param k the minimum number of variables that can take the value
*/
virtual void buildConstraintAtLeast(string id, vector<XVariable *> &list, int value, int k) {
throw runtime_error("atleast constraint is not yet supported");
}
/**
* The callback function related to a exactly k constraint
* This is a special count constraint
* This callback is called if #recognizeSpecialCountCases is enabled
* See http://xcsp.org/specifications/count
*
*
* Example:
* <count id="c5">
* <list> z1 z2 z3 Z4</list>
* <values> 0 </values>
* <condition> (eq,2) </condition>
* </count>
* Here exactly 2 variables from z1...z4 must have value 0
*
* @param id the id (name) of the constraint
* @param list the scope of the constraint
* @param value the value
* @param k the exact number of variables that can take the value
*/
virtual void buildConstraintExactlyK(string id, vector<XVariable *> &list, int value, int k) {
throw runtime_error("exactly K constraint is not yet supported");
}
/**
* The callback function related to a exactly k variable constraint
* This is a special count constraint
* This callback is called if #recognizeSpecialCountCases is enabled
* See http://xcsp.org/specifications/count
*
*
* Example:
* <count id="c5"> <!-- exactly -->
* <list> z1 z2 z3 Z4</list>
* <values> 0 </values>
* <condition> (eq,z5) </condition>
* </count>
* Here exactly z5 variables from z1...z4 must have value 0
* @param id the id (name) of the constraint
* @param list the scope of the constraint
* @param value the value
* @param x the exact number of variables that can take the value (here it is a variable)
*/
virtual void buildConstraintExactlyVariable(string id, vector<XVariable *> &list, int value, XVariable *x) {
throw runtime_error("exactly Variable constraint is not yet supported");
}
/**
* The callback function related to a among constraint
* This is a special count constraint
* This callback is called if #recognizeSpecialCountCases is enabled
* See http://xcsp.org/specifications/count
*
*
* Example:
* <count id="c2">
* <list> w1 w2 w3 w4 </list>
* <values> 1 5 8 </values>
* <condition> (eq,k2) </condition>
* </count>
*
* @param id the id (name) of the constraint
* @param list the scope of the constraint
* @param value the value
* @param k
*/
virtual void buildConstraintAmong(string id, vector<XVariable *> &list, vector<int> &values, int k) {// TODO AMONG
throw runtime_error("Among constraint is not yet supported");
}
/**
* The callback function related to a count constraint with integer values
* See http://xcsp.org/specifications/count
* Example:
* <count id="c1">
* <list> v1 v2 v3 v4 </list>
* <values> 2 4 </values>
* <condition> (ne,k1) </condition>
* </count>
*
* @param id the id (name) of the constraint
* @param list the scope of the constraint
* @param value the set of values (here set of ints)
* @param k the number of variables
* @param xc the condition (see #XCondition)
*/
virtual void buildConstraintCount(string id, vector<XVariable *> &list, vector<int> &values, XCondition &xc) {
throw runtime_error("count with integer values constraint is not yet supported");
}
/**
* The callback function related to a count constraint with integer variables
* See http://xcsp.org/specifications/count
* Example:
* <count id="c1">
* <list> v1 v2 v3 v4 </list>
* <values> x1 x2 </values>
* <condition> (ne,k1) </condition>
* </count>
*
* @param id the id (name) of the constraint
* @param list the scope of the constraint
* @param value the set of values (here set of variables)
* @param k the number of variables
* @param xc the condition (see #XCondition)
*/
virtual void buildConstraintCount(string id, vector<XVariable *> &list, vector<XVariable *> &values, XCondition &xc) {
throw runtime_error("count with variables values constraint is not yet supported");
}
/**
* The callback function related to a nValues constraint with exception
* See http://xcsp.org/specifications/nValues
* Example:
* <nValues id="c3">
* <list> z1 z2 z3 z4 </list>
* <except> 0 </except>
* <condition> (eq,2) </condition>
* </nValues>
*
* @param id the id (name) of the constraint
* @param list the scope of the constraint
* @param except the set of excepted values
* @param xc the condition (see #XCondition)
*/
virtual void buildConstraintNValues(string id, vector<XVariable *> &list, vector<int> &except, XCondition &xc) {
throw runtime_error("NValues with exception constraint is not yet supported");
}
/**
* The callback function related to a nValues constraint with exception
* See http://xcsp.org/specifications/nValues
* Example:
* <nValues id="c3">
* <list> z1 z2 z3 z4 </list>
* <condition> (eq,2) </condition>
* </nValues>
*
* @param id the id (name) of the constraint
* @param list the scope of the constraint
* @param xc the condition (see #XCondition)
*/
virtual void buildConstraintNValues(string id, vector<XVariable *> &list, XCondition &xc) {
throw runtime_error("NValues constraint is not yet supported");
}
/**
* The callback function related to a cardinality constraint with int values and int occurs
* See http://xcsp.org/specifications/cardinality
*
* Example:
* <cardinality>
* <list> x1 x2 x3 x4 </list>
* <values> 2 5 10 </values>
* <occurs> 1 2 3 </occurs>
* </cardinality>
*
* @param id the id (name) of the constraint
* @param list the scope of the constraint
* @param values the set of values (here int)
* @param occurs the number of occurences (here int)
* @param closed is the constraint is closed
*/
virtual void buildConstraintCardinality(string id, vector<XVariable *> &list, vector<int> values, vector<int> &occurs, bool closed) {
throw runtime_error("cardinality with int values and int occurs constraint is not yet supported");
}
//
/**
* The callback function related to a cardinality constraint with int values and variable occurs
* See http://xcsp.org/specifications/cardinality
*
* Example:
* <cardinality>
* <list> x1 x2 x3 x4 </list>
* <values> 0 1 2 3 </values>
* <occurs> z0 z1 z2 z3 </occurs>
* </cardinality>
*
* @param id the id (name) of the constraint
* @param list the scope of the constraint
* @param values the set of values (here int)
* @param occurs the number of occurences (here variables)
* @param closed is the constraint is closed
*/
virtual void buildConstraintCardinality(string id, vector<XVariable *> &list, vector<int> values, vector<XVariable *> &occurs, bool closed) {
throw runtime_error("cardinality with int values and int occurs constraint is not yet supported");
}
//
/**
* The callback function related to a cardinality constraint with int values and interval occurs
* See http://xcsp.org/specifications/cardinality
*
* Example:
* <cardinality>
* <list> x1 x2 x3 x4 </list>
* <values> 2 5 10 </values>
* <occurs> 0..1 1..3 2..3 </occurs>
* </cardinality>
*
* @param id the id (name) of the constraint
* @param list the scope of the constraint
* @param values the set of values (here int)
* @param occurs the number of occurences (here intervals)
* @param closed is the constraint is closed
*/
virtual void buildConstraintCardinality(string id, vector<XVariable *> &list, vector<int> values, vector<XInterval> &occurs, bool closed) {
throw runtime_error("cardinality with int values and int occurs constraint is not yet supported");
}
/**
* The callback function related to a cardinality constraint with variable values and int occurs
* See http://xcsp.org/specifications/cardinality
*
* Example:
* <cardinality>
* <list> x1 x2 x3 x4 </list>
* <values> z1 z2 z3 </values>
* <occurs> 1 2 3 </occurs>
* </cardinality>
*
* @param id the id (name) of the constraint
* @param list the list of the constraint (not the scope...)
* @param values the set of values (here variable)
* @param occurs the number of occurences (here int)
* @param closed is the constraint is closed
*/
virtual void buildConstraintCardinality(string id, vector<XVariable *> &list, vector<XVariable *> values, vector<int> &occurs, bool closed) {
throw runtime_error("cardinality with int values and int occurs constraint is not yet supported");
}
/**
* The callback function related to a cardinality constraint with variable values and variable occurs
* See http://xcsp.org/specifications/cardinality
*
* Example:
* <cardinality>
* <list> x1 x2 x3 x4 </list>
* <values> z1 z2 z3 </values>
* <occurs> y1 y2 y3 </occurs>
* </cardinality>
*
* @param id the id (name) of the constraint
* @param list the list of the constraint (not the scope)
* @param values the set of values (here variables)
* @param occurs the number of occurences (here variables)
* @param closed is the constraint is closed
*/
virtual void buildConstraintCardinality(string id, vector<XVariable *> &list, vector<XVariable *> values, vector<XVariable *> &occurs, bool closed) {
throw runtime_error("cardinality with int values and int occurs constraint is not yet supported");
}
/**
* The callback function related to a cardinality constraint with variable values and interval occurs
* See http://xcsp.org/specifications/cardinality
*
* Example:
* <cardinality>
* <list> x1 x2 x3 x4 </list>
* <values> z1 z2 z3 </values>
* <occurs> 1..2 3..5 2..4 </occurs>
* </cardinality>
*
* @param id the id (name) of the constraint
* @param list the list of the constraint (not the scope)
* @param values the set of values (here variables)
* @param occurs the number of occurences (here intervals)
* @param closed is the constraint is closed
*/
virtual void buildConstraintCardinality(string id, vector<XVariable *> &list, vector<XVariable *> values, vector<XInterval> &occurs, bool closed) {
throw runtime_error("cardinality with int values and int occurs constraint is not yet supported");
}
//--------------------------------------------------------------------------------------
// Connection constraints
//--------------------------------------------------------------------------------------
/**
* The callback function related to a minimum constraint
* See http://xcsp.org/specifications/minimum
*
* Example:
* <minimum>
* <list> x1 x2 x3 x4 </list>
* <condition> (eq,y) </condition>
* </minimum>
*
* @param id the id (name) of the constraint
* @param list the scope of the constraint
* @param xc the condition (see #XCondition)
*/
virtual void buildConstraintMinimum(string id, vector<XVariable *> &list, XCondition &xc) {
throw runtime_error("minimum constraint is not yet supported");
}
/**
* The callback function related to a minimum constraint (arg_min)
* See http://xcsp.org/specifications/minimum
*
* Example:
* <minimum>
* <list> x1 x2 x3 x4 </list>
* <index rank="any"> z1 </index>
* <condition> (eq,3) </condition>
* </minimum>
*
* @param id the id (name) of the constraint
* @param list the scope of the constraint
* @param index the index variable
* @param startIndex 0 or something else ?
* @param rank ANY, ALL...
* @param xc the condition (see #XCondition)
*/
virtual void buildConstraintMinimum(string id, vector<XVariable *> &list, XVariable *index, int startIndex, RankType rank, XCondition &xc) {
throw runtime_error("minimum with index constraint is not yet supported");
}
/**
* The callback function related to a maximum constraint
* See http://xcsp.org/specifications/maximum
*
* Example:
* <maximum>
* <list> x1 x2 x3 x4 </list>
* <condition> (ge,2) </condition>
* </maximum>
*
* @param id the id (name) of the constraint
* @param list the scope of the constraint
* @param xc the condition (see #XCondition)
*/
virtual void buildConstraintMaximum(string id, vector<XVariable *> &list, XCondition &xc) {
throw runtime_error("maximum constraint is not yet supported");
}
/**
* The callback function related to a maximum constraint (arg_max)
* See http://xcsp.org/specifications/maximum
*
* Example:
* <maximum>
* <list> x1 x2 x3 x4 </list>
* <index rank="any"> z1 </index>
* <condition> (eq,3) </condition>
* </maximum>
*
* @param id the id (name) of the constraint
* @param list the scope of the constraint
* @param index the index variable
* @param startIndex 0 or something else ?
* @param rank ANY, ALL...
* @param xc the condition (see #XCondition)
*/
virtual void buildConstraintMaximum(string id, vector<XVariable *> &list, XVariable *index, int startIndex, RankType rank, XCondition &xc) {
throw runtime_error("maximum with index constraint is not yet supported");
}
/**
* The callback function related to a element constraint with int value
* See http://xcsp.org/specifications/element
*
* Example:
* <element>
* <list> y[] </list>
* <value> 2 </value>
* </element>
*
* @param id the id (name) of the constraint
* @param list the scope of the constraint
* @param value the value (here an int)
*/
virtual void buildConstraintElement(string id, vector<XVariable *> &list, int value) {
throw runtime_error("Element value constraint is not yet supported");
}
/**
* The callback function related to a element constraint with variable value
* See http://xcsp.org/specifications/element
*
* Example:
* <element>
* <list> y[] </list>
* <value> z </value>
* </element>
*
* @param id the id (name) of the constraint
* @param list the scope of the constraint
* @param value the value (here a variable)
*/
virtual void buildConstraintElement(string id, vector<XVariable *> &list, XVariable *value) {
throw runtime_error("Element variable constraint is not yet supported");
}
/**
* The callback function related to a element constraint with variable index and int value
* See http://xcsp.org/specifications/element
*
* Example:
* <element>
* <list> y[] </list>
* <index> i </index>
* <value> 2 </value>
* </element>
*
* @param id the id (name) of the constraint
* @param list the list of the constraint (not necessary the scope)
* @param index the index variable
* @param startIndex 0 or something else ?
* @param rank ANY, ALL...
* @param value the value (here an int)
*/
virtual void buildConstraintElement(string id, vector<XVariable *> &list, int startIndex, XVariable *index, RankType rank, int value) {
throw runtime_error("Element value with index constraint is not yet supported");
}
/**
* The callback function related to a element constraint with variable index and variable value
* See http://xcsp.org/specifications/element
*
* Example:
* <element>
* <list> y[] </list>
* <index> i </index>
* <value> z </value>
* </element>
*
* @param id the id (name) of the constraint
* @param list the list of the constraint (not necessary the scope)
* @param index the index variable
* @param startIndex 0 or something else ?
* @param rank ANY, ALL...
* @param value the value (here a variable)
*/
virtual void buildConstraintElement(string id, vector<XVariable *> &list, int startIndex, XVariable *index, RankType rank, XVariable *value) {
throw runtime_error("Element variable with index constraint is not yet supported");
}
/**
* The callback function related to a element constraint with int list variable index and variable value
* See http://xcsp.org/specifications/element
*
* Example:
* <element>
* <list> 1 2 3 4 </list>
* <index> i </index>
* <value> z </value>
* </element>
*
* @param id the id (name) of the constraint
* @param list the list of int
* @param index the index variable
* @param startIndex 0 or something else ?
* @param rank ANY, ALL...
* @param value the value (here a variable)
*/
virtual void buildConstraintElement(string id, vector<int> &list, int startIndex, XVariable *index, RankType rank, XVariable *value) {
throw runtime_error("Element value (with list of integers) with index constraint is not yet supported");
}
/**
* The callback function related to a channel constraint
* See http://xcsp.org/specifications/channel
*
* Example:
* <channel>
* <list> z1 z2 z3 z4 z5 </list>
* </channel>
*
* @param id the id (name) of the constraint
* @param list the scope of the constraint
*/
virtual void buildConstraintChannel(string id, vector<XVariable *> &list, int startIndex) {
throw runtime_error("channel with 1 list constraint is not yet supported");
}
/**
* The callback function related to a channel constraint
* See http://xcsp.org/specifications/channel
*
* Example:
* <channel>
* <list> x1 x2 x3 x4 </list>
* <list> y1 y2 y3 y4 </list>
* </channel>
*
* The size of the array {@code list1} must be less than or equal to the size of {@code list2}.
*
* If list1.size() == list2.size() then list1[i] = j <=> list2[j] = i
* If list1.size() < list2.size() then list1[i] = j => list2[j] = i
*
* @param id the id (name) of the constraint
* @param list1 the first list
* @param startIndex1 the starting index for list1
* @param list2 the second list
* @param startIndex2 the starting index for list2
*
*/
virtual void buildConstraintChannel(string id, vector<XVariable *> &list1, int startIndex1, vector<XVariable *> &list2, int startIndex2) {
throw runtime_error("channel with 2 lists constraint is not yet supported");
}
/**
* The callback function related to a channel constraint with a value
* See http://xcsp.org/specifications/channel
*
* Example:
* <channel>
* <list> z1 z2 z3 z4 z5 </list>
* <value> v </value>
* </channel>
*
* @param id the id (name) of the constraint
* @param list the list of the constraint not necessary the scope)
* @param startIndex the starting index for list
* @param value the vaule
*/
virtual void buildConstraintChannel(string id, vector<XVariable *> &list, int startIndex, XVariable *value) {
throw runtime_error("channel with 1 list and 1 value constraint is not yet supported");
}
//--------------------------------------------------------------------------------------
// packing and schedulling constraints
//--------------------------------------------------------------------------------------
/**
* The callback function related to a strectch constraint with values and widths
* See http://xcsp.org/specifications/stretch
*
* Example:
* <stretch>
* <list> x1 x2 x3 x4 x5 x6 x7 </list>
* <values> 1 2 3 0 </values>
* <widths> 1..3 1..3 2..3 2..4 </widths>
* </stretch>
*
* @param id the id (name) of the constraint
* @param list the scope of the constraint
* @param values thelist of values
* @param widths the list of intervals for widths
*/
virtual void buildConstraintStretch(string id, vector<XVariable *> &list, vector<int> &values, vector<XInterval> &widths) {
throw runtime_error("stretch constraint is not yet supported");
}
/**
* The callback function related to a strectch constraint with values, widths and patterns
* See http://xcsp.org/specifications/stretch
*
* @param id the id (name) of the constraint
* @param list the scope of the constraint
* @param values thelist of values
* @param widths the list of intervals for widths
* @param patterns
*
*/
virtual void
buildConstraintStretch(string id, vector<XVariable *> &list, vector<int> &values, vector<XInterval> &widths, vector<vector<int>> &patterns) {
throw runtime_error("stretch constraint is not yet supported");
}
/**
* The callback function related to a no overlap constraint with variable origins and int lenghts
* See http://xcsp.org/specifications/noOverlap
*
* Example:
* <noOverlap>
* <origins> x1 x2 x3 </origins>
* <lengths> l1 l2 l3 </lengths>
* </noOverlap>
*
* @param id the id (name) of the constraint
* @param origins the vector of origins
* @param lengths the vector of lenghts (here int)
* @param zeroIgnored are zero ignored?
*/
virtual void buildConstraintNoOverlap(string id, vector<XVariable *> &origins, vector<int> &lengths, bool zeroIgnored) {
throw runtime_error("nooverlap with int lengths constraint is not yet supported");
}
/**
* The callback function related to a no overlap constraint with variable origins and variable lenghts
* See http://xcsp.org/specifications/noOverlap
*
* Example:
* <noOverlap>
* <origins> x1 x2 x3 </origins>
* <lengths> z1 z2 z3 </lengths>
* </noOverlap>
*
* @param id the id (name) of the constraint
* @param origins the vector of origins
* @param lengths the vector of lenghts (here variables)
* @param zeroIgnored are zero ignored?
*/
virtual void buildConstraintNoOverlap(string id, vector<XVariable *> &origins, vector<XVariable *> &lengths, bool zeroIgnored) {
throw runtime_error("nooverlap with variable lengths constraint is not yet supported");
}
/**
* The callback function related to a no overlap constraint with variable origins and 3 dimensional int lenghts
* See http://xcsp.org/specifications/noOverlap
*
* Example:
* <noOverlap>
* <origins> (x1,y1,z1)(x2,y2,z2)(x3,y3,z3)(x4,y4,z4) </origins>
* <lengths> (2,4,1)(4,2,3)(5,1,2)(3,3,2) </lengths>
* </noOverlap>
*
* @param id the id (name) of the constraint
* @param origins the vector of origins
* @param lengths the vector of lenghts (here vector of int)
* @param zeroIgnored are zero ignored?
*/
virtual void buildConstraintNoOverlap(string id, vector<vector<XVariable *>> &origins, vector<vector<int>> &lengths, bool zeroIgnored) {
throw runtime_error("K dim nooverlap with int lengths constraint is not yet supported");
}
/**
* The callback function related to a no overlap constraint with variable origins and 3 dimensional variable lenghts
* See http://xcsp.org/specifications/noOverlap
*
* Example:
* <noOverlap>
* <origins> (x1,y1,z1)(x2,y2,z2)(x3,y3,z3)(x4,y4,z4) </origins>
* <lengths> (a,b,c)(d,e,f)(g,h,i)(l,m,n) </lengths>
* </noOverlap>
*
* @param id the id (name) of the constraint
* @param origins the vector of origins
* @param lengths the vector of lenghts (here vector of variables)
* @param zeroIgnored are zero ignored?
*/
virtual void buildConstraintNoOverlap(string id, vector<vector<XVariable *>> &origins, vector<vector<XVariable *>> &lengths, bool zeroIgnored) {
throw runtime_error("K dim nooverlap with variable lengths constraint is not yet supported");
}
/**
* The callback function related to a cumulative constraint with variable origins, int lengths and int heights
* See http://xcsp.org/specifications/cumulative
*
* Example:
* <cumulative>
* <origins> s1 s2 s3 s4 </origins>
* <lengths> 1 2 3 4 </lengths>
* <heights> 3 4 5 6 </heights>
* <condition> (le,4) </condition>
* </cumulative>
*
* @param id the id (name) of the constraint
* @param origins the vector of origins
* @param lengths the vector of lenghts (here ints)
* @param heights the vector of heights (here ints)
* @param xc the condition (see XCondition)
*/
virtual void buildConstraintCumulative(string id, vector<XVariable *> &origins, vector<int> &lengths, vector<int> &heights, XCondition &xc) {
throw runtime_error("cumulative (int lengths, int heights) constraint is not yet supported");
}
/**
* The callback function related to a cumulative constraint with variable origin, int lengths and variable heights
* See http://xcsp.org/specifications/cumulative
*
* Example:
* <cumulative>
* <origins> s1 s2 s3 s4 </origins>
* <lengths> 1 2 3 4 </lengths>
* <heights> h1 h2 h3 h4 </heights>
* <condition> (le,4) </condition>
* </cumulative>
*
* @param id the id (name) of the constraint
* @param origins the vector of origins
* @param lengths the vector of lenghts (here ints)
* @param heights the vector of heights (here variables)
* @param xc the condition (see XCondition)
*/
virtual void buildConstraintCumulative(string id, vector<XVariable *> &origins, vector<int> &lengths, vector<XVariable *> &varHeights, XCondition &xc) {
throw runtime_error("cumulative (int lengths, var heights) constraint is not yet supported");
}
/**
* The callback function related to a cumulative constraint with variable origin, variable lengths and int heights
* See http://xcsp.org/specifications/cumulative
*
* Example:
* <cumulative>
* <origins> s1 s2 s3 s4 </origins>
* <lengths> l1 l2 l3 l4 </lengths>
* <heights> 1 2 3 4 </heights>
* <condition> (le,4) </condition>
* </cumulative>
*
* @param id the id (name) of the constraint
* @param origins the vector of origins
* @param lengths the vector of lenghts (here variables)
* @param heights the vector of heights (here ints)
* @param xc the condition (see XCondition)
*/
virtual void buildConstraintCumulative(string id, vector<XVariable *> &origins, vector<XVariable *> &lengths, vector<int> &heights, XCondition &xc) {
throw runtime_error("cumulative (var lengths, int heights) constraint is not yet supported");
}
/**
* The callback function related to a cumulative constraint with variable origin, variable lengths and variable heights
* See http://xcsp.org/specifications/cumulative
*
* Example:
* <cumulative>
* <origins> s1 s2 s3 s4 </origins>
* <lengths> l1 l2 l3 l4 </lengths>
* <heights> h1 h2 h3 h4 </heights>
* <condition> (le,4) </condition>
* </cumulative>
*
* @param id the id (name) of the constraint
* @param origins the vector of origins
* @param lengths the vector of lenghts (here variables)
* @param heights the vector of heights (here variables)
* @param xc the condition (see XCondition)
*/
virtual void
buildConstraintCumulative(string id, vector<XVariable *> &origins, vector<XVariable *> &lengths, vector<XVariable *> &heights, XCondition &xc) {
throw runtime_error("cumulative (var lengths, var heights) constraint is not yet supported");
}
/**
* The callback function related to a cumulative constraint with variable origin, int lengths and int heights and variable ends
* See http://xcsp.org/specifications/cumulative
*
* Example:
* <cumulative>
* <origins> s1 s2 s3 s4 </origins>
* <lengths> 1 2 3 4 </lengths>
* <heights> 1 2 3 4 </heights>
* <end> e1 e2 e3 e4 </end>
* <condition> (le,4) </condition>
* </cumulative>
*
* @param id the id (name) of the constraint
* @param origins the vector of origins
* @param lengths the vector of lenghts (here ints)
* @param heights the vector of heights (here ints)
* @param ends the vector of ends (here variables)
* @param xc the condition (see XCondition)
*/
virtual void buildConstraintCumulative(string id, vector<XVariable *> &origins, vector<int> &lengths, vector<int> &heights, vector<XVariable *> &ends,
XCondition &xc) {
throw runtime_error("cumulative (int lengths, int heights) constraint is not yet supported");
}
/**
* The callback function related to a cumulative constraint with variable origin, int lengths and variable heights and variable ends
* See http://xcsp.org/specifications/cumulative
*
* Example:
* <cumulative>
* <origins> s1 s2 s3 s4 </origins>
* <lengths> 1 2 3 4 </lengths>
* <heights> h1 h2 h3 h4 </heights>
* <end> e1 e2 e3 e4 </end>
* <condition> (le,4) </condition>
* </cumulative>
*
* @param id the id (name) of the constraint
* @param origins the vector of origins
* @param lengths the vector of lenghts (here ints)
* @param heights the vector of heights (here variables)
* @param ends the vector of ends (here variables)
* @param xc the condition (see XCondition)
*/
virtual void
buildConstraintCumulative(string id, vector<XVariable *> &origins, vector<int> &lengths, vector<XVariable *> &varHeights, vector<XVariable *> &ends,
XCondition &xc) {
throw runtime_error("cumulative (int lengths, var heights, ends) constraint is not yet supported");
}
/**
* The callback function related to a cumulative constraint with variable origin, variable lengths and int heights and variable ends
* See http://xcsp.org/specifications/cumulative
*
* Example:
* <cumulative>
* <origins> s1 s2 s3 s4 </origins>
* <lengths> l1 l2 l3 l4 </lengths>
* <heights> 1 2 3 4 </heights>
* <end> e1 e2 e3 e4 </end>
* <condition> (le,4) </condition>
* </cumulative>
*
* @param id the id (name) of the constraint
* @param origins the vector of origins
* @param lengths the vector of lenghts (here variables)
* @param heights the vector of heights (here ints)
* @param ends the vector of ends (here variables)
* @param xc the condition (see XCondition)
*/
virtual void
buildConstraintCumulative(string id, vector<XVariable *> &origins, vector<XVariable *> &lengths, vector<int> &heights, vector<XVariable *> &ends,
XCondition &xc) {
throw runtime_error("cumulative (var lengths, int heights, ends) constraint is not yet supported");
}
/**
* The callback function related to a cumulative constraint with variable origin, variable lengths and variable heights and variable ends
* See http://xcsp.org/specifications/cumulative
*
* Example:
* <cumulative>
* <origins> s1 s2 s3 s4 </origins>
* <lengths> l1 l2 l3 l4 </lengths>
* <heights> h1 h2 h3 h4 </heights>
* <end> e1 e2 e3 e4 </end>
* <condition> (le,4) </condition>
* </cumulative>
*
* @param id the id (name) of the constraint
* @param origins the vector of origins
* @param lengths the vector of lenghts (here variables)
* @param heights the vector of heights (here variables)
* @param ends the vector of ends (here variables)
* @param xc the condition (see XCondition)
*/
virtual void
buildConstraintCumulative(string id, vector<XVariable *> &origins, vector<XVariable *> &lengths, vector<XVariable *> &heights,
vector<XVariable *> &ends, XCondition &xc) {
throw runtime_error("cumulative (var lengths, var heights, ends) constraint is not yet supported");
}
//--------------------------------------------------------------------------------------
// instantiation constraints
//--------------------------------------------------------------------------------------
/**
* The callback function related to an instantiation constraint
* See http://xcsp.org/specifications/instantiation
*
* Example:
* <instantiation>
* <list> x y z </list>
* <values> 12 4 30 </values>
* </instantiation>
*
* @param id the id (name) of the constraint
* @param list the scope of the constraint
* @param values the value for each variable
*/
virtual void buildConstraintInstantiation(string id, vector<XVariable *> &list, vector<int> &values) {
throw runtime_error("instantiation constraint not yet supported");
}
//--------------------------------------------------------------------------------------
// Graph constraints
//--------------------------------------------------------------------------------------
/**
* The callback function related to circuit constraint
* See http://xcsp.org/specifications/circuit
*
* Example:
* <circuit>
* <list> x y z </list>
* </circuit>
*
* @param id the id (name) of the constraint
* @param list the scope of the constraint
* @param startIndex the start index for the list
*/
virtual void buildConstraintCircuit(string id, vector<XVariable *> &list, int startIndex) {
throw runtime_error("circuit constraint not yet supported");
}
/**
* The callback function related to circuit constraint with defined int size
* See http://xcsp.org/specifications/circuit
*
* Example:
* <circuit>
* <list> x y z </list>
* <size> 4 </size>
* </circuit>
*
* @param id the id (name) of the constraint
* @param list the scope of the constraint
* @param startIndex the start index for the list
* @param size the size of the circuit (here an int)
*/
virtual void buildConstraintCircuit(string id, vector<XVariable *> &list, int startIndex, int size) {
throw runtime_error("circuit constraint not yet supported");
}
/**
* The callback function related to circuit constraint with defined variable size
* See http://xcsp.org/specifications/circuit
*
* Example:
* <circuit>
* <list> x y z </list>
* <size> s </size>
* </circuit>
*
* @param id the id (name) of the constraint
* @param list the list of variables (not necessary the scope)
* @param startIndex the start index for the list
* @param size the size of the circuit (here an variable)
*/
virtual void buildConstraintCircuit(string id, vector<XVariable *> &list, int startIndex, XVariable *size) {
throw runtime_error("circuit constraint not yet supported");
}
//--------------------------------------------------------------------------------------
// Objectives
//--------------------------------------------------------------------------------------
/**
* The callback function related to an objective minimize an expression
* See http://xcsp.org/specifications/objectives
*
* Example:
* <objectives>
* <minimize> add(x,mul(y,2)) </minimize>
* </objectives>
*
* @param expr the expression
*/
virtual void buildObjectiveMinimizeExpression(string expr) {
throw runtime_error("minimize expression objective not yet supported");
}
/**
* The callback function related to an objective maximize an expression
* See http://xcsp.org/specifications/objectives
*
* Example:
* <objectives>
* <maximize> add(x,2) </maximize>
* </objectives>
*
* @param expr the expression
*/
virtual void buildObjectiveMaximizeExpression(string expr) {
throw runtime_error("maximize expression objective not yet supported");
}
/**
* The callback function related to an objective minimize a variable
* See http://xcsp.org/specifications/objectives
*
* Example:
* <objectives>
* <minimize> x </minimize>
* </objectives>
*
* @param x the variable
*/
virtual void buildObjectiveMinimizeVariable(XVariable *x) {
throw runtime_error("minimize variable objective not yet supported");
}
/**
* The callback function related to an objective maximize a variable
* See http://xcsp.org/specifications/objectives
*
* Example:
* <objectives>
* <maximize> x </maximize>
* </objectives>
*
* @param x the variable
*/
virtual void buildObjectiveMaximizeVariable(XVariable *x) {
throw runtime_error("maximize variable objective not yet supported");
}
/**
* The callback function related to an objective minimize a sum/product
* See http://xcsp.org/specifications/objectives
*
* Example:
* <objectives>
* <minimize type="sum">
* <list> x1 x2 x3 x4 x5 </list>
* <coeffs> 2 4 1 4 8 </coeffs>
* </minimize>
* <objectives>
*
* @param type SUM, PRODUCT...
* @param list the scope
* @param coefs the vector of coefficients
*/
virtual void buildObjectiveMinimize(ExpressionObjective type, vector<XVariable *> &list, vector<int> &coefs) {
throw runtime_error("minimize objective sum... not yet supported");
}
/**
* The callback function related to an objective maximize a sum/product
* See http://xcsp.org/specifications/objectives
*
* Example:
* <objectives>
* <maximize type="sum">
* <list> x1 x2 x3 x4 x5 </list>
* <coeffs> 2 4 1 4 8 </coeffs>
* </maximize>
* <objectives>
*
* @param type SUM, PRODUCT...
* @param list the scope
* @param coefs the vector of coefficients
*/
virtual void buildObjectiveMaximize(ExpressionObjective type, vector<XVariable *> &list, vector<int> &coefs) {
throw runtime_error("maximize objective not yet supported");
}
/**
* The callback function related to an objective minimize a sum/product with coefs = 1
* See http://xcsp.org/specifications/objectives
*
* Example:
* <objectives>
* <minimize type="sum">
* <list> x1 x2 x3 x4 x5 </list>
* </minimize>
* <objectives>
*
* @param type SUM, PRODUCT...
* @param list the scope
*/
virtual void buildObjectiveMinimize(ExpressionObjective type, vector<XVariable *> &list) {
throw runtime_error("minimize objective not yet supported");
}
/**
* The callback function related to an objective maximize a sum/product with coefs = 1
* See http://xcsp.org/specifications/objectives
*
* Example:
* <objectives>
* <maximize type="sum">
* <list> x1 x2 x3 x4 x5 </list>
* </maximize>
* <objectives>
*
* @param type SUM, PRODUCT...
* @param list the scope
*/
virtual void buildObjectiveMaximize(ExpressionObjective type, vector<XVariable *> &list) {
throw runtime_error("maximize objective not yet supported");
}
/**
* The callback function related to annotations.
* It provides the set of decision variables related to the problem.
* @param list
*/
virtual void buildAnnotationDecision(vector<XVariable *> &list) {}
};
}
#endif //COSOCO_XCSP3CORECALLBACKS_H
|