On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent...

42
On the design of (meta)heuristics Tony Wauters CODeS Research group, KU Leuven, Belgium

Transcript of On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent...

Page 1: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

On the design of

(meta)heuristics

Tony Wauters

CODeS Research group, KU Leuven, Belgium

Page 2: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

Tony Wauters, Department of Computer Science, CODeS research group2

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

There are two types of people

Page 3: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

Heuristics

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

Origin: Ancient Greek: εὑρίσκω, "find" or "discover"

Oxford Dictionary: Proceeding to a solution by trial and error or

by rules that are only loosely defined.

Page 4: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

+ 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

Tony Wauters, Department of Computer Science, CODeS research group4

Properties of heuristics

* if well designed

Page 5: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

• Constructive heuristics

• Metaheuristics

• Hybrid heuristics

• Matheuristics: hybrid of Metaheuristics and Mathematical Programming

• Other hybrids: Machine Learning, Constraint Programming,…

• Hyperheuristics

Tony Wauters, Department of Computer Science, CODeS research group5

Heuristic types

Page 6: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

• Incrementally construct a solution from scratch.

• Easy to understand and implement

• Usually very fast

• Reasonably good solutions

Tony Wauters, Department of Computer Science, CODeS research group6

Constructive heuristics

Page 7: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

Tony Wauters, Department of Computer Science, CODeS research group7

A Metaheuristic 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.

Metaheuristics

Page 8: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

• Key property: iteratively improve one or more solutions

• Can be combined with constructive heuristics (initial solution)

• Local search based

• Steepest descent / Hill climbing

• Tabu search, Variable Neighbourhood Search (VNS)

• Simulated Annealing, Late Acceptance

• GRASP, Guided Local Search

• Population based

• Genetic algorithms / memetic algorithms

• Ant Colony Optimization

• PSO (Particle swarm optimization)

Tony Wauters, Department of Computer Science, CODeS research group8

Metaheuristics

Page 9: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

Tony Wauters, Department of Computer Science, CODeS research group9

• Variants

• Stochastic Hill-climbing

• First-improving

Hill climbing

Page 10: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

Late acceptance Hill-climbing [Burke and

Bykov 2017]

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

Page 11: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

Metaheuristicsthe metaphor

exposedSlides 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!

Page 12: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

Tony Wauters, Department of Computer Science, CODeS research group12

Page 13: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

Tony Wauters, Department of Computer Science, CODeS research group13

• 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.

History

Page 14: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

Tony Wauters, Department of Computer Science, CODeS research group14

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

human intuition.

• Simulated annealing

• Natural evolution

• Ant-colony optimization

History

Page 15: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

Tony Wauters, Department of Computer Science, CODeS research group15

• 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).

History

Page 16: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

Tony Wauters, Department of Computer Science, CODeS research group16

• 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.

History

Page 17: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

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.

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

Page 18: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

Tony Wauters, Department of Computer Science, CODeS research group18

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

question:

Until what point creating metaphors would result in really effective

approaches?

History

Page 19: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

Not so good metaphors

Tony Wauters, Department of Computer Science, CODeS research group19

Page 20: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

Tony Wauters, Department of Computer Science, CODeS research group20

“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)

Metaphors

Page 21: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

Tony Wauters, Department of Computer Science, CODeS research group21

• 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.

Metaphors

Page 22: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

Tony Wauters, Department of Computer Science, CODeS research group22

• 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”.

“Novel” metaphor-based method

Page 23: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

Tony Wauters, Department of Computer Science, CODeS research group23

• 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 evolutionary algorithm…

Harmony search

Page 24: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

Tony Wauters, Department of Computer Science, CODeS research group24

• “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

Harmony search

Page 25: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

Tony Wauters, Department of Computer Science, CODeS research group25

• 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 search

algorithm.

How are these heuristics accepted?

Page 26: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

Tony Wauters, Department of Computer Science, CODeS research group26

• 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.

How are these heuristics accepted?

Page 27: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

Tony Wauters, Department of Computer Science, CODeS research group27

• 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.

Metaheuristic deconstruction

Page 28: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

Design of (meta)heuristics

Tony Wauters, Department of Computer Science, CODeS research group28

Page 29: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

• Solution representation

• Direct vs indirect representation

• Often a permutation

• Datastructures

• N-dimensional array

• Tree, graph

• Linked List, Queue, Stack

Tony Wauters, Department of Computer Science, CODeS research group29

Design of heuristic techniques I

Page 30: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

• 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

Tony Wauters, Department of Computer Science, CODeS research group30

Design of heuristic techniques II

Page 31: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

• 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.

Tony Wauters, Department of Computer Science, CODeS research group31

Intensification vs diversification

Page 32: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

• Greediness

• Randomness

• Memory (e.g. Tabu Search)

• Adaptiveness

• Other things to consider:

• Decomposition (e.g. solving a subproblem with a specialized technique)

Tony Wauters, Department of Computer Science, CODeS research group32

Key Ingredients

Page 33: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

Heuristics in cutting &

packing

Tony Wauters, Department of Computer Science, CODeS research group33

Page 34: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

• 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 genetic algorithm (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.

Tony Wauters, Department of Computer Science, CODeS research group34

Popular heuristic choices in cutting & packing

Page 35: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

Tony Wauters, Department of Computer Science, CODeS research group35

• 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

How to evaluate heuristics?

Page 36: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

Framework

Name

Languages Usage/license Metaheuristics Features

OptaPlanner Java, Kotlin,

Scala

Open source Hill Climbing, Tabu search,

Simulated Annealing, Late

Acceptance, Construction

heuristics

Good documentation, many

examples (Vehicle routing,

Scheduling, Nurse

Rostering,…). Full algorithm

configuration.

LocalSolver APIs for Python,

Java, C#, C++

Commercial

(1 Month free

academic)

?heuristic search? Powerful modeling language,

Limited algorithm

configuration.

EasyLocal++ C++ Open source Hillclimbing , simulated

annealing, and tabu search

Limited documentation

Tony Wauters, Department of Computer Science, CODeS research group36

Localsearch Frameworks

Page 37: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

• 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?

Tony Wauters, Department of Computer Science, CODeS research group37

Wrap-up

Page 38: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

Extra: Bestiary of metaheuristics

Tony Wauters, Department of Computer Science, CODeS research group38

Page 39: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

Tony Wauters, Department of Computer Science, CODeS research group39

Bestiary

Page 40: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

Tony Wauters, Department of Computer Science, CODeS research group40

• 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

Bestiary

Page 41: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

Tony Wauters, Department of Computer Science, CODeS research group41

• 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.

ExamplesSperm: Raouf OA and Hezam IM (2017). “Sperm motility

algorithm: a novel metaheuristic approach for global

optimisation.” International Journal of Operational

Research, 28(2), pp. 143. doi: 10.1504/ijor.2017.10002079

Page 42: On the design of (meta)heuristics · A Metaheuristic is a high-level problem independent algorithmic framework that provides a set of guidelines or strategies to develop heuristic

Thank you

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