Flow Shop Providing Frequency Regulation Service in Electricity Market

: Electricity cost is one of main production costs for ﬂow shops. Providing frequency regulation services can help electric loads reduce their electricity costs. Previous studies mostly focus on automatic generation control (AGC) strategies for other types of electric loads, such as air conditioners, EVs or battery storage. In this paper, we ﬁnd ﬂow shops competent to follow regulation signals and avoid interrupts of processing with the help of scheduling optimization. This ﬁnding may be an aid for ﬂow shops by availing regulation services to the market and making a proﬁt. Hence, we propose an AGC strategy for optimizing ﬂow shop scheduling, without a ﬀ ecting the operation. To formulate the bidding strategy for ﬂow shops in regulation market, we considered as many relevant factors as possible, including the regulation performance and yield of ﬂow shops, constraints on load power, regulation reserve capacity and machines operation, inventory of each semi-ﬁnished product, AGC strategy—as well as the coupling between the bids in both energy market and regulation market. Our case study shows the potential of the methodology proposed in this paper to cut down the electric cost of ﬂow shops and supplies of performance-qualiﬁed frequency regulation service.


Introduction
Reducing the energy cost of production is significant for the flow shops with a lot of energy consumption. For example, the electricity cost accounts for more than 40% of the total production cost of the electrolytic aluminum industry [1]. Flow shop scheduling optimization can help factories save energy consumption [2]. In electricity market, flow shop scheduling plays an important role in reducing the electricity cost by optimizing power use at different periods [3] and providing demand response service [4]. The development of Industry 4.0 [5] makes it more apparent. On the one hand, The Internet of Things (IOT) and the 5th generation of mobile telecommunications technology (5G) help realize a more flexible scheduling and industrial process control of flow shops. On the other hand, big data, machine learning and cloud storage favor manufacturers to evaluate some complex and vague factors, like carbon emission and product performance. However, most of these technologies are not yet universal [6]. They, nevertheless, are worth exploiting for more applications [7], such as industrial pollution control, carbon emission reducing and waste recycling [8,9]. For manufacturing industry in particular, those Industry 4.0 technologies can be instrumental for the operation of power system by some new models of energy management [10].

Demand-Side Electric Users Providing AGC Service
In order to mitigate fossil energy crisis, environmental pollution and climate deterioration caused by fossil energy, renewable energy generators have been increasingly integrated into power grid in recent years. However, the uncertainty and the intermittence of renewable energy generation have led to increased uncertainty of power flow. Hence, power systems have an increased demand for the quantity and performance of the frequency regulation resources [11,12].
For thermostatically controlled loads (TCLs), such as heating, ventilation and air conditioners, a control strategy is proposed in [13]. It allows the loads to follow regulation signals within the expected temperature for comfort. In [14], a progressive load control strategy comes up for residential air conditioners loads implementing primary and secondary frequency regulation efficiently. Proper control strategy has been proven to organize a large population of TCLs for the provision of a frequency reserve in [15].
For electric vehicles (EVs), a vehicle-to-grid control strategy to achieve frequency regulation service within expected SOC levels is proposed in [16]. Ref. [17] proposes a state space model for EVs providing frequency regulation with high accuracy and computational efficiency but a low real-time communication requirement. The economic benefits of EVs providing frequency regulation is also proved in [18]. Other types of strategy, such as new controllers and game theoretic approaches, can also help EVs provide better regulation services in performance and economic benefits [19,20]. Moreover, those strategies or approaches barely affect the comfort and operation of users [21].
Above all, although the electricity users have some difficulty in providing AGC service, frequency regulation benefits them a lot. Meanwhile, many control strategies or operational approaches mentioned can solve the difficulty to some extent.
As for industrial electric users, Research [22][23][24][25] has proved industrial electric users able to adjust power and implement demand response events, by controlling the power, operating status and waiting time of the electric equipment. However, the ability of adjusting power remains to be further exploited and used for frequency regulation. Traditionally, users involved in a demand response event need to curtail their load over a long period like one or two hours, which, however, may lead to a decrease in the production of users. While providing frequency regulation service in a proper way can avoid load curtailment and production decrease in a perspective of relatively long period. Because the response power of frequency regulation fluctuates around zero and the average value of response power is close to zero.
In summary, the supply of frequency regulation service by the loads in electricity market can mitigate the shortage of frequency-regulation resources and bring them additional profit. However, although many loads can provide frequency regulation service, only a few studies focus on the potential of industrial loads to supply the service, especially for flow shops. Also, the method, possibility and ability of frequency-regulation service provided by flow shops should be studied.

