New Post

Poplar Optimization Algorithm || Step-By-Step || ~xRay Pixy

Image
The Poplar Optimization Algorithm (POA) is a nature-inspired optimization method based on how poplar trees reproduce. It uses sexual propagation (seed dispersal by wind) for exploration and asexual reproduction (cutting and regrowth) for exploitation. Mutation and chaos factors help maintain diversity and prevent premature convergence, making POA efficient for solving complex optimization problems. Learn the Poplar Optimization Algorithm Step-By-Step using Examples. Video Chapters: Poplar Optimization Algorithm (POA) 00:00 Introduction 02:12 POA Applications 03:32 POA Steps 05:50 Execute Algorithm 1 13:45 Execute Algorithm 2 16:38 Execute Algorithm 3 18:15 Conclusion Main Points of the Poplar Optimization Algorithm (POA) Nature-Inspired Algorithm ā€“ Based on the reproductive mechanisms of poplar trees. Two Key Processes : Sexual Propagation (Seed Dispersal) ā€“ Uses wind to spread seeds, allowing broad exploration. Asexual Reproduction (Cuttings) ā€“ Strong branches grow ...

WFLO in Python || Optimal Placement of Wind Turbines using PSO in Python...

Wind turbine optimal placement using particle swarm optimization Implementation in Python. Video Chapters: 00:00 Introduction 00:30 Key Points 03:17 Implementation 05:50 Flowchart 06:32 Code 23:47 Apply PSO 31:53 Output

SOURCE CODE

import numpy as np
import math
import random

#Probability Distribution Function
def PDF(U,k,c):
    return (k / c) * (U / c)**(k - 1) * math.exp(-((U / c)**k))

#Calculate Alpha
def Cal_alpha(Z,Z_o):
    return 0.5 / math.log (Z/Z_o)

#Calculate Full Wake Effect
def Full_WE(u_o,a,alpha,X,R_1):
    return u_o*(1-(2*a/(1+alpha*(X/R_1)**2)))

#Calculate Partial Wake Effect
def Partial_WE(u_o,a,alpha,X,R_1,A_Partial,A_Total):
    return u_o * (1-(2*a/(1+alpha*(X/R_1)**2)))*(A_Partial-A_Total)

#Calculate No Wake Effect
def No_WE(u_o):
    return u_o

#Calculate Power
def Power(u,Ideal_Power):
    if u<3:
        return 0
    elif 3<=u<=12:
        return Ideal_Power
    elif 12<=u<=25:
        return 518.4
    else:
        return 0
    
#Calculate Objective Function
def Obj_Fun(installation_cost,Total_Power,U_values,k,c):
    objective_value = [installation_cost / (Total_Power * PDF(U,k,c)) for U in U_values]
    return min(objective_value)

#Apply PSO
#PSO Parameters
Pop_S = 100
MaxT = 500
w = 0.5
c1 = 2.5
c2 = 2.5

#Particle Class
class Particle:
    def __init__ (self):
        self.position = [random.uniform(0.1,1.0),random.uniform(10,50)]
        self.velocity = [0.0,0.0]
        self.pbest = self.position.copy()

#PSO MAIN LOOP
def PSO(config):
    initial_Total_Power = config["Total_Power"]
    U_values = config["U_values"]
    k = config["k"]
    c = config["c"]
    particles = [Particle() for _ in range (Pop_S)]
    gbest = particles[0].pbest.copy()
    best_a = gbest[1]
    best_installation_cost = gbest[0]

    installation_cost = Pop_S*(2/3+(1/3)*math.exp(-0.00174*Pop_S**Pop_S))

    #PSO LOOP
    for iteration in range (MaxT):
        for particle in particles:
            a = particle.position[1]
            Total_Power_Particle = initial_Total_Power
            for U in U_values:
                best_a = particle.position[1]

            #Objective Function
            objective = Obj_Fun(installation_cost,Total_Power_Particle,U_values,k,c)

            #Compare Pbest
            if objective < Obj_Fun(particle.pbest[0],Total_Power_Particle,U_values,k,c):
                particle.pbest = particle.position.copy()

            #Compare Gbest
            if objective < Obj_Fun(gbest[0],Total_Power_Particle,U_values,k,c):
                gbest = particle.position.copy
                best_a = a
                best_installation_cost=installation_cost

            #Calculate Velocity
            for i in range (len(particle.velocity)):
                r1,r2 = random.random(),random.random()
                C_velocity = c1 *r1 *(particle.pbest[i]-particle.position[i])
                S_velocity = c2 *r2 *(gbest[i]-particle.position[i])
                particle.velocity[i] = w * particle.velocity[i]+C_velocity+S_velocity

                #Calculate  Position
                particle.position[i] += particle.velocity[i]
    return best_installation_cost,best_a

def main():
    k = 0.10
    c = 10
    Z = 60
    Z_o = 0.3
    a = 1/3
    u_o = 12
    X = 200
    D = 40
    R_r = 40
    R_1 = a * X * R_r
    alpha = Cal_alpha(Z,Z_o)
    A_Partial = 3.14 * (R_1)**2
    A_single = 3.14 * (D/2)**2
    A_Total = (200*200) * A_single

    #Wind Speed Values
    U_values = [3,6,9,12,15]

    #Ideal Power
    Ideal_Power = 0.3*u_o**3

    partial_wake = Partial_WE(u_o,a,alpha,X,R_1,A_Partial,A_Total)


    #Actual Power
    Actual_Power = 0.3*partial_wake**3

    #Total Power
    Total_Power = Ideal_Power + Actual_Power

    #AEP
    AEP = 8760*Total_Power

    Configuration = {
        "Total_Power":Total_Power,
        "U_values":U_values,
        "k":k,
        "c":c,
        "u_o":u_o,
        "alpha":alpha,
        "X":X,
        "R_1":R_1,
        "A_Partial":A_Partial,
        "A_Total":A_Total
    }

    best_installation_cost,best_a = PSO(Configuration)

    best_objective = Obj_Fun(best_installation_cost,Total_Power,Configuration["U_values"],Configuration["k"],Configuration["c"])

    efficiency = Total_Power / (2 * Ideal_Power)

    #Display Output Values
    print("Objective",best_objective)
    print("Efficiency",efficiency)
    print("Total Power",Total_Power)

if __name__ == "__main__":
    main()

Comments

Popular Post

PARTICLE SWARM OPTIMIZATION ALGORITHM NUMERICAL EXAMPLE

Cuckoo Search Algorithm for Optimization Problems

Particle Swarm Optimization (PSO)

PSO (Particle Swarm Optimization) Example Step-by-Step

PSO Python Code || Particle Swarm Optimization in Python || ~xRay Pixy

how is the LBP |Local Binary Pattern| values calculated? Step-by-Step with Example

Whale Optimization Algorithm Code Implementation || WOA CODE || ~xRay Pixy

Grey Wolf Optimization Algorithm

Grey Wolf Optimization Algorithm Numerical Example

Bat algorithm Explanation Step by Step with example