/usr/share/doc/lp-solve-doc/Octave.htm is in lp-solve-doc 5.5.0.13-7.
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 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<HEAD>
<TITLE>Using lpsolve from Octave</TITLE>
<style TYPE="text/css"> BODY { font-family:verdana,arial,helvetica; margin:15; }
</style>
</HEAD>
<BODY>
<h1 align="left"><u>Using lpsolve from Octave</u></h1>
<a name="Octave"></a>
<h3>Octave?</h3>
<P>GNU Octave is a high-level language, primarily intended for numerical
computations. It provides a convenient command line interface for
solving linear and non-linear problems numerically, and for performing
other numerical experiments. It may also be used as a batch-oriented
language.</P>
<p>GNU Octave is also freely redistributable software.</p>
<p>We will not discuss the specifics of Octave here but instead refer the reader to the
<a href="http://www.octave.org/">Octave</a> website and
<a href="http://octave.sourceforge.net/">GNU Octave Repository</a>.
</p>
<a name="Octave_and_lpsolve"></a>
<h3>Octave and lpsolve</h3>
<p>lpsolve is callable from Octave via a dynamic linked function. As such, it looks like lpsolve is fully integrated
with Octave. Matrices can directly be transferred between Octave and lpsolve in both directions. The complete interface
is written in C so it has maximum performance. The whole lpsolve API is implemented with some extra's specific for
Octave (especially for matrix support). So you have full control to the complete lpsolve functionality via the octlpsolve
Octave driver. If you find that this involves too much work to solve an lp model then you can also work via higher-level
script files that can make things a lot easier. See further in this article.
</p>
<p>Note that your version of Octave must support dynamic linking. To find out if it does, type the command:</p>
<pre>octave_config_info ("ENABLE_DYNAMIC_LINKING")</pre>
<p>at the Octave prompt. Support for dynamic linking is included if this expression returns the string "true".</p>
<p>If this is not the case, then Octave is not able to call dynamic linked routines and as such also not lpsolve.
In that case you must recompile Octave with dynamic linked routines enabled.
Under Linux, the following commands must be executed for this:</p>
<pre>configure --enable-shared
make
</pre>
<p>See <a href="http://www.octave.org/doc/octave_38.html">Installing Octave</a> for more information.</p>
<p>Under Windows, dynamic linking should already be active. If not, then Octave must be recompiled. The
following document can help in this process: <a href="ftp://ftp.octave.org/pub/octave/README.Windows">README.Windows</a></p>
<p>The octave dynamic linked routine is in a file with extension .oct. It is impossible to provide a precompiled
octlpsolve.oct file with the lpsolve distribution because the structure of the .oct files change often on new
releases of Octave and are not compatible with each other. Therefore you must build the driver yourself.
Look at the end of this document how to do this.
</p>
<a name="Installation"></a>
<h3>Installation</h3>
<p>A driver program is needed: octlpsolve (octlpsolve.oct).
This driver must be put in a directory known to Octave (in one of the directories from the Octave 'path' command) and Octave can call the octlpsolve solver.</p>
<p>This driver calls lpsolve via the lpsolve shared library (lpsolve55.dll under Windows
and liblpsolve55.so under Unix/Linux) (in archives lp_solve_5.5.0.13_dev.zip/lp_solve_5.5.0.13_dev.tar.gz). This has the advantage that the octlpsolve driver doesn't have to
be recompiled when an update of lpsolve is provided.</p>
<p>So note the difference between the Octave lpsolve driver that is called octlpsolve and the lpsolve library that implements the
API that is called lpsolve55.</p>
<p>There are also some Octave script files (.m) as a quick start.</p>
<p>To test if everything is installed correctly, enter octlpsolve in the Octave command window.
If it gives the following, then everything is ok:</p>
<pre>octlpsolve Octave Interface version 5.5.0.5
using lpsolve version 5.5.0.13
Usage: [ret1, ret2, ...] = octlpsolve('functionname', arg1, arg2, ...)
</pre>
<p>However, if you get the following:</p>
<pre>error: 'octlpsolve' undefined near line 2 column 1</pre>
<p>Then Octave cannot find octlpsolve.oct</p>
<p>If you get the following:</p>
<pre>error: Failed to initialise lpsolve library.</pre>
<p>Then Octave can find the octlpsolve driver program, but the driver program cannot find the lpsolve library
that contains the lpsolve implementation. This library is called lpsolve55.dll under Windows
and liblpsolve55.so under Unix/Linux. Under Windows, the dll should be in a directory specified by the PATH
environment variables and under Unix/Linux in directory /lib, /usr/lib or a directory defined by LD_LIBRARY_PATH.</p>
<a name="Solve_an_lp_model_from_Octave_via_octlpsolve"></a>
<h3>Solve an lp model from Octave via octlpsolve</h3>
<p>In the following text, octave:> before the Octave commands is the Octave prompt.
Only the text after octave:> must be entered.
Note that the default prompt also contains an incrementing number starting from one each time Octave starts.
For this documentation, the default Octave was changed with the following command: PS1 = "\\s:> "
</p>
<p>To call an lpsolve function, the following syntax must be used:</p>
<pre>octave:> [ret1, ret2, ...] = octlpsolve('functionname', arg1, arg2, ...)</pre>
<p>The return values are optional and depend on the function called. functionname must always be enclosed between single or double
quotes to make it alphanumerical and it is case sensitive. The number and type of arguments depend on the function called.
Some functions even have a variable number of arguments and a different behaviour occurs depending on the type of the argument.
functionname can be (almost) any of the lpsolve API routines (see <a href="lp_solveAPIreference.htm">lp_solve API reference</a>)
plus some extra Octave specific functions.
Most of the lpsolve API routines use or return an lprec structure. To make things more robust in Octave, this structure
is replaced by a handle or the model name. The lprec structures are maintained internally by the lpsolve driver.
The handle is an incrementing number starting from 0.
Starting from driver version 5.5.0.2, it is also possible to use the model name instead of the handle.
This can of course only be done if a name is given to the model. This is done via lpsolve routine
<a href="#set_lp_name">set_lp_name</a> or by specifying the model name in routine <a href="#read_lp">read_lp</a>.
See <a href="#Using_model_name_instead_of_handle">Using model name instead of handle</a>.
</p>
<p>Almost all callable functions can be found in the <a href="lp_solveAPIreference.htm">lp_solve API reference</a>.
Some are exactly as described in the reference guide, others have a slightly different syntax to make maximum
use of the Octave functionality. For example make_lp is used identical as described. But get_variables is slightly
different. In the API reference, this function has two arguments. The first the lp handle and the second the
resulting variables and this array must already be dimensioned. When lpsolve is used from Octave, nothing must
be dimensioned in advance. The octlpsolve driver takes care of dimensioning all return variables and they are
always returned as return value of the call to octlpsolve. Never as argument to the routine. This can be a single
value as for get_objective (although Octave stores this in a 1x1 matrix) or a matrix or vector as in get_variables.
In this case, get_variables returns a 4x1 matrix (vector) with the result of the 4 variables of the lp model.
</p>
<p>Note that you can get an overview of the available functionnames and their arguments by entering the following in Octave:</p>
<pre>>> help octlpsolve.m</pre>
<a name="An_example"></a>
<h3>An example</h3>
<p>(Note that you can execute this example by entering command per command as shown below or by just entering example1.
This will execute example1.m. You can see its contents by entering type example1.m)</p>
<pre>octave:> lp=octlpsolve('make_lp', 0, 4);
octave:> octlpsolve('set_verbose', lp, 3);
octave:> octlpsolve('set_obj_fn', lp, [1, 3, 6.24, 0.1]);
octave:> octlpsolve('add_constraint', lp, [0, 78.26, 0, 2.9], 2, 92.3);
octave:> octlpsolve('add_constraint', lp, [0.24, 0, 11.31, 0], 1, 14.8);
octave:> octlpsolve('add_constraint', lp, [12.68, 0, 0.08, 0.9], 2, 4);
octave:> octlpsolve('set_lowbo', lp, 1, 28.6);
octave:> octlpsolve('set_lowbo', lp, 4, 18);
octave:> octlpsolve('set_upbo', lp, 4, 48.98);
octave:> octlpsolve('set_col_name', lp, 1, 'COLONE');
octave:> octlpsolve('set_col_name', lp, 2, 'COLTWO');
octave:> octlpsolve('set_col_name', lp, 3, 'COLTHREE');
octave:> octlpsolve('set_col_name', lp, 4, 'COLFOUR');
octave:> octlpsolve('set_row_name', lp, 1, 'THISROW');
octave:> octlpsolve('set_row_name', lp, 2, 'THATROW');
octave:> octlpsolve('set_row_name', lp, 3, 'LASTROW');
octave:> octlpsolve('write_lp', lp, 'a.lp');
octave:> octlpsolve('get_mat', lp, 1, 2)
ans = 78.260
octave:> octlpsolve('solve', lp)
ans = 0
octave:> octlpsolve('get_objective', lp)
ans = 31.783
octave:> octlpsolve('get_variables', lp)
ans =
28.60000
0.00000
0.00000
31.82759
octave:> octlpsolve('get_constraints', lp)
ans =
92.3000
6.8640
391.2928
</pre>
<p>Note that there are some commands that return an answer. To see the answer, the command was not terminated with
a semicolon (;). If the semicolon is put at the end of a command, the answer is not shown. However it is also possible
to write the answer in a variable. For example:
</p>
<pre>octave:> obj=octlpsolve('get_objective', lp)
obj = 31.783
</pre>
<p>Or without echoing on screen:</p>
<pre>octave:> obj=octlpsolve('get_objective', lp);</pre>
<p>The last command will only write the result in variable obj without showing anything on screen.
get_variables and get_constraints return a vector with the result. This can also be put in a variable:</p>
<pre>octave:> x=octlpsolve('get_variables', lp);
octave:> b=octlpsolve('get_constraints', lp);
</pre>
<p>It is always possible to show the contents of a variable by just giving it as command:</p>
<pre>octave:> x
x =
28.60000
0.00000
0.00000
31.82759
</pre>
<p>Don't forget to free the handle and its associated memory when you are done:</p>
<pre>octave:> octlpsolve('delete_lp', lp);</pre>
<a name="Using_model_name_instead_of_handle"></a>
<h3>Using model name instead of handle</h3>
From driver version 5.5.0.2, it is possible to use the model name instead of the handle. From the moment the model
has a name, you can use this name instead of the handle. This is best shown by an example. Above example would look
like this:
<pre>octave:> lp=octlpsolve('make_lp', 0, 4);
octave:> octlpsolve('set_lp_name', lp, 'mymodel');
octave:> octlpsolve('set_verbose', 'mymodel', 3);
octave:> octlpsolve('set_obj_fn', 'mymodel', [1, 3, 6.24, 0.1]);
octave:> octlpsolve('add_constraint', 'mymodel', [0, 78.26, 0, 2.9], 2, 92.3);
octave:> octlpsolve('add_constraint', 'mymodel', [0.24, 0, 11.31, 0], 1, 14.8);
octave:> octlpsolve('add_constraint', 'mymodel', [12.68, 0, 0.08, 0.9], 2, 4);
octave:> octlpsolve('set_lowbo', 'mymodel', 1, 28.6);
octave:> octlpsolve('set_lowbo', 'mymodel', 4, 18);
octave:> octlpsolve('set_upbo', 'mymodel', 4, 48.98);
octave:> octlpsolve('set_col_name', 'mymodel', 1, 'COLONE');
octave:> octlpsolve('set_col_name', 'mymodel', 2, 'COLTWO');
octave:> octlpsolve('set_col_name', 'mymodel', 3, 'COLTHREE');
octave:> octlpsolve('set_col_name', 'mymodel', 4, 'COLFOUR');
octave:> octlpsolve('set_row_name', 'mymodel', 1, 'THISROW');
octave:> octlpsolve('set_row_name', 'mymodel', 2, 'THATROW');
octave:> octlpsolve('set_row_name', 'mymodel', 3, 'LASTROW');
octave:> octlpsolve('write_lp', 'mymodel', 'a.lp');
octave:> octlpsolve('get_mat', 'mymodel', 1, 2)
ans = 78.260
octave:> octlpsolve('solve', 'mymodel')
ans = 0
octave:> octlpsolve('get_objective', 'mymodel')
ans = 31.783
octave:> octlpsolve('get_variables', 'mymodel')
ans =
28.60000
0.00000
0.00000
31.82759
octave:> octlpsolve('get_constraints', 'mymodel')
ans =
92.3000
6.8640
391.2928
</pre>
<p>So everywhere a handle is needed, you can also use the model name. You can even mix the two methods.
There is also a specific Octave routine to get the handle from the model name: <a href="#get_handle">get_handle</a>.<br>
For example:</p>
<pre>
>> octlpsolve('get_handle', 'mymodel')
0
</pre>
<p>Don't forget to free the handle and its associated memory when you are done:</p>
<pre>octave:> octlpsolve('delete_lp', 'mymodel');</pre>
<p>In the next part of this documentation, the handle is used. But if you name the model, the name could thus also be used.</p>
<a name="Matrices"></a>
<h3>Matrices</h3>
In Octave, all numerical data is stored in matrices; even a scalar variable. Octave also supports complex numbers
(a + b * i with i=sqrt(-1)). octlpsolve can only work with real numbers.
For example:
<pre>octave:> octlpsolve('add_constraint', lp, [0.24, 0, 11.31, 0], 1, 14.8);</pre>
<p>Most of the time, variables are used to provide the data:</p>
<pre>octave:> octlpsolve('add_constraint', lp, a1, 1, 14.8);</pre>
<p>Where a1 is a matrix variable.</p>
<p>Most of the time, octlpsolve needs vectors (rows or columns).
In all situations, it doesn't matter if the vectors are row or column vectors. The driver accepts them both.
For example:</p>
<pre>octave:> octlpsolve('add_constraint', lp, [0.24; 0; 11.31; 0], 1, 14.8);</pre>
<p>Which is a column vector, but it is also accepted.</p>
<p>An important final note. Several lp_solve API routines accept a vector where the first element (element 0) is not used.
Other lp_solve API calls do use the first element. In the Octave interface, there is never an unused element in the matrices.
So if the lp_solve API specifies that the first element is not used, then this element is not in the Octave matrix.</p>
<a name="Sets"></a>
<h3>Sets</h3>
<p>All numerical data is stored in matrices. Alphanumerical data, however, is more difficult to store in matrices.
Matrices require that each element has the same size (length) and that is difficult and unpractical for alphanumerical
data. In a limited number of lpsolve routines, alphanumerical data is required or returned and in some also multiple
elements. An example is set_col_name. For this, Octave sets are used. To specify a set of alphanumerical elements,
the following notation is used: { 'element1', 'element2', ... }. Note the { and } symbols instead of [ and ] that
are used with matrices.
</p>
<a name="Maximum_usage_of_matrices_sets_with_octlpsolve"></a>
<h3>Maximum usage of matrices/sets with octlpsolve</h3>
<p>Because Octave is all about matrices, all lpsolve API routines that need a column or row number to get/set information for that
column/row are extended in the octlpsolve Octave driver to also work with matrices. For example set_int in the API can
only set the integer status for one column. If the status for several integer variables must be set, then set_int
must be called multiple times. The octlpsolve Octave driver however also allows specifying a vector to set the integer
status of all variables at once. The API call is: return = octlpsolve('set_int', lp, column, must_be_int). The
matrix version of this call is: return = octlpsolve('set_int', lp, [must_be_int]).
The API call to return the integer status of a variable is: return = octlpsolve('is_int', lp, column). The
matrix version of this call is: [is_int] = octlpsolve('is_int', lp)<br>
Also note the get_mat and set_mat routines. In Octave these are extended to return/set the complete constraint matrix.
See following example.
</p>
<p>Above example can thus also be done as follows:<br>
(Note that you can execute this example by entering command per command as shown below or by just entering example2.
This will execute example2.m. You can see its contents by entering type example2.m)</p>
<pre>octave:> lp=octlpsolve('make_lp', 0, 4);
octave:> octlpsolve('set_verbose', lp, 3);
octave:> octlpsolve('set_obj_fn', lp, [1, 3, 6.24, 0.1]);
octave:> octlpsolve('add_constraint', lp, [0, 78.26, 0, 2.9], 2, 92.3);
octave:> octlpsolve('add_constraint', lp, [0.24, 0, 11.31, 0], 1, 14.8);
octave:> octlpsolve('add_constraint', lp, [12.68, 0, 0.08, 0.9], 2, 4);
octave:> octlpsolve('set_lowbo', lp, [28.6, 0, 0, 18]);
octave:> octlpsolve('set_upbo', lp, [Inf, Inf, Inf, 48.98]);
octave:> octlpsolve('set_col_name', lp, {'COLONE', 'COLTWO', 'COLTHREE', 'COLFOUR'});
octave:> octlpsolve('set_row_name', lp, {'THISROW', 'THATROW', 'LASTROW'});
octave:> octlpsolve('write_lp', lp, 'a.lp');
octave:> octlpsolve('get_mat', lp)
ans =
0.00000 78.26000 0.00000 2.90000
0.24000 0.00000 11.31000 0.00000
12.68000 0.00000 0.08000 0.90000
octave:> octlpsolve('solve', lp)
ans = 0
octave:> octlpsolve('get_objective', lp)
ans = 31.783
octave:> octlpsolve('get_variables', lp)
ans =
28.60000
0.00000
0.00000
31.82759
octave:> octlpsolve('get_constraints', lp)
ans =
92.3000
6.8640
391.2928
</pre>
<p>Note the usage of Inf in set_upbo. This stands for 'infinity'. Meaning an infinite upper bound.
It is also possible to use -Inf to express minus infinity. This can for example be used to create a free variable.</p>
<p>To show the full power of the matrices, let's now do some matrix calculations to check the solution.
It works further on above example:</p>
<pre>octave:> A=octlpsolve('get_mat', lp);
octave:> X=octlpsolve('get_variables', lp);
octave:> B = A * X
B =
92.3000
6.8640
391.2928
</pre>
<p>So what we have done here is calculate the values of the constraints (RHS) by multiplying the constraint matrix
with the solution vector. Now take a look at the values of the constraints that lpsolve has found:</p>
<pre>octave:> octlpsolve('get_constraints', lp)
ans =
92.3000
6.8640
391.2928
</pre>
<p>Exactly the same as the calculated B vector, as expected.</p>
<p>Also the value of the objective can be calculated in a same way:</p>
<pre>octave:> C=octlpsolve('get_obj_fn', lp);
octave:> X=octlpsolve('get_variables', lp);
octave:> obj = C * X
obj = 31.783
</pre>
<p>So what we have done here is calculate the value of the objective by multiplying the objective vector
with the solution vector. Now take a look at the value of the objective that lpsolve has found:</p>
<pre>octave:> octlpsolve('get_objective', lp)
ans = 31.783
</pre>
<p>Again exactly the same as the calculated obj value, as expected.</p>
<a name="Script_files"></a>
<h3>Script files</h3>
<p>Octave can execute a sequence of statements stored in diskfiles. Script files mostly have the file type of ".m"
as the last part of their filename (extension).
Much of your work with Octave will be in creating and refining script files. Script files are
usually created using your local editor.</p>
<p>Script files can be compared with batch files or scripts. You can put Octave commands in them and execute them at
any time. The script file is executed like any other command, by entering its name (without the .m extension).</p>
<p>The octlpsolve Octave distribution contains some example script files to demonstrate this.</p>
<p>To see the contents of such a file, enter the command 'type filename'. You can also edit these files with your
favourite text editor (or notepad).</p>
<h4>example1.m</h4>
<p>Contains the commands as shown in the first example of this article.</p>
<h4>example2.m</h4>
<p>Contains the commands as shown in the second example of this article.</p>
<h4>example3.m</h4>
<p>Contains the commands of a practical example. See further in this article.</p>
<h4>example4.m</h4>
<p>Contains the commands of a practical example. See further in this article.</p>
<h4>example5.m</h4>
<p>Contains the commands of a practical example. See further in this article.</p>
<h4>example6.m</h4>
<h4>lp_solve.m</h4>
<p>This script uses the API to create a higher-level function called lp_solve.
This function accepts as arguments some matrices and options to create and solve an lp model.
See the beginning of the file or type help lp_solve or just lp_solve to see its usage:</p>
<pre> LP_SOLVE Solves mixed integer linear programming problems.
SYNOPSIS: [obj,x,duals] = lp_solve(f,a,b,e,vlb,vub,xint,scalemode,keep)
solves the MILP problem
max v = f'*x
a*x <> b
vlb <= x <= vub
x(int) are integer
ARGUMENTS: The first four arguments are required:
f: n vector of coefficients for a linear objective function.
a: m by n matrix representing linear constraints.
b: m vector of right sides for the inequality constraints.
e: m vector that determines the sense of the inequalities:
e(i) = -1 ==> Less Than
e(i) = 0 ==> Equals
e(i) = 1 ==> Greater Than
vlb: n vector of lower bounds. If empty or omitted,
then the lower bounds are set to zero.
vub: n vector of upper bounds. May be omitted or empty.
xint: vector of integer variables. May be omitted or empty.
scalemode: scale flag. Off when 0 or omitted.
keep: Flag for keeping the lp problem after it's been solved.
If omitted, the lp will be deleted when solved.
OUTPUT: A nonempty output is returned if a solution is found:
obj: Optimal value of the objective function.
x: Optimal value of the decision variables.
duals: solution of the dual problem.
</pre>
<p>Example of usage. To create and solve following lp-model:</p>
<pre>max: -x1 + 2 x2;
C1: 2x1 + x2 < 5;
-4 x1 + 4 x2 <5;
int x2,x1;
</pre>
<p>The following command can be used:</p>
<pre>octave:> [obj, x]=lp_solve([-1, 2], [2, 1; -4, 4], [5, 5], [-1, -1], [], [], [1, 2])
obj = 3
x =
1
2
</pre>
<h4>lp_maker.m</h4>
<p>This script is analog to the lp_solve script and also uses the API to create a higher-level function called lp_maker.
This function accepts as arguments some matrices and options to create an lp model. Note that this scripts only
creates a model and returns a handle.
See the beginning of the file or type help lp_maker or just lp_maker to see its usage:</p>
<pre>octave:> help lp_maker
LP_MAKER Makes mixed integer linear programming problems.
SYNOPSIS: lp_handle = lp_maker(f,a,b,e,vlb,vub,xint,scalemode,setminim)
make the MILP problem
max v = f'*x
a*x <> b
x >= vlb >= 0
x <= vub
x(int) are integer
ARGUMENTS: The first four arguments are required:
f: n vector of coefficients for a linear objective function.
a: m by n matrix representing linear constraints.
b: m vector of right sides for the inequality constraints.
e: m vector that determines the sense of the inequalities:
e(i) < 0 ==> Less Than
e(i) = 0 ==> Equals
e(i) > 0 ==> Greater Than
vlb: n vector of non-negative lower bounds. If empty or omitted,
then the lower bounds are set to zero.
vub: n vector of upper bounds. May be omitted or empty.
xint: vector of integer variables. May be omitted or empty.
scalemode: scale flag. Off when 0 or omitted.
setminim: Set maximum lp when this flag equals 0 or omitted.
OUTPUT: lp_handle is an integer handle to the lp created.
</pre>
<p>Example of usage. To create following lp-model:</p>
<pre>max: -x1 + 2 x2;
C1: 2x1 + x2 < 5;
-4 x1 + 4 x2 <5;
int x2,x1;
</pre>
<p>The following command can be used:</p>
<pre>octave:> lp=lp_maker([-1, 2], [2, 1; -4, 4], [5, 5], [-1, -1], [], [], [1, 2])
lp = 0
</pre>
<p>To solve the model and get the solution:</p>
<pre>octave:> octlpsolve('solve', lp)
ans = 0
octave:> octlpsolve('get_objective', lp)
ans = 3
octave:> octlpsolve('get_variables', lp)
ans =
1
2
</pre>
<p>Don't forget to free the handle and its associated memory when you are done:</p>
<pre>octave:> octlpsolve('delete_lp', lp);</pre>
<h4>lpdemo.m</h4>
<p>Contains several examples to build and solve lp models.</p>
<h4>ex.m</h4>
<p>Contains several examples to build and solve lp models.
Also solves the lp_examples from the lp_solve distribution.</p>
<a name="A_practical_example"></a>
<h3>A practical example</h3>
<p>We shall illustrate the method of linear programming by means of a simple example,
giving a combination graphical/numerical solution, and then solve both a slightly as well as a substantially
more complicated problem.</p>
<p>Suppose a farmer has 75 acres on which to plant two crops: wheat and barley.
To produce these crops, it costs the farmer (for seed, fertilizer, etc.) $120 per acre for the
wheat and $210 per acre for the barley. The farmer has $15000 available for expenses.
But after the harvest, the farmer must store the crops while awaiting favourable market conditions.
The farmer has storage space for 4000 bushels. Each acre yields an average of 110 bushels of wheat
or 30 bushels of barley. If the net profit per bushel of wheat (after all expenses have been subtracted)
is $1.30 and for barley is $2.00, how should the farmer plant the 75 acres to maximize profit?</p>
<p>We begin by formulating the problem mathematically.
First we express the objective, that is the profit, and the constraints
algebraically, then we graph them, and lastly we arrive at the solution
by graphical inspection and a minor arithmetic calculation.</p>
<p>Let x denote the number of acres allotted to wheat and y the number of acres allotted to barley.
Then the expression to be maximized, that is the profit, is clearly</p>
<p align="center">P = (110)(1.30)x + (30)(2.00)y = 143x + 60y.</p>
<p>There are three constraint inequalities, specified by the limits on expenses, storage and acreage.
They are respectively:</p>
<p align="center">
120x + 210y <= 15000<br>
110x + 30y <= 4000<br>
x + y <= 75
</p>
<p>Strictly speaking there are two more constraint inequalities forced by the fact that the farmer cannot plant
a negative number of acres, namely:</p>
<p align="center">x >= 0, y >= 0.</p>
<p>Next we graph the regions specified by the constraints. The last two say that we only need to consider
the first quadrant in the x-y plane. Here's a graph delineating the triangular region in the first quadrant determined
by the first inequality.</p>
<pre>
octave:> X = 0.1:0.1:125;
octave:> Y1 = (15000 - 120.*X)./210;
octave:> bar(X, Y1);
</pre>
<p><IMG alt="Source" src="http://lpsolve.sourceforge.net/5.5/Octave1.jpg" border="0"></p>
<p>Now let's put in the other two constraint inequalities.</p>
<pre>
octave:> X = 0.1:0.05:40;
octave:> Y1 = (15000. - 120*X)/210;
octave:> Y2 = max((4000 - 110.*X)./30, 0);
octave:> Y3 = max(75 - X, 0);
octave:> Ytop = min([Y1; Y2; Y3]);
octave:> bar(X, Ytop);
</pre>
<p><IMG alt="Source" src="http://lpsolve.sourceforge.net/5.5/Octave2.jpg" border="0"></p>
<p>The red area is the solution space that holds valid solutions. This means that any point in this area fulfils the
constraints.
</p>
<p>Now let's superimpose on top of this picture the objective function P.</p>
<pre>
octave:> hold on
octave:> X=15:25:40;
octave:> title('Solution space and objective')
octave:> plot(X,(6315.63-143.0*X)/60.0);
octave:> hold off
</pre>
<p><IMG alt="Source" src="http://lpsolve.sourceforge.net/5.5/Octave3.jpg" border="0"></p>
<p>The line gives a picture of the objective function.
All solutions that intersect with the red area are valid solutions, meaning that this result also fulfils
the set constraints. The more the line goes to the right, the higher the objective value is. The optimal solution
or best objective is a line that is still in the red area, but with an as large as possible value.
</p>
<p>It seems apparent that the maximum value of P will occur on the level curve (that is, level
line) that passes through the vertex of the polygon that lies near (22,53).<br>
It is the intersection of x + y = 75 and 110*x + 30*y = 4000<br>
This is a corner point of the diagram. This is not a coincidence. The simplex algorithm, which is used
by lp_solve, starts from a theorem that the optimal solution is such a corner point.<br>
In fact we can compute the result:</p>
<pre>
octave:> x = [1 1; 110 30] \ [75; 4000]
x =
21.875
53.125
</pre>
<p>The acreage that results in the maximum profit is 21.875 for wheat and 53.125 for barley.
In that case the profit is:</p>
<pre>
octave:> P = [143 60] * x
P = 6315.6
</pre>
<p>That is, $6315.6.</p>
<p>Note that these command are in script example3.m</p>
<p>Now, lp_solve comes into the picture to solve this linear programming problem more generally.
After that we will use it to solve two more complicated problems involving more variables
and constraints.</p>
<p>For this example, we use the higher-level script lp_maker to build the model and then some lp_solve API calls
to retrieve the solution. Here is again the usage of lp_maker:</p>
<pre>
LP_MAKER Makes mixed integer linear programming problems.
SYNOPSIS: lp_handle = lp_maker(f,a,b,e,vlb,vub,xint,scalemode,setminim)
make the MILP problem
max v = f'*x
a*x <> b
x >= vlb >= 0
x <= vub
x(int) are integer
ARGUMENTS: The first four arguments are required:
f: n vector of coefficients for a linear objective function.
a: m by n matrix representing linear constraints.
b: m vector of right sides for the inequality constraints.
e: m vector that determines the sense of the inequalities:
e(i) < 0 ==> Less Than
e(i) = 0 ==> Equals
e(i) > 0 ==> Greater Than
vlb: n vector of non-negative lower bounds. If empty or omitted,
then the lower bounds are set to zero.
vub: n vector of upper bounds. May be omitted or empty.
xint: vector of integer variables. May be omitted or empty.
scalemode: scale flag. Off when 0 or omitted.
setminim: Set maximum lp when this flag equals 0 or omitted.
OUTPUT: lp_handle is an integer handle to the lp created.
</pre>
<p>Now let's formulate this model with lp_solve:</p>
<pre>
octave:> f = [143 60];
octave:> A = [120 210; 110 30; 1 1];
octave:> b = [15000; 4000; 75];
octave:> lp = lp_maker(f, A, b, [-1; -1; -1], [], [], [], 1, 0);
octave:> solvestat = octlpsolve('solve', lp)
solvestat = 0
octave:> obj = octlpsolve('get_objective', lp)
obj = 6315.6
octave:> x = octlpsolve('get_variables', lp)
x =
21.875
53.125
octave:> octlpsolve('delete_lp', lp);
</pre>
<p>Note that these command are in script example4.m</p>
<p>With the higher-level script lp_maker, we provide all data to lp_solve. lp_solve returns a handle (lp) to the
created model. Then the API call 'solve' is used to calculate the optimal solution of the model.
The value of the objective function is retrieved via the API call 'get_objective' and the values of the variables
are retrieved via the API call 'get_variables'. At last, the model is removed from memory via a call to 'delete_lp'.
Don't forget this to free all memory allocated by lp_solve.</p>
<p>The solution is the same answer we obtained before.
Note that the non-negativity constraints are accounted implicitly because variables are by default non-negative
in lp_solve.</p>
<p>Well, we could have done this problem by hand (as shown in the introduction) because it is very small and it
can be graphically presented.<br>
Now suppose that the farmer is dealing with a third crop, say corn, and that the corresponding data is:</p>
<blockquote>
<table cellSpacing="1" cellPadding="1" border="1" ID="Table1">
<tr><td>cost per acre</td><td>$150.75</td></tr>
<tr><td>yield per acre</td><td>125 bushels</td></tr>
<tr><td>profit per bushel</td><td>$1.56</td></tr>
</table>
</blockquote>
<p>With three variables it is already a lot more difficult to show this model graphically. Adding more variables
makes it even impossible because we can't imagine anymore how to represent this. We only have a practical understanding
of 3 dimentions, but beyound that it is all very theorethical.</p>
<p>If we denote the number of acres allotted to corn by z, then the objective function becomes:</p>
<p align="center">P = (110)(1.30)x + (30)(2.00)y + (125)(1.56) = 143x + 60y + 195z</p>
<p>And the constraint inequalities are:</p>
<p align="center">
120x + 210y + 150.75z <= 15000<br>
110x + 30y + 125z <= 4000<br>
x + y + z <= 75<br>
x >= 0, y >= 0, z >= 0
</p>
<p>The problem is solved with lp_solve as follows:</p>
<pre>
octave:> f = [143 60 195];
octave:> A = [120 210 150.75; 110 30 125; 1 1 1];
octave:> b = [15000; 4000; 75];
octave:> lp = lp_maker(f, A, b, [-1; -1; -1], [], [], [], 1, 0);
octave:> solvestat = octlpsolve('solve', lp)
solvestat = 0
octave:> obj = octlpsolve('get_objective', lp)
obj = 6986.8
octave:> x = octlpsolve('get_variables', lp)
x =
0.00000
56.57895
18.42105
octave:> octlpsolve('delete_lp', lp);
</pre>
<p>Note that these command are in script example5.m</p>
<p>So the farmer should ditch the wheat and plant 56.5789 acres of barley and 18.4211 acres of corn.</p>
<p>There is no practical limit on the number of variables and constraints that Octave can handle.
Certainly none that the relatively unsophisticated user will encounter. Indeed, in
many true applications of the technique of linear programming, one needs
to deal with many variables and constraints. The solution of such
a problem by hand is not feasible, and software like Octave is crucial
to success. For example, in the farming problem with which we
have been working, one could have more crops than two or three. Think
agribusiness instead of family farmer. And one could have constraints
that arise from other things beside expenses, storage and acreage limitations. For example:</p>
<ul>
<li>Availability of seed. This might lead to constraint inequalities like xj < k.</li>
<li>Personal preferences. Thus the farmer's spouse might have a preference
for one variety over another and insist on a corresponding planting,
or something similar with a collection of crops; thus constraint inequalities
like xi < xj or x1 + x2 > x3.</li>
<li>Government subsidies. It may take a moment's reflection on the reader's part,
but this could lead to inequalities like xj > k.</li>
</ul>
<p>Below is a sequence of commands that solves exactly such a problem.
You should be able to recognize the objective expression and the constraints from the data that is entered.
But as an aid, you might answer the following questions:
</p>
<ul>
<li>How many crops are under consideration?</li>
<li>What are the corresponding expenses? How much is available for expenses?</li>
<li>What are the yields in each case? What is the storage capacity?</li>
<li>How many acres are available?</li>
<li>What crops are constrained by seed limitations? To what extent?</li>
<li>What about preferences?</li>
<li>What are the minimum acreages for each crop?</li>
</ul>
<pre>
octave:> f = [110*1.3 30*2.0 125*1.56 75*1.8 95*.95 100*2.25 50*1.35];
octave:> A = [120 210 150.75 115 186 140 85;
110 30 125 75 95 100 50;
1 1 1 1 1 1 1;
1 -1 0 0 0 0 0;
0 0 1 0 -2 0 0;
0 0 0 -1 0 -1 1];
octave:> b = [55000;40000;400;0;0;0];
octave:> lp = lp_maker(f, A, b, [-1; -1; -1; -1; -1; -1],
[10 10 10 10 20 20 20], [100 Inf 50 Inf Inf 250 Inf], [], 1, 0);
octave:> solvestat = octlpsolve('solve', lp)
solvestat = 0
octave:> obj = octlpsolve('get_objective', lp)
obj = 7.5398e+04
octave:> x = octlpsolve('get_variables', lp)
x =
10.000
10.000
40.000
45.652
20.000
250.000
20.000
octave:> octlpsolve('delete_lp', lp);
</pre>
<p>Note that these command are in script example6.m</p>
<p>Note that we have used in this formulation the vlb and vub arguments of lp_maker. This to set lower and upper bounds
on variables. This could have been done via extra constraints, but it is more performant to set bounds on variables.
Also note that Inf is used for variables that have no upper limit. This stands for Infinity.
</p>
<p>Note that despite the complexity of the problem, lp_solve solves it almost instantaneously. It seems the
farmer should bet the farm on crop number 6. We strongly suggest
you alter the expense and/or the storage limit in the problem and see
what effect that has on the answer.</p>
<a name="Another,_more_theoretical,_example"></a>
<h3>Another, more theoretical, example</h3>
<p>Suppose we want to solve the following linear program using Octave:</p>
<p align="center">
max 4x1 + 2x2 + x3<br>
s. t. 2x1 + x2 <= 1<br>
x1 + 2x3 <= 2<br>
x1 + x2 + x3 = 1<br>
x1 >= 0<br>
x1 <= 1<br>
x2 >= 0<br>
x2 <= 1<br>
x3 >= 0<br>
x3 <= 2<br>
</p>
<p>Convert the LP into Octave format we get:</p>
<p align="center">
f = [4 2 1]<br>
A = [2 1 0; 1 0 2; 1 1 1]<br>
b = [1; 2; 1]
</p>
<p>Note that constraints on single variables are not put in the constraint matrix.
lp_solve can set bounds on individual variables and this is more performant than creating
additional constraints. These bounds are:
</p>
<p align="center">
l = [ 0 0 0]<br>
u = [ 1 1 2]
</p>
<p>Now lets enter this in Octave:</p>
<pre>
octave:> f = [4 2 1];
octave:> A = [2 1 0; 1 0 2; 1 1 1];
octave:> b = [1; 2; 1];
octave:> l = [ 0 0 0];
octave:> u = [ 1 1 2];
</pre>
<p>Now solve the linear program using Octave: Type the commands</p>
<pre>
octave:> lp = lp_maker(f, A, b, [-1; -1; -1], l, u, [], 1, 0);
octave:> solvestat = octlpsolve('solve', lp)
solvestat = 0
octave:> obj = octlpsolve('get_objective', lp)
obj = 2.5000
octave:> x = octlpsolve('get_variables', lp)
x =
0.50000
0.00000
0.50000
octave:> octlpsolve('delete_lp', lp)
</pre>
<p>What to do when some of the variables are missing ?<br>
For example, suppose there are no lower bounds on the variables. In this case define l to be the empty set using the Octave command:
</p>
<pre>
octave:> l = [];
</pre>
<p>This has the same effect as before, because lp_solve has as default lower bound for variables 0.</p>
<p>But what if you want that variables may also become negative?<br>
Then you can use -Inf as lower bounds:</p>
<pre>
octave:> l = [-Inf -Inf -Inf];
</pre>
<p>Solve this and you get a different result:</p>
<pre>
octave:> lp = lp_maker(f, A, b, [-1; -1; -1], l, u, [], 1, 0);
octave:> solvestat = octlpsolve('solve', lp)
solvestat = 0
octave:> obj = octlpsolve('get_objective', lp)
obj = 2.6667
octave:> x = octlpsolve('get_variables', lp)
x =
0.66667
-0.33333
0.66667
octave:> octlpsolve('delete_lp', lp)
</pre>
<a name="Overview_of_API_routines"></a>
<h3>Overview of API routines</h3>
<p>Note again that the Octave command 'help octlpsolve.m' gives an overview of all functions that can be called via octlpsolve with their arguments and return values.</p>
<p>Note that everwhere where lp is used as argument that this can be a handle (lp_handle) or the models name.</p>
<ul>
<li>
<a href="add_column.htm">add_column, add_columnex</a>
<ul>
<li>return = octlpsolve('add_column', lp,
[column])
<li>return = octlpsolve('add_columnex', lp,
[column])
<li>Both have the same interface from <a href="add_column.htm">add_column</a> but act as <a href="add_column.htm">add_columnex</a></li>
</ul>
<li>
<a href="add_constraint.htm">add_constraint, add_constraintex</a>
<ul>
<li>return = octlpsolve('add_constraint', lp,
[row], constr_type, rh)
<li>return = octlpsolve('add_constraintex', lp,
[row], constr_type, rh)
<li>Both have the same interface from <a href="add_constraint.htm">add_constraint</a> but act as <a href="add_constraint.htm">add_constraintex</a></li>
</ul>
<li>
<a href="add_SOS.htm">add_SOS</a>
<ul>
<li>return = octlpsolve('add_SOS', lp, name,
sostype, priority, [sosvars], [weights])
<li>The <i>count</i> argument in the API documentation is not needed in Octave since the number of elements is derived from the size of the sosvars and weights matrices. These must have the same size.</li>
</ul>
<li>
<a href="column_in_lp.htm">column_in_lp</a>
<ul>
<li>return = octlpsolve('column_in_lp', lp,
[column])
<li>No special considerations.</li>
</ul>
<li>
<a href="copy_lp.htm">copy_lp</a>
<ul>
<li>lp_handle = octlpsolve('copy_lp', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="default_basis.htm">default_basis</a>
<ul>
<li>octlpsolve('default_basis', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="del_column.htm">del_column</a>
<ul>
<li>return = octlpsolve('del_column', lp, column)
<li>No special considerations.</li>
</ul>
<li>
<a href="del_constraint.htm">del_constraint</a>
<ul>
<li>return = octlpsolve('del_constraint', lp,
del_row)
<li>No special considerations.</li>
</ul>
<li>
<a href="delete_lp.htm">delete_lp</a>
<ul>
<li>octlpsolve('delete_lp', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="free_lp.htm">free_lp</a>
<ul>
<li>octlpsolve('free_lp', lp)
<li>lp is not changed as in the lpsolve API since it is a read_only input parameter. So it acts the same as delete_lp.</li>
</ul>
<li>
<a href="get_anti_degen.htm">get_anti_degen</a>
<ul>
<li>return = octlpsolve('get_anti_degen', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_basis.htm">get_basis</a>
<ul>
<li>[bascolumn] = octlpsolve('get_basis', lp {,
nonbasic})
<li>The <i>bascolumn</i> argument in the API documentation is here the return value. The <i>nonbasic</i> argument is optional in Octave. If not provided, then 0 is used.</li>
</ul>
<li>
<a href="get_basiscrash.htm">get_basiscrash</a>
<ul>
<li>return = octlpsolve('get_basiscrash', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_bb_depthlimit.htm">get_bb_depthlimit</a>
<ul>
<li>return = octlpsolve('get_bb_depthlimit', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_bb_floorfirst.htm">get_bb_floorfirst</a>
<ul>
<li>return = octlpsolve('get_bb_floorfirst', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_bb_rule.htm">get_bb_rule</a>
<ul>
<li>return = octlpsolve('get_bb_rule', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_bounds_tighter.htm">get_bounds_tighter</a>
<ul>
<li>return = octlpsolve('get_bounds_tighter', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_break_at_value.htm">get_break_at_value</a>
<ul>
<li>return = octlpsolve('get_break_at_value', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_col_name.htm">get_col_name</a>
<ul>
<li>name = octlpsolve('get_col_name', lp, column)
<li>[names] = octlpsolve('get_col_name', lp)
<li>In Octave, this routine has two formats. The first format is identical to the API.
The second format allows retrieving the values into an Octave matrix.</li>
</ul>
<li>
<a href="get_column.htm">get_column</a>
<a href="get_column.htm">get_columnex</a>
<ul>
<li>[column, return] = octlpsolve('get_column', lp, col_nr)
<li>[column, return] = octlpsolve('get_columnex', lp, col_nr)
<li>The <i>column</i> argument in
the API documentation is here the first return value.
<li>The return code of the call is the second return value.</li>
</ul>
<li>
<a href="get_constr_type.htm">get_constr_type</a>
<ul>
<li>return = octlpsolve('get_constr_type', lp,
row)
<li>[constr_type] = octlpsolve('get_constr_type',
lp)
<li>In Octave, this routine has two formats. The first format is identical to the API.
The second format allows retrieving the values into an Octave matrix.</li>
</ul>
<li>
<a href="get_constr_value.htm">get_constr_value</a>
<ul>
<li>return = octlpsolve('get_constr_value', lp, row {, primsolution})
<li>The primsolution argument is optional. If not provided, then the solution of last solve is used.</li>
</ul>
<li>
<a href="get_constraints.htm">get_constraints</a>
<ul>
<li>[constr, return] = octlpsolve('get_constraints',
lp)
<li>The <i>constr</i> argument in
the API documentation is here the first return value.
<li>The return code of the call is the second return value.</li>
</ul>
<li>
<a href="get_sensitivity_rhs.htm">get_dual_solution</a>
<ul>
<li>[duals, return] = octlpsolve('get_dual_solution',
lp)
<li>The <i>duals</i> argument in
the API documentation is here the first return value.
<li>In the API, element 0 is not used and values start
from element 1. In Octave, there is no unused element in the matrix.
<li>The return code of the call is the second return value.</li>
</ul>
<li>
<a href="get_epsb.htm">get_epsb</a>
<ul>
<li>return = octlpsolve('get_epsb', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_epsd.htm">get_epsd</a>
<ul>
<li>return = octlpsolve('get_epsd', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_epsel.htm">get_epsel</a>
<ul>
<li>return = octlpsolve('get_epsel', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_epsint.htm">get_epsint</a>
<ul>
<li>return = octlpsolve('get_epsint', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_epsperturb.htm">get_epsperturb</a>
<ul>
<li>return = octlpsolve('get_epsperturb', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_epspivot.htm">get_epspivot</a>
<ul>
<li>return = octlpsolve('get_epspivot', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_improve.htm">get_improve</a>
<ul>
<li>return = octlpsolve('get_improve', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_infinite.htm">get_infinite</a>
<ul>
<li>return = octlpsolve('get_infinite', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_lowbo.htm">get_lowbo</a>
<ul>
<li>return = octlpsolve('get_lowbo', lp, column)
<li>[return] = octlpsolve('get_lowbo', lp)
<li>In Octave, this routine has two formats. The first format is identical to the API.
The second format allows retrieving the values into an Octave matrix.</li>
</ul>
<li>
<a href="get_lp_index.htm">get_lp_index</a>
<ul>
<li>return = octlpsolve('get_lp_index', lp,
orig_index)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_lp_name.htm">get_lp_name</a>
<ul>
<li>name = octlpsolve('get_lp_name', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_mat.htm">get_mat</a>
<ul>
<li>value = octlpsolve('get_mat', lp, row, col)
<li>[matrix, return] = octlpsolve('get_mat', lp)
<li>In Octave, this routine has two formats. The first format is identical to the API.
The second format allows retrieving the values into an Octave matrix in the first return value.
The return code of the call is the second return value.</li>
</ul>
<li>
<a href="get_max_level.htm">get_max_level</a>
<ul>
<li>return = octlpsolve('get_max_level', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_maxpivot.htm">get_maxpivot</a>
<ul>
<li>return = octlpsolve('get_maxpivot', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_mip_gap.htm">get_mip_gap</a>
<ul>
<li>return = octlpsolve('get_mip_gap', lp,
absolute)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_nameindex.htm">get_nameindex</a>
<ul>
<li>return = octlpsolve('get_nameindex', lp, name, isrow)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_Ncolumns.htm">get_Ncolumns</a>
<ul>
<li>return = octlpsolve('get_Ncolumns', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_negrange.htm">get_negrange</a>
<ul>
<li>return = octlpsolve('get_negrange', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_nonzeros.htm">get_nonzeros</a>
<ul>
<li>return = octlpsolve('get_nonzeros', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_Norig_columns.htm">get_Norig_columns</a>
<ul>
<li>return = octlpsolve('get_Norig_columns', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_Norig_rows.htm">get_Norig_rows</a>
<ul>
<li>return = octlpsolve('get_Norig_rows', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_Nrows.htm">get_Nrows</a>
<ul>
<li>return = octlpsolve('get_Nrows', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_obj_bound.htm">get_obj_bound</a>
<ul>
<li>return = octlpsolve('get_obj_bound', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_objective.htm">get_objective</a>
<ul>
<li>return = octlpsolve('get_objective', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_orig_index.htm">get_orig_index</a>
<ul>
<li>return = octlpsolve('get_orig_index', lp,
lp_index)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_col_name.htm">get_origcol_name</a>
<ul>
<li>name = octlpsolve('get_origcol_name', lp,
column)
<li>[names] = octlpsolve('get_origcol_name', lp)
<li>In Octave, this routine has two formats. The first format is identical to the API.
The second format allows retrieving the values into an Octave matrix.</li>
</ul>
<li>
<a href="get_row_name.htm">get_origrow_name</a>
<ul>
<li>name = octlpsolve('get_origrow_name', lp,
row)
<li>[names] = octlpsolve('get_origrow_name', lp)
<li>In Octave, this routine has two formats. The first format is identical to the API.
The second format allows retrieving the values into an Octave matrix.</li>
</ul>
<li>
<a href="get_pivoting.htm">get_pivoting</a>
<ul>
<li>return = octlpsolve('get_pivoting', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_presolve.htm">get_presolve</a>
<ul>
<li>return = octlpsolve('get_presolve', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_presolveloops.htm">get_presolveloops</a>
<ul>
<li>return = octlpsolve('get_presolveloops', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_primal_solution.htm">get_primal_solution</a>
<ul>
<li>[pv, return] = octlpsolve('get_primal_solution',
lp)
<li>The <i>pv</i> argument in the
API documentation is here the first return value.
<li>The return code of the call is the second return value.</li>
</ul>
<li>
<a href="get_print_sol.htm">get_print_sol</a>
<ul>
<li>return = octlpsolve('get_print_sol', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_constraints.htm">get_ptr_constraints</a>
<ul>
<li>Not implemented.</li>
</ul>
<li>
<a href="get_sensitivity_rhs.htm">get_ptr_dualsolution</a>
<ul>
<li>Not implemented.</li>
</ul>
<li>
<a href="get_primal_solution.htm">get_ptr_primal_solution</a>
<ul>
<li>Not implemented.</li>
</ul>
<li>
<a href="get_sensitivity_obj.htm">get_ptr_sensitivity_obj, get_ptr_sensitivity_objex</a>
<ul>
<li>Not implemented.</li>
</ul>
<li>
<a href="get_sensitivity_rhs.htm">get_ptr_sensitivity_rhs</a>
<ul>
<li>Not implemented.</li>
</ul>
<li>
<a href="get_variables.htm">get_ptr_variables</a>
<ul>
<li>Not implemented.</li>
</ul>
<li>
<a href="get_rh.htm">get_rh</a>
<ul>
<li>return = octlpsolve('get_rh', lp, row)
<li>[rh] = octlpsolve('get_rh', lp)
<li>In Octave, this routine has two formats. The first format is identical to the API.
The second format allows retrieving the values into an Octave matrix.</li>
</ul>
<li>
<a href="get_rh_range.htm">get_rh_range</a>
<ul>
<li>return = octlpsolve('get_rh_range', lp, row)
<li>[rh_ranges] = octlpsolve('get_rh_range', lp)
<li>In Octave, this routine has two formats. The first format is identical to the API.
The second format allows retrieving the values into an Octave matrix.</li>
</ul>
<li>
<a href="get_row.htm">get_row</a>
<a href="get_row.htm">get_rowex</a>
<ul>
<li>[row, return] = octlpsolve('get_row', lp, row_nr)
<li>[row, return] = octlpsolve('get_rowex', lp, row_nr)
<li>The <i>row</i> argument in the
API documentation is here the first return value.
<li>In the API, element 0 is not used and values start
from element 1. In Octave, there is no unused element in the matrix.
<li>The return code of the call is the second return value.</li>
</ul>
<li>
<a href="get_row_name.htm">get_row_name</a>
<ul>
<li>name = octlpsolve('get_row_name', lp, row)
<li>[names] = octlpsolve('get_row_name', lp)
<li>In Octave, this routine has two formats. The first format is identical to the API.
The second format allows retrieving the values into an Octave matrix.</li>
</ul>
<li>
<a href="get_scalelimit.htm">get_scalelimit</a>
<ul>
<li>return = octlpsolve('get_scalelimit', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_scaling.htm">get_scaling</a>
<ul>
<li>return = octlpsolve('get_scaling', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_sensitivity_obj.htm">get_sensitivity_obj, get_sensitivity_objex</a>
<ul>
<li>[objfrom, objtill, objfromvalue, objtillvalue,
return] = octlpsolve('get_sensitivity_obj', lp)
<li>[objfrom, objtill, objfromvalue, objtillvalue,
return] = octlpsolve('get_sensitivity_objex', lp)
<li>The <i>objfrom</i>, <i>objtill</i>, <i>objfromvalue</i>, <i>objtillvalue</i> arguments in the API documentation
are here the return values. Note that Octave allows the return of fewer
variables. For example if only objfrom and objtill are needed then the
call can be [objfrom, objtill] = octlpsolve('get_sensitivity_obj',
lp). The unrequested values are even not calculated.
<li>Since the API routine doesn't calculate the <i>objtillvalue</i> value at this time, Octave always
returns a zero vector for this.
<li>The return code of the call is the last value.
<li>get_sensitivity_obj and get_sensitivity_objex are both implemented, but have the same functionality.</li>
</ul>
<li>
<a href="get_sensitivity_rhs.htm">get_sensitivity_rhs, get_sensitivity_rhsex</a>
<ul>
<li>[duals, dualsfrom, dualstill, return] =
octlpsolve('get_sensitivity_rhs', lp)
<li>[duals, dualsfrom, dualstill, return] =
octlpsolve('get_sensitivity_rhsex', lp)
<li>The <i>duals</i>, <i>dualsfrom</i>, <i>dualstill</i>
arguments in the API documentation are here the return values. Note that
Octave allows the return of fewer variables. For example if only duals is
needed then the call can be [duals] = octlpsolve('get_sensitivity_rhs',
lp). The unrequested values are even not calculated.
<li>The return code of the call is the last value.
<li>get_sensitivity_rhs and get_sensitivity_rhsex are both implemented, but have the same functionality.</li>
</ul>
<li>
<a href="get_simplextype.htm">get_simplextype</a>
<ul>
<li>return = octlpsolve('get_simplextype', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_solutioncount.htm">get_solutioncount</a>
<ul>
<li>return = octlpsolve('get_solutioncount', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_solutionlimit.htm">get_solutionlimit</a>
<ul>
<li>return = octlpsolve('get_solutionlimit', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_status.htm">get_status</a>
<ul>
<li>return = octlpsolve('get_status', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_statustext.htm">get_statustext</a>
<ul>
<li>return = octlpsolve('get_statustext', lp,
statuscode)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_timeout.htm">get_timeout</a>
<ul>
<li>return = octlpsolve('get_timeout', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_total_iter.htm">get_total_iter</a>
<ul>
<li>return = octlpsolve('get_total_iter', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_total_nodes.htm">get_total_nodes</a>
<ul>
<li>return = octlpsolve('get_total_nodes', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_upbo.htm">get_upbo</a>
<ul>
<li>return = octlpsolve('get_upbo', lp, column)
<li>[upbo] = octlpsolve('get_upbo', lp)
<li>In Octave, this routine has two formats. The first format is identical to the API.
The second format allows retrieving the values into an Octave matrix.</li>
</ul>
<li>
<a href="get_var_branch.htm">get_var_branch</a>
<ul>
<li>return = octlpsolve('get_var_branch', lp,
column)
<li>[var_branch] = octlpsolve('get_var_branch',
lp)
<li>In Octave, this routine has two formats. The first format is identical to the API.
The second format allows retrieving the values into an Octave matrix.</li>
</ul>
<li>
<a href="get_sensitivity_rhs.htm">get_var_dualresult</a>
<ul>
<li>return = octlpsolve('get_var_dualresult', lp,
index)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_primal_solution.htm">get_var_primalresult</a>
<ul>
<li>return = octlpsolve('get_var_primalresult',
lp, index)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_var_priority.htm">get_var_priority</a>
<ul>
<li>return = octlpsolve('get_var_priority', lp,
column)
<li>[var_priority] = octlpsolve('get_var_priority',
lp)
<li>In Octave, this routine has two formats. The first format is identical to the API.
The second format allows retrieving the values into an Octave matrix.</li>
</ul>
<li>
<a href="get_variables.htm">get_variables</a>
<ul>
<li>[var, return] = octlpsolve('get_variables',
lp)
<li>The <i>var</i> argument in the
API documentation is here the first return value.
<li>The return code of the call is the second return value.</li>
</ul>
<li>
<a href="get_verbose.htm">get_verbose</a>
<ul>
<li>return = octlpsolve('get_verbose', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="get_working_objective.htm">get_working_objective</a>
<ul>
<li>return = octlpsolve('get_working_objective',
lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="guess_basis.htm">guess_basis</a>
<ul>
<li>[basisvector, return] = octlpsolve('guess_basis', lp, [guessvector])
<li>In the API, element 0 of <i>guessvector</i> is not used and values start from element 1. In Octave, there is no unused element in the matrix.</li>
<li>In the API, element 0 of <i>basisvector</i> is not used and values start from element 1. In Octave, there is no unused element in the matrix.</li>
</ul>
<li>
<a href="has_BFP.htm">has_BFP</a>
<ul>
<li>return = octlpsolve('has_BFP', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="has_XLI.htm">has_XLI</a>
<ul>
<li>return = octlpsolve('has_XLI', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="is_add_rowmode.htm">is_add_rowmode</a>
<ul>
<li>return = octlpsolve('is_add_rowmode', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="is_anti_degen.htm">is_anti_degen</a>
<ul>
<li>return = octlpsolve('is_anti_degen', lp,
testmask)
<li>No special considerations.</li>
</ul>
<li>
<a href="is_binary.htm">is_binary</a>
<ul>
<li>return = octlpsolve('is_binary', lp, column)
<li>[binary] = octlpsolve('is_binary', lp)
<li>In Octave, this routine has two formats. The first format is identical to the API.
The second format allows retrieving the values into an Octave matrix.</li>
</ul>
<li>
<a href="is_break_at_first.htm">is_break_at_first</a>
<ul>
<li>return = octlpsolve('is_break_at_first', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="is_constr_type.htm">is_constr_type</a>
<ul>
<li>return = octlpsolve('is_constr_type', lp,
row, mask)
<li>No special considerations.</li>
</ul>
<li>
<a href="is_debug.htm">is_debug</a>
<ul>
<li>return = octlpsolve('is_debug', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="is_feasible.htm">is_feasible</a>
<ul>
<li>return = octlpsolve('is_feasible', lp,
[values] {, threshold})
<li>The threshold argument is optional.
When not provided, the value of <A href="get_epsint.htm">get_epsint</A> will be taken.</li>
</ul>
<li>
<a href="is_unbounded.htm">is_free</a>
<a href="is_unbounded.htm">is_unbounded</a>
<ul>
<li>return = octlpsolve('is_free', lp, column)
<li>return = octlpsolve('is_unbounded', lp, column)
<li>[free] = octlpsolve('is_free', lp)
<li>[free] = octlpsolve('is_unbounded', lp)
<li>In Octave, this routine has two formats. The first format is identical to the API.
The second format allows retrieving the values into an Octave matrix.</li>
</ul>
<li>
<a href="is_infinite.htm">is_infinite</a>
<ul>
<li>return = octlpsolve('is_infinite', lp, value)
<li>No special considerations.</li>
</ul>
<li>
<a href="is_int.htm">is_int</a>
<ul>
<li>return = octlpsolve('is_int', lp, column)
<li>[int] = octlpsolve('is_int', lp)
<li>In Octave, this routine has two formats. The first format is identical to the API.
The second format allows retrieving the values into an Octave matrix.</li>
</ul>
<li>
<a href="is_integerscaling.htm">is_integerscaling</a>
<ul>
<li>return = octlpsolve('is_integerscaling', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="is_maxim.htm">is_maxim</a>
<ul>
<li>return = octlpsolve('is_maxim', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="is_nativeBFP.htm">is_nativeBFP</a>
<ul>
<li>return = octlpsolve('is_nativeBFP', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="is_nativeXLI.htm">is_nativeXLI</a>
<ul>
<li>return = octlpsolve('is_nativeXLI', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="is_negative.htm">is_negative</a>
<ul>
<li>return = octlpsolve('is_negative', lp,
column)
<li>[negative] = octlpsolve('is_negative', lp)
<li>In Octave, this routine has two formats. The first format is identical to the API.
The second format allows retrieving the values into an Octave matrix.</li>
</ul>
<li>
<a href="is_piv_mode.htm">is_piv_mode</a>
<ul>
<li>return = octlpsolve('is_piv_mode', lp,
testmask)
<li>No special considerations.</li>
</ul>
<li>
<a href="is_piv_rule.htm">is_piv_rule</a>
<ul>
<li>return = octlpsolve('is_piv_rule', lp, rule)
<li>No special considerations.</li>
</ul>
<li>
<a href="is_presolve.htm">is_presolve</a>
<ul>
<li>return = octlpsolve('is_presolve', lp,
testmask)
<li>No special considerations.</li>
</ul>
<li>
<a href="is_scalemode.htm">is_scalemode</a>
<ul>
<li>return = octlpsolve('is_scalemode', lp,
testmask)
<li>No special considerations.</li>
</ul>
<li>
<a href="is_scaletype.htm">is_scaletype</a>
<ul>
<li>return = octlpsolve('is_scaletype', lp,
scaletype)
<li>No special considerations.</li>
</ul>
<li>
<a href="is_semicont.htm">is_semicont</a>
<ul>
<li>return = octlpsolve('is_semicont', lp,
column)
<li>[semicont] = octlpsolve('is_semicont', lp)
<li>In Octave, this routine has two formats. The first format is identical to the API.
The second format allows retrieving the values into an Octave matrix.</li>
</ul>
<li>
<a href="is_SOS_var.htm">is_SOS_var</a>
<ul>
<li>return = octlpsolve('is_SOS_var', lp, column)
<li>[SOS_var] = octlpsolve('is_SOS_var', lp)
<li>In Octave, this routine has two formats. The first format is identical to the API.
The second format allows retrieving the values into an Octave matrix.</li>
</ul>
<li>
<a href="is_trace.htm">is_trace</a>
<ul>
<li>return = octlpsolve('is_trace', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="is_use_names.htm">is_use_names</a>
<ul>
<li>return = octlpsolve('is_use_names', lp, isrow)
<li>No special considerations.</li>
</ul>
<li>
<a href="lp_solve_version.htm">lp_solve_version</a>
<ul>
<li>versionstring = octlpsolve('lp_solve_version')
<li>The octlpsolve API routine returns the version information in 4 provided argument variables while the Octave version returns the information as a string in the format major.minor.release.build</li>
</ul>
<li>
<a href="make_lp.htm">make_lp</a>
<ul>
<li>lp_handle = octlpsolve('make_lp', rows, columns)
<li>lp_handle is not a pointer to an lprec structure as in the API, but an incrementing handle number starting from 0.</li>
</ul>
<li>
<a href="print_constraints.htm">print_constraints</a>
<ul>
<li>octlpsolve('print_constraints', lp {,
columns})
<li>columns is optional. If not specified, then 1 is
used.
<li>First call set_outputfile to specify where the
information is written to. In the API documentation it is written that by
default, the output goes to stdout, but under Octave (Windows) this means
that the output is not shown.
<li>The same information can also be obtained via octlpsolve('get_constraints', lp). This shows the result on screen.</li>
</ul>
<li>
<a href="print_debugdump.htm">print_debugdump</a>
<ul>
<li>return = octlpsolve('print_debugdump', lp,
filename)
<li>No special considerations.</li>
</ul>
<li>
<a href="print_duals.htm">print_duals</a>
<ul>
<li>octlpsolve('print_duals', lp)
<li>First call set_outputfile to specify where the
information is written to. In the API documentation it is written that by
default, the output goes to stdout, but under Octave (Windows) this means
that the output is not shown.
<li>The same information can be obtained via octlpsolve('get_dual_solution', lp). This shows the result on screen.</li>
</ul>
<li>
<a href="print_lp.htm">print_lp</a>
<ul>
<li>octlpsolve('print_lp', lp)
<li>First call set_outputfile to specify where the information is written to.
In the API documentation it is written that by default, the output goes to stdout, but under Octave (Windows) this means that the output is not shown.</li>
</ul>
<li>
<a href="print_objective.htm">print_objective</a>
<ul>
<li>octlpsolve('print_objective', lp)
<li>First call set_outputfile to specify where the
information is written to. In the API documentation it is written that by
default, the output goes to stdout, but under Octave (Windows) this means
that the output is not shown.
<li>The same information can be obtained via octlpsolve('get_objective', lp). This shows the result on screen.</li>
</ul>
<li>
<a href="print_scales.htm">print_scales</a>
<ul>
<li>octlpsolve('print_scales', lp)
<li>First call set_outputfile to specify where the information is written to.
In the API documentation it is written that by default, the output goes to stdout, but under Octave (Windows) this means that the output is not shown.</li>
</ul>
<li>
<a href="print_solution.htm">print_solution</a>
<ul>
<li>octlpsolve('print_solution', lp {, columns})
<li>columns is optional. If not specified, then 1 is
used.
<li>First call set_outputfile to specify where the
information is written to. In the API documentation it is written that by
default, the output goes to stdout, but under Octave (Windows) this means
that the output is not shown.
<li>The same information can also be obtained via octlpsolve('get_variables', lp). This shows the result on screen.</li>
</ul>
<li>
<a href="print_str.htm">print_str</a>
<ul>
<li>octlpsolve('print_str', lp, str)
<li>First call set_outputfile to specify where the information is written to.
In the API documentation it is written that by default, the output goes to stdout, but under Octave (Windows) this means that the output is not shown.</li>
</ul>
<li>
<a href="print_tableau.htm">print_tableau</a>
<ul>
<li>octlpsolve('print_tableau', lp)
<li>First call set_outputfile to specify where the information is written to.
In the API documentation it is written that by default, the output goes to stdout, but under Octave (Windows) this means that the output is not shown.</li>
</ul>
<li>
<a href="put_abortfunc.htm">put_abortfunc</a>
<ul>
<li>Not implemented.</li>
</ul>
<li>
<a href="put_logfunc.htm">put_logfunc</a>
<ul>
<li>Not implemented.
<li>However, the octlpsolve driver sets a log function to redirect the output of lpsolve from stdout (which is not visible in Windows Octave) to the command window of Octave.
As such, all reported output can be seen in Octave. How much output is seen is controlled by the verbose level that can be defined by set_verbose or can be specified in the read_ routines.</li>
</ul>
<li>
<a href="put_msgfunc.htm">put_msgfunc</a>
<ul>
<li>Not implemented.</li>
</ul>
<li>
<a href="read_basis.htm">read_basis</a>
<ul>
<li>[ret, info] = octlpsolve('read_basis', lp, filename)
<li>No special considerations.</li>
</ul>
<li>
<a href="read_mps.htm">read_freemps, read_freeMPS</a>
<ul>
<li>lp_handle = octlpsolve('read_freemps', filename {,
verbose})
<li>lp_handle = octlpsolve('read_freeMPS', filename {,
verbose})
<li>In the lpsolve API, read_freemps needs a FILE
handle. In Octave it needs the filename and thus acts the same as
read_freeMPS.
<li>lp_handle is not a pointer to an lprec structure as
in the API, but an incrementing handle number starting from 0.
<li>verbose is optional. If not specified, then NORMAL is used.</li>
</ul>
<li>
<a name="read_lp"></a>
<a href="read_lp.htm">read_lp, read_LP</a>
<ul>
<li>lp_handle = octlpsolve('read_lp', filename {,
verbose {, lp_name}})
<li>lp_handle = octlpsolve('read_LP', filename {,
verbose {, lp_name}})
<li>In the lpsolve API, read_lp needs a FILE handle. In
Octave it needs the filename and thus acts the same as read_LP.
<li>lp_handle is not a pointer to an lprec structure as
in the API, but an incrementing handle number starting from 0.
<li>verbose is optional. If not provided then NORMAL is
used.
<li>lp_name is optional. If not provided then no name is given to the model ('').</li>
</ul>
<li>
<a href="read_MPS.htm">read_mps, read_MPS</a>
<ul>
<li>lp_handle = octlpsolve('read_mps', filename {,
verbose})
<li>lp_handle = octlpsolve('read_MPS', filename {,
verbose})
<li>In the lpsolve API, read_mps needs a FILE handle.
In Octave it needs the filename and thus acts the same as read_MPS.
<li>lp_handle is not a pointer to an lprec structure as
in the API, but an incrementing handle number starting from 0.
<li>verbose is optional. If not specified, then NORMAL is used.</li>
</ul>
<li>
<a href="read_params.htm">read_params</a>
<ul>
<li>return = octlpsolve('read_params', lp, filename {, options })
<li>options is optional.</li>
</ul>
<li>
<a href="read_XLI.htm">read_XLI</a>
<ul>
<li>lp_handle = octlpsolve('read_XLI', xliname,
modelname {, dataname {, options {, verbose}}}
<li>lp_handle is not a pointer to an lprec structure as
in the API, but an incrementing handle number starting from 0.
<li>dataname is optional. When not provided, '' (NULL)
is taken. '' is taken as NULL.
<li>options is optional. When not provided, '' is
taken.
<li>verbose is optional. If not specified, then NORMAL is used.</li>
</ul>
<li>
<a href="reset_basis.htm">reset_basis</a>
<ul>
<li>Not implemented.
<li>Use <A href="default_basis.htm">default_basis</A></li>
</ul>
<li>
<a href="set_basisvar.htm">set_basisvar</a>
<ul>
<li>octlpsolve('set_basisvar', lp, basisPos, enteringCol)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_add_rowmode.htm">set_add_rowmode</a>
<ul>
<li>return = octlpsolve('set_add_rowmode', lp,
turnon)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_anti_degen.htm">set_anti_degen</a>
<ul>
<li>octlpsolve('set_anti_degen', lp, anti_degen)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_basis.htm">set_basis</a>
<ul>
<li>return = octlpsolve('set_basis', lp,
[bascolumn], nonbasic)
<li>In the API, element 0 of <i>bascolumn</i> is not used and values start from element 1. In Octave, there is no unused element in the matrix.</li>
</ul>
<li>
<a href="set_basiscrash.htm">set_basiscrash</a>
<ul>
<li>octlpsolve('set_basiscrash', lp, mode)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_bb_depthlimit.htm">set_bb_depthlimit</a>
<ul>
<li>octlpsolve('set_bb_depthlimit', lp,
bb_maxlevel)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_bb_floorfirst.htm">set_bb_floorfirst</a>
<ul>
<li>octlpsolve('set_bb_floorfirst', lp,
bb_floorfirst)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_bb_rule.htm">set_bb_rule</a>
<ul>
<li>octlpsolve('set_bb_rule', lp, bb_rule)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_BFP.htm">set_BFP</a>
<ul>
<li>return = octlpsolve('set_BFP', lp, filename)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_binary.htm">set_binary</a>
<ul>
<li>return = octlpsolve('set_binary', lp, column,
must_be_bin)
<li>return = octlpsolve('set_binary', lp,
[must_be_bin])
<li>In Octave, this routine has two formats. The first format is identical to the API.
The second format allows setting a matrix of all variables.</li>
</ul>
<li>
<a href="set_bounds.htm">set_bounds</a>
<ul>
<li>return = octlpsolve('set_bounds', lp, column,
lower, upper)
<li>return = octlpsolve('set_bounds', lp,
[lower], [upper])
<li>In Octave, this routine has two formats. The first format is identical to the API.
The second format allows setting a matrix of all variables.</li>
</ul>
<li>
<a href="set_bounds_tighter.htm">set_bounds_tighter</a>
<ul>
<li>octlpsolve('set_bounds_tighter', lp, tighten)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_break_at_first.htm">set_break_at_first</a>
<ul>
<li>octlpsolve('set_break_at_first', lp,
break_at_first)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_break_at_value.htm">set_break_at_value</a>
<ul>
<li>octlpsolve('set_break_at_value', lp,
break_at_value)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_col_name.htm">set_col_name</a>
<ul>
<li>return = octlpsolve('set_col_name', lp,
column, name)
<li>return = octlpsolve('set_col_name', lp,
[names])
<li>In Octave, this routine has two formats. The first format is identical to the API.
The second format allows setting a matrix of all variables.</li>
</ul>
<li>
<a href="set_column.htm">set_column, set_columnex</a>
<ul>
<li>return = octlpsolve('set_column', lp, col_no,
[column])
<li>return = octlpsolve('set_columnex', lp,
col_no, [column])
<li>Both have the same interface from <a href="set_column.htm">set_column</a> but act as <a href="set_column.htm">set_columnex</a></li>
</ul>
<li>
<a href="set_constr_type.htm">set_constr_type</a>
<ul>
<li>return = octlpsolve('set_constr_type', lp,
row, con_type)
<li>return = octlpsolve('set_constr_type', lp,
[con_type])
<li>In Octave, this routine has two formats. The first format is identical to the API.
The second format allows setting a matrix of all rows.</li>
</ul>
<li>
<a href="set_debug.htm">set_debug</a>
<ul>
<li>octlpsolve('set_debug', lp, debug)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_epsb.htm">set_epsb</a>
<ul>
<li>octlpsolve('set_epsb', lp, epsb)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_epsd.htm">set_epsd</a>
<ul>
<li>octlpsolve('set_epsd', lp, epsd)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_epsel.htm">set_epsel</a>
<ul>
<li>octlpsolve('set_epsel', lp, epsel)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_epsint.htm">set_epsint</a>
<ul>
<li>octlpsolve('set_epsint', lp, epsint)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_epslevel.htm">set_epslevel</a>
<ul>
<li>octlpsolve('set_epslevel', lp, epslevel)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_epsperturb.htm">set_epsperturb</a>
<ul>
<li>octlpsolve('set_epsperturb', lp, epsperturb)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_epspivot.htm">set_epspivot</a>
<ul>
<li>octlpsolve('set_epspivot', lp, epspivot)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_unbounded.htm">set_free</a>
<a href="set_unbounded.htm">set_unbounded</a>
<ul>
<li>return = octlpsolve('set_free', lp, column)
<li>return = octlpsolve('set_unbounded', lp, column)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_improve.htm">set_improve</a>
<ul>
<li>octlpsolve('set_improve', lp, improve)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_infinite.htm">set_infinite</a>
<ul>
<li>octlpsolve('set_infinite', lp, infinite)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_int.htm">set_int</a>
<ul>
<li>return = octlpsolve('set_int', lp, column,
must_be_int)
<li>return = octlpsolve('set_int', lp,
[must_be_int])
<li>In Octave, this routine has two formats. The first format is identical to the API.
The second format allows setting a matrix of all variables.</li>
</ul>
<li>
<a href="set_lowbo.htm">set_lowbo</a>
<ul>
<li>return = octlpsolve('set_lowbo', lp, column,
value)
<li>return = octlpsolve('set_lowbo', lp,
[values])
<li>In Octave, this routine has two formats. The first format is identical to the API.
The second format allows setting a matrix of all variables.</li>
</ul>
<li>
<a name="set_lp_name"></a>
<a href="set_lp_name.htm">set_lp_name</a>
<ul>
<li>return = octlpsolve('set_lp_name', lp, name)
<li>In Octave, when you name a model, this name can be used everywhere where lp is specified.
This to access the model via the name instead of via a handle.</li>
</ul>
<li>
<a href="set_mat.htm">set_mat</a>
<ul>
<li>return = octlpsolve('set_mat', lp, row,
column, value)
<li>return = octlpsolve('set_mat', lp, [matrix])
<li>In Octave, this routine has two formats. The first format is identical to the API.
The second format allows to set the whole matrix (all rows/columns) at once.
This is the most performant way to provide the constraint matrix.
The matrix must be two-dimentional.</li>
</ul>
<li>
<a href="set_maxim.htm">set_maxim</a>
<ul>
<li>octlpsolve('set_maxim', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_maxpivot.htm">set_maxpivot</a>
<ul>
<li>octlpsolve('set_maxpivot', max_num_inv)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_minim.htm">set_minim</a>
<ul>
<li>octlpsolve('set_minim', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_mip_gap.htm">set_mip_gap</a>
<ul>
<li>octlpsolve('set_mip_gap', lp, absolute,
mip_gap)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_negrange.htm">set_negrange</a>
<ul>
<li>octlpsolve('set_negrange', negrange)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_obj_fn.htm">set_obj</a>
<ul>
<li>return = octlpsolve('set_obj', lp, column,
value)
<li>return = octlpsolve('set_obj', lp, [values])
<li>In Octave, this routine has two formats. The first format is identical to the API.
The second format allows setting a matrix of all variables. It is then the same as set_obj_fn</li>
</ul>
<li>
<a href="set_obj_bound.htm">set_obj_bound</a>
<ul>
<li>octlpsolve('set_obj_bound', lp, obj_bound)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_obj_fn.htm">set_obj_fn, set_obj_fnex</a>
<ul>
<li>return = octlpsolve('set_obj_fn', lp, [row])
<li>return = octlpsolve('set_obj_fnex', lp,
[row])
<li>Both have the same interface from <a href="set_obj_fn.htm">set_obj_fn</a> but act as <a href="set_obj_fn.htm">set_obj_fnex</a>
<li>In the API, element 0 is not used and values start from element 1. In Octave, there is no unused element in the matrix.</li>
</ul>
<li>
<a href="set_output.htm">set_outputfile</a>
<ul>
<li>return = octlpsolve('set_outputfile', lp,
filename)
<li>In the API description it says that setting filename to NULL results in writing output back to stdout.
In Octave under Windows, output to stdout it not shown. However it results in closing the file.
Use '' to have the effect of NULL.</li>
</ul>
<li>
<a href="set_output.htm">set_outputstream</a>
<ul>
<li>Not implemented.</li>
</ul>
<li>
<a href="set_pivoting.htm">set_pivoting</a>
<ul>
<li>octlpsolve('set_pivoting', lp, pivoting)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_preferdual.htm">set_preferdual</a>
<ul>
<li>octlpsolve('set_preferdual', lp, dodual)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_presolve.htm">set_presolve</a>
<ul>
<li>octlpsolve('set_presolve', lp, do_presolve {, maxloops})
<li>The <i>maxloops</i> argument is optional in Octave. If not provided, then infinite is used.</li>
</ul>
<li>
<a href="set_print_sol.htm">set_print_sol</a>
<ul>
<li>octlpsolve('set_print_sol', lp, print_sol)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_rh.htm">set_rh</a>
<ul>
<li>return = octlpsolve('set_rh', lp, row, value)
<li>return = octlpsolve('set_rh', lp, [values])
<li>In Octave, this routine has two formats. The first format is identical to the API.
The second format allows setting a matrix of all rows. Note that in this case, the value of row 0 is not specified in the matrix.</li>
</ul>
<li>
<a href="set_rh_range.htm">set_rh_range</a>
<ul>
<li>return = octlpsolve('set_rh_range', lp, row,
deltavalue)
<li>return = octlpsolve('set_rh_range', lp,
[deltavalues])
<li>In Octave, this routine has two formats. The first format is identical to the API.
The second format allows setting a matrix of all rows.</li>
</ul>
<li>
<a href="set_rh_vec.htm">set_rh_vec</a>
<ul>
<li>octlpsolve('set_rh_vec', lp, [rh])
<li>In the API, element 0 is not used and values start from element 1. In Octave, there is no unused element in the matrix.</li>
</ul>
<li>
<a href="set_row.htm">set_row, set_rowex</a>
<ul>
<li>return = octlpsolve('set_row', lp, row_no,
[row])
<li>return = octlpsolve('set_rowex', lp, row_no,
[row])
<li>Both have the same interface from <a href="set_row.htm">set_row</a> but act as <a href="set_row.htm">set_rowex</a>
<li>In the API, element 0 is not used and values start from element 1. In Octave, there is no unused element in the matrix.</li>
</ul>
<li>
<a href="set_row_name.htm">set_row_name</a>
<ul>
<li>return = octlpsolve('set_row_name', lp, row,
name)
<li>return = octlpsolve('set_row_name', lp,
[names])
<li>In Octave, this routine has two formats. The first format is identical to the API.
The second format allows setting a matrix of all rows.</li>
</ul>
<li>
<a href="set_scalelimit.htm">set_scalelimit</a>
<ul>
<li>octlpsolve('set_scalelimit', lp, scalelimit)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_scaling.htm">set_scaling</a>
<ul>
<li>octlpsolve('set_scaling', lp, scalemode)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_semicont.htm">set_semicont</a>
<ul>
<li>return = octlpsolve('set_semicont', lp,
column, must_be_sc)
<li>return = octlpsolve('set_semicont', lp,
[must_be_sc])
<li>In Octave, this routine has two formats. The first format is identical to the API.
The second format allows setting a matrix of all variables.</li>
</ul>
<li>
<a href="set_sense.htm">set_sense</a>
<ul>
<li>octlpsolve('set_sense', lp, maximize)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_simplextype.htm">set_simplextype</a>
<ul>
<li>octlpsolve('set_simplextype', lp,
simplextype)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_solutionlimit.htm">set_solutionlimit</a>
<ul>
<li>octlpsolve('set_solutionlimit', lp,
simplextype)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_timeout.htm">set_timeout</a>
<ul>
<li>octlpsolve('set_timeout', lp, sectimeout)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_trace.htm">set_trace</a>
<ul>
<li>octlpsolve('set_trace', lp, trace)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_upbo.htm">set_upbo</a>
<ul>
<li>return = octlpsolve('set_upbo', lp, column,
value)
<li>return = octlpsolve('set_upbo', lp, [values])
<li>In Octave, this routine has two formats. The first format is identical to the API.
The second format allows setting a matrix of all variables.</li>
</ul>
<li>
<a href="set_use_names.htm">set_use_names</a>
<ul>
<li>octlpsolve('set_use_names', lp, isrow, use_names)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_var_branch.htm">set_var_branch</a>
<ul>
<li>return = octlpsolve('set_var_branch', lp,
column, branch_mode)
<li>return = octlpsolve('set_var_branch', lp,
[branch_mode])
<li>In Octave, this routine has two formats. The first format is identical to the API.
The second format allows setting a matrix of all variables.</li>
</ul>
<li>
<a href="set_var_weights.htm">set_var_weights</a>
<ul>
<li>return = octlpsolve('set_var_weights', lp,
[weights])
<li>No special considerations.</li>
</ul>
<li>
<a href="set_verbose.htm">set_verbose</a>
<ul>
<li>octlpsolve('set_verbose', lp, verbose)
<li>No special considerations.</li>
</ul>
<li>
<a href="set_XLI.htm">set_XLI</a>
<ul>
<li>return = octlpsolve('set_XLI', lp, filename)
<li>No special considerations.</li>
</ul>
<li>
<a href="solve.htm">solve</a>
<ul>
<li>result = octlpsolve('solve', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="add_column.htm">str_add_column</a>
<ul>
<li>Not implemented.</li>
</ul>
<li>
<a href="add_constraint.htm">str_add_constraint</a>
<ul>
<li>Not implemented.</li>
</ul>
<li>
<a href="set_obj_fn.htm">str_set_obj_fn</a>
<ul>
<li>Not implemented.</li>
</ul>
<li>
<a href="set_rh_vec.htm">str_set_rh_vec</a>
<ul>
<li>Not implemented.</li>
</ul>
<li>
<a href="time_elapsed.htm">time_elapsed</a>
<ul>
<li>return = octlpsolve('time_elapsed', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="unscale.htm">unscale</a>
<ul>
<li>octlpsolve('unscale', lp)
<li>No special considerations.</li>
</ul>
<li>
<a href="write_basis.htm">write_basis</a>
<ul>
<li>octlpsolve('write_basis', lp, filename)
<li>No special considerations.</li>
</ul>
<li>
<a href="write_mps.htm">write_freemps, write_freeMPS</a>
<ul>
<li>return = octlpsolve('write_freemps', lp,
filename)
<li>return = octlpsolve('write_freeMPS', lp,
filename)
<li>In the lpsolve API, write_freeMPS needs a FILE handle. In Octave it needs the filename and thus acts the same as write_freemps.</li>
</ul>
<li>
<a href="write_lp.htm">write_lp, write_LP</a>
<ul>
<li>return = octlpsolve('write_lp', lp, filename)
<li>return = octlpsolve('write_LP', lp, filename)
<li>In the lpsolve API, write_LP needs a FILE handle. In Octave it needs the filename and thus acts the same as write_lp.</li>
</ul>
<li>
<a href="write_mps.htm">write_mps, write_MPS</a>
<ul>
<li>return = octlpsolve('write_mps', lp,
filename)
<li>return = octlpsolve('write_MPS', lp,
filename)
<li>In the lpsolve API, write_MPS needs a FILE handle.
In Octave it needs the filename and thus acts the same as write_mps.
<li>No special considerations.</li>
</ul>
<li>
<a href="write_XLI.htm">write_XLI</a>
<ul>
<li>return = octlpsolve('write_XLI', lp, filename
{, options {, results}})
<li>No special considerations.</li>
</ul>
</li>
</ul>
<a name="Extra_Octave_routines"></a>
<h3>Extra Octave routines</h3>
<p>These routines are not part of the lpsolve API, but are added for backwards compatibility.
Most of them exist in the lpsolve API with another name.</p>
<ul>
<li>[names] = octlpsolve('get_col_names', lp)
<ul>
<li>The same as get_col_name. Implemented for backwards compatibility.</li>
</ul>
<li>[constr_type] = octlpsolve('get_constr_types', lp)
<ul>
<li>The same as get_constr_type. Implemented for backwards compatibility.</li>
</ul>
<li>[int] = octlpsolve('get_int', lp)
<ul>
<li>The same as is_int. Implemented for backwards compatibility.</li>
</ul>
<li>return = octlpsolve('get_no_cols', lp)
<ul>
<li>The same as get_Ncolumns. Implemented for backwards compatibility.</li>
</ul>
<li>return = octlpsolve('get_no_rows', lp)
<ul>
<li>The same as get_Nrows. Implemented for backwards compatibility.</li>
</ul>
<li>name = octlpsolve('get_objective_name', lp)
<ul>
<li>The same as get_row_name with row=0. Implemented for backwards compatibility.</li>
</ul>
<li>[row_vec, return] = octlpsolve('get_obj_fn', lp)<br>
[row_vec, return] =
octlpsolve('get_obj_fun', lp)
<ul>
<li>The same as get_row with row 0. Implemented for backwards compatibility.</li>
</ul>
<li>name = octlpsolve('get_problem_name', lp)
<ul>
<li>The same as get_lp_name. Implemented for backwards compatibility.</li>
</ul>
<li>[costs] = octlpsolve('get_reduced_costs', lp)
<ul>
<li>The same as get_dual_solution. Implemented for backwards compatibility.</li>
</ul>
<li>[names] = octlpsolve('get_row_names', lp)
<ul>
<li>The same as get_row_name. Implemented for backwards compatibility.</li>
</ul>
<li>[obj, x, duals, return] = octlpsolve('get_solution', lp)
<ul>
<li>Returns the value of the objective function, the
values of the variables and the duals. Implemented for backwards
compatibility.
<li>The return code of the call is the last value.</li>
</ul>
<li>value = octlpsolve('mat_elm', lp)
<ul>
<li>The same as get_mat. Implemented for backwards compatibility.</li>
</ul>
<li>[handle_vec] = octlpsolve('print_handle')
<ul>
<li>Returns a vector with open handles.
Can be handy to see which handles aren't closed yet with delete_lp or free_lp.</li>
</ul>
<li>lp_handle = octlpsolve('read_lp_file', filename {, verbose {, lp_name}})
<ul>
<li>The same as read_LP. Implemented for backwards compatibility.</li>
</ul>
</li>
<li><a name="get_handle"></a>
lp_handle = octlpsolve('get_handle', lp_name)
<ul>
<li>Get the handle for this model from the models name.
If an unknown model name is given (or already deleted), -1 is returned.
</li>
</ul>
</li>
</ul>
<a name="Compile_the_octlpsolve_driver"></a>
<h3>Compile the octlpsolve driver</h3>
<h4>Windows</h4>
To compile the Octave driver under Windows, the cygwin environment is needed. The following document describes
what is needed for this: <a href="ftp://ftp.octave.org/pub/octave/README.Windows">README.Windows</a>. It may not
be needed to build the Octave sources to compile the binary file, but the proposed cygwin and octave packages
are needed to build a .oct file.<br>
The build must be done from the cygwin prompt from the directory where the lpsolve octave files are located.<br>
To make the compilation process easier, a script file can be used: ccc.win32<br>
To make for release, just enter ./ccc.win32 and everything is build.<br>
<h4>Unix/Linux</h4>
The build must be done from a shell prompt from the directory where the lpsolve octave files are located.<br>
To make the compilation process easier, a script file can be used: ccc<br>
To make for release, just enter sh ccc and everything is build.<br>
<h4>All platforms</h4>
This compiles three source files: lpsolve.cpp, octave.cpp and hash.cpp<br>
Then these are linked together to generate the octlpsolve.oct file.<br>
The optional arguments to ccc are used for development. Source files can be provided
and then only these are compiled. For example hash.cpp should only be compiled
once while developing. So specifying lpsolve.cpp as first argument will only
compile this file and then link everything. This makes the build process a bit
faster. Also the option -DDEMO can be added to add the demo command to test some
functionality of lpsolve. This is also only for debugging. Also the option
-DDEBUG can be added. This to print some debug information while executing
octlpsolve. Should only be used for debugging purposes.
<P></P>
<p>See also <a href="O-Matrix.htm">Using lpsolve from O-Matrix</a>,
<a href="MATLAB.htm">Using lpsolve from MATLAB</a>,
<a href="Scilab.htm">Using lpsolve from Scilab</a>,
<a href="Python.htm">Using lpsolve from Python</a>,
<a href="R.htm">Using lpsolve from R</a>
</p>
</BODY>
</html>
|