萤火虫模糊回归算法(Matlab代码实现)

news2024/10/2 8:41:28

 🍒🍒🍒欢迎关注🌈🌈🌈

📝个人主页:我爱Matlab


👍点赞➕评论➕收藏 == 养成习惯(一键三连)🌻🌻🌻

🍌希望大家多多支持🍓~一起加油 🤗

💬语录:将来的我一定会感谢现在奋斗的自己!

🍁🥬🕒摘要🕒🥬🍁

萤火虫算法模拟了萤火虫的自然现象。真实的萤火虫自然地呈现出一种离散的闪烁模式,而萤火虫算法假设它们总是在发光。为了模拟萤火虫的这种闪烁行为,Yang Xin-She提出了了三条规则(Yang,2009):
(1)假设所有萤火虫都是雌雄同体的,因此一只萤火虫可能会被其他任何萤火虫吸引。
(2)萤火虫的亮度决定其吸引力的大小,较亮的萤火虫吸引较暗的萤火虫。如果没有萤火虫比被考虑的萤火虫更亮,它就会随机移动。
(3)函数的最优值与萤火虫的亮度成正比。

✨🔎⚡运行结果⚡🔎✨

 

💂♨️👨‍🎓Matlab代码👨‍🎓♨️💂
 

clc;
clear;
warning('off');
% Data Loading
data=JustLoad();
% Generate Fuzzy Model
ClusNum=4; % Number of Clusters in FCM
%
fis=GenerateFuzzy(data,ClusNum);
%
%% Tarining FireFly Algorithm
FireFlyFis=FireFlyRegression(fis,data);
       

%% Plot Fuzzy FireFly Results (Train - Test)
% Train Output Extraction
TrTar=data.TrainTargets;
TrainOutputs=evalfis(data.TrainInputs,FireFlyFis);
% Test Output Extraction
TsTar=data.TestTargets;
TestOutputs=evalfis(data.TestInputs,FireFlyFis);
% Train calc
Errors=data.TrainTargets-TrainOutputs;
MSE=mean(Errors.^2);RMSE=sqrt(MSE);  
error_mean=mean(Errors);error_std=std(Errors);
% Test calc
Errors1=data.TestTargets-TestOutputs;
MSE1=mean(Errors1.^2);RMSE1=sqrt(MSE1);  
error_mean1=mean(Errors1);error_std1=std(Errors1);
% Train
figure('units','normalized','outerposition',[0 0 1 1])
subplot(3,2,1);
plot(data.TrainTargets,'c');hold on;
plot(TrainOutputs,'k');legend('Target','Output');
title('FireFly Training Part');xlabel('Sample Index');grid on;
% Test
subplot(3,2,2);
plot(data.TestTargets,'c');hold on;
plot(TestOutputs,'k');legend('FireFly Target','FireFly Output');
title('FireFly Testing Part');xlabel('Sample Index');grid on;
% Train
subplot(3,2,3);
plot(Errors,'k');legend('FireFly Training Error');
title(['Train MSE =     ' num2str(MSE) '  ,     Train RMSE =     ' num2str(RMSE)]);grid on;
% Test
subplot(3,2,4);
plot(Errors1,'k');legend('FireFly Testing Error');
title(['Test MSE =     ' num2str(MSE1) '  ,    Test RMSE =     ' num2str(RMSE1)]);grid on;
% Train
subplot(3,2,5);
h=histfit(Errors, 50);h(1).FaceColor = [.8 .8 0.3];
title(['Train Error Mean =   ' num2str(error_mean) '  ,   Train Error STD =   ' num2str(error_std)]);
% Test
subplot(3,2,6);
h=histfit(Errors1, 50);h(1).FaceColor = [.8 .8 0.3];
title(['Test Error Mean =   ' num2str(error_mean1) '  ,   Test Error STD =    ' num2str(error_std1)]);

