A TWO-STAGE GREEDY HEURISTIC FOR A FLOWSHOP SCHEDULING PROBLEM UNDER TIME-OF-USE ELECTRICITY TARIFFS

This paper studies a two-machine flowshop scheduling problem under time-dependent electricity tariffs, in which electricity prices may vary from time to time throughout the day. The main issue is to assign a set of jobs to available time slots with different electricity prices to minimise the total resource cost required for processing the jobs. The main contribution of this work is two-fold. First, a new continuous-time mixed-integer linear programming (MILP) model is proposed for the problem. Second, a two-stage greedy heuristic is developed. A computational experiment on randomly generated instances demonstrates that the greedy algorithm can improve the objective function by almost 40 percent. The algorithm can be applied by production managers to scheduling jobs in a flowshop under time-of-use (TOU) electricity tariffs to save electricity costs.


INTRODUCTION
Energy has been the subject of many researches in recent years.In fact, rapid economic development in various countries has led to the unbridled use of energy sources in different parts of the world; therefore, energy shortages became a bottleneck in the development of many countries.Electricity tariffs and international non-renewable energy costs are increasing at a rapid rate.These trends highlight the need for competitive, energy-intensive industries to reduce their energy costs [1].
Management of energy consumption in the manufacturing sector will be realised with two approaches: a hard approach, and a soft one.In the first approach, energy consumption could be managed by changing and using modern and efficient machinery and other hardware-related techniques.However, in the software approach, management principles can be used to reduce energy consumption and create sustainable production.Demand-side management is one of the soft approaches that can be used by energy suppliers.The aim of this approach is to transfer energy consumption from peak to non-peak hours to reduce the cost of generating energy, in addition to enabling the public to use the produced energy.One of the most common methods is time-based pricing policies.In this policy, called time-of-use (TOU) tariffs, the cost of electricity consumption varies throughout the day, and as a result, consumers are urged to manage their demand for energy consumption.For example, in Iran, the cost of electricity consumption varies according to different periods of the day [2].Figure 1 shows the relationship between hours and the low-load, mediumload, and peak-load of the electricity distribution system for a typical home in the first six months of the year.The electricity tariff varies in each of these situations.In Iran, approximately 13 percent of the manufacturing sectors use electricity as their main source of energy, and more than 80 percent of the energy is consumed by production lines.
On the other hand, one of the common workshop environments is a flowshop, in which a number of jobs require different operations at different stages.Each operation at any stage requires a specific time for each job.The basic point in a flowshop is that each job should pass each stage in a oneway and forward-flow sequential order.Determining an appropriate sequence and schedule for doing jobs in a flowshop can reduce various costs in the system.This paper is among the few that address the theoretical discussions of scheduling-related optimisation with time-dependent costs in a flowshop environment.
This research addresses the problem of job scheduling in a two-machine flowshop to minimise energy costs, where the tariff of electricity follows a TOU policy.The main challenge is to allocate operations to the empty time intervals in the flowshop so that the amount of energy required to process the jobs is minimised.This paper is important from two perspectives.First, a continuoustime mixed-integer linear mathematical model is presented for determining optimal task scheduling.Second, a two-step greedy heuristic algorithm is presented to solve high-level problems.The algorithm can be applied by production managers to schedule jobs on a two-machine flowshop under TOU electricity tariffs to save electricity costs.

