【智能优化算法】基于文化和谐和学习算法优化模糊函数FUZZY附matlab代码
1 簡介
This paper studies the constrained optimization problem for nonlinear diesel blending. A new hybrid algorithm called cultural harmony search algorithm is presented to solve the proposed optimization problem, which uses cultural knowledge in the belief space of the cultural algorithm to guide the evolving and searching process of the harmony search algorithm. Then, an improved harmony improvisation in the population space of cultural algorithm is developed for new harmony generation to enrich the population diversity. Moreover, in order to accelerate convergence, the domain of decision variables is scaled down by a simplex method at the beginning of the algorithm, and a simplex improved cultural harmony search algorithm is provided. Finally, benchmark functions and the results of application in nonlinear diesel blending of a real-world refinery show the feasibility and effectiveness of the proposed algorithms. The contrasted experiments show that our proposed hybrid algorithm is better than other hybrid algorithms, especially in diesel blending optimization problem.?
2 部分代碼
%% Cultural Harmony Learning Algorithm - Created in 18 Jan 2022 by Seyed Muhammad Hossein Mousavi% Here is all about learning with evolutionary algorithms. Harmony search% and cultural algorithms are two fast optimization algorithms which their% result are combined here in order to train inputs for targets in a simple% dataset. Basically, system starts with making initial fuzzy model and fit% the outputs based on inputs by harmony search first and then tries to fit the% harmony search outputs with inputs in the second stage. That means we are using both% evolutionary algorithms to improve the accuracy. System easily could be% used for regression, classification and other optimization tasks. You can?%% Cleaningclc;clear;warning('off');%% Data Loadingdata=JustLoad();%% Generate Basic Fuzzy Model% Number of Clusters in FCMClusNum=4; %fis=GenerateFuzzy(data,ClusNum);%%% Tarining Cultural Harmony Algorithm% Harmony Search LearningHarFis=hars(fis,data); % Harmony Cultural Algorithm LearningCAHSfis=CulturalFCN(HarFis,data); ?%% Plot Cultural Harmony Results (Train - Test)% Train Output ExtractionTrTar=data.TrainTargets;TrainOutputs=evalfis(data.TrainInputs,CAHSfis);% Test Output ExtractionTsTar=data.TestTargets;TestOutputs=evalfis(data.TestInputs,CAHSfis);% Train calcErrors=data.TrainTargets-TrainOutputs;MSE=mean(Errors.^2);RMSE=sqrt(MSE); error_mean=mean(Errors);error_std=std(Errors);% Test calcErrors1=data.TestTargets-TestOutputs;MSE1=mean(Errors1.^2);RMSE1=sqrt(MSE1); error_mean1=mean(Errors1);error_std1=std(Errors1);% Trainfigure('units','normalized','outerposition',[0 0 1 1])subplot(3,2,1);plot(data.TrainTargets,'c');hold on;plot(TrainOutputs,'k');legend('Target','Output');title('Cultural Harmony Training Part');xlabel('Sample Index');grid on;% Testsubplot(3,2,2);plot(data.TestTargets,'c');hold on;plot(TestOutputs,'k');legend('Cultural Harmony Target','Cultural Harmony Output');title('Cultural Harmony Testing Part');xlabel('Sample Index');grid on;% Trainsubplot(3,2,3);plot(Errors,'k');legend('Cultural Harmony Training Error');title(['Train MSE = ' num2str(MSE) ' , Train RMSE = ' num2str(RMSE)]);grid on;% Testsubplot(3,2,4);plot(Errors1,'k');legend('Cultural Harmony Testing Error');title(['Test MSE = ' num2str(MSE1) ' , Test RMSE = ' num2str(RMSE1)]);grid on;% Trainsubplot(3,2,5);h=histfit(Errors, 50);h(1).FaceColor = [.1 .2 0.9];title(['Train Error Mean = ' num2str(error_mean) ' , Train Error STD = ' num2str(error_std)]);% Testsubplot(3,2,6);h=histfit(Errors1, 50);h(1).FaceColor = [.1 .2 0.9];title(['Test Error Mean = ' num2str(error_mean1) ' , Test Error STD = ' num2str(error_std1)]);?%% Plot Just Fuzzy Results (Train - Test)% Train Output ExtractionfTrainOutputs=evalfis(data.TrainInputs,fis);% Test Output ExtractionfTestOutputs=evalfis(data.TestInputs,fis);% Train calcfErrors=data.TrainTargets-fTrainOutputs;fMSE=mean(fErrors.^2);fRMSE=sqrt(fMSE); ferror_mean=mean(fErrors);ferror_std=std(fErrors);% Test calcfErrors1=data.TestTargets-fTestOutputs;fMSE1=mean(fErrors1.^2);fRMSE1=sqrt(fMSE1); ferror_mean1=mean(fErrors1);ferror_std1=std(fErrors1);% Trainfigure('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;% Testsubplot(3,2,2);plot(data.TestTargets,'m');hold on;plot(fTestOutputs,'k');legend('Target','Output');title('Fuzzy Testing Part');xlabel('Sample Index');grid on;% Trainsubplot(3,2,3);plot(fErrors,'g');legend('Fuzzy Training Error');title(['Train MSE = ' num2str(fMSE) ' , Test RMSE = ' num2str(fRMSE)]);grid on;% Testsubplot(3,2,4);plot(fErrors1,'g');legend('Fuzzy Testing Error');title(['Train MSE = ' num2str(fMSE1) ' , Test RMSE = ' num2str(fRMSE1)]);grid on;% Trainsubplot(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)]);% Testsubplot(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)]);??3 仿真結果
4 參考文獻
[1] Gao M ,? Zhu Y ,? Cao C , et al. A Hybrid Cultural Harmony Search Algorithm for Constrained Optimization Problem of Diesel Blending[J]. IEEE Access, 2019, PP(99):1-1.
博主簡介:擅長智能優化算法、神經網絡預測、信號處理、元胞自動機、圖像處理、路徑規劃、無人機等多種領域的Matlab仿真,相關matlab代碼問題可私信交流。
部分理論引用網絡文獻,若有侵權聯系博主刪除。
總結
以上是生活随笔為你收集整理的【智能优化算法】基于文化和谐和学习算法优化模糊函数FUZZY附matlab代码的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 什么是 ClickHouse(实时数据分
- 下一篇: Vue 调用PC摄像头拍照