以下内容为全部求解完A题后,写下。内容具有绝对可行性,下面为问题一二三四结果可视化结果。

2024年深圳杯&东三省数学建模联赛A题超详细解题思路-LMLPHP

深圳杯A题超详细解题思路+问题一代码分享资料链接:https://pan.baidu.com/s/1L2NVgoefSW-yuqZjEB3wcw 提取码:sxjm

问题简述

u 单个残骸定位:确定用于精确测定单个空中火箭残骸音爆位置的最少监测设备数量,并计算指定数据中的残骸位置。

u 多个残骸定位:开发一个模型来分析和确定哪些震动波数据来自哪个残骸,并确定在空中有多个残骸同时发生音爆时的残骸位置和时间。

u 增强模型:在考虑监测设备记录时间可能存在的随机误差下,调整模型以更精确地确定多个残骸的位置和时间。

对于该问题,不用于以往的数学建模赛题,没有给出过多的数据。因此对于该题目的数据预处理,我们只能进行大致的数据描述,即绘制给出数据的散点图即可,

(例如,问题一可以绘制一下在三维坐标系下,每个监测点可能检测到的来源 即一个球体)

2024年深圳杯&东三省数学建模联赛A题超详细解题思路-LMLPHP

问题一:单个残骸定位

残骸发生音爆的位置(x,y,z) 和时间t。给定7台设备的三维坐标和音爆抵达时间,我们可以使用多边测量技术建立以下方程组,对于每个设备i:

2024年深圳杯&东三省数学建模联赛A题超详细解题思路-LMLPHP

这里,(xi,yi,zi)和ti分别是第i台设备的坐标和音爆抵达时间。我们需要解这个方程组来找出(x,y,z,t)。

文末给出两套实现代码,用python或者matlab运行,可直接运行出结果。

基于这个模型,首先需要将设备的地理坐标(经度、纬度)转换为一个更适合计算的坐标系统,如笛卡尔坐标系。可以使用下列近似方法:

将纬度转换为Y坐标:=纬度×111263Y=纬度×111263米(纬度每度的距离)

将经度转换为X坐标:=经度×97304X=经度×97304米(经度每度的距离,取决于纬度)

高程(Z坐标)直接使用给定的米值

最终结果:音爆发生的位置大约是:

X坐标:1.07784×107 米

Y坐标:2.99621×106 米

高程:717.63 米

时间偏移:-74.52 秒(相对于设备A的记录时间)

问题二三:多残骸定位

问题三涉及到了,确定每个监测设备接收到的不同音爆数据属于哪个具体的残骸。此外,还需要确定这些残骸的精确位置和音爆时间。涉及到了最优值的求解,属于优化模型。建立一个数学模型来解决多源定位问题。可以设置一个优化问题,目标是最小化预测的音爆位置和实际接收时间之间的误差。这可能涉及到非线性最优化或者迭代重定位技术。

首先与问题一相同,将设备的经纬度坐标转换为笛卡尔坐标系统,以便进行空间计算。由于每个设备记录了多个音爆时间,我们需要首先确定哪些时间点是由同一个残骸引起的。这可以通过比较不同设备间音爆抵达时间的相对差异来实现。例如,如果两个设备对同一残骸的音爆抵达时间的差异与它们之间的距离和声速计算得出的传播时间差匹配,则可以假定它们是由同一音爆引起的。对于每组关联的音爆时间(即认为来自同一残骸的音爆时间),设置一个优化问题,以确定该残骸的位置和音爆时间。目标是最小化预测的音爆抵达时间和实际记录时间之间的误差。

使用非线性最优化方法(如梯度下降、牛顿法等)求解每个残骸的位置和音爆时间。考虑到问题的非线性和多解性,可能需要适当的初始值和约束来确保收敛到合理的解。

具体结果如下所示

2024年深圳杯&东三省数学建模联赛A题超详细解题思路-LMLPHP

问题四:增强模型

首先,为每个设备记录的时间添加一个随机误差,模拟实际条件中可能的测量不准确性。这个误差可以通过添加一个均值为0,标准差为0.5秒的高斯(正态)噪声来模拟。对于包含随机误差的数据,我们需要使用一种更加健壮的定位技术,比如加权最小二乘法(WLS),其中权重可以是与设备的测量精度相关的逆方差。利用改进后的模型进行参数优化,求解残骸的位置和时间。由于噪声的引入,可能需要更多的迭代次数或更高级的优化算法以确保找到全局最优解。

具体求解优化模型:

目标函数

