Solving the 0/1 Knapsack Problem Using Metaheuristic and Neural Networks for the Virtual Machine Placement Process in Cloud Computing Environment

. Virtual machine placement (VMP) is carried out during virtual machine migration to choose the best physical computer to host the virtual machines. It is a crucial task in cloud computing. It directly afects data center performance, resource utilization, and power consumption, and it can help cloud providers save money on data center maintenance. To optimize various characteristics that afect data centers, VMs, and their runs, numerous VMP strategies have been developed in the cloud computing environment. Tis paper aims to compare the accuracy and efciency of nine distinct strategies for treating the VMP as a knapsack problem. In the numerical analysis, we test out various conditions to determine how well the system works. We frst illustrate the rate of convergence for algorithms, then the rate of execution time growth for a given number of virtual machines, and lastly the rate of development of CPU usage rate supplied by the nine methods throughout the three analyzed conditions. Te obtained results reveal that the neural network algorithm performs better than the other eight approaches. Te model performed well, as shown by its ability to provide near-optimal solutions to test cases.


Introduction
Te virtual machine placement (VMP) model, which is extensively used in modern computing, suggests that the demand for computer resources (e.g., memory, network bandwidth, processing power, and storage) in a particular application might change dramatically over time. By allowing fexibility of computer resources [1,2], the cloud computing computation paradigm arose as a solution to this challenge. Hardware virtualization is commonly used to achieve such elasticity [3,4]. Te deployment of virtual machines under ideal settings on actual machines in cloud data centers is a challenging task in virtualization technology. In cloud data centers, the best way to put virtual computers over real ones can help manage resources and cut down on waste.
Currently, virtualization is becoming more widely adopted by data centers to enhance the utilization of servers and achieve a more efective allocation of resources performance management with a reduced cost of energy expense [5].
Many signifcant contributions to the virtual machine allocation problem have lately been presented [6,7]. Virtual machine allocation on a physical host is seen as a nondeterministic polynomial time challenge, more precisely as an NP-hard problem, to which the NP-hard knapsack problem (KP) can be simplifed. Te KP is often a combinatorial optimization problem with a constraint on the solution objects. However, since it belongs to the class of NPhard problems, it poses a difculty for researchers.
We provide a situation in which a person is carrying a bag, as well as a list of goods that can be carried in the bag. Each item has a distinct value and occupies a distinct place in the bag. Because the capacity of the bag is limited, the challenge is to maximize the value of a collection of goods placed within the bag while not exceeding its capacity.
Combinatorial problems, such as KP, are hard to solve because the number of possible solutions usually goes up as the size and complexity of the problem goes up. Because of this, scientists have come up with many methods that can be put into two main groups: exact methods and approximate methods.
Te knapsack problem's method relies on the problem size, desired solution quality, computational resources, and problem instance. Exact methods such as dynamic programming (DP) and branch and bound (B&B) may provide optimum solutions for small to moderate cases but may be computationally infeasible for larger problems. Metaheuristics such as genetic algorithms (GAs), ant colony optimization (CO), simulated annealing (SA), greedy search (GS), tabu search (TS), and particle swarm optimization (PSO) may rapidly explore huge search spaces and discover excellent answers in a reasonable time, although they may not be optimum. Neural network algorithms (NNAs) may efectively approximate complicated functions and discover excellent solutions, by repeatedly modifying neural network weights.
Tis article compares nine diferent strategies to tackle the VMP as an KP issue, including the B&B and DP, which are accurate approaches, and seven approximation methods GA, ACO, SA, TS, GS, PSO, and NNA. Te nine methods were chosen for two reasons: even though the B&B method and the DP algorithm are frequently employed for KP, their implementation in the context of the VMP issue is quite restricted, but as exact methods, they give the exact optimal solution. Furthermore, GA, ACO, SA, TS, GS, PSO, and NNA are used for the VMP issue in many studies [8][9][10][11], providing at least an overview of their efectiveness, but no comparative analysis has been conducted comparing the two approaches.
Te main contributions of this paper are summarized as follows: (1) Comparing the accuracy and efciency of nine different strategies for solving the virtual machine placement (VMP) problem as a knapsack problem (2) Testing the system under various conditions to determine its efectiveness (3) Illustrating, for each algorithm, the rate of convergence, the rate of execution time growth for a given number of VMs, and the rate of CPU usage throughout three analyzed conditions (4) Performing experiments to evaluate the performance of the methods used Te rest of the paper is organized as follows. Section 2 contains some related works. Section 3 includes our proposed model and discusses the mathematical formulation of the knapsack problem. A review of the various proposed algorithms is provided in Section 4. Section 5 presents the experiments and results obtained. Finally, Section 6 concludes the paper.

