A Simulated Annealing Algorithm for Scheduling Problems

An algorithm using the heuristic technique of Simulated Annealing to solve a scheduling problem is presented, focusing on the scheduling issues. The approximated method is examined together with its key parameters (freezing, tempering, cooling, number of contours to be explored), and the choices made in identifying these parameters are illustrated to generate a good algorithm that efficiently solves the scheduling problem.


Introduction
In general terms, an operation is defined as an elementary activity whose realization requires a machine, that is, an instrument capable of performing operations.
For example, a production process is composed of operations that require the use of resources (machines, manpower).
There are three main problems to be considered: 1) Loading: to allocate the operations to the available resources; 2) Sequencing: to determine the sequence according to which the operations are to be performed; 3) Scheduling: to define the planning of each operation; that is, to identify its instants of beginning and completion.
The term "scheduling" can be used to indicate the timing according to which the operations must be carried out and the process that leads to the identification of this timing. Scheduling problems [1] therefore concern the use over time of limited resources for which there is a demand.
A machine can be: dedicated (if it can only perform certain operations), or parallel (if it can perform all the operations indifferently). In the case of parallel machines we speak of machines: identical, if they process the operations with the same speed; uniform, if the speed of the machines is different but constant and independent of the operations; uncorrelated, if the speed depends on the operations to be carried out.
The state of the art of the job scheduling problem is illustrated in [2] [3] [4].

Definitions
We can define the following entities in a scheduling problem: Processing time ij

Objectives of a Scheduling Problem
The objectives of a scheduling problem can be summarised as follows: 1) Maximum completion time (makespan): 2) Weighted sum of the completion times: A scheduling problem typically involves the following constraints: • Each machine cannot process more than one operation at a time; • Each operation must be processed at most by one machine at a time; • An operation can be performed in the time interval , Some examples of technological constraints may be: 1) Possibility to interrupt the execution of an operation and to resume it later (preemptive scheduling); 2) Constraints of precedence between operations; 3) Need to wait for setup times between the completion of one operation and the start of another on the same machine; 4) Possibility to execute groups of operations simultaneously (batch scheduling).

Classification of Scheduling Problems
Scheduling problems can be classified on the basis of: characteristics of operations; time constraints; type of information available.
Classification according to the characteristics of the operations.
According to the characteristics of the operations you can distinguish between: one-step problems (all jobs require only one operation and, therefore, you can talk about either job or task), multi-stage problems (each job is composed of several operations among which there are precedence constraints).
One-step problems can, in turn, be distinguished, depending on the number of machines, under (see Figure 2): single machine problems (with only one machine), parallel machine problems (if there is more than one machine).  Classification according to the type of information available.
Considering the type of information available, scheduling problems can be: • Deterministic, if the parameters associated with the operations (processing times, release times, deadlines) are all deterministic; • Stochastic, if any of the parameters associated with the operations (processing times, release times, deadlines) are defined in random terms.

Classification of Solutions
A standard method for classifying a scheduling problem is Graham's notation [5] where a problem is indicated by specifying three types of information: information on machines and phases; information related to the presence of constraints; optimization criterion.
A solution to a scheduling problem can be (see Figure 3): without delay (if it never happens that a machine, even though it can perform an operation, remains inactive); active (if, in order to anticipate the completion of any operation, there is a delay in the completion of other operations); inactive (if not active).
A solution without delay is also active. An active solution may be delayed. The optimal solution to a scheduling problem is an active solution but not necessarily without delay. C. Gallo, V. Capozzi

Solution Methods
Like all optimization problems, a scheduling problem can be solved with exact or heuristic methods depending on its complexity [6] [7] [8].
A widely used construction method for solving scheduling problems is the "dispatching rules" method. It is a construction method that, in the initialisation phase, orders operations on the basis of rules or priority indexes, and then builds the solution by assigning them, in this order, to the available machines.
The following section illustrates the scheduling problem applied to a typical CPU processing environment; then the Simulated Annealing technique is presented, followed by two mathematical models formalising the scheduling problem in terms of objective function and related constraints. The final sections deal with the algorithm derived from the application of SA to the CPU scheduling problem, the related computational tests and conclusions.

