On the design of (meta)heuristics

Tony Wauters CODeS Research group, KU Leuven, Belgium There are two types of people

• Those who use heuristics • And those who don’t ☺

2 Tony Wauters, Department of , CODeS research group Heuristics

Origin: Ancient Greek: εὑρίσκω, "find" or "discover" Oxford Dictionary: Proceeding to a solution by trial and error or by rules that are only loosely defined. Tony Wauters, Department of Computer Science, CODeS research group 3 Properties of heuristics

+ Fast* + Scalable* + High quality solutions* + Solve any type of problem (complex constraints, non-linear, …)

- Problem specific (but usually transferable to other problems) - Cannot guarantee optimallity

* if well designed

4 Tony Wauters, Department of Computer Science, CODeS research group Heuristic types

• Constructive heuristics

• Hybrid heuristics • Matheuristics: hybrid of Metaheuristics and Mathematical Programming • Other hybrids: , ,… • Hyperheuristics

5 Tony Wauters, Department of Computer Science, CODeS research group Constructive heuristics

• Incrementally construct a solution from scratch. • Easy to understand and implement • Usually very fast • Reasonably good solutions

6 Tony Wauters, Department of Computer Science, CODeS research group Metaheuristics

A is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic optimization algorithms.

Instead of reinventing the wheel when developing a heuristic for each different problem, metaheuristics offer several tools that can be used as the skeleton for the development of a heuristic.

7 Tony Wauters, Department of Computer Science, CODeS research group Metaheuristics

• Key property: iteratively improve one or more solutions • Can be combined with constructive heuristics (initial solution) • Local search based • Steepest descent / , Variable Neighbourhood Search (VNS) • , Late Acceptance • GRASP, • Population based • Genetic algorithms / memetic algorithms • Ant Colony Optimization • PSO (Particle swarm optimization)

8 Tony Wauters, Department of Computer Science, CODeS research group Hill climbing

• Variants • Stochastic Hill-climbing

• First-improving

9 Tony Wauters, Department of Computer Science, CODeS research group Late acceptance Hill-climbing [Burke and Bykov 2017]

Tony Wauters, Department of Computer Science, CODeS research group 10 Metaheuristics the metaphor exposed Slides based on: Sörensen, K. Metaheuristics – the metaphor exposed. International Transactions in Operational Research, 22: 3-18, 2015. Thanks to Everton for sharing these slides! 12 Tony Wauters, Department of Computer Science, CODeS research group History

• Early research on heuristics focused on human intuition, insight and learning as a way of solving problems. • Metaheuristics followed the same strategy.

• Example: Tabu search • Memorizes part of the trajectory the search had taken in the recent and not-so-recent past. • Similar to a person looking for water in the desert trying to avoid running in circles.

13 Tony Wauters, Department of Computer Science, CODeS research group History

• Eventually new methods were based on processes that had little to do with human intuition.

• Simulated annealing

• Natural

• Ant-colony optimization

14 Tony Wauters, Department of Computer Science, CODeS research group History

• Simulated annealing • One of the earliest metaphor-based heuristics. • Analogy to the thermodynamic process of annealing. • Attempt to settle atoms into the lowest possible energy state.

• Total energy state of the atoms quality of the solution. • Change of atom positions changes in the solution (moves).

15 Tony Wauters, Department of Computer Science, CODeS research group History

• Natural evolution • Probably the most successful metaphor used until now. • Individuals in a population competing for survival.

• Individuals or chromosomes solutions. • Fitness objective function value. • Crossover / Mutation changes in the solution.

16 Tony Wauters, Department of Computer Science, CODeS research group History

• Ant-colony optimization • Models the optimization process upon the behavior of a colony of ants searching for food.

• Agents (ants) construct solutions in parallel. • Each element of each solution has its own measure • pheromone • Elements with stronger pheromones have higher probability of being selected for future solutions.

Tony Wauters, Department of Computer Science, CODeS research group 17 History

