## 2 Materials and Methods
### Simulated Annealing  
Rather than sensing the full resolution spectra in each of the three modes, the proposed method uses just a small number of narrow wavelength bands (referred to simply as \"wavelengths\" in this paper) that are specifically chosen to yield accurate species classifications. Simulated annealing, a heuristic optimization method modeled after the metallurgical annealing process in which the metal undergoes controlled cooling to remove defects and toughen it, was used to select the wavelengths. The simulated annealing algorithm consists of a discrete-time inhomogeneous Markov chain with current state \(s(i)\) and a cooling schedule defined by a starting temperature, \(T_{max}\), a final temperature, \(T_{min}<T_{max}\), and a total number of steps, \(n\)[24]. The goal of the algorithm is to determine the minimum of a user-defined energy function, \(E(i)\). At each iteration \(i\in 1,\cdots,n\), a new trial state is determined by randomly selecting a \"neighbor\" of the previous state and calculating its energy. If the resulting energy is less than the energy from the previous iteration, the trial state becomes the new state of the system. If the resulting energy exceeds the energy of the previous energy, the algorithm adopts the trial state with probability given by:  
\[P(E(i),\ E(i-1))=e^{-\frac{1}{T(i)}[E(i)-E(i-1)]} \tag{1}\]  
where \(T(i)\) is the temperature at iteration \(i\). Note that this equation allows the algorithm to occasionally accept states that result in an increase in energy. This can benefit the optimization by preventing it from becoming stuck in local minima. The probability of accepting such states is high at the beginning of the process when the temperature is high but gradually decreases with decreasing temperature. The output of the algorithm is the state with the lowest energy encountered throughout the annealing schedule. Figure 1 provides a summary of this algorithm. For this wavelength selection problem, we define the state as an array of binary elements indicating the presence or absence of each wavelength in the full-resolution spectrum. Because the collected spectra may contain artifacts at the lowest and highest wavelengths, we institute a fixed buffer of size \(m\) at either end of the spectrum. Thus, the state at iteration \(i\) can be expressed as  
\[s(i)=I(j)\;for\;j\in m+1,\cdots,N-m-1 \tag{2}\]  
where \(I(j)\) is 1 to indicate that the \(j\)th wavelength is selected and 0 to indicate it is not, and \(N\) is the total number of wavelengths in the spectrum. Furthermore, because consecutive wavelengths are highly correlated and thus offer little additional information if both are selected, we institute a minimum separation of \(q\) wavelength indices between selected wavelengths. Finally, we set a limit, \(k\), on the number of wavelengths selected such that:  
\[\sum_{j=m+1}^{N-m-1}I(j)=k \tag{3}\]  
Under these three restrictions, we update the state for each iteration by generating a \"neighbor\" of the current system state. This is done by randomly de-selecting one wavelength index from the current state and selecting a new one. The energy of the trial state is then calculated as \(1-a(i)\) where \(a(i)\) is the average 4-fold cross validation accuracy (see Section 2.5) as determined using the weighted k-nearest neighbors (WKNN) classifier. WKNN is a variation of the familiar k-nearest neighbors algorithm where the training data points are weighted based on the squared inverse of their distances from the query  
Figure 1: Flowchart for the simulated annealing algorithm used to select the best \(k\) wavelength for fish species classification. point. It was chosen as the basis for the energy calculation because of its relatively high classification performance and its rapid training time. Accuracy, in this sense, is calculated as the percentage of correct classifications, weighted by the number of samples per class in the test sets to ensure equal contribution from each class.