# Optimized Travel Itineraries: Combining Mandatory Visits and Personalized Activities
## 3 Methodology
### Adaptive Neighborhood Simulated Annealing Algorithm (ANSA)
#### 3.3.2 ANSA Procedure  
The ANSA methodology includes a mechanism to control the probability of selecting neighborhood moves during the search phase. The main notion behind this technique is that if the neighborhood was successful in producing quality results in the prior search, it will be more likely to be chosen in the subsequent search. The ANSA primary steps are described in Algorithm 1. The search technique begins with an initial solution. The initial step in the ANSA search procedure is to set the current temperature \(T\) to the initial temperature \(T_{0}\). The best solution \(X_{best}\) and the current solution \(X\) are set to be the initial solution. The objective value of the solution \(X\) is predetermined to be the best objective value. In ANSA, \(R_{t}\) represents the probability of selecting the neighborhood mechanism \(t\), \(t\in\{1,\,2,\,3,\,\ldots,\,E\}\). This probability is dynamically adjusted based on the performance history of the neighborhood mechanisms during the search process. Initially, \(R_{t}\) is set to be \(1/E\), where \(E\) is the total number of neighborhood mechanisms available. This means that each neighborhood mechanism is given an equal probability at the start of the search process. Next, a neighborhood mechanism \(t\) is chosen based on the current probability \(R_{t}\). The selected neighborhood mechanism \(t\) is used to produce a new solution \(Y\) from the current solution \(X\). Then, the objective value of the solution \(Y\) is added to \(O_{t}\), the sum of objective values of the solutions obtained by neighborhood move \(t\). \(N_{t}\) represents the number of times neighborhood move \(t\) has been used. After each iteration where neighborhood move \(t\) is selected and applied to generate a new solution \(N_{t}\) is incremented by 1. The \(\Delta\) is the different objective between \(Y\) and \(X\). If \(\Delta<0\), then \(Y\) is better than \(X\); thus, \(Y\) replaces \(X\) as the current solution; otherwise, the new neighborhood solution is accepted with a probability calculated by the Boltzmann function, \(\exp(-\Delta/KT)\). After completing all iterations at the current temperature, the probability \(R_{t}\) of choosing each neighborhood mechanism \(t\) is updated based on its performance. The update formula typically takes the form \(R_{t}=\overline{O}_{t}/O\), where \(\overline{O}_{t}\) is the average objective value of the solutions obtained using neighborhood mechanism \(t\), and \(O\) is the sum of the average objective values of the solutions obtained using all neighborhood mechanisms. If a neighborhood mechanism \(t\) has not been selected at the current temperature, then \(O_{t}\) is set to be \(F_{worst}\) and \(N_{t}\) is set to be 1. Note that \(F_{worst}\) represents the objective value of the worst solution found so far during the search process. The selection of neighborhood mechanism is subsequently used these updated probabilities at each iteration of the following temperature \(\alpha T\). When the current temperature is lower than or equal to the final temperature \(T_{f}\), the algorithm terminates.