Alpha_pos = np.zeros(dim)
Alpha_score = float("inf")

Beta_pos = np.zeros(dim)
Beta_score = float("inf")

Delta_pos = np.zeros(dim)
Delta_score = float("inf")

#Initialize the positions of search agents
population = []

for i in range(SearchAgents_no):
    vector = np.random.uniform(low=lb, high=ub, size=dim)
    fitness = structureEnergy(transform(vector), aminoAcid)

    if fitness < Alpha_score:
        Delta_score = Beta_score
        Delta_pos = Beta_pos
        Beta_score = Alpha_score
        Beta_pos = Alpha_pos
        Alpha_score = fitness
        Alpha_pos = vector

    if (fitness > Alpha_score and fitness < Beta_score):
        Delta_score = Beta_score
        Delta_pos = Beta_pos
        Beta_score = fitness
        Beta_pos = vector
Example #2
0
inertiaWeight = 0.7

hypersphereRadius = 7

c1 = 1.49618
c2 = 1.49618
c3 = 1.01

gbestPositionVector = np.zeros(dimension)
gbestFitness = sys.maxsize
gbestParticle = -1

for i in range(populationSize):
    vector = np.random.uniform(low=posMin, high=posMax, size=dimension)
    fitness = structureEnergy(transform(vector), aminoAcid)
    population.append(
        particle(vector, np.zeros(dimension), fitness, hypersphereRadius))

    if fitness < gbestFitness:
        gbestPositionVector = vector
        gbestFitness = fitness
        gbestParticle = i

gbestFitnessAtEachIteration = []

print("%d %d" % (0, gbestFitness))

gbestFitnessAtEachIteration.append(gbestFitness)

for it in range(maxIterations):
dampingFactor = 1.0

c1 = 2
c2 = 2

#Initialisation

population = []

gbestPositionVector = np.zeros(dimension)
gbestCost = sys.maxsize

for i in range(populationSize):
    vector = np.random.uniform(low=posMin, high=posMax, size=dimension)
    fitness = structureEnergy(transform(vector), aminoAcid)
    population.append(particle(vector, np.zeros(dimension), fitness))

    if fitness < gbestCost:
        gbestPositionVector = vector
        gbestCost = fitness

gbestCostAtEachIteration = []

gbestCostAtEachIteration.append(gbestCost)

print("%d %d" % (0, gbestCost))

#Main Loop starts

for it in range(maxIterations):
Example #4
0
Alpha_pos = np.zeros(dim)
Alpha_score = float("inf")

Beta_pos = np.zeros(dim)
Beta_score = float("inf")

Delta_pos = np.zeros(dim)
Delta_score = float("inf")

#Initialize the positions of search agents
population = []

for i in range(SearchAgents_no):
    vector = np.random.uniform(low=lb, high=ub, size=dim)
    fitness = structureEnergy(transform(vector), aminoAcid)

    if fitness < Alpha_score:
        Delta_score = Beta_score
        Delta_pos = Beta_pos
        Beta_score = Alpha_score
        Beta_pos = Alpha_pos
        Alpha_score = fitness
        Alpha_pos = vector

    if (fitness > Alpha_score and fitness < Beta_score):
        Delta_score = Beta_score
        Delta_pos = Beta_pos
        Beta_score = fitness
        Beta_pos = vector