目标是找到最优的残骸位置和时间以及设备布置方案

决策变量

每个残骸位置和时间都由4个参数表示:x,y,z坐标和时间t。

我们的目标是优化这16个参数,以最小化目标函数。

约束条件

时间差异限制:确保每个残骸的音爆时间与实际观测的时间差异不超过5秒。

参数边界限制:对每个参数设置了边界,以确保其值在合理范围内。

优化算法(Differential Evolution)

使用差分进化算法进行优化,这是一种全局优化算法,用于解决连续和离散优化问题。

差分进化算法通过生成和演化候选解的群体来搜索参数空间,以找到最优解。

具体设置参数 如下所示

# 差分进化优化
result = differential_evolution(
objective_function, bounds, strategy='best1bin', maxiter=10000, popsize=30, tol=0.01, mutation=(0.5, 1), recombination=0.8)

import numpy as np
from scipy.optimize import minimize

# 设备数据:经度、纬度、高程、音爆抵达时间
device_data = {
    'A': {'lon': 110.241, 'lat': 27.204, 'alt': 824, 'time': 100.767},
    'B': {'lon': 110.780, 'lat': 27.456, 'alt': 727, 'time': 112.220},
    'C': {'lon': 110.712, 'lat': 27.785, 'alt': 742, 'time': 188.020},
    'D': {'lon': 110.251, 'lat': 27.825, 'alt': 850, 'time': 258.985}
}

# 声速 m/s
c = 340

# 经纬度转换为米
def convert_coordinates(lon, lat, alt):
    lat_to_m = 111263  # 纬度每度的距离,单位米
    lon_to_m = 97304   # 经度每度的距离,依赖纬度
    x = lon * lon_to_m
    y = lat * lat_to_m
    z = alt
    return x, y, z
# 设备的笛卡尔坐标和时间
device_coords = {key: convert_coordinates(val['lon'], val['lat'], val['alt']) + (val['time'],) for key, val in device_data.items()}

# 定义要最小化的函数
def objective_function(vars):
    x, y, z, t = vars
    total_error = 0
    for key, value in device_coords.items():
        x_i, y_i, z_i, t_i = value
        predicted_time = t + np.sqrt((x - x_i)**2 + (y - y_i)**2 + (z - z_i)**2) / c
        total_error += (predicted_time - t_i)**2
    return total_error

# 初始猜测(取一个设备位置和时间附近的值)
initial_guess = [device_coords['A'][0], device_coords['A'][1], device_coords['A'][2], device_coords['A'][3]]

# 进行最小化
result = minimize(objective_function, initial_guess, method='BFGS')

result


import matplotlib.pyplot as plt

# 计算得到的笛卡尔坐标转换回地理坐标
def cartesian_to_geographic(x, y, z):
    lat_to_m = 111263  # 纬度每度的距离,单位米
    lon_to_m = 97304   # 经度每度的距离,依赖纬度
    lon = x / lon_to_m
    lat = y / lat_to_m
    alt = z
    return lon, lat, alt

# 转换坐标
calculated_lon, calculated_lat, calculated_alt = cartesian_to_geographic(result.x[0], result.x[1], result.x[2])

# 绘制设备位置和计算得到的残骸位置
fig, ax = plt.subplots()
device_lons = [cartesian_to_geographic(*device_coords[key][:3])[0] for key in device_coords]
device_lats = [cartesian_to_geographic(*device_coords[key][:3])[1] for key in device_coords]

ax.scatter(device_lons, device_lats, color='blue', label='Monitoring Devices')
ax.scatter([calculated_lon], [calculated_lat], color='red', marker='*', s=200, label='Calculated Debris Location')
ax.set_xlabel('Longitude (degrees)')
ax.set_ylabel('Latitude (degrees)')
ax.set_title('Geographic Positions of Devices and Calculated Debris Location')
ax.legend()
plt.show()

(calculated_lon, calculated_lat, calculated_alt)


from mpl_toolkits.mplot3d import Axes3D

# 三维可视化设备位置和计算得到的残骸位置
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

device_x = [device_coords[key][0] for key in device_coords]
device_y = [device_coords[key][1] for key in device_coords]
device_z = [device_coords[key][2] for key in device_coords]

# 绘制设备位置
ax.scatter(device_x, device_y, device_z, color='blue', label='Monitoring Devices')

# 绘制计算得到的残骸位置
calculated_x, calculated_y, calculated_z = result.x[:3]
ax.scatter([calculated_x], [calculated_y], [calculated_z], color='red', marker='*', s=200, label='Calculated Debris Location')