%% Plot Just Fuzzy Results (Train - Test)
% Train Output Extraction
fTrainOutputs=evalfis(data.TrainInputs,fis);
% Test Output Extraction
fTestOutputs=evalfis(data.TestInputs,fis);
% Train calc
fErrors=data.TrainTargets-fTrainOutputs;
fMSE=mean(fErrors.^2);fRMSE=sqrt(fMSE);  
ferror_mean=mean(fErrors);ferror_std=std(fErrors);
% Test calc
fErrors1=data.TestTargets-fTestOutputs;
fMSE1=mean(fErrors1.^2);fRMSE1=sqrt(fMSE1);  
ferror_mean1=mean(fErrors1);ferror_std1=std(fErrors1);
% Train
figure('units','normalized','outerposition',[0 0 1 1])
subplot(3,2,1);
plot(data.TrainTargets,'m');hold on;
plot(fTrainOutputs,'k');legend('Target','Output');
title('Fuzzy Training Part');xlabel('Sample Index');grid on;
% Test
subplot(3,2,2);
plot(data.TestTargets,'m');hold on;
plot(fTestOutputs,'k');legend('Target','Output');
title('Fuzzy Testing Part');xlabel('Sample Index');grid on;
% Train
subplot(3,2,3);
plot(fErrors,'g');legend('Fuzzy Training Error');
title(['Train MSE =     ' num2str(fMSE) '   ,    Test RMSE =     ' num2str(fRMSE)]);grid on;
% Test
subplot(3,2,4);
plot(fErrors1,'g');legend('Fuzzy Testing Error');
title(['Train MSE =     ' num2str(fMSE1) '   ,    Test RMSE =     ' num2str(fRMSE1)]);grid on;
% Train
subplot(3,2,5);
h=histfit(fErrors, 50);h(1).FaceColor = [.3 .8 0.3];
title(['Train Error Mean =    ' num2str(ferror_mean) '   ,   Train Error STD =    ' num2str(ferror_std)]);
% Test
subplot(3,2,6);
h=histfit(fErrors1, 50);h(1).FaceColor = [.3 .8 0.3];
title(['Test Error Mean =    ' num2str(ferror_mean1) '   ,   Test Error STD =    ' num2str(ferror_std1)]);

%% Regression Plots
figure('units','normalized','outerposition',[0 0 1 1])
subplot(2,2,1)
[population2,gof] = fit(TrTar,TrainOutputs,'poly4');
plot(TrTar,TrainOutputs,'o',...
    'LineWidth',1,...
    'MarkerSize',6,...
    'MarkerEdgeColor','g',...
    'MarkerFaceColor',[0.9,0.1,0.1]);
    title(['FireFly Train - R =  ' num2str(1-gof.rmse)]);
        xlabel('Train Target');
    ylabel('Train Output');   
hold on
plot(population2,'b-','predobs');
    xlabel('Train Target');
    ylabel('Train Output');   
hold off
subplot(2,2,2)
[population2,gof] = fit(TsTar, TestOutputs,'poly4');
plot(TsTar, TestOutputs,'o',...
    'LineWidth',1,...
    'MarkerSize',6,...
    'MarkerEdgeColor','g',...
    'MarkerFaceColor',[0.9,0.1,0.1]);
    title(['FireFly Test - R =  ' num2str(1-gof.rmse)]);
    xlabel('Test Target');
    ylabel('Test Output');    
hold on
plot(population2,'b-','predobs');
    xlabel('Test Target');
    ylabel('Test Output');
 hold off
subplot(2,2,3)
[population2,gof] = fit(TrTar,fTrainOutputs,'poly4');
plot(TrTar,fTrainOutputs,'o',...
    'LineWidth',1,...
    'MarkerSize',6,...
    'MarkerEdgeColor','b',...
    'MarkerFaceColor',[0.3,0.9,0.2]);
    title(['Fuzzy Train - R =  ' num2str(1-gof.rmse)]);
        xlabel('Train Target');
    ylabel('Train Output');   
hold on
plot(population2,'r-','predobs');
    xlabel('Train Target');
    ylabel('Train Output');   
hold off
subplot(2,2,4)
[population2,gof] = fit(TsTar, fTestOutputs,'poly4');
plot(TsTar, fTestOutputs,'o',...
    'LineWidth',1,...
    'MarkerSize',6,...
    'MarkerEdgeColor','b',...
    'MarkerFaceColor',[0.3,0.9,0.2]);
    title(['Fuzzy Test - R =  ' num2str(1-gof.rmse)]);
    xlabel('Test Target');
    ylabel('Test Output');    