Related Work
Various methods have been presented in the literature to solve the knapsack problem. Te majority of the algorithms deal with precise techniques. In this part, we will discuss numerous techniques to solve the KP problem. Before delving deeper into each method, we divide them into three categories: exact, metaheuristic, and machine learning algorithms.
One approach to the virtual machine placement problem is the heuristic method. To tackle the knapsack issue, the authors of [12] presented a divide-and-conquer heuristic. Other methods involve combining several low-level heuristics to produce a high-level solution known as a hyperheuristic. Nonetheless, the authors of [13] described hyperheuristics as automated mechanisms for choosing or developing low-level heuristics to address difcult computational problems and ofered a classifcation of such methods. Te study described in [14] explores the VMP problem using a two-dimensional knapsack formulation and a heuristic method in two phases. Te frst stage is to choose a subdatacenter to which a virtual machine will be allocated and the second step is to choose a server in the specifed subdatacenter to ft the virtual machine. Troughout the process, the work addresses the cost of communication.
Another form of the algorithm used to handle the VM placement problem is the metaheuristic technique (such as the ant colony algorithm and particle swarm optimization). Tese techniques are thought to be promising for locating the nearly optimum solution. Some algorithms have been developed to reduce energy usage and waste, as well as manage computational resources. Te authors of [15] suggested a metaheuristic approach for virtual machine deployment on physical equipment in a cloud data center. One of the most critical difculties in cloud computing is making the greatest use of hardware resources while minimizing energy usage and providing the highest quality service. Tus, by optimizing virtual machines on real equipment, the suggested strategy in [15] intends to reduce energy usage in cloud data centers. Te genetic algorithm was used to create the suggested approach. Te goal of the study was to lower the amount of power used, the SLA, and the number of virtual machine moves in cloud data centers. Te research provided in [16] proposes VMPACS, a multiobjective ant colony optimization (ACO) method. Ants deposit the pheromone between each VM-PM pair in VMPACS. Te related pheromone is updated when a VM is placed on a PM. Tis algorithm's purpose is to decrease resource waste and energy consumption by PMs.
In [17], the authors suggest a population-based simulated annealing approach (PSA) for determining which items would provide the greatest fnancial return while still ftting inside a given knapsack. Several well-known instances with small, medium, and large scale dimensions up to 10000 were used to rigorously test this method and compare it to various other optimizers and a number of existing simulated annealing modifcations to prove its superiority. Te experimental fndings show that this method works better than the others; however, it still has room for improvement when applied to weakly correlated and strongly correlated highdimensional cases.
Metaheuristic methods, including memetic optimization algorithm (MA) and local search, have been applied to various optimization problems in cloud and fog computing. MAs are a hybrid approach that combines evolutionary algorithms (EAs) with local search methods to improve the efciency and efectiveness of the search process. Tey work by combining the global exploration capabilities of EAs with the local exploitation capabilities of local search methods. In cloud and fog computing, MAs have been used to optimize resource allocation, task scheduling, and load balancing, among other applications. For example, in [18], volunteers build a dynamic, peer-to-peer fog utilizing modifed memetic algorithm (MA) for optimum service placement. Local-search heuristics and extra ftness functions prioritize services based on task completion delay and rate. Enhancements increase energy efciency, service quality, and system throughput. Machine learning helps locate the most Pareto optimum solution. Tis study advances green computing systems.
Chhabra et al. [19] created a task scheduling paradigm that overcomes local search issue and enhances cloud scheduling performance by improving makespan and energy usage. Tis simulation improves cuckoo and OBL techniques by introducing a diferential evolution parameter to better searching and scheduling. Simulation on CloudSim and workload traces from HPC2N were compared to metaheuristic techniques and showed improvement for above parameters. In [20], the authors propose a multiobjective virtual machine placement algorithm to optimize energy costs and scheduling in cloud data centers while reducing greenhouse gas emissions. Te proposed method utilizes a modifed memetic algorithm and outperforms baseline and state-of-the-art methods in reducing energy costs, carbon footprints, and service-level agreement violations, while improving the total response time of IoT requests. Tis study demonstrates the potential of metaheuristic methods, such as memetic algorithm, in addressing the NP-hard issues of energy consumption minimization and scheduling in IoT environments.
Te knapsack problem, DNA fragment assembly problem, feature selection, task scheduling, and the travel salesman problem are all examples of combinatorial optimization problems; parameter estimation of photovoltaic models and nonlinear equations systems are continuous optimization problems; recently, metaheuristic algorithms and neural networks algorithms, either single-based or population-based, have strongly interacted to solve these problems [21][22][23][24][25][26][27][28]. Some of those recent algorithms used to solve the KP problem are presented in Table 1.

