Posts

Showing posts from August 8, 2023

New Post

GWO Python Code || Grey Wolf Optimizer in Python || ~xRay Pixy

Image
SOURCE CODE import numpy as np import tkinter as tk import matplotlib.pyplot as plt from tkinter import messagebox def initialization (PopSize,D,LB,UB):     SS_Boundary = len(LB) if isinstance(UB,(list,np.ndarray)) else 1     if SS_Boundary ==1:         Positions = np.random.rand(PopSize,D)*(UB-LB)+LB     else:         Positions = np.zeros((PopSize,D))         for i in range(D):             Positions[:,i]=np.random.rand(PopSize)*(UB[i]-LB[i])+LB[i]     return Positions def GWO(PopSize,MaxT,LB,UB,D,Fobj):     Alpha_Pos = np.zeros(D)     Alpha_Fit = np.inf     Beta_Pos = np.zeros(D)     Beta_Fit = np.inf     Delta_Pos = np.zeros(D)     Delta_Fit = np.inf     Positions = initialization(PopSize,D,UB,LB)     Convergence_curve = np.zeros(MaxT)     l = 0     while l<MaxT:         for i in range (Positions.shape[0]):             BB_UB = Positions[i,:]>UB              BB_LB = Positions[i,:]<LB             Positions[i,:] = (Positions[i,:]*(~(BB_UB+BB_LB)))+UB*BB_UB+LB*BB_LB            
More posts