-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathoptim_func.py
More file actions
51 lines (30 loc) · 1012 Bytes
/
Copy pathoptim_func.py
File metadata and controls
51 lines (30 loc) · 1012 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# -*- coding: utf-8 -*-
#####################################################
# Fn5: DeJong's F5 function
# 论文附录F5函数定义错误,见图片
#
#####################################################
import math
def fn5(x1, x2):
'''this two-dimensional function contain 25 foxholes of various depths surrounded
by a relatively flat surface.
>>>fn5(-32,-32)
0.998
'''
base = [-32.0, -16.0, 0.0, 16.0, 32.0]
a = [[base[i % 5] for i in range(25)],
[base[j // 5] for j in range(25)]]
sum = 0
for x in range(25):
sum += 1 / (x+1 + math.pow((x1-a[0][x]), 6) + math.pow((x2-a[1][x]), 6))
return 1 / (0.002 + sum)
#########################################################
# Gear problem (Deb and Goyal 1997)
#
# -12 <= x1,x2,x3,x4 <= 60
#
#########################################################
def gear(x1, x2, x3, x4):
pass
def nestedFn5(parameter):
return fn5(parameter[0], parameter[1])