Flow Shop Scheduling Optimization
Flow shop scheduling optimization can help manufacturers manage production process, so as to achieve various objectives. The scheduling goal is to minimize makespan and total tardiness in [26,27]. Besides, in [28], idle time for total machine, total device availability, total machine setup times and total job blocking time are also evaluation indexes of the scheduling result. Production cost is considered as an available evaluation index in [29].
Meanwhile, the way to improve solving algorithm is intensively studied recently [30][31][32][33][34]. In the literature, new algorithms or methods are proposed for more optimal scheduling results or more efficient computation.
Above all, most of researches emphasizes on minimizing makespan, responding to emergency or improving solving algorithm. However, they may not be prior for an enterprise with enough stock or well-supplied product in the market. In this case, production cost, like energy consumption, will be one of important evaluation index for flow shop scheduling. Meanwhile, providing ancillary service in electricity market, such as frequency regulation, will be a way to drop down energy cost.
To provide regulation service, the scheduling of flow shops is intended to follow frequency regulation signals (AGC signals) as accurately as possible, which is rarely studied in literature. Namely, the scheduling optimization should adjust the power of flow shops to an expected response power without interrupting any machine processing. Nonetheless, some doubts rise about whether so frequent adjustments will cause frequent switches of machines and the interrupts of processing in the flow shops, thereby affecting the quality of products; and whether flow shops are able to follow regulation signals accurately. In fact, we find flow shops capable of following regulation signals and avoiding processing interrupts with proper scheduling strategy. This capability allows flow shops to offer regulation service to the markets and make additional profit.

Flow Shops in Electricity Market
In frequency regulation market, the potential of flow shops for frequency regulation should be evaluated in order to decide whether to participate in a regulation market or determine their bids in the markets. Some studies have analyzed the potential of industries for demand response [35][36][37][38]. The feasibility of industrial users participating in a demand response program and associated profit were studied [35,36]. In [37], researchers proposed an energy management system of material flow in a refinery and corresponding demand response strategy. A flow shop scheduling optimization model to help assembly enterprises offer demand response service is proposed in [38] for minimizing electricity cost of assembly enterprises. However, some variables and constraints vital for flow shops in regulation market have never been studied, such as regulation performance, constraints on load power and regulation-reserve capacity.
The modeling of the variables and constraints mentioned above should consider many factors, such as the production quantity of a flow shop, constraints for machines' operation, inventory of each semi-finished product, AGC strategy, the coupling between the bids in both energy market and regulation market. Some of the factors are mentioned in [39][40][41][42][43], however, they are not sufficiently studied in the perspective of providing regulation service by flow shops.
In summary, production process of flow shops needs properly scheduling to minimize AGC response error, and the associated bid in electricity market should be optimized. In this paper, we placed focus on two respects of how a flow shop participate in the electricity market to provide AGC service.
Above all, the paper achieved following work and contribution.
(1) We formulate the AGC strategy for a flow shop to provide frequency regulation service, while flow shop is rarely studied in terms of frequency regulation previously, which focused on AGC strategies for other types of electric loads, such as air conditioners, EVs or battery storage. Flow shops are able to follow regulation signals accurately and prevent processing interrupts by an aid of the proposed scheduling optimization. This will help flow shops offer regulation service to market and make a profit. (2) To formulate the bidding strategy for flow shops participating in regulation market, we considered the regulation performance, constraints on load power and regulation reserve capacity in the optimization. Meanwhile, the production quantity of flow shops, machines operation, inventory of each semi-finished product, AGC strategy, as well as the coupling between the bids in both energy market and regulation market were all taken into account fully, while they were not sufficiently studied from the perspective of regulation service supply of flow shops.

