├── .idea ├── .gitignore ├── 2023.iml ├── inspectionProfiles │ └── profiles_settings.xml ├── misc.xml ├── modules.xml ├── other.xml └── vcs.xml ├── B题.pdf ├── B题.rar ├── README.md ├── appendix.xlsx ├── format2023.doc ├── q1.py ├── q1_result.xlsx ├── q2.py ├── q2_result.xlsx ├── q3.py ├── q3_path.png ├── q3_result.xlsx ├── q3_result1.xlsx ├── q4.py ├── q4_floor.png ├── result1.xlsx └── result2.xlsx /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # 默认忽略的文件 2 | /shelf/ 3 | /workspace.xml 4 | # 基于编辑器的 HTTP 客户端请求 5 | /httpRequests/ 6 | # Datasource local storage ignored files 7 | /dataSources/ 8 | /dataSources.local.xml 9 | -------------------------------------------------------------------------------- /.idea/2023.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 11 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/other.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /B题.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gis-Code/2023_MathModeling_QuestionB/b3945245ff756780faca02c57d3a39afa26a026e/B题.pdf -------------------------------------------------------------------------------- /B题.rar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gis-Code/2023_MathModeling_QuestionB/b3945245ff756780faca02c57d3a39afa26a026e/B题.rar -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 2023年数学建模国赛B题解题代码 2 | 3 | ## 问题一 4 | 5 | 结果存储于**q1_result.xlsx**文件,由`q1.py`代码进行生成 6 | 7 | ## 问题二 8 | 9 | 结果存储**q2_result.xlsx**中,由`q2.py`代码计算生成 10 | 11 | ## 问题三 12 | 13 | 52条测线,路线效果图 14 | 15 | ![path](q3_path.png) 16 | 17 | ## 问题四 18 | 19 | 先根据附件数据,复原海底地貌等高地形图 20 | 21 | ![floor](q4_floor.png) -------------------------------------------------------------------------------- /appendix.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gis-Code/2023_MathModeling_QuestionB/b3945245ff756780faca02c57d3a39afa26a026e/appendix.xlsx -------------------------------------------------------------------------------- /format2023.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gis-Code/2023_MathModeling_QuestionB/b3945245ff756780faca02c57d3a39afa26a026e/format2023.doc -------------------------------------------------------------------------------- /q1.py: -------------------------------------------------------------------------------- 1 | # %% 2 | import math 3 | import pandas as pd 4 | 5 | alpha = math.pi / 120 6 | theta = math.pi * 2 / 3 7 | distance = [-800, -600, -400, -200, 0, 200, 400, 600, 800] 8 | depth_list = [] 9 | 10 | 11 | # %% 12 | def width_calculate(d): 13 | depth = 70 - (d * math.tan(alpha)) 14 | depth_list.append(depth) 15 | width = depth * math.sin(theta / 2) * ((1 / math.cos(theta / 2 + alpha)) + (1 / math.cos(theta / 2 - alpha))) 16 | return width 17 | 18 | 19 | # %% 20 | result_width = [] 21 | for d_data in distance: 22 | w = width_calculate(d_data) 23 | result_width.append(w) 24 | 25 | print("Width data:", result_width) 26 | 27 | 28 | # %% 29 | def duplication_calculate(): 30 | var = (200 * math.cos(theta / 2)) / (math.cos(theta / 2 - alpha)) 31 | return var 32 | 33 | 34 | def coverage_calculate(var, w): 35 | return 1 - var / w 36 | 37 | 38 | # %% 39 | coverage_list = [] 40 | for d_data in distance: 41 | cov = coverage_calculate(duplication_calculate(), width_calculate(d_data)) 42 | coverage_list.append(cov) 43 | 44 | print("Coverage data:", coverage_list) 45 | 46 | # %% 47 | depth_list = depth_list[:9] 48 | 49 | # %% 50 | result = [depth_list, result_width, coverage_list] 51 | result_data = pd.DataFrame(result) 52 | result_data.to_excel('q1_result.xlsx', index=False) 53 | -------------------------------------------------------------------------------- /q1_result.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gis-Code/2023_MathModeling_QuestionB/b3945245ff756780faca02c57d3a39afa26a026e/q1_result.xlsx -------------------------------------------------------------------------------- /q2.py: -------------------------------------------------------------------------------- 1 | # %% 2 | import math 3 | import pandas as pd 4 | 5 | alpha = math.pi / 120 6 | theta = math.pi * 2 / 3 7 | beta_data = [0.0, math.pi / 4, math.pi / 2, math.pi * 3 / 4, math.pi, math.pi * 5 / 4, math.pi * 3 / 2, math.pi * 7 / 4] 8 | n_mile = 1852 9 | distance_data = [0.0, 0.3 * n_mile, 0.6 * n_mile, 0.9 * n_mile, 1.2 * n_mile, 1.5 * n_mile, 1.8 * n_mile, 2.1 * n_mile] 10 | 11 | # %% 12 | delta_data = [] 13 | depth_data = [] 14 | for beta in beta_data: 15 | tan_delta = math.tan(alpha) * abs(math.sin(beta)) 16 | # print("tan value: ",tan_delta) 17 | # print("angle: ",math.atan(tan_delta)) 18 | delta_data.append(math.atan(tan_delta)) 19 | 20 | list = [] 21 | for distance in distance_data: 22 | depth = 120 + distance * math.cos(beta) * math.tan(alpha) 23 | list.append(depth) 24 | depth_data.append(list) 25 | 26 | # %% 27 | width_data = [] 28 | index = 0 29 | for beta in beta_data: 30 | index = beta_data.index(beta) 31 | d_list = depth_data[index] 32 | w_list = [] 33 | for depth in d_list: 34 | width = (2 * depth * math.cos(delta_data[index]) * math.sin(theta)) / ( 35 | math.cos(theta) + math.cos(2 * delta_data[index])) 36 | w_list.append(width) 37 | width_data.append(w_list) 38 | 39 | # %% 40 | result_data = pd.DataFrame(width_data) 41 | result_data.to_excel('q2_result.xlsx', index=False) 42 | -------------------------------------------------------------------------------- /q2_result.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gis-Code/2023_MathModeling_QuestionB/b3945245ff756780faca02c57d3a39afa26a026e/q2_result.xlsx -------------------------------------------------------------------------------- /q3.py: -------------------------------------------------------------------------------- 1 | # %% 2 | import math 3 | 4 | import numpy as np 5 | 6 | alpha = math.pi / 120 7 | theta = math.pi * 2 / 3 8 | n_mile = 1852 9 | D_max = 110 + 2 * n_mile * math.tan(alpha) 10 | 11 | 12 | # %% 13 | def depth_calculate(distance): # distance 表示当前位置到最西边的距离 14 | return D_max - distance * math.tan(alpha) 15 | 16 | 17 | # %% 18 | d0 = D_max * math.tan(math.pi / 3) 19 | 20 | # %% 21 | import sympy as sp 22 | 23 | 24 | # def width_calculate(distance): 25 | # return (2 * depth_calculate(distance) * math.cos(alpha) * math.sin(theta)) / (math.cos(theta) + math.cos(2 * alpha)) 26 | # 27 | # 28 | # def coverage_calculate(difference, last_distance): 29 | # # different 表示两条侧线之间的距离 30 | # var = (difference * math.cos(theta / 2)) / (math.cos(theta / 2 + alpha)) 31 | # cur_distance = difference + last_distance 32 | # return 1 - var / width_calculate(cur_distance) 33 | 34 | 35 | # %% 36 | def difference_inequality(last_distance): 37 | x = sp.symbols('x') 38 | var = 1 - ((x * math.cos(theta / 2)) / (math.cos(theta / 2 + alpha))) / ( 39 | (2 * (D_max - (last_distance + x) * math.tan(alpha)) * math.cos(alpha) * math.sin(theta)) / ( 40 | math.cos(theta) + math.cos(2 * alpha))) 41 | formula=sp.Eq(var,0.1) 42 | solution=sp.solve(formula,x) 43 | return solution 44 | 45 | # %% 46 | difference_list=[] 47 | cur=d0 48 | while sum(difference_list)<=7408: 49 | s=difference_inequality(cur) 50 | difference_list.append(s[0]) 51 | cur+=s[0] 52 | depth = depth_calculate(sum(difference_list)) 53 | x = (depth * math.sin(theta / 2)) / math.cos(theta / 2 - alpha) 54 | total = x + sum(difference_list) 55 | if total>=7408: 56 | break 57 | 58 | # %% 59 | difference_list.pop() 60 | depth1 = depth_calculate(sum(difference_list)) 61 | x1 = (depth1 * math.sin(theta / 2)) / math.cos(theta / 2 - alpha) 62 | total1 = x1 + sum(difference_list) 63 | 64 | # %% 65 | import pandas as pd 66 | result=pd.DataFrame(difference_list) 67 | result.to_excel('q3_result1.xlsx',index=False) 68 | 69 | # %% 70 | import matplotlib.pyplot as plt 71 | # difference_list.reverse() 72 | pos=[] 73 | for i in range(len(difference_list)): 74 | pos.append(2*1852) 75 | plt.bar(difference_list,pos) 76 | plt.title('Survey_path') 77 | plt.xlabel('Position_from_E_to_W') 78 | plt.ylabel('From_S_to_N(M)') 79 | plt.show() 80 | 81 | -------------------------------------------------------------------------------- /q3_path.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gis-Code/2023_MathModeling_QuestionB/b3945245ff756780faca02c57d3a39afa26a026e/q3_path.png -------------------------------------------------------------------------------- /q3_result.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gis-Code/2023_MathModeling_QuestionB/b3945245ff756780faca02c57d3a39afa26a026e/q3_result.xlsx -------------------------------------------------------------------------------- /q3_result1.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gis-Code/2023_MathModeling_QuestionB/b3945245ff756780faca02c57d3a39afa26a026e/q3_result1.xlsx -------------------------------------------------------------------------------- /q4.py: -------------------------------------------------------------------------------- 1 | # %% 2 | import numpy as py 3 | import pandas as pd 4 | import matplotlib.pyplot as plt 5 | 6 | depth_dataFrame = pd.read_excel('appendix.xlsx') 7 | depth_data = depth_dataFrame.values 8 | 9 | # %% 10 | # depth_data=py.delete(depth_data,0,axis=0) 11 | depth_data = py.delete(depth_data, 0, axis=1) 12 | depth_data[0, 0] = 0.0 13 | 14 | # %% 15 | x_coordinate = depth_data[0, :] 16 | y_coordinate = depth_data[:, 0] 17 | 18 | # %% 19 | x_cor = x_coordinate.tolist() 20 | y_cor = y_coordinate.tolist() 21 | 22 | # %% 23 | del x_cor[0] 24 | del y_cor[0] 25 | 26 | # %% 27 | presicion = 2 28 | x = [round(num, presicion) for num in x_cor] 29 | y = [round(num, presicion) for num in y_cor] 30 | 31 | # %% 32 | X,Y=py.meshgrid(x,y) 33 | 34 | # %% 35 | depth_data = py.delete(depth_data, 0, axis=0) 36 | depth_data = py.delete(depth_data, 0, axis=1) 37 | # %% 38 | negated=[[-n for n in row]for row in depth_data] 39 | 40 | # %% 41 | plt.figure(figsize=(10,7.5)) 42 | contours=plt.contour(X,Y,negated,cmap='Blues_r') 43 | plt.clabel(contours,inline=True,fontsize=8,colors='black') 44 | plt.xlabel('From_W_to_E(NM)') 45 | plt.ylabel('From_S_to_N(NM)') 46 | plt.title('Ocean_floor(M)') 47 | plt.contourf(x,y,negated,cmap='Blues_r',alpha=0.75) 48 | plt.colorbar(shrink=0.8) 49 | plt.grid(True) 50 | plt.show() -------------------------------------------------------------------------------- /q4_floor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gis-Code/2023_MathModeling_QuestionB/b3945245ff756780faca02c57d3a39afa26a026e/q4_floor.png -------------------------------------------------------------------------------- /result1.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gis-Code/2023_MathModeling_QuestionB/b3945245ff756780faca02c57d3a39afa26a026e/result1.xlsx -------------------------------------------------------------------------------- /result2.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gis-Code/2023_MathModeling_QuestionB/b3945245ff756780faca02c57d3a39afa26a026e/result2.xlsx --------------------------------------------------------------------------------