The Scheduling Problem in the Processing Environment
With reference to the management of the Central Processing Unit, it is fundamental to have an algorithm that specifies the sequence according to which the processing service is assigned to a specific job. This algorithm is called scheduler and implements some computing methodologies which can be very time-consuming [9] [10]. For example, it may be more expensive to run the scheduler job than the entire sequence to process.
It is therefore important to indicate a "cost" function with which the weight of each possible sequence can be measured: based on this, it is necessary to find a sequence order that allows the minimisation of the cost function. It is therefore clear that scheduling issues are intimately linked to decisions about what needs to be done and how it needs to be done.
Given a problem, we will say that we can extract the sequence requests associated with this problem when the following assumptions are met: 1) The jobs to be executed are fully known, and may not be announced to the scheduling process simultaneously but sequentially over time; Journal of Applied Mathematics and Physics 2) The resources that can be used in the execution of the work are fully specified; 3) The sequence of core tasks required to perform each of the jobs is known.
The scheduling problem can be solved in several ways [11] [12]. A first way is to enumerate all the possible sequences, calculating the value of the objective function, to choose the sequence which corresponds to the lowest value of the objective function. For example if we have 10 jobs on 4 machines, we have to calculate the value of the objective function for each of the 10! possible permutations. This method then becomes not available for medium and large scheduling problems.
Other classic methods that solve the problem exactly consist of algorithms for branch-and-bound [13], truncated branch-and-bound [14], dynamic programming [15]. In the following we will examine the solution approach known as Simulated Annealing, an approach which derives from the controlled lowering of temperature in physical systems.

Simulated Annealing
Simulated annealing (SA) [16] [17] [18] [19] [20] is an approach based on statistical mechanics concepts, and it is motivated by an analogy with the behaviour of physical systems during the cooling process. This is a heuristic method for global optimization which requires no particular assumption on the objective function (e.g. convexity).
This analogy is best illustrated in terms of the physics of single crystal formation starting from a melting phase. The temperature of this "molten crystal" is then very slowly reduced until the crystal structure is formed. If cooling is carried out very quickly, undesirable phenomena occur as dislocations and polycrystalline phases. In particular, very large irregularities are enclosed in the structure of the crystal and the level of potential energy incorporated is much higher than that which would exist in a perfect single crystal.
This "quick cooling" process can be seen as similar to local optimization ( Table 1). The states of the physical system correspond to the solutions of a combinatorial optimization problem; the energy of a state corresponds to the cost of a solution and the minimum energy, or fundamental state, corresponds to an optimal solution. When the temperature is, theoretically, at absolute zero Kelvin no state transition can lead to a higher energy state. Therefore, as in local optimization, upward movements are forbidden and the consequences of this may be undesirable.
When crystals begin to form, the risk of undesirable local states is avoided by lowering the temperature very slowly, with a process called accurate annealing.
In this process the temperature drops very slowly through a series of levels, each maintained long enough to allow the search for equilibrium-at that temperature-for the crystal. As long as the temperature is larger than zero Kelvin, upward movements are always possible. By not allowing the temperature to deviate from that one compatible with the energy level of the current equilibrium, we can hope to avoid local optima until we are relatively close to the basic state. SA is the algorithmic counterpart of this physical annealing process. Its name refers to the technique of simulation of the physical annealing process in conjunction with an annealing schedule of temperature decrease. It can be seen as an extension of the local optimization technique [21] [22] [23] [24], where the initial solution is repeatedly improved by small local perturbations until none of these perturbations improves the solution. SA randomizes this procedure in such a way as to occasionally allow upward movements, i.e. perturbations that worsen the solution, and this in an attempt to reduce the probability of blocking in a locally optimal but overall poor solution.
This technique was proposed by [25] and used in the field of statistical physics to determine the properties of metal alloys at a given temperature. The possibility of solving combinatorial optimization problems have been demonstrated independently by [26] and [27]. Further applications have been carried out with great success, as shown in [28] [29] [30] [31].
A simple scheme of simulated annealing is as follows: Freezing. This consists of establishing the criteria for stopping the algorithm.
Temperature. This is a value on which the probability of accepting upward movements depends. At each iteration this temperature is reduced by a constant rate called cooling.
Number of neighbors to explore. Each iteration considers a (fixed) number of sequences close to the one considered.
SA is widely applicable in local optimization problems. It seems to produce better solutions than other local optimization techniques, as it permits you to get Journal of Applied Mathematics and Physics out of locally excellent but globally poor solutions by allowing upward movements with a certain probability.

Mathematical Models
In Subection 1.1, we indicated with the term completion time ( j C ) a value that depends on the particular scheduling sequence. If a job is in position j in the sequence, its completion time is the completion time of the job at position 1 j − plus its processing time. We will denote with the term total completion time the sum of the completion times of each individual job.
The sequencing problems that we will deal with are called non preemptive: the job that is in the processing state cannot be interrupted for any reason.
For the solution of scheduling problems we describe two mathematical models [32] that formalise it. The first model formulates the problem of scheduling n jobs on m machines that minimises the total completion time. We indicate with k ij x the variable that is equal to 1 if job j is the k-th job executed on the machine i, 0 otherwise. We also indicated ij p the processing time of job j on machine i.
The model is therefore as follows:

The Simulated Annealing Algorithm
The problem that we are going to solve with the simulated annealing technique can be summarized as follows [33] [34] [35]: To schedule a sequence of n jobs on C. Gallo, V. Capozzi m machines establishing that the order of the n jobs is the same on each of the m machines.