Day-ahead Energy Market
Generators or Purchasers offer price and capacity bid before the close of day-ahead market. Then Pennsylvania-New Jersey-Maryland (PJM) market calculates the day-ahead market clearing price (DAMCP). If a purchaser offers price bid higher than DAMCP, the purchaser will buy energy successfully. The pay will be: Here, we assumed flow shops to be price-takers. They only need to offer capacity bid, and the capacity bid will be always accepted by the market.

Frequency Regulation Market
Regulation units offer price and capacity bid before the close of regulation market. Then PJM will buy enough regulation reserve capacity from lower price to higher price. Then in real-time stage, purchased reserve will response to AGC signals. After one-hour regulation, PJM starts to calculate market clearing reserve capacity price (MCRCP), market clearing regulation performance price (MCRPP) and regulation performance score (RPS). PJM owns two types of AGC signals, RegA and RegD, with different MCRPPs. For the sake of readability, regulation capacity price (RCP) was used here to replace MCRCP and MCRPP, as expressed below. The revenue of a unit will be: Furthermore, flow shops were presumed price-takers in regulation market. They have only to offer capacity bid, and the capacity bid will be always accepted by the market.

AGC Rules
AGC signal denotes the ratio of expected response power (ERP) to regulation reserve capacity of a generating unit. It is a continual variable from 0 to 1. Equations below present the expected response power and expected total power (ETP) of a generating unit.

Settlement Mechanism of Regulation Performance Score
In real-time stage, PJM broadcasts AGC signals every two seconds to regulation units, and the power of the units is sampled every ten seconds for calculating RPSs. PJM calculate RPSs every five minutes. The final hourly RPS is the average of the 12 scores calculated every five minutes.
The RPS consists of three kinds of scores: the precision score S P , correlation score S C and delay score S D . S P is the average relative error between the expected response power and practical response power, as expressed in Formula (1). S C is the maximum value of the correlation coefficient σ(d) between the regulation signals sampled-series and the response power sampled-series, as expressed in Formulas (2) and (3). Assuming that the time-series of the regulation signals ranged from 0 to 300 s, then the time-series of the response power used for calculating fluctuated from d to 300 + d s. Hence there was a value d max ranging from 0 to 300 s, the input of maximal σ(d), as expressed in Formula (4). Then d max was introduced in the function of delay score S D , as expressed in Formula (5). Finally, the regulation performance score of the 5-min time series was the weighted average of the three scores, as expressed in Formula (6).
In Formulas (1) and (2), y(t) is RTRP (MW) sampled at second t. x(t) is the regulation signal sampled at second t. R reg h is the regulation reserve capacity bid at hour h (MW). x h is the rolling average of the absolute value of the regulation signals sampled during recent one hour. N is the number of samples during each five-minute period, which was 30 in total since response power was sampled every ten seconds. y and x are the average response power (MW) and response signals sampled at the five minutes. In Formula (6), A, B and C are the weighted average coefficients of the response performance score K, which are 1/3.

The Bidding Optimization for Flow Shop in Electrical Markets
The AGC strategies of flow shops, namely the scheduling of flow shops, are optimized according to their bids in electricity market. Hence, we introduced bidding optimization in this section, and the AGC strategy is given next. To the best of our knowledge, it is the first paper to propose optimal bidding model for flow shop in energy market and regulation market, given the ability constraint of flow shop.