hold on
plot(population2,'r-','predobs');
    xlabel('Test Target');
    ylabel('Test Output');
 hold off

📜📢🌈参考文献🌈📢📜

[1]王昕, 黄柯, 郑益慧,等. 基于萤火虫算法-广义回归神经网络的光伏发电功率组合预测[J]. 电网技术, 2017, 41(2):7.

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/54479.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

FA-Phe-Gly-Gly,64967-39-1

Substrate for a continuous spectrophotometric assay of human angiotensin I-converting enzyme (ACE). Enzymatic cleavage of FAPGG yields FA-Phe-OH and H-Gly-Gly-OH. 连续分光光度法测定人血管紧张素i转换酶(ACE)的底物。酶法裂解FAPGG产生fa - pheo - oh和H-Gly-Gly-…

Kamiya丨Kamiya艾美捷抗-C-Myc,多克隆说明书

Kamiya艾美捷抗-C-Myc,多克隆化学性质: 程序:鸡用C-Myc免疫与KLH缀合的肽。多次之后用弗氏佐剂免疫收集。使用固定在固体上的肽对抗体进行免疫亲和纯化阶段 规范: ELISA:抗体特异性通过针对与BSA缀合的肽的ELISA。A…

在微信小程序里引入Vant Weapp组件库详细步骤

1. 新建一个文件夹。 2. 使用微信开发者工具 选择一个模板(这里以javaScript 基础模板 为例) 选择完模板之后如下: 2. 右键打开终端:按如下步骤执行命令。 ① npm init 解释:执行 npm init 需要在当前文件夹下的DOS窗口执行或者VS code里面…

Springboot策略模式实现文件上传功能(Windows/Linux本地,oss,cos)

1&#xff1a;首先配置pom依赖&#xff1a; <!-- 阿里云oss--><dependency><groupId>com.aliyun.oss</groupId><artifactId>aliyun-sdk-oss</artifactId><version>3.8.0</version></dependency><!-- 腾讯云cos-->…

Raspberry Pi 3 Model B+ (树莓派3B+)快速上手

文章目录一、硬件资源二、供电三、引脚说明四、Raspberry Pi OS1. 下载imager2. 选择操作系统3. 选择SD卡4. 烧写完成5. 启动6. 版本信息五、网络测试1. WiFi2. 以太网六、开启串口日志1. 硬件串口连接2. 修改config.txt配置3. 修改cmdline4. 测试一、硬件资源 下面是硬件资源图…

架构-三层架构:三层架构

概述 顾名思义&#xff0c;三层架构分为三层&#xff0c;分别是“数据访问层”、“业务逻辑层”、“表示层”。 数据访问层&#xff1a;数据访问层在作业过程中访问数据系统中的文件&#xff0c; 实现对数据库中数据的读取保存操作。 表示层&#xff1a;主要功能是 显示数据和…

李宁「向上」:不止缺一个FILA

文|螳螂观察 作者|易不二 随着卡塔尔世界杯拉开战幕&#xff0c;今年年初大幅下跌的阿迪和耐克&#xff0c;正在借助世界杯大放异彩。 据统计&#xff0c;在2022年的32强世界杯球衣中&#xff0c;耐克、阿迪、彪马三家品牌共包揽了80%。世界杯球衣是出镜率最高的广告载体&am…

Android基础之Fragment

目录前言一、Fragment简介二、Fragment的基础使用1.创建Fragment2.在Activity中加入Fragment&#xff08;1&#xff09;在Activity的layout.xml布局文件中静态添加&#xff08;2&#xff09;在Activity的.java文件中动态添加三、Fragment的基础实践应用1.应用过程详解2.代码总览…

Java JDK下载与安装教程

文章目录Java JDK 简介下载 JDK安装 JDKJava JDK 简介 JDK是 Java 语言的软件开发工具包&#xff0c;主要用于移动设备、嵌入式设备上的java应用程序。JDK是整个java开发的核心&#xff0c;它包含了JAVA的运行环境&#xff08;JVMJava系统类库&#xff09;和JAVA工具。 万事开…

