Skip to main content

My Journey

[Originally posted here]

Like many people, this is not the first time I take Discrete Optimization.

I stumbled upon this course in 2013 and found it very interesting. I finished Knapsack without much problem and felt pretty good about myself. Then Graph Coloring beat me. My homegrown CP solver had serious bugs: I probably missed something important in the lecture. I thought to myself, "This is problem 2 and I'm already in deep s**t?!" Between a full-time job and a 9-month-old baby, I painfully realized that I could never finish it. I felt defeated, no, humiliated.

In 2014, I quickly dismissed the idea of taking this course again because I was way too busy to spare the amount of effort needed for this course.

This year, I made sure that I had the time for this course and started my journey of redemption.

Let me state my problem first:

minimize the amount of effort I spend 
subject to getting 10s for all problems that count toward the final grade 

As you can immediately see, I won't touch Set Cover although it looks really interesting. And I won't work towards improving my leader board position or program running time once I've passed 10-point line for that problem.

Naturally my weapon of choice is Local Search (LS). ("If you want guarantee, buy a toaster." has become my favorite Clint Eastwood quote.) And my programming language is C++. (Starting with Python was one of the mistakes I made in 2013.)

Now here is a laundry list of what worked for me for each assignment. You can skip it if you are not interested in technical details:

  • Knapsack
    • Dynamic Programming for smaller problems and Branch-and-Bound for larger ones;
    • Just follow the lectures as the solution has been "spoon-fed" to you.
  • Graph Coloring
    • The \sum 2 * |B| * |C| - |C|^2 objective from the lecture + Tabu Search (TS) worked like magic;
    • I got all 10s just by running it a bit longer.
  • Traveling Salesman
    • k-Opt neighbourhood as described in the lecture + Simulated Annealing (SA) for most of problems; 
    • For the infamous Problem 6, 2-Opt + Guided Fast Local Search (GFLS) for the win!
    • I tried k-Opt + TS first but couldn't get it to work;
    • For some problems I needed to tune the k (in k-Opt) and SA parameters (starting temperature, annealing speed) more carefully to pass the 10-point line;
    • I also tried a simple CP model but couldn't get it to work on even the smallest problem;
    • I also tried Large Neighbourhood Search with an MIP model which rearrange a small part of the whole tour; it worked for some mid-sized problems but not enough to tackle Problem 6;
    • TSP Problem 6 was the last problem I ever cracked; I'm going to buy myself a T-shirt to celebrate.
  • Facility Location
    • Large Neighbourhood Search (LNS) with a Mixed Integer Programming (MIP) model of adjacent facilities of a random facility and their current customers worked amazingly;
    • I tried simple neighbourhoods (reassignment, swap and open/close facility) + SA first but couldn't cross the 10-point line for the two harder problems (5 & 7, I think);
    • Inspired by Graph Coloring, I tried to enlarge the neighbourhood by allowing infeasible moves and penalizing constraint violation but couldn't get it to work;
    • I'm impressed with SA's ability to turn weak neighbourhoods into something usable.
  • Vehicle Routing
    • LNS + an MIP model of two random vehicles did the trick again; for smaller problems, simple neighbourhoods (reassignment, swap and k-Opt) + SA worked too;
    • I figured out an interesting way to break symmetry in my MIP model, which I shared in the forum;
    • As noted by many fellow students, the bars for this assignment seemed to be lower than previous ones; maybe to give us a little break? :)
Because of my choice of LS, most of my solvers are written from scratch so I don't have much experience with general purpose tools. But I do want to say a few words on tools. 

I don't quite understand the rationale of not recommending some good tools (to reduce the search space, if you will) but it did make it harder for me to try MIP and CP. From my limited experience, Gurobi is great for MIP and Google or-tools is good for CP. Both of them have a clean API and are well-documented, which means they are very easy to learn. The only problem I had was that I only had a limited license for Gurobi which limits the size of the problems to 2000 variables and 2000 constraints. However, it wasn't so bad because LNS worked really well.

In contrast, I wasted a lot of time on CBC. I'm sure an expert user can use CBC much better than I did but I just didn't have the time (or patience). It's a shame that I didn't have the chance to use or-tools, or CP in general, since most of the assignments don't seem to have very complex constraints. But next time I need to solve a problem with CP, I know where to start.

I couldn't have done it without the following:
  • My fellow students Andrew, Lukas, Nils, Adriel and others for sharing their successes and failures on the Discussion Forums;
  • Assignment Visualization tool is extremely useful for discovering problem structures that you have previously missed. As a concrete example, one of the insights I got from visualizing VRP led me to a better greedy solver that halved the cost of Problem 5, thus giving the subsequent LS solver much better starting point.
Finally, I want to thank Prof. van Hentenryck and TAs for creating such a fantastic course! It was super challenging but once you climb it, you'll get to a beautiful spot!

Now let me have a Duchesse de Bourgogne beer with some of my favorite Neuhaus chocolate. I earned it. :)

