s25061872.pdf - 第10页
Sensors 2025 , 25 , 1872 10 of 24 X i , m _2 ( t + 1 ) = X food ( t ) ± C 3 × T emp × r a n d × [ X food ( t ) − X i , m ( t ) ] (13) X i , m _3 ( t + 1 ) = X i , m _3 ( t ) ± C 3 × F m × r a n d × h Q × X be s t , f − X…

Sensors 2025, 25, 1872
9 of 24
sition of this initial population can be represented by Equation (6), where the numbers of male
and female individuals are represented by Equations (7) and (8), respectively.
X
i
= lb + rand ×(ub −lb) (6)
N
m
=
N
2
(7)
N
f
= N − N
m
(8)
where X
i
denotes the position of the i-th individual. The random function ‘rand’ generates
a real random number between 0 and 1. The upper and lower bounds of X
i
are ub and lb,
respectively. N is the total population size. N
m
and N
f
are the numbers of individual males
and females, respectively.
However, the use of the function ‘rand’ in Equation (6) of the SO algorithm may result
in an uneven distribution of random numbers. Moreover, because this function is based on
a deterministic algorithm, the same random sequence is generated when the same seed is
given. This situation may lead to the premature convergence of the heuristic algorithm to
the local optimal solution, making it challenging to find the global optimal solution. To
address this issue in population initialization, this study introduces a Tent Chaotic Map.
It has excellent chaotic characteristics, which can effectively improve the uniformity of
population distribution. In addition, compared with Sine and Logistic chaotic map [
32
,
33
],
its implementation is more intuitive and simple, while Sine and Logistic chaotic map’s
late depth search ability is weak, which may cause the algorithm to fall into local optimal.
At the same time, the distribution of their output sequence may be uneven under certain
parameter values. As a consequence, the Tent Chaos map is a good choice in this study.
And the Tent Chaos Map can be expressed as Equation (9). And ‘x
i
’ replaces ‘rand’ as shown
in Equation (10).
x
i+1
=
x
i
a
, 0 ≤ x
i
< a
1−x
i
1−a
, a ≤ x
i
≤ 1
(9)
X
i
= lb + x
i
×(ub −lb) (10)
where x
i
and x
i+
1
stand for the i-th and i + 1-th values of Tent Chaotic Map, respectively. X
i
stands for the i-th individual position. Moreover, parameter a is the variable value, which
is 0.5 in this study [34].
2.4.2. Dynamic Learning Factor with Random Noise
In heuristic algorithms, learning factors play a key role in regulating the search be-
havior, including the balance between exploration and exploitation. Exploration refers
to the ability to search for new solutions randomly, whereas development refers to the
ability to search locally for the best solution. The learning factors of the SO algorithm
include the constant value C
1
of the food calculation equation, constant value C
2
of the
food exploration stage, and constant value C
3
of the food development stage. The initial
values of these constants are typically set to C
1
= 0.5, C
2
= 0.05, and C
3
= 2. The equations
containing C
1
, C
2
, and C
3
are Equations (11)–(15). The subscript ‘m’ and ‘f ’ refers to the
male and female snakes, respectively. The special mention of female snake expressions will
be omitted in the following text.
Q = C
1
×(
t − T
T
) (11)
X
i, m_1
(t + 1) = X
rand, m_1
(t) ±C
2
× A
m
×
[
(ub − lb) ×rand + lb
]
(12)

