2024/9/1周报

摘要

本周阅读了一篇基于时间与非时间序列模型耦合来模拟城市内涝区洪水水深的文章,文中提出了一种极值梯度提升和长短记忆算法的耦合模型。通过对郑州市三个典型的洪水点的实际应用,结果表明,该耦合模型能较好地拟合和预报洪水。验证数据的平均相对误差、Nash-Sutcliffe效率系数和合格率的平均值分别为9.13%、0.96和90.3%。

Abstract

This week, an article on simulating flood depth in urban waterlogging areas based on the coupling of time and non time series models is readed. A coupled model of extreme gradient enhancement and long short-term memory algorithm is proposed in the article. Through the practical application of three typical flood points in Zhengzhou City, the results show that the coupled model can fit and predict floods well. The average relative error, Nash Sutcliffe efficiency coefficient, and pass rate of the validation data are 9.13%, 0.96%, and 90.3%, respectively. In addition, supplementary learning is conducted on the relevant content of Boosting algorithm used in the article, which is an algorithm related to enhancement and enhancement.

文献阅读

题目

Coupling Time and Non‑Time Series Models to Simulate the Flood Depth at Urban Flooded Area

创新点

本研究将XGBoost回归模型与LSTM回归模型耦合,对郑州市部分洪泛区的洪水埋深进行了预测。
具体如下:
(1)将洪水的突变过程分为雨期和雨后两个阶段;
(2)利用降雨资料,建立非时间序列回归模型,利用XGBoost算法预测雨期洪水的水深;
(3)基于XGBoost回归模型预测的数据,将LSTM算法应用于时间序列模型,预测雨后洪水的洪水深度;
(4)利用XGBoost和LSTM算法耦合模型预测不同重现期降雨淹没区的洪水深度。

实验数据

研究区域

在这里插入图片描述

郑州地理位置所导致的大陆性季风气候(Lv et al. 2021),尽管年降雨量达到640.9 mm,但60%的降水集中在夏季,这导致郑州市城市洪水风险增加。

自数据记录开始以来,有些地区被洪水淹没的频率很高,选择A点、B点和C点作为本次研究的重点水淹区。

数据和材料

本研究将降雨量的相关数据作为预测变量输入模型,将各点的洪水深数据作为模型的输出变量。所需数据的详细说明如下:
1.雨量数据:降雨量数据为郑州市16个雨量观测站在历史降雨事件下的自记雨量计观测到的降雨量时间序列数据。数据来自河南省气象局。
2.泛洪数据:洪水数据包括城市灾害数据库中存储的城市淹没区域的位置和深度信息,这些信息是从每个交叉口的监测设备收集的。这些监测设备由郑州市城市管理局管理。

方法

XGBoost algorithm

XGBoost算法由多个相关的CART树共同决定,因此下一个决策树的输入样本将与前一个决策树的训练和预测结果相关:
在这里插入图片描述

XGBoost算法是一种用于大规模并行化的提升树集成,是目前最快和最好的集成决策树算法。XGBoost算法原理的推导过程如下:
在这里插入图片描述

Long Short‑Term Memory Algorithm

LSTM算法与大多数神经网络具有相同的结构,即输入层,隐藏层和输出层。LSTM中隐藏层的单元是线性自循环记忆块,包含自连接记忆单元的记忆块可以记忆时间状态(如下图)。依靠三个门(输入门it、输出门ot和遗忘门ft)来控制信息流入和流出:
在这里插入图片描述

任何时间t的输入特征由输入xt和先前的隐藏状态ht-1通过tanh函数计算:
在这里插入图片描述

输入特征和先前存储器单元的部分遗忘用于更新存储器单元,并且隐藏输出状态ht最终由输出门ot和存储器ct计算:
在这里插入图片描述

LSTM网络yt的输出可以表示为:
在这里插入图片描述

Evaluation of the Model Accuracy

选择平均相对误差、Nash-Sutcliffe效率系数和合格率(MRE、NSE和QR)(表1)作为模型的定量评价指标:
在这里插入图片描述

实验结果

为了验证模型的有效性,将LSTM模型与XGBoost回归模型进行比较,将相同的数据应用于XGBoost模型和LSTM模型。如表所示,经验证的三个降雨事件的LSTM和XGBoost模型得到的平均NSE分别为0.90和0.86。LSTM模型的MRE值较低,表明LSTM模型对雨后期城市洪水深度的预测精度更高。
在这里插入图片描述

对3次降雨事件的模拟结果进行分析,降雨期间XGBoost模型、降雨后LSTM模型和XGBoost与LSTM模型耦合模型模拟的洪水深度平均误差分别为8.87%、9.77%和9.13%,满足洪水预测的要求。同时,利用NSE和QR来评价模型的效率和精度。耦合模型的平均NSE为0.96,平均预测合格率为90.3%。结果表明,XGBoost与LSTM算法的耦合模型在洪水预报中是有效可行。

为了评估模拟值与实测值的差异,通过间隔10 min的系统采样生成拟合曲线如右图,结果表明,耦合模型预测值与实测值具有较强的一致性:
在这里插入图片描述

