From bcf8ee834d5c1a11891e28b445395a5d6012d412 Mon Sep 17 00:00:00 2001 From: JQSakaJoo Date: Tue, 30 Apr 2024 16:04:43 +0500 Subject: [PATCH] modify TSEA --- .../Math/AOs/PopulationAO/#C_AO_enum.mqh | Bin 6116 -> 6116 bytes .../AO_TSEA_TurtleShellEvolutionAlgorithm.mqh | 92 +++++++++++++----- README.md | 6 +- 3 files changed, 71 insertions(+), 27 deletions(-) diff --git a/MQL5/Include/Math/AOs/PopulationAO/#C_AO_enum.mqh b/MQL5/Include/Math/AOs/PopulationAO/#C_AO_enum.mqh index 814e24dd6eef79685ec09b331613daed4a55cdeb..c3ff1228df8364396087a04918ec67f5d729d499 100644 GIT binary patch delta 59 zcmV-B0L1^~FXS(cvz8E20keD(Xa#>I6n6js delta 67 zcmV-J0KEU?FXS(YYWCaT=7Iy#u diff --git a/MQL5/Include/Math/AOs/PopulationAO/AO_TSEA_TurtleShellEvolutionAlgorithm.mqh b/MQL5/Include/Math/AOs/PopulationAO/AO_TSEA_TurtleShellEvolutionAlgorithm.mqh index 0a17d0d..27bfe69 100644 --- a/MQL5/Include/Math/AOs/PopulationAO/AO_TSEA_TurtleShellEvolutionAlgorithm.mqh +++ b/MQL5/Include/Math/AOs/PopulationAO/AO_TSEA_TurtleShellEvolutionAlgorithm.mqh @@ -319,7 +319,7 @@ class C_AO_TSEA : public C_AO popSize = 100; //population size vClusters = 3; //number of vertical clusters - hClusters = 10; //number of horizontal clusters + hClusters = 20; //number of horizontal clusters neighbNumb = 5; //number of nearest neighbors maxAgentsInCell = 3; //max agents in cell @@ -466,39 +466,83 @@ void C_AO_TSEA::Moving () for (int i = 0; i < popSize; i++) { - while (true) + if (u.RNDprobab () < 0.8) { - rnd = u.RNDprobab (); - rnd = (-rnd * rnd + 1.0) * vClusters; + while (true) + { + rnd = u.RNDprobab (); + rnd = (-rnd * rnd + 1.0) * vClusters; - vPos = (int)rnd; - if (vPos > vClusters - 1) vPos = vClusters - 1; + vPos = (int)rnd; + if (vPos > vClusters - 1) vPos = vClusters - 1; - hPos = u.RNDminusOne (hClusters); + hPos = u.RNDminusOne (hClusters); - size = ArraySize (cell [vPos].cell [hPos].agent); + size = ArraySize (cell [vPos].cell [hPos].agent); - if (size > 0) break; + if (size > 0) break; + } + + pos = u.RNDminusOne (size); + + if (u.RNDprobab () < 0.5) pos = cell [vPos].cell [hPos].indBest; + + for (int c = 0; c < coords; c++) + { + if (u.RNDprobab () < 0.6) val = cell [vPos].cell [hPos].agent [pos].c [c]; + else val = cB [c]; + + double dist = (rangeMax [c] - rangeMin [c]) * 0.1; + min = val - dist; if (min < rangeMin [c]) min = rangeMin [c]; + max = val + dist; if (max > rangeMax [c]) max = rangeMax [c]; + + val = u.PowerDistribution (val, min, max, 30); + + a [i].c [c] = u.SeInDiSp (val, rangeMin [c], rangeMax [c], rangeStep [c]); + + agent [i].c [c] = a [i].c [c]; + } } - - pos = u.RNDminusOne (size); - - if (u.RNDprobab () < 0.5) pos = cell [vPos].cell [hPos].indBest; - - for (int c = 0; c < coords; c++) + else { - if (u.RNDprobab () < 0.6) val = cell [vPos].cell [hPos].agent [pos].c [c]; - else val = cB [c]; + int size2 = 0; + int hPos2 = 0; + int pos2 = 0; - double dist = (rangeMax [c] - rangeMin [c]) * 0.1; - min = val - dist; if (min < rangeMin [c]) min = rangeMin [c]; - max = val + dist; if (max > rangeMax [c]) max = rangeMax [c]; + while (true) + { + rnd = u.RNDprobab (); + rnd = (-rnd * rnd + 1.0) * vClusters; - val = u.PowerDistribution (val, min, max, 30); + vPos = (int)rnd; + if (vPos > vClusters - 1) vPos = vClusters - 1; - a [i].c [c] = u.SeInDiSp (val, rangeMin [c], rangeMax [c], rangeStep [c]); + hPos = u.RNDminusOne (hClusters); - agent [i].c [c] = a [i].c [c]; + size = ArraySize (cell [vPos].cell [hPos].agent); + + + + + hPos2 = u.RNDminusOne (hClusters); + + size2 = ArraySize (cell [vPos].cell [hPos2].agent); + + if (size > 0 && size2 > 0) break; + } + + pos = u.RNDminusOne (size); + pos2 = u.RNDminusOne (size2); + + for (int c = 0; c < coords; c++) + { + val = (cell [vPos].cell [hPos ].agent [pos ].c [c] + + cell [vPos].cell [hPos2].agent [pos2].c [c]) * 0.5; + + a [i].c [c] = u.SeInDiSp (val, rangeMin [c], rangeMax [c], rangeStep [c]); + + agent [i].c [c] = a [i].c [c]; + } } } } @@ -571,7 +615,7 @@ void C_AO_TSEA::Revision () { agent [i].label = km.KNN (data, agent [i], neighbNumb, hClusters); } - + if (epochsNow % 50 == 0) { //km.KMeansPlusPlusInit (data, ArraySize (data), clusters); diff --git a/README.md b/README.md index ee721aa..d56ab39 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,12 @@ A list of implemented (+) optimization algorithms, (-) not included in the repos +P_O_ES ((P+O) evolution strategies) +SDSm (stochastic diffusion search M) +ESG (evolution of social groups) -+SIA (simulated isotropic annealing) ++SIA (simulated isotropic annealing) ++TSEA (turtle shell evolution algorithm) -DE (differential evolution) +BSA (bird swarm algorithm) -HS (harmony search) --SSG (saplings sowing and growing) -+TSEA (turtle shell evolution algorithm) +-SSG (saplings sowing and growing) -(PO)ES ((PO) evolution strategies) +BSO (brain storm optimization) +WOAm (wale optimization algorithm M)