• With the increase in number of metaheuristics being created comes the question:

Until what point creating metaphors would result in really effective approaches?

18 Tony Wauters, Department of Computer Science, CODeS research group Not so good metaphors

19 Tony Wauters, Department of Computer Science, CODeS research group Metaphors

“Models of nature that are relied upon for inspiration [in creating new metaheuristics] are ubiquitous, and it is easy to conjure up examples whose metaphorical possibilities have not yet been tapped.[…]

It is perhaps surprising in retrospect that the behavior of bees has not been selected as a basis for one of the ‘new’ problem solving methods.” – Glover & Laguna (1998)

20 Tony Wauters, Department of Computer Science, CODeS research group Metaphors

• People took seriously what he meant as sarcasm: • Bees optimization algorithm (2004). • Bee colony algorithm (2005). • Bee mating optimization algorithm (2006).

• Difference between all insect algorithms proved marginal at best.

21 Tony Wauters, Department of Computer Science, CODeS research group “Novel” metaphor-based method

• Harmony search metaheuristic (2001) • Changes the terminology of optimization into a musical one. • Harmony solution. • Note decision variable. • Sounds better has a better objective function. • Harmony memory set of solutions.

• Concept: A musician playing or composing music has to “draw notes from a uniform random distribution”.

22 Tony Wauters, Department of Computer Science, CODeS research group Harmony search

• General idea: • generates a set of random initial solutions; • tries to find better solutions by combining existing ones; • changes the values of decision variables in some of the solutions in the set.

• In the end it is just another

23 Tony Wauters, Department of Computer Science, CODeS research group Harmony search

• “Most importantly, when I searched Wikipedia, I could not find the structure which equals Harmony Search”.

• HS was originally “created” to solve the design of water distribution networks. • 3 or 4 instances are tested. • A simple constructive heuristic outperformed the method.

• Google scholar search for “harmony search”: • 2010 – around 500 results. • 2012 – around 3000 results • 2 hours ago – around 23000 results

24 Tony Wauters, Department of Computer Science, CODeS research group How are these heuristics accepted?

• Fetish with novelty. • Race to make new scientific discoveries.

• Most common is for the method to be marketed by a single researcher: • Co-authors a sizeable fraction of all papers on this method. • Social media website profiles for these methods: • Intelligent water drops algorithm officially “likes” the galaxy-based .

25 Tony Wauters, Department of Computer Science, CODeS research group How are these heuristics accepted?

• Up-the-wall game (Burke et al., 2009) • Game with no rules, just a goal: • To obtain better results than your opponents

• Papers on metaheuristics are not accepted if they contain only an interesting insight • The methods presented need to be successful players in the up-the-wall game. • Methods have to be “tuned” for an instance-specific basis.

26 Tony Wauters, Department of Computer Science, CODeS research group Metaheuristic deconstruction

• Which components it consists of?

• Which other metaheuristics these components appear?

• How to adapt this components to a specific problem that is being solved?

• Please, use the general terminology

• Call a solution as solution.

27 Tony Wauters, Department of Computer Science, CODeS research group Design of (meta)heuristics

28 Tony Wauters, Department of Computer Science, CODeS research group Design of heuristic techniques I

• Solution representation • Direct vs indirect representation • Often a permutation

• Datastructures • N-dimensional array • , graph • Linked List, Queue, Stack

29 Tony Wauters, Department of Computer Science, CODeS research group Design of heuristic techniques II

• How can we modify our solutions (and make them better)? • Solution modifications (aka the moves) • For example: insert, remove, swap, shift, rotate, .. • Depends on solution representation. • Important points to consider: • Maximum coverage of the solution space • Connectivity • Some basic Landscape analysis might help

30 Tony Wauters, Department of Computer Science, CODeS research group Intensification vs diversification