To my fellow students: Succes! Bonne chance! Viel glück!


Comments

Popular posts from this blog

The Analects of Confucius

As many people point out, it takes perseverance, patience and pain to set up Chinese support in LaTeX . So after I took the pain to do it, following these two great tutorials (TeXLive users take note: DO follow instruction 4.b .), I thought I should use it more. Here it is: the bilingual pdf version of the " Analects of Confucius"(《论语》), or "Confucian Analects", translated by James Legge and typeset by me. Many thanks to Project Gutenberg for the original plain text version!

天国之秋

Book review: “Autumn in the Heavenly Kingdom: China, the West, and the Epic Story of the Taiping Civil War" by Stephen R. Platt 秋天有两种:一种是丰收喜悦之秋,一种是伤感可悲之秋。太平天国之秋,毫无疑问是第二种。 《天国之秋》改变了很多我对于太平天国的认识和评价。作者一上来就对太平天国运动的性质作了一个中肯的评价,认为西方史学界长期以来称之为“太平叛乱”,以及中国史学界以太平天国为原始共产主义而称之为“太平革命”或“太平起义”,都失之偏颇。唯一恰当的称谓,当为“太平内战”。 ("The Taiping were indeed rebels, but to call the entire war the Taiping Rebellion is to cast the rebels forever in the wrong, and to blame on them for defying their legitimate rulers and destroying what one might surmise was otherwise a peaceful and stable empire." "...just as it is unfair to suggest that the Taiping were solely responsible for the devastation of the war, it is likewise an exaggeration to claim they were building some kind of peasant utopia.") 作为西方人写中国史,作者不可避免地更关心西方历史与这段中国历史的联系。全书令人信服地论证了,发生在十九世纪中国的太平内战,已经不再是一个孤立的事件,而是跟欧洲和美国历史有实质性的联系。简而言之,因为美国内战导致大英帝国在美国的贸易锐减,英国害怕同时因为中国内战而失去另一个巨大的贸易伙伴,而违背一贯的中立政策,干预了中国内战。虽然直接干预并不多,而且政策还有反复,却鬼使神差地影响了

两个庄园的故事

每次去纽约市玩,我都尽量顺路寻访一个纽约上州的景点。 比如洛克菲勒庄园( Kykuit the Rockefeller Estate ),就是位于哈德逊河边上众多美国第一代大资本家的庄园之一。虽然是七八年前去的,我还能记得当时导游告诉我们的几件老洛克菲勒教子有方的逸事。作为白手起家的第一代,老洛克菲勒的庄园尤其简朴。他没有太多爱好,就喜欢驾马车兜风。于是庄园里就有马棚。他要求自己的儿子(小约翰)和孙子们(包括曾任纽约州州长和美国副总统的纳尔逊洛克菲勒)从小就在马棚劳动,喂马、洗马、倒马粪。每天的“工资”是一毛钱,可以用来换糖果、冰淇淋。劳动后的奖励还包括跟老洛克菲勒一起在自家后院驾马车兜风。此外,他还要求子孙把每天工钱的十分之一,也就是一分钱,捐给教会。今天的美国社会,到处都是洛克菲勒家族的影子。除了非常明显的如洛克菲勒中心、洛克菲勒大学,还有芝加哥大学、纽约现代艺术博物馆、好几个国家公园。 虽然这次旅行多了一个两岁半的女儿,也不能破例。 等我们匆匆赶到范德堡庄园( Vanderbilt Mansion )的时候,身穿国家公园护林员制服的导游正带领大家从游客中心走出来。他在一棵大树下站定,等游客陆续到来围成半圈,才不紧不慢地开口道:“大家下午好!我的名字叫Dimitri。” 像一个善于讲故事的说书人,Dimitri一开口就把大家的注意力吸引住了。他娓娓道来,大家眼前的这栋欧式建筑的主人,是镀金时代传奇的资本家、“铁路大王”范德堡之后。他从范德堡如何发迹于一艘渡轮讲起,到他如何建立铁路帝国,富甲一方,福荫子孙。然而与其他美国早期资本家族不同的是,他的子孙却几乎个个热衷于跻身上流,富而求贵。(当时社会风气正处于转型期,遗老遗少依然重血统而轻新富。)为标榜富豪,范德堡的子孙大兴土木,最有名的莫过于位于北卡罗来纳州的比尔特莫庄园( Biltmore Estate )。朝歌暮宴,一掷千金。 这个位于纽约州的范德堡庄园的主人,是范氏子孙中的异类。据说他是唯一一个遗产多于继承来的财富的范氏子孙。这个庄园,也只是他夫妻两人消暑小住的地方。导游这才带我们登堂入室,一览当年的奢华。 导游最后告诉我们,与范德堡同时代的大资本家族如洛克菲勒、卡内基、摩根、梅隆,都为私福荫后人,为公泽被后世。唯独范德堡家族,竟没有一个能守住当年积累的巨大财富的后人;对美国社会的贡献,