LITERATURE REVIEW
The paper by Nilsson and Söderström [3] is among the earliest research with a particular focus on time-dependent costs.In their research, different concepts of time-dependent costs of energy are discussed, and they state that the energy costs can be reduced in the planning of industrial enterprises production by considering the peak time of energy consumption and changing the production schedule.Castro, Harjunkoski and Grossmann [4] addressed the role of time-dependent scheduling with regard to variable hourly energy costs, and provided a variety of algorithms for optimal scheduling of the factory production plan in continuous production planning.According to their claim, time-dependent scheduling can be used to reduce the energy costs for factories by up to 20 percent.Wan and Qi [5] examined the varied cost of task execution in different timeslots (i.e., slotcost) and filled the gap in the study of these subjects in the scheduling literature.In their general model, each time interval k can have a cost of πk.They did not discuss the energy-related costs specifically, but stated that TOU could be a specific application of their research.They then examined the combination of different objective functions of single-machine scheduling with this time-dependent cost, and proved that general hybrid problems, such as the combination of total flow time with time-dependent costs, or total tardiness with time-dependent costs, are categorised as NP-hard problems.
Another study of scheduling jobs with time-dependent costs was done by Moon, Shin and Park [6].They defined a scheduling problem for parallel machines, taking into account time-dependent and machine-dependent electricity costs.The research tries to find the best scheduling by offering a meta-heuristic algorithm based on a genetic algorithm to minimise energy costs and the maximum time of completion -i.e., makespan.In fact, by inserting idle time at costly times, they tried to find optimal scheduling; but since inserting the idle time of machines can lead to a longer completion time for tasks, they attempted a trade-off between these two functions.
Shrouf, Ordieres-Meré, García-Sánchez and Ortega-Mier [7] investigated a single-machine scheduling problem for time-dependent energy costs.In this research, a machine can be defined by three states: processing, idle, and off.Each of these three states has a different energy consumption, and energy costs change overnight and hourly.The results of this research determine which jobs should be done and in which order, and how the machine transits between the different states.The aim of this research is to minimise the total cost of energy.After providing a mathematical model, a metaheuristic algorithm based on a genetic algorithm is proposed, due to the difficulty of the problem.
Fang, Uhan, Zhao and Sutherland [8] studied a single-machine scheduling problem in which each task has a different processing time and energy consumption.The main aim of this study was to achieve the best scheduling of jobs to minimise the total cost of energy, where the energy costs are time-dependent.
Another study, by Zhang, Zhao, Fang and Sutherland [9], is in the area of flowshop scheduling to minimise the two objective functions of energy cost and CO2 emission, and in which energy costs follow the time-dependency model.In their problem, every job has a processing time and a certain amount of energy consumption per machine.According to their assumption, replacing tasks from the peak time of energy consumption to a non-peak time can increase CO2 production while reducing energy costs (because coal power stations can be used instead of gas).Consequently, the paper aims to find a Pareto front of energy costs and CO 2 emissions.In order to solve the problem, the researchers presented time-indexed integer programming.
Che, Zeng and Lyu [10] presented a mathematical model and a greedy heuristic algorithm to find the best scheduling of jobs in a single-machine environment.In their study, each job for processing had a certain processing time with an accompanying amount of required energy.Consequently, finding a schedule to minimise the costs of processing the entire job was realised by the proposed mathematical model, which assumed a TOU pricing policy for energy.The authors presented a greedy heuristic algorithm to achieve fairly good answers.Ding, Song, Zhang, Chiong and Wu [11] investigated a similar problem to that studied by Che et al. [10], but in the environment of parallel machines.The aim of that was to find the optimal scheduling to achieve the lowest total energy cost of the system, with the makespan no less than a threshold determined by the user.To solve this problem, they proposed two approaches.In the first approach, the problem was modelled by mathematical programming in the form of a time-interval-based mixed integer linear program.In the second approach, the problem was redefined by the Dantiz-Wolfe decomposition technique, and a heuristic algorithm of column generation was proposed to solve it.

PROBLEM DEFINITION AND MATHEMATICAL MODEL
We are studying a two-machine flowshop problem with a given set J=(1,2,..., n) of two-operation jobs that are available to be processed at time zero.Each job requires the first operation to be on machine 1 and the second operation on machine 2. At any time, each machine can process one job at most; and each job can be processed on one machine at most.Once the processing of a job on a machine has started, it must be completed without interruption.Also, each job must be processed in the same order on every machine.Let pj,1 and pj,2 be the processing times of job j on machines 1 and 2 respectively.
On the other hand, the processing of jobs consumes energy resources and incurs corresponding resource costs -i.e., electricity costs.Let qj,1 and qj,2 be the resource demand for the first and the second operations of job j respectively.The resource price varies in time horizon and obeys the TOU tariffs.A set of P, consisting of K time periods, is used to formulate the time-dependent pricing scheme.Period k is characterised by its starting time tk, duration ak, and resource price fk.The main aim of the problem is to assign the jobs to the available cost periods with different resource prices in the time horizon [0,T] to minimise the total resource cost required for processing them.In fact, when an inserted idle time schedule is permitted, the solution is to determine the start time and the completion time of each operation.The single machine version of this problem has been proven to be strongly NP-hard [8].
To clarify the problem, let's consider a small example with six jobs and three cost periods.Suppose each job has a specific processing time and energy demand on each machine, based on Table 1.Table 2 gives the TOU tariffs throughout a day. Figure 2 shows one sequence of jobs and their corresponding energy cost (EC).It is worth mentioning that T is seen as the upper bound for the makespan of the problem because, if some sequences with a completion time later than T exist, they will not be feasible.So T is a parameter that is defined by the decision-maker.In this paper, T is a number more than the upper bound of the makespan.Kim [12] developed a procedure to generate a sequence with the maximum makespan, which we show as Cu.Then in our problem it is assumed that T≥Cu, which implies that a feasible schedule always exists.
To develop a mixed integer mathematical model, two types of variables are needed.The first type will be used to sequence jobs and determine a feasible schedule, while the latter will be used to calculate the total energy costs (TEC).
To define a feasible schedule, an approach inspired by Manne [13] is suggested, based on whether a job occurs before others.Let xj,i be a binary variable equal to one, if job j precedes job i in the sequence (not necessarily immediately before it), and zero otherwise.Also let sj,l and cj,l be the start time and completion time of each job j on the l th machine respectively.Finally, the constant M1 used in the formulation represents a large positive number.Then constraints (1-6) can be used to sequence jobs in a two-machine flowshop and also determine the start and completion time of each operation. (1) 1,..., It should be noted that an operation might be processed in more than one cost period because either its processing time is sufficiently greater than the duration of a period, or it is processed across two or more adjacent periods.For this reason, three cases can be distinguished to calculate the energy cost of operations.The first is when an operation is completely processed within a cost period.The second happens when an operation is processed in two adjacent cost periods.Finally, the third happens when an operation is completed within more than two cost periods.Figure 3 shows an example of each of these cases.