Flink系列文档-(YY11)-watermark工作机制

1 WaterMark生成工作机制 观察源码 /*** A WatermarkGenerator for situations where records are out of order, but you can place an upper* bound on how far the events are out of order. An out-of-order bound B means that once an event* with timestamp T was encou…

[附源码]Python计算机毕业设计SSM酒店管理系统(程序+LW)

项目运行 环境配置&#xff1a; Jdk1.8 Tomcat7.0 Mysql HBuilderX&#xff08;Webstorm也行&#xff09; Eclispe&#xff08;IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持&#xff09;。 项目技术&#xff1a; SSM mybatis Maven Vue 等等组成&#xff0c;B/S模式 M…

alertmanager 基于webhook-adapter插件实现企业微信机器人提醒服务

前言 Alertmanager处理客户端应用程序&#xff08;例如 Prometheus 服务器&#xff09;发送的警报。它负责删除重复数据、分组并将它们路由到正确的接收器集成&#xff0c;例如电子邮件、PagerDuty 或 OpsGenie。它还负责警报的静音和抑制。 前提要求 安装docker&#xff0c;…

分布式搜索引擎 ElasticSearch(ES)

一、初识elasticsearch 1.了解ES 1&#xff09;elasticsearch的作用 elasticsearch是一款非常强大的开源搜索引擎&#xff0c;具备非常多强大功能&#xff0c;可以帮助我们从海量数据中快速找到需要的内容。elasticsearch结合kibana、Logstash、Beats&#xff0c;也就是elast…

基于SSH的周报管理系统

来公司的第一个实习项目&#xff0c;前端使用的是Freemark,刚开始上手比较复杂&#xff0c;慢慢摸索也算是圆满完成了&#xff0c;加油&#xff01;

LockSupport与线程中断

LockSupport与线程中断 线程中断机制 voidinterrupt()中断此线程static booleaninterrupted()获取当前线程中断标志位 true|falsebooleanisInterrupted()获取当前线程中断标志位true|false static boolean interrupted&#xff08;&#xff09;和boolean isInterrupted&#x…

【unity】安卓环境配置(踩坑整理)

一、基础环境配置 1、模块安装 可能报错&#xff1a;Currently selected scripting backend (IL2CPP) is notinstalled. 解决&#xff1a;部分项目依赖于IL2CPP&#xff0c;及WebGL组件&#xff0c;因此也需要勾上。 2、打开偏好设置 3、设置需要的VS版本 可能报错&#xf…

Linux动态库与静态库

Linux动态库与静态库 文章目录Linux动态库与静态库1.库的概念、种类与使用2.链接简述2.1 链接过程理解2.2 静态链接与动态链接概念2.3 静态链接与动态链接的例子3.动态库与静态库的生成方法3.1 静态库的生成3.2 静态库的打包3.2 静态库的使用3.3 动态库的生成3.4 动态库的打包3…

[附源码]JAVA毕业设计基于web的面向公众的食品安全知识系统(系统+LW)

[附源码]JAVA毕业设计基于web的面向公众的食品安全知识系统&#xff08;系统LW&#xff09; 目运行 环境项配置&#xff1a; Jdk1.8 Tomcat8.5 Mysql HBuilderX&#xff08;Webstorm也行&#xff09; Eclispe&#xff08;IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持&…

设备发现:通向全面网络可见性的途径

想实现企业网络安全防护&#xff0c;它首先需要完全了解其网络中发生的所有事件。有了这种可见性&#xff0c;企业网络安全管理员可以分析用户在网络环境中进行了哪些危险的操作&#xff0c;并采取必要的应对措施来主动保护企业网络免受攻击。 日志取证 但是&#xff0c;如果攻…

Java 每日一练 (7)

Java每日一练(7) 单选 1. JAVA属于&#xff08; &#xff09;。   A 操作系统 B 办公软件 C 数据库系统 D 计算机语言 答案 &#xff1a; java 是属于一门语言&#xff0c;是 计算可以识别的语言&#xff0c; 所以 答案 D 2. 类声明中&#xff0c;声明抽象类的关键字是 ( …