【优化算法】麻雀搜索优化算法(SSA)【含Matlab源码 1288期】【 Mastering The Art Of Regular Texas Hold'em: Strategies For Consistent Success】
03.03.2024 725 0 +45 AnibalDanner

【优化算法】麻雀搜索优化算法(SSA)【含Matlab源码 1288期】【 Mastering The Art Of Regular Texas Hold'em: Strategies For Consistent Success】

---
+45
В закладки


文章目錄



【优化算法】麻雀搜索优化算法(SSA)【含Matlab源码 1288期】


Mastering the Art of Regular Texas Hold'em: Strategies for Consistent Success


德州撲克牌大小:如何運用數學概率提高勝率




【优化算法】麻雀搜索优化算法(SSA)【含Matlab源码 1288期】
【優化算法】麻雀搜索優化算法(SSA)【含Matlab源碼 1288期】 - 掘
/p>

首頁
<

/p>

沸點
<
課/p>
<
直/p>
<

/p>
<
競/p>
商城

/p>





搜索歷史 清空

創作者中



<
寫文章



>發沸點


寫筆記


寫代碼



草稿箱



創作靈感 查看更多











<
【優化算法】麻雀搜索優化算法(SSA)【含Matlab源碼 1


紫極神光Q1564658423 2,48
/span> 一、麻雀

麻雀搜索算法(Sparrow Search Algorithm, SSA)是於2020年提出的。SSA 主要是受麻雀的覓食行為和反捕食行為的啓發而提出的。該算法比較新穎,具有尋優能力強,收斂速度快點。 1
法原理

建立麻雀搜索算法的數學模型,主要規則如下所述: (1)發現者通常擁有較高的能源儲備並且在整個種羣中負責搜索到具有豐富食物的區域,為所有的加入者提供覓食的區域和方向。在模型建立中能量儲備的高低取決於麻雀個體所對應的適應度值(Fitness Value)的好壞。 (2)一旦麻雀發現了捕食者,個體開始發出鳴叫作為報警信號。當報警值大於安全值時,發現者會將加入者帶到其它安全區域進行覓食。 (3)發現者和加入者的身份是動態變化的。只要能夠尋找到更好的食物來源,每隻麻雀都可以成為發現者,但是發現者和加入者所佔整個種羣數量的比重是不變的。也就是説,有一隻麻雀變成發現者必然有另一隻麻雀變成加入者。 (4)加入者的能量越低,它們在整個種羣中所處的覓食位置就越差。一些飢腸轆轆的加入者更有可能飛往其它地方覓食,以獲得更多的能量。 (5)在覓食過程中,加入者總是能夠搜索到提供最好食物的發現者,然後從最好的食物中獲取食物或者在該發現者周圍覓食。與此同時,一些加入者為了增加自己的捕食率可能會不斷地監控發現者進而去爭奪食物資源。 (6)當意識到危險時,羣體邊緣的麻雀會迅速向安全區域移動,以獲得更好的位置,位於種羣中間的麻雀則會隨機走動,以靠近其它麻雀。 在模擬實驗中,我們需要使用虛擬麻雀進行食物的尋找,由n只麻雀組成的種羣可表示為如下形式: 其中,d表示待優化問題變量的維數,n則是麻雀的數量。那麼,所有麻雀的適應度值可以表示為如下形式: 其中,f表示適應度值。 在SSA中, 具有較好適應度值的發現者在搜索過程中會優先獲取食物。此外, 因為發現者負責為整個麻雀種羣尋找食物並為所有加入者提供覓食的方向。因此,發現者可以獲得比加入者更大的覓食搜索範圍。根據規則(1)和規則(2),在每次迭代的過程中,發現者的位置更新描述如下: 其中, t代表當前迭代數, j=1, 2, 3, ..., d.item maz是一個常數,表示最大的迭代次數。Xy表示第i個麻雀在第j維中的位置信息。xE(0,1]是一個隨機數。R2(R2E[0,1])和ST(STe[0.5, 1] ) 分別表示預警值和安全值。Q是服從正態分佈的隨機數.L表示一個1×d的矩陣, 其中該矩陣內每個元素全部為 1. 當R2n/2時,這表明,適應度值較低的第i個加入者沒有獲得食物,處於十分飢餓的狀態,此時需要飛往其它地方覓食,以獲得更多的能量。在模擬實驗中,我們假設這些意識到危險的麻雀佔總數量的10%到20%。這些麻雀的初始位置是在種羣中隨機產生的。根據規則(5),其數學表達式可以表示為如下形式: 其中, 其中X best是當前的全局最優位置。β作為步長控制參數, 是服從均值為0, 方差為1的正態分佈的隨機數。KE[-1, 1] 是一個隨機數,則是當前麻雀個體的適應度值。f,和fw分別是當前全局最佳和最差的適應度值。e的常數,以避免分母出現零。 為簡單起見, 當f:>f, 表示此時的麻雀正處於種羣的邊緣, 極其容易受到捕食者的攻擊。X best表示這個位置的麻雀是種羣中最好的位置也是十分安全的。f;=f,時,這表明處於種羣中間的麻雀意識到了危險,需要靠近其它的麻雀以此儘量減少它們被捕食的風險。K表
移動的

