{"id":94,"date":"2016-10-23T23:32:19","date_gmt":"2016-10-23T23:32:19","guid":{"rendered":"http:\/\/www.aarondefazio.com\/tangentially\/?p=94"},"modified":"2016-10-23T23:32:19","modified_gmt":"2016-10-23T23:32:19","slug":"everything-is-easy-in-low-dimensions-part-1-linear-programming","status":"publish","type":"post","link":"https:\/\/www.aarondefazio.com\/tangentially\/?p=94","title":{"rendered":"Everything is Easy in Low Dimensions (Part 1): Linear Programming"},"content":{"rendered":"<p><!--l. 21--><\/p>\n<p class=\"noindent\" >I recently came across this remarkable randomized algorithm due to Seidel<br \/>\n(1991) for linear programming in 2 dimensions that takes only time<br \/>\n<!--l. 23--><math \n xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"  \ndisplay=\"inline\" ><mi \n>O<\/mi><mrow ><mo \nclass=\"MathClass-open\">(<\/mo><mrow><mi \n>n<\/mi><\/mrow><mo \nclass=\"MathClass-close\">)<\/mo><\/mrow><\/math> for<br \/>\n<!--l. 23--><math \n xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"  \ndisplay=\"inline\" ><mi \n>n<\/mi><\/math><br \/>\nconstraints (in expectation). It&#x2019;s de\ufb01nitely worth a close inspection, so I thought I<br \/>\nwould write a short article about it.\n<\/p>\n<p><!--l. 27--><\/p>\n<p class=\"indent\" >   Note that my presentation of this algorithm assumes that there are no redundant<br \/>\nor colinear constraints, that the solution is bounded, and that the solution for each<br \/>\nsubproblem encountered is unique. These assumptions are easy to remove<br \/>\nwithout slowing the algorithm down, but they complicate the presentation a<br \/>\nlittle.\n<\/p>\n<p><!--l. 53--><\/p>\n<p class=\"indent\" >\n<div class=\"minipage\"><span \nclass=\"eccc-1000\"><span \nclass=\"small-caps\">F<\/span><span \nclass=\"small-caps\">U<\/span><span \nclass=\"small-caps\">N<\/span><span \nclass=\"small-caps\">C<\/span><span \nclass=\"small-caps\">T<\/span><span \nclass=\"small-caps\">I<\/span><span \nclass=\"small-caps\">O<\/span><span \nclass=\"small-caps\">N<\/span> <\/span>lpsolve<br \/>\n<!--l. 53--><\/p>\n<p class=\"noindent\" ><span \nclass=\"eccc-1000\"><span \nclass=\"small-caps\">I<\/span><span \nclass=\"small-caps\">N<\/span><span \nclass=\"small-caps\">P<\/span><span \nclass=\"small-caps\">U<\/span><span \nclass=\"small-caps\">T<\/span><\/span>: Set <!--l. 53--><math \n xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"  \ndisplay=\"inline\" ><mi \n>H<\/mi><\/math><br \/>\nof constraints &#x0026; vector <!--l. 53--><math \n xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"  \ndisplay=\"inline\" ><mi \n>c<\/mi><\/math>.\n<\/p>\n<p><!--l. 53--><\/p>\n<p class=\"noindent\" ><span \nclass=\"eccc-1000\"><span \nclass=\"small-caps\">O<\/span><span \nclass=\"small-caps\">U<\/span><span \nclass=\"small-caps\">T<\/span><span \nclass=\"small-caps\">P<\/span><span \nclass=\"small-caps\">U<\/span><span \nclass=\"small-caps\">T<\/span><\/span>: A point <!--l. 53--><math \n xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"  \ndisplay=\"inline\" ><mi \n>v<\/mi><\/math><br \/>\nin the polytope de\ufb01ned by <!--l. 53--><math \n xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"  \ndisplay=\"inline\" ><mi \n>H<\/mi><\/math><br \/>\nminimizing <!--l. 53--><math \n xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"  \ndisplay=\"inline\" ><msup><mrow \n><mi \n>c<\/mi><\/mrow><mrow \n><mi \n>T<\/mi><\/mrow><\/msup \n><mi \n>v<\/mi><\/math>.\n<\/p>\n<p><!--l. 53--><\/p>\n<p class=\"noindent\" ><span \nclass=\"eccc-1000\">B<span \nclass=\"small-caps\">A<\/span><span \nclass=\"small-caps\">S<\/span><span \nclass=\"small-caps\">E<\/span>                                       C<span \nclass=\"small-caps\">A<\/span><span \nclass=\"small-caps\">S<\/span><span \nclass=\"small-caps\">E<\/span>:                                     <\/span>If<br \/>\n<!--l. 53--><math \n xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"  \ndisplay=\"inline\" ><mo \nclass=\"MathClass-rel\">|<\/mo><mi \n>H<\/mi><mo \nclass=\"MathClass-rel\">|<\/mo> <mo \nclass=\"MathClass-rel\">=<\/mo> <mn>2<\/mn><\/math><br \/>\nthen return the unique intersecting point.\n<\/p>\n<p><!--l. 53--><\/p>\n<p class=\"noindent\" ><span \nclass=\"eccc-1000\">N<span \nclass=\"small-caps\">O<\/span><span \nclass=\"small-caps\">N<\/span> <span \nclass=\"small-caps\">B<\/span><span \nclass=\"small-caps\">A<\/span><span \nclass=\"small-caps\">S<\/span><span \nclass=\"small-caps\">E<\/span> C<span \nclass=\"small-caps\">A<\/span><span \nclass=\"small-caps\">S<\/span><span \nclass=\"small-caps\">E<\/span>:<\/span>\n       <\/p>\n<ol  class=\"enumerate1\" >\n<li \n  class=\"enumerate\" id=\"x1-3x1\">Pick a constraint <!--l. 53--><math \n xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"  \ndisplay=\"inline\" ><mi \n>B<\/mi><\/math><br \/>\n      uniformly at random from <!--l. 53--><math \n xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"  \ndisplay=\"inline\" ><mi \n>H<\/mi><\/math>.\n        <\/li>\n<li \n  class=\"enumerate\" id=\"x1-5x2\"><!--l. 53--><math \n xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"  \ndisplay=\"inline\" ><msup><mrow \n><mi \n>v<\/mi><\/mrow><mrow \n><mi \n>\u2032<\/mi><\/mrow><\/msup \n><\/math><br \/>\n    = lpsolve(<!--l. 53--><math \n xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"  \ndisplay=\"inline\" ><mi \n>H<\/mi> <mo \nclass=\"MathClass-bin\">\u2212<\/mo><mfenced separators=\"\" \nopen=\"{\"  close=\"}\" ><mrow><mi \n>B<\/mi><\/mrow><\/mfenced><\/math>,<br \/>\n        <!--l. 53--><math \n xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"  \ndisplay=\"inline\" ><mi \n>c<\/mi><\/math>).\n        <\/li>\n<li \n  class=\"enumerate\" id=\"x1-7x3\">If <!--l. 53--><math \n xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"  \ndisplay=\"inline\" ><msup><mrow \n><mi \n>v<\/mi><\/mrow><mrow \n><mi \n>\u2032<\/mi><\/mrow><\/msup \n><\/math><br \/>\n    is in the half-space de\ufb01ned by <!--l. 53--><math \n xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"  \ndisplay=\"inline\" ><mi \n>B<\/mi><\/math><br \/>\n      <span \nclass=\"eccc-1000\"><span \nclass=\"small-caps\">R<\/span><span \nclass=\"small-caps\">E<\/span><span \nclass=\"small-caps\">T<\/span><span \nclass=\"small-caps\">U<\/span><span \nclass=\"small-caps\">R<\/span><span \nclass=\"small-caps\">N<\/span> <\/span><!--l. 53--><math \n xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"  \ndisplay=\"inline\" ><mi \n>v<\/mi> <mo \nclass=\"MathClass-rel\">=<\/mo> <msup><mrow \n><mi \n>v<\/mi><\/mrow><mrow \n><mi \n>\u2032<\/mi><\/mrow><\/msup \n><\/math>,<br \/>\n        otherwise:\n        <\/li>\n<li \n  class=\"enumerate\" id=\"x1-9x4\"><span \nclass=\"eccc-1000\"><span \nclass=\"small-caps\">R<\/span><span \nclass=\"small-caps\">E<\/span><span \nclass=\"small-caps\">T<\/span><span \nclass=\"small-caps\">U<\/span><span \nclass=\"small-caps\">R<\/span><span \nclass=\"small-caps\">N<\/span> <\/span><!--l. 53--><math \n xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"  \ndisplay=\"inline\" ><mi \n>v<\/mi><\/math>,<br \/>\n        the   solution   of   the   1D   LP   consisting   of   the   projection   of<br \/>\n        <!--l. 53--><math \n xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"  \ndisplay=\"inline\" ><mi \n>H<\/mi><\/math><br \/>\n      <!--l. 53--><math \n xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"  \ndisplay=\"inline\" ><mi \n>&#x0026;<\/mi><\/math><br \/>\n       <!--l. 53--><math \n xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"  \ndisplay=\"inline\" ><mi \n>c<\/mi><\/math><br \/>\n      onto <!--l. 53--><math \n xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"  \ndisplay=\"inline\" ><mi \n>B<\/mi><\/math>.<\/li>\n<\/ol><\/div>\n<p><!--l. 55--><\/p>\n<p class=\"indent\" >   This algorithm is quite remarkable in its simplicity. It takes the<br \/>\nform of an recursive algorithm, where we solve a base case, then add<\/p>\n<p>additional constraints 1 at a time. Every time we add a constraint,<br \/>\nwe consider if it changes the solution. It&#x2019;s only when the old solution<br \/>\n<!--l. 59--><math \n xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"  \ndisplay=\"inline\" ><msup><mrow \n><mi \n>v<\/mi><\/mrow><mrow \n><mi \n>\u2032<\/mi><\/mrow><\/msup \n><\/math> is outside<br \/>\nthe added constraint that we have to do any work, namely solving a simple 1D LP, which<br \/>\nis trivially <!--l. 60--><math \n xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"  \ndisplay=\"inline\" ><mi \n>O<\/mi><mrow ><mo \nclass=\"MathClass-open\">(<\/mo><mrow><mi \n>m<\/mi><\/mrow><mo \nclass=\"MathClass-close\">)<\/mo><\/mrow><\/math><br \/>\ntime for <!--l. 61--><math \n xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"  \ndisplay=\"inline\" ><mi \n>m<\/mi><\/math><br \/>\nconstraints.\n<\/p>\n<p><!--l. 63--><\/p>\n<p class=\"indent\" >   If we had to solve the 1D LP subproblem at every<br \/>\nstep the algorithm would have quadratic running time<br \/>\n<!--l. 64--><math \n xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"  \ndisplay=\"inline\" ><mrow ><mo \nclass=\"MathClass-open\">(<\/mo><mrow><msubsup><mrow \n><mo \nclass=\"MathClass-op\">\u2211<\/mo>\n  <!--nolimits--><\/mrow><mrow \n><mi \n>i<\/mi><mo \nclass=\"MathClass-rel\">=<\/mo><mn>1<\/mn><\/mrow><mrow \n><mi \n>n<\/mi><\/mrow><\/msubsup \n><mi \n>i<\/mi> <mo \nclass=\"MathClass-rel\">=<\/mo> <mi \n>O<\/mi><mrow ><mo \nclass=\"MathClass-open\">(<\/mo><mrow><msup><mrow \n><mi \n>n<\/mi><\/mrow><mrow \n><mn>2<\/mn><\/mrow><\/msup \n><\/mrow><mo \nclass=\"MathClass-close\">)<\/mo><\/mrow><\/math>). We avoid this because<br \/>\nwe pick the constraint <!--l. 65--><math \n xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"  \ndisplay=\"inline\" ><mi \n>B<\/mi><\/math><br \/>\nto recurse on at each step randomly. Clearly we only have to solve that 1D LP if the<br \/>\nrandomly chosen constraint B forms part of the new solution to the problem (ignoring<br \/>\ndegenerate solutions), and since a solution is the intersection of 2 constraints, there is<br \/>\nonly a <!--l. 69--><math \n xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"  \ndisplay=\"inline\" ><mn>2<\/mn><\/math> in<br \/>\n<!--l. 69--><math \n xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"  \ndisplay=\"inline\" ><mo \nclass=\"MathClass-rel\">|<\/mo><mi \n>H<\/mi><mo \nclass=\"MathClass-rel\">|<\/mo><\/math><br \/>\nchance that we randomly pick such a constraint.\n<\/p>\n<p><!--l. 72--><\/p>\n<p class=\"indent\" >   It follows that the cost of each recursion in expectation is<br \/>\n<!--l. 72--><math \n xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"  \ndisplay=\"inline\" ><mo \nclass=\"MathClass-rel\">|<\/mo><mi \n>H<\/mi><mo \nclass=\"MathClass-rel\">|<\/mo><\/math> times<br \/>\n<!--l. 73--><math \n xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"  \ndisplay=\"inline\" ><mn>2<\/mn><mo \nclass=\"MathClass-bin\">\u2215<\/mo><mo \nclass=\"MathClass-rel\">|<\/mo><mi \n>H<\/mi><mo \nclass=\"MathClass-rel\">|<\/mo><\/math> which is just 2,<br \/>\nand we recurse <!--l. 73--><math \n xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"  \ndisplay=\"inline\" ><mi \n>n<\/mi><\/math><br \/>\ntimes, giving us a <!--l. 74--><math \n xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"  \ndisplay=\"inline\" ><mi \n>O<\/mi><mrow ><mo \nclass=\"MathClass-open\">(<\/mo><mrow><mi \n>n<\/mi><\/mrow><mo \nclass=\"MathClass-close\">)<\/mo><\/mrow><\/math><br \/>\nrunning time in expectation.\n<\/p>\n<p><!--l. 76--><\/p>\n<p class=\"indent\" >   In the original presentation by Seidel, the algorithm is given in<br \/>\na general form, usable in higher dimensions as well. The di\ufb03culty<br \/>\nis that the running time quickly gets out of hand as the dimension<br \/>\n<!--l. 79--><math \n xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"  \ndisplay=\"inline\" ><mi \n>d<\/mi><\/math><br \/>\nincreases. The main obstacle is step 4 above, you essentially need to solve a<br \/>\n<!--l. 80--><math \n xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"  \ndisplay=\"inline\" ><mi \n>d<\/mi> <mo \nclass=\"MathClass-bin\">\u2212<\/mo> <mn>1<\/mn><\/math><br \/>\ndimensional LP, which is only slightly easier than your original LP in higher<br \/>\ndimensions.\n<\/p>\n<p><!--l. 83--><\/p>\n<p class=\"indent\" >   On a side note, there is an interesting discussion of this algorithm and related<br \/>\nones in the Wikipedia page for <a \nhref=\"https:\/\/en.wikipedia.org\/wiki\/LP-type_problem\" >LP-type problems<\/a>.\n<\/p>\n<h5 class=\"likesubsubsectionHead\"><a \n id=\"x1-1000\"><\/a>References<\/h5>\n<p><!--l. 89--><\/p>\n<p class=\"noindent\" >Seidel, Raimund (1991), &#x0022;Small-dimensional linear programming and convex<br \/>\nhulls made easy&#x0022;, Discrete and Computational Geometry, 6 (5): 423\u2013434<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I recently came across this remarkable randomized algorithm due to Seidel (1991) for linear programming in 2 dimensions that takes only time O(n) for n constraints (in expectation). It&#x2019;s de\ufb01nitely worth a close inspection, so I thought I would write a short article about it. Note that my presentation of this algorithm assumes that there &hellip; <a href=\"https:\/\/www.aarondefazio.com\/tangentially\/?p=94\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Everything is Easy in Low Dimensions (Part 1): Linear Programming<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.aarondefazio.com\/tangentially\/index.php?rest_route=\/wp\/v2\/posts\/94"}],"collection":[{"href":"https:\/\/www.aarondefazio.com\/tangentially\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.aarondefazio.com\/tangentially\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.aarondefazio.com\/tangentially\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.aarondefazio.com\/tangentially\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=94"}],"version-history":[{"count":2,"href":"https:\/\/www.aarondefazio.com\/tangentially\/index.php?rest_route=\/wp\/v2\/posts\/94\/revisions"}],"predecessor-version":[{"id":96,"href":"https:\/\/www.aarondefazio.com\/tangentially\/index.php?rest_route=\/wp\/v2\/posts\/94\/revisions\/96"}],"wp:attachment":[{"href":"https:\/\/www.aarondefazio.com\/tangentially\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=94"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.aarondefazio.com\/tangentially\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=94"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.aarondefazio.com\/tangentially\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=94"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}