Sunday, March 12, 2023

A simple OOP example of 3D-FOA by Python

 """A simple OOP example of 3D-FOA by Python to find the min value of QF Author: Wei-Yuan LinSoochow University, TaipeiTaiwanVer.3In this version, there are two classes - Fly and FOA.The Fly class represents each individual fly in the swarmThis code implements the Fruitfly  Optimization Algorithm (FOA) to optimize a function called "smell". FOA is a nature-inspired...

Wednesday, March 1, 2023

 The  FOA with constraints program generated by ChatGPTimport randomimport numpy as np# Define the optimization problem with constraintsdef objective_function(x):    # objective function: x1^2 + x2^2 + x3^2    # constraint: 2*x1 + 3*x2 + 4*x3 <= 5    f = x[0]**2 + x[1]**2 + x[2]**2    g = 2*x[0] + 3*x[1] + 4*x[2] - 5    if g > 0:   ...

Thursday, October 18, 2018

A simple example of 3D-FOA by Python

##A simple example of 3D-FOA by Python# Find the min value of QF by FOA """ author: Wei-Yuan LinSoochow University, TaipeiTaiwanVer.2""" import numpy as npimport matplotlib.pyplot as plt Population = 100Gen = 100def initParams(bestX,bestY,bestZ,Population):     location = []    fitness = []    for num in range(Population):        x,y,z= bestX+2*np.random.rand()-1,bestY+2*np.random.rand()-1,bestZ+2*np.random.rand()-1       ...