Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize Whale Optimization algorithm based on Matlab

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "how to achieve whale optimization algorithm based on Matlab". In daily operation, I believe many people have doubts about how to achieve whale optimization algorithm based on Matlab. Xiaobian consulted all kinds of data and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubt of "how to achieve whale optimization algorithm based on Matlab". Next, please follow the editor to study!

1. Modeling of whale optimization algorithm

Whale optimization algorithm (WOA) is a swarm intelligence optimization algorithm proposed by Australian scholar Mirjaili et al in 2016, which optimizes the search according to the hunting behavior of humpback whales. Each whale can be seen as a particle, and each particle as a different decision variable. The realization process of WOA mainly includes three stages: encircling prey, spiral hunting and random search. Its mathematical model is as follows:

1.1 surround the prey

1.2 Spiral hunting

1.3 search for prey

1.4 algorithm flow chart

The 2.Matlab code achieves 2.1 results

2.2 Code clear all clc SearchAgents_no=30;Function_name='F1';% Name of the test function that can be from F1 to F23 (Table 1 Table 2 and 3 in the paper)% Max_iteration=500;% Maximum numbef of iterationsMax_iteration=500;% Load details of the selected benchmark function [lb,ub,dim,fobj] = Get_Functions_details (Function_name); [Best_score,Best_pos,WOABAT_cg_curve] = WOABAT (SearchAgents_no,Max_iteration,lb,ub,dim,fobj) Figure ('Position', [269 240 660 290])% Draw search space subplot; func_plot (Function_name); title (' Parameter space') xlabel ('xantha 1'); ylabel ('Xerox 2'); zlabel ([Function_name,' (xylene 1, xylene 2)])% Draw objective space subplot (1m 2); semilogy (WOABAT_cg_curve,'Color','r') title ('Objective space') xlabel (' Iteration') Ylabel ('Best score obtained so far'); axis tight grid on box on legend (' WOABAT')% display (['The best solution obtained by WOABAT is:', num2str (Best_pos)]); display (['The best optimal value of the objective funciton found by WOA is:', num2str (Best_score)]);% display (num2str (Best_score)) % The Whale Optimization Algorithmfunction [Leader_score,Leader_pos,Convergence_curve] = WOABAT (SearchAgents_no,Max_iter,lb,ub,dim,fobj)% initialize position vector and score for the leaderLeader_pos=zeros (1Magne dim); Leader_score=inf;% change this to-inf for maximization problems% Initialize the positions of search agentsPositions=initialization (SearchAgents_no,dim,ub,lb); Convergence_curve=zeros (1JM Maxclimiter);% bat algorithm additionQmin=0;% Frequency minimumQmax=2;% Frequency maximumQ=zeros (SearchAgents_no,1) % Frequencyv=zeros (SearchAgents_no,dim);% Velocitiesr=0.5;A1=0.5;t=0;% Loop counter% summ=0;% Main loopwhile tub; Flag4lb=Positions (iMagne:) r% The factor 0.001 limits the step sizes of random walks z (iMagne:) = Leader_pos (j) + 0.001*randn (1meme dim) End% Evaluate new solutions Fnew=fobj (z (iMagna:));% Update if the solution improves, or not too loud if (Fnew

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report