A meta-heuristic is a canvas or framework to construct a heuristic adapted to your specific problem. Dozens of meta-heuristics have been invented. Let’s set aside the unproductive debate about what meta-heuristic is best and who invented it and let’s dive right into the topic. Meta-heuristics:
One could write books on meta-heuristics and indeed lots of books, articles and reports have been written. There are even scientific communities that only swear by this meta-heuristic and each meta-heuristic comes with its own vocabulary[1]. In this manual, we only scratch the surface of this fascinating subject.
Many meta-heuristics are based on Local Search[2]: they start with an initial solution and improve it little by little. From now on and for the rest of this chapter, we only talk about meta-heuristics using Local Search.
Warning
The whole chapter is about meta-heuristics using Local Search.
Among them, we present three well-known meta-heuristics:
These three meta-heuristics are implemented in or-tools and are used in the routing library (through flags).
In or-tools, we implement meta-heuristics with SearchMonitors guiding Local Search (and thus we also use the LocalSearch, LocalSearchOperator, LocalSearchFilter classes). This is quite “natural” as SearchMonitors allow to... monitor the search and the implemented meta-heuristics are based on Local Search.
When you implement a (meta)-heuristic, you have to take decisions. Our implementations are one possibility among others. We would like to warn the reader on an important choice we have made in our implementation: we only use meta-heuristic when we have reached a local optimum, not before!
Warning
Our meta-heuristics only kick in when we already have reached a local optimum with the Local Search.
A last word of advice. In this chapter, we decided to show you the code in full details. Real code, especially in optimization, is complicated and has to deal with lots of subtleties. While we try to explain most of the intricate details (but not all), you only see the end results. The code we show has been polished and is used in production (and changes sometimes!). Some parts have a long history of trial and error and there is no way we can explain all the details. We cannot emphasize enough that you’ll learn how to use the or-tools by actually coding with it, not only reading existing code. That said, the exposed code gives you good examples on what can be done and how the makers of the or-tools library decided to do it. Beside, you’ll have a pretty good idea of what actually our meta-heuristic implementations do and how to adapt the code to solve your problems.
Overview:
Before diving in the heart of the matter, we address two ways to improve the search. First, because our meta-heuristics never stop, we detail how SearchLimits can be used to stop a search. Second, we discuss restarting a search. Recent research shows that restarting a search might improve the overall search. Next, we detail our Metaheuristic class and our three specialized TabuSearch, SimulatedAnnealing and GuidedLocalSearch implementations. To finish this chapter, we present another meta-heuristic, Large Neighborhood Search[3], that is not implemented with a SearchMonitor but with a LocalSearchOperator. Next we answer the question “What do you do when you have no idea of a (good) search strategy?”. Answer? You throw in lots of heuristic and random behavior in your top-level search. In or-tools, we implemented the DefaultIntegerSearch DecisionBuilder to do just that.
Prerequisites:
Classes under scrutiny:
SearchLimit, SearchMonitor, Metaheuristic, TabuSearch, SimulatedAnnealing, GuidedLocalSearch, LocalSearchOperator and DefaultIntegerSearch.
Files:
The files used in this chapter are:
Content:
[1] | In order to “sell” your (meta-)heuristic to the scientific community, it is also good to give it a snappy name. We don’t resist to name a few:
and our favorite: the imperialist competitive algorithm. |
[2] | Local Search and meta-heuristics are so intricate that it is difficult to separate the two concepts. This is also the case in the or-tools library. The LocalSearch class was devised with the Metaheuristic class in mind and vice-versa. Reread the section What is Local Search (LS)? if needed. It also has some comments on meta-heuristics in general. Because we use Local Search, most of the examples will involve the Job-Shop Problem and the implementation of the LocalSearchOperators met in the previous chapter. |
[3] | Large Neighborhood Search (LNS) can be seen as a meta-heuristic (same for Local Search) and is in a way an extension of Local Search. In or-tools, we implement LNS with special LocalSearchOperators. |