A NEW MATHEMATICAL MODEL FOR THE WORKOVER RIG SCHEDULING PROBLEM

One of the most important activities in the oil and gas industry is the intervention in wells for maintenance services, which is necessary to ensure the constant production of oil. These interventions are carried out by workover rigs. Thus, the Workover Rig Scheduling Problem (WRSP) consists of finding the best schedule to service the wells while considering the limited number of rigs with the objective of minimizing the total production loss. In this study, a 0-1 integer linear programming model capable of efficiently solving the WRSP with a homogeneous fleet of rigs is proposed. Computational experiments were carried out using instances based on real cases in Brazil to compare the results obtained by the proposed model with the results reported by other methods. The proposed model was capable of solving all instances considered in a reduced computational time, including the large instances for which only approximate solutions were presently known.


INTRODUCTION
Usually for oil wells to operate at onshore fields, it is necessary to pump fluids so that the oil reaches the surface.Fluid lift can be carried out by various artificial techniques, such as mechanical pumping, progressive cavity pumping, gas lift and others.As a result, it is necessary to install equipment that works next to the well pumping the fluids.Over time, wells and pieces of equipment require maintenance services (called workover), such as cleaning, reinstatement, stimulation and others, all of which aim to maintain the production or to improve the productivity of the well.The interventions in the wells are performed by workover rigs.
The rigs are limited and scarce resources with high operational costs, and there are a large number of wells that demand maintenance services.Therefore, a service schedule should be defined for the wells.The construction of the schedule should be based on factors such as the oil production of the well, the type of service that needs to be performed and the available time window to carry out the service.Waiting for service can cause the wells to become inactive, which causes major production losses (Aloise et al., 2006).
The problem of intervention in wells for maintenance services is one of the most important activities in the oil and gas industry.Thus, providing optimal solutions is an issue that can lead to thousands of dollars in savings due to the reduction of the oil production loss as it can be confirmed in the works of Costa (2005) and Aloise et al. (2006).
Thus, the Workover Rig Scheduling Problem (WRSP) consists of establishing the schedule of the well service while considering the limited number of available rigs and minimizing the total production loss due to waiting for maintenance services in a planning horizon.The WRSP can be classified as a particular case of the scheduling problem, where the maintenance services represent a set of tasks and the rigs represent a set of parallel machines and that aim to minimize the total weighted tardiness (Colin & Shimizu, 2000;Valente & Alves, 2003).This problem is of a combinatorial nature and belongs to the NP-hard class (Du & Leung, 1990).For scheduling problems can be found a vast amount of literature addressing its classic form and extensions.
The present paper proposes a 0-1 integer linear programming model to efficiently solve the WRSP.This mathematical model extends the mathematical model proposed by Costa & Ferreira Filho (2004).A reformulation and decomposition procedure are developed to formulate the WRSP using a smaller number of decision variables and constraints, allowing to solve large instances.
The proposed model was tested in instances generated by Costa (2005) from real cases of an oil production field in Brazil.In the literature, 25 instances are available; optimum values are known for 10 of them, as reported by Pacheco, Dias Filho & Ribeiro (2009) by using the CPLEX 12.1 solver.These authors were not able to solve the remaining instances due to their great complexity, and only approximate solutions reported by some heuristics and metaheuristics for those instances are known.Thus, there are two main contributions in this paper.First, this paper describes the development of a new formulation for the problem in question, which proved to be more efficient than the methods available in the literature.The second contribution is the generation of optimum solutions for the instances of Costa (2005), which were not known in the literature until now.
This study is structured as follows: A review of the literature is presented in Section 2. The WRSP is formulated and the proposed model is developed in Section 3. The computational results are analyzed in Section 4, and the proposed model is compared with the methods available in the literature.Finally, conclusions and proposals for future work are presented in Section 5.