Objective Function
We assume flow shops are price takers in the day-ahead energy market and regulation market. Hence, the flow shop only needs to decide the bids, the energy purchased in the day-ahead spot market and the regulation reserve capacity sold in the regulation market, respectively. The factory is supposed to work from 8:00 a.m. to 4:00 p.m. Its objective is to minimize the cost of the flow shop in the two markets, as expressed in Formula (7).
The cost of a flow shop consists of two parts. One was the cost of electricity purchased in the day-ahead energy market, as expressed in the first term of Formula (1); the other is the revenue of regulation, as expressed in the second term of formula (1). λ da h and λ

Energy Bid
Limited by the production capacity, the power of a flow shop is smaller than the value expressed in Formulas (8)- (10).
P max denotes the maximum average power (MW) of the flow shop in one hour, depending on the production capacity. P on i and P off i denote the rated power (MW) of production machine i in the processing status and the standby status, respectively. M is the number of production machines in the flow shop. Yielding per unit product consumes β i workpieces produced by machine i. M on i is the processing time (second) of machine i for per unit of semi-finished product i. N m is maximum production of the flow shop in one hour.
Formula (10) is applied to compute the maximum production. According to Formulas (9) and (10), when there is a machine keeping in the processing status all the hour, the flow shop is unable to produce more product, and the energy consumption reaches to the maximum power of the hour.

Production Demand
The daily energy purchased in day-ahead market should meet the daily production demand, as expressed in Formula (11).
N D is the number of daily scheduled production of the flow shop.

Regulation Reserve Capacity
The power bids in the energy market and the reserve capacity of regulation are subject to the following inequalities, according to PJM's rules on regulation reserve.

Regulation Performance Score
The regulation performance index/score of responsive units should be higher than the threshold value according to the PJM rules of the regulation market. Otherwise, it is unqualified and not allowed to participate in regulation market. Therefore, the regulation performance score of the flow shop should be subject to the inequality as expressed in Formula (14).
K min is the threshold of regulation performance scores.

The AGC Strategy of Flow Shops
The AGC strategy of flow shops is to adjust the power load by controlling the operation status of productive machines as a response to the AGC signals. Flow shop scheduling optimization refers to a method to optimize the operation status of machines. Both share same decision variables. Hence, the paper proposes a flow shop scheduling with the objective to follow AGC signals. The decision variables consist of the digital command to shut up or down machines, so as to adjust the power of machines, as presented in Formula (15).
where, P i,t is the real-time power of production machine i at second t (MW); m i,t is the status of production machine i at second t, a binary variable that is equal to 1 if the machine is in the processing status and 0 in the standby status. The transition between processing status and standby status could be neglected in the automated flow shop since the transition takes a much shorter time than the processing.

Objective Function
The objective of the scheduling optimization for AGC strategy is to minimize the absolute value of the error between expected power and real-time power of the flow shop, as expressed in Formula (16). consist of the digital command to shut up or down machines, so as to adjust the power of machines, as presented in formula (15).
Where, P i,t is the real-time power of production machine i at second t (MW); m i,t is the status of production machine i at second t, a binary variable that is equal to 1 if the machine is in the processing status and 0 in the standby status. The transition between processing status and standby status could be neglected in the automated flow shop since the transition takes a much shorter time than the processing.

Objective Function
The objective of the scheduling optimization for AGC strategy is to minimize the absolute value of the error between expected power and real-time power of the flow shop, as expressed in formula (16).

Constraints
If a machine starts processing, its operating status must be maintained until the completion of processing. The constraint can be expressed by formula (17). This is similar to the minimum startup time constraint of thermal units.
Where, T i,t-i on is the accumulated working time (second) of machine i at time t-1.
The real-time inventory of semi-finished product in the flow shop can be described by formulas (18)- (20).
, 1 , off , Where, ∆m i,t on and ∆m i,t off are binary variables denoting the status change of machine i at t th second; ∆m i,t on is equal to 1 when the machine starts processing at time t, and 0 otherwise. ∆m i,t off is equal to 1 In Equation (16)

