Experiment 7: Hybridization of Genetic Algorithm With PSO
Experiment 7: Hybridization of Genetic Algorithm With PSO
Experiment 7: Hybridization of Genetic Algorithm With PSO
Theory:
Particle Swarm Optimization (PSO) is a popular algorithm used extensively in continuous
optimization. One of its well-known drawbacks is its propensity for premature convergence.
Many techniques have been proposed for alleviating this problem. One of the alternative
approaches is hybridization. Genetic Algorithms (GA) are one of the possible techniques used for
hybridization
Algorithm:
Code : -
import numpy as np
class Cell():
FILLED_COLOR_BG = "green"
EMPTY_COLOR_BG = "white"
FILLED_COLOR_BORDER = "green"
EMPTY_COLOR_BORDER = "black"
def draw(self):
""" order to the cell to draw its representation on the canvas
"""
if self.master is not None :
fill = Cell.FILLED_COLOR_BG
outline = Cell.FILLED_COLOR_BORDER
self.value = 1
if not self.fill:
fill = Cell.EMPTY_COLOR_BG
outline = Cell.EMPTY_COLOR_BORDER
self.value = 0
class CellGrid(Canvas):
def __init__(self,master, rowNumber, columnNumber, cellSize,
*args, **kwargs):
Canvas.__init__(self, master, width = cellSize * columnNumber
, height = cellSize * rowNumber, *args, **kwargs)
self.cellSize = cellSize
self.grid = []
for row in range(rowNumber):
line = []
for column in range(columnNumber):
line.append(Cell(self, column, row, cellSize))
self.grid.append(line)
self.draw()
def draw(self):
for row in self.grid:
for cell in row:
cell.draw()
self.matrix[cell.ord, cell.abs] = cell.value
if __name__ == "__main__" :
app = Tk()
app.mainloop()
Output : -
Initial epoch
Final epoch