{"id":498,"date":"2009-01-04T22:20:34","date_gmt":"2009-01-05T02:20:34","guid":{"rendered":"http:\/\/mat.tepper.cmu.edu\/blog\/?p=498"},"modified":"2009-01-04T22:20:34","modified_gmt":"2009-01-05T02:20:34","slug":"bugs-and-modeling","status":"publish","type":"post","link":"https:\/\/mat.tepper.cmu.edu\/blog\/index.php\/2009\/01\/04\/bugs-and-modeling\/","title":{"rendered":"Bugs and Modeling"},"content":{"rendered":"<p>The web was <a href=\"http:\/\/www.sfgate.com\/cgi-bin\/article.cgi?f=\/c\/a\/2008\/12\/31\/BUV91525C0.DTL\">all abuzz on December 31<\/a> as the 30Gig version of the Microsoft Zune players all stopped working.\u00a0 What was up?\u00a0 Was it a terrorist attack?\u00a0 Solar flares?\u00a0 A weird Y2K bug almost a decade later?<\/p>\n<p>The truth is a bit prosaic:\u00a0 there was simply a bug related to leap years.\u00a0 Since the Zune was not around four years ago, 2008 was the first time for the bug to show itself.\u00a0 There are descriptions of the bug in numerous places:\u00a0 <a href=\"http:\/\/www.aeroxp.org\/2009\/01\/lesson-on-infinite-loops\/\">here is one<\/a> if you haven&#8217;t seen it yet.\u00a0 Bottom line:\u00a0 a section of code for converting &#8220;days since January 1, 1980&#8221; (when the universe was created) to years, months, and days didn&#8217;t correctly handle a leap year, leading to an infinite loop.<\/p>\n<p>It is easy to laugh at such a mistake:\u00a0 why didn&#8217;t a code review or unit testing catch such a simple mistake?\u00a0 But, it seems, such &#8220;simple&#8221; parts of the code seem the ones most likely not to get tested.\u00a0 When you have to test all sorts of complicated things like checking authorization, playing music, handling the interface and so on, who expects problems in a date calculation?\u00a0 And hence a zillion Zunes fail for a day.<\/p>\n<figure id=\"attachment_499\" aria-describedby=\"caption-attachment-499\" style=\"width: 135px\" class=\"wp-caption alignleft\"><a href=\"https:\/\/fac-mtrick02.tepper.cmu.edu\/blog\/wp-content\/uploads\/2009\/01\/embarrassment.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-499\" title=\"embarrassment\" src=\"https:\/\/fac-mtrick02.tepper.cmu.edu\/blog\/wp-content\/uploads\/2009\/01\/embarrassment.gif\" alt=\"Ooops!\" width=\"135\" height=\"126\" \/><\/a><figcaption id=\"caption-attachment-499\" class=\"wp-caption-text\">Ooops!<\/figcaption><\/figure>\n<p>I experienced something similar when I was reviewing some code I use to create a sports schedule.\u00a0 Never mind the sport:\u00a0 it doesn&#8217;t matter.\u00a0 But the model I created aimed to have a large number of a particular type game on a particular week.\u00a0 And, for the last few years, we didn&#8217;t get a lot of those games on that week.\u00a0 This didn&#8217;t particularly worry me:\u00a0 there are a lot of constraints that interact in complicated ways, so I assumed the optimization was right in claiming the best number was the one we got (and this was one of the less important parts of the objective).\u00a0 But when I looked at the code recently, I realized there was an &#8220;off by one&#8221; error in my logic, and sure enough the previous week had a full slate of the preferred games.\u00a0 Right optimization, wrong week.\u00a0 Dang!<\/p>\n<p>So one of my goals this week, before class starts is to relook at the code with fresh eyes and see what other errors I can find. \u00a0\u00a0 There are some things I can do to help find such bugs, like trying it on small instances and turning on and off various constraint types, but one difficult aspect of optimization is that knowing the optimal solution requires &#8230; optimization, making it very hard to find these sorts of bugs.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The web was all abuzz on December 31 as the 30Gig version of the Microsoft Zune players all stopped working.\u00a0 What was up?\u00a0 Was it a terrorist attack?\u00a0 Solar flares?\u00a0 A weird Y2K bug almost a decade later? The truth is a bit prosaic:\u00a0 there was simply a bug related to leap years.\u00a0 Since the &hellip; <a href=\"https:\/\/mat.tepper.cmu.edu\/blog\/index.php\/2009\/01\/04\/bugs-and-modeling\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Bugs and Modeling&#8221;<\/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":[12,51],"tags":[],"class_list":["post-498","post","type-post","status-publish","format-standard","hentry","category-computing","category-sports"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/mat.tepper.cmu.edu\/blog\/index.php\/wp-json\/wp\/v2\/posts\/498","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mat.tepper.cmu.edu\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mat.tepper.cmu.edu\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mat.tepper.cmu.edu\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mat.tepper.cmu.edu\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=498"}],"version-history":[{"count":0,"href":"https:\/\/mat.tepper.cmu.edu\/blog\/index.php\/wp-json\/wp\/v2\/posts\/498\/revisions"}],"wp:attachment":[{"href":"https:\/\/mat.tepper.cmu.edu\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=498"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mat.tepper.cmu.edu\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=498"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mat.tepper.cmu.edu\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=498"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}