Basic Parameters
Basic parameters for the phase of simulated annealing are: Initialization. Choice of an initial solution. In theory the choice of an initial solution has no effect on the quality of the final solution, i.e. the solution converges to the overall optimum independently of the initial solution [36]. There are, however, experimentally verified exceptions to this theory, in which it has been shown that sometimes the process of convergence to the optimal solution is more rapid if one takes as the initial solution a solution obtained by means of a good heuristic [37]. However, the overall computational time for an approximate solution starting from a "good" initial solution is often higher than the computational time needed to obtain an approximate solution starting from any initial solution. The reason for this approach is to be found in the peculiarity of the mechanism that generates the perturbations.
Selection of a mechanism that generates small perturbations, to pass from one configuration to another one. The perturbation pattern is a crucial element to obtain good performances. The chosen perturbation scheme consists in considering two randomly generated numbers and exchanging places for the jobs that in the scheduling queue occupy the positions relative to the random numbers chosen.

Data Structure
The data structure chosen for the representation of the j-th job (with late This is the late work [12] value of the job. It is computed as follows: Other useful information for understanding the algorithm are: Actual order This is the scheduling order of the jobs currently considered. The order following the reading of the data from the input stream is assumed to be 0,1, 2, , 1 n −  .

Best order
It is the job scheduling order that obtains the minimum from the objective function. This minimum value is stored in the variable BOF (Best Objective Function).
Parameters chosen for the simulated annealing phase are: Freezing criterion A freeze occurs when the algorithm, for MAXITERATIONS times, does not perform neither a downhill nor an uphill movement.

Temperature
The initial temperature for the simulated annealing phase is set in the temperature parameter. Cooling At each iteration, the temperature is cooled by this parameter. L Number of neighbors to visit at each iteration.

The Proposed Algorithm
The proposed algorithm consists of two nested cycles. Basically, it chooses two integer random numbers (i and j) in the range { } 0,1, , 1 n −  ; then exchanges job i and job j in the scheduling queue; finally it calculates the value of the objective function. If this value is lower than the value stored in BOF, the scheduling order is stored and the variable BOF is updated. Otherwise, if the value worsens the objective function, a probability is computed on the basis of which the worsening of the objective function is accepted. The detailed algorithm is shown in Figure 4. Its strength lies in computing the value of the objective function without having to physically exchange jobs i and j.

Application Example
Let's take an example of how the algorithm works. Let's suppose we have the situation represented in Table 2, and we have chosen the random indexes 2 and 4. The queue resulting by exchanging the jobs that occupy these positions in the actual order queue is shown in Table 3. Journal of Applied Mathematics and Physics    In general, if we intend to exchange job i with job j ( i j < ): • the values of late work will be unchanged for jobs in positions { } We can therefore compute the value of the objective function without having to build the tables for the new schedule queue, but simply by processing information that is already available without using memory quantities.

Computational Tests
Before analyzing the computational tests, let us consider the (random) generator of the numbers that form the processing time values. For each job on each machine a random integer number is generated in the range [ ] 0,100   which represents the processing time value of the job on the processor.
The seed of the random number generator is initialized to a different number depending on the system time. The due date time is instead calculated by adding the sum of the values of the processing time of the job on all the available machines, increased by a percentage given by input.

C. Gallo, V. Capozzi Journal of Applied Mathematics and Physics
Data to be considered common to all tests are: • increase percentage for the due date values: 10; • number of neighbors to be explored: 10; • number of iterations per problem: 15.
With regard to the number of neighbors to be explored, the above value was chosen because from an experimental check it was noted that for a smaller number (of neighbors) you get results close to the optimal one, while for a larger number you will keep (in the cases we tested) values that often coincide with the optimal one but, being computationally severe, they negatively affect the execution time of the approximation algorithm.
Some test cases are presented to verify the computational weight on the basis of the hypotheses made.
Guidance for understanding computational testing. Table 4

Conclusions
In this paper we present a randomised algorithm using the heuristic technique of Simulated Annealing (SA)-which proved its positive result as a single-state optimization search algorithm for both discrete and continuous problems-for solving scheduling problems. The main goal behind our randomisation is to improve the solutions generated by classical job scheduling algorithms using SA to explore the search space in an efficient manner. The proposed hybrid algorithm were evaluated, and the experimental results show that it provides a performance enhancement in terms of best solutions and running time when compared to job scheduling and SA as stand-alone algorithms.
The followed solution method is of a non-deterministic type. It is based on the probability of obtaining an optimal solution in relation to the current situation of the objective function and the possible improvement due to a controlled movement in the space of the feasible solutions-linked to the concept of "temperature" of the algorithm-until it reaches the freezing point, that is an optimal acceptable one.
The choice made in our method prescinds from the initial solution and it rather takes into account the total computing time required, since it is more important to obtain an "almost" optimal feasible solution in a reasonable time rather than trying to arrive at the optimal solution in a theoretically unlimited time.