# Optimizing Parameters for an Electrical Car Employing Vehicle Dynamics Simulation Program
## 2 Literature Review
The probability \(P\) of the system being in a state with energy \(E\) at a given temperature \(T\) is given by the Boltzmann distribution according to Equation (1) [15]:  
\[P(E)=\frac{1}{Z(T)}\cdot e^{(-\frac{E}{E\cdot T})} \tag{1}\]  
where \(Z(T)\) is the normalization factor and \(k=1.3806\times 10^{-23}\left[\frac{l}{k}\right]\) is the Boltzmann constant. If the system cools too quickly, it can enter a metastable state (i.e., \"get stuck\" in a higher energy state). The process of simulated annealing is based on the Monte Carlo method, and instead of the energy \(E\), the value of the objective function \(\phi\) is used, and instead of the temperature \(T\), an artificial heat treatment temperature \(T_{A}\) is introduced. Figure 1 demonstrates the flow chart of the general simulated annealing algorithm [15]. Let us assume a one-dimensional continuous optimization problem (\(\dim(x)=1\)). In the neighborhood of state \(x^{k}\), a new state \(x^{k+1}\) will be generated stochastically applying Equation (2) [15]:  
\[x^{k+1}=x^{k}+r\cdot\Delta s^{j}\ \forall r\in[-1,1] \tag{2}\]  
where \(\Delta s^{j}\) is the current step length and \(r\) is a random number. The new state \(x^{k+1}\) is unconditionally accepted as the new (and currently optimal) state if the value of the objective function decreases:  
\[\varphi\Big{(}x^{k+1}\Big{)}\leq\varphi\Big{(}x^{k}\Big{)} \tag{3}\]  
Figure 1: Flow chart of the general simulated annealing algorithm [15]. Otherwise, the Metropolis criterion (4) gives the probability of accepting the state \(x^{k+1}\) as a new state [15]:  
\[e^{(-\frac{\varphi(x^{k+1})-\varphi(x^{k})}{k!T_{A}^{m}})}\geq p\ \forall p\in[0,1] \tag{4}\]  
where \(T_{A}^{m}\) is the current annealing temperature and \(p\) is a random number. The steps at which the objective function increases are called \"up-hill\" steps. The procedure takes place within the inner loop until a given number of evaluation cycles, \(N_{k}\), is done [15]. As the algorithm progresses, the step size (i.e., the search area) decreases, and it should be chosen in the outer loop so that the ratio of accepted and evaluated steps be close to 0.5 [53]  
\[q=\frac{N_{accepted}}{N_{evaluated}}\approx 0.5 \tag{5}\]  
If the ratio is too high, too many unnecessary steps will be accepted, so the calculation time will be too long. On the other hand, if the above ratio is too small, it can result in \"getting stuck\" in a local minimum. There is a direct connection between the annealing temperature \(T_{A}\) and the step length \(\Delta s^{l}\). At high temperature, a large decrease of the objective function is acceptable, and a large step length can be chosen to cover a large search area. The initial temperature should be large enough so that all steps are accepted. Based on the above, simulated annealing has the theoretical possibility of finding the global minimum. With decreasing temperature \(T_{A}\), the step length must be reduced, since Equation (4) only accepts an objective function that decreases to a smaller extent, which results in a smaller acceptance rate q. There are various approaches to setting the step length. One of these is the following simple but effective way [54]:  
\[\Delta s^{l+1}= \begin{cases}\Delta s^{l}\Big{(}1+c\cdot\frac{q-0.6}{0.4}\Big{)} &\quad if\ q>0.6\\ \Delta s^{l}&\quad if\ 0.4\leq q\leq 0.6\\ \Delta s^{l}\Big{(}1+c\cdot\frac{0.4-q}{0.4}\Big{)}^{-1}&\quad if\ q<0.4\\ \end{cases}  \tag{6}\]  
The change of the step length is adjusted by the parameter \(c\), whose value is usually set to 1 [23]. In Figure 2 ratio \(\frac{\Delta s^{l+1}}{\Delta s^{l}}\) is plotted vs. acceptance ratio \(q\). In an homogeneous algorithm, the temperature \(T_{A}\) is reduced after \(N_{l}\) step length adjustments, completing a \"Markov chain\" in the outer loop \(m\). We always assume that we have found the optimal state at the current temperature \(T_{A}^{m}\).