Figure 3: An example of three conditions of operation placements
To calculate the energy costs of each job, two types of binary variables are defined: Sj,k,l (a binary variable), which is equal to 1 if job j starts its l th operation at time period k; and Fj,k,l, which is equal to 1 when job j completes its l th operation at time period k. yj,k,l shows how much time of each operation l th of job j is processed at time period k.Also, tk, ak, and fk are starting time, duration, and resource cost of each cost period respectively.Finally, for simplicity, tK+1 is considered as T, while K is the total number of cost periods.
To accelerate the speed of solvers, it can be useful to define a value for M1=T+max(pj,l) and M2=T.

S F x y binary
Constraints (7-10) calculate the amount of time each operation occupies at different cost periods.Constraints (11-13) deal with assigning the binary variable of Sj,k,l, and similarly, constraints (14-16) calculate Fj,k,l, which shows if an operation is completed in a period.
Some studies in the literature use a discrete-time formulation for scheduling problems under timedependent costs.With discrete-time formulation, the number of binary variables can be large due to the division of the time horizon.In this work, a continuous-time formulation is proposed.The proposed MILP can find optimum solutions for small size instances, while heuristic algorithms are suggested to solve larger size instances.

GREEDY HEURISTIC ALGORITHM
In this section, a two-stage greedy heuristic algorithm is proposed to solve high-level problems.The logic of this algorithm is to allocate tasks and operations to cost intervals, so that in each stage the lowest cost is realised.The first stage of this algorithm is to allocate operations to the boundaries of the cost intervals.The second stage of the algorithm will allocate the remaining tasks to the cost intervals.
Before investigating the algorithm, it is necessary to provide a series of definitions.
Definition one.Boundaries set (B): Boundary is a part of the time that a cost interval varies from its own adjacent cost interval.The set B represents all the boundaries of the problem, which is B={1,2,…,K-1}.Also, the time of the boundary is b B  is tb+1.Figure 4 shows a planning horizon with four cost intervals and three boundaries.
Definition two.∆qj: The difference between the resource demands of job j on the first machine and those on the second machine.In fact, ∆qj=qj,1-qj,2.Definition three.∆fb: Indicates the difference between the resource cost of a cost interval and that of the previous cost interval, which is calculated for each boundary as ∆fb=fb+1-fb.
Definition four.q'j: Shows an average value for the resource demand, which is calculated as the weighted average of the resource demands of each job on both machines.It is calculated as the following equation: Definition five.IFb: Indicates the amount of idle time on the second machine if we move from the boundary b B  to go forward in time.Indeed, it represents the amount of idle time on the second machine after the boundary b B  .If we assume that a new operation begins at the time of the boundary tb+1, then that operation can continue its activity until either it reaches another operation, or it reaches the end of the programming horizon.Figure 4 shows the value IFb for b=1,2,3.
Definition six.IBb: The amount of idle time on the first machine shows for the roll-back movement at the time of the border b B  .Figure 4 shows the value IBb for b=1,2,3. and the next operation on the first machine or the end of the programming horizon, whichever comes first.Figure 5 shows the value I1,k for different cost intervals.Definition eight.I2,t: Indicates the amount of empty time on the second machine from any desired time t forward to the next operation on the second machine or the end of the programming horizon, whichever comes first.Figure 5 shows the value I2,t(ex1) and I2,t(ex2) for two imaginary time points of ex1 and ex2 as examples.1) The time of completion of the last job on the second machine is not greater than T; 2) The operations on each machine do not have any overlap, and each machine at any moment processes only one task; 3) The sequence of jobs on the first machine is equal to the sequence of jobs on the second machine.Consequently, the total cost of resources for jobs of feasible partial sequence can be easily calculated.

