modify TSEA

This commit is contained in:
JQSakaJoo
2024-04-30 16:04:43 +05:00
parent 314ef87bcc
commit bcf8ee834d
3 changed files with 71 additions and 27 deletions
Binary file not shown.
@@ -319,7 +319,7 @@ class C_AO_TSEA : public C_AO
popSize = 100; //population size popSize = 100; //population size
vClusters = 3; //number of vertical clusters vClusters = 3; //number of vertical clusters
hClusters = 10; //number of horizontal clusters hClusters = 20; //number of horizontal clusters
neighbNumb = 5; //number of nearest neighbors neighbNumb = 5; //number of nearest neighbors
maxAgentsInCell = 3; //max agents in cell maxAgentsInCell = 3; //max agents in cell
@@ -466,39 +466,83 @@ void C_AO_TSEA::Moving ()
for (int i = 0; i < popSize; i++) for (int i = 0; i < popSize; i++)
{ {
while (true) if (u.RNDprobab () < 0.8)
{ {
rnd = u.RNDprobab (); while (true)
rnd = (-rnd * rnd + 1.0) * vClusters; {
rnd = u.RNDprobab ();
rnd = (-rnd * rnd + 1.0) * vClusters;
vPos = (int)rnd; vPos = (int)rnd;
if (vPos > vClusters - 1) vPos = vClusters - 1; 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];
}
} }
else
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]; int size2 = 0;
else val = cB [c]; int hPos2 = 0;
int pos2 = 0;
double dist = (rangeMax [c] - rangeMin [c]) * 0.1; while (true)
min = val - dist; if (min < rangeMin [c]) min = rangeMin [c]; {
max = val + dist; if (max > rangeMax [c]) max = rangeMax [c]; 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); agent [i].label = km.KNN (data, agent [i], neighbNumb, hClusters);
} }
if (epochsNow % 50 == 0) if (epochsNow % 50 == 0)
{ {
//km.KMeansPlusPlusInit (data, ArraySize (data), clusters); //km.KMeansPlusPlusInit (data, ArraySize (data), clusters);
+3 -3
View File
@@ -4,12 +4,12 @@ A list of implemented (+) optimization algorithms, (-) not included in the repos
+P_O_ES ((P+O) evolution strategies) +P_O_ES ((P+O) evolution strategies)
+SDSm (stochastic diffusion search M) +SDSm (stochastic diffusion search M)
+ESG (evolution of social groups) +ESG (evolution of social groups)
+SIA (simulated isotropic annealing) +SIA (simulated isotropic annealing)
+TSEA (turtle shell evolution algorithm)
-DE (differential evolution) -DE (differential evolution)
+BSA (bird swarm algorithm) +BSA (bird swarm algorithm)
-HS (harmony search) -HS (harmony search)
-SSG (saplings sowing and growing) -SSG (saplings sowing and growing)
+TSEA (turtle shell evolution algorithm)
-(PO)ES ((PO) evolution strategies) -(PO)ES ((PO) evolution strategies)
+BSO (brain storm optimization) +BSO (brain storm optimization)
+WOAm (wale optimization algorithm M) +WOAm (wale optimization algorithm M)