是步長控制參數。

2 算法流程



Step1: 初始化種羣,迭代次數,初始化捕食者和加入者比列。 Step2:計算適應度值,並排序。 Step3:利用式(3)更新捕食者位置。 Step4:利用式(4)更新加入者位置。 Step5:利用式(5)更新警戒者位置。 Step6:計算適應度值並更新麻雀位置。 Step7:是否滿足停止條件
滿足則,輸出結果,否則,重複執行Step2-6;

二、原始碼

% ----------------------------------------------------------------------------------------------------------- % Sparrow Search algorithm (SSA) (demo) clear all clc SearchAgents_no=100; % 代數 Function_name='F1'; % Name of the test function that can be from F1 to F23 (Table 1,2,3 in the paper) Max_iteration=1000; % Maximum numbef of iterations % Load details of the selected benchmark function [lb,ub,dim,fobj]=Get_Functions_details(Function_name); [fMin,bestX,SSA_curve]=SSA(SearchAgents_no,Max_iteration,lb,ub,dim,fobj); %Draw objective space semilogy(SSA_curve,'Color','g') axis ([0 1000 0 1 ]) title('Objective space') xlabel('Iteration'); ylabel('Best score obtained so far'); %axis tight grid on box on legend('SSA') display(['The best solution obtained by SSA is : ', num2str(bestX)]); display(['The best optimal value of the objective funciton found by SSA is : ', num2str(fMin)]); %pop是種羣,M是迭代次數,fobj是用來計算適應度的函數 %pNum是生產者 %r1==a % r2:預警值 % fit:適應度 function [fMin , bestX,Convergence_curve ] = SSA(pop, M,c,d,dim,fobj ) P_percent = 0.2; % The population size of producers accounts for "P_percent" percent of the total population size %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% pNum = round( pop * P_percent ); % The population size of the producers lb= c.*ones( 1,dim ); % Lower limit/bounds/ a vector ub= d.*ones( 1,dim ); % Upper limit/bounds/ a vector %Initialization for i = 1 : pop x( i, : ) = lb + (ub - lb) .* rand( 1, dim ); fit( i ) = fobj( x( i, : ) ) ; end pFit = fit; pX = x; % The individual's best position corresponding to the pFit [ fMin, bestI ] = min( fit ); % fMin denotes the global optimum fitness value bestX = x( bestI, : ); % bestX denotes the global optimum position corresponding to fMin % Start updating the solutions. % for t = 1 : M [ ans, sortIndex ] = sort( pFit );% Sort. [fmax,B]=max( pFit ); worse= x(B,:); r2=rand(1); %%%%%%%%%%%%%5%%%%%%這一部位為發現者(探索者)的位置更新%%%%%%%%%%%%%%%%%%%%%%%%% if(r2<0.8)%預警值較小,説明沒有捕食者出現 for i = 1 : pNum %r2小於0.8的發現者的改變(1-20) % Equation (3) r1=rand(1); x( sortIndex( i ), : ) = pX( sortIndex( i ), : )*exp(-(i)/(r1*M));%對自變量做一個隨機變換 x( sortIndex( i ), : ) = Bounds( x( sortIndex( i ), : ), lb, ub );%對超過邊界的變量進行去除 fit( sortIndex( i ) ) = fobj( x( sortIndex( i ), : ) ); %就算新的適應度值 end else %預警值較大,説明有捕食者出現威脅到了種羣的安全,需要去其它地方覓食 for i = 1 : pNum %r2大於0.8的發現者的改變 x( sortIndex( i ), : ) = pX( sortIndex( i ), : )+randn(1)*ones(1,dim); x( sortIndex( i ), : ) = Bounds( x( sortIndex( i ), : ), lb, ub ); fit( sortIndex( i ) ) = fobj( x( sortIndex( i ), : ) ); end end %%%%%%%%%%%%%5%%%%%%這一部位為加入者(追隨者)的位置更新%%%%%%%%%%%%%%%%%%%%%%%%% for i = ( pNum + 1 ) : pop %剩下20-100的個體的變換 % Equation (4) A=floor(rand(1,dim)*2)*2-1; if( i>(pop/2))%這個代表這部分麻雀處於十分飢餓的狀態(因為它們的能量很低,也是是適應度值很差),需要到其它地方覓食 x( sortIndex(i ), : )=randn(1)*exp((worse-pX( sortIndex( i ), : ))/(i)^2); else%這一部分追隨者是圍繞最好的發現者周圍進行覓食,其間也有可能發生食物的爭奪,使其自己變成生產者 x( sortIndex( i ), : )=bestXX+(abs(( pX( sortIndex( i ), : )-bestXX)))*(A'*(A*A')^(-1))*ones(1,dim); end x( sortIndex( i ), : ) = Bounds( x( sortIndex( i ), : ), lb, ub );%判斷邊界是否超出 fit( sortIndex( i ) ) = fobj( x( sortIndex( i ), : ) );%計算適應度值 end %%%%%%%%%%%%%5%%%%%%這一部位為意識到危險(注意這裏只是意識到了危險,不代表出現了真正的捕食者)的麻雀的位置更新%%%%%%%%%%%%%%%%%%%%%%%%% c=randperm(numel(sortIndex));%%%%%%%%%這個的作用是在種羣中隨機產生其位置(也就是這部分的麻雀位置一開始是隨機的,意識到危險了要進行位置移動, %處於種羣外圍的麻雀向安全區域靠攏,處在種羣中心的麻雀則隨機行走以靠近別的麻雀) x( sortIndex( b(j) ), : )=bestX+(randn(1,dim)).*(abs(( pX( sortIndex( b(j) ), : ) -bestX))); else %處於種羣中心的麻雀的位置改變 x( sortIndex( b(j) ), : ) =pX( sortIndex( b(j) ), : )+(2*rand(1)-1)*(abs(pX( sortIndex( b(j) ), : )-worse))/ ( pFit( sortIndex( b(j) ) )-fmax+1e-50); end x( sortIndex(b(j) ), : ) = Bounds( x( sortIndex(b(j) ), : ), lb, ub ); fit( sortIndex( b(j) ) ) = fobj( x( sortIndex( b(j) ), : ) ); end for i = 1 : pop if ( fit( i ) < pFit( i ) ) pFit( i ) = fit( i ); pX( i, : ) = x( i, : ); end end end Convergence_curve(t)=fMin; end % Application of simple limits/bounds function s = Bounds( s, Lb, Ub) % Apply the lower bound vector % Apply the upper bound vector J = temp > Ub; temp(J) = Ub(J); % Update this new move s = temp; %------------------------------------------
------------------

-------------------------------------

---------- <
>


四、matlab版本及參考文獻

1 matlab版本

2014a

2 參考文獻

[1] 包子陽,餘繼周,楊杉.智能優化算法及其MATLAB實例(第2版)[M].電子工業出版社,2016. [2]張巖,吳水根.MATLAB優化算法原始碼[M].清華大學出版社,2017. [3]周品.MATLAB 神經網絡設計與應用[M].清華大學出版社,2013. [4]陳明.MATLAB神經網絡原理與實例精解[M].清華大學出版社,2013. [5]方清城.MATLAB R2016a神經網絡設計與應用28個案例分析[M].
華社,2018
p>



光Q15646584

/p> 閲讀<
粉絲
目錄





<
一、麻雀
法簡介




原始碼

<
>
三、結果



四、matlab及文


<
>
相薦

為什麼
官這
性能?

6


1.1k點讚

2023 前端性能優化清單


閲讀

8


跳轉到國內版(cn.bing.com)?New Bing使用全攻略
<
138點讚<
當面試官問我前端可以做的性能優化有

67k

1.3k


前端
能優化——首頁資源
縮63%、白間縮短86%

108k閲讀

3.0k點讚

友情連結:



數據庫事務管理 組件





"Mastering the Art of Regular Texas Hold'em: Strategies for Consistent
cess"


Mastering the Art of Regular Texas Hold'em: Strategies for Consistent Success

When it comes to playing Texas Hold'em, having a solid strategy is crucial for consistent success. Whether you're a beginner or an experienced player, understanding and implementing effective strategies can greatly improve your chances of
ing. In this article, we will discuss some key str
gies that can help you master the art of regular Texas Hold'em.



1. Starting Hands

One of the most important aspects of Texas Hold'em is knowing which starting hands to play. Not all hands are created equal, a
laying the right starting hands is essential for long-term success. Here are a few examples of strong starting hands:





Ace-King (suited or unsuited)


Pocket pairs (tens or higher)

Ace-Queen (suited or unsuited)


King-Queen (suited or unsuited)


These hands have a higher p
ability of winning and can give you an advantage over your opponents.



2. Position

Another crucial aspect of Texas Hold'em is understanding the importance of position. Your position at the ta
determines the orde
n which you act, and it can greatly influence your decision-making process. Here's an example:


Let's say you have a mediocre hand like 8-9 suited. If you are in an early position (one of the first to act), it's generally better to fold this hand. However, if you are in a late position (
of the last to act), you can consider playing this ha
as you have more information about your opponents' actions.



3. Reading Opponents

Being able to read your opponents' actions and behaviors is a valuable skill in Texas Hold'em. By observing their be
g patterns, body la
age, and reactions, you can gain insights into the strength of their hands. Here's an example:


Let's say you notice that a particular opponent tends to bet aggressively when they have a strong hand. If this opponent suddenly starts betting cautiously, it could i
ate that they have a weaker hand. This information can
p you make better decisions and potentially win more pots.



4. Bankroll Management

Proper bankroll management is essential for long-term success in Texas
'em. It involves se
ng limits on how much you are willing to risk and sticking to those limits. Here's an example:


Let's say you have a bankroll of $1,000. Instead of playing in high-stakes games where the minimum buy-in is $500, it's wiser to play in lower-stakes
s with a minimum bu
n of $100. This way, you minimize the risk of losing your entire bankroll in a single session.


By implementing these strategies and continuously improving your skills, you can increase your chances of consistent success in r
ar Texas Hold'em. Remember, practice and experience are also crucial in mastering the art of this popular poker game.



"德州撲克牌大小:
何運用數學概率提高勝率"


如何運用數學概率提高德州撲克勝率

德州撲克是一種非常受歡迎的撲克遊戲,玩家需要根據手中的牌和公共牌來進行下注和判斷。儘管遊戲中有一定的運氣因素,但運用數學概
可以幫助玩家做出更明智的決策,提高勝率。



1. 計算手牌勝率

在德州撲克中,玩家會先收到兩張手牌,然後在後
的回合中,會逐漸翻開五張公共牌。計算手牌勝率是提高勝率的第一步。


假設你手中的牌是紅桃A和紅桃K,這是一個非常強的起手牌。根據數學概率,你有約31%的機會在河牌(最後一共牌)時獲得最好的牌型,比如同花順。



2. 計算對手可能的牌型

在德州撲克中,不僅要計算自己的勝率,還要考慮對手可能的牌型。這需察對手的下注行為和公共牌的情況,並根據數學概率估計對手可能的牌型。


假設在河牌時,公共牌是紅桃10、方塊J、梅花Q、紅桃K和黑桃A。你手中的牌是紅桃A和紅桃K。如果對手下注,你可以通過計算概率來估計對手可能的牌型。例如,如果對手下注並且很有可能有同花順,以根據數學概率來決定是否跟注或放棄。



3. 利用概率計算下注金額

在德州撲克中,下注金額的大小也是一個需要考慮素。利用數學概率可以幫助你計算最佳的下注金額,以最大化你的期望收益。


假設你手中的牌是紅桃A和紅桃K,公共牌是紅桃2、紅桃3、紅桃4、紅桃5和紅桃6。你有一個同花順的可能性,但是對手可能還有其他強牌。通過計算概率,你可以估計你的勝率約為20%。如果你的對手下注,你可以根據數學來決定是否跟注或放棄,並且決定下注金額。



4. 考慮概率和賠率的關係

在德州撲克中,概率和賠率是密切相關的。概指某一事件發生的可能性,而賠率則是指下注金額和可能獲得的回報之間的比例。


假設你手中的牌是紅桃A和紅桃K,公共牌是紅桃2、紅桃3、紅桃4、紅桃5和紅桃6。你有一個同花順的可能性,但是對手可能還有其他強牌。通過計算概率,你可以估計你的勝率約為20%。如果你的對手下注,你可以根據數學概率和賠率來決定是否跟注或放棄。





如果對手的下注金額小於你的期望收
,你可以跟注。


如果對手的下注金額大於你的期望收益,你可以放棄。










運用數學概率提高德州撲克勝率需要學習和實踐。你可以閲讀相關的書籍和文章,學習基本學概率計算方法。同時,你也需要在實際的遊戲中應用所學,並不斷調整和改進你的策略。


總結來説,運用數學概率可以幫助你在德州撲克中做出更明智的決策,提高勝率。通過計算手牌勝率、估計對手可能的牌型、計算下注金額、考慮概率和賠率的關係,以及不斷學習和實踐,你可以成為一個更出色的德州撲克玩家。уникальные шаблоны и модули для dle
Комментарии (0)
Добавить комментарий
[related-news]
{related-news}
[/related-news]