Constraints
If a machine starts processing, its operating status must be maintained until the completion of processing. The constraint can be expressed by Formula (17). This is similar to the minimum startup time constraint of thermal units.
where, T on i,t−i is the accumulated working time (second) of machine i at time t − 1. The real-time inventory of semi-finished product in the flow shop can be described by Formulas (18)- (20).
where, ∆m on i,t and ∆m off i,t are binary variables denoting the status change of machine i at t th second; ∆m on i,t is equal to 1 when the machine starts processing at time t, and 0 otherwise. ∆m off i,t is equal to 1 when the machine finishes processing at time t, and 0 otherwise. S i,t is the real-time inventory of the semi-finished product produced by machine i and stored in the flow shop at the end of time t. In Formula (20), S i,t consists of three terms: the inventory S i,t−1 stored in the flow shop at the previous moment time t − 1, the increment ∆m off i,t and the consumption at time t, namely the right term of the formula. D i represents the index set of all the downstream machines of machine i. Since limited by the inventory capacity of semi-finished products and finished products in the flow shop, S i,t is limited by the inventory capacity of the flow shop, as expressed in Formula (21).
where, S max i denotes the inventory capacity of the semi-finished product or the workpiece produced by machine i in the flow shop.

The Modeling of Regulation Performance Score
According to Formulas (1)- (6) and (16), the regulation performance score of the flow shop is related to the variables P da h and R reg h . In order to simplify the optimization, the method proposed in [44] was adopted for modeling regulation performance score in PJM, as expressed in Formula (22).
where, α p , α r and α c denote the coefficients of the linear regression function.

Numerical Setting
In this paper, we are curious about whether a simplest flow shop is able to flexibly adjust power, follow AGC signals and keep a qualified RPS. Hence, in this example, we suppose that there is an enterprise having only one flow shop, and the flow shop harbors six production processes. The structure of a flow shop is shown in Figure 1

The Modeling of Regulation Performance Score
According to formulas (1)- (6) and (16), the regulation performance score of the flow shop is related to the variables P h da and R h reg . In order to simplify the optimization, the method proposed in [44] was adopted for modeling regulation performance score in PJM, as expressed in formula (22).
Where, α p , α r and α c denote the coefficients of the linear regression function.

Numerical Setting
In this paper, we are curious about whether a simplest flow shop is able to flexibly adjust power, follow AGC signals and keep a qualified RPS. Hence, in this example, we suppose that there is an enterprise having only one flow shop, an The parameters of the machines are presented in Table 1. The forecasted market prices and AGC regulation signals are derived from the PJM data of June 1, 2018.  The parameters of the machines are presented in Table 1. The forecasted market prices and AGC regulation signals are derived from the PJM data of 1 June 2018. Figure 2 shows the relationship between the scheduling optimization and bidding optimization of a flow shop. First, the flow shop is required to solve bidding strategy according to Formulas (7)- (14) and (22). However, the coefficients of the Formula (22) come from linear regression fitting, whose sampled-data partly derives from the solution of the flow shop scheduling optimization, as expressed by the Link Line 1 in Figure 2. Then the flow shop solves the real-time scheduling strategy in light of the optimal bidding strategy and real-time regulation signals, as illustrated by Link Line 2 in Figure 2. the optimal bidding strategy and real-time regulation signals, as illustrated by Link Line 2 in Figure  2.

Start
Solving the optimization problem as presented in formulas (1)-(9) and (23).  Figure 2. The relationship between the flow shop scheduling optimization and the bidding optimization for flow shops participating in electricity market.