LITERATURE REVIEW
The problem of intervention in wells for maintenance services can be seen as both a scheduling problem in the environment of parallel machines and as a problem of routing and scheduling with multiple vehicles.In the scheduling approach, the rig travel time between wells is disregarded for practical reasons.However, in the approach of routing and scheduling, this element is considered significant.According to Gouvêa, Goldbarg & Costa (2002), using the scheduling approach is appropriate when the times required to move the rigs between the wells are on the order of minutes or hours and the rig intervention time is on the order of days or weeks.
Among the applications that addressed the approach of routing and scheduling, the following applications stand out: Paiva (1997 2006), the second is based on the open vehicle routing model and the third is based on the set covering model incorporating the column generation strategy to find the optimal linear relaxation solution.The best results were obtained by the third mathematical model, achieving optimal values for medium-sized instances.Bassi, Ferreira Filho & Bahiense (2012) presented the first study dealing with uncertain data for this approach.A simulation-optimization method was developed to generate expected solutions.The simulation stage consists of performing a random sampling of uncertain data to be solved in the optimization stage.In the optimization stage, a greedy algorithm and a Greedy Randomized Adaptive Search Procedure (GRASP) metaheuristic were used.Ribeiro et al. (2014) presented a BPC heuristic and a Hybrid Genetic Algorithm (HGA).Monemi et al. (2015) proposed a mixed integer linear programming model.The solution method begins with a hyper-heuristic and this result is used to generate columns for BPC algorithm.The numerical experiments were performed in disturbed data from an onshore field in Brazil.The method is able to solve small instances.
Applications addressing the scheduling approach has been studied by several authors: Smith Smith (1956) showed that for the case of one rig, the optimal schedule is obtained when the wells are ordered in decreasing values of P i /d i , called Natural Order, where P i is the production loss in well i per day and d i is the duration of the intervention in well i.Brennan, Barnes & Knapp (1977) showed a lower bound for WRSP with N rigs and J wells based on the papers published by Smith (1956) and Eastman, Even & Isaacs (1964).Costa & Ferreira Filho (2004) proposed a mathematical model and a heuristic based on the Natural Order.Costa (2005) implemented a GRASP metaheuristic, and they constructed instances based on real cases from an onshore field in Brazil.Costa & Ferreira Filho (2005) proposed a Dynamic Assembly Heuristic (DAH) that allocates the services sequentially according to the criterion described in Costa & Ferreira Filho ( 2004), testing all of the possibilities for adding a new service before and after those already programmed and dynamically allocating the services to the rigs with the purpose of improving the solution.Alves & Ferreira Filho (2006) proposed a Genetic Algorithm (GA) in which the solutions (chromosomes) represent a vector of wells that will be distributed to the rigs.The crossover operator that was used was the uniform order crossover, and the mutation operator was the random swap of two positions in the well vector.Oliveira et al. ( 2007) presented an evolutionary algorithm based on the Scatter Search (SS) metaheuristic that operates over a population of solutions and employs procedures to combine those solutions with the goal of generating better solutions.Instead of randomly exploring solutions like the GA, the SS extensively explores predetermined regions in each new iteration.Pacheco ).Thus, this paper proposes an efficient mathematical model to determine the optimal solutions of the instances of Costa (2005).Until now, just approximate solutions for large instances are known, we will propose a formulation to solve this gap in the literature.

PROBLEM FORMULATION
The WRSP is formulated as follows: a set of available rigs m = 1, 2, . . ., N and a set of wells i = 1, 2, . . ., J that require maintenance services, in which each well i is associated with an intervention time d i ; a time window in the range [e i , l i ] in which it can be serviced; and a value of production loss P i , which indicates how much that well will not produce (in units of volume per unit of time).The execution of each intervention in a well requires that a rig is selected.Thus, the WRSP consists of determining the service schedule for the wells by the rigs with the objective of minimizing the total production loss due to the time that the wells waited for maintenance service in a planning horizon.
The assumptions are as follows: • The fleet of rigs is considered homogenous.
• The travel times between each pair of wells are not considered because they are not significant compared to the intervention times.
• The assembly and disassembly times are included in the intervention times.
• Each rig operates without idle time until all wells allocated to the rig have been serviced.
• Once the intervention is started, it cannot be interrupted.
The following notation is used to formulate the WRSP: J number of wells, i, j = {1, 2, . . ., J } N number of rigs, m = {1, 2, . . ., N } T planning horizon, t, h = {1, 2, . . ., T } d i duration of the intervention in well i P i production loss in well i per unit time [e i , l i ] time window, where e i is the earliest start time for the intervention in well i and l i is the latest finish time for the intervention in well i The decision variables are defined as follows: S imt binary variable that takes on the value of 1 if rig m starts the service in well i at time t ; otherwise, it takes on the value 0 C imt binary variable that takes on the value of 1 if rig m finishes the service in well i at time t ; otherwise, it takes on the value 0 X imt binary variable that takes on the value of 1 if rig m is performing the service in well i at time t ; otherwise, it takes on the value 0 Figure 1 illustrates the representation of the decision variables.Suppose that a certain intervention i starts at t = 3(S im3 = 1), if the duration of the intervention is 4 time units (d i = 4), then the finish of the intervention will be at t = 6(C im6 = 1), such that the total time that requires a rig in a well is exactly d i = 4.That is, the intervention occurs in the range ).Therefore, it can be inferred that