Formulation of the Knapsack Problem and System Model
Te VMP problem in this work maximizes the number of VMs on a server while keeping the server's limited capacity in mind as shown in Figure 1. Te following evidence backs up our knapsack claim: Te server represents the knapsack, VMs represent the things that may be placed in the knapsack, the value represents the average CPU use of a VM over a certain period, and the weight represents the amount of CPU available on a server. As a result, the formula is as follows: KP: For item k: (1) Require a specifc amount of CPU P k to be executed in a given amount of time (2) During the same time frame, the server makes W k CPU available (3) C: the server's overall CPU capacity (4) x k : based on whether or not an item k is selected, the value is either 1 or 0 Following the formulation of the problem, the most appropriate approach for solving it must be determined. Te needed background for the approaches used in this study is presented in the next section.

Exact Methods.
Exact algorithms are used to fnd at least one optimal solution to a problem. Te most successful exact algorithms in the literature belong to paradigms from two main classes: dynamic programming and branch and bound methods.

Branch and Bound
Algorithm. Te branch and bound method (procedure by evaluation and progressive separation) consists of enumerating these solutions in an intelligent way in the sense that, by exploiting elements of the issue at hand, this method removes incomplete answers that do not lead to the desired outcome [29]. As a result, we frequently fnd the answer we need within a decent amount of time. Of course, in the worst-case scenario, we always explicitly eliminate all potential solutions to the problem. Tis technique ofers a feature that allows you to confne certain solutions in order to discard them or maintain them as potential solutions. Obviously, this function's quality afects how well a branch and bound technique works, as does its ability to get rid of incomplete solutions quickly.

Dynamic Programming Method.
Dynamic programming has been called that since 1940 by Richard Bellman and allows us to apprehend a problem in a diferent way than we could imagine at frst sight. Te basic concept is simple: an optimal solution is the sum of subproblems solved in an optimal way [30]. Terefore, a given problem must be Table  1: Some recent metaheuristic and neural network algorithms.