Regulation Effect of Flow Shops
To evaluate the regulation effect of flow shops, we involved numerical settings as follows. The bid in the day-ahead energy market P h da is 200 kW; the bid in the regulation market R h reg is 20 kW; the initial inventory of each workpiece in the flow shop is half of their capacity; each machine is in standby status at the beginning of the regulation; and the scheduling optimization is performed according to received regulation signals every two second. The results of real-time flow shop scheduling are presented in Figure 3. Blue lines show the operating status of each machines within 1 hour. Zero means the standby status of machine, whereas 1 denotes the processing status of machine. Red lines show the number of the workpiece produced by each machine in inventory. The comparison between actual and expected response power is reported in Figure 4. Red curve represents the expected response power, which derives from AGC signals and regulation reserve of the flow shop. Blue curve is the actual real-time AGC response power. From the figures, we found the timing when the flow shop had difficulty in following AGC signals from those curves, and the error between expected and actual AGC response power. Analysis and discussion are presented below. Give that most research [26][27][28][29][30][31][32][33][34] defines both optimizations to be nonlinear programming and addresses them by heuristic algorithms, we also adopted genetic algorithm to solve them.

Regulation Effect of Flow Shops
To evaluate the regulation effect of flow shops, we involved numerical settings as follows. The bid in the day-ahead energy market P da h is 200 kW; the bid in the regulation market R reg h is 20 kW; the initial inventory of each workpiece in the flow shop is half of their capacity; each machine is in standby status at the beginning of the regulation; and the scheduling optimization is performed according to received regulation signals every two second.
The results of real-time flow shop scheduling are presented in Figure 3. Blue lines show the operating status of each machines within 1 h. Zero means the standby status of machine, whereas 1 denotes the processing status of machine. Red lines show the number of the workpiece produced by each machine in inventory. The comparison between actual and expected response power is reported in Figure 4. Red curve represents the expected response power, which derives from AGC signals and regulation reserve of the flow shop. Blue curve is the actual real-time AGC response power. From the figures, we found the timing when the flow shop had difficulty in following AGC signals from those curves, and the error between expected and actual AGC response power. Analysis and discussion are presented below.   It can be observed from Figures 3 and 4 that the inventory capacity of each workpiece and the processing time of each machine are the key variables relating to the regulation performance and the AGC control strategy of flow shops.
On the one hand, the inventory capacity of each workpiece is a key variable relating to the capability of flow shops to adjust power. As shown in Figure 3, machines are kept unchanged during the first 100 seconds to follow AGC regulation signals. From Figures 3 and 4, the flow shop follows the regulation signals accurately, and the response power is close to the expected power since the inventory capacity of each workpiece remain sufficient.
From 100 seconds to 700 seconds, the inventory of products produced by M2 approaches to the capacity. Hence, M1 and M5 stop processing and keep in standby status, and M3 and M4 start processing. Thus, the response power of the flow shop keeps close to the expected power, and the semi-finished products produced by M2 are available for consumption. In a word, the scheduling    It can be observed from Figures 3 and 4 that the inventory capacity of each workpiece and the processing time of each machine are the key variables relating to the regulation performance and the AGC control strategy of flow shops.
On the one hand, the inventory capacity of each workpiece is a key variable relating to the capability of flow shops to adjust power. As shown in Figure 3, machines are kept unchanged during the first 100 seconds to follow AGC regulation signals. From Figures 3 and 4, the flow shop follows the regulation signals accurately, and the response power is close to the expected power since the inventory capacity of each workpiece remain sufficient.
From 100 seconds to 700 seconds, the inventory of products produced by M2 approaches to the capacity. Hence, M1 and M5 stop processing and keep in standby status, and M3 and M4 start processing. Thus, the response power of the flow shop keeps close to the expected power, and the semi-finished products produced by M2 are available for consumption. In a word, the scheduling from 100 seconds to 700 seconds is not the most expected, whereas the ideal scheduling occurs within It can be observed from Figures 3 and 4 that the inventory capacity of each workpiece and the processing time of each machine are the key variables relating to the regulation performance and the AGC control strategy of flow shops.
On the one hand, the inventory capacity of each workpiece is a key variable relating to the capability of flow shops to adjust power. As shown in Figure 3, machines are kept unchanged during the first 100 s to follow AGC regulation signals. From Figures 3 and 4, the flow shop follows the regulation signals accurately, and the response power is close to the expected power since the inventory capacity of each workpiece remain sufficient.
From 100 s to 700 s, the inventory of products produced by M2 approaches to the capacity. Hence, M1 and M5 stop processing and keep in standby status, and M3 and M4 start processing. Thus, the response power of the flow shop keeps close to the expected power, and the semi-finished products produced by M2 are available for consumption. In a word, the scheduling from 100 s to 700 s is not the most expected, whereas the ideal scheduling occurs within the first 100 s. Besides, this less-expected scheduling is limited by the inventory capacity of the product produced by M2. That is to say, the inventory capacity limits the regulation performance of a flow shop.
Between 1200 s and 2400 s, the inventory of most semi-finished products moves toward the capacity of such as M1-, M2-and M5-made products. These machines can start up and shut down frequently to ensure that the AGC regulation signals are followed as accurately as possible, without prejudice to the operation of the flow shop.
Compared with the regulation performances in the first 1200 s and during the period from 2400 s to 3600 s, the scores/indexes of that from 1200 to 2400 s is significantly lower since the inventory of most machines reaches to the capacity.
On the other hand, the processing time of machines limits flow shops to adjust power frequently. Because the machines are not allowed to change their operating status when in processing for the quality of products. Therefore, flow shops are unable to response to regulation signals quickly when regulation signals change rapidly if the processing lasts long. For example, the error between the expected power and real-time power is considerable when the flow shop engage in gradient transition around from 600 s to 1000 s and around from 1700 s to 2000 s, although the inventory of most products is kept enough.
The regulation performance score is still qualified even in worst conditions. As can be observed in Figure 4, the real-time response power of the flow shop is close to the expected response power in general. The regulation performance score reaches 0.7618, a qualified score for flow shops to participate in PJM regulation market.
The result illustrates the ability of flow shops to offer frequency regulation service as a demandresponse resource with the help of reasonable AGC strategy and scheduling optimization. In this case, the system with only a flow shop and six ma-chines is too small for a real factory. The more flow shops and machines are available, the more precisely and quickly a factory can adjust its power to follow regulation signals, and the better the regulation performance will be.