Definition ten.
Adjustment function: This function will modify the partial sequences so that they are feasible.This function transforms the infeasible partial sequence by pushing the overlapped jobs forward in time in order for the partial sequence to be feasible.The output of this is of two types: 1) If it can be arranged by replacing tasks forward, the total resource cost of the partial sequence will be calculated and reported.2) A FALSE value will be reported if it fails to reach a feasible sequence by pushing tasks forward.Figure 6 shows an example of how the initial infeasible partial sequence will be made feasible by pushing tasks forward in time, if the new job number 4 is placed after the first job.
The first stage of the proposed algorithm is to allocate tasks with the highest ∆qj to boundaries with the highest ∆fb.In the second stage of the algorithm, the remaining jobs will be seen as a continuous pack of jobs with a new resource demand of q'j.Therefore, the jobs that have a higher q'j will be allocated to the idle times of each cost interval, and an interval that has the least cost will be considered as the starting time of the job.This procedure will be continued until all jobs are scheduled.The algorithm pseudo-codes of the first and second stages are presented below.The description of the basic operators used in the pseudo-codes is: Set cardinality |A|, which returns the number of elements within the set A; Set difference A-B denotes the difference between sets A and B, returning set A with all members in B removed from A. Although the answer is not optimal, the result obtained from implementing this algorithm can be viewed as acceptable.It can also be used as a foundation for implementing a more complex metaheuristic that may yield a closer configuration to the optimal solution.

THE RESULTS OF IMPLEMENTING THE ALGORITHM
The processing time per operation, and the number of resources required of each operation on each machine respectively, are generated from the discrete uniform random distribution with a range of 1 to 10 and a range of 1 to 5 respectively.Then, based on the proposed approach by [12], the upper limit is calculated for the maximum completion time of jobs, and is considered to be equivalent to the T parameter.Then the programming horizon is divided into an equal number of cost intervals, and the resource cost per interval is generated based on the discrete uniform random distribution in the range of 1 to 5.This algorithm is coded by Matlab 2012.To investigate the proposed heuristic algorithm's performance, the algorithm is implemented on a wide range of problems.The algorithm's performance quality for small size problems is compared with the optimum value obtained from the implementation of the mathematical model.The suggested mathematical model is solved by CPLEX, and the results are reported at Table 3. Table 3 shows the result of error from the optimal value for small-size instances.For each class of problems, 10 samples are generated, and the average error of the heuristic algorithm is compared with the optimum value.* For more than seven jobs, the mathematical model cannot find an optimal solution for more than three cost periods within 3,600 seconds.
For large-size problems, the algorithm's performance is compared with two general dispatching rules, the sequence resulting from the Johnson rule and the sequence resulting from the highest resource demand (HRD) rule -i.e., jobs are sorted based on the non-decreasing order of q'.When applied to a sequence, these rules will result in a Johnson sequence and an HRD sequence respectively.
For each class of problems, 50 instances are generated.Table 4 shows the result of a comparison between the total resource costs of the sequences derived from the two dispatching rules.The average improvement rates show the average improvement of the objective function while the heuristic algorithm is applied.

CONCLUSION
This paper examined a two-machine flowshop scheduling under a time-of-use (TOU) tariff situation.
The main objective of the study was to find a scheduling that minimises the total resource costs, although electricity prices may vary from time to time throughout a day.A new continuous-time mixed-integer linear programming (MILP) model was proposed for the problem, which could be solved using CPLEX to find an optimal solution for small-sized problems.To solve problems in large instances, a two-stage greedy heuristic was developed.The logic of this algorithm was to allocate tasks and operations to cost intervals, so that the lowest cost is realised in each stage.The first stage of this algorithm was to allocate operations to the boundaries of the cost intervals.The second stage of the algorithm allocates the remaining tasks to the cost intervals.A computational experiment on randomly-generated instances demonstrates that the greedy algorithm can improve the objective function by almost 40 percent.As for future research, it would be worthwhile to study other objective functions beside total energy costs, considering a multi-objective approach to solve the problem.

Figure 1 :
Figure 1: The relationship between time of day and the low-load, medium-load, and peak-load of the electricity distribution system for a typical home in the first six months of the year in Iran

Figure 2 :
Figure 2: One sequence of jobs (down) and the corresponding energy cost (up)

Figure 4 :
Figure 4: Example of IFb and IBb for b=1,2,3 Definition seven.I1,k: By considering an initial sequence of operations, I1,k indicates the amount of idle time between the first idle time on the first machine in the cost interval k P  and the next operation on the first machine or the end of the programming horizon, whichever comes first.Figure 5 shows the value I1,k for different cost intervals.

Figure 5 :
Figure 5: Examples of I1,k and I2,t Definition nine.Feasible partial sequence (π): A partial job sequence -a sequence that does not necessarily consist of all the jobs -will be called feasible if it has the following conditions:

Figure 6 :J
Figure 6: Running the adjustment function on a partial sequence (up) to obtain a feasible partial sequence (down) after insertion of job 4 before job 2