Skip to content

Commit

Permalink
feat: Added Zakharov func
Browse files Browse the repository at this point in the history
  • Loading branch information
Agrover112 committed Jul 19, 2021
1 parent 931d0cd commit 4c3b5ea
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions fitness.py
Expand Up @@ -12,7 +12,7 @@
schwefel_N2_23_d=[(-10,10)]
brown_d=[(-1,4)]
rosenbrock_d=[(-5,10)]

zakharov_d=[(-5,10)]
domain = {
'domain': [(0, 9)] * (len(people) * 2), # 9 times * no.of people * to-from
'ackley_N2': ackley_N2_d,
Expand All @@ -24,7 +24,8 @@
'sphere':sphere_d,
'three_hump_camel':three_hump_camel_d,
'brown':brown_d,
'rosenbrock':rosenbrock_d
'rosenbrock':rosenbrock_d,
'zakharov':zakharov_d
}
#Our Problem's fitness function
def fitness_function(solution, dest):
Expand Down Expand Up @@ -139,6 +140,10 @@ def rosenbrock(x):
My implementation was absolutely ***"""
return sum(100 * (x * x - y)**2 + (1. - x)**2 for x, y in zip(x[:-1], x[1:]))

def zakharov(x):
p2=sum(0.5*idx*i for idx,i in enumerate(x))
return (sum(i**2 for i in x) + p2**2 +p2**4 )

if __name__ == "__main__":
"""assert fitness_function(
[1, 4, 3, 2, 7, 3, 6, 3, 2, 4, 5, 3], "FCO") == 5451
Expand All @@ -153,4 +158,5 @@ def rosenbrock(x):
assert schaffer_N1([0,0]) == 0 #difficult
assert schwefel([0,0,0]) == 0
assert brown([0,0,0])==0
assert rosenbrock([1,1,1])==0
assert rosenbrock([1,1,1])==0
assert zakharov([0,0,0,0])==0

0 comments on commit 4c3b5ea

Please sign in to comment.