Bidding Strategy in Energy Market and Regulation Market
The coefficients α p , α r and α c of regulation performance score function are derived by the method proposed in [44]. Their values are 0.00082, −0.00022 and 0.74646 in the flow shop, respectively. The relative error of regression fitting is 3.44%, which is precise enough for practical optimization of a bidding strategy.
The daily production of the factory is 1600. As presented in Figure 5, the market prices forecasted in regulation market consist of capacity prices and performance prices for readability. The bid of the factory in the day-ahead energy market and regulation market are also available in Figure 5. The electricity cost and revenue in regulation market are shown in Figure 6.
As shown in Figure 6, the revenue of the flow shop in regulation market is considerable, sometimes it is even higher than the electricity cost. This difference enables the factory to make a profit in electricity market. In another word, the provision of regulation ancillary service reduces the overall cost of a factory. At 10 a.m. and 1 p.m., the factory can produce without paying electricity cost by providing frequency regulation ancillary service since the bid in day-ahead market and regulation market are the same, which is explained later, and the prices in both markets are close. At 11 a.m. and 2 p.m., the revenue even exceeds its electricity cost thanks to the high price of the regulation market, which brings the factory extra profit. The bid in regulation market is a decisive variable of electricity cost when the price of regulation market is high enough. As shown in Figure 5, the energy bid in the day-ahead market is equal to the capacity bid of reserve in regulation market at all the working hours of the day. This is because the factory will bid as much as possible in regulation market for more revenue, however, the capacity bid of regulation reserve is limited by its energy bid, according to the formulas (12)- (13). On the one hand, the energy bid of the factory relates to not only the prices of the day-ahead energy market but also the bid in the regulation market. It keeps as equal as possible to 0.5 ∑ P i on M i , which is about 200 kW in this case. Thus, the factory is enabled to provide as much the regulation-up reserve as possible in the regulation market. On the other hand, subjected to formula (13), the capacity bid of the factory keeps as much as possible hence the same as the energy bid in the day-ahead market. Thus, the factory can only provide regulation-down reserve to its maximum. Overall, compared with prices in dayahead market, the prices in regulation market are thought far more influential for the optimal bidding decisions in this case. Table 2 presents a comparison between the results that the flow shop participates in DAM & RM and DAM alone. It can be found that offering regulation service does not affect the energy cost of the flow shop because both produce the same product in the day. The number of semi-finished products The bid in regulation market is a decisive variable of electricity cost when the price of regulation market is high enough. As shown in Figure 5, the energy bid in the day-ahead market is equal to the capacity bid of reserve in regulation market at all the working hours of the day. This is because the factory will bid as much as possible in regulation market for more revenue, however, the capacity bid of regulation reserve is limited by its energy bid, according to the formulas (12)- (13). On the one hand, the energy bid of the factory relates to not only the prices of the day-ahead energy market but also the bid in the regulation market. It keeps as equal as possible to 0.5 ∑ P i on M i , which is about 200 kW in this case. Thus, the factory is enabled to provide as much the regulation-up reserve as possible in the regulation market. On the other hand, subjected to formula (13), the capacity bid of the factory keeps as much as possible hence the same as the energy bid in the day-ahead market. Thus, the factory can only provide regulation-down reserve to its maximum. Overall, compared with prices in dayahead market, the prices in regulation market are thought far more influential for the optimal bidding decisions in this case. Table 2 presents a comparison between the results that the flow shop participates in DAM & RM and DAM alone. It can be found that offering regulation service does not affect the energy cost of the flow shop because both produce the same product in the day. The number of semi-finished products The bid in regulation market is a decisive variable of electricity cost when the price of regulation market is high enough. As shown in Figure 5, the energy bid in the day-ahead market is equal to the capacity bid of reserve in regulation market at all the working hours of the day. This is because the factory will bid as much as possible in regulation market for more revenue, however, the capacity bid of regulation reserve is limited by its energy bid, according to the Formulas (12) and (13). On the one hand, the energy bid of the factory relates to not only the prices of the day-ahead energy market but also the bid in the regulation market. It keeps as equal as possible to 0.5 M i P on i , which is about 200 kW in this case. Thus, the factory is enabled to provide as much the regulation-up reserve as possible in the regulation market. On the other hand, subjected to formula (13), the capacity bid of the factory keeps as much as possible hence the same as the energy bid in the day-ahead market. Thus, the factory can only provide regulation-down reserve to its maximum. Overall, compared with prices in day-ahead market, the prices in regulation market are thought far more influential for the optimal bidding decisions in this case. Table 2 presents a comparison between the results that the flow shop participates in DAM & RM and DAM alone. It can be found that offering regulation service does not affect the energy cost of the flow shop because both produce the same product in the day. The number of semi-finished products may be the reason of the slight difference in energy cost. However, if the regulation price is extremely high at any one hour, offering regulation service can bring the flow shop a so considerable revenue as to even cover its energy cost of a day.

Conclusions
This paper formulated a flow shop scheduling optimization for AGC and a flow shop bidding optimization for the participation of flow shops in electricity market and frequency regulation market, without compromise of their production. The simulation results show:

1.
With the help of flow shop scheduling optimization for AGC, flow shops can provide frequency regulation ancillary service to power system, with a service performance qualified in PJM.

2.
To avoid prejudice to product quality, the processing time of machines in a flow shop should be accounted in the AGC. Meanwhile, the inventory and the capacity of a flow shop should be also taken in account; otherwise, the flow shop will overestimate its regulation reserve capacity and performance, which will lead it to punishment or reduction in the regulation revenue.

3.
Providing frequency regulation service can drive flow shops to reduce its cost of energy consumption in electricity market. When the price in the regulation market is higher than that in the day-ahead energy market, flow shops can embark on a production without electricity cost and even making a profit.