• Intensification vs diversification [Glover and Laguna 1997] • In intensification, the promising regions are explored more thoroughly in the hope to find better solutions. • In diversification, non-explored must be visited to be sure that all regions of the search space are evenly explored and that the search is not confined to only a reduced number of regions.

31 Tony Wauters, Department of Computer Science, CODeS research group Key Ingredients

• Greediness • Randomness • Memory (e.g. Tabu Search) • Adaptiveness

• Other things to consider: • Decomposition (e.g. solving a subproblem with a specialized technique)

32 Tony Wauters, Department of Computer Science, CODeS research group Heuristics in cutting & packing

33 Tony Wauters, Department of Computer Science, CODeS research group Popular heuristic choices in cutting & packing

• Constructive heuristics: • Bottom-Left , Best-fit • Metaheuristics: • Greedy randomized adaptive search procedure (GRASP) • Alvarez-Valdés, R., Parreño, F., & Tamarit, J. M. (2008). Reactive GRASP for the strip-packing problem. Computers & Operations Research, 35(4), 1065-1083. • Gomes, A. M., & Oliveira, J. F. (2001, July). A GRASP approach to the nesting problem. In 4th Metaheuristics International Conference MIC’2001. • Biased random-key (BRKGA) • Gonçalves, J. F., & Resende, M. G. (2013). A biased random key genetic algorithm for 2D and 3D bin packing problems. International Journal of Production Economics, 145(2), 500-510.

34 Tony Wauters, Department of Computer Science, CODeS research group How to evaluate heuristics?

• If stochastic → Multiple runs • Stopping condition? • Iterations or time • Convergence • Gap to a known bound • What to measure in a single run? • Quality of best solution? • Time/iterations to best solution? • Runtime characteristics • Time-cost plots • Time-to-target plots [Ribeiro, C. C., Rosseti, I. (2015). ] • Statistical analysis

35 Tony Wauters, Department of Computer Science, CODeS research group Localsearch Frameworks

Framework Languages Usage/license Metaheuristics Features Name OptaPlanner Java, Kotlin, Open source Hill Climbing, Tabu search, Good documentation, many Scala Simulated Annealing, Late examples (Vehicle routing, Acceptance, Construction Scheduling, Nurse heuristics Rostering,…). Full algorithm configuration. LocalSolver APIs for Python, Commercial ?heuristic search? Powerful modeling language, Java, C#, C++ (1 Month free Limited algorithm academic) configuration.

EasyLocal++ C++ Open source Hillclimbing , simulated Limited documentation annealing, and tabu search

36 Tony Wauters, Department of Computer Science, CODeS research group Wrap-up

• A well designed heuristic can: • Produce high quality solutions • In a reasonable amount of time • Solve large-scale real-world problems • Many design choices: • Solution representation and data structures? • Initial solution? • How to modify solutions? • Which metaheuristic?

37 Tony Wauters, Department of Computer Science, CODeS research group Extra: Bestiary of metaheuristics

38 Tony Wauters, Department of Computer Science, CODeS research group Bestiary

39 Tony Wauters, Department of Computer Science, CODeS research group Bestiary

• Catalogs the many different types of metaphors • Animals • Plants • Microbes • Natural Phenomena • Supernatural Activities

• No distinction about their quality • The island of Doctor Moreau

• https://github.com/fcampelo/EC-Bestiary

40 Tony Wauters, Department of Computer Science, CODeS research group Sperm: Raouf OA and Hezam IM (2017). “Sperm motility algorithm: a novel metaheuristic approach for global Examples optimisation.” International Journal of Operational Research, 28(2), pp. 143. doi: 10.1504/ijor.2017.10002079

• Frogs leaping. • Blind naked mole rats. • Flowing of water to the sea. • 8 different metaheuristics that use water properties. • Community of scientists. • The life of a killer whale. • 3 different metaheuristics based on whales. • Reincarnation.

41 Tony Wauters, Department of Computer Science, CODeS research group Thank you

Tony Wauters, Department of Computer Science, CODeS research group 42