Skip to main content
. 2015 May 6;15(5):10650–10675. doi: 10.3390/s150510650
Algorithm 1. PSO-RBFN-SA
  • Offline phase

nspectrum prepared spectra are used as samples for RBFN training.
For α=1,2,,nspectrum
 PSO is performed to the spectrum F(α), and the population of particles is set as nparticle.
 For l=1,2,,nparticle
  Pl represents the current solution, which is initialized as a random solution in the solution space:
Pl(1)=[a0,a1,,aτ,w1,w2,wm] (14)
  Vl represents the current velocity, which is initialized as a random velocity:
Vl(1)=[v1,v2,,vτ+m] (15)
  Pls represents the best solution it has achieved so far, which is initialized as:
Pls(1)=Pl(1) (16)
 End
 The maximum iteration of PSO is set as nPSO.
 For t=1,2,,nPSO
  The global best solution Pg is defined as:
z(Pg(t))=MIN(z(Pls(t)))      l=1,2,,nparticle (17)
  For l=1,2,,nparticle
   The weighted particle velocity is updated as:
Vl(t+1)=η(t)Vl(t)+c1R1[Pls(t)Pl(t)]+c2R2[Pg(t)Pl(t)] (18)
where R1 and R2 are two separate random number between 0 and 1, while c1 and c2 are acceleration constants, representing the weight of acceleration terms that pull each particle toward the local best solution and the global best solution. η(t) is the inertia weight for balancing the global and local influences, which is defined as:
η(t)=0.9tnPSO×0.5 (19)
where η(t) linearly decreases through the course of the run. A large inertia weight facilitates a global search while a small inertia weight facilitates a local search. Accordingly, the optimization process can converge to the neighborhood of global optimal solution smoothly at the prophase and converge to the global optimal solution quickly at the anaphase.
   The solution of each particle is updated as:
Pl(t+1)=Pl(t)+Vl(t+1) (20)
   The best position of particle is calculated as:
Pls(t+1)={Pls(t)z(Pl(t+1))z(Pls(t))Pl(t+1)z(Pl(t+1))<z(Pls(t)) (21)
  End
 End
 The global optimization result of F(α) is recorded as P(α)g.
End
 RBFN is trained with the optimization results, where the training inputs are defined as:
X(α)=[F(α)(x1),F(α)(x2),,F(α)(xn)]      α=1,2,,nspectrum (22)
and the training outputs are defined as:
Y(α)=P(α)g      α=1,2,,nspectrum (23)
  • Online phase

 The global optimization result of each online measured spectrum F is inferred by the constructed RBFN, where the input is set as:
X=[F(x1),F(x2),,F(xn)] (24)
 The output is calculated as:
Y=β=12,Nωβψ(Xcβ) (25)
where ψ is a basis function, denotes the Euclidean norm, ωβ is the weight in the output layer, N is the number of neurons in the hidden layer, and cβ is the center of RBF in the input vector space. SA is performed with the initial solution Y, and the initial state A is defined as Y. Initial temperature is set as T, and the maximum iteration of SA is set as nSA.
For t=1,2,,nSA
 The cooling condition is that the best state remains unchanged for K times.
 While the cooling condition is not satisfied
  Use a perturbation mechanism to generate a new state A:
A=A+randnΔ (26)
where randn is a normally distributed random number. Δ is defined as:
Δ=[δ1,δ2,,δτ+m] (27)
and δγ (γ=1,2,,τ+m) is defined with a random integer γ0 in [1,τ+m]:
δγ={1γ=γ00γγ0 (28)
  The decrease of fitness is:
dz=z(A)z(A) (29)
  Check whether the new state should be accepted according to Metropolis criteria:
A={Adf<0 or exp(dfκT)>randAelse (30)
where κ is Boltzmann constant and rand is a random number in [0,1].
 End
 Cool down with a parameter ρ:
T=ρT (31)
End
The result of [a0,a1,,aτ,w1,w2,wm] is returned to calculate multi-element concentrations.