Untitled

mail@pastecode.io avatar
unknown
python
2 years ago
1.0 kB
4
Indexable
Never
import functions
from enumFunctions import Functions
from GWO import GWO
import pandas as pd

def gwo(pop, gens, decreaseFrom):
    obj_func = functions.selectFunction(Functions.ackley)
    # dim array size, -5 lb +5 lb
    return GWO(obj_func, -500, 500, 30, pop, gens, decreaseFrom)
    
    
def main():
    dict = {}
    arr = []
    brr = []
    pop = [250, 500, 1000, 5000, 10000]
    gens = [250, 500, 1000, 1500, 2000]
    decreaseFrom = [2,3,4]
    for x in pop:
        for y in gens:
            for z in decreaseFrom:
                    sol = gwo(x, y, z)
                    dict[x, y, z] = sol
    for key, value in dict.items():
        arr.append(key)
        brr.append(value)
    print(arr)
    print(brr)


    df = pd.DataFrame([brr],
                        columns=arr)
    print(df)
    df.to_excel('gwo_ackley.xlsx', sheet_name='new_sheet_name')
                    
    

if __name__ == "__main__":
    main()
    
#def GWO(objf, lb, ub, dim, SearchAgents_no, Max_iter):