Original Mathematical Model
Costa & Ferreira Filho (2004) proposed a 0-1 integer linear programming model, here called the Original Mathematical Model (OMM) for the WRSP, which is formulated with the variable S imt and represented as: Subject to: In this mathematical model, the objective function (1) represents minimizing the total production loss.Constraint (2) ensures that the start of the intervention in each well occurs only once by a rig at a specific time.Constraint (3) ensures that a rig starts at most one intervention at a specific time.Constraint (4) ensures that there is no interference between the services in the wells that use the same rig; that is, no well j can be serviced in the range [t, t + d i − 1] by rig m if well i is being serviced in that range by the same rig m.Constraint (5) defines the domain of the decision variables and ensures that the start of the interventions in the wells is within the time window.

Reformulated Mathematical Model
In this paper, a Reformulated Mathematical Model (RMM) based on the OMM is presented.The RMM will be derived from a mathematical model that is initially larger and formulated with the variables S imt , C imt and X imt .With the inclusion of these variables, the WRSP is formulated as follows: Subject to: In this mathematical model, the objective function (6) represents minimizing the total production loss.Constraint (7) ensures that the start of the intervention in each well occurs only once by a rig at a specific time.Constraint (8) ensures that a rig starts at most one intervention at a specific time.Constraint (9) ensures that the start of the interventions in the wells is within the time window.Constraint (10) ensures that the finish of the intervention in each well occurs only once by a rig at a specific time.Constraint (11) ensures that a rig finishes at most one intervention at a specific time.Constraint (12) ensures that the finish of the intervention in the wells is within the time window.Constraint (13) ensures that the period between the beginning and the end of the intervention in each well is exactly the duration of the intervention.Constraint (14) ensures that each well is serviced without interruption within the start and finish times established for the intervention.Constraint (15) ensures that a rig performs at most one intervention at a specific time.Constraint (16) defines the domain of the decision variables.
In this formulation, the variable C imt depends of S imt and the variable X imt depends on the choice of S imt and C imt to be determined.Thus, constraint (13) can be replaced in constraint (14): This constraint can be further simplified as follows: Equation ( 17) is equivalent to equation (14).
Equation ( 14), together with equation ( 15), ensures that there is no interference between the serviced wells that are allocated to a rig.Substituting equation (17) in equation ( 15) gives: Finally, the previous mathematical model is formulated by substituting the variables C imt and X imt as a function of the variable S imt , so that the Constraints ( 10), ( 11) and ( 12) become unnecessary.The RMM is shown below: (RMM) Minimize (t + d i − e i )P i S imt (18) Subject to: In this mathematical model, the objective function (18) represents minimizing the total production loss.Constraint (19) ensures that the start of the intervention in each well occurs only once by a rig at a specific time.Constraint (20) fulfills the function of constraints (3) and (4) of the OMM; that is, ensures that a rig starts at most one intervention at a specific time and ensures that there is no interference between the services in the wells that use the same rig.Constraint (21) defines the domain of the decision variables and ensures that the start of the interventions in the wells is within the time window.