Java开发环境

1.首先下载jdk
进入oracle官网,这里选择下载jdk8的版本:
在这里插入图片描述
2.下载安装后配置系统变量
在这里插入图片描述
3.使用IntelliJ IDEA进行java程序编写
如下是一个简单日历程序的编写:

import java.util.Scanner;

public class Rili {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

//    1.第一步获取到输入的年月
        System.out.println("请输入年份:");
        int year = input.nextInt();
        System.out.println("请输入月份:");
        int month = input.nextInt();

//    2. 核心,190011日是星期一  202261日是星期几? 总天数/7
        int days = 0;  //统计总天数
        for (int i = 1900; i < year; i++){
            if (i%4 == 0 && i%100 != 0 || i%400 == 0){
                days += 366;
            }else
                days += 365;
        }
        for (int j = 1; j < month; j++){
            if (j == 2){
                if (year%4 == 0 && year%100 != 0 || year%400 == 0){
                    days += 29;
                }else
                    days += 28;
            }
            if (j == 1 || j == 3 || j == 5 || j == 7 || j == 8 || j == 10 || j == 12){
                days += 31;
            }
            if (j == 4 || j == 6 || j == 9 || j == 11){
                days += 30;
            }
        }
        System.out.println(days);
        int week = days%7 + 1;
        System.out.println("星期" + week);
//   3.打印表
        System.out.println("一\t二\t三\t四\t五\t六\t日\t");
        for (int i = 1; i < week; i++){
            System.out.print("\t");
        }
        int dayofmonth = 0;
        switch (month){
            case 2:
                if (year%4 == 0 && year%100 != 0 || year%400 == 0){
                    dayofmonth = 29;
                }else
                    dayofmonth = 28;
                break;
            case 4:
            case 6:
            case 9:
            case 11:
                dayofmonth = 30;
                break;
            default:
                dayofmonth = 31;
                break;
        }
        for (int i = 1; i <= dayofmonth; i++){
            System.out.print(i + "\t");
            if ((week - 1 + i)%7 == 0){
            System.out.println();
            }
        }
    }
}

运行结果如下:
在这里插入图片描述

bug记录
IntelliJ IDEA Ultimate 2024最新版遇到scanner不能输入中文的情况,查阅资料和多方求助后无果,最终选择卸载重新安装2023年的旧版本解决。
在这里插入图片描述
在这里插入图片描述

简单的LSTM结合GA优化的代码示例

import numpy as np
import tensorflow as tf
from deap import base, creator, tools, algorithms
from sklearn.metrics import mean_squared_error

# 设置随机种子以保证可重复性
np.random.seed(42)
tf.random.set_seed(42)

# 定义优化问题
creator.create("FitnessMin", base.Fitness, weights=(-1.0,))  # 最小化损失
creator.create("Individual", list, fitness=creator.FitnessMin)

toolbox = base.Toolbox()
toolbox.register("attr_int", np.random.randint, 10, 100)
toolbox.register("attr_float", np.random.uniform, 0.001, 0.01)
toolbox.register("individual", tools.initCycle, creator.Individual, (toolbox.attr_int, toolbox.attr_float), n=1)
toolbox.register("population", tools.initRepeat, list, toolbox.individual)

def evaluate(individual):
    units = int(round(individual[0]))  # 确保单元数是整数
    lr = individual[1]

    # 构建并训练 LSTM 模型
    model = tf.keras.Sequential([
        tf.keras.layers.LSTM(units=units, input_shape=(X_train.shape[1], X_train.shape[2])),
        tf.keras.layers.Dense(1)
    ])

    model.compile(optimizer=tf.keras.optimizers.Adam(learning_rate=lr), loss='mse')
    model.fit(X_train, y_train, epochs=10, batch_size=32, verbose=0)

    # 评估模型性能
    y_pred = model.predict(X_test)
    mse = mean_squared_error(y_test, y_pred)

    return mse,

toolbox.register("evaluate", evaluate)
toolbox.register("mate", tools.cxBlend, alpha=0.5)
toolbox.register("mutate", tools.mutGaussian, mu=0, sigma=1, indpb=0.2)
toolbox.register("select", tools.selTournament, tournsize=3)

# 创建数据集
X_train, X_test, y_train, y_test = np.random.rand(100, 10, 1), np.random.rand(20, 10, 1), np.random.rand(100), np.random.rand(20)

population = toolbox.population(n=10)
algorithms.eaSimple(population, toolbox, cxpb=0.5, mutpb=0.2, ngen=5, verbose=True)

# 打印最佳个体
for ind in tools.sortNondominated(population, len(population), first_front_only=True)[0]:
    print(ind, ind.fitness.values)


结果如下:
在这里插入图片描述

总结

本周对智慧水务项目进行进一步学习,在对遗传算法和GA算法有一定的了解后,尝试使用GA和LSTM相结合,通过遗传算法优化 LSTM 模型的超参数,找出最优的超参数组合以最小化模型的均方误差。

  • 6
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值