Hello! Welcome to our next lesson on metaheuristics.
In the previous lesson, we explored Genetic Algorithms, a powerful population-based approach that mimics natural evolution to search for optimal solutions. We saw how it balances exploration and exploitation by managing a diverse set of solutions.
Today, we return to single-solution metaheuristics and dive deep into one of the most elegant and widely used algorithms: Simulated Annealing (SA). Our learning outcome is to apply the principles of Simulated Annealing for neighborhood search, including its acceptance criteria and cooling schedules. You'll discover how SA uses a clever analogy from physics to probabilistically escape local optima and navigate complex search landscapes, making it a powerful tool for problems like the Flexible Job Shop.
1. The Inspiration: Annealing in Metallurgy
The core idea behind Simulated Annealing is borrowed directly from a process in metallurgy, which, given your background in industrial engineering, should provide a strong intuitive foundation. When a metal is heated to a high temperature, its atoms have a lot of energy and move around freely. If it's cooled very quickly ("quenched"), the atoms get locked into a high-energy, disordered state. However, if it's cooled slowly and carefully—a process called annealing—the atoms have time to settle into a highly ordered, low-energy crystalline structure.
Simulated Annealing applies this same principle to optimization:
- A solution is like the arrangement of atoms in the material.
- The cost of a solution (e.g., makespan) is like the energy of the system.
- The global optimum is the minimum energy state (the perfect crystal).
- Temperature is a control parameter that manages the search process.
To start, let's watch a video that introduces this physical analogy and explains why algorithms like SA are needed to overcome the limitations of simple local search.
Optimization - I (Simulated Annealing)
The video 'Optimization - I (Simulated Annealing)' from the NPTEL lecture series provides an excellent academic introduction. It starts by framing the problem of local optima and then beautifully explains the physical annealing process that inspired the algorithm.
Please watch from the beginning until 06:16. The first part (until 02:29) recaps the problem of getting stuck in local optima with methods like hill climbing. The second part (02:29 - 06:16) explains the physical process of annealing and draws the parallel to optimization problems.
This analogy gives us the core strategy of SA: start "hot" to explore the search space widely, and then gradually "cool down" to exploit promising regions and settle on a high-quality solution.
2. The Simulated Annealing Algorithm
At its heart, SA is a modified version of hill climbing. While a simple hill-climbing algorithm only ever accepts moves that improve the solution, SA allows for "bad" moves (moves that worsen the solution) with a certain probability. This ability is what allows it to escape from local optima.
The general structure of the algorithm is as follows:
Simulated annealing: From basics to applications
The paper 'Simulated annealing: From basics to applications' provides a concise pseudo-code for the SA algorithm. This will give you a clear, structured overview of the process.
Please read section 2.3, 'Simulated annealing (SA) algorithm', focusing on the pseudo-code presented (steps 1 through 6). Don't worry about the formal definitions for now; focus on the flow: Initialization -> Repeat loop -> Inner loop for transitions -> Update temperature -> Stop.
The algorithm can be summarized in these steps:
- Initialize:
- Generate an initial solution, .
- Set a high initial temperature, .
- Loop until a stopping condition is met:
- For a fixed number of iterations:
- Generate a neighboring solution, , from the neighborhood of .
- Calculate the change in the objective function: . For makespan minimization, this is .
- Decide whether to accept using the acceptance criterion (we'll detail this next). If accepted, set .
- Cool down: Reduce the temperature according to a cooling schedule.
- For a fixed number of iterations:
The two most critical components of this algorithm are the acceptance criterion and the cooling schedule.
3. The Acceptance Criterion: The Metropolis Rule
How does SA decide whether to accept a worse solution? It uses a probabilistic rule known as the Metropolis criterion.
If the new solution is better than the current one (i.e., for minimization), it is always accepted.
If is worse (i.e., ), it is accepted with a probability given by the Boltzmann distribution:
Let's break down this formula:
- : The change in cost. The larger the increase in cost (the "worse" the move), the smaller the exponential term becomes, and the lower the acceptance probability.
- : The current temperature.
- When is high, the fraction is close to zero, so is close to . The algorithm accepts almost any move, leading to a random-walk-like exploration.
- When is low, the fraction becomes a large negative number, so is close to 0. The algorithm is very unlikely to accept bad moves, behaving like a simple hill-climbing algorithm (exploitation).
The following video section provides a brilliant numerical illustration of how this probability changes with both and .
Optimization - I (Simulated Annealing)
Let's return to the NPTEL video. This segment provides a concrete table of values showing exactly how the acceptance probability changes based on the quality of the move and the current temperature. This is key to understanding the algorithm's behavior.
Please watch from 07:33 to 28:01. The first part (until 17:39) introduces the probability function (sigmoid). The tables starting around 17:39 are the most important part. Observe how the probability of accepting a move changes as: The new solution gets worse (eval n decreases). The temperature (T) changes for a fixed 'bad' move.
The image below provides a great graphical summary of this relationship.

Test your understanding!
Imagine you are using SA to minimize the makespan of a schedule. The current solution has a makespan of 200 time units. You generate a neighbor solution with a makespan of 205.
- If the current temperature is 10, what is the probability of accepting this new, worse solution?
- What happens to this probability if the algorithm has cooled down and the temperature is now 2?
Show answer
First, we calculate the change in cost, :
.
The acceptance probability is .
-
At :
So, there is a 60.7% chance of accepting this worse solution, allowing the search to potentially escape a local optimum.
-
At :
Now, the probability has dropped to just 8.2%. As the system "cools," the algorithm becomes much more greedy and less likely to make non-improving moves.
4. The Cooling Schedule
The cooling schedule dictates how the temperature decreases over time. It is a critical part of the algorithm that controls the balance between exploration and exploitation. A poorly designed schedule can either terminate the search prematurely in a poor-quality region (cooling too fast) or waste computational time exploring randomly (cooling too slow).
A cooling schedule is defined by four key parameters:
Genetic Algorithm and Simulated Annealing for Flexible ...
For your thesis work, understanding the practical design of these parameters is crucial. The paper 'Genetic Algorithm and Simulated Annealing for Flexible ...' provides a clear, practice-oriented description of the components of a cooling schedule.
Please read the following subsections in Section 2.4 ('Simulated Annealing'): 2.4.1 Initialization: Focus on the part about selecting the initial temperature Temp_init. 2.4.3 Cooling Schedule: Understand the widely used geometric cooling scheme. 2.4.4 Termination Criteria: Review the common ways to stop the algorithm.
Let's summarize these crucial components:
-
Initial Temperature (): This should be high enough to allow the algorithm to freely explore at the beginning. A common practice is to set such that the initial acceptance rate for worsening moves is high (e.g., 80% or more). This can be found by running some trial moves and calculating the required based on the average of those moves.
-
Cooling Function: This defines how the temperature is reduced. The most common method is geometric cooling:
Here, is the cooling rate, a value typically between 0.8 and 0.99.
- A value of close to 1 (e.g., 0.99) results in very slow cooling, allowing for extensive exploration but requiring more computation time.
- A smaller (e.g., 0.85) cools much faster, leading to quicker convergence but with a higher risk of getting stuck in a local optimum.
-
Iterations per Temperature Step (Markov Chain Length): At each temperature level, the algorithm runs for a certain number of iterations. This allows the system to reach a "quasi-equilibrium" at that temperature before cooling further. A common choice is a fixed number of iterations, or a number proportional to the size of the problem (e.g., the number of operations).
-
Termination Criterion: The algorithm must have a condition to stop. Common criteria include:
- The temperature reaches a very low final temperature ().
- The best solution found has not improved for a certain number of consecutive temperature steps.
- A maximum number of iterations or a total runtime limit is reached.
The effectiveness of SA is highly sensitive to the tuning of these parameters, which often requires empirical testing for a specific problem domain.
5. Applying SA to the Flexible Job Shop Problem (FJSP)
To apply SA to your specific problem of interest, FJSP, we need to define the "neighborhood" and the "cost function".
-
Cost Function: This is straightforward. For makespan minimization, the cost function is simply the makespan of the schedule .
-
Neighborhood Search: This is the mechanism for generating a new solution from . Since an FJSP solution involves both job sequencing and machine assignment, a neighborhood move can alter one or both of these components.
Genetic Algorithm and Simulated Annealing for Flexible ...
The Chalmers thesis again provides excellent, specific examples of neighborhood structures suitable for FJSP.
Please read subsection 2.4.2 Neighborhood Search. Note the two main types of operations described for generating neighbors in an FJSP context.
As described in the text, typical neighborhood moves for FJSP include:
- Resequencing: Altering the order of operations on a machine. This can be a simple swap of two operations on the same machine or an insertion of one operation into a different position in the sequence.
- Reassignment: Changing the machine assigned to a particular operation (while respecting the set of machines capable of performing it). This directly addresses the "flexible" part of the FJSP.
By combining these moves, the neighborhood search can effectively explore the vast solution space of both operation sequencing and machine allocation that characterizes the FJSP.
Conclusion
In this lesson, we have dissected the Simulated Annealing algorithm, a cornerstone of metaheuristic optimization. You've seen how its power lies in its probabilistic acceptance of non-improving moves, allowing it to systematically escape local optima.
Key Takeaways:
- Simulated Annealing is a single-solution metaheuristic inspired by the physical annealing process in metallurgy.
- It balances exploration at high temperatures with exploitation at low temperatures.
- The Metropolis acceptance criterion, , is the core mechanism that allows the algorithm to accept "bad" moves, with a probability dependent on the move's quality and the current temperature.
- The cooling schedule (initial temperature, cooling rate, iterations per step, and termination criterion) is critical for guiding the search effectively and must be carefully tuned.
- For scheduling problems like FJSP, neighborhood moves typically involve resequencing operations or reassigning them to different machines.
Preview of the Next Lesson:
We have now seen a population-based approach (GA) and a probabilistic single-solution approach (SA). In our next lesson, we will explore Tabu Search (TS). You will see how TS uses a completely different mechanism to escape local optima: memory. Instead of relying on probability, TS deterministically forbids (makes "tabu") recent moves to prevent cycling and force the search into new, unexplored regions of the solution space.