/usr/include/gecode/float.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 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 | /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main authors:
* Christian Schulte <schulte@gecode.org>
* Guido Tack <tack@gecode.org>
* Vincent Barichard <Vincent.Barichard@univ-angers.fr>
*
* Copyright:
* Christian Schulte, 2002
* Guido Tack, 2004
* Vincent Barichard, 2012
*
* Last modified:
* $Date: 2013-07-23 14:31:03 +0200 (Tue, 23 Jul 2013) $ by $Author: schulte $
* $Revision: 13939 $
*
* 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_FLOAT_HH__
#define __GECODE_FLOAT_HH__
#include <climits>
#include <cfloat>
#include <iostream>
#include <gecode/kernel.hh>
#include <gecode/int.hh>
/*
* Configure linking
*
*/
#if !defined(GECODE_STATIC_LIBS) && \
(defined(__CYGWIN__) || defined(__MINGW32__) || defined(_MSC_VER))
#ifdef GECODE_BUILD_FLOAT
#define GECODE_FLOAT_EXPORT __declspec( dllexport )
#else
#define GECODE_FLOAT_EXPORT __declspec( dllimport )
#endif
#else
#ifdef GECODE_GCC_HAS_CLASS_VISIBILITY
#define GECODE_FLOAT_EXPORT __attribute__ ((visibility("default")))
#else
#define GECODE_FLOAT_EXPORT
#endif
#endif
// Configure auto-linking
#ifndef GECODE_BUILD_FLOAT
#define GECODE_LIBRARY_NAME "Float"
#include <gecode/support/auto-link.hpp>
#endif
// Include interval implementation
#include <gecode/third-party/boost/numeric/interval.hpp>
/**
* \namespace Gecode::Float
* \brief Floating point numbers
*
* The Gecode::Float namespace contains all functionality required
* to program propagators and branchers for floating point numbers.
* In addition, all propagators and branchers for floating point
* numbers provided by %Gecode are contained as nested namespaces.
*
*/
#include <gecode/float/exception.hpp>
#include <gecode/float/nextafter.hpp>
namespace Gecode {
/**
* \brief Floating point number base type
*
* This type defines the interval bounds used for representing floating
* point values.
* \ingroup TaskModelFloatVars
*/
typedef double FloatNum;
/// Return lower bound of \f$\pi/2\f$
FloatNum pi_half_lower(void);
/// Return upper bound of \f$\pi/2\f$
FloatNum pi_half_upper(void);
/// Return lower bound of \f$\pi\f$
FloatNum pi_lower(void);
/// Return upper bound of \f$\pi\f$
FloatNum pi_upper(void);
/// Return lower bound of \f$2\pi\f$
FloatNum pi_twice_lower(void);
/// Return upper bound of \f$2\pi\f$
FloatNum pi_twice_upper(void);
// Forward declaration
class FloatVal;
}
#include <gecode/float/num.hpp>
namespace Gecode { namespace Float {
/**
* \brief Floating point rounding policy
*
* \ingroup TaskModelFloatVars
*/
class Rounding :
public boost::numeric::interval_lib::rounded_arith_opp<FloatNum> {
protected:
/// Base class
typedef boost::numeric::interval_lib::rounded_arith_opp<FloatNum> Base;
public:
/// \name Constructor and destructor
//@{
/// Default constructor (configures full rounding mode)
Rounding(void);
/// Destructor (restores previous rounding mode)
~Rounding(void);
//@}
/// \name Arithmetic operations
//@{
/// Return lower bound of \a x plus \a y (domain: \f$ [-\infty;+\infty][-\infty;+\infty]\f$)
FloatNum add_down(FloatNum x, FloatNum y);
/// Return upper bound of \a x plus \a y (domain: \f$ [-\infty;+\infty] [-\infty;+\infty]\f$)
FloatNum add_up (FloatNum x, FloatNum y);
/// Return lower bound of \a x minus \a y (domain: \f$ [-\infty;+\infty] [-\infty;+\infty]\f$)
FloatNum sub_down(FloatNum x, FloatNum y);
/// Return upper bound of \a x minus \a y (domain: \f$ [-\infty;+\infty] [-\infty;+\infty]\f$)
FloatNum sub_up (FloatNum x, FloatNum y);
/// Return lower bound of \a x times \a y (domain: \f$ [-\infty;+\infty] [-\infty;+\infty]\f$)
FloatNum mul_down(FloatNum x, FloatNum y);
/// Return upper bound of \a x times \a y (domain: \f$ [-\infty;+\infty] [-\infty;+\infty]\f$)
FloatNum mul_up (FloatNum x, FloatNum y);
/// Return lower bound of \a x divided by \a y (domain: \f$ [-\infty;+\infty] ([-\infty;+\infty]-{0}) \f$)
FloatNum div_down(FloatNum x, FloatNum y);
/// Return upper bound of \a x divided \a y (domain: \f$ [-\infty;+\infty] ([-\infty;+\infty]-{0})\f$)
FloatNum div_up (FloatNum x, FloatNum y);
/// Return lower bound of square root of \a x (domain: \f$ ]0;+\infty] \f$)
FloatNum sqrt_down(FloatNum x);
/// Return upper bound of square root of \a x (domain: \f$ ]0;+\infty]\f$)
FloatNum sqrt_up (FloatNum x);
//@}
/// \name Miscellaneous operations
//@{
/// Return median of \a x and \a y (domain: \f$ [-\infty;+\infty][-\infty;+\infty]\f$)
FloatNum median(FloatNum x, FloatNum y);
/// Return next downward-rounded integer of \a x (domain: \f$ [-\infty;+\infty]\f$)
FloatNum int_down(FloatNum x);
/// Return next upward-rounded integer of \a x (domain: \f$ [-\infty;+\infty] \f$)
FloatNum int_up (FloatNum x);
//@}
#ifdef GECODE_HAS_MPFR
/// \name Exponential functions
//@{
/// Return lower bound of exponential of \a x (domain: \f$ [-\infty;+\infty]\f$)
GECODE_FLOAT_EXPORT FloatNum exp_down(FloatNum x);
/// Return upper bound of exponential of \a x (domain: \f$ [-\infty;+\infty]\f$)
GECODE_FLOAT_EXPORT FloatNum exp_up (FloatNum x);
/// Return lower bound of logarithm of \a x (domain: \f$ ]0;+\infty]\f$)
GECODE_FLOAT_EXPORT FloatNum log_down(FloatNum x);
/// Return upper bound of logarithm of \a x (domain: \f$ ]0;+\infty]\f$)
GECODE_FLOAT_EXPORT FloatNum log_up (FloatNum x);
//@}
/// \name Trigonometric functions
//@{
/// Return lower bound of sine of \a x (domain: \f$ [0;2\pi]\f$)
GECODE_FLOAT_EXPORT FloatNum sin_down(FloatNum x);
/// Return upper bound of sine of \a x (domain: \f$ [0;2\pi]\f$)
GECODE_FLOAT_EXPORT FloatNum sin_up (FloatNum x);
/// Return lower bound of cosine of \a x (domain: \f$ [0;2\pi]\f$)
GECODE_FLOAT_EXPORT FloatNum cos_down(FloatNum x);
/// Return upper bound of cosine of \a x (domain: \f$ [0;2\pi]\f$)
GECODE_FLOAT_EXPORT FloatNum cos_up (FloatNum x);
/// Return lower bound of tangent of \a x (domain: \f$ ]-\pi/2;\pi/2[\f$)
GECODE_FLOAT_EXPORT FloatNum tan_down(FloatNum x);
/// Return upper bound of tangent of \a x (domain: \f$ ]-\pi/2;\pi/2[\f$)
GECODE_FLOAT_EXPORT FloatNum tan_up (FloatNum x);
//@}
/// \name Inverse trigonometric functions
//@{
/// Return lower bound of arcsine of \a x (domain: \f$ [-1;1]\f$)
GECODE_FLOAT_EXPORT FloatNum asin_down(FloatNum x);
/// Return upper bound of arcsine of \a x (domain: \f$ [-1;1]\f$)
GECODE_FLOAT_EXPORT FloatNum asin_up (FloatNum x);
/// Return lower bound of arccosine of \a x (domain: \f$ [-1;1]\f$)
GECODE_FLOAT_EXPORT FloatNum acos_down(FloatNum x);
/// Return upper bound of arccossine of \a x (domain: \f$ [-1;1]\f$)
GECODE_FLOAT_EXPORT FloatNum acos_up (FloatNum x);
/// Return lower bound of arctangent of \a x (domain: \f$ [-\infty;+\infty]\f$)
GECODE_FLOAT_EXPORT FloatNum atan_down(FloatNum x);
/// Return upper bound of arctangent of \a x (domain: \f$ [-\infty;+\infty]\f$)
GECODE_FLOAT_EXPORT FloatNum atan_up (FloatNum x);
//@}
/// \name Hyperbolic functions
//@{
/// Return lower bound of hyperbolic sine of \a x (domain: \f$ [-\infty;+\infty]\f$)
GECODE_FLOAT_EXPORT FloatNum sinh_down(FloatNum x);
/// Return upper bound of hyperbolic sine of \a x (domain: \f$ [-\infty;+\infty]\f$)
GECODE_FLOAT_EXPORT FloatNum sinh_up (FloatNum x);
/// Return lower bound of hyperbolic cosine of \a x (domain: \f$ [-\infty;+\infty]\f$)
GECODE_FLOAT_EXPORT FloatNum cosh_down(FloatNum x);
/// Return upper bound of hyperbolic cosine of \a x (domain: \f$ [-\infty;+\infty]\f$)
GECODE_FLOAT_EXPORT FloatNum cosh_up (FloatNum x);
/// Return lower bound of hyperbolic tangent of \a x (domain: \f$ [-\infty;+\infty]\f$)
GECODE_FLOAT_EXPORT FloatNum tanh_down(FloatNum x);
/// Return upper bound of hyperbolic tangent of \a x (domain: \f$ [-\infty;+\infty]\f$)
GECODE_FLOAT_EXPORT FloatNum tanh_up (FloatNum x);
//@}
/// \name Inverse hyperbolic functions
//@{
/// Return lower bound of hyperbolic arcsine of \a x (domain: \f$ [-\infty;+\infty]\f$)
GECODE_FLOAT_EXPORT FloatNum asinh_down(FloatNum x);
/// Return upper bound of hyperbolic arcsine of \a x (domain: \f$ [-\infty;+\infty]\f$)
GECODE_FLOAT_EXPORT FloatNum asinh_up (FloatNum x);
/// Return lower bound of hyperbolic arccosine of \a x (domain: \f$ [1;+\infty]\f$)
GECODE_FLOAT_EXPORT FloatNum acosh_down(FloatNum x);
/// Return upper bound of hyperbolic arccosine of \a x (domain: \f$ [1;+\infty]\f$)
GECODE_FLOAT_EXPORT FloatNum acosh_up (FloatNum x);
/// Return lower bound of hyperbolic arctangent of \a x (domain: \f$ [-1;1]\f$)
GECODE_FLOAT_EXPORT FloatNum atanh_down(FloatNum x);
/// Return upper bound of hyperbolic arctangent of \a x (domain: \f$ [-1;1]\f$)
GECODE_FLOAT_EXPORT FloatNum atanh_up (FloatNum x);
//@}
#endif
};
}}
#include <gecode/float/rounding.hpp>
namespace Gecode { namespace Float {
/**
* \brief Test whether \a x is a subset of \a y
* \relates Gecode::FloatVal
*/
bool subset(const FloatVal& x, const FloatVal& y);
/**
* \brief Test whether \a x is a proper subset of \a y
* \relates Gecode::FloatVal
*/
bool proper_subset(const FloatVal& x, const FloatVal& y);
/**
* \brief Test whether \a x and \a y overlap
* \relates Gecode::FloatVal
*/
bool overlap(const FloatVal& x, const FloatVal& y);
/**
* \brief Return intersection of \a x and \a y
* \relates Gecode::FloatVal
*/
FloatVal intersect(const FloatVal& x, const FloatVal& y);
/**
* \brief Return hull of \a x and \a y
* \relates Gecode::FloatVal
*/
FloatVal hull(const FloatVal& x, const FloatVal& y);
/**
* \brief Return hull of \a x and \a y
* \relates Gecode::FloatVal
*/
FloatVal hull(const FloatVal& x, const FloatNum& y);
/**
* \brief Return hull of \a x and \a y
* \relates Gecode::FloatVal
*/
FloatVal hull(const FloatNum& x, const FloatVal& y);
/**
* \brief Return hull of \a x and \a y
* \relates Gecode::FloatVal
*/
FloatVal hull(const FloatNum& x, const FloatNum& y);
}}
namespace Gecode {
/**
* \brief Float value type
*
* \ingroup TaskModelFloatVars
*/
class FloatVal {
friend FloatVal operator +(const FloatVal& x);
friend FloatVal operator -(const FloatVal& x);
friend FloatVal operator +(const FloatVal& x, const FloatVal& y);
friend FloatVal operator +(const FloatVal& x, const FloatNum& y);
friend FloatVal operator +(const FloatNum& x, const FloatVal& y);
friend FloatVal operator -(const FloatVal& x, const FloatVal& y);
friend FloatVal operator -(const FloatVal& x, const FloatNum& y);
friend FloatVal operator -(const FloatNum& x, const FloatVal& y);
friend FloatVal operator *(const FloatVal& x, const FloatVal& y);
friend FloatVal operator *(const FloatVal& x, const FloatNum& y);
friend FloatVal operator *(const FloatNum& x, const FloatVal& y);
friend FloatVal operator /(const FloatVal& x, const FloatVal& y);
friend FloatVal operator /(const FloatVal& x, const FloatNum& y);
friend FloatVal operator /(const FloatNum& x, const FloatVal& y);
friend bool operator <(const FloatVal& x, const FloatVal& y);
friend bool operator <(const FloatVal& x, const FloatNum& y);
friend bool operator <(const FloatNum& x, const FloatVal& y);
friend bool operator <=(const FloatVal& x, const FloatVal& y);
friend bool operator <=(const FloatVal& x, const FloatNum& y);
friend bool operator <=(const FloatNum& x, const FloatVal& y);
friend bool operator >(const FloatVal& x, const FloatVal& y);
friend bool operator >(const FloatVal& x, const FloatNum& y);
friend bool operator >(const FloatNum& x, const FloatVal& y);
friend bool operator >=(const FloatVal& x, const FloatVal& y);
friend bool operator >=(const FloatVal& x, const FloatNum& y);
friend bool operator >=(const FloatNum& x, const FloatVal& y);
friend bool operator ==(const FloatVal& x, const FloatVal& y);
friend bool operator ==(const FloatVal& x, const FloatNum& y);
friend bool operator ==(const FloatNum& x, const FloatVal& y);
friend bool operator !=(const FloatVal& x, const FloatVal& y);
friend bool operator !=(const FloatVal& x, const FloatNum& y);
friend bool operator !=(const FloatNum& x, const FloatVal& y);
template<class Char, class Traits>
friend std::basic_ostream<Char,Traits>&
operator <<(std::basic_ostream<Char,Traits>& os, const FloatVal& x);
friend FloatVal abs(const FloatVal& x);
friend FloatVal sqrt(const FloatVal& x);
friend FloatVal sqr(const FloatVal& x);
friend FloatVal pow(const FloatVal& x, int n);
friend FloatVal nroot(const FloatVal& x, int n);
friend FloatVal max(const FloatVal& x, const FloatVal& y);
friend FloatVal max(const FloatVal& x, const FloatNum& y);
friend FloatVal max(const FloatNum& x, const FloatVal& y);
friend FloatVal min(const FloatVal& x, const FloatVal& y);
friend FloatVal min(const FloatVal& x, const FloatNum& y);
friend FloatVal min(const FloatNum& x, const FloatVal& y);
#ifdef GECODE_HAS_MPFR
friend FloatVal exp(const FloatVal& x);
friend FloatVal log(const FloatVal& x);
friend FloatVal fmod(const FloatVal& x, const FloatVal& y);
friend FloatVal fmod(const FloatVal& x, const FloatNum& y);
friend FloatVal fmod(const FloatNum& x, const FloatVal& y);
friend FloatVal sin(const FloatVal& x);
friend FloatVal cos(const FloatVal& x);
friend FloatVal tan(const FloatVal& x);
friend FloatVal asin(const FloatVal& x);
friend FloatVal acos(const FloatVal& x);
friend FloatVal atan(const FloatVal& x);
friend FloatVal sinh(const FloatVal& x);
friend FloatVal cosh(const FloatVal& x);
friend FloatVal tanh(const FloatVal& x);
friend FloatVal asinh(const FloatVal& x);
friend FloatVal acosh(const FloatVal& x);
friend FloatVal atanh(const FloatVal& x);
#endif
friend bool Float::subset(const FloatVal& x, const FloatVal& y);
friend bool Float::proper_subset(const FloatVal& x, const FloatVal& y);
friend bool Float::overlap(const FloatVal& x, const FloatVal& y);
friend FloatVal Float::intersect(const FloatVal& x, const FloatVal& y);
friend FloatVal Float::hull(const FloatVal& x, const FloatVal& y);
friend FloatVal Float::hull(const FloatVal& x, const FloatNum& y);
friend FloatVal Float::hull(const FloatNum& x, const FloatVal& y);
friend FloatVal Float::hull(const FloatNum& x, const FloatNum& y);
protected:
/// Used rounding policies
typedef boost::numeric::interval_lib::save_state<Float::Rounding> R;
/// Used checking policy
typedef boost::numeric::interval_lib::checking_strict<FloatNum> P;
/// Implementation type for float value
typedef boost::numeric::interval
<FloatNum,
boost::numeric::interval_lib::policies<R, P> >
FloatValImpType;
/// Implementation of float value
FloatValImpType x;
/// Initialize from implementation \a i
explicit FloatVal(const FloatValImpType& i);
public:
/// \name Constructors and initialization
//@{
/// Default constructor
FloatVal(void);
/// Initialize with float number \a n
FloatVal(const FloatNum& n);
/// Initialize with lower bound \a l and upper bound \a u
FloatVal(const FloatNum& l, const FloatNum& u);
/// Copy constructor
FloatVal(const FloatVal& v);
/// Assignment operator
FloatVal& operator =(const FloatNum& n);
/// Assignment operator
FloatVal& operator =(const FloatVal& v);
/// Assign lower bound \a l and upper bound \a u
void assign(FloatNum const &l, FloatNum const &u);
//@}
/// \name Value access
//@{
/// Return lower bound
FloatNum min(void) const;
/// Return upper bound
FloatNum max(void) const;
/// Return size of float value (distance between maximum and minimum)
FloatNum size(void) const;
/// Return median of float value
FloatNum med(void) const;
//@}
/// \name Value tests
//@{
/// Test whether float is tight
bool tight(void) const;
/// Test whether float is a singleton
bool singleton(void) const;
/// Test whether \a n is included
bool in(FloatNum n) const;
/// Test whether zero is included
bool zero_in(void) const;
//@}
/// \name Float value construction
//@{
/// Return hull of \a x and \a y
static FloatVal hull(FloatNum x, FloatNum y);
/// Return \f$\pi/2\f$
static FloatVal pi_half(void);
/// Return lower bound of \f$\pi\f$
static FloatVal pi(void);
/// Return \f$2\pi\f$
static FloatVal pi_twice(void);
//@}
/// \name Update operators
//@{
/// Increment by \a n
FloatVal& operator +=(const FloatNum& n);
/// Subtract by \a n
FloatVal& operator -=(const FloatNum& n);
/// Multiply by \a n
FloatVal& operator *=(const FloatNum& n);
/// Divide by \a n
FloatVal& operator /=(const FloatNum& n);
/// Increment by \a v
FloatVal& operator +=(const FloatVal& v);
/// Subtract by \a v
FloatVal& operator -=(const FloatVal& v);
/// Multiply by \a v
FloatVal& operator *=(const FloatVal& v);
/// Divide by \a v
FloatVal& operator /=(const FloatVal& v);
//@}
};
/**
* \brief Arithmetic operator
* \relates Gecode::FloatVal
*/
FloatVal operator +(const FloatVal& x);
/**
* \brief Arithmetic operator
* \relates Gecode::FloatVal
*/
FloatVal operator -(const FloatVal& x);
/**
* \brief Arithmetic operator
* \relates Gecode::FloatVal
*/
FloatVal operator +(const FloatVal& x, const FloatVal& y);
/**
* \brief Arithmetic operator
* \relates Gecode::FloatVal
*/
FloatVal operator +(const FloatVal& x, const FloatNum& y);
/**
* \brief Arithmetic operator
* \relates Gecode::FloatVal
*/
FloatVal operator +(const FloatNum& x, const FloatVal& y);
/**
* \brief Arithmetic operator
* \relates Gecode::FloatVal
*/
FloatVal operator -(const FloatVal& x, const FloatVal& y);
/**
* \brief Arithmetic operator
* \relates Gecode::FloatVal
*/
FloatVal operator -(const FloatVal& x, const FloatNum& y);
/**
* \brief Arithmetic operator
* \relates Gecode::FloatVal
*/
FloatVal operator -(const FloatNum& x, const FloatVal& y);
/**
* \brief Arithmetic operator
* \relates Gecode::FloatVal
*/
FloatVal operator *(const FloatVal& x, const FloatVal& y);
/**
* \brief Arithmetic operator
* \relates Gecode::FloatVal
*/
FloatVal operator *(const FloatVal& x, const FloatNum& y);
/**
* \brief Arithmetic operator
* \relates Gecode::FloatVal
*/
FloatVal operator *(const FloatNum& x, const FloatVal& y);
/**
* \brief Arithmetic operator
* \relates Gecode::FloatVal
*/
FloatVal operator /(const FloatVal& x, const FloatVal& y);
/**
* \brief Arithmetic operator
* \relates Gecode::FloatVal
*/
FloatVal operator /(const FloatVal& x, const FloatNum& y);
/**
* \brief Arithmetic operator
* \relates Gecode::FloatVal
*/
FloatVal operator /(const FloatNum& r, const FloatVal& x);
/**
* \brief Comparison operator
* \relates Gecode::FloatVal
*/
bool operator <(const FloatVal& x, const FloatVal& y);
/**
* \brief Comparison operator
* \relates Gecode::FloatVal
*/
bool operator <(const FloatVal& x, const FloatNum& y);
/**
* \brief Comparison operator
* \relates Gecode::FloatVal
*/
bool operator <(const FloatNum& x, const FloatVal& y);
/**
* \brief Comparison operator
* \relates Gecode::FloatVal
*/
bool operator <=(const FloatVal& x, const FloatVal& y);
/**
* \brief Comparison operator
* \relates Gecode::FloatVal
*/
bool operator <=(const FloatVal& x, const FloatNum& y);
/**
* \brief Comparison operator
* \relates Gecode::FloatVal
*/
bool operator <=(const FloatNum& x, const FloatVal& y);
/**
* \brief Comparison operator
* \relates Gecode::FloatVal
*/
bool operator >(const FloatVal& x, const FloatVal& y);
/**
* \brief Comparison operator
* \relates Gecode::FloatVal
*/
bool operator >(const FloatVal& x, const FloatNum& y);
/**
* \brief Comparison operator
* \relates Gecode::FloatVal
*/
bool operator >(const FloatNum& x, const FloatVal& y);
/**
* \brief Comparison operator
* \relates Gecode::FloatVal
*/
bool operator >=(const FloatVal& x, const FloatVal& y);
/**
* \brief Comparison operator
* \relates Gecode::FloatVal
*/
bool operator >=(const FloatVal& x, const FloatNum& y);
/**
* \brief Comparison operator
* \relates Gecode::FloatVal
*/
bool operator >=(const FloatNum& x, const FloatVal& y);
/**
* \brief Comparison operator
* \relates Gecode::FloatVal
*/
bool operator ==(const FloatVal& x, const FloatVal& y);
/**
* \brief Comparison operator
* \relates Gecode::FloatVal
*/
bool operator ==(const FloatVal& x, const FloatNum& y);
/**
* \brief Comparison operator
* \relates Gecode::FloatVal
*/
bool operator ==(const FloatNum& x, const FloatVal& y);
/**
* \brief Comparison operator
* \relates Gecode::FloatVal
*/
bool operator !=(const FloatVal& x, const FloatVal& y);
/**
* \brief Comparison operator
* \relates Gecode::FloatVal
*/
bool operator !=(const FloatVal& x, const FloatNum& y);
/**
* \brief Comparison operator
* \relates Gecode::FloatVal
*/
bool operator !=(const FloatNum& x, const FloatVal& y);
/**
* \brief Print float value \a x
* \relates Gecode::FloatVal
*/
template<class Char, class Traits>
std::basic_ostream<Char,Traits>&
operator <<(std::basic_ostream<Char,Traits>& os, const FloatVal& x);
/**
* \brief Return absolute value of \a x
* \relates Gecode::FloatVal
*/
FloatVal abs(const FloatVal& x);
/**
* \brief Return square root of \a x
* \relates Gecode::FloatVal
*/
FloatVal sqrt(const FloatVal& x);
/**
* \brief Return square of \a x
* \relates Gecode::FloatVal
*/
FloatVal sqr(const FloatVal& x);
/**
* \brief Return \a n -th power of \a x
* \relates Gecode::FloatVal
*/
FloatVal pow(const FloatVal& x, int n);
/**
* \brief Return \a n -th root of \a x
* \relates Gecode::FloatVal
*/
FloatVal nroot(const FloatVal& x, int n);
/**
* \brief Return maximum of \a x and \a y
* \relates Gecode::FloatVal
*/
FloatVal max(const FloatVal& x, const FloatVal& y);
/**
* \brief Return maximum of \a x and \a y
* \relates Gecode::FloatVal
*/
FloatVal max(const FloatVal& x, const FloatNum& y);
/**
* \brief Return maximum of \a x and \a y
* \relates Gecode::FloatVal
*/
FloatVal max(const FloatNum& x, const FloatVal& y);
/**
* \brief Return minimum of \a x and \a y
* \relates Gecode::FloatVal
*/
FloatVal min(const FloatVal& x, const FloatVal& y);
/**
* \brief Return minimum of \a x and \a y
* \relates Gecode::FloatVal
*/
FloatVal min(const FloatVal& x, const FloatNum& y);
/**
* \brief Return minimum of \a x and \a y
* \relates Gecode::FloatVal
*/
FloatVal min(const FloatNum& x, const FloatVal& y);
#ifdef GECODE_HAS_MPFR
/* transcendental functions: exp, log */
/**
* \brief Return exponential of \a x
* \relates Gecode::FloatVal
*/
FloatVal exp(const FloatVal& x);
/**
* \brief Return logarithm of \a x
* \relates Gecode::FloatVal
*/
FloatVal log(const FloatVal& x);
/**
* \brief Trigonometric function argument reduction
* \relates Gecode::FloatVal
*/
FloatVal fmod(const FloatVal& x, const FloatVal& y);
/**
* \brief Trigonometric function argument reduction
* \relates Gecode::FloatVal
*/
FloatVal fmod(const FloatVal& x, const FloatNum& y);
/**
* \brief Trigonometric function argument reduction
* \relates Gecode::FloatVal
*/
FloatVal fmod(const FloatNum& x, const FloatVal& y);
/**
* \brief Return sine of \a x
* \relates Gecode::FloatVal
*/
FloatVal sin(const FloatVal& x);
/**
* \brief Return cosine of \a x
* \relates Gecode::FloatVal
*/
FloatVal cos(const FloatVal& x);
/**
* \brief Return tangent of \a x
* \relates Gecode::FloatVal
*/
FloatVal tan(const FloatVal& x);
/**
* \brief Return arcsine of \a x
* \relates Gecode::FloatVal
*/
FloatVal asin(const FloatVal& x);
/**
* \brief Return arccosine of \a x
* \relates Gecode::FloatVal
*/
FloatVal acos(const FloatVal& x);
/**
* \brief Return arctangent of \a x
* \relates Gecode::FloatVal
*/
FloatVal atan(const FloatVal& x);
/**
* \brief Return hyperbolic of \a x
* \relates Gecode::FloatVal
*/
FloatVal sinh(const FloatVal& x);
/**
* \brief Return hyperbolic of \a x
* \relates Gecode::FloatVal
*/
FloatVal cosh(const FloatVal& x);
/**
* \brief Return hyperbolic of \a x
* \relates Gecode::FloatVal
*/
FloatVal tanh(const FloatVal& x);
/**
* \brief Return hyperbolic of \a x
* \relates Gecode::FloatVal
*/
FloatVal asinh(const FloatVal& x);
/**
* \brief Return hyperbolic of \a x
* \relates Gecode::FloatVal
*/
FloatVal acosh(const FloatVal& x);
/**
* \brief Return hyperbolic of \a x
* \relates Gecode::FloatVal
*/
FloatVal atanh(const FloatVal& x);
#endif
}
#include <gecode/float/val.hpp>
namespace Gecode { namespace Float {
/**
* \brief Numerical limits for floating point variables
*
* \ingroup TaskModelFloatVars
*/
namespace Limits {
/// Largest allowed float value
const FloatNum max = std::numeric_limits<FloatNum>::max();
/// Smallest allowed float value
const FloatNum min = -max;
/// Return whether float \a n is a valid number
bool valid(const FloatVal& n);
/// Check whether float \a n is a valid number, otherwise throw out of limits exception with information \a l
void check(const FloatVal& n, const char* l);
}
}}
#include <gecode/float/limits.hpp>
#include <gecode/float/var-imp.hpp>
namespace Gecode {
namespace Float {
class FloatView;
}
/**
* \brief Float variables
*
* \ingroup TaskModelFloatVars
*/
class FloatVar : public VarImpVar<Float::FloatVarImp> {
friend class FloatVarArray;
friend class FloatVarArgs;
private:
using VarImpVar<Float::FloatVarImp>::x;
/**
* \brief Initialize variable with range domain
*
* The variable is created with a domain ranging from \a min
* to \a max. No exceptions are thrown.
*/
void _init(Space& home, FloatNum min, FloatNum max);
public:
/// \name Constructors and initialization
//@{
/// Default constructor
FloatVar(void);
/// Initialize from float variable \a y
FloatVar(const FloatVar& y);
/// Initialize from float view \a y
FloatVar(const Float::FloatView& y);
/**
* \brief Initialize variable with range domain
*
* The variable is created with a domain ranging from \a min
* to \a max. The following exceptions might be thrown:
* - If \a min is greater than \a max, an exception of type
* Gecode::Float::VariableEmptyDomain is thrown.
* - If \a min or \a max exceed the limits for floats as defined
* in Gecode::Float::Limits, an exception of type
* Gecode::Float::OutOfLimits is thrown.
*/
GECODE_FLOAT_EXPORT FloatVar(Space& home, FloatNum min, FloatNum max);
//@}
/// \name Value access
//@{
/// Return domain
FloatVal domain(void) const;
/// Return minimum of domain
FloatNum min(void) const;
/// Return maximum of domain
FloatNum max(void) const;
/// Return median of domain
FloatNum med(void) const;
/// Return size of domain (distance between maximum and minimum)
FloatNum size(void) const;
/**
* \brief Return assigned value
*
* Throws an exception of type Float::ValOfUnassignedVar if variable
* is not yet assigned.
*
*/
FloatVal val(void) const;
//@}
/// \name Domain tests
//@{
/// Test whether \a n is contained in domain
bool in(const FloatVal& n) const;
//@}
};
/**
* \brief Print float variable \a x
* \relates Gecode::FloatVar
*/
template<class Char, class Traits>
std::basic_ostream<Char,Traits>&
operator <<(std::basic_ostream<Char,Traits>& os, const FloatVar& x);
}
#include <gecode/float/view.hpp>
#include <gecode/float/array-traits.hpp>
namespace Gecode {
/// Passing float arguments
class FloatValArgs : public PrimArgArray<FloatVal> {
public:
/// \name Constructors and initialization
//@{
/// Allocate empty array
FloatValArgs(void);
/// Allocate array with \a n elements
explicit FloatValArgs(int n);
/// Allocate array and copy elements from \a x
FloatValArgs(const SharedArray<FloatVal>& x);
/// Allocate array and copy elements from \a x
FloatValArgs(const std::vector<FloatVal>& x);
/// Allocate array and copy elements from \a first to \a last
template<class InputIterator>
FloatValArgs(InputIterator first, InputIterator last);
/// Allocate array with \a n elements and initialize with \a e0, ...
GECODE_FLOAT_EXPORT
FloatValArgs(int n, int e0, ...);
/// Allocate array with \a n elements and initialize with elements from array \a e
FloatValArgs(int n, const FloatVal* e);
/// Initialize from primitive argument array \a a (copy elements)
FloatValArgs(const PrimArgArray<FloatVal>& a);
/// Allocate array with \a n elements such that for all \f$0\leq i<n: x_i=\text{start}+i\cdot\text{inc}\f$
static FloatValArgs create(int n, FloatVal start, int inc=1);
//@}
};
/// \brief Passing float variables
class FloatVarArgs : public VarArgArray<FloatVar> {
public:
/// \name Constructors and initialization
//@{
/// Allocate empty array
FloatVarArgs(void) {}
/// Allocate array with \a n elements
explicit FloatVarArgs(int n) : VarArgArray<FloatVar>(n) {}
/// Initialize from variable argument array \a a (copy elements)
FloatVarArgs(const FloatVarArgs& a) : VarArgArray<FloatVar>(a) {}
/// Initialize from variable array \a a (copy elements)
FloatVarArgs(const VarArray<FloatVar>& a) : VarArgArray<FloatVar>(a) {}
/// Initialize from vector \a a
FloatVarArgs(const std::vector<FloatVar>& a) : VarArgArray<FloatVar>(a) {}
/// Initialize from InputIterator \a first and \a last
template<class InputIterator>
FloatVarArgs(InputIterator first, InputIterator last)
: VarArgArray<FloatVar>(first,last) {}
/**
* \brief Initialize array with \a n new variables
*
* The variables are created with a domain ranging from \a min
* to \a max. The following execptions might be thrown:
* - If \a min is greater than \a max, an exception of type
* Gecode::Float::VariableEmptyDomain is thrown.
* - If \a min or \a max exceed the limits for floats as defined
* in Gecode::Float::Limits, an exception of type
* Gecode::Float::OutOfLimits is thrown.
*/
GECODE_FLOAT_EXPORT
FloatVarArgs(Space& home, int n, FloatNum min, FloatNum max);
//@}
};
//@}
/**
* \defgroup TaskModelFloatVarArrays Variable arrays
*
* Variable arrays can store variables. They are typically used
* for storing the variables being part of a solution (script). However,
* they can also be used for temporary purposes (even though
* memory is not reclaimed until the space it is created for
* is deleted).
* \ingroup TaskModelFloat
*/
/**
* \brief Float variable array
* \ingroup TaskModelFloatVarArrays
*/
class FloatVarArray : public VarArray<FloatVar> {
public:
/// \name Creation and initialization
//@{
/// Default constructor (array of size 0)
FloatVarArray(void);
/// Allocate array for \a n float variables (variables are uninitialized)
FloatVarArray(Space& home, int n);
/// Initialize from float variable array \a a (share elements)
FloatVarArray(const FloatVarArray& a);
/// Initialize from float variable argument array \a a (copy elements)
FloatVarArray(Space& home, const FloatVarArgs& a);
/**
* \brief Initialize array with \a n new variables
*
* The variables are created with a domain ranging from \a min
* to \a max. The following execptions might be thrown:
* - If \a min is greater than \a max, an exception of type
* Gecode::Float::VariableEmptyDomain is thrown.
* - If \a min or \a max exceed the limits for floats as defined
* in Gecode::Float::Limits, an exception of type
* Gecode::Float::OutOfLimits is thrown.
*/
GECODE_FLOAT_EXPORT
FloatVarArray(Space& home, int n, FloatNum min, FloatNum max);
//@}
};
}
#include <gecode/float/array.hpp>
namespace Gecode {
/**
* \brief Relation types for floats
* \ingroup TaskModelFloat
*/
enum FloatRelType {
FRT_EQ, ///< Equality (\f$=\f$)
FRT_NQ, ///< Disequality (\f$\neq\f$)
FRT_LQ, ///< Less or equal (\f$\leq\f$)
FRT_LE, ///< Less (\f$<\f$)
FRT_GQ, ///< Greater or equal (\f$\geq\f$)
FRT_GR ///< Greater (\f$>\f$)
};
/**
* \defgroup TaskModelFloatDomain Domain constraints
* \ingroup TaskModelFloat
*
*/
//@{
/// Propagates \f$x=n\f$
GECODE_FLOAT_EXPORT void
dom(Home home, FloatVar x, FloatVal n);
/// Propagates \f$ x_i=n\f$ for all \f$0\leq i<|x|\f$
GECODE_FLOAT_EXPORT void
dom(Home home, const FloatVarArgs& x, FloatVal n);
/// Propagates \f$ l\leq x\leq u\f$
GECODE_FLOAT_EXPORT void
dom(Home home, FloatVar x, FloatNum l, FloatNum m);
/// Propagates \f$ l\leq x_i\leq u\f$ for all \f$0\leq i<|x|\f$
GECODE_FLOAT_EXPORT void
dom(Home home, const FloatVarArgs& x, FloatNum l, FloatNum u);
/// Post domain consistent propagator for \f$ (x=n) \equiv r\f$
GECODE_FLOAT_EXPORT void
dom(Home home, FloatVar x, FloatVal n, Reify r);
/// Post domain consistent propagator for \f$ (l\leq x \leq u) \equiv r\f$
GECODE_FLOAT_EXPORT void
dom(Home home, FloatVar x, FloatNum l, FloatNum u, Reify r);
/// Constrain domain of \a x according to domain of \a d
GECODE_FLOAT_EXPORT void
dom(Home home, FloatVar x, FloatVar d);
/// Constrain domain of \f$ x_i \f$ according to domain of \f$ d_i \f$ for all \f$0\leq i<|x|\f$
GECODE_FLOAT_EXPORT void
dom(Home home, const FloatVarArgs& x, const FloatVarArgs& d);
//@}
/**
* \defgroup TaskModelFloatRelFloat Simple relation constraints over float variables
* \ingroup TaskModelFloat
*/
/** \brief Post propagator for \f$ x_0 \sim_{frt} x_1\f$
*
* \ingroup TaskModelFloatRelFloat
*/
GECODE_FLOAT_EXPORT void
rel(Home home, FloatVar x0, FloatRelType frt, FloatVar x1);
/** \brief Propagates \f$ x \sim_{frt} c\f$
* \ingroup TaskModelFloatRelFloat
*/
GECODE_FLOAT_EXPORT void
rel(Home home, FloatVar x, FloatRelType frt, FloatVal c);
/** \brief Post propagator for \f$(x \sim_{frt} c)\equiv r\f$
* \ingroup TaskModelFloatRelFloat
*/
GECODE_FLOAT_EXPORT void
rel(Home home, FloatVar x, FloatRelType frt, FloatVal c, Reify r);
/** \brief Post propagator for \f$(x_0 \sim_{frt} x_1)\equiv r\f$
* \ingroup TaskModelFloatRelFloat
*/
GECODE_FLOAT_EXPORT void
rel(Home home, FloatVar x0, FloatRelType frt, FloatVar x1, Reify r);
/** \brief Propagates \f$ x_i \sim_{frt} c \f$ for all \f$0\leq i<|x|\f$
* \ingroup TaskModelFloatRelFloat
*/
GECODE_FLOAT_EXPORT void
rel(Home home, const FloatVarArgs& x, FloatRelType frt, FloatVal c);
/** \brief Propagates \f$ x_i \sim_{frt} y \f$ for all \f$0\leq i<|x|\f$
* \ingroup TaskModelFloatRelFloat
*/
GECODE_FLOAT_EXPORT void
rel(Home home, const FloatVarArgs& x, FloatRelType frt, FloatVar y);
}
namespace Gecode {
/**
* \defgroup TaskModelFloatArith Arithmetic constraints
* \ingroup TaskModelFloat
*/
//@{
/** \brief Post propagator for \f$ \min\{x_0,x_1\}=x_2\f$
*/
GECODE_FLOAT_EXPORT void
min(Home home, FloatVar x0, FloatVar x1, FloatVar x2);
/** \brief Post propagator for \f$ \min x=y\f$
* If \a x is empty, an exception of type Float::TooFewArguments is thrown.
*/
GECODE_FLOAT_EXPORT void
min(Home home, const FloatVarArgs& x, FloatVar y);
/** \brief Post propagator for \f$ \max\{x_0,x_1\}=x_2\f$
*/
GECODE_FLOAT_EXPORT void
max(Home home, FloatVar x0, FloatVar x1, FloatVar x2);
/** \brief Post propagator for \f$ \max x=y\f$
* If \a x is empty, an exception of type Float::TooFewArguments is thrown.
*/
GECODE_FLOAT_EXPORT void
max(Home home, const FloatVarArgs& x, FloatVar y);
/** \brief Post propagator for \f$ |x_0|=x_1\f$
*/
GECODE_FLOAT_EXPORT void
abs(Home home, FloatVar x0, FloatVar x1);
/** \brief Post propagator for \f$x_0\cdot x_1=x_2\f$
*/
GECODE_FLOAT_EXPORT void
mult(Home home, FloatVar x0, FloatVar x1, FloatVar x2);
/** \brief Post propagator for \f$x_0\cdot x_0=x_1\f$
*/
GECODE_FLOAT_EXPORT void
sqr(Home home, FloatVar x0, FloatVar x1);
/** \brief Post propagator for \f$\sqrt{x_0}=x_1\f$
*/
GECODE_FLOAT_EXPORT void
sqrt(Home home, FloatVar x0, FloatVar x1);
/** \brief Post propagator for \f${x_0}^{n}=x_1\f$ for $n\geq 0$
*/
GECODE_FLOAT_EXPORT void
pow(Home home, FloatVar x0, int n, FloatVar x1);
/** \brief Post propagator for \f${x_0}^{1/n}=x_1\f$ for $n\geq 0$
*/
GECODE_FLOAT_EXPORT void
nroot(Home home, FloatVar x0, int n, FloatVar x1);
/** \brief Post propagator for \f$x_0\ \mathrm{div}\ x_1=x_2\f$
*/
GECODE_FLOAT_EXPORT void
div(Home home, FloatVar x0, FloatVar x1, FloatVar x2);
#ifdef GECODE_HAS_MPFR
/** \brief Post propagator for \f$ \mathrm{exp}(x_0)=x_1\f$
*/
GECODE_FLOAT_EXPORT void
exp(Home home, FloatVar x0, FloatVar x1);
/** \brief Post propagator for \f$ \mathrm{log}_e(x_0)=x_1\f$
*/
GECODE_FLOAT_EXPORT void
log(Home home, FloatVar x0, FloatVar x1);
/** \brief Post propagator for \f$ \mathit{base}^{x_0}=x_1\f$
*/
GECODE_FLOAT_EXPORT void
pow(Home home, FloatNum base, FloatVar x0, FloatVar x1);
/** \brief Post propagator for \f$ \mathrm{log}_{\mathit{base}}(x_0)=x_1\f$
*/
GECODE_FLOAT_EXPORT void
log(Home home, FloatNum base, FloatVar x0, FloatVar x1);
/** \brief Post propagator for \f$ \mathrm{asin}(x_0)=x_1\f$
*/
GECODE_FLOAT_EXPORT void
asin(Home home, FloatVar x0, FloatVar x1);
/** \brief Post propagator for \f$ \mathrm{sin}(x_0)=x_1\f$
*/
GECODE_FLOAT_EXPORT void
sin(Home home, FloatVar x0, FloatVar x1);
/** \brief Post propagator for \f$ \mathrm{acos}(x_0)=x_1\f$
*/
GECODE_FLOAT_EXPORT void
acos(Home home, FloatVar x0, FloatVar x1);
/** \brief Post propagator for \f$ \mathrm{cos}(x_0)=x_1\f$
*/
GECODE_FLOAT_EXPORT void
cos(Home home, FloatVar x0, FloatVar x1);
/** \brief Post propagator for \f$ \mathrm{atan}(x_0)=x_1\f$
*/
GECODE_FLOAT_EXPORT void
atan(Home home, FloatVar x0, FloatVar x1);
/** \brief Post propagator for \f$ \mathrm{tan}(x_0)=x_1\f$
*/
GECODE_FLOAT_EXPORT void
tan(Home home, FloatVar x0, FloatVar x1);
//@}
#endif
/**
* \defgroup TaskModelFloatLI Linear constraints over float variables
* \ingroup TaskModelFloat
*/
/** \brief Post propagator for \f$\sum_{i=0}^{|x|-1}x_i\sim_{frt} c\f$
* \ingroup TaskModelFloatLI
*/
GECODE_FLOAT_EXPORT void
linear(Home home, const FloatVarArgs& x,
FloatRelType frt, FloatNum c);
/** \brief Post propagator for \f$\sum_{i=0}^{|x|-1}x_i\sim_{frt} y\f$
* \ingroup TaskModelFloatLI
*/
GECODE_FLOAT_EXPORT void
linear(Home home, const FloatVarArgs& x,
FloatRelType frt, FloatVar y);
/** \brief Post propagator for \f$\left(\sum_{i=0}^{|x|-1}x_i\sim_{frt} c\right)\equiv r\f$
* \ingroup TaskModelFloatLI
*/
GECODE_FLOAT_EXPORT void
linear(Home home, const FloatVarArgs& x,
FloatRelType frt, FloatNum c, Reify r);
/** \brief Post propagator for \f$\left(\sum_{i=0}^{|x|-1}x_i\sim_{frt} y\right)\equiv r\f$
* \ingroup TaskModelFloatLI
*/
GECODE_FLOAT_EXPORT void
linear(Home home, const FloatVarArgs& x,
FloatRelType frt, FloatVar y, Reify r);
/** \brief Post propagator for \f$\sum_{i=0}^{|x|-1}a_i\cdot x_i\sim_{frt} c\f$
*
* Throws an exception of type Float::ArgumentSizeMismatch, if
* \a a and \a x are of different size.
* \ingroup TaskModelFloatLI
*/
GECODE_FLOAT_EXPORT void
linear(Home home, const FloatValArgs& a, const FloatVarArgs& x,
FloatRelType frt, FloatNum c);
/** \brief Post propagator for \f$\sum_{i=0}^{|x|-1}a_i\cdot x_i\sim_{frt} y\f$
*
* Throws an exception of type Float::ArgumentSizeMismatch, if
* \a a and \a x are of different size.
* \ingroup TaskModelFloatLI
*/
GECODE_FLOAT_EXPORT void
linear(Home home, const FloatValArgs& a, const FloatVarArgs& x,
FloatRelType frt, FloatVar y);
/** \brief Post propagator for \f$\left(\sum_{i=0}^{|x|-1}a_i\cdot x_i\sim_{frt} c\right)\equiv r\f$
*
* Throws an exception of type Float::ArgumentSizeMismatch, if
* \a a and \a x are of different size.
* \ingroup TaskModelFloatLI
*/
GECODE_FLOAT_EXPORT void
linear(Home home, const FloatValArgs& a, const FloatVarArgs& x,
FloatRelType frt, FloatNum c, Reify r);
/** \brief Post propagator for \f$\left(\sum_{i=0}^{|x|-1}a_i\cdot x_i\sim_{frt} y\right)\equiv r\f$
*
* Throws an exception of type Float::ArgumentSizeMismatch, if
* \a a and \a x are of different size.
* \ingroup TaskModelFloatLI
*/
GECODE_FLOAT_EXPORT void
linear(Home home, const FloatValArgs& a, const FloatVarArgs& x,
FloatRelType frt, FloatVar y, Reify r);
/**
* \defgroup TaskModelFloatChannel Channel constraints
* \ingroup TaskModelFloat
*/
//@{
/// Post propagator for channeling a float and an integer variable \f$ x_0 = x_1\f$
GECODE_FLOAT_EXPORT void
channel(Home home, FloatVar x0, IntVar x1);
/// Post propagator for channeling a float and an integer variable \f$ x_0 = x_1\f$
GECODE_FLOAT_EXPORT void
channel(Home home, IntVar x0, FloatVar x1);
//@}
/**
* \defgroup TaskModelFloatExec Synchronized execution
* \ingroup TaskModelFloat
*
* Synchronized execution executes a function or a static member function
* when a certain event happends.
*/
//@{
/// Execute \a c when \a x becomes assigned
GECODE_FLOAT_EXPORT void
wait(Home home, FloatVar x, void (*c)(Space& home));
/// Execute \a c when all variables in \a x become assigned
GECODE_FLOAT_EXPORT void
wait(Home home, const FloatVarArgs& x, void (*c)(Space& home));
//@}
}
namespace Gecode {
/**
* \defgroup TaskModelFloatBranch Branching on float variables
* \ingroup TaskModelFloat
*/
/**
* \brief Branch filter function type for float variables
*
* The variable \a x is considered for selection and \a i refers to the
* variable's position in the original array passed to the brancher.
*
* \ingroup TaskModelFloatBranch
*/
typedef bool (*FloatBranchFilter)(const Space& home, FloatVar x, int i);
/**
* \brief Branch merit function type for float variables
*
* The function must return a merit value for the variable
* \a x.
* The value \a i refers to the variable's position in the original array
* passed to the brancher.
*
* \ingroup TaskModelFloatBranch
*/
typedef double (*FloatBranchMerit)(const Space& home, FloatVar x, int i);
/**
* \brief Value description class for branching
*
* \ingroup TaskModelFloatBranch
*/
class FloatNumBranch {
public:
/// The middle value for branching
FloatNum n;
/// Whether to try the lower or upper half first
bool l;
};
/**
* \brief Branch value function type for float variables
*
* Returns a value for the variable \a x that is to be used in the
* corresponding branch commit function. The integer \a i refers
* to the variable's position in the original array passed to the
* brancher.
*
* \ingroup TaskModelFloatBranch
*/
typedef FloatNumBranch (*FloatBranchVal)(const Space& home, FloatVar x, int i);
/**
* \brief Branch commit function type for float variables
*
* The function must post a constraint on the variable \a x which
* corresponds to the alternative \a a. The integer \a i refers
* to the variable's position in the original array passed to the
* brancher. The value \a nl is the value description
* computed by the corresponding branch value function.
*
* \ingroup TaskModelFloatBranch
*/
typedef void (*FloatBranchCommit)(Space& home, unsigned int a,
FloatVar x, int i, FloatNumBranch nl);
}
#include <gecode/float/branch/traits.hpp>
namespace Gecode {
/**
* \brief Recording AFC information for float variables
*
* \ingroup TaskModelFloatBranch
*/
class FloatAFC : public AFC {
public:
/**
* \brief Construct as not yet initialized
*
* The only member functions that can be used on a constructed but not
* yet initialized AFC storage is init or the assignment operator.
*
*/
FloatAFC(void);
/// Copy constructor
FloatAFC(const FloatAFC& a);
/// Assignment operator
FloatAFC& operator =(const FloatAFC& a);
/// Initialize for float variables \a x with decay factor \a d
FloatAFC(Home home, const FloatVarArgs& x, double d=1.0);
/**
* \brief Initialize for float variables \a x with decay factor \a d
*
* This member function can only be used once and only if the
* AFC storage has been constructed with the default constructor.
*
*/
void init(Home, const FloatVarArgs& x, double d=1.0);
};
}
#include <gecode/float/branch/afc.hpp>
namespace Gecode {
/**
* \brief Recording activities for float variables
*
* \ingroup TaskModelFloatBranch
*/
class FloatActivity : public Activity {
public:
/**
* \brief Construct as not yet initialized
*
* The only member functions that can be used on a constructed but not
* yet initialized activity storage is init or the assignment operator.
*
*/
FloatActivity(void);
/// Copy constructor
FloatActivity(const FloatActivity& a);
/// Assignment operator
FloatActivity& operator =(const FloatActivity& a);
/**
* \brief Initialize for float variables \a x with decay factor \a d
*
* If the branch merit function \a bm is different from NULL, the
* activity for each variable is initialized with the merit returned
* by \a bm.
*
*/
GECODE_FLOAT_EXPORT
FloatActivity(Home home, const FloatVarArgs& x, double d=1.0,
FloatBranchMerit bm=NULL);
/**
* \brief Initialize for float variables \a x with decay factor \a d
*
* If the branch merit function \a bm is different from NULL, the
* activity for each variable is initialized with the merit returned
* by \a bm.
*
* This member function can only be used once and only if the
* activity storage has been constructed with the default constructor.
*
*/
GECODE_FLOAT_EXPORT void
init(Home, const FloatVarArgs& x, double d=1.0,
FloatBranchMerit bm=NULL);
};
}
#include <gecode/float/branch/activity.hpp>
namespace Gecode {
/// Function type for explaining branching alternatives for set variables
typedef void (*FloatVarValPrint)(const Space &home, const BrancherHandle& bh,
unsigned int a,
FloatVar x, int i, const FloatNumBranch& n,
std::ostream& o);
}
namespace Gecode {
/**
* \brief Which variable to select for branching
*
* \ingroup TaskModelFloatBranch
*/
class FloatVarBranch : public VarBranch {
public:
/// Which variable selection
enum Select {
SEL_NONE = 0, ///< First unassigned
SEL_RND, ///< Random (uniform, for tie breaking)
SEL_MERIT_MIN, ///< With least merit
SEL_MERIT_MAX, ///< With highest merit
SEL_DEGREE_MIN, ///< With smallest degree
SEL_DEGREE_MAX, ///< With largest degree
SEL_AFC_MIN, ///< With smallest accumulated failure count
SEL_AFC_MAX, ///< With largest accumulated failure count
SEL_ACTIVITY_MIN, ///< With lowest activity
SEL_ACTIVITY_MAX, ///< With highest activity
SEL_MIN_MIN, ///< With smallest min
SEL_MIN_MAX, ///< With largest min
SEL_MAX_MIN, ///< With smallest max
SEL_MAX_MAX, ///< With largest max
SEL_SIZE_MIN, ///< With smallest domain size
SEL_SIZE_MAX, ///< With largest domain size
SEL_DEGREE_SIZE_MIN, ///< With smallest degree divided by domain size
SEL_DEGREE_SIZE_MAX, ///< With largest degree divided by domain size
SEL_AFC_SIZE_MIN, ///< With smallest accumulated failure count divided by domain size
SEL_AFC_SIZE_MAX, ///< With largest accumulated failure count divided by domain size
SEL_ACTIVITY_SIZE_MIN, ///< With smallest activity divided by domain size
SEL_ACTIVITY_SIZE_MAX ///< With largest activity divided by domain size
};
protected:
/// Which variable to select
Select s;
public:
/// Initialize with strategy SEL_NONE
FloatVarBranch(void);
/// Initialize with random number generator \a r
FloatVarBranch(Rnd r);
/// Initialize with selection strategy \a s and tie-break limit function \a t
FloatVarBranch(Select s, BranchTbl t);
/// Initialize with selection strategy \a s, decay factor \a d, and tie-break limit function \a t
FloatVarBranch(Select s, double, BranchTbl t);
/// Initialize with selection strategy \a s, AFC \a a, and tie-break limit function \a t
FloatVarBranch(Select s, AFC a, BranchTbl t);
/// Initialize with selection strategy \a s, activity \a a, and tie-break limit function \a t
FloatVarBranch(Select s, Activity a, BranchTbl t);
/// Initialize with selection strategy \a s, branch merit function \a mf, and tie-break limit function \a t
FloatVarBranch(Select s, VoidFunction mf, BranchTbl t);
/// Return selection strategy
Select select(void) const;
/// Expand decay factor into AFC or activity
void expand(Home home, const FloatVarArgs& x);
};
/**
* \defgroup TaskModelFloatBranchVar Variable selection for float variables
* \ingroup TaskModelFloatBranch
*/
//@{
/// Select first unassigned variable
FloatVarBranch FLOAT_VAR_NONE(void);
/// Select random variable (uniform distribution, for tie breaking)
FloatVarBranch FLOAT_VAR_RND(Rnd r);
/// Select variable with least merit according to branch merit function \a bm
FloatVarBranch FLOAT_VAR_MERIT_MIN(FloatBranchMerit bm, BranchTbl tbl=NULL);
/// Select variable with highest merit according to branch merit function \a bm
FloatVarBranch FLOAT_VAR_MERIT_MAX(FloatBranchMerit bm, BranchTbl tbl=NULL);
/// Select variable with smallest degree
FloatVarBranch FLOAT_VAR_DEGREE_MIN(BranchTbl tbl=NULL);
/// Select variable with largest degree
FloatVarBranch FLOAT_VAR_DEGREE_MAX(BranchTbl tbl=NULL);
/// Select variable with smallest accumulated failure count with decay factor \a d
FloatVarBranch FLOAT_VAR_AFC_MIN(double d=1.0, BranchTbl tbl=NULL);
/// Select variable with smallest accumulated failure count
FloatVarBranch FLOAT_VAR_AFC_MIN(FloatAFC a, BranchTbl tbl=NULL);
/// Select variable with largest accumulated failure count with decay factor \a d
FloatVarBranch FLOAT_VAR_AFC_MAX(double d=1.0, BranchTbl tbl=NULL);
/// Select variable with largest accumulated failure count
FloatVarBranch FLOAT_VAR_AFC_MAX(FloatAFC a, BranchTbl tbl=NULL);
/// Select variable with lowest activity with decay factor \a d
FloatVarBranch FLOAT_VAR_ACTIVITY_MIN(double d=1.0, BranchTbl tbl=NULL);
/// Select variable with lowest activity
FloatVarBranch FLOAT_VAR_ACTIVITY_MIN(FloatActivity a, BranchTbl tbl=NULL);
/// Select variable with highest activity with decay factor \a d
FloatVarBranch FLOAT_VAR_ACTIVITY_MAX(double d=1.0, BranchTbl tbl=NULL);
/// Select variable with highest activity
FloatVarBranch FLOAT_VAR_ACTIVITY_MAX(FloatActivity a, BranchTbl tbl=NULL);
/// Select variable with smallest min
FloatVarBranch FLOAT_VAR_MIN_MIN(BranchTbl tbl=NULL);
/// Select variable with largest min
FloatVarBranch FLOAT_VAR_MIN_MAX(BranchTbl tbl=NULL);
/// Select variable with smallest max
FloatVarBranch FLOAT_VAR_MAX_MIN(BranchTbl tbl=NULL);
/// Select variable with largest max
FloatVarBranch FLOAT_VAR_MAX_MAX(BranchTbl tbl=NULL);
/// Select variable with smallest domain size
FloatVarBranch FLOAT_VAR_SIZE_MIN(BranchTbl tbl=NULL);
/// Select variable with largest domain size
FloatVarBranch FLOAT_VAR_SIZE_MAX(BranchTbl tbl=NULL);
/// Select variable with smallest degree divided by domain size
FloatVarBranch FLOAT_VAR_DEGREE_SIZE_MIN(BranchTbl tbl=NULL);
/// Select variable with largest degree divided by domain size
FloatVarBranch FLOAT_VAR_DEGREE_SIZE_MAX(BranchTbl tbl=NULL);
/// Select variable with smalllest accumulated failure count divided by domain size with decay factor \a d
FloatVarBranch FLOAT_VAR_AFC_SIZE_MIN(double d=1.0, BranchTbl tbl=NULL);
/// Select variable with smallest accumulated failure count divided by domain size
FloatVarBranch FLOAT_VAR_AFC_SIZE_MIN(FloatAFC a, BranchTbl tbl=NULL);
/// Select variable with largest accumulated failure count divided by domain size with decay factor \a d
FloatVarBranch FLOAT_VAR_AFC_SIZE_MAX(double d=1.0, BranchTbl tbl=NULL);
/// Select variable with largest accumulated failure count divided by domain size
FloatVarBranch FLOAT_VAR_AFC_SIZE_MAX(FloatAFC a, BranchTbl tbl=NULL);
/// Select variable with smallest activity divided by domain size with decay factor \a d
FloatVarBranch FLOAT_VAR_ACTIVITY_SIZE_MIN(double d=1.0, BranchTbl tbl=NULL);
/// Select variable with smallest activity divided by domain size
FloatVarBranch FLOAT_VAR_ACTIVITY_SIZE_MIN(FloatActivity a, BranchTbl tbl=NULL);
/// Select variable with largest activity divided by domain size with decay factor \a d
FloatVarBranch FLOAT_VAR_ACTIVITY_SIZE_MAX(double d=1.0, BranchTbl tbl=NULL);
/// Select variable with largest activity divided by domain size
FloatVarBranch FLOAT_VAR_ACTIVITY_SIZE_MAX(FloatActivity a, BranchTbl tbl=NULL);
//@}
}
#include <gecode/float/branch/var.hpp>
namespace Gecode {
/**
* \brief Which values to select for branching first
*
* \ingroup TaskModelFloatBranch
*/
class FloatValBranch : public ValBranch {
public:
/// Which value selection
enum Select {
SEL_SPLIT_MIN, ///< Select values not greater than mean of smallest and largest value
SEL_SPLIT_MAX, ///< Select values greater than mean of smallest and largest value
SEL_SPLIT_RND, ///< Select values randomly which are not greater or not smaller than mean of largest and smallest value
SEL_VAL_COMMIT, ///< Select value according to user-defined functions
};
protected:
/// Which value to select
Select s;
public:
/// Initialize with selection strategy \a s
FloatValBranch(Select s = SEL_SPLIT_MIN);
/// Initialize with random number generator \a r
FloatValBranch(Rnd r);
/// Initialize with value function \a f and commit function \a c
FloatValBranch(VoidFunction v, VoidFunction c);
/// Return selection strategy
Select select(void) const;
};
/**
* \defgroup TaskModelFloatBranchVal Value selection for float variables
* \ingroup TaskModelFloatBranch
*/
//@{
/// Select values not greater than mean of smallest and largest value
FloatValBranch FLOAT_VAL_SPLIT_MIN(void);
/// Select values greater than mean of smallest and largest value
FloatValBranch FLOAT_VAL_SPLIT_MAX(void);
/// Select values randomly which are not greater or not smaller than mean of largest and smallest value
FloatValBranch FLOAT_VAL_SPLIT_RND(Rnd r);
/**
* Select value as defined by the value function \a v and commit function \a c
* The default commit function posts the constraint that the float variable
* \a x must be less or equal than the value \a n for the first
* alternative and that \a x must be greater or equal than \a n otherwise.
*/
FloatValBranch FLOAT_VAL(FloatBranchVal v, FloatBranchCommit c=NULL);
//@}
}
#include <gecode/float/branch/val.hpp>
namespace Gecode {
/**
* \brief Which values to select for assignment
*
* \ingroup TaskModelFloatBranch
*/
class FloatAssign : public ValBranch {
public:
/// Which value selection
enum Select {
SEL_MIN, ///< Select median value of the lower part
SEL_MAX, ///< Select median value of the upper part
SEL_RND, ///< Select median value of a randomly chosen part
SEL_VAL_COMMIT ///< Select value according to user-defined functions
};
protected:
/// Which value to select
Select s;
public:
/// Initialize with selection strategy \a s
FloatAssign(Select s = SEL_MIN);
/// Initialize with random number generator \a r
FloatAssign(Rnd r);
/// Initialize with value function \a f and commit function \a c
FloatAssign(VoidFunction v, VoidFunction c);
/// Return selection strategy
Select select(void) const;
};
/**
* \defgroup TaskModelFloatBranchAssign Value selection for assigning float variables
* \ingroup TaskModelFloatBranch
*/
//@{
/// Select median value of the lower part
FloatAssign FLOAT_ASSIGN_MIN(void);
/// Select median value of the upper part
FloatAssign FLOAT_ASSIGN_MAX(void);
/// Select median value of a randomly chosen part
FloatAssign FLOAT_ASSIGN_RND(Rnd r);
/**
* Select value as defined by the value function \a v and commit function \a c
* The default commit function posts the constraint that the float variable
* \a x must be less or equal than the value \a n.
*/
FloatAssign FLOAT_ASSIGN(FloatBranchVal v, FloatBranchCommit c=NULL);
//@}
}
#include <gecode/float/branch/assign.hpp>
namespace Gecode {
/**
* \brief Branch over \a x with variable selection \a vars and value selection \a vals
*
* \ingroup TaskModelFloatBranch
*/
GECODE_FLOAT_EXPORT BrancherHandle
branch(Home home, const FloatVarArgs& x,
FloatVarBranch vars, FloatValBranch vals,
FloatBranchFilter bf=NULL,
FloatVarValPrint vvp=NULL);
/**
* \brief Branch over \a x with tie-breaking variable selection \a vars and value selection \a vals
*
* \ingroup TaskModelFloatBranch
*/
GECODE_FLOAT_EXPORT BrancherHandle
branch(Home home, const FloatVarArgs& x,
TieBreak<FloatVarBranch> vars, FloatValBranch vals,
FloatBranchFilter bf=NULL,
FloatVarValPrint vvp=NULL);
/**
* \brief Branch over \a x with value selection \a vals
*
* \ingroup TaskModelFloatBranch
*/
GECODE_FLOAT_EXPORT BrancherHandle
branch(Home home, FloatVar x, FloatValBranch vals,
FloatVarValPrint vvp=NULL);
/**
* \brief Assign all \a x with value selection \a vals
*
* \ingroup TaskModelFloatBranch
*/
GECODE_FLOAT_EXPORT BrancherHandle
assign(Home home, const FloatVarArgs& x, FloatAssign vals,
FloatBranchFilter fbf=NULL,
FloatVarValPrint vvp=NULL);
/**
* \brief Assign \a x with value selection \a vals
*
* \ingroup TaskModelFloatBranch
*/
GECODE_FLOAT_EXPORT BrancherHandle
assign(Home home, FloatVar x, FloatAssign vals,
FloatVarValPrint vvp=NULL);
//@}
}
#endif
// IFDEF: GECODE_HAS_FLOAT_VARS
// STATISTICS: float-post
|