Methods/authors/years
Contributions MD-HACO (Imen Ben Mansour [21], 2023) Te suggested MD-HACO approach combines an ACO algorithm with a multiobjective local search process to create a multidirectional framework. Te proposed method is evaluated and compared to well-known state-of-the-art algorithms on extensively utilized multiobjective multidimensional knapsack problem (MOMKP) MBO and PSO (Silalahi et al. [22], 2022) Te 0-1 knapsack problem is addressed in this work, along with its solution using the migrating birds optimization and particle swarm optimization methods BPSO-SA (Zhang et al. [23], 2022) Te study proposes a new approach for optimization that combines the advantages of the simulated annealing algorithm (SA) with the binary particle swarm optimization algorithm (BPSO Te particle swarm optimization (PSO) algorithm, the genetic algorithm, and a combination of these two algorithms called genetic-based PSO (gbPSO) are used as optimizers in the proposed Q-learning method. On the basis of a set-union knapsack problem, the efcacy of every method that was used is evaluated Cost and renewable energy-aware dynamic PUE (CRA-DP) (Abbasi-Khazaei and Rezvani [20], 2022) Te study solve the joint cost and scheduling optimization problem using two metaheuristic methods of genetic algorithm (GA) and memetic algorithm (MA) Evolutionary game theory with replicator dynamics (Khoobkar et al. [28], 2022) Tis paper proposes a partial ofoading method based on replicator dynamics of evolutionary game theory 4 Mathematical Problems in Engineering divided into subproblems and solved one by one. A dynamic programming algorithm's design may be broken down into the following four parts: (1) Describe the structure of an ideal solution (2) Defne the value of an ideal solution recursively (3) By going back to the original problem statement over and over, you can fgure out how much an ideal solution is worth (4) Construct an optimal solution for the computed information

Metaheuristic Methods.
Tey are modern metaheuristics dedicated to issue resolution, particularly optimization problems, with the goal of reaching a global optimum, typically buried in the center of several local optima [31]. Exploration and exploitation are two important aspects of any optimization algorithm. Exploration refers to the search for new solutions, while exploitation refers to the refnement of existing solutions. Te balance between exploration and exploitation is crucial for fnding a good solution in an efcient manner.
Te proposed method may have an impact on exploration and exploitation in the following ways: (1) Exploration: the proposed method may encourage exploration by using stochastic or randomized search strategies that allow the algorithm to search a larger portion of the search space. For example, genetic algorithms and particle swarm optimization use stochastic search strategies that help in exploring a wide range of solutions. Ant colony optimization and tabu search, on the other hand, use heuristics that encourage exploration by guiding the search towards unexplored areas of the search space. (2) Exploitation: the proposed method may encourage exploitation by using strategies that refne existing solutions. For example, simulated annealing and tabu search use local search strategies that focus on improving the quality of the current solution by making small modifcations to it. Greedy search, on the other hand, focuses on exploiting the current best solution by adding the item with the highest valueto-weight ratio to the knapsack. Table 2 provides a comparison of diferent optimization methods for the knapsack problem, based on their exploration and exploitation characteristics.

Greedy Search Algorithm.
Te greedy search algorithm is an iterative process that generates a solution step by step. It tries to add to the partially solved problem from the previous step at each step, starting with a partially solved problem that is empty. Tis process is repeated until a full solution is found. A greedy search algorithm can be used when the quality of the solution is not a primary factor or the size of the instance is reasonable, in this case to generate an initial solution in a metaheuristic, which is fast and easy to implement [32]. Te greedy search algorithm constructs a feasible solution by reducing it to a sequence of decisions that are made each time as best as possible according to a local criterion without questioning the decisions already made. Generally, the solution obtained is approximately.

Simulated Annealing Method.
Te simulated annealing process originated in metallurgy when a solid is heated to extremely high temperatures and then allowed to cool slowly in order to obtain low energy states. Tis procedure is known as annealing. Te method of simulated annealing was developed simultaneously by Kirk in 1983 [33]. Tis method is based on the algorithm of metropolis [34]. Tis algorithm allows us to get out of local minima with a high probability if the temperature T is high and to keep the most probable states for very low temperatures. Te metropolis algorithm samples the objective function through a Boltzmann distribution of parameters T.
To better understand the simulated annealing method, there are several notions to defne, such as the Boltzmann probability and the metropolis criterion. Te Boltzmann probability, denoted P T , is the probability of fnding    6 Mathematical Problems in Engineering a system with an energy E i at a given temperature T in the space of confgurations S. It is defned by the following expression:

Mathematical Problems in Engineering
where X is a stochastic variable that denotes the current state of the solid, K is called the Boltzmann constant, and Z(T) is a function called the distribution function defned by the following expression: where t represents all possible energy states. Te KT factor demonstrates that when the temperature is extremely high, all states are approximately equiprobable, implying that a large number of confgurations are available. On the contrary, when the temperature is low, the high energy states become unlikely compared to the low energy ones. To simulate the evolution of a solid towards thermal equilibrium for a temperature T. Te Boltzmann probability was used to come up with the metropolis criterion, which was proposed in the movie metropolis.
In the context of optimization by the simulated annealing method, the energy is replaced by the objective function, so obtaining a minimum energy solid is equivalent to the search for the global optimum of the objective function. Tis search is done by successive explorations of diferent confgurations. ∆g � g(Y) − g(X) is the goal function variant. Te transformation is approved based on the probability p(X, Y) such that When the variation Δg is negative or null, the exponential is greater than or equal to 1, and the new confguration is accepted. If ∆g > 0, p(X, Y) is compared to a uniform random number in [0, 1] If r and < p(X, Y), the confguration Y is accepted If not, it is rejected and another confguration is tried. So, it is less likely that the objective function will get worse at a given temperature and less likely that it will get worse when the temperature is low. Te crucial point of the algorithm is therefore the temperature decay law. Many diferent decay laws have been proposed by Chelouah and Siarry [35].
Te simulated annealing method has quickly become popular due to its ease of adaptation to a large number of problems and its efciency. On the other hand, this method has the disadvantage of containing a large number of parameters (initial temperature, temperature decay rule, duration of temperature steps, etc.) that make the settings of the method rather empirical. However, there are studies that focus on optimal tuning of the parameters of this method [36]. Another major disadvantage of this method is its slowness. To solve this problem, several methods of parallelization of the calculations were introduced by Azencott in 1994 [37]. Te simulated annealing method was frst made to work with discrete variables, but there are also versions that work with continuous variables.

Tabu Research.
Te tabu search (TS) approach was created by Glover in 1986 [38] particularly for combinatorial optimization problems and provides for a fexible tradeof between solution quality and computing time. Te idea behind this method is to add a fexible memory to the search process, which will make it possible to search the solution space in a more "intelligent" way.
Te tabu search technique, like the simulated annealing approach, operates with a single current confguration that is modifed between rounds. To eliminate the chance of returning to a previously visited confguration, a list of disallowed movements known as the tabu list is kept. Tis list contains (t ⟶ s) movements which are the inverses of the (t ⟶ s) last movements performed. Te method thus models a primary form of short-term memory. In its basic form, the tabu search method has the advantage of having fewer parameters than the simulated annealing method. However, since the method is not always efcient, it is often appropriate to add intensifcation and/or diversifcation processes to it, which introduce new control parameters [39]. In tabu search with continuous variables, two concepts are involved: the neighborhood of a given point and a random motion in the neighborhood. For a given point X and a given step p, the neighborhood ϕ(X, p) is defned as follows: where the point Y is generated at random in the vicinity of ϕ(X, p) of X. Moreover, if it satisfes the constraints, it is called "feasible random motion." phi represents this neighborhood. Te number of points Y generated in the neighborhood phi of X with a given step p is the neighborhood size. Te performance of the tabu search depends on the size of the neighborhood and the length of the tabu list. By iteratively exploring the solution space, the search proceeds from any solution X belonging to the solution set S to a solution Y located in the neighborhood ϕ. At the beginning, the step vector covers the whole search space, and then it decreases at each iteration. Te best point in the neighborhood formed by ϕ of X is retained and becomes the center of the next neighborhood. Tis point is the one that either enhances or worsens the goal function the greatest. Te technique requires a memory to keep track of the last solutions visited within a particular time period. Tese solutions are designated as tabu, thus the method's name. Tey are kept in a list of a set length L known as the tabu list. A new solution is only accepted if it is not on the tabu list. Te length of the tabu list thus determines the return to previously investigated solutions. Te longer the list, the more difcult it will be. Consequently, the search will be directed towards unexplored regions.

Genetic Algorithms.
Genetic algorithms (GAs) are search algorithms that are motivated by the mechanics of natural development and genetics. Te frst work was carried Mathematical Problems in Engineering out by Holland in 1992 [40] in the book "Adaptation in Natural and Artifcial System," which formalizes genetic algorithms in the framework of mathematical optimization. Te publication of David Goldberg's book in [41] describing the use of these algorithms for solving concrete problems, has increased their visibility in the scholarly community and sparked renewed interest in this optimization approach. Tese methods focus on simulating the process of natural selection in an unfavorable environment and are inspired by the theory of evolution proposed by Darwin in the 1859 "Journal of Research in to Geology and Natural History." According to these concepts, when a population is subjected to the constraints of a natural environment, only the best-adapted individuals survive and generate ofspring. Over the course of generations, natural selection allows the appearance of individuals better and better adapted to the natural environment, to the detriment of those who are notoriously maladjusted, thus ensuring the survival of the species. Tis particularity of natural evolution, the capacity of a population to explore its environment in parallel and to recombine the best individuals between them, is borrowed by genetic algorithms. By analogy with genetics, these algorithms seek the best individuals from an initial population. To constitute the appropriate parents, giving birth to the best ofspring children, among which will be drawn the acceptable solutions to the treated problem. Each optimization problem is characterized by decision variables that condition the decisions to be taken, an objective to be satisfed, and constraints to be respected. Unlike classical optimization methods, variables are not used in genetic algorithms; instead, they are associated with specialized coding. Te factors of interest are taken into account by utilizing characters that form a code sequence. Each variable of choice is converted into a gene, which may include one or more codes capable of expressing unique features. Te code sequence represents a person. In other words, a chromosome is a possible solution. Te goal of the challenge is represented by a function that allows deciding whether or not a person should be picked to produce new solutions. Tis function is known as the ftness function. Te ftness function considers restrictions by penalizing people who disregard the problem's constraints. Te search for feasible solutions is based on two strategies that aim to generate new solutions at random from the starting population. Tese mechanisms are the genetic operators: crossing and mutation. Te decision-making process aims to direct the inquiry by identifying those who have the best possibility of being chosen. We will travel through the steps of a simple genetic algorithm to demonstrate how they function, as shown in Figure 2.

Ant Colony Optimization Algorithm.
Te ant colony method emerged from a simple observation: social insects, and in particular ants, naturally, solve complex problems. Since ants interact with one another indirectly by depositing chemical molecules called pheromones on the ground, such behavior is conceivable. Tis is known as stigmergy. Indeed, if a barrier is placed in the path of the ants, the latter will prefer to follow the shortest route between the nest and the obstruction after a period of inquiry. Te greater the pheromone level in a specifc location, the more likely an ant will be attracted to that area. Te ants that arrived to the nest frst chose the shortest branch of the path. It follows that the number of pheromones on this path is greater than on the longest path. Terefore, the shortest path has a higher probability of being taken by the ants than the other paths, and it will be taken by all the ants. Te frst algorithm based on this analogy was proposed in 1996 by Dorigo et al. [42].
Reference [43] advocated using the same solution to deposit pheromones on the specifed pairings of objects. Te frst approach is used for this investigation. Tis is how the algorithm might be summarized: To build a solution, ants frst choose a seed item at random, then add items from a set containing all the things that may be chosen (N j ) without exceeding the constraint on available resources. Each time, the component of the current solution S j that will be added is selected with a probability of ϕ i . Both a pheromonal component (σ i ) and a heuristic factor (also known as an attractiveness factor) (c i ) contribute to this likelihood, with their relative signifcance being determined by two parameters (α and β). If you know that the probability of ϕ i is supplied by, then you can derive the following expression: Te pheromonal factor is Te heuristic factor is expressed as follows: 4.2.6. Particle Swarm Optimization. Te particle swarm optimization (PSO) method is a SI-based strategy motivated by the cooperative nature of animal societies like bird focks and fsh schools. Developed in [44] for use in resolving issues of continuous optimization, it has been used in a variety of applications thereafter. Scheduling, traveling salesman, network deployment, task assignment, and neural network training are only some of the optimization problems that the PSO method has been used to solve [8].
To solve the optimization problem at hand, the PSO method takes into account the particles as candidates for optimal solutions. Here, N is the total number of particles in the swarm and t is the time interval between iterations, p i (t) and v i (t) (i ∈ 1, . . . , N { }) represent the location and velocity of particle i in D-dimensional space. Te problem's decision variables are represented by the entries in the position vector A ftness function f(p i (t)) measures how happy each particle is with its current location. Personal best positions, or p pBest i (t), are the best positions discovered by individual particles over several iterations, whereas the best position ever found by the whole swarm, p gBest (t) is the greatest position ever found. Particles' locations and velocities are revised according to the following rules: Te inertia mass is denoted by ω and the acceleration coefcients by c 1 and c 2 , and the two random values r 1 and r 2 are chosen from the interval [0, 1]. Particle location is updated using the velocity vector, as shown by equation (10). Te velocity vector update rule, denoted by the equation (11), consists of the following three terms: Tere are two types of infuence at play here: individual infuence, which improves the quality of each particle's position by allowing each particle to return to the previous position if it is better than the current one, and social infuence, which causes particles to follow the direction of the best neighbor. To be clear, the inertia weight is not always the same and is instead adjusted according to the formula while the algorithm runs.
where ω max and ω min represent the maximum and lowest inertia weights, respectively, and t and t max represent the iteration time and maximum number of iterations, respectively.

Neural Networks Algorithm.
Using the model's output to obtain the outcome Sometimes, fnding the largest output index is sufcient; other times, more complicated techniques are required. Following the execution of the inference, the method might be implemented. However, there are certain advantages to developing a model that can execute such an algorithm on its own. Using neural networks to solve the knapsack problem also lets the model run the knapsack algorithm and trains the model from the beginning to the end.

NNA Algorithm Data.
Te initial stage is to prepare the data; we utilize random numbers for item weights, values, and knapsack capacity. After generating the problem, brute force is used to identify the best answer. Normalizing the input is an important aspect of any machine learning task since it allows the model to adapt more efectively. To illustrate every knapsack problem, the following points are followed: (1) Subtract the values from the problem's maximum value (2) Subtract the weights from the capacity (3) Remove the capacity from the inputs as it is now integrated into the weights Te dataset contains 10,000 training sets and 200 evaluation samples.

Description of the Model.
Tis study's proposed model is a basic model with two inputs and one output. Te inputs are chained frst, and the result is passed through 2 successive layers triggered by sigmoid nonlinearity, with the output of the last dense layer acting as the model's output. Figure 3 displays a working implementation of the Keras model.

Performance Metrics.
To examine the knapsack problem, measurements besides binary classifcation efciency are required. Te frst statistic presented in this paper is referred to as "overpricing," which checks the mean diference in the values of the chosen goods and the optimal solution.

Supervised Technique.
Te supervised technique involves feeding weights and values into the model and predicting the best response as an output. Te model trains through the use of a cross-entropy loss function during this process. After training the model with 512 epochs using the supervised method, the obtained results are shown in Table 3.
However, the supervised method has the following two major faws: (1) To begin training, the best solution is required (2) Tere is no control over space violations or overpricing

Mathematical Problems in Engineering
Following that, let us try to solve these issues utilizing an unsupervised technique.

Unsupervised
Technique. Training is the model without computing the best answer. As a result, a novel loss function is required. Te item weights, values, knapsack capacity, and model output are described as W, p, C, and out, respectively. Te objective is to maximize the overall cost of the selected items. It may be computed as follows: At the same time, it is necessary to ensure that the selected items do not exceed the capacity of the knapsack. Tis value can be expressed as follows: Finally, the objective is to increase Total Price while minimizing Space Violation. Tis might be expressed as follows: To manage the Space Violation, the coefcient λ is applied to the second term. Te following is the ultimate loss formula: Te results of our 512 epochs of unsupervised training are summarized in Table 4.

Time Complexity Analysis.
In general, the method of choice for addressing an optimization problem is determined not only by its correctness but also by its complexity. Some algorithms are more efcient than others, but their complexity slows down the resolution process. Te ideal situation is to fnd the optimum balance between the quality of the answer and the time complexity faced. Table 5 displays the temporal complexity of the investigated nine methods.

Experimental Results and Performance Analysis
In this part, we use a real dataset to put our proposed approaches to solving the KP issue for VMP to the test. Readers are encouraged to view reference [45] for further information on the dataset. Te experiments have been performed on an Intel(R) Core(TM) i5-7300U @ 2.60 GHz −2.71 GHz, 16 GB RAM. Te MATLAB version employed for the manipulation is R2019a (win64). In this section, the performance of various accepted methodologies is presented and discussed when applied to the chosen dataset. Te convergence rate and the combination of objects (virtual machines) generated by each approach are the frst points of comparison. After that, the methods are evaluated based on their execution time and CPU usage. Tis metric represents the maximum number of concurrently running virtual machines that may be hosted on a single physical server without overloading the hardware. Table 6 provides a synopsis of the collected data. As a frst step, the task is to load 10 virtual machines onto a server with   Figure 4 for better understanding. Figure 5 shows the evolution of the CPU utilization rate as a function of the number of virtual machines. We can see that when the number of virtual machines increases, the variation in the results in terms of the CPU utilization rate increases signifcantly. In fact, the two exact procedures provide a solution that ensures the best use of the server's CPU resources. Te ACO and NNA values are also important.
In Figure 6, we base our comparison on the pace of convergence. Tis mostly relates to the number of iterations required to arrive at an ideal solution. When the number of iterations is predetermined, as in the case of the DP algorithm, the best solution is given by 380 iterations to ensure that there is no item remaining to process. Te B&B method must converge because it always removes incomplete solutions at each stage. Te ideal solution is obtained after approximately 20 iterations in the run shown in Figure 6. When all ants propose almost the same optimal solution, the ACO technique achieves convergence. Figure 6 illustrates that the ACO algorithm converges after 50 iterations. We may minimize the number of extra ants without impacting the ideal solution because the run was carried out with a number of ants equal to 100. For the NNA, TS, PSO, and B&B algorithms, 20 iterations result in the optimal solution. We can see that greedy, PSO, TS, B&B, and NNA require the fewest iterative steps to converge. Figure 7 shows a comparison of CPU rate utilized for one run of each method for 20 VMs. As a result, there is no    discernible diference between the studied techniques; nonetheless, it is clear that the CPU rate utilized rises, with the exception of SA and TS. Te distinction between the NNA approach and the other methods is very evident. By comparing NNA to GA, ACO, SA, TS, greedy, and PSO in terms of analysis of variance (ANOVA) [46], it is easy to observe that NNA is the better algorithm. Tis is seen in Figures 8 and 9. Te simulation is run ten times. Figure 10 depicts the evolution of the execution time for a number of VMs equal to (10, 15, and 20). We show that all of the methods give the best results except for the NNA method, which takes a long time to run.   Te accuracy and difculty of an optimization problem infuence the method used to solve it. Te ideal situation is to strike an optimal balance between response quality and time complexity. On the other hand, metaheuristics are well suited to dealing with such an issue. Te DP technique has pseudo-polynomial complexity, which implies that the time complexity O(n * C) is proportional to not only the number of components n but also to the capacity of the knapsack C, which is exponential in the binary computing system [6]. Furthermore, we can demonstrate that the GA, ACO, SA,   [47]. Te following conclusions may be drawn from this quick examination of the fndings obtained: (1) Both the B&B and DP approaches, which are refected in this study as the precise strategy for addressing the KP applicable to the VMP problem, provide optimal solutions, one of which is making full use of the server's CPU resources for such machines that have been allocated to it. As a result, the main purpose of the challenge will be to allocate as many virtual machines as possible to a limited set of servers while powering down the other servers. (2) According to studies of convergence rates, accurate methods converge after a fxed or variable number of iterations, depending on the amount of data being input. However, with the metaheuristics and NNA under discussion, the convergence rate is also linked to the procedure followed by each method. For this inquiry, we may make the educated guess that the convergence rate of neural network algorithm methods is higher than that of exact techniques and metaheuristics. resources to deliver an approximate solution in the shortest amount of time.
To summarize, as the quantity of virtual machines grows, the need to turn to metaheuristic approaches to VMP is unavoidable. In fact, the fndings suggest that the precise approaches under study are better suited to a limited number of virtual machines, as they provide the best solution while making the most efcient use of available resources. A similar statement may be made for NNA, which ofers a near-optimal solution. Table 7 highlights the comparison made in this research and confrms that metaheuristics (mainly ACO) are suggested for a wide variety of virtual machines placement problems.

Conclusion and Perspectives
Tis article presented research on optimizing server use in the cloud. Te worldwide approach of VMP was shown by the established policy, which aimed at concentrating the process on a limited number of servers so that the rest may be turned of. In this research, various methods were employed to study and solve the knapsack problem. Many strategies were compared and contrasted in the process. When combined with GA, ACO, SA, TS, greedy, PSO, and NNA, B&B and DP proved to be efective techniques. Te purpose of the research was not to create a cutting-edge solution but to address certain gaps in current research that include learning in combinatorial optimization problems.
Certainly, the methods presented in this work have given remarkable and relevant results. Based on the assessment of several optimization strategies applied to the KP problem, the NNA algorithm obtained the highest score. Terefore, the conclusion is that this algorithm is a viable and efcient strategy to address problems related to route optimization. As NNA delivered the biggest advantages, but ACO sped up the process, it is possible that future studies may beneft from integrating two of the competing methodologies (ACO and NNA). As a result, they were able to counterbalance each other and compensate for each other's shortcomings in the many KP-related optimization difculties they faced.

Data Availability
No data were used to support the fndings of the study.