# Self-Tuning Lam Annealing: Learning Hyperparameters While Problem Solving
## 2 Methods
### Self-Tuning Lam
#### 2.3.5 Putting It All Together
Figure 5 shows the acceptance rates for the Modified Lam and the Self-Tuning Lam, and the target acceptance rate, for different run lengths. Similar to what we previously saw for OneMax, the Self-Tuning Lam effectively follows the target Lam acceptance rate, with very low MSE, and which you can also see visually in the graphs. The acceptance rate for the Modified Lam oscillates wildly for most run lengths, and for the shortest run length is rather far from the target. The MSE of the Self-Tuning Lam is extremely statistically significantly lower than that of the Modified Lam (from a \(p<10^{-6}\) for the 100,000 iteration run length to a \(p<10^{-29}\) for the shortest run lengths). Table 5 summarizes the results for TwoMax. For very short runs, the Modified Lam outperforms the Self-Tuning Lam (at statistically significant levels). However, as run length increases, the Self-Tuning Lam begins outperforming the Modified Lam due to its more effective exploration. The performance advantage appears to switch around run length 10,000, when the Self-Tuning Lam finds solutions with lower average cost, although not at a statistically significant level. When run length is increased further to 100,000 SA iterations, the Self-Tuning Lam optimally solves the problem in all 100 experimental runs, while the Modified Lam gets caught in the local optima for some runs. The cost difference is statistically significant in that case (\(p=0.04\)). \begin{table}
\begin{tabular}{c c c c} \hline \hline \(N\) & **Modified Lam** & **Self-Tuning Lam** & **T-Test \(p\)-Value** \\ \hline
1000 & 60.00 & 312.62 & \(<\)10\({}^{-36}\) \\
10,000 & 15.36 & 10.78 & 0.69 \\
100,000 & 20.48 & 0.00 & 0.04 \\
1,000,000 & 0.00 & 0.00 & n/a \\ \hline \hline \end{tabular}
\end{table} 
Table 5: Average solution cost for the TwoMax problem. Figure 5: TwoMax problem: Self-Tuning Lam, Modified Lam, and target acceptance rates for (**a**) 1000 iterations, (**b**) 10,000 iterations, (**c**) 100,000 iterations, and (**d**) 1 million iterations. #### 3.1.3 Trap: Single Global Optimum and a Strongly Attractive Local Optimum

In the Trap problem, there is a single global optimum, and a single local optimum, but where most of the search space is within the attraction basin of the local optimum [39]. Specifically, we must maximize the following function over bit vectors \(x\) of length \(n\):

\[f(x)= \begin{cases}\frac{8n(z-\text{CountOfOneBits}(x))}{\frac{2n}{\text{($n-z$)} }}&\text{if CountOfOneBits}(x)\leq z\\ \frac{10n(\text{CountOfOneBits}(x)-z)}{\text{($n-z$)}}&\text{otherwise,}\end{cases}  \tag{30}\]

where \(z=\left|\frac{3n}{4}\right|\). The global maximum is \(x\) of all ones, with \(f(x)=10n\); and the local maximum is \(x\) of all zeros, with \(f(x)=8n\), just like TwoMax. However, the sub-optimal local maximum is significantly more attractive than the global maximum. We transform the problem to minimizing the following cost function:

\[C(x)=10\cdot n-f(x), \tag{31}\]

which has a minimum cost of 0 for the global optimum, and a cost of \(2n\) for the local optimum, which for the 256-bit vectors of our experiments has a cost of 512. In Figure 6, we see that the Self-Tuning Lam consistently achieves the target Lam acceptance rate independent of run length with low MSE, while the Modified Lam is far less consistent. The Modified Lam eventually achieves the target rate for longer runs, taking more time at the start to adapt the temperature. For 1 million iteration runs, the difference in MSE is not statistically significant (\(p=0.32\)). However, for all other run lengths, the Self-Tuning Lam achieves a much lower MSE at statistically significant levels. Both algorithms consistently get stuck in the \"trap\". Although for TwoMax we saw that the superior exploration of the Self-Tuning Lam leads to an increased chance of converging to the global optimum, this is not the case with Trap. Table 6 summarizes the results. No runs at any length of either algorithm found the global optimum.