Sensors 2025, 25, 1872
10 of 24
X
i, m_2
(t + 1) = X
food
(t) ±C
3
×Temp ×rand ×
[
X
food
(t) − X
i, m
(t)
]
(13)
X
i, m_3
(t + 1) = X
i, m_3
(t) ±C
3
× F
m
×rand ×
h
Q × X
best, f
− X
i, m
(t)
i
(14)
X
i, m_4
(t + 1) = X
i, m_4
(t) ±C
3
× M
m
×rand ×
h
Q × X
i, f
(t) − X
i, m
(t)
i
(15)
where Q is the amount of food consumed. t denotes the current number of itera-
tions. T denotes the maximum number of iterations. Temp is the iteration temperature.
X
i
, m_1
, X
i
, m_
2
, X
i
, m_3
,
and X
i
, m_4
are the locations of food in the exploration phase of male
snakes, food in the development phase of male snakes, combat mode in the development
phase of male snakes, and mating mode in the development phase of male snakes, respec-
tively. X
rand
, m_1
is the randomly selected male population. X
best_f
is the best position for
the females in this population. A
m
, F
m
, and M
m
are measured for the male’s ability to find
food, the male’s ability to fight, and the male’s ability to mate.
Because the learning factors C
1
, C
2
, and C
3
remain unchanged during the iteration, the
algorithm may not adapt to the dynamic changes in the solution space. Hence, the delta
value is introduced for the normal distribution of random tubs. This perturbation helps
the SO algorithm eliminate the trap of local optimal solutions, thus enhancing its global
search abilities. In addition, the literature [
35
] introduces a learning strategy employed
within the ISO framework, which centers on acquiring knowledge from the experiences
of other group members. This approach aims to mitigate the likelihood of converging on
local optima. Nonetheless, the implementation of such specialized learning mechanisms
not only entails a notable increase in algorithmic complexity but also exhibits diminished
efficacy when adapting to the diverse phases of the optimization procedure. However, the
SO algorithm can achieve an effective dynamic balance between global and local searches
by dynamically adjusting these fixed learning factors C
1
, C
2
, and C
3
, thereby improving
the performance and efficiency of the algorithm. The concrete expression of the random
disturbance is shown in Equations (16) and (17). In Equation (19), alpha is used to store the
parameter values for learning factors C
1
, C
2
, and C
3
.
delta = sigma ×randn (16)
al pha(t + 1) = alpha(t) + delta (17)
where sigma represents the amplitude of the perturbation. It is 0.1 in this paper [
36
]. alpha is
limited to a range between 0.01 and 1. Random function ‘randn’ represents a random value
with a standard normal distribution.
2.4.3. Cosine Annealing Learning Rate
In Equations (12)–(15), the strategy for updating the individual positions is relatively
simple. Without considering adjusting the strategy as an iteration progress, the SO algo-
rithm mainly relies on the current individual’s position and velocity vector to determine
the next individual’s position. This method is more likely to cause the algorithm to become
stuck in a locally optimal solution. To improve the update strategy of the original SO
algorithm, this study introduced a cosine learning annealing rate. This strategy simulates
the dynamic adjustment of the learning rate based on the cosine function, which can dy-
namically adjust the speed of the position updating based on the number of iterations. In
the early stages of the iteration, the learning rate can be reduced rapidly to achieve fast
convergence. In the later stages of the iteration, fine adjustments are made to optimize the
precision of the solution by reducing the learning rate, as shown in Figure 7. The specific
expression of the cosine learning annealing rate is shown in Equation (18).