Decomposed Mathematical Model
In this paper, the proposed mathematical model is presented as a Decomposed Mathematical Model (DMM), which is formulated from the RMM with a new decision variable: where: S it binary variable that takes on the value of 1 if the service in well i starts at time t ; otherwise, it takes on the value 0 The variable S it could be used to replace the variable S imt directly in the RMM except for constraint (20).Thus, applying the sum for all m in constraint (20) and assuming that the rigs are homogenous, the following applies: Given that a maximum of N rigs perform the maintenance services in the wells at the same time, this constraint ensures that a maximum of N interventions are performed at a specific time and that there is no interference between the wells.
Thus, substituting the variable S imt as a function of the variable S it in the RMM, a DMM is obtained, which determines the optimum start of the interventions in the wells as shown below: (DMM) Minimize Subject to: In this mathematical model, the objective function (22) represents minimizing the total production loss.Constraint (23) ensures that the start of the intervention in each well occurs only once by a rig at a specific time.Constraint (24) ensures that a maximum of N interventions are performed at a specific time and that there is no interference between the allocations of the wells to rigs.Constraint (25) defines the domain of the decision variables and ensures that the start of the interventions in the wells is within the time window.
From the DMM, the optimum solutions S it * are obtained.These solutions will be used to determine the allocation of the wells to the rigs throughout the planning horizon.This allocation can be achieved by constructing a simple algorithm that allocates the wells to the rigs consecutively following the service order in time.Another way to determine this allocation is to solve the RMM, redefining the domain of the variable S imt depending on the optimal solutions S it * .
The suitability of the RMM for this purpose is shown next.
(RMM') Minimize (t + d i − e i )P i S imt (26) Subject to: In this mathematical model, constraints ( 27) and ( 28) and the objective function ( 26) have a similar interpretation to constraints ( 19) and ( 20) and the objective function ( 18) of the RMM, respectively.Constraint (29) defines the constrained domain of the decision variable S imt and ensures that the start of interventions in the wells are exactly the values found S it * , that is, only in the cases where S it * = 1, the variable S imt will be defined to determine the allocation of the wells to the rigs.

Comparison between the OMM, the RMM and the DMM
Table 1 shows the total number of constraints and variables used in the OMM, RMM and DMM.
No. of variables Eq.No. of variables Eq.No. of variables ( 5) The RMM and the DMM are formulated with fewer constraints compared to that of the OMM, and constraint (4) of the latter generates the most constraints.While the OMM uses the variables S imt and S jmh in constraints ( 3) and ( 4), the RMM and the DMM do not use the index j of the formulation and use the variable S imh in constraint (20) and the variable S ih in constraint (24), that is, they use fewer constraints.The same number of variables is used in the OMM and the RMM, and fewer are used in the DMM compared to them because it is a mathematical model that does not consider the problem of allocating wells to rigs.

COMPUTATIONAL RESULTS
To evaluate the performance of the DMM, this model were compared to the OMM.The instances of Costa (2005) were used.These samples consist of 25 instances that have 25, 50, 75, 100 and 125 wells with 2, 4, 6, 8 and 10 rigs, generated from real cases in Brazil, where the values of production loss (P i ) are in units of (m 3 /day)/10, and the values of the intervention time (d i ) are in units of half of a day (12 hrs).
The mathematical models were implemented in the AIMMS 3.14 software using the CPLEX 12.4 solver and run on a computer equipped with an Intel Core i7-3960X processor with 3.3 GHz and 64 GB of RAM.
Next, a preliminary analysis was performed, and Table 2 shows the planning horizon (T ) for each processed instance, the number of variables, the number of constraints and the optimal values of the objective function obtained via linear relaxation for the OMM and DMM.
Table 2 shows the significant differences between the number of constraints of the OMM compared to of the DMM, similar to Table 1.Furthermore, according to the values of the linear relaxation, the DMM obtained the best lower bounds for the different instances, with a mean difference of 40% relative to the OMM.This result supports the statement that such formulation is stronger concerning the use of methods based on linear relaxation (such as methods based on branch-and-bound strategies), which in turn implies that they obtain optimum solutions in a more efficient manner.
Table 3 presents the results of the objective function obtained for the WRSP by the OMM and DMM exact methods and then compares the results with other methods available in the literature.In this table, those methods that obtained the best results are shown: GA (Douro & Lorenzoni, 2009), MA (Pacheco, 2011) and SA (Ribeiro, Mauri & Lorena, 2011).As the solver stopping criteria, a GAP of 0% and a run time limit of 300 s were established to solve the OMM and DMM.
In Table 3, the values in bold indicate the optimum solutions found by the exact methods and by the metaheuristics.The OMM was only capable of solving the first 15 of the 25 instances, while in the instances with 100 and 125 wells, optimum solutions were not obtained within the established time limit.This result is in contrast with of the DMM, which was able to find optimum solutions for all 25 instances.The optimum solutions of the last 15 instances, i.e., those with 75, 100 and 125 wells (considered the large instances), were previously unknown in the literature.As a more modern computer was used here than in Pacheco, Dias Filho & Ribeiro (2009), it was possible to find solutions using the OMM for the instances with 75 wells.
A comparison between the results of the linear relaxation in Table 2 and the results of the exact methods in Table 3 shows that the DMM obtained lower bounds that are very close to the optimum value of the objective function, where the linear relaxation did not reach the optimum value of the problem in only two instances.
Regarding the metaheuristics, in general, the best results were obtained by the SA, but it was able to solve only two of the large instances optimally.
Table 4 presents the computational times of the OMM and DMM (including the solution time of the RMM ) exact methods and the computational times reported by the GA, MA and SA metaheuristics.Table 4 shows that the DMM can solve the WRSP more efficiently than the OMM.For example, in the instances with 75 wells, the OMM needed 109.9s on average (considering the 5 instances of 75 wells), while the DMM needed 0.4 s on average; that is, a remarkable reduction of the consumed time.In the instances with 25 and 50 wells, the DMM also notably reduced the time consumed compared to that of the OMM.In the large instances with 100 and 125 wells, the DMM needed 1.3 s and 2.3 s on average, respectively.The DMM required a computational time of less than 7 s to solve each instance, requiring 0.8 s on average.The proposed model has a lower mean time than that of the OMM and is the most efficient to solve the WRSP according to the computational results.
Regarding the computational times reported by the metaheuristics, these cannot be compared directly with of the DMM because they were run in computers with different characteristics.However, from the point of view of the computational time, taking the 15.7 s consumed by the SA in the largest instance (125-10) as a reference, the DMM can be considered effective, with the justification that, in general, the metaheuristics should perform several replications to ensure the robustness of the obtained solution, in addition to the time spent with previous experiments required to adjust the execution parameters.

CONCLUSIONS AND FUTURE WORKS
In this study, the Workover Rig Scheduling Problem (WRSP) is addressed with the objective of minimizing the oil production loss.The WRSP is one of the most challenging problems in the oil and gas industry due to the high costs of using rigs and the high production losses caused by inactive wells waiting for maintenance services.Because it is an NP-hard problem, the difficulty in solving the WRSP has resulted in various heuristics and metaheuristics in the literature.
Although the heuristics and metaheuristics can obtain approximate solutions, they are not capable of obtaining optimal solutions for large instances (e.g., large numbers of wells or rigs).Thus, to efficiently solve the WRSP, a 0-1 integer linear programming model was proposed.This mathematical model (DMM) extends the mathematical model proposed by Costa & Ferreira Filho (2004) and proved to be more efficient in the computational experiments that were carried out.
The DMM was tested in instances based on real cases in Brazil and compared to various methods in the literature.The computational results showed that the DMM was able to solve all of the instances considered, including the large instances, and this model obtained optimum solutions, which were not known until now.Regarding the computational time, the DMM solved all of the instances in short times.Thus, the proposed model showed efficient performance in comparison to the other methods proposed to solve the WRSP.
The computational results corroborate the usefulness of the DMM as computational tool to solve real problems, with various numbers of wells and different rig fleet sizes for an established planning horizon.Consequently, DMM can be used by companies dedicated to planning interventions in wells or other analogous services, carrying out the planning quickly and reliably, reducing errors in the service schedule and improving the decision making capacity.
In future works, it is desirable to extend the proposed formulation to address the Workover Rig Routing Problem and the Rig Fleet Sizing Problem.Furthermore, due to the variations in the intervention times of the rigs and other uncertainties in the operations, it is desirable to apply techniques that are able to address the uncertain characteristics of the problem of intervention in wells.
Another important point is the generation of instances, given that there is only one group of instances available in the literature that were randomly built from an oil production field.Therefore, it is necessary to generate a new group of instances to address the problem of intervention in wells.
Finally, it would be important to test the formulations in offshore fields, which are generally more complex than onshore fields.
, Dias Filho & Ribeiro (2009) proposed a Bubble Swap (BS) heuristic.This heuristic is constructed in two stages.In the first stage, a feasible solution is generated through the heuristic proposed by Costa & Ferreira Filho (2004), and the second stage consists of performing a swap of wells in the same rig and between different rigs.Douro & Lorenzoni (2009) presented a GA with a 2-opt local search technique.The solutions (chromosomes) are represented by a well vector that is distributed to the rigs.The single point was used as the crossover operator, and the simple inversion mutation operator was used as the mutation operator.Pacheco, Ribeiro & Mauri (2010) presented a GRASP with Path-Relinking (PR) as an intensification strategy, exploring the paths that connect the elite solutions to search for better solutions.Pacheco (2011) presented a Memetic Algorithm (MA) metaheuristic where a strategy based on the Natural Order is applied on the chromosomes.Ribeiro, Mauri & Lorena (2011) applied a Simulated Annealing (SA) with three different moves to compose the neighborhood structure.The instances generated by Costa (2005) for this problem are widely used in the literature (Costa & Ferreira Filho, 2005; Alves & Ferreira Filho, 2006; Oliveira et al., 2007; Pacheco, Dias Filho & Ribeiro, 2009; Douro & Lorenzoni, 2009; Pacheco, Ribeiro & Mauri, 2010; Pacheco, 2011; Ribeiro, Mauri & Lorena, 2011

Figure 1 -
Figure 1 -An example of a representation of decision variables.

Table 1 -
Comparison of the total number of constraints and variables in the OMM, RMM and DMM.

Table 2 -
Results of the linear relaxation applied to the OMM and DMM.

Table 3 -
Numerical results of the different methods that were employed.
a Computer used Pentium IV 2.0 GHz processor with 480 MB of RAM.b Computer used Pentium Core i3 2.13 GHz processor with 4 GB of RAM.c Computer used AMD Athlon 64 3500 2.2 GHz processor with 1 GB of RAM.