ax.set_xlabel('X (m)')
ax.set_ylabel('Y (m)')
ax.set_zlabel('Z (m)')
ax.set_title('3D Positions of Devices and Calculated Debris Location')
ax.legend()

plt.show()
 
% 设备数据:经度、纬度、高程、音爆抵达时间
device_data = struct(...
'A', struct('lon', 110.241, 'lat', 27.204, 'alt', 824, 'time', 100.767), ...
'B', struct('lon', 110.780, 'lat', 27.456, 'alt', 727, 'time', 112.220), ...
'C', struct('lon', 110.712, 'lat', 27.785, 'alt', 742, 'time', 188.020), ...
'D', struct('lon', 110.251, 'lat', 27.825, 'alt', 850, 'time', 258.985) ...
);
 
% 声速 m/s
c = 340;
 
% 经纬度转换为米
function [x, y, z] = convert_coordinates(lon, lat, alt)
lat_to_m = 111263; % 纬度每度的距离,单位米
lon_to_m = 97304; % 经度每度的距离,依赖纬度
x = lon * lon_to_m;
y = lat * lat_to_m;
z = alt;
end
 
% 设备的笛卡尔坐标和时间
device_coords = cell(numel(fieldnames(device_data)), 1);
keys_data = fieldnames(device_data);
for i = 1:numel(keys_data)
val = device_data.(keys_data{i});
[x, y, z] = convert_coordinates(val.lon, val.lat, val.alt);
device_coords{i} = [x, y, z, val.time];
end
 
% 定义要最小化的函数
function total_error = objective_function(vars, device_coords, c)
x = vars(1);
y = vars(2);
z = vars(3);
t = vars(4);
total_error = 0;
for i = 1:numel(device_coords)
value = device_coords{i};
x_i = value(1);
y_i = value(2);
z_i = value(3);
t_i = value(4);
predicted_time = t + sqrt((x - x_i)^2 + (y - y_i)^2 + (z - z_i)^2) / c;
total_error = total_error + (predicted_time - t_i)^2;
end
end
 
% 初始猜测(取一个设备位置和时间附近的值)
initial_guess = [device_coords{1}(1:3), device_coords{1}(4)];
 
% 进行最小化
result = fminsearch(@(vars) objective_function(vars, device_coords, c), initial_guess);
 
result
 
% 计算得到的笛卡尔坐标转换回地理坐标
function [lon, lat, alt] = cartesian_to_geographic(x, y, z)
lat_to_m = 111263; % 纬度每度的距离,单位米
lon_to_m = 97304; % 经度每度的距离,依赖纬度
lon = x / lon_to_m;
lat = y / lat_to_m;
alt = z;
end
 
% 转换坐标
[calculated_lon, calculated_lat, calculated_alt] = cartesian_to_geographic(result(1), result(2), result(3));
 
% 绘制设备位置和计算得到的残骸位置
device_lons = zeros(1, numel(device_coords));
device_lats = zeros(1, numel(device_coords));
for i = 1:numel(device_coords)
[device_lons(i), device_lats(i), ~] = cartesian_to_geographic(device_coords{i}(1), device_coords{i}(2), device_coords{i}(3));
end
 
scatter(device_lons, device_lats, 'b', 'DisplayName', 'Monitoring Devices');
hold on;
scatter(calculated_lon, calculated_lat, 'r', 'filled', 'DisplayName', 'Calculated Debris Location');
xlabel('Longitude (degrees)');
ylabel('Latitude (degrees)');
title('Geographic Positions of Devices and Calculated Debris Location');
legend('Location', 'best');
hold off;
 
(calculated_lon, calculated_lat, calculated_alt)
 
% 三维可视化设备位置和计算得到的残骸位置
figure;
device_x = zeros(1, numel(device_coords));
device_y = zeros(1, numel(device_coords));
device_z = zeros(1, numel(device_coords));
for i = 1:numel(device_coords)
device_x(i) = device_coords{i}(1);
device_y(i) = device_coords{i}(2);
device_z(i) = device_coords{i}(3);
end
 
scatter3(device_x, device_y, device_z, 'b', 'DisplayName', 'Monitoring Devices');
hold on;
scatter3(result(1), result(2), result(3), 'r', 'filled', 'DisplayName', 'Calculated Debris Location');
xlabel('X (m)');
ylabel('Y (m)');
zlabel('Z (m)');
title('3D Positions of Devices and Calculated Debris Location');
legend('Location', 'best');
hold off;
04-23 08:32