Sensors 2025, 25, 1872
11 of 24
η
t
= η
min
+
1
2
(η
max
−η
min
) × (1 + cos(
T
cur
T
max
π)) (18)
where
η
t
is the current learning rate.
η
min
and
η
max
are the minimum and maximum values
of the learning rate, which are 0.001 and 0.01 in this paper. T
cur
and T
max
are the current
and total iterations, respectively. T
max
is usually set to half the number of iterations of the
main algorithm, which is 20 in this article [37].
Sensors2025,25,xFORPEERREVIEW 11 of 25
convergingonlocaloptima.Nonetheless,theimplementationofsuchspecializedlearn‐
ingmechanismsnotonlyentailsanotableincreaseinal gorithmiccomplexitybutalso
exhibitsdiminishedefficacywhenadaptingtothediversephasesoftheoptimizationpro‐
cedure.However,the SOalgorithmcan achieve aneffectivedynamicbalance
between
globalandlocalsearchesbydynamicallyadjustingthesefixedlearni ng factors C
1,C2,
andC
3,therebyimp rov in gtheperformanceandefficiencyofthealgorithm.Thecon‐
creteexpressionoftherandomdisturbanceisshowninEquations(16)and(17).InEqua‐
tion(19),alphaisusedtostoretheparametervaluesforlearningfactorsC
1,C2,andC3.
delta sigma randn
(16)
(1) ()alpha t alpha t delta
(17)
wheresigmarepresentstheamplitudeoftheperturbation.Itis0.1inthispaper[36].alpha
islimitedtoarangebetween0.01and1.Randomfunction‘randn’representsarandom
valuewithastandardnormaldistribution.
2.4.3.CosineAnnealingLearningRate
InEquations(12)–(15),thestrat egyforupdating
theindi vidualpositionsisrel‐
ativelysimple.Withoutconsideringadjustingthestrategyasaniterationprogress,theSO
algorithmmainlyreliesonthecurrentindividual’spositionandvelocityvectortodeter‐
minethenextindividual’sposition.Thismethodismorelikelytocausethealgorithmto
becomestuckina
locallyoptimalsolution.Toimprovetheupdatestrategyoftheoriginal
SOalgorithm,thisstudyintroducedacosinelearningannealingrate.Thisstrategysim‐
ulatesthedynamicadjustmentof thelearningratebasedonthecosinefunction,which
candynamicallyadjustthespeedofthepositionupdatingbasedonthenumber
ofitera‐
tions. In the early stages of the iteration, the learning rate can be reduced rapidly to
achievefastconvergence.Inthelaterstagesoftheiteration,fineadjustmentsaremadeto
optimizetheprecisionofthesolutionbyreducingthelearningrate,asshowninFigure7.
The
specificexpressionofthecosinelearningannealingrateisshown inEqua tion(18).
min max min
max
1
()(1cos())
2
cur
t
T
T
(18)
whereη
tisthecurrentlearningrate.ηminandηmaxaretheminimumandmaximumvalues
ofthelearningrate,whichare0.001and0.01inthispaper.T
curandTmaxarethecurrent
andtotaliterations,respectively.T
maxisusuallysettohalfthenumberofiterationsofthe
mainalgorithm,whichis20inthisarticle[37].
Figure 7. Cosine annealing learning rate iteration graph.
By comparison with the cosine annealing learning rate, Gaussian adaptive param-
eters [
38
] are sensitive to initial conditions, prone to premature convergence, and may
introduce additional computational complexity. However, the cosine annealing learning
rate exhibits periodic change, which enables the SO algorithm to adopt diverse search strate-
gies in different stages, thus enhancing the dynamic adjustment ability of the algorithm.
This flexibility helps the algorithm to avoid premature convergence during the search pro-
cess, thereby increasing the possibility of finding a global optimal solution. Therefore, by
introducing the cosine annealing learning rate based on Equations (12)–(15), the improved
Equations (19)–(22) are obtained.
X
i, m_1
(t + 1) = η
t
× X
rand, m_1
(t) ± η
t
×C
2
× A
m
×
[
(ub − lb) ×rand + lb
]
(19)
X
i, m_2
(t + 1) = η
t
× X
food
(t) ± η
t
×C
3
×Temp ×rand ×
[
X
food
(t) − X
i, m
(t)
]
(20)
X
i, m_3
(t + 1) = η
t
× X
i, m_3
(t) ± η
t
×C
3
× F
m
×rand ×
h
Q × X
best, f
− X
i, m
(t)
i
(21)
X
i, m_3
(t + 1) = η
t
× X
i, m_3
(t) ± η
t
×C
3
× F
m
×rand ×
h
Q × X
best, f
− X
i, m
(t)
i
(22)
2.4.4. The Bayesian Method to Find the Optimization Threshold
Bayesian optimization can be applied not only to neural network architectures based
on snake algorithms to improve system performance [
39
], but also to optimize hyperpa-
rameter combinations in machine learning. In the process of determining threshold values
of the SO algorithm, parameter setting often depends on the experience and intuition
of algorithm developers or needs to be determined by practical users through practice.
This approach lacks universality and requires considerable time for experimentation and
adjustments. If the parameters are not selected properly, the adaptability of the algorithm
may be affected. To solve the problem in which the SO algorithm has difficulty adapting
parameters in the iterative process, this study introduces a hyperparameter-tuning method