/usr/include/gecode/int/linear.hh is in libgecode-dev 4.2.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main authors:
* Christian Schulte <schulte@gecode.org>
* Guido Tack <tack@gecode.org>
* Tias Guns <tias.guns@cs.kuleuven.be>
*
* Copyright:
* Christian Schulte, 2002
* Guido Tack, 2004
* Tias Guns, 2009
*
* Last modified:
* $Date: 2013-02-14 16:29:11 +0100 (Thu, 14 Feb 2013) $ by $Author: schulte $
* $Revision: 13292 $
*
* This file is part of Gecode, the generic constraint
* development environment:
* http://www.gecode.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 __GECODE_INT_LINEAR_HH__
#define __GECODE_INT_LINEAR_HH__
#include <gecode/int.hh>
/**
* \namespace Gecode::Int::Linear
* \brief %Linear propagators
*/
namespace Gecode { namespace Int { namespace Linear {
/*
* Binary propagators
*
*/
/**
* \brief Base-class for binary linear propagators
*
* The type \a Val can be either \c long long int or \c int, defining the
* numerical precision during propagation. The types \a A and \a B
* give the types of the views.
*
* The propagation condition \a pc refers to both views.
*/
template<class Val, class A, class B, PropCond pc>
class LinBin : public Propagator {
protected:
/// View of type \a A
A x0;
/// View of type \a B
B x1;
/// Value of type \a Val
Val c;
/// Constructor for cloning \a p
LinBin(Space& home, bool share, LinBin& p);
/// Constructor for rewriting \a p during cloning
LinBin(Space& home, bool share, Propagator& p, A x0, B x1, Val c);
/// Constructor for creation
LinBin(Home home, A x0, B x1, Val c);
public:
/// Cost function (defined as low binary)
virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
/// Delete propagator and return its size
virtual size_t dispose(Space& home);
};
/**
* \brief Base-class for reified binary linear propagators
*
* The type \a Val can be either \c long long int or \c int, defining the
* numerical precision during propagation. The types \a A and \a B
* give the types of the views.
*
* The propagation condition \a pc refers to both views.
*/
template<class Val, class A, class B, PropCond pc, class Ctrl>
class ReLinBin : public Propagator {
protected:
/// View of type \a A
A x0;
/// View of type \a B
B x1;
/// Value of type \a Val
Val c;
/// Control view for reification
Ctrl b;
/// Constructor for cloning \a p
ReLinBin(Space& home, bool share, ReLinBin& p);
/// Constructor for creation
ReLinBin(Home home, A x0, B x1, Val c, Ctrl b);
public:
/// Cost function (defined as low binary)
virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
/// Delete propagator and return its size
virtual size_t dispose(Space& home);
};
/**
* \brief %Propagator for bounds consistent binary linear equality
*
* The type \a Val can be either \c long long int or \c int, defining the
* numerical precision during propagation. The types \a A and \a B
* give the types of the views.
*
* The propagation condition \a pc refers to both views.
*
* Requires \code #include <gecode/int/linear.hh> \endcode
* \ingroup FuncIntProp
*/
template<class Val, class A, class B>
class EqBin : public LinBin<Val,A,B,PC_INT_BND> {
protected:
using LinBin<Val,A,B,PC_INT_BND>::x0;
using LinBin<Val,A,B,PC_INT_BND>::x1;
using LinBin<Val,A,B,PC_INT_BND>::c;
/// Constructor for cloning \a p
EqBin(Space& home, bool share, EqBin& p);
/// Constructor for creation
EqBin(Home home, A x0, B x1, Val c);
public:
/// Constructor for rewriting \a p during cloning
EqBin(Space& home, bool share, Propagator& p, A x0, B x1, Val c);
/// Create copy during cloning
virtual Actor* copy(Space& home, bool share);
/// Perform propagation
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
/// Post propagator for \f$x_0+x_1 = c\f$
static ExecStatus post(Home home, A x0, B x1, Val c);
};
/**
* \brief %Propagator for reified bounds consistent binary linear equality
*
* The type \a Val can be either \c long long int or \c int, defining the
* numerical precision during propagation. The types \a A and \a B
* give the types of the views.
*
* The propagation condition \a pc refers to both views.
*
* Requires \code #include <gecode/int/linear.hh> \endcode
* \ingroup FuncIntProp
*/
template<class Val, class A, class B, class Ctrl, ReifyMode rm>
class ReEqBin : public ReLinBin<Val,A,B,PC_INT_BND,Ctrl> {
protected:
using ReLinBin<Val,A,B,PC_INT_BND,Ctrl>::x0;
using ReLinBin<Val,A,B,PC_INT_BND,Ctrl>::x1;
using ReLinBin<Val,A,B,PC_INT_BND,Ctrl>::c;
using ReLinBin<Val,A,B,PC_INT_BND,Ctrl>::b;
/// Constructor for cloning \a p
ReEqBin(Space& home, bool share, ReEqBin& p);
/// Constructor for creation
ReEqBin(Home home,A,B,Val,Ctrl);
public:
/// Create copy during cloning
virtual Actor* copy(Space& home, bool share);
/// Perform propagation
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
/// Post propagator for \f$(x_0+x_1 = c)\equiv \operatorname{rm}(b)\f$
static ExecStatus post(Home home, A x0, B x1, Val c, Ctrl b);
};
/**
* \brief %Propagator for bounds consistent binary linear disequality
*
* The type \a Val can be either \c long long int or \c int, defining the
* numerical precision during propagation. The types \a A and \a B
* give the types of the views.
*
* The propagation condition \a pc refers to both views.
*
* Requires \code #include <gecode/int/linear.hh> \endcode
* \ingroup FuncIntProp
*/
template<class Val, class A, class B>
class NqBin : public LinBin<Val,A,B,PC_INT_VAL> {
protected:
using LinBin<Val,A,B,PC_INT_VAL>::x0;
using LinBin<Val,A,B,PC_INT_VAL>::x1;
using LinBin<Val,A,B,PC_INT_VAL>::c;
/// Constructor for cloning \a p
NqBin(Space& home, bool share, NqBin& p);
/// Constructor for creation
NqBin(Home home, A x0, B x1, Val c);
public:
/// Constructor for rewriting \a p during cloning
NqBin(Space& home, bool share, Propagator& p, A x0, B x1, Val c);
/// Create copy during cloning
virtual Actor* copy(Space& home, bool share);
/// Perform propagation
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
/// Cost function (defined as low unary)
virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
/// Post propagator for \f$x_0+x_1 \neq c\f$
static ExecStatus post(Home home, A x0, B x1, Val c);
};
/**
* \brief %Propagator for bounds consistent binary linear less or equal
*
* The type \a Val can be either \c long long int or \c int, defining the
* numerical precision during propagation. The types \a A and \a B
* give the types of the views.
*
* The propagation condition \a pc refers to both views.
*
* Requires \code #include <gecode/int/linear.hh> \endcode
* \ingroup FuncIntProp
*/
template<class Val, class A, class B>
class LqBin : public LinBin<Val,A,B,PC_INT_BND> {
protected:
using LinBin<Val,A,B,PC_INT_BND>::x0;
using LinBin<Val,A,B,PC_INT_BND>::x1;
using LinBin<Val,A,B,PC_INT_BND>::c;
/// Constructor for cloning \a p
LqBin(Space& home, bool share, LqBin& p);
/// Constructor for creation
LqBin(Home home, A x0, B x1, Val c);
public:
/// Constructor for rewriting \a p during cloning
LqBin(Space& home, bool share, Propagator& p, A x0, B x1, Val c);
/// Create copy during cloning
virtual Actor* copy(Space& home, bool share);
/// Perform propagation
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
/// Post propagator for \f$x_0+x_1 \leq c\f$
static ExecStatus post(Home home, A x0, B x1, Val c);
};
/**
* \brief %Propagator for bounds consistent binary linear greater or equal
*
* The type \a Val can be either \c long long int or \c int, defining the
* numerical precision during propagation. The types \a A and \a B
* give the types of the views.
*
* The propagation condition \a pc refers to both views.
*
* Requires \code #include <gecode/int/linear.hh> \endcode
* \ingroup FuncIntProp
*/
template<class Val, class A, class B>
class GqBin : public LinBin<Val,A,B,PC_INT_BND> {
protected:
using LinBin<Val,A,B,PC_INT_BND>::x0;
using LinBin<Val,A,B,PC_INT_BND>::x1;
using LinBin<Val,A,B,PC_INT_BND>::c;
/// Constructor for cloning \a p
GqBin(Space& home, bool share, GqBin& p);
/// Constructor for creation
GqBin(Home home, A x0, B x1, Val c);
public:
/// Constructor for rewriting \a p during cloning
GqBin(Space& home, bool share, Propagator& p, A x0, B x1, Val c);
/// Create copy during cloning
virtual Actor* copy(Space& home, bool share);
/// Perform propagation
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
/// Post propagator for \f$x_0+x_1 \geq c\f$
static ExecStatus post(Home home, A x0, B x1, Val c);
};
/**
* \brief %Propagator for reified bounds consistent binary linear less or equal
*
* The type \a Val can be either \c long long int or \c int, defining the
* numerical precision during propagation. The types \a A and \a B
* give the types of the views.
*
* The propagation condition \a pc refers to both views.
*
* Requires \code #include <gecode/int/linear.hh> \endcode
* \ingroup FuncIntProp
*/
template<class Val, class A, class B, ReifyMode rm>
class ReLqBin : public ReLinBin<Val,A,B,PC_INT_BND,BoolView> {
protected:
using ReLinBin<Val,A,B,PC_INT_BND,BoolView>::x0;
using ReLinBin<Val,A,B,PC_INT_BND,BoolView>::x1;
using ReLinBin<Val,A,B,PC_INT_BND,BoolView>::c;
using ReLinBin<Val,A,B,PC_INT_BND,BoolView>::b;
/// Constructor for cloning \a p
ReLqBin(Space& home, bool share, ReLqBin& p);
/// Constructor for creation
ReLqBin(Home home, A x0, B x1, Val c, BoolView b);
public:
/// Create copy during cloning
virtual Actor* copy(Space& home, bool share);
/// Perform propagation
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
/// Post propagator for \f$(x_0+x_1 \leq c)\equiv \operatorname{rm}(b)\f$
static ExecStatus post(Home home, A x0, B x1, Val c, BoolView b);
};
}}}
#include <gecode/int/linear/int-bin.hpp>
namespace Gecode { namespace Int { namespace Linear {
/*
* Ternary propagators
*
*/
/**
* \brief Base-class for ternary linear propagators
*
* The type \a Val can be either \c long long int or \c int, defining the
* numerical precision during propagation. The types \a A, \a B,
* and \a C give the types of the views.
*
* The propagation condition \a pc refers to all three views.
*/
template<class Val, class A, class B, class C, PropCond pc>
class LinTer : public Propagator {
protected:
/// View of type \a A
A x0;
/// View of type \a B
B x1;
/// View of type \a C
C x2;
/// Value of type \a Val
Val c;
/// Constructor for cloning \a p
LinTer(Space& home, bool share, LinTer& p);
/// Constructor for creation
LinTer(Home home, A x0, B x1, C x2, Val c);
/// Constructor for rewriting \a p during cloning
LinTer(Space& home, bool share, Propagator& p, A x0, B x1, C x2, Val c);
public:
/// Cost function (defined as low ternary)
virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
/// Delete propagator and return its size
virtual size_t dispose(Space& home);
};
/**
* \brief %Propagator for bounds consistent ternary linear equality
*
* The type \a Val can be either \c long long int or \c int, defining the
* numerical precision during propagation. The types \a A, \a B,
* and \a C give the types of the views.
*
* The propagation condition \a pc refers to all three views.
*
* Requires \code #include <gecode/int/linear.hh> \endcode
* \ingroup FuncIntProp
*/
template<class Val, class A, class B, class C>
class EqTer : public LinTer<Val,A,B,C,PC_INT_BND> {
protected:
using LinTer<Val,A,B,C,PC_INT_BND>::x0;
using LinTer<Val,A,B,C,PC_INT_BND>::x1;
using LinTer<Val,A,B,C,PC_INT_BND>::x2;
using LinTer<Val,A,B,C,PC_INT_BND>::c;
/// Constructor for cloning \a p
EqTer(Space& home, bool share, EqTer& p);
/// Constructor for creation
EqTer(Home home, A x0, B x1, C x2, Val c);
public:
/// Constructor for rewriting \a p during cloning
EqTer(Space& home, bool share, Propagator& p, A x0, B x1, C x2, Val c);
/// Create copy during cloning
virtual Actor* copy(Space& home, bool share);
/// Perform propagation
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
/// Post propagator for \f$x_0+x_1+x_2 = c\f$
static ExecStatus post(Home home, A x0, B x1, C x2, Val c);
};
/**
* \brief %Propagator for bounds consistent ternary linear disquality
*
* The type \a Val can be either \c long long int or \c int, defining the
* numerical precision during propagation. The types \a A, \a B,
* and \a C give the types of the views.
*
* The propagation condition \a pc refers to all three views.
*
* Requires \code #include <gecode/int/linear.hh> \endcode
* \ingroup FuncIntProp
*/
template<class Val, class A, class B, class C>
class NqTer : public LinTer<Val,A,B,C,PC_INT_VAL> {
protected:
using LinTer<Val,A,B,C,PC_INT_VAL>::x0;
using LinTer<Val,A,B,C,PC_INT_VAL>::x1;
using LinTer<Val,A,B,C,PC_INT_VAL>::x2;
using LinTer<Val,A,B,C,PC_INT_VAL>::c;
/// Constructor for cloning \a p
NqTer(Space& home, bool share, NqTer& p);
/// Constructor for creation
NqTer(Home home, A x0, B x1, C x2, Val c);
public:
/// Constructor for rewriting \a p during cloning
NqTer(Space& home, bool share, Propagator& p, A x0, B x1, C x2, Val c);
/// Create copy during cloning
virtual Actor* copy(Space& home, bool share);
/// Perform propagation
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
/// Post propagator for \f$x_0+x_1+x_2 \neq c\f$
static ExecStatus post(Home home, A x0, B x1, C x2, Val c);
};
/**
* \brief %Propagator for bounds consistent ternary linear less or equal
*
* The type \a Val can be either \c long long int or \c int, defining the
* numerical precision during propagation. The types \a A, \a B,
* and \a C give the types of the views.
*
* The propagation condition \a pc refers to all three views.
*
* Requires \code #include <gecode/int/linear.hh> \endcode
* \ingroup FuncIntProp
*/
template<class Val, class A, class B, class C>
class LqTer : public LinTer<Val,A,B,C,PC_INT_BND> {
protected:
using LinTer<Val,A,B,C,PC_INT_BND>::x0;
using LinTer<Val,A,B,C,PC_INT_BND>::x1;
using LinTer<Val,A,B,C,PC_INT_BND>::x2;
using LinTer<Val,A,B,C,PC_INT_BND>::c;
/// Constructor for cloning \a p
LqTer(Space& home, bool share, LqTer& p);
/// Constructor for creation
LqTer(Home home, A x0, B x1, C x2, Val c);
public:
/// Constructor for rewriting \a p during cloning
LqTer(Space& home, bool share, Propagator& p, A x0, B x1, C x2, Val c);
/// Create copy during cloning
virtual Actor* copy(Space& home, bool share);
/// Perform propagation
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
/// Post propagator for \f$x_0+x_1+x_2 \leq c\f$
static ExecStatus post(Home home, A x0, B x1, C x2, Val c);
};
}}}
#include <gecode/int/linear/int-ter.hpp>
namespace Gecode { namespace Int { namespace Linear {
/*
* n-ary propagators
*
*/
/**
* \brief Base-class for n-ary linear propagators
*
* The type \a Val can be either \c long long int or \c int, defining the
* numerical precision during propagation. Positive views are of
* type \a P whereas negative views are of type \a N.
*
* The propagation condition \a pc refers to all views.
*/
template<class Val, class P, class N, PropCond pc>
class Lin : public Propagator {
protected:
/// Array of positive views
ViewArray<P> x;
/// Array of negative views
ViewArray<N> y;
/// Constant value
Val c;
/// Constructor for cloning \a p
Lin(Space& home, bool share, Lin<Val,P,N,pc>& p);
/// Constructor for creation
Lin(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c);
public:
/// Cost function (defined as low linear)
virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
/// Delete propagator and return its size
virtual size_t dispose(Space& home);
};
/**
* \brief Base-class for reified n-ary linear propagators
*
* The type \a Val can be either \c long long int or \c int, defining the
* numerical precision during propagation. Positive views are of
* type \a P whereas negative views are of type \a N.
*
* The propagation condition \a pc refers to all views.
*/
template<class Val, class P, class N, PropCond pc, class Ctrl>
class ReLin : public Lin<Val,P,N,pc> {
protected:
/// Control view for reification
Ctrl b;
/// Constructor for cloning \a p
ReLin(Space& home, bool share, ReLin& p);
/// Constructor for creation
ReLin(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c, Ctrl b);
public:
/// Delete propagator and return its size
virtual size_t dispose(Space& home);
};
/**
* \brief Compute bounds information for positive views
*
* \relates Lin
*/
template<class Val, class View>
void bounds_p(ModEventDelta med, ViewArray<View>& x,
Val& c, Val& sl, Val& su);
/**
* \brief Compute bounds information for negative views
*
* \relates Lin
*/
template<class Val, class View>
void bounds_n(ModEventDelta med, ViewArray<View>& y,
Val& c, Val& sl, Val& su);
/**
* \brief %Propagator for bounds consistent n-ary linear equality
*
* The type \a Val can be either \c long long int or \c int, defining the
* numerical precision during propagation. The types \a P and \a N
* give the types of the views.
*
* The propagation condition \a pc refers to both views.
*
* Requires \code #include <gecode/int/linear.hh> \endcode
* \ingroup FuncIntProp
*/
template<class Val, class P, class N>
class Eq : public Lin<Val,P,N,PC_INT_BND> {
protected:
using Lin<Val,P,N,PC_INT_BND>::x;
using Lin<Val,P,N,PC_INT_BND>::y;
using Lin<Val,P,N,PC_INT_BND>::c;
/// Constructor for cloning \a p
Eq(Space& home, bool share, Eq& p);
public:
/// Constructor for creation
Eq(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c);
/// Create copy during cloning
virtual Actor* copy(Space& home, bool share);
/// Perform propagation
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
/// Post propagator for \f$\sum_{i=0}^{|x|-1}x_i-\sum_{i=0}^{|y|-1}y_i=c\f$
static ExecStatus
post(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c);
};
/**
* \brief %Propagator for domain consistent n-ary linear equality
*
* The type \a Val can be either \c long long int or \c int, defining the
* numerical precision during propagation. The types \a View
* give the type of the view.
*
* Requires \code #include <gecode/int/linear.hh> \endcode
* \ingroup FuncIntProp
*/
template<class Val, class View>
class DomEq
: public Lin<Val,View,View,PC_INT_DOM> {
protected:
using Lin<Val,View,View,PC_INT_DOM>::x;
using Lin<Val,View,View,PC_INT_DOM>::y;
using Lin<Val,View,View,PC_INT_DOM>::c;
/// Constructor for cloning \a p
DomEq(Space& home, bool share, DomEq& p);
public:
/// Constructor for creation
DomEq(Home home, ViewArray<View>& x, ViewArray<View>& y, Val c);
/// Create copy during cloning
virtual Actor* copy(Space& home, bool share);
/**
* \brief Cost function
*
* If in stage for bounds propagation, the cost is
* low linear. Otherwise it is high crazy.
*/
virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
/// Perform propagation
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
/// Post propagator for \f$\sum_{i=0}^{|x|-1}x_i-\sum_{i=0}^{|y|-1}y_i=c\f$
static ExecStatus
post(Home home, ViewArray<View>& x, ViewArray<View>& y, Val c);
};
/**
* \brief %Propagator for reified bounds consistent n-ary linear equality
*
* The type \a Val can be either \c long long int or \c int, defining the
* numerical precision during propagation. The types \a P and \a N
* give the types of the views.
*
* The propagation condition \a pc refers to both views.
*
* Requires \code #include <gecode/int/linear.hh> \endcode
* \ingroup FuncIntProp
*/
template<class Val, class P, class N, class Ctrl, ReifyMode rm>
class ReEq : public ReLin<Val,P,N,PC_INT_BND,Ctrl> {
protected:
using ReLin<Val,P,N,PC_INT_BND,Ctrl>::x;
using ReLin<Val,P,N,PC_INT_BND,Ctrl>::y;
using ReLin<Val,P,N,PC_INT_BND,Ctrl>::c;
using ReLin<Val,P,N,PC_INT_BND,Ctrl>::b;
/// Constructor for cloning \a p
ReEq(Space& home, bool share, ReEq& p);
public:
/// Constructor for creation
ReEq(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c, Ctrl b);
/// Create copy during cloning
virtual Actor* copy(Space& home, bool share);
/// Perform propagation
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
/// Post propagator for \f$\left(\sum_{i=0}^{|x|-1}x_i-\sum_{i=0}^{|y|-1}y_i=c\right)\equiv \operatorname{rm}(b)\f$
static ExecStatus
post(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c, Ctrl b);
};
/**
* \brief %Propagator for bounds consistent n-ary linear disequality
*
* The type \a Val can be either \c long long int or \c int, defining the
* numerical precision during propagation. The types \a P and \a N
* give the types of the views.
*
* The propagation condition \a pc refers to both views.
*
* Requires \code #include <gecode/int/linear.hh> \endcode
* \ingroup FuncIntProp
*/
template<class Val, class P, class N>
class Nq : public Lin<Val,P,N,PC_INT_VAL> {
protected:
using Lin<Val,P,N,PC_INT_VAL>::x;
using Lin<Val,P,N,PC_INT_VAL>::y;
using Lin<Val,P,N,PC_INT_VAL>::c;
/// Constructor for cloning \a p
Nq(Space& home, bool share, Nq& p);
public:
/// Constructor for creation
Nq(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c);
/// Create copy during cloning
virtual Actor* copy(Space& home, bool share);
/// Perform propagation
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
/// Post propagator for \f$\sum_{i=0}^{|x|-1}x_i-\sum_{i=0}^{|y|-1}y_i\neq c\f$
static ExecStatus
post(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c);
};
/**
* \brief %Propagator for bounds consistent n-ary linear less or equal
*
* The type \a Val can be either \c long long int or \c int, defining the
* numerical precision during propagation. The types \a P and \a N
* give the types of the views.
*
* The propagation condition \a pc refers to both views.
*
* Requires \code #include <gecode/int/linear.hh> \endcode
* \ingroup FuncIntProp
*/
template<class Val, class P, class N>
class Lq : public Lin<Val,P,N,PC_INT_BND> {
protected:
using Lin<Val,P,N,PC_INT_BND>::x;
using Lin<Val,P,N,PC_INT_BND>::y;
using Lin<Val,P,N,PC_INT_BND>::c;
/// Constructor for cloning \a p
Lq(Space& home, bool share, Lq& p);
public:
/// Constructor for creation
Lq(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c);
/// Create copy during cloning
virtual Actor* copy(Space& home, bool share);
/// Perform propagation
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
/// Post propagator for \f$\sum_{i=0}^{|x|-1}x_i-\sum_{i=0}^{|y|-1}y_i\leq c\f$
static ExecStatus
post(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c);
};
/**
* \brief %Propagator for reified bounds consistent n-ary linear less or equal
*
* The type \a Val can be either \c long long int or \c int, defining the
* numerical precision during propagation. The types \a P and \a N
* give the types of the views.
*
* The propagation condition \a pc refers to both views.
*
* Requires \code #include <gecode/int/linear.hh> \endcode
* \ingroup FuncIntProp
*/
template<class Val, class P, class N, ReifyMode rm>
class ReLq : public ReLin<Val,P,N,PC_INT_BND,BoolView> {
protected:
using ReLin<Val,P,N,PC_INT_BND,BoolView>::x;
using ReLin<Val,P,N,PC_INT_BND,BoolView>::y;
using ReLin<Val,P,N,PC_INT_BND,BoolView>::c;
using ReLin<Val,P,N,PC_INT_BND,BoolView>::b;
/// Constructor for cloning \a p
ReLq(Space& home, bool share, ReLq& p);
public:
/// Constructor for creation
ReLq(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c, BoolView b);
/// Create copy during cloning
virtual Actor* copy(Space& home, bool share);
/// Perform propagation
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
/// Post propagator for \f$\left(\sum_{i=0}^{|x|-1}x_i-\sum_{i=0}^{|y|-1}y_i\leq c\right)\equiv \operatorname{rm}(b)\f$
static ExecStatus
post(Home home, ViewArray<P>& x, ViewArray<N>& y, Val c, BoolView b);
};
}}}
#include <gecode/int/linear/int-nary.hpp>
#include <gecode/int/linear/int-dom.hpp>
namespace Gecode { namespace Int { namespace Linear {
/*
* Boolean linear propagators
*
*/
/**
* \brief Baseclass for integer Boolean sum
*
*/
template<class VX>
class LinBoolInt : public Propagator {
protected:
/// Council for managing single advisor
Council<Advisor> co;
/// Boolean views
ViewArray<VX> x;
/// Number of active subscriptions
int n_as;
/// Number of views that have or had subscriptions
int n_hs;
/// Righthandside
int c;
/// Normalize by removing unused views
void normalize(void);
/// Constructor for cloning \a p
LinBoolInt(Space& home, bool share, LinBoolInt& p);
/// Constructor for creation
LinBoolInt(Home home, ViewArray<VX>& x, int n_s, int c);
public:
/// Cost function (defined as high unary)
virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
/// Delete propagator and return its size
virtual size_t dispose(Space& home);
};
/**
* \brief %Propagator for integer equal to Boolean sum (cardinality)
*
* Requires \code #include <gecode/int/linear.hh> \endcode
* \ingroup FuncIntProp
*/
template<class VX>
class EqBoolInt : public LinBoolInt<VX> {
protected:
using LinBoolInt<VX>::co;
using LinBoolInt<VX>::x;
using LinBoolInt<VX>::n_as;
using LinBoolInt<VX>::n_hs;
using LinBoolInt<VX>::c;
/// Constructor for cloning \a p
EqBoolInt(Space& home, bool share, EqBoolInt& p);
/// Constructor for creation
EqBoolInt(Home home, ViewArray<VX>& x, int c);
public:
/// Create copy during cloning
virtual Actor* copy(Space& home, bool share);
/// Give advice to propagator
virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
/// Perform propagation
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
/// Post propagator for \f$\sum_{i=0}^{|x|-1}x_i = c\f$
static ExecStatus post(Home home, ViewArray<VX>& x, int c);
};
/**
* \brief %Propagator for integer less or equal to Boolean sum (cardinality)
*
* Requires \code #include <gecode/int/linear.hh> \endcode
* \ingroup FuncIntProp
*/
template<class VX>
class GqBoolInt : public LinBoolInt<VX> {
protected:
using LinBoolInt<VX>::co;
using LinBoolInt<VX>::x;
using LinBoolInt<VX>::n_as;
using LinBoolInt<VX>::n_hs;
using LinBoolInt<VX>::c;
/// Constructor for cloning \a p
GqBoolInt(Space& home, bool share, GqBoolInt& p);
/// Constructor for creation
GqBoolInt(Home home, ViewArray<VX>& x, int c);
public:
/// Create copy during cloning
virtual Actor* copy(Space& home, bool share);
/// Give advice to propagator
virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
/// Perform propagation
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
/// Post propagator for \f$\sum_{i=0}^{|x|-1}x_i \geq c\f$
static ExecStatus post(Home home, ViewArray<VX>& x, int c);
};
/**
* \brief %Propagator for integer disequal to Boolean sum (cardinality)
*
* Requires \code #include <gecode/int/linear.hh> \endcode
* \ingroup FuncIntProp
*/
template<class VX>
class NqBoolInt : public BinaryPropagator<VX,PC_INT_VAL> {
protected:
using BinaryPropagator<VX,PC_INT_VAL>::x0;
using BinaryPropagator<VX,PC_INT_VAL>::x1;
/// Views not yet subscribed to
ViewArray<VX> x;
/// Righthandside
int c;
/// Update subscription
bool resubscribe(Space& home, VX& y);
/// Constructor for posting
NqBoolInt(Home home, ViewArray<VX>& b, int c);
/// Constructor for cloning \a p
NqBoolInt(Space& home, bool share, NqBoolInt<VX>& p);
public:
/// Copy propagator during cloning
virtual Actor* copy(Space& home, bool share);
/// Cost function (defined as low linear)
virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
/// Perform propagation
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
/// Post propagator for \f$\sum_{i=0}^{|x|-1}x_i \neq c\f$
static ExecStatus post(Home home, ViewArray<VX>& b, int c);
/// Delete propagator and return its size
virtual size_t dispose(Space& home);
};
/**
* \brief Baseclass for reified integer Boolean sum
*
*/
template<class VX, class VB>
class ReLinBoolInt : public Propagator {
protected:
/// Council for single advisor
Council<Advisor> co;
/// Views
ViewArray<VX> x;
/// Number of subscriptions
int n_s;
/// Righthandside
int c;
/// Control variable
VB b;
/// Normalize by removing unused views
void normalize(void);
/// Constructor for cloning \a p
ReLinBoolInt(Space& home, bool share, ReLinBoolInt& p);
/// Constructor for creation
ReLinBoolInt(Home home, ViewArray<VX>& x, int c, VB b);
public:
/// Cost function (defined as high unary)
virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
/// Delete propagator and return its size
virtual size_t dispose(Space& home);
};
/**
* \brief Traits for Boolean negation view
*/
template<class BV>
class BoolNegTraits {};
/**
* \brief %Propagator for reified integer less or equal to Boolean sum (cardinality)
*
* Requires \code #include <gecode/int/linear.hh> \endcode
* \ingroup FuncIntProp
*/
template<class VX, class VB, ReifyMode rm>
class ReGqBoolInt : public ReLinBoolInt<VX,VB> {
protected:
using ReLinBoolInt<VX,VB>::co;
using ReLinBoolInt<VX,VB>::x;
using ReLinBoolInt<VX,VB>::c;
using ReLinBoolInt<VX,VB>::b;
using ReLinBoolInt<VX,VB>::n_s;
using ReLinBoolInt<VX,VB>::normalize;
/// Constructor for cloning \a p
ReGqBoolInt(Space& home, bool share, ReGqBoolInt& p);
/// Constructor for creation
ReGqBoolInt(Home home, ViewArray<VX>& x, int c, VB b);
public:
/// Create copy during cloning
virtual Actor* copy(Space& home, bool share);
/// Give advice to propagator
virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
/// Perform propagation
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
/// Post propagator for \f$\left(\sum_{i=0}^{|x|-1}x_i \geq\right) c \equiv \operatorname{rm}(b)\f$
static ExecStatus post(Home home, ViewArray<VX>& x, int c, VB b);
};
/**
* \brief %Propagator for reified integer equal to Boolean sum (cardinality)
*
* Requires \code #include <gecode/int/linear.hh> \endcode
* \ingroup FuncIntProp
*/
template<class VX, class VB, ReifyMode rm>
class ReEqBoolInt : public ReLinBoolInt<VX,VB> {
protected:
using ReLinBoolInt<VX,VB>::co;
using ReLinBoolInt<VX,VB>::x;
using ReLinBoolInt<VX,VB>::c;
using ReLinBoolInt<VX,VB>::b;
using ReLinBoolInt<VX,VB>::n_s;
using ReLinBoolInt<VX,VB>::normalize;
/// Constructor for cloning \a p
ReEqBoolInt(Space& home, bool share, ReEqBoolInt& p);
/// Constructor for creation
ReEqBoolInt(Home home, ViewArray<VX>& x, int c, VB b);
public:
/// Create copy during cloning
virtual Actor* copy(Space& home, bool share);
/// Give advice to propagator
virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
/// Perform propagation
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
/// Post propagator for \f$\left(\sum_{i=0}^{|x|-1}x_i = c\right)\equiv \operatorname{rm}(b)\f$
static ExecStatus post(Home home, ViewArray<VX>& x, int c, VB b);
};
}}}
#include <gecode/int/linear/bool-int.hpp>
namespace Gecode { namespace Int { namespace Linear {
/**
* \brief Base-class for Boolean linear propagators
*
*/
template<class XV, class YV>
class LinBoolView : public Propagator {
protected:
/// Boolean views
ViewArray<XV> x;
/// View to compare number of assigned Boolean views to
YV y;
/// Righthandside (constant part from Boolean views assigned to 1)
int c;
/// Constructor for cloning \a p
LinBoolView(Space& home, bool share, LinBoolView& p);
/// Constructor for creation
LinBoolView(Home home, ViewArray<XV>& x, YV y, int c);
public:
/// Cost function (defined as low linear)
virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
/// Delete propagator and return its size
virtual size_t dispose(Space& home);
};
/**
* \brief %Propagator for equality to Boolean sum (cardinality)
*
* Requires \code #include <gecode/int/linear.hh> \endcode
* \ingroup FuncIntProp
*/
template<class XV, class YV>
class EqBoolView : public LinBoolView<XV,YV> {
protected:
using LinBoolView<XV,YV>::x;
using LinBoolView<XV,YV>::y;
using LinBoolView<XV,YV>::c;
/// Constructor for cloning \a p
EqBoolView(Space& home, bool share, EqBoolView& p);
/// Constructor for creation
EqBoolView(Home home, ViewArray<XV>& x, YV y, int c);
public:
/// Create copy during cloning
virtual Actor* copy(Space& home, bool share);
/// Perform propagation
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
/// Post propagator for \f$\sum_{i=0}^{|x|-1}x_i = y+c\f$
static ExecStatus post(Home home, ViewArray<XV>& x, YV y, int c);
};
/**
* \brief %Propagator for disequality to Boolean sum (cardinality)
*
* Requires \code #include <gecode/int/linear.hh> \endcode
* \ingroup FuncIntProp
*/
template<class XV, class YV>
class NqBoolView : public LinBoolView<XV,YV> {
protected:
using LinBoolView<XV,YV>::x;
using LinBoolView<XV,YV>::y;
using LinBoolView<XV,YV>::c;
/// Constructor for cloning \a p
NqBoolView(Space& home, bool share, NqBoolView& p);
/// Constructor for creation
NqBoolView(Home home, ViewArray<XV>& x, YV y, int c);
public:
/// Create copy during cloning
virtual Actor* copy(Space& home, bool share);
/// Perform propagation
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
/// Post propagator for \f$\sum_{i=0}^{|x|-1}x_i \neq y+c\f$
static ExecStatus post(Home home, ViewArray<XV>& x, YV y, int c);
};
/**
* \brief %Propagator for greater or equal to Boolean sum (cardinality)
*
* Requires \code #include <gecode/int/linear.hh> \endcode
* \ingroup FuncIntProp
*/
template<class XV, class YV>
class GqBoolView : public LinBoolView<XV,YV> {
protected:
using LinBoolView<XV,YV>::x;
using LinBoolView<XV,YV>::y;
using LinBoolView<XV,YV>::c;
/// Constructor for cloning \a p
GqBoolView(Space& home, bool share, GqBoolView& p);
/// Constructor for creation
GqBoolView(Home home, ViewArray<XV>& x, YV y, int c);
public:
/// Create copy during cloning
virtual Actor* copy(Space& home, bool share);
/// Perform propagation
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
/// Post propagator for \f$\sum_{i=0}^{|x|-1}x_i \geq y+c\f$
static ExecStatus post(Home home, ViewArray<XV>& x, YV y, int c);
};
}}}
#include <gecode/int/linear/bool-view.hpp>
namespace Gecode { namespace Int { namespace Linear {
/// Coefficient and Boolean view
class ScaleBool {
public:
/// Integer coefficient
int a;
/// Boolean view
BoolView x;
};
/// Array of scale Boolean views
class ScaleBoolArray {
private:
/// First entry in array
ScaleBool* _fst;
/// One after last entry in array
ScaleBool* _lst;
public:
/// Default constructor
ScaleBoolArray(void);
/// Create array with \a n elements
ScaleBoolArray(Space& home, int n);
/// Subscribe propagator \a p
void subscribe(Space& home, Propagator& p);
/// Cancel propagator \a p
void cancel(Space& home, Propagator& p);
/// Update \a sba during copying
void update(Space& home, bool share, ScaleBoolArray& sba);
/// Return pointer to first element
ScaleBool* fst(void) const;
/// Return pointer after last element
ScaleBool* lst(void) const;
/// Set pointer to first element
void fst(ScaleBool* f);
/// Set pointer after last element
void lst(ScaleBool* l);
/// Test whether array is empty
bool empty(void) const;
/// Return number of elements
int size(void) const;
private:
/// For sorting array in decreasing order of coefficients
class ScaleDec {
public:
bool
operator ()(const ScaleBool& x, const ScaleBool& y);
};
public:
/// Sort array in decreasing order of coefficients
void sort(void);
};
/// Empty array of scale Boolean views
class EmptyScaleBoolArray {
public:
/// Default constructor
EmptyScaleBoolArray(void);
/// Create array with \a n elements
EmptyScaleBoolArray(Space& home, int n);
/// Subscribe propagator \a p
void subscribe(Space& home, Propagator& p);
/// Cancel propagator \a p
void cancel(Space& home, Propagator& p);
/// Update \a sba during copying
void update(Space& home, bool share, EmptyScaleBoolArray& esba);
/// Return pointer to first element
ScaleBool* fst(void) const;
/// Return pointer after last element
ScaleBool* lst(void) const;
/// Set pointer to first element
void fst(ScaleBool* f);
/// Set pointer after last element
void lst(ScaleBool* l);
/// Test whether array is empty
bool empty(void) const;
/// Return number of elements
int size(void) const;
/// Sort array in decreasing order of coefficients
void sort(void);
};
/**
* \brief Base class for linear Boolean constraints with coefficients
*
*/
template<class SBAP, class SBAN, class VX, PropCond pcx>
class LinBoolScale : public Propagator {
protected:
/// Positive Boolean views with coefficients on left-hand side
SBAP p;
/// Negative Boolean views with coefficients on left-hand side
SBAN n;
/// Integer view on right-hand side
VX x;
/// Integer constant on right-hand side
int c;
public:
/// Constructor for creation
LinBoolScale(Home home, SBAP& p, SBAN& n, VX x, int c);
/// Constructor for cloning \a pr
LinBoolScale(Space& home, bool share, Propagator& pr,
SBAP& p, SBAN& n, VX x, int c);
/// Cost function (defined as low linear)
virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
/// Delete propagator and return its size
virtual size_t dispose(Space& home);
};
/**
* \brief %Propagator for equality to Boolean sum with coefficients
*
* Requires \code #include <gecode/int/linear.hh> \endcode
* \ingroup FuncIntProp
*/
template<class SBAP, class SBAN, class VX>
class EqBoolScale : public LinBoolScale<SBAP,SBAN,VX,PC_INT_BND> {
protected:
using LinBoolScale<SBAP,SBAN,VX,PC_INT_BND>::p;
using LinBoolScale<SBAP,SBAN,VX,PC_INT_BND>::n;
using LinBoolScale<SBAP,SBAN,VX,PC_INT_BND>::x;
using LinBoolScale<SBAP,SBAN,VX,PC_INT_BND>::c;
public:
/// Constructor for creation
EqBoolScale(Home home, SBAP& p, SBAN& n, VX x, int c);
/// Constructor for cloning \a pr
EqBoolScale(Space& home, bool share, Propagator& pr,
SBAP& p, SBAN& n, VX x, int c);
/// Create copy during cloning
virtual Actor* copy(Space& home, bool share);
/// Perform propagation
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
/// Post propagator
static ExecStatus post(Home home, SBAP& p, SBAN& n, VX x, int c);
};
/**
* \brief %Propagator for inequality to Boolean sum with coefficients
*
* Requires \code #include <gecode/int/linear.hh> \endcode
* \ingroup FuncIntProp
*/
template<class SBAP, class SBAN, class VX>
class LqBoolScale : public LinBoolScale<SBAP,SBAN,VX,PC_INT_BND> {
protected:
using LinBoolScale<SBAP,SBAN,VX,PC_INT_BND>::p;
using LinBoolScale<SBAP,SBAN,VX,PC_INT_BND>::n;
using LinBoolScale<SBAP,SBAN,VX,PC_INT_BND>::x;
using LinBoolScale<SBAP,SBAN,VX,PC_INT_BND>::c;
public:
/// Constructor for creation
LqBoolScale(Home home, SBAP& p, SBAN& n, VX x, int c);
/// Constructor for cloning \a pr
LqBoolScale(Space& home, bool share, Propagator& pr,
SBAP& p, SBAN& n, VX x, int c);
/// Create copy during cloning
virtual Actor* copy(Space& home, bool share);
/// Perform propagation
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
/// Post propagator
static ExecStatus post(Home home, SBAP& p, SBAN& n, VX x, int c);
};
/**
* \brief %Propagator for disequality to Boolean sum with coefficients
*
* Requires \code #include <gecode/int/linear.hh> \endcode
* \ingroup FuncIntProp
*/
template<class SBAP, class SBAN, class VX>
class NqBoolScale : public LinBoolScale<SBAP,SBAN,VX,PC_INT_VAL> {
protected:
using LinBoolScale<SBAP,SBAN,VX,PC_INT_VAL>::p;
using LinBoolScale<SBAP,SBAN,VX,PC_INT_VAL>::n;
using LinBoolScale<SBAP,SBAN,VX,PC_INT_VAL>::x;
using LinBoolScale<SBAP,SBAN,VX,PC_INT_VAL>::c;
public:
/// Constructor for creation
NqBoolScale(Home home, SBAP& p, SBAN& n, VX x, int c);
/// Constructor for cloning \a pr
NqBoolScale(Space& home, bool share, Propagator& pr,
SBAP& p, SBAN& n, VX x, int c);
/// Create copy during cloning
virtual Actor* copy(Space& home, bool share);
/// Perform propagation
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
/// Post propagator
static ExecStatus post(Home home, SBAP& p, SBAN& n, VX x, int c);
};
}}}
#include <gecode/int/linear/bool-scale.hpp>
namespace Gecode { namespace Int { namespace Linear {
/**
* \brief Class for describing linear term \f$a\cdot x\f$
*
*/
template<class View>
class Term {
public:
/// Coefficient
int a;
/// View
View x;
};
/** \brief Estimate lower and upper bounds
*
* Estimates the boundaries for a linear expression
* \f$\sum_{i=0}^{n-1}t_i + c\f$. If the boundaries exceed
* the limits as defined in Limits::Int, these boundaries
* are returned.
*
* \param t array of linear terms
* \param n size of array
* \param c constant
* \param l lower bound
* \param u upper bound
*
*/
template<class View>
void estimate(Term<View>* t, int n, int c,
int& l, int& u);
/**
* \brief Post propagator for linear constraint over integers
* \param home current space
* \param t array of linear terms over integers
* \param n size of array
* \param irt type of relation
* \param c result of linear constraint
*
* All variants for linear constraints share the following properties:
* - Variables occuring multiply in the term array are replaced
* by a single occurence: for example, \f$ax+bx\f$ becomes
* \f$(a+b)x\f$.
* - If in the above simplification the value for \f$(a+b)\f$ (or for
* \f$a\f$ and \f$b\f$) exceeds the limits for integers as
* defined in Limits::Int, an exception of type
* Int::NumericalOverflow is thrown.
* - Assume linear terms for the constraint
* \f$\sum_{i=0}^{|x|-1}a_i\cdot x_i\sim_{irt} c\f$.
* If \f$|c|+\sum_{i=0}^{|x|-1}a_i\cdot x_i\f$ exceeds the limits
* for long long ints as defined in Limits::Int, an exception of
* type Int::NumericalOverflow is thrown.
* - In all other cases, the created propagators are accurate (that
* is, they will not silently overflow during propagation).
*
* Requires \code #include <gecode/int/linear.hh> \endcode
* \ingroup FuncIntProp
*/
GECODE_INT_EXPORT void
post(Home home, Term<IntView>* t, int n, IntRelType irt, int c,
IntConLevel=ICL_DEF);
/**
* \brief Post reified propagator for linear constraint
* \param home current space
* \param t array of linear terms
* \param n size of array
* \param irt type of relation
* \param c result of linear constraint
* \param r reification specification
*
* All variants for linear constraints share the following properties:
* - Only bounds consistency is supported.
* - Variables occuring multiply in the term array are replaced
* by a single occurence: for example, \f$ax+bx\f$ becomes
* \f$(a+b)x\f$.
* - If in the above simplification the value for \f$(a+b)\f$ (or for
* \f$a\f$ and \f$b\f$) exceeds the limits for integers as
* defined in Limits::Int, an exception of type
* Int::NumericalOverflow is thrown.
* - Assume linear terms for the constraint
* \f$\sum_{i=0}^{|x|-1}a_i\cdot x_i\sim_{irt} c\f$.
* If \f$|c|+\sum_{i=0}^{|x|-1}a_i\cdot x_i\f$ exceeds the limits
* for long long ints as defined in Limits::Int, an exception of
* type Int::NumericalOverflow is thrown.
* - In all other cases, the created propagators are accurate (that
* is, they will not silently overflow during propagation).
*
* Requires \code #include <gecode/int/linear.hh> \endcode
* \ingroup FuncIntProp
*/
GECODE_INT_EXPORT void
post(Home home, Term<IntView>* t, int n, IntRelType irt, int c, Reify r,
IntConLevel=ICL_DEF);
/**
* \brief Post propagator for linear constraint over Booleans
* \param home current space
* \param t array of linear terms over Booleans
* \param n size of array
* \param irt type of relation
* \param c result of linear constraint
*
* All variants for linear constraints share the following properties:
* - Variables occuring multiply in the term array are replaced
* by a single occurence: for example, \f$ax+bx\f$ becomes
* \f$(a+b)x\f$.
* - If in the above simplification the value for \f$(a+b)\f$ (or for
* \f$a\f$ and \f$b\f$) exceeds the limits for integers as
* defined in Limits::Int, an exception of type
* Int::NumericalOverflow is thrown.
* - Assume linear terms for the constraint
* \f$\sum_{i=0}^{|x|-1}a_i\cdot x_i\sim_{irt} c\f$.
* If \f$|c|+\sum_{i=0}^{|x|-1}a_i\cdot x_i\f$ exceeds the limits
* for integers as defined in Limits::Int, an exception of
* type Int::NumericalOverflow is thrown.
* - In all other cases, the created propagators are accurate (that
* is, they will not silently overflow during propagation).
*
* Requires \code #include <gecode/int/linear.hh> \endcode
* \ingroup FuncIntProp
*/
GECODE_INT_EXPORT void
post(Home home, Term<BoolView>* t, int n, IntRelType irt, int c,
IntConLevel=ICL_DEF);
/**
* \brief Post propagator for reified linear constraint over Booleans
* \param home current space
* \param t array of linear terms over Booleans
* \param n size of array
* \param irt type of relation
* \param c result of linear constraint
* \param r reification specification
*
* All variants for linear constraints share the following properties:
* - Variables occuring multiply in the term array are replaced
* by a single occurence: for example, \f$ax+bx\f$ becomes
* \f$(a+b)x\f$.
* - If in the above simplification the value for \f$(a+b)\f$ (or for
* \f$a\f$ and \f$b\f$) exceeds the limits for integers as
* defined in Limits::Int, an exception of type
* Int::NumericalOverflow is thrown.
* - Assume linear terms for the constraint
* \f$\sum_{i=0}^{|x|-1}a_i\cdot x_i\sim_{irt} c\f$.
* If \f$|c|+\sum_{i=0}^{|x|-1}a_i\cdot x_i\f$ exceeds the limits
* for integers as defined in Limits::Int, an exception of
* type Int::NumericalOverflow is thrown.
* - In all other cases, the created propagators are accurate (that
* is, they will not silently overflow during propagation).
*
* Requires \code #include <gecode/int/linear.hh> \endcode
* \ingroup FuncIntProp
*/
GECODE_INT_EXPORT void
post(Home home, Term<BoolView>* t, int n, IntRelType irt, int c, Reify r,
IntConLevel=ICL_DEF);
/**
* \brief Post propagator for linear constraint over Booleans
* \param home current space
* \param t array of linear terms over Booleans
* \param n size of array
* \param irt type of relation
* \param y variable right hand side of linear constraint
* \param c constant right hand side of linear constraint
*
* All variants for linear constraints share the following properties:
* - Variables occuring multiply in the term array are replaced
* by a single occurence: for example, \f$ax+bx\f$ becomes
* \f$(a+b)x\f$.
* - If in the above simplification the value for \f$(a+b)\f$ (or for
* \f$a\f$ and \f$b\f$) exceeds the limits for integers as
* defined in Limits::Int, an exception of type
* Int::NumericalOverflow is thrown.
* - Assume linear terms for the constraint
* \f$\sum_{i=0}^{|x|-1}a_i\cdot x_i\sim_{irt} c\f$.
* If \f$|c|+\sum_{i=0}^{|x|-1}a_i\cdot x_i\f$ exceeds the limits
* for integers as defined in Limits::Int, an exception of
* type Int::NumericalOverflow is thrown.
* - In all other cases, the created propagators are accurate (that
* is, they will not silently overflow during propagation).
*
* Requires \code #include <gecode/int/linear.hh> \endcode
* \ingroup FuncIntProp
*/
GECODE_INT_EXPORT void
post(Home home, Term<BoolView>* t, int n, IntRelType irt, IntView y, int c=0,
IntConLevel=ICL_DEF);
/**
* \brief Post propagator for reified linear constraint over Booleans
* \param home current space
* \param t array of linear terms over Booleans
* \param n size of array
* \param irt type of relation
* \param y variable right hand side of linear constraint
* \param r reification specification
*
* All variants for linear constraints share the following properties:
* - Variables occuring multiply in the term array are replaced
* by a single occurence: for example, \f$ax+bx\f$ becomes
* \f$(a+b)x\f$.
* - If in the above simplification the value for \f$(a+b)\f$ (or for
* \f$a\f$ and \f$b\f$) exceeds the limits for integers as
* defined in Limits::Int, an exception of type
* Int::NumericalOverflow is thrown.
* - Assume linear terms for the constraint
* \f$\sum_{i=0}^{|x|-1}a_i\cdot x_i\sim_{irt} c\f$.
* If \f$|c|+\sum_{i=0}^{|x|-1}a_i\cdot x_i\f$ exceeds the limits
* for integers as defined in Limits::Int, an exception of
* type Int::NumericalOverflow is thrown.
* - In all other cases, the created propagators are accurate (that
* is, they will not silently overflow during propagation).
*
* Requires \code #include <gecode/int/linear.hh> \endcode
* \ingroup FuncIntProp
*/
GECODE_INT_EXPORT void
post(Home home, Term<BoolView>* t, int n, IntRelType irt, IntView y,
Reify r, IntConLevel=ICL_DEF);
}}}
#include <gecode/int/linear/post.hpp>
#endif
// STATISTICS: int-prop
|