当前位置: 首页 > news >正文

使用 LSSVM 的 Matlab 演示求解反常微分方程问题(Matlab代码实现)

       目录

💥1 概述

📚2 运行结果

🎉3 参考文献

👨‍💻4 Matlab代码


💥1 概述

LSSVM的特性

  1) 同样是对原始对偶问题进行求解,但是通过求解一个线性方程组(优化目标中的线性约束导致的)来代替SVM中的QP问题(简化求解过程),对于高维输入空间中的分类以及回归任务同样适用;

  2) 实质上是求解线性矩阵方程的过程,与高斯过程(Gaussian processes),正则化网络(regularization networks)和费雪判别分析(Fisher discriminant analysis)的核版本相结合;

  3) 使用了稀疏近似(用来克服使用该算法时的弊端)与稳健回归(稳健统计);

  4) 使用了贝叶斯推断(Bayesian inference);

  5) 可以拓展到非监督学习中:核主成分分析(kernel PCA)或密度聚类;

  6) 可以拓展到递归神经网络中。

📚2 运行结果

主函数部分代码:

% dot(x1)  = a * (x_2 -x_1)

% dot(x_2) = x_1 * (b- x_3) - x_2

% dot(x_3) = x_1 * x_2 -c* x_3

% 0 <=  t  < = t_f

% Initial Condition

% x_1(0) = -9.42, x_2(0)= -9.34, x_3(0)=28.3

% Theta=[a, b, c] = [10, 28, 8/3]

%% ============================================================================

clear all; close all; clc

t0=0;

tf=10;

sampling_time=0.05;

t=(t0:sampling_time:tf)';

initial=[-9.42 -9.34 28.3]; % initial values of the ODE used for generating simulated data

ExactTheta=[10; 28 ; 8/3];  % The exact parameters of the lorenz system used for generating simulated data

cprintf( [1 0.1 0],'**** Excat parameters of the Lorenz system ***** \n\n');

fprintf('True theta_1= %f \n', ExactTheta(1));

fprintf('True theta_2= %f \n', ExactTheta(2));

fprintf('True theta_3= %f \n\n', ExactTheta(3));

fprintf( '************************************* \n\n');

%%  ========= Generating the simulation data ======================

options = odeset('RelTol',1e-5,'AbsTol',[1e-5 1e-5 1e-5]);

sol = ode45(@ridg,[t0 tf],initial,options,ExactTheta);

Y=deval(sol,t);

Y=Y';

noise_level=0.01; % 0.03, 0.05, 0.07, 0.1

noise=noise_level*randn(size(t,1),1);

y1=Y(:,1)+noise;

y2=Y(:,2)+noise;

y3=Y(:,3)+noise;

%% Estimating the parameters of the ODE system:

num_realization =3;

K_fold=3;

num_grid_gam=10;

num_grid_sig=10;

gamma_range = logspace(0,6,num_grid_gam);

sigma_range = logspace(-3,1,num_grid_sig);

ER1=[];

ER2=[];

ER3=[];

Par1=zeros(num_realization,1);

Par2=zeros(num_realization,1);

Par3=zeros(num_realization,1);

BB1=zeros(num_grid_gam,num_grid_sig);

BB2=zeros(num_grid_gam,num_grid_sig);

BB3=zeros(num_grid_gam,num_grid_sig);

for itr=1:num_realization

    

    

    cprintf( [1 0.1 0],'**** iteration =%d\n',itr);

    n=size(t,1);

    ind=crossvalind('Kfold', n, K_fold);

    

    for gamma_idx=1:size(gamma_range,2)

        gamma = gamma_range(gamma_idx);

        

        for sig_idx=1:size(sigma_range,2)

            sig = sigma_range(sig_idx);

            

            test_errors_1=zeros(K_fold,1);

            test_errors_2=zeros(K_fold,1);

            test_errors_3=zeros(K_fold,1);

            

            

            for i=1:K_fold

                Xte=t(ind==i,1);

                Yte_1=y1(ind==i,1);

                Yte_2=y2(ind==i,1);

                Yte_3=y3(ind==i,1);

                Xtr=t(ind~=i,1);

                Ytr_1=y1(ind~=i,1);

                Ytr_2=y2(ind~=i,1);

                Ytr_3=y3(ind~=i,1);

                               

                K=KernelMatrix(Xtr,'RBF_kernel', sig);

                m=size(K,1);

                A= [K + (1/gamma) * eye(m), ones(m,1);...

                    ones(m,1)' ,0];

                B1= [Ytr_1;0];

                B2= [Ytr_2;0];

                B3= [Ytr_3;0];

                result1=A\B1;

                result2=A\B2;

                result3=A\B3;

                alpha1=result1(1:m);

                b1=result1(end);

                alpha2=result2(1:m);

                b2=result2(end);

                alpha3=result3(1:m);

                b3=result3(end);

                yhattr1 = K * alpha1 + b1;

                yhattr2 = K * alpha2 + b2;

                yhattr3 = K * alpha3 + b3;

🎉3 参考文献

[1]姜星宇. 基于动态粒子群算法的DPSO-LSSVM模型在短期电力负荷预测中的应用研究[D].沈阳农业大学,2022.DOI:10.27327/d.cnki.gshnu.2022.000596.

👨‍💻4 Matlab代码

http://www.lryc.cn/news/2275.html

相关文章:

  • 动态规划-背包问题
  • 计算24点与运算符重载
  • MES系统智能工厂,搭上中国制造2025顺风车
  • 【LeetCode】每日一题(1)
  • SpringCloud-Netflix学习笔记11——Hystrix实现服务降级
  • Oracle Dataguard(主库为 Oracle rac 集群)配置教程(03)—— 创建 dataguard 数据库之前的准备工作
  • 零代码做分析报表的bi软件才是好软件
  • linux ALSA 驱动架构
  • JDK 8 JVM内存结构详解
  • 黑马程序员 Linux 教程
  • 文件操作 -- IO
  • FPGA解析串口协议帧3.0版本,增加了错误重发功能,提供仿真文件以及源码
  • 365天深度学习训练营 第P6周:好莱坞明星识别
  • 一文读懂 Zebec Chain 的“先行网络” Nautilus 链
  • FuzzyMathematicalModel模糊数学模型-2-多目标模糊综合评价案例分享
  • 单链表--C语言版(从0开始,超详细解析,小白一看就会)
  • cv2-特征点匹配(bf、FLANN)
  • 基于matlab多功能相控阵雷达资源管理的服务质量优化
  • 立创eda专业版学习笔记(6)(pcb板移动节点)
  • Java面试——MyBatis相关知识
  • Cortex-M0编程入门
  • 字符串函数能有什么坏心思?
  • Vue3 组件之间的通信
  • 多路查找树
  • Mybatis——注入执行sql查询、更新、新增以及建表语句
  • 即时通讯系列-4-如何设计写扩散下的同步协议方案
  • tui-swipe-action组件上的按钮点击后有阴影的解决方法
  • 【大数据Hadoop】Hadoop 3.x 新特性总览
  • Python-第三天 Python判断语句
  • 失手删表删库,赶紧跑路?!