/usr/include/gecode/minimodel.hh is in libgecode-dev 4.4.0-5.
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 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 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 | /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main authors:
* Christian Schulte <schulte@gecode.org>
* Guido Tack <tack@gecode.org>
* Mikael Lagerkvist <lagerkvist@gecode.org>
* Vincent Barichard <Vincent.Barichard@univ-angers.fr>
*
* Copyright:
* Christian Schulte, 2004
* Guido Tack, 2004
* Mikael Lagerkvist, 2005
* Vincent Barichard, 2012
*
* Last modified:
* $Date: 2015-03-20 15:37:34 +0100 (Fri, 20 Mar 2015) $ by $Author: schulte $
* $Revision: 14471 $
*
* 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_MINIMODEL_HH__
#define __GECODE_MINIMODEL_HH__
#include <gecode/kernel.hh>
#include <gecode/int.hh>
#ifdef GECODE_HAS_SET_VARS
#include <gecode/set.hh>
#endif
#ifdef GECODE_HAS_FLOAT_VARS
#include <gecode/float.hh>
#endif
#include <gecode/minimodel/exception.hpp>
#include <iostream>
/*
* Support for DLLs under Windows
*
*/
#if !defined(GECODE_STATIC_LIBS) && \
(defined(__CYGWIN__) || defined(__MINGW32__) || defined(_MSC_VER))
#ifdef GECODE_BUILD_MINIMODEL
#define GECODE_MINIMODEL_EXPORT __declspec( dllexport )
#else
#define GECODE_MINIMODEL_EXPORT __declspec( dllimport )
#endif
#else
#ifdef GECODE_GCC_HAS_CLASS_VISIBILITY
#define GECODE_MINIMODEL_EXPORT __attribute__ ((visibility("default")))
#else
#define GECODE_MINIMODEL_EXPORT
#endif
#endif
// Configure auto-linking
#ifndef GECODE_BUILD_MINIMODEL
#define GECODE_LIBRARY_NAME "MiniModel"
#include <gecode/support/auto-link.hpp>
#endif
namespace Gecode {
/// Minimalistic modeling support
namespace MiniModel {}
class LinIntRel;
#ifdef GECODE_HAS_SET_VARS
class SetExpr;
#endif
#ifdef GECODE_HAS_FLOAT_VARS
class LinFloatExpr;
#endif
/// Base class for non-linear expressions over integer variables
class NonLinIntExpr {
public:
/// Return variable constrained to be equal to the expression
virtual IntVar post(Home home, IntVar* ret, IntConLevel icl) const = 0;
/// Post expression to be in relation \a irt with \a c
virtual void post(Home home, IntRelType irt, int c,
IntConLevel icl) const = 0;
/// Post reified expression to be in relation \a irt with \a c
virtual void post(Home home, IntRelType irt, int c,
BoolVar b, IntConLevel icl) const = 0;
/// Destructor
virtual ~NonLinIntExpr(void) {}
/// Return fresh variable if \a x is NULL, \a x otherwise
static IntVar result(Home home, IntVar* x) {
if (x==NULL)
return IntVar(home,Int::Limits::min,Int::Limits::max);
return *x;
}
/// Constrain \a x to be equal to \a y if \a x is not NULL
static IntVar result(Home home, IntVar* x, IntVar y) {
if (x!=NULL)
rel(home,*x,IRT_EQ,y);
return y;
}
/// Memory management
void* operator new(size_t size) { return heap.ralloc(size); }
/// Memory management
void operator delete(void* p, size_t) { heap.rfree(p); }
};
/// Linear expressions over integer variables
class LinIntExpr {
friend class LinIntRel;
#ifdef GECODE_HAS_SET_VARS
friend class SetExpr;
#endif
#ifdef GECODE_HAS_FLOAT_VARS
friend class LinFloatExpr;
#endif
public:
/// Type of linear expression
enum NodeType {
NT_CONST, ///< Integer constant
NT_VAR_INT, ///< Linear term with integer variable
NT_VAR_BOOL, ///< Linear term with Boolean variable
NT_NONLIN, ///< Non-linear expression
NT_SUM_INT, ///< Sum of integer variables
NT_SUM_BOOL, ///< Sum of Boolean variables
NT_ADD, ///< Addition of linear terms
NT_SUB, ///< Subtraction of linear terms
NT_MUL ///< Multiplication by coefficient
};
private:
/// Nodes for linear expressions
class Node;
Node* n;
public:
/// Default constructor
GECODE_MINIMODEL_EXPORT
LinIntExpr(void);
/// Create expression for constant \a c
GECODE_MINIMODEL_EXPORT
LinIntExpr(int c);
/// Create expression
GECODE_MINIMODEL_EXPORT
LinIntExpr(const IntVar& x, int a=1);
/// Create expression
GECODE_MINIMODEL_EXPORT
LinIntExpr(const BoolVar& x, int a=1);
/// Create sum expression
GECODE_MINIMODEL_EXPORT
explicit LinIntExpr(const IntVarArgs& x);
/// Create sum expression
GECODE_MINIMODEL_EXPORT
LinIntExpr(const IntArgs& a, const IntVarArgs& x);
/// Create sum expression
GECODE_MINIMODEL_EXPORT
explicit LinIntExpr(const BoolVarArgs& x);
/// Create sum expression
GECODE_MINIMODEL_EXPORT
LinIntExpr(const IntArgs& a, const BoolVarArgs& x);
/// Copy constructor
GECODE_MINIMODEL_EXPORT
LinIntExpr(const LinIntExpr& e);
/// Create expression for type and subexpressions
GECODE_MINIMODEL_EXPORT
LinIntExpr(const LinIntExpr& e0, NodeType t, const LinIntExpr& e1);
/// Create expression for type and subexpression
GECODE_MINIMODEL_EXPORT
LinIntExpr(const LinIntExpr& e0, NodeType t, int c);
/// Create expression for multiplication
GECODE_MINIMODEL_EXPORT
LinIntExpr(int a, const LinIntExpr& e);
/// Create non-linear expression
GECODE_MINIMODEL_EXPORT
explicit LinIntExpr(NonLinIntExpr* e);
/// Assignment operator
GECODE_MINIMODEL_EXPORT
const LinIntExpr& operator =(const LinIntExpr& e);
/// Post propagator
GECODE_MINIMODEL_EXPORT
void post(Home home, IntRelType irt, IntConLevel icl) const;
/// Post reified propagator
GECODE_MINIMODEL_EXPORT
void post(Home home, IntRelType irt, const BoolVar& b,
IntConLevel icl) const;
/// Post propagator and return variable for value
GECODE_MINIMODEL_EXPORT
IntVar post(Home home, IntConLevel icl) const;
/// Return non-linear expression inside, or NULL if not non-linear
GECODE_MINIMODEL_EXPORT
NonLinIntExpr* nle(void) const;
/// Destructor
GECODE_MINIMODEL_EXPORT
~LinIntExpr(void);
};
class BoolExpr;
/// Linear relations over integer variables
class LinIntRel {
friend class BoolExpr;
private:
/// Linear expression describing the entire relation
LinIntExpr e;
/// Which relation
IntRelType irt;
/// Negate relation type
static IntRelType neg(IntRelType irt);
/// Default constructor
LinIntRel(void);
public:
/// Create linear relation for expressions \a l and \a r
LinIntRel(const LinIntExpr& l, IntRelType irt, const LinIntExpr& r);
/// Create linear relation for expression \a l and integer \a r
LinIntRel(const LinIntExpr& l, IntRelType irt, int r);
/// Create linear relation for integer \a l and expression \a r
LinIntRel(int l, IntRelType irt, const LinIntExpr& r);
/// Post propagator for relation (if \a t is false for negated relation)
void post(Home home, bool t, IntConLevel icl) const;
/// Post reified propagator for relation (if \a t is false for negated relation)
void post(Home home, const BoolVar& b, bool t, IntConLevel icl) const;
};
/**
* \defgroup TaskModelMiniModelLin Linear expressions and relations
*
* Linear expressions can be freely composed of sums and differences of
* integer variables (Gecode::IntVar) or Boolean variables
* (Gecode::BoolVar) possibly with integer coefficients and integer
* constants.
*
* Note that both integer and Boolean variables are automatically
* available as linear expressions.
*
* Linear relations are obtained from linear expressions with the normal
* relation operators.
*
* \ingroup TaskModelMiniModel
*/
//@{
/// Construct linear expression as sum of integer variable and integer
GECODE_MINIMODEL_EXPORT LinIntExpr
operator +(int, const IntVar&);
/// Construct linear expression as sum of Boolean variable and integer
GECODE_MINIMODEL_EXPORT LinIntExpr
operator +(int, const BoolVar&);
/// Construct linear expression as sum of linear expression and integer
GECODE_MINIMODEL_EXPORT LinIntExpr
operator +(int, const LinIntExpr&);
/// Construct linear expression as sum of integer variable and integer
GECODE_MINIMODEL_EXPORT LinIntExpr
operator +(const IntVar&, int);
/// Construct linear expression as sum of Boolean variable and integer
GECODE_MINIMODEL_EXPORT LinIntExpr
operator +(const BoolVar&, int);
/// Construct linear expression as sum of linear expression and integer
GECODE_MINIMODEL_EXPORT LinIntExpr
operator +(const LinIntExpr&, int);
/// Construct linear expression as sum of integer variables
GECODE_MINIMODEL_EXPORT LinIntExpr
operator +(const IntVar&, const IntVar&);
/// Construct linear expression as sum of integer and Boolean variable
GECODE_MINIMODEL_EXPORT LinIntExpr
operator +(const IntVar&, const BoolVar&);
/// Construct linear expression as sum of Boolean and integer variable
GECODE_MINIMODEL_EXPORT LinIntExpr
operator +(const BoolVar&, const IntVar&);
/// Construct linear expression as sum of Boolean variables
GECODE_MINIMODEL_EXPORT LinIntExpr
operator +(const BoolVar&, const BoolVar&);
/// Construct linear expression as sum of integer variable and linear expression
GECODE_MINIMODEL_EXPORT LinIntExpr
operator +(const IntVar&, const LinIntExpr&);
/// Construct linear expression as sum of Boolean variable and linear expression
GECODE_MINIMODEL_EXPORT LinIntExpr
operator +(const BoolVar&, const LinIntExpr&);
/// Construct linear expression as sum of linear expression and integer variable
GECODE_MINIMODEL_EXPORT LinIntExpr
operator +(const LinIntExpr&, const IntVar&);
/// Construct linear expression as sum of linear expression and Boolean variable
GECODE_MINIMODEL_EXPORT LinIntExpr
operator +(const LinIntExpr&, const BoolVar&);
/// Construct linear expression as sum of linear expressions
GECODE_MINIMODEL_EXPORT LinIntExpr
operator +(const LinIntExpr&, const LinIntExpr&);
/// Construct linear expression as sum of integer variable and integer
GECODE_MINIMODEL_EXPORT LinIntExpr
operator -(int, const IntVar&);
/// Construct linear expression as sum of Boolean variable and integer
GECODE_MINIMODEL_EXPORT LinIntExpr
operator -(int, const BoolVar&);
/// Construct linear expression as sum of integer and linear expression
GECODE_MINIMODEL_EXPORT LinIntExpr
operator -(int, const LinIntExpr&);
/// Construct linear expression as sum of integer variable and integer
GECODE_MINIMODEL_EXPORT LinIntExpr
operator -(const IntVar&, int);
/// Construct linear expression as sum of Boolean variable and integer
GECODE_MINIMODEL_EXPORT LinIntExpr
operator -(const BoolVar&, int);
/// Construct linear expression as sum of linear expression and integer
GECODE_MINIMODEL_EXPORT LinIntExpr
operator -(const LinIntExpr&, int);
/// Construct linear expression as sum of integer variables
GECODE_MINIMODEL_EXPORT LinIntExpr
operator -(const IntVar&, const IntVar&);
/// Construct linear expression as sum of integer and Boolean variable
GECODE_MINIMODEL_EXPORT LinIntExpr
operator -(const IntVar&, const BoolVar&);
/// Construct linear expression as sum of Boolean and integer variable
GECODE_MINIMODEL_EXPORT LinIntExpr
operator -(const BoolVar&, const IntVar&);
/// Construct linear expression as sum of Boolean variables
GECODE_MINIMODEL_EXPORT LinIntExpr
operator -(const BoolVar&, const BoolVar&);
/// Construct linear expression as sum of integer variable and linear expression
GECODE_MINIMODEL_EXPORT LinIntExpr
operator -(const IntVar&, const LinIntExpr&);
/// Construct linear expression as sum of Boolean variable and linear expression
GECODE_MINIMODEL_EXPORT LinIntExpr
operator -(const BoolVar&, const LinIntExpr&);
/// Construct linear expression as sum of linear expression and integer variable
GECODE_MINIMODEL_EXPORT LinIntExpr
operator -(const LinIntExpr&, const IntVar&);
/// Construct linear expression as sum of linear expression and Boolean variable
GECODE_MINIMODEL_EXPORT LinIntExpr
operator -(const LinIntExpr&, const BoolVar&);
/// Construct linear expression as sum of linear expressions
GECODE_MINIMODEL_EXPORT LinIntExpr
operator -(const LinIntExpr&, const LinIntExpr&);
/// Construct linear expression as negative of integer variable
GECODE_MINIMODEL_EXPORT LinIntExpr
operator -(const IntVar&);
/// Construct linear expression as negative of Boolean variable
GECODE_MINIMODEL_EXPORT LinIntExpr
operator -(const BoolVar&);
/// Construct linear expression as negative of linear expression
GECODE_MINIMODEL_EXPORT LinIntExpr
operator -(const LinIntExpr&);
/// Construct linear expression as product of integer coefficient and integer variable
GECODE_MINIMODEL_EXPORT LinIntExpr
operator *(int, const IntVar&);
/// Construct linear expression as product of integer coefficient and Boolean variable
GECODE_MINIMODEL_EXPORT LinIntExpr
operator *(int, const BoolVar&);
/// Construct linear expression as product of integer coefficient and integer variable
GECODE_MINIMODEL_EXPORT LinIntExpr
operator *(const IntVar&, int);
/// Construct linear expression as product of integer coefficient and Boolean variable
GECODE_MINIMODEL_EXPORT LinIntExpr
operator *(const BoolVar&, int);
/// Construct linear expression as product of integer coefficient and linear expression
GECODE_MINIMODEL_EXPORT LinIntExpr
operator *(const LinIntExpr&, int);
/// Construct linear expression as product of integer coefficient and linear expression
GECODE_MINIMODEL_EXPORT LinIntExpr
operator *(int, const LinIntExpr&);
/// Construct linear expression as sum of integer variables
GECODE_MINIMODEL_EXPORT LinIntExpr
sum(const IntVarArgs& x);
/// Construct linear expression as sum of integer variables with coefficients
GECODE_MINIMODEL_EXPORT LinIntExpr
sum(const IntArgs& a, const IntVarArgs& x);
/// Construct linear expression as sum of Boolean variables
GECODE_MINIMODEL_EXPORT LinIntExpr
sum(const BoolVarArgs& x);
/// Construct linear expression as sum of Boolean variables with coefficients
GECODE_MINIMODEL_EXPORT LinIntExpr
sum(const IntArgs& a, const BoolVarArgs& x);
/// Construct linear expression as sum of \ref IntArgs
GECODE_MINIMODEL_EXPORT LinIntExpr
sum(const IntArgs& args);
/// Construct linear equality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator ==(int l, const IntVar& r);
/// Construct linear equality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator ==(int l, const BoolVar& r);
/// Construct linear equality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator ==(int l, const LinIntExpr& r);
/// Construct linear equality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator ==(const IntVar& l, int r);
/// Construct linear equality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator ==(const BoolVar& l, int r);
/// Construct linear equality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator ==(const LinIntExpr& l, int r);
/// Construct linear equality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator ==(const IntVar& l, const IntVar& r);
/// Construct linear equality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator ==(const IntVar& l, const BoolVar& r);
/// Construct linear equality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator ==(const BoolVar& l, const IntVar& r);
/// Construct linear equality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator ==(const BoolVar& l, const BoolVar& r);
/// Construct linear equality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator ==(const IntVar& l, const LinIntExpr& r);
/// Construct linear equality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator ==(const BoolVar& l, const LinIntExpr& r);
/// Construct linear equality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator ==(const LinIntExpr& l, const IntVar& r);
/// Construct linear equality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator ==(const LinIntExpr& l, const BoolVar& r);
/// Construct linear equality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator ==(const LinIntExpr& l, const LinIntExpr& r);
/// Construct linear disequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator !=(int l, const IntVar& r);
/// Construct linear disequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator !=(int l, const BoolVar& r);
/// Construct linear disequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator !=(int l, const LinIntExpr& r);
/// Construct linear disequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator !=(const IntVar& l, int r);
/// Construct linear disequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator !=(const BoolVar& l, int r);
/// Construct linear disequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator !=(const LinIntExpr& l, int r);
/// Construct linear disequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator !=(const IntVar& l, const IntVar& r);
/// Construct linear disequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator !=(const IntVar& l, const BoolVar& r);
/// Construct linear disequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator !=(const BoolVar& l, const IntVar& r);
/// Construct linear disequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator !=(const BoolVar& l, const BoolVar& r);
/// Construct linear disequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator !=(const IntVar& l, const LinIntExpr& r);
/// Construct linear disequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator !=(const BoolVar& l, const LinIntExpr& r);
/// Construct linear disequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator !=(const LinIntExpr& l, const IntVar& r);
/// Construct linear disequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator !=(const LinIntExpr& l, const BoolVar& r);
/// Construct linear disequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator !=(const LinIntExpr& l, const LinIntExpr& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator <(int l, const IntVar& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator <(int l, const BoolVar& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator <(int l, const LinIntExpr& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator <(const IntVar& l, int r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator <(const BoolVar& l, int r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator <(const LinIntExpr& l, int r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator <(const IntVar& l, const IntVar& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator <(const IntVar& l, const BoolVar& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator <(const BoolVar& l, const IntVar& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator <(const BoolVar& l, const BoolVar& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator <(const IntVar& l, const LinIntExpr& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator <(const BoolVar& l, const LinIntExpr& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator <(const LinIntExpr& l, const IntVar& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator <(const LinIntExpr& l, const BoolVar& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator <(const LinIntExpr& l, const LinIntExpr& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator <=(int l, const IntVar& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator <=(int l, const BoolVar& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator <=(int l, const LinIntExpr& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator <=(const IntVar& l, int r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator <=(const BoolVar& l, int r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator <=(const LinIntExpr& l, int r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator <=(const IntVar& l, const IntVar& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator <=(const IntVar& l, const BoolVar& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator <=(const BoolVar& l, const IntVar& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator <=(const BoolVar& l, const BoolVar& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator <=(const IntVar& l, const LinIntExpr& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator <=(const BoolVar& l, const LinIntExpr& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator <=(const LinIntExpr& l, const IntVar& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator <=(const LinIntExpr& l, const BoolVar& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator <=(const LinIntExpr& l, const LinIntExpr& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator >(int l, const IntVar& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator >(int l, const BoolVar& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator >(int l, const LinIntExpr& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator >(const IntVar& l, int r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator >(const BoolVar& l, int r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator >(const LinIntExpr& l, int r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator >(const IntVar& l, const IntVar& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator >(const IntVar& l, const BoolVar& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator >(const BoolVar& l, const IntVar& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator >(const BoolVar& l, const BoolVar& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator >(const IntVar& l, const LinIntExpr& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator >(const BoolVar& l, const LinIntExpr& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator >(const LinIntExpr& l, const IntVar& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator >(const LinIntExpr& l, const BoolVar& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator >(const LinIntExpr& l, const LinIntExpr& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator >=(int l, const IntVar& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator >=(int l, const BoolVar& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator >=(int l, const LinIntExpr& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator >=(const IntVar& l, int r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator >=(const BoolVar& l, int r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator >=(const LinIntExpr& l, int r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator >=(const IntVar& l, const IntVar& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator >=(const IntVar& l, const BoolVar& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator >=(const BoolVar& l, const IntVar& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator >=(const BoolVar& l, const BoolVar& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator >=(const IntVar& l, const LinIntExpr& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator >=(const BoolVar& l, const LinIntExpr& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator >=(const LinIntExpr& l, const IntVar& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator >=(const LinIntExpr& l, const BoolVar& r);
/// Construct linear inequality relation
GECODE_MINIMODEL_EXPORT LinIntRel
operator >=(const LinIntExpr& l, const LinIntExpr& r);
//@}
#ifdef GECODE_HAS_FLOAT_VARS
/// Base class for non-linear float expressions
class NonLinFloatExpr {
public:
/// Return variable constrained to be equal to the expression
virtual FloatVar post(Home home, FloatVar* ret) const = 0;
/// Post expression to be in relation \a frt with \a c
virtual void post(Home home, FloatRelType frt, FloatVal c) const = 0;
/// Post reified expression to be in relation \a frt with \a c
virtual void post(Home home, FloatRelType frt, FloatVal c,
BoolVar b) const = 0;
/// Destructor
virtual ~NonLinFloatExpr(void) {}
/// Return fresh variable if \a x is NULL, \a x otherwise
static FloatVar result(Home home, FloatVar* x) {
if (x == NULL)
return FloatVar(home,Float::Limits::min,Float::Limits::max);
return *x;
}
/// Constrain \a x to be equal to \a y if \a x is not NULL
static FloatVar result(Home home, FloatVar* x, FloatVar y) {
if (x!=NULL)
rel(home,*x,FRT_EQ,y);
return y;
}
/// Memory management
void* operator new(size_t size) { return heap.ralloc(size); }
/// Memory management
void operator delete(void* p, size_t) { heap.rfree(p); }
};
/// %Float expressions
class LinFloatExpr {
friend class LinFloatRel;
public:
/// Type of linear expression
enum NodeType {
NT_CONST, ///< Float value constant
NT_VAR, ///< Linear term with variable
NT_NONLIN, ///< Non-linear expression
NT_SUM, ///< Sum of float variables
NT_ADD, ///< Addition of linear terms
NT_SUB, ///< Subtraction of linear terms
NT_MUL ///< Multiplication by coefficient
};
private:
/// Nodes for linear expressions
class Node;
Node* n;
public:
/// Default constructor
GECODE_MINIMODEL_EXPORT
LinFloatExpr(void);
/// Create expression for constant \a c
GECODE_MINIMODEL_EXPORT
LinFloatExpr(const FloatVal& c);
/// Create expression
GECODE_MINIMODEL_EXPORT
LinFloatExpr(const FloatVar& x);
/// Create expression
GECODE_MINIMODEL_EXPORT
LinFloatExpr(const FloatVar& x, FloatVal a);
/// Create sum expression
GECODE_MINIMODEL_EXPORT
explicit LinFloatExpr(const FloatVarArgs& x);
/// Create sum expression
GECODE_MINIMODEL_EXPORT
LinFloatExpr(const FloatValArgs& a, const FloatVarArgs& x);
/// Copy constructor
GECODE_MINIMODEL_EXPORT
LinFloatExpr(const LinFloatExpr& e);
/// Create expression for type and subexpressions
GECODE_MINIMODEL_EXPORT
LinFloatExpr(const LinFloatExpr& e0, NodeType t, const LinFloatExpr& e1);
/// Create expression for type and subexpression
GECODE_MINIMODEL_EXPORT
LinFloatExpr(const LinFloatExpr& e0, NodeType t, const FloatVal& c);
/// Create expression for multiplication
GECODE_MINIMODEL_EXPORT
LinFloatExpr(FloatVal a, const LinFloatExpr& e);
/// Create non-linear expression
GECODE_MINIMODEL_EXPORT
explicit LinFloatExpr(NonLinFloatExpr* e);
/// Assignment operator
GECODE_MINIMODEL_EXPORT
const LinFloatExpr& operator =(const LinFloatExpr& e);
/// Post propagator
GECODE_MINIMODEL_EXPORT
void post(Home home, FloatRelType frt) const;
/// Post reified propagator
GECODE_MINIMODEL_EXPORT
void post(Home home, FloatRelType frt, const BoolVar& b) const;
/// Post propagator and return variable for value
GECODE_MINIMODEL_EXPORT
FloatVar post(Home home) const;
/// Return non-linear expression inside, or NULL if not non-linear
GECODE_MINIMODEL_EXPORT
NonLinFloatExpr* nlfe(void) const;
/// Destructor
GECODE_MINIMODEL_EXPORT
~LinFloatExpr(void);
};
class BoolExpr;
/// Linear relations
class LinFloatRel {
friend class BoolExpr;
private:
/// Linear float expression describing the entire relation
LinFloatExpr e;
/// Which relation
FloatRelType frt;
/// Negate relation type
static FloatRelType neg(FloatRelType frt);
/// Default constructor
LinFloatRel(void);
public:
/// Create linear float relation for expressions \a l and \a r
LinFloatRel(const LinFloatExpr& l, FloatRelType frt, const LinFloatExpr& r);
/// Create linear float relation for expression \a l and FloatVal \a r
LinFloatRel(const LinFloatExpr& l, FloatRelType frt, FloatVal r);
/// Create linear float relation for FloatVal \a l and expression \a r
LinFloatRel(FloatVal l, FloatRelType frt, const LinFloatExpr& r);
/// Post propagator for relation (if \a t is false for negated relation)
void post(Home home, bool t) const;
/// Post reified propagator for relation (if \a t is false for negated relation)
void post(Home home, const BoolVar& b, bool t) const;
};
/**
* \defgroup TaskModelMiniModelFloat Linear float expressions and relations
*
* Linear float expressions can be freely composed of sums and differences of
* float variables (Gecode::FloatVar) with float coefficients and float
* constants.
*
* Linear float relations are obtained from linear float expressions with the normal
* relation operators.
*
* \ingroup TaskModelMiniModel
*/
//@{
/// Construct linear float expression as sum of float variable and float
GECODE_MINIMODEL_EXPORT LinFloatExpr
operator +(const FloatVal&, const FloatVar&);
/// Construct linear float expression as sum of linear float expression and float
GECODE_MINIMODEL_EXPORT LinFloatExpr
operator +(const FloatVal&, const LinFloatExpr&);
/// Construct linear float expression as sum of float variable and float
GECODE_MINIMODEL_EXPORT LinFloatExpr
operator +(const FloatVar&, const FloatVal&);
/// Construct linear float expression as sum of linear float expression and float
GECODE_MINIMODEL_EXPORT LinFloatExpr
operator +(const LinFloatExpr&, const FloatVal&);
/// Construct linear float expression as sum of float variables
GECODE_MINIMODEL_EXPORT LinFloatExpr
operator +(const FloatVar&, const FloatVar&);
/// Construct linear float expression as sum of float variable and linear float expression
GECODE_MINIMODEL_EXPORT LinFloatExpr
operator +(const FloatVar&, const LinFloatExpr&);
/// Construct linear float expression as sum of linear float expression and float variable
GECODE_MINIMODEL_EXPORT LinFloatExpr
operator +(const LinFloatExpr&, const FloatVar&);
/// Construct linear float expression as sum of linear float expressions
GECODE_MINIMODEL_EXPORT LinFloatExpr
operator +(const LinFloatExpr&, const LinFloatExpr&);
/// Construct linear float expression as sum of float variable and float
GECODE_MINIMODEL_EXPORT LinFloatExpr
operator -(const FloatVal&, const FloatVar&);
/// Construct linear float expression as sum of float and linear float expression
GECODE_MINIMODEL_EXPORT LinFloatExpr
operator -(const FloatVal&, const LinFloatExpr&);
/// Construct linear float expression as sum of float variable and float
GECODE_MINIMODEL_EXPORT LinFloatExpr
operator -(const FloatVar&, const FloatVal&);
/// Construct linear float expression as sum of linear float expression and float
GECODE_MINIMODEL_EXPORT LinFloatExpr
operator -(const LinFloatExpr&, const FloatVal&);
/// Construct linear float expression as sum of float variables
GECODE_MINIMODEL_EXPORT LinFloatExpr
operator -(const FloatVar&, const FloatVar&);
/// Construct linear float expression as sum of float variable and linear float expression
GECODE_MINIMODEL_EXPORT LinFloatExpr
operator -(const FloatVar&, const LinFloatExpr&);
/// Construct linear float expression as sum of linear float expression and float variable
GECODE_MINIMODEL_EXPORT LinFloatExpr
operator -(const LinFloatExpr&, const FloatVar&);
/// Construct linear float expression as sum of linear float expressions
GECODE_MINIMODEL_EXPORT LinFloatExpr
operator -(const LinFloatExpr&, const LinFloatExpr&);
/// Construct linear float expression as negative of float variable
GECODE_MINIMODEL_EXPORT LinFloatExpr
operator -(const FloatVar&);
/// Construct linear float expression as negative of linear float expression
GECODE_MINIMODEL_EXPORT LinFloatExpr
operator -(const LinFloatExpr&);
/// Construct linear float expression as product of float coefficient and float variable
GECODE_MINIMODEL_EXPORT LinFloatExpr
operator *(const FloatVal&, const FloatVar&);
/// Construct linear float expression as product of float coefficient and float variable
GECODE_MINIMODEL_EXPORT LinFloatExpr
operator *(const FloatVar&, const FloatVal&);
/// Construct linear float expression as product of float coefficient and linear float expression
GECODE_MINIMODEL_EXPORT LinFloatExpr
operator *(const LinFloatExpr&, const FloatVal&);
/// Construct linear float expression as product of float coefficient and linear float expression
GECODE_MINIMODEL_EXPORT LinFloatExpr
operator *(const FloatVal&, const LinFloatExpr&);
/// Construct linear float expression as sum of float variables
GECODE_MINIMODEL_EXPORT LinFloatExpr
sum(const FloatVarArgs& x);
/// Construct linear float expression as sum of float variables with coefficients
GECODE_MINIMODEL_EXPORT LinFloatExpr
sum(const FloatValArgs& a, const FloatVarArgs& x);
/// Construct linear float equality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator ==(const FloatVal& l, const FloatVar& r);
/// Construct linear float equality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator ==(const FloatVal& l, const LinFloatExpr& r);
/// Construct linear float equality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator ==(const FloatVar& l, const FloatVal& r);
/// Construct linear float equality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator ==(const LinFloatExpr& l, const FloatVal& r);
/// Construct linear float equality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator ==(const FloatVar& l, const FloatVar& r);
/// Construct linear float equality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator ==(const FloatVar& l, const BoolVar& r);
/// Construct linear float equality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator ==(const FloatVar& l, const LinFloatExpr& r);
/// Construct linear float equality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator ==(const LinFloatExpr& l, const FloatVar& r);
/// Construct linear float equality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator ==(const LinFloatExpr& l, const BoolVar& r);
/// Construct linear float equality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator ==(const LinFloatExpr& l, const LinFloatExpr& r);
/// Construct linear float disequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator !=(const FloatVal& l, const FloatVar& r);
/// Construct linear float disequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator !=(const FloatVal& l, const LinFloatExpr& r);
/// Construct linear float disequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator !=(const FloatVar& l, const FloatVal& r);
/// Construct linear float disequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator !=(const LinFloatExpr& l, const FloatVal& r);
/// Construct linear float disequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator !=(const FloatVar& l, const FloatVar& r);
/// Construct linear float disequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator !=(const FloatVar& l, const BoolVar& r);
/// Construct linear float disequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator !=(const FloatVar& l, const LinFloatExpr& r);
/// Construct linear float disequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator !=(const LinFloatExpr& l, const FloatVar& r);
/// Construct linear float disequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator !=(const LinFloatExpr& l, const BoolVar& r);
/// Construct linear float disequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator !=(const LinFloatExpr& l, const LinFloatExpr& r);
/// Construct linear float inequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator <(const FloatVal& l, const FloatVar& r);
/// Construct linear float inequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator <(const FloatVal& l, const LinFloatExpr& r);
/// Construct linear float inequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator <(const FloatVar& l, const FloatVal& r);
/// Construct linear float inequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator <(const LinFloatExpr& l, const FloatVal& r);
/// Construct linear float inequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator <(const FloatVar& l, const FloatVar& r);
/// Construct linear float inequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator <(const FloatVar& l, const LinFloatExpr& r);
/// Construct linear float inequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator <(const LinFloatExpr& l, const FloatVar& r);
/// Construct linear float inequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator <(const LinFloatExpr& l, const LinFloatExpr& r);
/// Construct linear float inequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator <=(const FloatVal& l, const FloatVar& r);
/// Construct linear float inequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator <=(const FloatVal& l, const LinFloatExpr& r);
/// Construct linear float inequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator <=(const FloatVar& l, const FloatVal& r);
/// Construct linear float inequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator <=(const LinFloatExpr& l, const FloatVal& r);
/// Construct linear float inequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator <=(const FloatVar& l, const FloatVar& r);
/// Construct linear float inequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator <=(const FloatVar& l, const LinFloatExpr& r);
/// Construct linear float inequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator <=(const LinFloatExpr& l, const FloatVar& r);
/// Construct linear float inequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator <=(const LinFloatExpr& l, const LinFloatExpr& r);
/// Construct linear float inequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator >(const FloatVal& l, const FloatVar& r);
/// Construct linear float inequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator >(const FloatVal& l, const LinFloatExpr& r);
/// Construct linear float inequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator >(const FloatVar& l, const FloatVal& r);
/// Construct linear float inequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator >(const LinFloatExpr& l, const FloatVal& r);
/// Construct linear float inequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator >(const FloatVar& l, const FloatVar& r);
/// Construct linear float inequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator >(const FloatVar& l, const LinFloatExpr& r);
/// Construct linear float inequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator >(const LinFloatExpr& l, const FloatVar& r);
/// Construct linear float inequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator >(const LinFloatExpr& l, const LinFloatExpr& r);
/// Construct linear float inequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator >=(const FloatVal& l, const FloatVar& r);
/// Construct linear float inequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator >=(const FloatVal& l, const LinFloatExpr& r);
/// Construct linear float inequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator >=(const FloatVar& l, const FloatVal& r);
/// Construct linear float inequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator >=(const LinFloatExpr& l, const FloatVal& r);
/// Construct linear float inequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator >=(const FloatVar& l, const FloatVar& r);
/// Construct linear float inequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator >=(const FloatVar& l, const LinFloatExpr& r);
/// Construct linear float inequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator >=(const LinFloatExpr& l, const FloatVar& r);
/// Construct linear float inequality relation
GECODE_MINIMODEL_EXPORT LinFloatRel
operator >=(const LinFloatExpr& l, const LinFloatExpr& r);
//@}
#endif
#ifdef GECODE_HAS_SET_VARS
/// %Set expressions
class SetExpr {
public:
/// Type of set expression
enum NodeType {
NT_VAR, ///< Variable
NT_CONST, ///< Constant
NT_LEXP, ///< Linear expression
NT_CMPL, ///< Complement
NT_INTER, ///< Intersection
NT_UNION, ///< Union
NT_DUNION ///< Disjoint union
};
/// %Node for set expression
class Node;
private:
/// Pointer to node for expression
Node* n;
public:
/// Default constructor
SetExpr(void);
/// Copy constructor
GECODE_MINIMODEL_EXPORT
SetExpr(const SetExpr& e);
/// Construct expression for type and subexpresssions
GECODE_MINIMODEL_EXPORT
SetExpr(const SetExpr& l, NodeType t, const SetExpr& r);
/// Construct expression for variable
GECODE_MINIMODEL_EXPORT
SetExpr(const SetVar& x);
/// Construct expression for integer variable
GECODE_MINIMODEL_EXPORT
explicit SetExpr(const LinIntExpr& x);
/// Construct expression for constant
GECODE_MINIMODEL_EXPORT
SetExpr(const IntSet& s);
/// Construct expression for negation
GECODE_MINIMODEL_EXPORT
SetExpr(const SetExpr& e, NodeType t);
/// Post propagators for expression
GECODE_MINIMODEL_EXPORT
SetVar post(Home home) const;
/// Post propagators for relation
GECODE_MINIMODEL_EXPORT
void post(Home home, SetRelType srt, const SetExpr& e) const;
/// Post propagators for reified relation
GECODE_MINIMODEL_EXPORT
void post(Home home, BoolVar b, bool t,
SetRelType srt, const SetExpr& e) const;
/// Assignment operator
GECODE_MINIMODEL_EXPORT
const SetExpr& operator =(const SetExpr& e);
/// Destructor
GECODE_MINIMODEL_EXPORT
~SetExpr(void);
};
/// Comparison relation (for two-sided comparisons)
class SetCmpRel {
public:
/// Left side of relation
SetExpr l;
/// Right side of relation
SetExpr r;
/// Which relation
SetRelType srt;
/// Constructor
SetCmpRel(const SetExpr& l, SetRelType srt, const SetExpr& r);
};
/// %Set relations
class SetRel {
private:
/// Expression
SetExpr _e0;
/// Relation
SetRelType _srt;
/// Expression
SetExpr _e1;
public:
/// Default constructor
SetRel(void);
/// Constructor
SetRel(const SetExpr& e0, SetRelType srt, const SetExpr& e1);
/// Constructor
SetRel(const SetCmpRel& r);
/// Post propagators for relation (or negated relation if \a t is false)
void post(Home home, bool t) const;
/// Post propagators for reified relation (or negated relation if \a t is false)
void post(Home home, BoolVar b, bool t) const;
};
/**
* \defgroup TaskModelMiniModelSet Set expressions and relations
*
* Set expressions and relations can be freely composed of variables
* with the usual connectives.
*
* \ingroup TaskModelMiniModel
*/
//@{
/// Singleton expression
GECODE_MINIMODEL_EXPORT SetExpr
singleton(const LinIntExpr&);
/// Complement expression
GECODE_MINIMODEL_EXPORT SetExpr
operator -(const SetExpr&);
/// Intersection of set expressions
GECODE_MINIMODEL_EXPORT SetExpr
operator &(const SetExpr&, const SetExpr&);
/// Union of set expressions
GECODE_MINIMODEL_EXPORT SetExpr
operator |(const SetExpr&, const SetExpr&);
/// Disjoint union of set expressions
GECODE_MINIMODEL_EXPORT SetExpr
operator +(const SetExpr&, const SetExpr&);
/// Difference of set expressions
GECODE_MINIMODEL_EXPORT SetExpr
operator -(const SetExpr&, const SetExpr&);
/// Intersection of set variables
GECODE_MINIMODEL_EXPORT SetExpr
inter(const SetVarArgs&);
/// Union of set variables
GECODE_MINIMODEL_EXPORT SetExpr
setunion(const SetVarArgs&);
/// Disjoint union of set variables
GECODE_MINIMODEL_EXPORT SetExpr
setdunion(const SetVarArgs&);
/// Cardinality of set expression
GECODE_MINIMODEL_EXPORT LinIntExpr
cardinality(const SetExpr&);
/// Minimum element of set expression
GECODE_MINIMODEL_EXPORT LinIntExpr
min(const SetExpr&);
/// Minimum element of set expression
GECODE_MINIMODEL_EXPORT LinIntExpr
max(const SetExpr&);
/// Equality of set expressions
GECODE_MINIMODEL_EXPORT SetRel
operator ==(const SetExpr&, const SetExpr&);
/// Disequality of set expressions
GECODE_MINIMODEL_EXPORT SetRel
operator !=(const SetExpr&, const SetExpr&);
/// Subset of set expressions
GECODE_MINIMODEL_EXPORT SetCmpRel
operator <=(const SetExpr&, const SetExpr&);
/// Subset of set expressions
GECODE_MINIMODEL_EXPORT BoolExpr
operator <=(const SetCmpRel&, const SetExpr&);
/// Superset of set expressions
GECODE_MINIMODEL_EXPORT SetCmpRel
operator >=(const SetExpr&, const SetExpr&);
/// Superset of set expressions
GECODE_MINIMODEL_EXPORT BoolExpr
operator >=(const SetCmpRel&, const SetExpr&);
/// Disjointness of set expressions
GECODE_MINIMODEL_EXPORT SetRel
operator ||(const SetExpr&, const SetExpr&);
//@}
#endif
/// Boolean expressions
class BoolExpr {
public:
/// Type of Boolean expression
enum NodeType {
NT_VAR, ///< Variable
NT_NOT, ///< Negation
NT_AND, ///< Conjunction
NT_OR, ///< Disjunction
NT_EQV, ///< Equivalence
NT_RLIN, ///< Reified linear relation
NT_RLINFLOAT, ///< Reified linear relation
NT_RSET, ///< Reified set relation
NT_MISC ///< Other Boolean expression
};
/// Miscealloneous Boolean expressions
class MiscExpr {
public:
/** Constrain \a b to be equivalent to the expression
* (negated if \a neg)
*/
virtual void post(Space& home, BoolVar b, bool neg,
IntConLevel icl) = 0;
/// Destructor
virtual GECODE_MINIMODEL_EXPORT ~MiscExpr(void);
/// Memory management
static void* operator new(size_t size);
/// Memory management
static void operator delete(void* p, size_t size);
};
/// %Node for Boolean expression
class Node;
private:
/// Pointer to node for expression
Node* n;
public:
/// Default constructor
GECODE_MINIMODEL_EXPORT
BoolExpr(void);
/// Copy constructor
GECODE_MINIMODEL_EXPORT
BoolExpr(const BoolExpr& e);
/// Construct expression for type and subexpresssions
GECODE_MINIMODEL_EXPORT
BoolExpr(const BoolExpr& l, NodeType t, const BoolExpr& r);
/// Construct expression for variable
GECODE_MINIMODEL_EXPORT
BoolExpr(const BoolVar& x);
/// Construct expression for negation
GECODE_MINIMODEL_EXPORT
BoolExpr(const BoolExpr& e, NodeType t);
/// Construct expression for reified linear relation
GECODE_MINIMODEL_EXPORT
BoolExpr(const LinIntRel& rl);
#ifdef GECODE_HAS_FLOAT_VARS
/// Construct expression for reified float relation
GECODE_MINIMODEL_EXPORT
BoolExpr(const LinFloatRel& rfl);
#endif
#ifdef GECODE_HAS_SET_VARS
/// Construct expression for reified set relation
GECODE_MINIMODEL_EXPORT
BoolExpr(const SetRel& rs);
/// Construct expression for reified set relation
GECODE_MINIMODEL_EXPORT
BoolExpr(const SetCmpRel& rs);
#endif
/// Construct expression for miscellaneous Boolean expression
GECODE_MINIMODEL_EXPORT
explicit BoolExpr(MiscExpr* m);
/// Post propagators for expression
GECODE_MINIMODEL_EXPORT
BoolVar expr(Home home, IntConLevel icl) const;
/// Post propagators for relation
GECODE_MINIMODEL_EXPORT
void rel(Home home, IntConLevel icl) const;
/// Assignment operator
GECODE_MINIMODEL_EXPORT
const BoolExpr& operator =(const BoolExpr& e);
/// Destructor
GECODE_MINIMODEL_EXPORT
~BoolExpr(void);
};
/**
* \defgroup TaskModelMiniModelBool Boolean expressions
*
* Boolean expressions can be freely composed of variables with
* the usual connectives and reified linear expressions.
*
* \ingroup TaskModelMiniModel
*/
//@{
/// Negated Boolean expression
GECODE_MINIMODEL_EXPORT BoolExpr
operator !(const BoolExpr&);
/// Conjunction of Boolean expressions
GECODE_MINIMODEL_EXPORT BoolExpr
operator &&(const BoolExpr&, const BoolExpr&);
/// Disjunction of Boolean expressions
GECODE_MINIMODEL_EXPORT BoolExpr
operator ||(const BoolExpr&, const BoolExpr&);
/// Exclusive-or of Boolean expressions
GECODE_MINIMODEL_EXPORT BoolExpr
operator ^(const BoolExpr&, const BoolExpr&);
/// Non-equivalence of Boolean expressions
GECODE_MINIMODEL_EXPORT BoolExpr
operator !=(const BoolExpr&, const BoolExpr&);
/// Equivalence of Boolean expressions
GECODE_MINIMODEL_EXPORT BoolExpr
operator ==(const BoolExpr&, const BoolExpr&);
/// Implication of Boolean expressions
GECODE_MINIMODEL_EXPORT BoolExpr
operator >>(const BoolExpr&, const BoolExpr&);
/// Reverse implication of Boolean expressions
GECODE_MINIMODEL_EXPORT BoolExpr
operator <<(const BoolExpr&, const BoolExpr&);
//@}
/**
* \defgroup TaskModelMiniModelPost Posting of expressions and relations
*
* \ingroup TaskModelMiniModel
*/
//@{
/// Post linear expression and return its value
GECODE_MINIMODEL_EXPORT IntVar
expr(Home home, const LinIntExpr& e, IntConLevel icl=ICL_DEF);
#ifdef GECODE_HAS_FLOAT_VARS
/// Post float expression and return its value
GECODE_MINIMODEL_EXPORT FloatVar
expr(Home home, const LinFloatExpr& e);
#endif
#ifdef GECODE_HAS_SET_VARS
/// Post set expression and return its value
GECODE_MINIMODEL_EXPORT SetVar
expr(Home home, const SetExpr& e);
#endif
/// Post Boolean expression and return its value
GECODE_MINIMODEL_EXPORT BoolVar
expr(Home home, const BoolExpr& e, IntConLevel icl=ICL_DEF);
/// Post Boolean relation
GECODE_MINIMODEL_EXPORT void
rel(Home home, const BoolExpr& e, IntConLevel icl=ICL_DEF);
//@}
}
#include <gecode/minimodel/int-rel.hpp>
#include <gecode/minimodel/float-rel.hpp>
#include <gecode/minimodel/bool-expr.hpp>
#include <gecode/minimodel/set-expr.hpp>
#include <gecode/minimodel/set-rel.hpp>
namespace Gecode {
namespace MiniModel {
class ExpInfo;
}
/**
* \brief Regular expressions over integer values
*
* \ingroup TaskModelMiniModel
*/
class GECODE_MINIMODEL_EXPORT REG {
friend class MiniModel::ExpInfo;
private:
/// Implementation of the actual expression tree
class Exp;
/// The expression tree
Exp* e;
/// Initialize with given expression tree \a
REG(Exp* e);
public:
/// Initialize as empty sequence (epsilon)
REG(void);
/// Initialize as single integer \a s
REG(int s);
/**
* \brief Initialize as alternative of integers
*
* Throws an exception of type MiniModel::TooFewArguments if \a x
* is empty.
*/
REG(const IntArgs& x);
/// Initialize from regular expression \a r
REG(const REG& r);
/// Assign to regular expression \a r
const REG& operator =(const REG& r);
/// Return expression for: this expression followed by \a r
REG operator +(const REG& r);
/// This expression is followed by \a r
REG& operator +=(const REG& r);
/// Return expression for: this expression or \a r
REG operator |(const REG& r);
/// This expression or \a r
REG& operator |=(const REG& r);
/// Return expression for: this expression arbitrarily often (Kleene star)
REG operator *(void);
/// Return expression for: this expression at least once
REG operator +(void);
/// Return expression for: this expression at least \a n and at most \a m times
REG operator ()(unsigned int n, unsigned int m);
/// Return expression for: this expression at least \a n times
REG operator ()(unsigned int n);
/// Print expression
template<class Char, class Traits>
std::basic_ostream<Char,Traits>&
print(std::basic_ostream<Char,Traits>& os) const;
/// Return DFA for regular expression
operator DFA(void);
/// Destructor
~REG(void);
};
/** \relates Gecode::REG
* Print regular expression \a r
*/
template<class Char, class Traits>
std::basic_ostream<Char,Traits>&
operator <<(std::basic_ostream<Char,Traits>& os, const REG& r);
/**
* \defgroup TaskModelMiniModelArith Arithmetic functions
*
* \ingroup TaskModelMiniModel
*/
//@{
/// \brief Return expression for \f$|e|\f$
GECODE_MINIMODEL_EXPORT LinIntExpr
abs(const LinIntExpr& e);
/// \brief Return expression for \f$\min(x,y)\f$
GECODE_MINIMODEL_EXPORT LinIntExpr
min(const LinIntExpr& x, const LinIntExpr& y);
/// \brief Return expression for \f$\min(x)\f$
GECODE_MINIMODEL_EXPORT LinIntExpr
min(const IntVarArgs& x);
/// \brief Return expression for \f$\max(x,y)\f$
GECODE_MINIMODEL_EXPORT LinIntExpr
max(const LinIntExpr& x, const LinIntExpr& y);
/// \brief Return expression for \f$\max(x)\f$
GECODE_MINIMODEL_EXPORT LinIntExpr
max(const IntVarArgs& x);
#ifdef GECODE_HAS_FLOAT_VARS
/// \brief Return expression as product of float variables
GECODE_MINIMODEL_EXPORT LinFloatExpr
operator *(const FloatVar&, const FloatVar&);
/// \brief Return expression as product of float variable and linear float expression
GECODE_MINIMODEL_EXPORT LinFloatExpr
operator *(const FloatVar&, const LinFloatExpr&);
/// \brief Return expression as product of linear float expression and float variable
GECODE_MINIMODEL_EXPORT LinFloatExpr
operator *(const LinFloatExpr&, const FloatVar&);
#endif
/// \brief Return expression for \f$x\cdot y\f$
GECODE_MINIMODEL_EXPORT LinIntExpr
operator *(const LinIntExpr& x, const LinIntExpr& y);
/// \brief Return expression for \f$x\ \mathrm{div}\ y\f$
GECODE_MINIMODEL_EXPORT LinIntExpr
operator /(const LinIntExpr& x, const LinIntExpr& y);
/// \brief Return expression for \f$x\ \mathrm{mod}\ y\f$
GECODE_MINIMODEL_EXPORT LinIntExpr
operator %(const LinIntExpr& x, const LinIntExpr& y);
/// \brief Return expression for \f$x^2\f$
GECODE_MINIMODEL_EXPORT LinIntExpr
sqr(const LinIntExpr& x);
/// \brief Return expression for \f$\lfloor\sqrt{x}\rfloor\f$
GECODE_MINIMODEL_EXPORT LinIntExpr
sqrt(const LinIntExpr& x);
/// \brief Return expression for \f$x^n\f$
GECODE_MINIMODEL_EXPORT LinIntExpr
pow(const LinIntExpr& x, int n);
/// \brief Return expression for \f$\lfloor\sqrt[n]{x}\rfloor\f$
GECODE_MINIMODEL_EXPORT LinIntExpr
nroot(const LinIntExpr& x, int n);
/// \brief Return expression for \f$x[y]\f$
GECODE_MINIMODEL_EXPORT LinIntExpr
element(const IntVarArgs& x, const LinIntExpr& y);
/// \brief Return expression for \f$x[y]\f$
GECODE_MINIMODEL_EXPORT BoolExpr
element(const BoolVarArgs& x, const LinIntExpr& y);
/// \brief Return expression for \f$x[y]\f$
GECODE_MINIMODEL_EXPORT LinIntExpr
element(const IntArgs& x, const LinIntExpr& y);
/// \brief Return expression for if-then-else \f$b?x:y\f$
GECODE_MINIMODEL_EXPORT LinIntExpr
ite(const BoolExpr& b, const LinIntExpr& x, const LinIntExpr& y);
//@}
#ifdef GECODE_HAS_FLOAT_VARS
/// \brief Return expression for \f$|e|\f$
GECODE_MINIMODEL_EXPORT LinFloatExpr
abs(const LinFloatExpr& e);
/// \brief Return expression for \f$\min(x,y)\f$
GECODE_MINIMODEL_EXPORT LinFloatExpr
min(const LinFloatExpr& x, const LinFloatExpr& y);
/// \brief Return expression for \f$\min(x)\f$
GECODE_MINIMODEL_EXPORT LinFloatExpr
min(const FloatVarArgs& x);
/// \brief Return expression for \f$\max(x,y)\f$
GECODE_MINIMODEL_EXPORT LinFloatExpr
max(const LinFloatExpr& x, const LinFloatExpr& y);
/// \brief Return expression for \f$\max(x)\f$
GECODE_MINIMODEL_EXPORT LinFloatExpr
max(const FloatVarArgs& x);
/// \brief Return expression for \f$x\cdot y\f$
GECODE_MINIMODEL_EXPORT LinFloatExpr
operator *(const LinFloatExpr& x, const LinFloatExpr& y);
/// \brief Return expression for \f$x/y\f$
GECODE_MINIMODEL_EXPORT LinFloatExpr
operator /(const LinFloatExpr& x, const LinFloatExpr& y);
/// \brief Return expression for \f$x^2\f$
GECODE_MINIMODEL_EXPORT LinFloatExpr
sqr(const LinFloatExpr& x);
/// \brief Return expression for \f$\sqrt{x}\f$
GECODE_MINIMODEL_EXPORT LinFloatExpr
sqrt(const LinFloatExpr& x);
/// \brief Return expression for \f$x^n\f$
GECODE_MINIMODEL_EXPORT LinFloatExpr
pow(const LinFloatExpr& x, int n);
/// \brief Return expression for \f$x^{1/n}\f$
GECODE_MINIMODEL_EXPORT LinFloatExpr
nroot(const LinFloatExpr& x, int n);
//@}
#ifdef GECODE_HAS_MPFR
/**
* \defgroup TaskModelMiniModelTrans Transcendental functions
*
* \ingroup TaskModelMiniModel
*/
//@{
/// \brief Return expression for \f$ \mathrm{exp}(x)\f$
GECODE_MINIMODEL_EXPORT LinFloatExpr
exp(const LinFloatExpr& x);
/// \brief Return expression for \f$ \mathrm{log}(x)\f$
GECODE_MINIMODEL_EXPORT LinFloatExpr
log(const LinFloatExpr& x);
//@}
/**
* \defgroup TaskModelMiniModelTrigo Trigonometric functions
*
* \ingroup TaskModelMiniModel
*/
//@{
/// \brief Return expression for \f$ \mathrm{asin}(x)\f$
GECODE_MINIMODEL_EXPORT LinFloatExpr
asin(const LinFloatExpr& x);
/// \brief Return expression for \f$ \mathrm{sin}(x)\f$
GECODE_MINIMODEL_EXPORT LinFloatExpr
sin(const LinFloatExpr& x);
/// \brief Return expression for \f$ \mathrm{acos}(x)\f$
GECODE_MINIMODEL_EXPORT LinFloatExpr
acos(const LinFloatExpr& x);
/// \brief Return expression for \f$ \mathrm{cos}(x)\f$
GECODE_MINIMODEL_EXPORT LinFloatExpr
cos(const LinFloatExpr& x);
/// \brief Return expression for \f$ \mathrm{atan}(x)\f$
GECODE_MINIMODEL_EXPORT LinFloatExpr
atan(const LinFloatExpr& x);
/// \brief Return expression for \f$ \mathrm{tan}(x)\f$
GECODE_MINIMODEL_EXPORT LinFloatExpr
tan(const LinFloatExpr& x);
//@}
#endif
#endif
/**
* \defgroup TaskModelMiniModelChannel Channel functions
*
* \ingroup TaskModelMiniModel
*/
//@{
/// Return Boolean variable equal to \f$x\f$
inline BoolVar
channel(Home home, IntVar x,
IntConLevel icl=ICL_DEF) {
(void) icl;
BoolVar b(home,0,1); channel(home,b,x);
return b;
}
/// Return integer variable equal to \f$b\f$
inline IntVar
channel(Home home, BoolVar b,
IntConLevel icl=ICL_DEF) {
(void) icl;
IntVar x(home,0,1); channel(home,b,x);
return x;
}
#ifdef GECODE_HAS_FLOAT_VARS
/// Return integer variable equal to \f$f\f$
inline IntVar
channel(Home home, FloatVar f) {
int min = static_cast<int>(std::max(static_cast<double>(Int::Limits::min),
std::ceil(f.min())));
int max = static_cast<int>(std::min(static_cast<double>(Int::Limits::max),
std::floor(f.max())));
IntVar x(home,min,max);
channel(home,f,x);
return x;
}
#endif
#ifdef GECODE_HAS_SET_VARS
/// Return set variable equal to \f$\{x_0,\dots,x_{n-1}\}\f$
inline SetVar
channel(Home home, const IntVarArgs& x, IntConLevel icl=ICL_DEF) {
(void) icl;
SetVar s(home,IntSet::empty,Set::Limits::min,Set::Limits::max);
rel(home,SOT_UNION,x,s);
nvalues(home,x,IRT_EQ,expr(home,cardinality(s)));
return s;
}
#endif
//@}
}
namespace Gecode {
/**
* \defgroup TaskModelMiniModelIntAlias Aliases for integer constraints
*
* Contains definitions of common constraints which have different
* names in Gecode.
*
* \ingroup TaskModelMiniModel
*/
//@{
/** \brief Post constraint \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=n\}\leq m\f$
*
* Supports domain consistent propagation only.
*/
inline void
atmost(Home home, const IntVarArgs& x, int n, int m,
IntConLevel icl=ICL_DEF) {
count(home,x,n,IRT_LQ,m,icl);
}
/** \brief Post constraint \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=y\}\leq m\f$
*
* Supports domain consistent propagation only.
*/
inline void
atmost(Home home, const IntVarArgs& x, IntVar y, int m,
IntConLevel icl=ICL_DEF) {
count(home,x,y,IRT_LQ,m,icl);
}
/** \brief Post constraint \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=y_i\}\leq m\f$
*
* Supports domain consistent propagation only.
*
* Throws an exception of type Int::ArgumentSizeMismatch, if
* \a x and \a y are of different size.
*/
inline void
atmost(Home home, const IntVarArgs& x, const IntArgs& y, int m,
IntConLevel icl=ICL_DEF) {
count(home,x,y,IRT_LQ,m,icl);
}
/** \brief Post constraint \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=n\}\leq z\f$
*
* Supports domain consistent propagation only.
*/
inline void
atmost(Home home, const IntVarArgs& x, int n, IntVar z,
IntConLevel icl=ICL_DEF) {
count(home,x,n,IRT_LQ,z,icl);
}
/** \brief Post constraint \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=y\}\leq z\f$
*
* Supports domain consistent propagation only.
*/
inline void
atmost(Home home, const IntVarArgs& x, IntVar y, IntVar z,
IntConLevel icl=ICL_DEF) {
count(home,x,y,IRT_LQ,z,icl);
}
/** \brief Post constraint \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=y_i\}\leq z\f$
*
* Supports domain consistent propagation only.
*
* Throws an exception of type Int::ArgumentSizeMismatch, if
* \a x and \a y are of different size.
*/
inline void
atmost(Home home, const IntVarArgs& x, const IntArgs& y, IntVar z,
IntConLevel icl=ICL_DEF) {
count(home,x,y,IRT_LQ,z,icl);
}
/** \brief Post constraint \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=n\}\geq m\f$
*
* Supports domain consistent propagation only.
*/
inline void
atleast(Home home, const IntVarArgs& x, int n, int m,
IntConLevel icl=ICL_DEF) {
count(home,x,n,IRT_GQ,m,icl);
}
/** \brief Post constraint \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=y\}\geq m\f$
*
* Supports domain consistent propagation only.
*/
inline void
atleast(Home home, const IntVarArgs& x, IntVar y, int m,
IntConLevel icl=ICL_DEF) {
count(home,x,y,IRT_GQ,m,icl);
}
/** \brief Post constraint \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=y_i\}\geq m\f$
*
* Supports domain consistent propagation only.
*
* Throws an exception of type Int::ArgumentSizeMismatch, if
* \a x and \a y are of different size.
*/
inline void
atleast(Home home, const IntVarArgs& x, const IntArgs& y, int m,
IntConLevel icl=ICL_DEF) {
count(home,x,y,IRT_GQ,m,icl);
}
/** \brief Post constraint \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=n\}\geq z\f$
*
* Supports domain consistent propagation only.
*/
inline void
atleast(Home home, const IntVarArgs& x, int n, IntVar z,
IntConLevel icl=ICL_DEF) {
count(home,x,n,IRT_GQ,z,icl);
}
/** \brief Post constraint \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=y\}\geq z\f$
*
* Supports domain consistent propagation only.
*/
inline void
atleast(Home home, const IntVarArgs& x, IntVar y, IntVar z,
IntConLevel icl=ICL_DEF) {
count(home,x,y,IRT_GQ,z,icl);
}
/** \brief Post constraint \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=y_i\}\geq z\f$
*
* Supports domain consistent propagation only.
*
* Throws an exception of type Int::ArgumentSizeMismatch, if
* \a x and \a y are of different size.
*/
inline void
atleast(Home home, const IntVarArgs& x, const IntArgs& y, IntVar z,
IntConLevel icl=ICL_DEF) {
count(home,x,y,IRT_GQ,z,icl);
}
/** \brief Post constraint \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=n\}=m\f$
*
* Supports domain consistent propagation only.
*/
inline void
exactly(Home home, const IntVarArgs& x, int n, int m,
IntConLevel icl=ICL_DEF) {
count(home,x,n,IRT_EQ,m,icl);
}
/** \brief Post constraint \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=y\}=m\f$
*
* Supports domain consistent propagation only.
*/
inline void
exactly(Home home, const IntVarArgs& x, IntVar y, int m,
IntConLevel icl=ICL_DEF) {
count(home,x,y,IRT_EQ,m,icl);
}
/** \brief Post constraint \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=y_i\}=m\f$
*
* Supports domain consistent propagation only.
*
* Throws an exception of type Int::ArgumentSizeMismatch, if
* \a x and \a y are of different size.
*/
inline void
exactly(Home home, const IntVarArgs& x, const IntArgs& y, int m,
IntConLevel icl=ICL_DEF) {
count(home,x,y,IRT_EQ,m,icl);
}
/** \brief Post constraint \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=n\}=z\f$
*
* Supports domain consistent propagation only.
*/
inline void
exactly(Home home, const IntVarArgs& x, int n, IntVar z,
IntConLevel icl=ICL_DEF) {
count(home,x,n,IRT_EQ,z,icl);
}
/** \brief Post constraint \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=y\}=z\f$
*
* Supports domain consistent propagation only.
*/
inline void
exactly(Home home, const IntVarArgs& x, IntVar y, IntVar z,
IntConLevel icl=ICL_DEF) {
count(home,x,y,IRT_EQ,z,icl);
}
/** \brief Post constraint \f$\#\{i\in\{0,\ldots,|x|-1\}\;|\;x_i=y_i\}=z\f$
*
* Supports domain consistent propagation only.
*
* Throws an exception of type Int::ArgumentSizeMismatch, if
* \a x and \a y are of different size.
*/
inline void
exactly(Home home, const IntVarArgs& x, const IntArgs& y, IntVar z,
IntConLevel icl=ICL_DEF) {
count(home,x,y,IRT_EQ,z,icl);
}
/** \brief Post lexical order between \a x and \a y.
*/
inline void
lex(Home home, const IntVarArgs& x, IntRelType r, const IntVarArgs& y,
IntConLevel icl=ICL_DEF) {
rel(home,x,r,y,icl);
}
/** \brief Post lexical order between \a x and \a y.
*/
inline void
lex(Home home, const BoolVarArgs& x, IntRelType r, const BoolVarArgs& y,
IntConLevel icl=ICL_DEF) {
rel(home,x,r,y,icl);
}
/** \brief Post constraint \f$\{x_0,\dots,x_{n-1}\}=y\f$
*/
inline void
values(Home home, const IntVarArgs& x, IntSet y,
IntConLevel icl=ICL_DEF) {
dom(home,x,y,icl);
nvalues(home,x,IRT_EQ,static_cast<int>(y.size()),icl);
}
//@}
#ifdef GECODE_HAS_SET_VARS
/**
* \defgroup TaskModelMiniModelSetAlias Aliases for set constraints
*
* Contains definitions of common constraints which have different
* names in Gecode.
*
* \ingroup TaskModelMiniModel
*/
//@{
/** \brief Post constraint \f$\{x_0,\dots,x_{n-1}\}=y\f$
*
* In addition to constraining \a y to the union of the \a x, this
* also posts an nvalue constraint for additional cardinality propagation.
*/
inline void
channel(Home home, const IntVarArgs& x, SetVar y) {
rel(home,SOT_UNION,x,y);
nvalues(home,x,IRT_EQ,expr(home,cardinality(y)));
}
/** \brief Post constraint \f$\bigcup_{i\in y}\{x_i\}=z\f$
*/
inline void
range(Home home, const IntVarArgs& x, SetVar y, SetVar z) {
element(home,SOT_UNION,x,y,z);
}
/** \brief Post constraint \f$\bigcup_{i\in z}\{j\ |\ x_j=i\}=z\f$
*
* Note that this creates one temporary set variable for each element
* in the upper bound of \a z, so make sure that the bound is tight.
*/
inline void
roots(Home home, const IntVarArgs& x, SetVar y, SetVar z) {
SetVarArgs xiv(home,z.lubMax()+1,IntSet::empty,0,x.size()-1);
channel(home,x,xiv);
element(home,SOT_UNION,xiv,z,y);
}
//@}
#endif
}
namespace Gecode {
template<class> class Matrix;
/** \brief A slice of a matrix.
*
* This class represents a slice of the matrix. It is used to get
* context-dependent behaviour. The slice will be automatically
* converted to an ArgsType Args-array or to a Matrix<ArgsType>
* depending on the context where it is used.
*/
template<class A>
class Slice {
public:
/// The type of the Args-array type for ValueType values
typedef typename ArrayTraits<A>::ArgsType ArgsType;
private:
ArgsType _r; ///< The elements of the slice
unsigned int _fc, ///< From column
_tc, ///< To column
_fr, ///< From row
_tr; ///< To row
public:
/// Construct slice
Slice(const Matrix<A>& a, int fc, int tc, int fr, int tr);
/** \brief Reverses the contents of the slice, and returns a
* reference to it.
*/
Slice& reverse(void);
/// Cast to array type
operator ArgsType(void);
/// Cast to matrix type
operator Matrix<ArgsType>(void);
/// Cast to array type
operator const ArgsType(void) const;
/// Cast to matrix type
operator const Matrix<ArgsType>(void) const;
};
/// Concatenate \a x and \a y
template<class A>
typename Slice<A>::ArgsType
operator+(const Slice<A>& x, const Slice<A>& y);
/// Concatenate \a x and \a y
template<class A>
typename Slice<A>::ArgsType
operator+(const Slice<A>& x, const typename ArrayTraits<A>::ArgsType& y);
/// Concatenate \a x and \a y
template<class A>
typename Slice<A>::ArgsType
operator+(const typename ArrayTraits<A>::ArgsType& x, const Slice<A>& y);
/// Concatenate \a x and \a y
template<class A>
typename Slice<A>::ArgsType
operator+(const Slice<A>& x, const typename ArrayTraits<A>::ValueType& y);
/// Concatenate \a x and \a y
template<class A>
typename Slice<A>::ArgsType
operator+(const typename ArrayTraits<A>::ValueType& x, const Slice<A>& y);
/** \brief Matrix-interface for arrays
*
* This class allows for wrapping some array and accessing it as a
* matrix.
*
* \note This is a light-weight wrapper, and is not intended for
* storing variables directly instead of in an array.
*
* \ingroup TaskModelMiniModel
*/
template<class A>
class Matrix {
public:
/// The type of elements of this array
typedef typename ArrayTraits<A>::ValueType ValueType;
/// The type of the Args-array type for ValueType values
typedef typename ArrayTraits<A>::ArgsType ArgsType;
private:
/// The type of storage for this array
typedef typename ArrayTraits<A>::StorageType StorageType;
StorageType _a; ///< The array wrapped
int _w; ///< The width of the matrix
int _h; ///< The height of the matrix
public:
/** \brief Basic constructor
*
* Constructs a Matrix from the array \a a, using \a w and \a h as
* the width and height of the matrix.
*
* The elements in the wrapped array \a a are accessed in
* row-major order.
*
* \exception MiniModel::ArgumentSizeMismatch Raised if the
* parameters \a w and \a h doesn't match the size
* of the array \a a.
*/
Matrix(A a, int w, int h);
/** \brief Basic constructor
*
* Constructs a square Matrix from the array \a a, using \a n as
* the length of the sides.
*
* The elements in the wrapped array \a a are accessed in
* row-major order.
*
* \exception MiniModel::ArgumentSizeMismatch Raised if the
* parameter \a n doesn't match the size
* of the array \a a.
*/
Matrix(A a, int n);
/// Return the width of the matrix
int width(void) const;
/// Return the height of the matrix
int height(void) const;
/// Return an Args-array of the contents of the matrix
ArgsType const get_array(void) const;
/** \brief Access element (\a c, \a r) of the matrix
*
* \exception MiniModel::ArgumentOutOfRange Raised if \a c or \a r
* are out of range.
*/
ValueType& operator ()(int c, int r);
/** \brief Access element (\a c, \a r) of the matrix
*
* \exception MiniModel::ArgumentOutOfRange Raised if \a c or \a r
* are out of range.
*/
const ValueType& operator ()(int c, int r) const;
/** \brief Access slice of the matrix
*
* This function allows accessing a slice of the matrix, located at
* columns \f$[fc,tc)\f$ and rows \f$[fr,tr)\f$. The result of this
* function is an object that can be converted into either a
* Matrix<ArgsType> or into ArgsType.
*
* For further information, see Slice.
*/
Slice<A> slice(int fc, int tc, int fr, int tr) const;
/// Access row \a r.
Slice<A> row(int r) const;
/// Access column \a c.
Slice<A> col(int c) const;
};
/** \relates Gecode::Matrix
* Print matrix \a m
*/
template<class Char, class Traits, class A>
std::basic_ostream<Char,Traits>&
operator <<(std::basic_ostream<Char,Traits>& os, const Matrix<A>& m);
/** \relates Gecode::Matrix
* Print slice \a s
*/
template<class Char, class Traits, class A>
std::basic_ostream<Char,Traits>&
operator <<(std::basic_ostream<Char,Traits>& os, const Slice<A>& s);
/** \brief Element constraint for matrix
*
* Here, \a x and \a y are the coordinates and \a z is the value
* at position \a m(x,y).
* \relates Gecode::Matrix
*/
void element(Home home, const Matrix<IntArgs>& m, IntVar x, IntVar y,
IntVar z, IntConLevel icl=ICL_DEF);
/** \brief Element constraint for matrix
*
* Here, \a x and \a y are the coordinates and \a z is the value
* at position \a m(x,y).
* \relates Gecode::Matrix
*/
void element(Home home, const Matrix<IntArgs>& m, IntVar x, IntVar y,
BoolVar z, IntConLevel icl=ICL_DEF);
/** \brief Element constraint for matrix
*
* Here, \a x and \a y are the coordinates and \a z is the value
* at position \a m(x,y).
* \relates Gecode::Matrix
*/
void element(Home home, const Matrix<IntVarArgs>& m, IntVar x, IntVar y,
IntVar z, IntConLevel icl=ICL_DEF);
/** \brief Element constraint for matrix
*
* Here, \a x and \a y are the coordinates and \a z is the value
* at position \a m(x,y).
* \relates Gecode::Matrix
*/
void element(Home home, const Matrix<BoolVarArgs>& m, IntVar x, IntVar y,
BoolVar z, IntConLevel icl=ICL_DEF);
#ifdef GECODE_HAS_SET_VARS
/** \brief Element constraint for matrix
*
* Here, \a x and \a y are the coordinates and \a z is the value
* at position \a m(x,y).
* \relates Gecode::Matrix
*/
void element(Home home, const Matrix<IntSetArgs>& m, IntVar x, IntVar y,
SetVar z);
/** \brief Element constraint for matrix
*
* Here, \a x and \a y are the coordinates and \a z is the value
* at position \a m(x,y).
* \relates Gecode::Matrix
*/
void element(Home home, const Matrix<SetVarArgs>& m, IntVar x, IntVar y,
SetVar z);
#endif
/** \brief Interchangeable rows symmetry specification.
* \relates Gecode::Matrix
*/
template<class A>
SymmetryHandle rows_interchange(const Matrix<A>& m);
/** \brief Interchangeable columns symmetry specification.
* \relates Gecode::Matrix
*/
template<class A>
SymmetryHandle columns_interchange(const Matrix<A>& m);
/** \brief Reflect rows symmetry specification.
* \relates Gecode::Matrix
*/
template<class A>
SymmetryHandle rows_reflect(const Matrix<A>& m);
/** \brief Reflect columns symmetry specification.
* \relates Gecode::Matrix
*/
template<class A>
SymmetryHandle columns_reflect(const Matrix<A>& m);
/** \brief Reflect around main diagonal symmetry specification.
*
* The matrix \m must be square.
* \relates Gecode::Matrix
*/
template<class A>
SymmetryHandle diagonal_reflect(const Matrix<A>& m);
}
#include <gecode/minimodel/matrix.hpp>
#include <gecode/minimodel/ldsb.hpp>
/**
* \addtogroup TaskModelMiniModelLin
* @{
*/
namespace Gecode {
/// Construct linear expression as sum of \ref IntArgs \ref Slice elements
GECODE_MINIMODEL_EXPORT LinIntExpr
sum(const Slice<IntArgs>& slice);
/// Construct linear expression as sum of \ref IntArgs \ref Matrix elements
GECODE_MINIMODEL_EXPORT LinIntExpr
sum(const Matrix<IntArgs>& matrix);
}
/** @}*/
namespace Gecode {
/**
* \defgroup TaskModelMiniModelOptimize Support for cost-based optimization
*
* Provides for minimizing or maximizing the cost value as defined by
* a cost-member function of a space.
*
* \ingroup TaskModelMiniModel
*/
/**
* \brief Class for minimizing integer cost
* \ingroup TaskModelMiniModelOptimize
*/
class GECODE_VTABLE_EXPORT IntMinimizeSpace : public Space {
public:
/// Default constructor
IntMinimizeSpace(void);
/// Constructor for cloning
IntMinimizeSpace(bool share, IntMinimizeSpace& s);
/// Member function constraining according to decreasing cost
GECODE_MINIMODEL_EXPORT
virtual void constrain(const Space& best);
/// Return variable with current cost
virtual IntVar cost(void) const = 0;
};
/**
* \brief Class for maximizing integer cost
* \ingroup TaskModelMiniModelOptimize
*/
class GECODE_VTABLE_EXPORT IntMaximizeSpace : public Space {
public:
/// Default constructor
IntMaximizeSpace(void);
/// Constructor for cloning
IntMaximizeSpace(bool share, IntMaximizeSpace& s);
/// Member function constraining according to increasing cost
GECODE_MINIMODEL_EXPORT
virtual void constrain(const Space& best);
/// Return variable with current cost
virtual IntVar cost(void) const = 0;
};
/**
* \brief Class for minimizing integer cost
* \deprecated Use IntMinimizeSpace instead.
*/
typedef IntMinimizeSpace MinimizeSpace;
/**
* \brief Class for maximizing integer cost
* \deprecated Use IntMaximizeSpace instead.
*/
typedef IntMaximizeSpace MaximizeSpace;
#ifdef GECODE_HAS_FLOAT_VARS
/**
* \brief Class for minimizing float cost
*
* The class supports using a step value \a step that will make sure
* that better solutions must be better by at least the value of
* \a step.
*
* \ingroup TaskModelMiniModelOptimize
*/
class GECODE_VTABLE_EXPORT FloatMinimizeSpace : public Space {
protected:
/// Step by which a next solution has to have lower cost
FloatNum step;
public:
/// Constructor with step \a s
FloatMinimizeSpace(FloatNum s=0.0);
/// Constructor for cloning
FloatMinimizeSpace(bool share, FloatMinimizeSpace& s);
/// Member function constraining according to cost
GECODE_MINIMODEL_EXPORT
virtual void constrain(const Space& best);
/// Return variable with current cost
virtual FloatVar cost(void) const = 0;
};
/**
* \brief Class for maximizing float cost
*
* The class supports using a step value \a step that will make sure
* that better solutions must be better by at least the value of
* \a step.
*
* \ingroup TaskModelMiniModelOptimize
*/
class GECODE_VTABLE_EXPORT FloatMaximizeSpace : public Space {
protected:
/// Step by which a next solution has to have lower cost
FloatNum step;
public:
/// Constructor with step \a s
FloatMaximizeSpace(FloatNum s=0.0);
/// Constructor for cloning
FloatMaximizeSpace(bool share, FloatMaximizeSpace& s);
/// Member function constraining according to cost
GECODE_MINIMODEL_EXPORT
virtual void constrain(const Space& best);
/// Return variable with current cost
virtual FloatVar cost(void) const = 0;
};
#endif
}
#include <gecode/minimodel/optimize.hpp>
#endif
// IFDEF: GECODE_HAS_INT_VARS
// STATISTICS: minimodel-any
|