1. Introduction
Metaheuristics are powerful optimization methods known for their versatility and adaptability to diverse problem types, ranging from non-linear and non-convex challenges [
1] to large-scale, high-dimensional tasks [
2]. The stochastic nature of metaheuristics raises innovative solutions, while their scalability and parallelization potential [
3] enable efficiency in large computations. Additionally, their simplicity and ease of implementation make them generally applicable, yet they remain flexible enough to incorporate domain-specific heuristics or hybrid approaches for tailored problem-solving. These benefits have made metaheuristics a popular choice across several fields [
4]. Although Machine Learning (ML) methods have become increasingly popular in the last decade [
5,
6], they have been overshadowed in research on metaheuristics.
The principles of different metaheuristic search algorithms are generally straightforward, but these usually have several parameters. This is not a shortcoming that can be eliminated because it gives them their flexibility. For example, these parameters make it possible to find the correct balance between the exploration and exploitation phases, control the speed of convergence, and so on. Even the simplest Hill Climbing (HC) algorithm needs several parameters (staring positions, step size, and number of examined directions) and control functions (fitness calculation and stopping conditions).
These parameters are usually domain-specific and based on the attributes of the search space. Therefore, their setting requires considerable experience or a time-consuming trial-and-error process to achieve the most effective results. The novel idea of our research is to use ML to enhance the already existing metaheuristics to make them capable of learning these parameters themselves. There are several possibilities to build these hybrid methods, for example, to design a Tabu Search [
7] using ML to identify the already visited locations or to use ML to define the stopping conditions of the main iteration, answering the question of whether it is worth running further iterations of a local search or whether it is better to restart it from another starting point.
The design of these hybrid methods is very computationally intensive, as a large number of heuristics needs to be run to generate the training database, followed by another resource intensive neural network training; and finally, a lot more benchmark executions are required to ensure reliable evaluation (and this may need to be repeated when testing different ML models). As a preliminary step in this direction, this paper presents the idea of a hybrid ML-assisted HC method capable of determining the appropriate step size dynamically, based on the knowledge extracted from previous runs.
Liu et al. [
8] presented a novel method based on variable step size, solving a problem in the domain of tidal energy application with a maximum power tracking control technique for a power generator system. Another example can be the work of Zhang et al. [
9], which combines the attributes of individual searches and population-based algorithms. Nolle also presented [
10], a novel population-based adaptation scheme with a self-adaptive step size based on the distance of the current position and a randomly selected sample of the population during each iteration. Tanizawa et al. have multiple papers on the topic of the HC method using a random step size [
11,
12].
These domain-based methods can be very efficient, but they all need the knowledge of the attributes of the search space. In the case of complex problems, it can be very challenging to find the appropriate adaptations. The novel idea of this paper is that this domain-specific knowledge can be extracted via ML.
This paper presents some details about the HC algorithm and its variants, followed by the novel hybrid approach, detailing the methodology behind generating training data, refining the algorithm, and evaluating its effectiveness. The impact of these modifications is analyzed through a comparative study with existing HC variants, demonstrating key findings and performance improvements. The results provide insight into the strengths and limitations of the proposed method, ultimately shaping the conclusions of this work.
3. Methodology
3.1. Machine Learning-Assisted Hill Climbing Algorithm
The novel method proposed is based on the assumption that domain-specific knowledge about the search space can help the HC method (especially the determination of the distance of each iteration). Algorithm 2 presents the idea of the Machine Learning-assisted Hill Climbing method. The algorithm has the following modifications:
The additional
parameter presents a neural network trained on the specific
S search space. Its training is discussed in
Section 3.4.
The additional L queue contains the domain-specific information gathered by the current run of the HC algorithm.
Line 7 appears as the prediction of the neural network is used to determine the next value. The prediction is based on the already existing information stored by L.
This variant assumes a simple Feedforward Neural Network (FNN) with a fixed sized input (
). The detailed architecture and the training of the FNN are described in
Section 3.2,
Section 3.3 and
Section 3.4. The neural network is not able to predict before the necessary information has been collected; therefore, the algorithm uses the same steps as the original HC for the first few iterations.
At the end of each iteration, the current fitness value and values are stored in L (line 10). It is enough to store only the information of the last few iterations, based on the input size (line 8).
Algorithm 2 Machine Learning assisted Hill Climbing Steepest Ascent algorithm |
- 1:
function HillClimbingSteepestAscent() - 2:
- 3:
- 4:
- 5:
while do - 6:
if then - 7:
- 8:
- 9:
end if - 10:
- 11:
if then - 12:
- 13:
- 14:
else - 15:
- 16:
end if - 17:
end while - 18:
return p - 19:
end function
|
The presented algorithm uses a fixed step size. However, it is obviously possible for any of the already known methods to be used to handle the first few iterations (for example, the BF method). It is also possible to design an alternating version of the algorithm, making some steps based on the BF method, after following some steps based on the prediction of the FNN, and switching back to the BF method for a while.
3.2. Creating the Machine Learning Model
The whole idea is based on the domain-specific knowledge learned by the FNN. Therefore, it makes no sense to create a general ML model to serve all possible problems. On the contrary, it is necessary to train the neural network on a given search space to make it capable of accurate value predictions.
This training needs a training database which is easy to produce. It is possible to run several HC algorithms from random starting points of the search space. The BF method always determines the best value for a given location. The objective of the ML model is to build a function capable of predicting the best values based on the already known values. These are as follows:
The iteration number (i).
The current location.
The fitness value of the current location.
The current value (size of the previous step).
Historically, the last k of these values, where
- –
;
- –
;
- –
.
To ensure the generalization of the model, the method presented in this paper does not use the p values, it only uses the current (and last k) fitness and values.
3.3. Generating the Training Data
The evaluation is based on the Rosenbrock function, which is a non-convex function forming a valley used by several papers to perform tests for metaheuristics. Because of its shape, finding a good direction is trivial; however, finding the optimal step size is hard. Therefore, the fitness function is defined as follows:
The standard parameters (, ) have been used; therefore, the global minimum is at the , and the value of the function is here.
The training dataset is generated by the execution of 20,000 HC algorithms from random starting positions. As a constraint, the starting positions
are chosen randomly from a predefined area around the global optimum.
The training database generator algorithm is based on HC using the BF method for
determination, where the set of possible step sizes is as follows:
The number of possible directions (
) was four, as follows:
According to the BF method, the algorithm examines all
values and all directions, and it chooses the best move for all iterations. In total, 11 different
values were tested, with 4 directions for each case, so choosing the best move requires 44 fitness calculations. This is quite computationally intensive but gives the most accurate dataset for training. The HC algorithm has been extended with some monitoring operations as follows: it continuously saves the fitness value of the current
p position and the best
size from this location for each iteration. As visible from
Table 1, all HC runs could reach a good fitness value; however, the standard deviation of the required steps is very high.
3.4. Building the Machine Learning Model
A simple dense Deep Feedforward Neural Network was used for the study. Based on some preliminary tests, the architecture was defined as follows:
Input layer— number of input neurons.
Hidden layer—500 dense neurons, using sigmoid activation.
Hidden layer—500 dense neurons, using sigmoid activation.
Hidden layer—500 dense neurons, using sigmoid activation.
Output layer—1 output neuron using sigmoid activation.
The input layer is fed by the following vector: , where i is the number of the iteration, is the fitness of the position of the j-th iteration, and is the chosen value at the -th iteration.
The output is the prediction of the best
value for the
i-th iteration. As the
value can vary over a wide range (in this case, between
and 10), it was normalized by the following function:
A training dataset is built on the synthetic dataset presented in
Section 3.3. The first
iterations of all HC executions were skipped, and after that, vectors containing the given input data format were built for each subsequent iteration. The training dataset consists of 392 M records. The chosen depth (
k) value was 5.
The network is trained using the Adam optimizer with a learning rate of 0.001 for 500 epochs. The entire database has been used for training, with no risk of over-fitting due to the massive size of the database (compared to the small capacity of the network). Using synthetically generated data without any noise also helps to avoid over-fitting.
The limitation of the ML model trained in this way is that it is expected to work efficiently only in the search space used to generate the training database. This is the price to pay for replacing the otherwise general HC metaheuristic with a domain-specific HC algorithm, which is, in turn, expected to perform better in this narrower context.
To evaluate the novel method proposed, the assembled hybrid ML-HC algorithm was examined in depth. The built-in FNN model itself was only evaluated with some preliminary tests. This resulted in the choice of three hidden layers. As can be seen in
Figure 1, with one hidden layer, the network was not able to achieve good predictions, with two and three hidden layers; the networks showed similar results (slightly to the advantage of three); and with the introduction of the fourth layer, the network training slowed down considerably.
Since the training of different network architectures required a lot of resources and time, finding the perfect architecture and optimizing the training hyperparameters are outside the scope of this paper. Obviously, there may be better architectures (for example, recurrent neural networks), and the size of the network may be smaller. But this network was eligible for the goal of this paper—to prove that it is possible to predict the value based on the data of previous steps—and this method can make the HC algorithm more efficient. A future research topic that can be considered is finding the appropriate ML model for this purpose.
4. Results
4.1. ML-Based Step Count
The original idea of the ML-based hybrid method was to use the BF method to set the value for the first k steps and switch to the ML-based estimation for further steps. In practice, however, this simple solution did not always work. For an understanding of this, it is worth noting that the step size usually decreases continually during the execution of a HC algorithm. At the beginning of the search, the exploration phase has the advantage of high values, but later, it is better to decrease this value for the exploitation phase. This phenomenon is visible in the training database as follows: smaller fitness and inputs usually lead to small predictions (meaning both the absolute values and the changes in the fitness and ). In rare cases, this causes an erroneous loop as follows: (a) as it is just a prediction, the ML model sometimes underestimates the step size; (b) small prediction leads to a small step size and a resultant small fitness change; and (c) based on these small values, the ML model tends to predict more smaller step sizes and so on. In practice, this manifests as the algorithm starting to take smaller and smaller steps at some undefined point, slowing down the convergence.
An algorithm representing alternating behavior has been developed to avoid this loop. This variant starts with the BF method for the first k iterations and switches to the alternating mode. In this mode, it performs l steps using the ML predictions, and after these, one step is carried out using the BF method. If the ML prediction cannot give a better position, it immediately tries one Brute Force step. If this also fails, the algorithm is stuck in a local minima. If not, the search will continue with ML-based predictions.
To find the optimal number of ML steps, an experiment was carried out using different values, containing small
l values (1…10) and large ones (20, 50, 100, 200, 500, 1000, and 5000). Based on 20,000 Hybrid ML-HC executions, the results show (
Table 2) that the optimal number is 5. However, the achieved best fitness values are very similar, and there are huge differences in the number of iterations, which will be discussed later.
The HC runs for this and subsequent tests were completely independent of the database used to teach the neural network.
4.2. Comparison to Already Existing Methods
Based on the results of the previous section, it can be seen that the alternating method works well, as increasing the number of ML steps (therefore decreasing the ratio of BF steps) does not degrade the final fitness. However, the question of how the novel method performs compared to the existing ones is still open.
Table 3 presents the results of different methods according to the best fitness achieved. As is clearly visible, the fixed step size-based methods were not able to find the global optimum. Decreasing the step size can solve this problem, but it also leads to very slow convergence and high computational costs (
Section 4.3); therefore, these are not applicable in practice. The BF and Hybrid solutions could achieve much better results.
4.3. Comparison of Iteration Counts
In the case of a constant
value, a smaller step size causes more steps (iterations of the main HC loop). Comparing the fitness and step count columns of
Table 4 makes it obvious that this method has several disadvantages. The
configuration needs a similar iteration count to the BF and Hybrid methods, but the fitness is significantly worse. Lowering the fixed step size leads to better results, but the iteration count also grows out of control. This paper does not contain results for smaller
values because it was impossible to run all the necessary tests within an acceptable time. The BF and Hybrid solutions also show better performance in this area.
4.4. Comparison of the Fitness Calculation Counts
In the neighborhood check, the BF method has to check number of directions using number of step sizes, which needs fitness function calls. The ML-based method needs only fitness calculations in each iteration (similar to the fixed step size-based methods).
In the case of the hybrid alternating method, the number of fitness function calls depends on the number of BF- and ML-based steps. The ratio of these is based on the properties of the search space; therefore, it cannot be determined in advance. The more ML-based steps are taken during the search, the fewer fitness calculations are needed.
Table 5 shows the average of fitness calculations needed by the different methods. In the case of the fixed step size-based method, this correlates to the number of steps; therefore, smaller
values lead to higher computation demands. From this point of view, the BF method is in competition with the fixed step size methods; however, it is worth noting that it was able to find significantly better final solutions.
5. Discussion
In developing the Hybrid ML-HC algorithm, the first question was how many steps to allow the ML model before switching back to the BF method. The first experiments were aimed at determining this. The results show that the number of iterations is significantly affected by this parameter, but this has minimal influence on the best fitness values achieved (
Figure 2). The best results were obtained with the algorithm using five ML steps; therefore, this variant was further investigated.
When comparing the different methods for determining
, it was immediately obvious that solutions using fixed step sizes are not efficient (
Figure 3). It is more interesting to compare the standard BF and the novel Hybrid ML-BF methods (
Figure 4). As is visible, the new method has achieved basically the same results, sometimes even outperforming the original (although this advantage is not significant). The main strategy of the BF method is that it always chooses the best step size; therefore, it was surprising that the Hybrid method was able to find better results. The reason for this may be that the BF method uses a set of predefined step sizes, and one of these has to be chosen. The ML model was trained on these data, but the model was able to interpolate and extrapolate; therefore, it can suggest better step sizes than in the given predefined set.
In the next analysis, we examined the number of iterations performed by the different methods. Decreasing the fixed step size yields better results, but the iteration count can become unmanageable. Comparing the BF and Hybrid methods (
Figure 5), it is visible that the Hybrid method slightly outperforms the BF method; however, the difference is also not significant. In summary, the novel method can achieve similar results with a similar number of steps.
The BF and Hybrid methods outperformed the fixed step size-based methods, both in speed (iteration count) and accuracy (best fitness achieved). These two look very similar in both aspects; however, there is a considerable difference between the number of fitness calculations. The number of iterations performed by the methods is the same, but it is worth taking into account that the computation demand of one iteration is very different. As is visible from
Figure 6, the number of fitness calculations is significantly lower for the ML-assisted method.
6. Conclusions
This paper aimed to develop a novel hybrid HC method using a ML model and BF method to determine the optimal step size of each iteration. This required the modification of the original HC algorithm and building a domain-specific ML model. The model was trained on the information gathered from the best steps of 20,000 BF-based HC runs.
As the results show, the fix-step size has several disadvantages. It is a matter of choice whether to have high-quality results or low computational demands, but both of them are unreachable. The BF method was able to achieve significantly better results, but it needed a moderate number of iterations. The novel hybrid method gives slightly better results using slightly fewer steps.
Taking into account the number of fitness calculations, the results appear more promising. Using the alternating hybrid method (using a maximum of five consecutive ML steps), the same results were achieved using less than half the number of fitness calculations. Considering that fitness calculation is usually the most expensive operation in metaheuristics, this is a significant improvement.
The results obtained in this way cannot be generalized, and the same ML model is unlikely to be applicable to other search spaces. However, this is an acceptable compromise, since the goal was to implement a more efficient domain-specific search than the existing ones, which does not require precise knowledge of the structure of the search space. Further consideration may be required for comparisons of different ML models and the examination of various additional metaheuristics. It is also essential to test the viability of the proposed solution for other problems of greater complexity and with more dimensions. However, the aim of this article was to only examine the theoretical possibilities in practice, and based on the results, it can be clearly stated that it is worth continuing further studies in the direction of Machine Learning-assisted metaheuristics.