Skip to content

Commit b83c63b

Browse files
Add files via upload
1 parent 8938355 commit b83c63b

4 files changed

+168
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"""This script has been used in Qiqi Duan's Ph.D. Dissertation (HIT&SUSTech).
2+
3+
Chinese: 该绘图脚本被段琦琦的博士论文(哈工大与南科大联合培养)所使用。
4+
"""
5+
import matplotlib
6+
import matplotlib.pyplot as plt
7+
8+
from pypop7.benchmarks.utils import generate_xyz
9+
from pypop7.benchmarks.base_functions import rosenbrock
10+
11+
12+
matplotlib.rcParams['font.family'] = 'sans-serif'
13+
matplotlib.rcParams['font.sans-serif'] = 'SimSun'
14+
matplotlib.rcParams['axes.unicode_minus'] = False
15+
matplotlib.rcParams['font.size'] = 10 # 对应5号字体
16+
17+
18+
def cd(x): # from https://arxiv.org/pdf/1610.00040v1.pdf
19+
return 7.0 * (x[0] ** 2) + 6.0 * x[0] * x[1] + 8.0 * (x[1] ** 2)
20+
21+
22+
# helper function for 2D-plotting
23+
def plot_contour(func, x, y):
24+
x, y, z = generate_xyz(func, x, y, 1000)
25+
levels = [0, 1, 10, 100, 1000, 10000, 100000, 1000000]
26+
plt.contourf(x, y, z, cmap='bone', levels=levels)
27+
plt.contour(x, y, z, colors='white')
28+
29+
30+
if __name__ == '__main__':
31+
ndim_problem = 2
32+
bound=[-10.0, 10.0]
33+
plt.figure(figsize=(2.5, 2.5))
34+
plt.xlim(bound)
35+
plt.ylim(bound)
36+
plt.xticks(fontsize=10)
37+
plt.yticks(fontsize=10)
38+
plot_contour(rosenbrock, bound, bound)
39+
plt.xlabel('维度1', fontsize=10)
40+
plt.ylabel('维度2', fontsize=10, labelpad=-1)
41+
plt.scatter([0.0], [0.0], c='green', s=24)
42+
plt.savefig(str(rosenbrock.__name__) + '.png', dpi=700, bbox_inches='tight')
43+
plt.show()
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
"""This script has been used in Qiqi Duan's Ph.D. Dissertation (HIT&SUSTech).
2+
3+
Chinese: 该绘图脚本被段琦琦的博士论文(哈工大与南科大联合培养)所使用。
4+
"""
5+
import matplotlib
6+
import matplotlib.pyplot as plt
7+
8+
from pypop7.benchmarks.utils import generate_xyz
9+
10+
11+
matplotlib.rcParams['font.family'] = 'sans-serif'
12+
matplotlib.rcParams['font.sans-serif'] = 'SimSun'
13+
matplotlib.rcParams['axes.unicode_minus'] = False
14+
matplotlib.rcParams['font.size'] = 10 # 对应5号字体
15+
16+
17+
def cd(x): # from https://arxiv.org/pdf/1610.00040v1.pdf
18+
return 7.0 * (x[0] ** 2) + 6.0 * x[0] * x[1] + 8.0 * (x[1] ** 2)
19+
20+
21+
# helper function for 2D-plotting
22+
def plot_contour(func, x, y):
23+
x, y, z = generate_xyz(func, x, y, 500)
24+
plt.contourf(x, y, z, cmap='bone')
25+
plt.contour(x, y, z, colors='white')
26+
27+
28+
if __name__ == '__main__':
29+
ndim_problem = 2
30+
bound=[-10.0, 10.0]
31+
plt.figure(figsize=(2.5, 2.5))
32+
plt.xlim(bound)
33+
plt.ylim(bound)
34+
plt.xticks(fontsize=10)
35+
plt.yticks(fontsize=10)
36+
plot_contour(cd, bound, bound)
37+
plt.xlabel('维度1', fontsize=10)
38+
plt.ylabel('维度2', fontsize=10, labelpad=-1)
39+
plt.scatter([0.0], [0.0], c='green', s=24)
40+
plt.savefig(str(cd.__name__) + '.png', dpi=700, bbox_inches='tight')
41+
plt.show()
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
"""This script has been used in Qiqi Duan's Ph.D. Dissertation (HIT&SUSTech).
2+
3+
Chinese: 该绘图脚本被段琦琦的博士论文(哈工大与南科大联合培养)所使用。
4+
"""
5+
import matplotlib
6+
import matplotlib.pyplot as plt
7+
8+
from pypop7.benchmarks.utils import generate_xyz
9+
10+
11+
matplotlib.rcParams['font.family'] = 'sans-serif'
12+
matplotlib.rcParams['font.sans-serif'] = 'SimSun'
13+
matplotlib.rcParams['axes.unicode_minus'] = False
14+
matplotlib.rcParams['font.size'] = 10 # 对应5号字体
15+
16+
17+
def non_smooth(x):
18+
return abs(x[0] - x[1]) - min(x)
19+
20+
21+
# helper function for 2D-plotting
22+
def plot_contour(func, x, y):
23+
x, y, z = generate_xyz(func, x, y, 500)
24+
plt.contourf(x, y, z, cmap='bone')
25+
plt.contour(x, y, z, colors='white')
26+
27+
28+
if __name__ == '__main__':
29+
ndim_problem = 2
30+
bound=[-10.0, 10.0]
31+
plt.figure(figsize=(2.5, 2.5))
32+
plt.xlim(bound)
33+
plt.ylim(bound)
34+
plt.xticks(fontsize=10)
35+
plt.yticks(fontsize=10)
36+
plot_contour(non_smooth, bound, bound)
37+
plt.xlabel('维度1', fontsize=10)
38+
plt.ylabel('维度2', fontsize=10, labelpad=-1)
39+
plt.plot([-10.0, 10.0], [-10.0, 10.0], c='green', linewidth=3)
40+
plt.savefig(str(non_smooth.__name__) + '.png', dpi=700, bbox_inches='tight')
41+
plt.show()
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"""This script has been used in Qiqi Duan's Ph.D. Dissertation (HIT&SUSTech).
2+
3+
Chinese: 该绘图脚本被段琦琦的博士论文(哈工大与南科大联合培养)所使用。
4+
"""
5+
import matplotlib
6+
import matplotlib.pyplot as plt
7+
8+
from pypop7.benchmarks.rotated_functions import ellipsoid
9+
from pypop7.benchmarks.rotated_functions import generate_rotation_matrix
10+
from pypop7.benchmarks.utils import generate_xyz
11+
12+
13+
matplotlib.rcParams['font.family'] = 'sans-serif'
14+
matplotlib.rcParams['font.sans-serif'] = 'SimSun'
15+
matplotlib.rcParams['axes.unicode_minus'] = False
16+
matplotlib.rcParams['font.size'] = 10 # 对应5号字体
17+
font_size = 10
18+
19+
20+
# helper function for 2D-plotting
21+
def plot_contour(func, x, y):
22+
levels = [0, 50000, 20000000, 50000000,
23+
100000000, 150000000, 200000000]
24+
generate_rotation_matrix(ellipsoid, 2, 72)
25+
x, y, z = generate_xyz(func, x, y, 500)
26+
plt.contourf(x, y, z, cmap='bone', levels=levels)
27+
plt.contour(x, y, z, colors='white')
28+
29+
30+
if __name__ == '__main__':
31+
bound=[-10.0, 10.0]
32+
plt.figure(figsize=(2.5, 2.5))
33+
plt.xlim(bound)
34+
plt.ylim(bound)
35+
plt.xticks(fontsize=font_size)
36+
plt.yticks(fontsize=font_size)
37+
plot_contour(ellipsoid, bound, bound)
38+
plt.xlabel('维度1', fontsize=font_size)
39+
plt.ylabel('维度2', fontsize=font_size, labelpad=-1)
40+
plt.scatter([0.0], [0.0], c='green', s=24)
41+
plt.savefig(str(ellipsoid.__name__) + '.png',
42+
dpi=700, bbox_inches='tight')
43+
plt.show()

0 commit comments

Comments
 (0)