Soft computing Unit-5
Soft computing Unit-5
Start
Initial Population
Selection
Crossover
Mutation
Terminate?
Best Individuals
Output
Stop
Schema theorem:
2. Initial Population:
o Randomly generate an initial population of solutions (job
sequences).
o Each solution in the population will represent a possible way of
scheduling the jobs on the machines.
3. Fitness Function:
o The fitness function evaluates how good each solution is by
calculating the makespan of the schedule. The makespan is the
total time required to complete all jobs.
o The solution with the minimum makespan is the best, so a lower
makespan corresponds to a higher fitness value.
4. Selection:
o Selection involves choosing parents based on their fitness (lower
makespan).
o Techniques like roulette wheel selection or tournament
selection can be used. Fitter solutions (with shorter makespans) are
more likely to be selected.
5. Crossover (Recombination):
o Crossover involves combining the job sequences of two parents to
create offspring.
o For JSSP, order-based crossover is commonly used, where parts
of the job sequences are exchanged between parents to create new
schedules while maintaining job precedence constraints.
6. Mutation:
o Mutation introduces randomness into the population to maintain
diversity.
oFor JSSP, mutation could involve swapping the order of jobs, or
changing job assignments on different machines, ensuring that no
job precedence rules are violated.
7. Replacement (Survivor Selection):
o After crossover and mutation, the offspring are evaluated. Based on
their fitness (makespan), the best individuals are selected to form
the next generation.
o This can be done by replacing the worst individuals in the
population with the offspring or by using elitism (keeping the best
individuals).
8. Termination Criteria:
o The algorithm can stop when a maximum number of generations
have passed, or when the improvement in the makespan becomes
very small over several generations, indicating that the algorithm
has converged to a solution.
Example:
Machines: M1, M2
The schedule needs to assign jobs to machines in a way that minimizes
the makespan (total time).
The time taken for each job on each machine is predefined, and the goal
is to find the optimal order of jobs on each machine.
Job-to-Machine Time Table:
Job M1 M2
J1 3 2
J2 4 3
J3 2 5
The GA can be used to search for the best scheduling order (like "J1 on
M1, J2 on M2, J3 on M1") by evolving different sequences over
generations, selecting better schedules with lower makespans, and using
crossover and mutation to explore new schedules.
Challenges:
Parameter Tuning: Choosing the right crossover rate, mutation rate, and
population size can be challenging and often requires experimentation.
Convergence Speed: GAs may converge slowly for large-scale JSSP
instances or require many generations to find good solutions.
Summary:
6. Mutation:
o Mutation introduces randomness into the population to maintain
diversity and avoid the algorithm getting stuck in a local optimum.
o In TSP, a simple mutation could involve swapping two cities'
positions in the route.
o For example, if the route is [1, 3, 5, 2, 4], a mutation might result in
[1, 5, 3, 2, 4] by swapping cities 3 and 5.
7. Replacement (Survivor Selection):
o After crossover and mutation, the offspring are added to the
population. The next step is to choose which solutions will survive
into the next generation.
o One approach is to replace the worst solutions with the best
offspring, or use elitism to ensure that the best solution always
survives.
8. Termination Criteria:
o The algorithm stops when a stopping condition is met. This could
be:
A maximum number of generations is reached.
A solution is found that meets a specified distance threshold.
The improvement in the best solution becomes very small
over many generations.
Example:
Let’s say there are 5 cities, and the distance between each pair of cities is
given as follows:
City 1 2 3 4 5
1 0 10 15 20 25
2 10 0 35 25 30
3 15 35 0 30 20
4 20 25 30 0 15
5 25 30 20 15 0
Initial Population: Start with a set of random routes. For example, [1, 3,
5, 2, 4], [2, 4, 5, 3, 1], etc.
Fitness Calculation: Calculate the total distance for each route. For
example, for the route [1, 3, 5, 2, 4], the total distance would be 15 + 20 +
30 + 25 = 90.
Selection: Choose the best routes based on their fitness (shorter
distances).
Crossover: Combine parts of two parent routes to create offspring. For
example, combining [1, 3, 5, 2, 4] and [2, 4, 1, 5, 3] could give an
offspring like [1, 3, 2, 5, 4].
Mutation: Randomly swap two cities in a route to introduce diversity.
Repeat: Continue the process for many generations, improving the routes
over time.
Challenges:
Slow Convergence: GAs may require many generations to find a good
solution, especially for large numbers of cities.
Parameter Tuning: Finding the right settings for crossover rates,
mutation rates, and population size can take experimentation.
Conclusion:
Using Genetic Algorithms for solving the Travelling Salesman Problem
(TSP) is an effective way to find a good (if not always optimal) solution.
By evolving a population of routes, selecting the best ones, combining
them through crossover, and introducing mutations, the GA explores
different possibilities and can eventually find a route with a minimal total
distance.
Swarm intelligence
ACO is based on the concept of pheromone trails and the idea that ants
communicate indirectly using these trails to find the shortest path to a food
source.
1. Pheromone Trails:
3. Pheromone Update:
o Once the ants find a solution (e.g., a route in TSP), they update the
pheromone levels on the paths they traveled. The more ants that
take a path, the stronger the pheromone trail will become.
o Evaporation: Pheromone trails naturally evaporate over time,
reducing their influence on future ants, which helps avoid
converging on suboptimal solutions.
4. Global Update:
o After all ants complete their tours (or after a set number of
iterations), the best solution found by the ants is used to update the
pheromone values on the paths.
5. Iterative Process:
o The process of exploring, selecting paths, and updating
pheromones continues iteratively. With each iteration, ants tend to
favor the shortest path due to the increasing pheromone levels on
the optimal path.
Advantages of ACO:
Challenges of ACO:
Conclusion:
3. Position Update: After adjusting the velocity, the particle updates its
position in the search space.
Applications of PSO:
Advantages of PSO:
Disadvantages of PSO:
2. Employed Bees: These bees explore new areas for potential food sources
(solutions) and evaluate their quality by checking the fitness of the food
sources they find.
3. Onlooker Bees: These bees observe the waggle dance of employed bees,
which indicates the location of a good food source (solution). Onlooker
bees then select the best sources based on probability and move to those
locations to explore further.
1. Global Search Ability: The scout bees help the algorithm explore the
entire search space, avoiding local optima.
2. Simple and Flexible: BCO is easy to implement and can be adapted to
various optimization problems.
3. Efficient: It balances exploration and exploitation, improving the quality
of the solution over time.
4. Parallel Search: Multiple bees (agents) search the solution space in
parallel, speeding up the process.