Integration of Joint Power-Heat Flexibility of Oil Refinery Industries to Uncertain Energy Markets

This paper proposes a novel approach to optimize the main energy consumptions of heavy oil refining industries (ORI) in response to electricity price uncertainties. The whole industrial sub-processes of the ORI are modeled mathematically to investigate the joint power-heat flexibility potentials of the industry. To model the refinery processes, an input/output flow-based model is proposed for five main refining units. Moreover, the role of storage tanks capacity in the power system flexibility is investigated. To hedge against the electricity price uncertainty, an uncertain bound for the wholesale electricity price is addressed. To optimize the industrial processes, a dual robust mixed-integer quadratic program (R-MIQP) is adopted; therefore, the ORI’s operational strategies are determined under the worst-case realization of the electricity price uncertainty. Finally, the suggested approach is implemented in the south-west sector of the Iran Energy Market that suffers from a lack of electricity in hot days of summer. The simulation results confirm that the proposed framework ensures industrial demand flexibility to the external grids when a power shortage occurs. The approach not only provides demand flexibility to the power system, but also minimizes the operation cost of the industries.


Motivation and Problem Description
The Iran Energy Market (IEM) has been experiencing two major challenges recently. First of all, the Iran Power Grid (IPG) faces high peak demands during hot days of summer when the electricity demand of the air conditioning systems increases dramatically [1]. Increasing the generation and transmission capacities of the electricity network is a controversial decision. The reason is that the electricity network has a high unused non-seasonal capacity in summer. Therefore, it cannot be an economic decision to make such a huge investment. To overcome the challenge, there are some flexibility potentials among the heavy industries that can provide demand flexibility to the electricity/gas network [2]. Since Iran is now beginning to emerge as the major refiner in the Middle East in terms of refining capacity, the electricity and heat generation of Iran's Oil Refinery Industries (ORI) can provide a golden opportunity to hedge against the energy shortage at peak hours.
consumes a large amount of energy, i.e., electricity and heat, and steam for the refinery processes. Conventionally, the ORI is equipped with self-generation facilities, e.g., cogeneration units, to supply the industrial processes with electricity and steam. Producing/consuming the electricity and heat in refinery processes simultaneously, the energy management of the ORI is a complex problem. Therefore, barely comprehensive research studies are conducted, especially in the field of electrical energy management.
In the literature on the ORI, most research studies were focused on two issues, as follows: (1) Optimization of oil and gas productions.
(2) Energy efficiency measures in the ORI equipment.
First of all, in 2010, a research study was conducted in Gabriel Passos Refinery of Brazil to suggest additional investments, to expand its current production scheme [4]. Later, in 2011, a short-term scheduling problem of crude oil operations was provided to overcome the crude oil residency time constraint [5]. In 2012, a conceptual framework was addressed to predict the fouling rate in an industrial crude oil pre-heater using the computational fluid dynamic technique [6]. In 2013, four heat supply alternatives were studied to investigate the role of utilizing excess heat on the energy cost of the ORI [7]. In 2014, a comprehensive study was done in Mexico to reschedule the industrial equipment of the ORI. The main aims were to optimize the operation cost and improve power quality [8]. In 2015, a multi-period optimizing model was suggested to schedule a fuel gas system within refining processes. The main contribution of the study was to model the pipeline system which was usually ignored in the previous studies [9]. In 2016, paper [10] suggested three integrated oil shale refinery processes to turn losses of the conventional oil shale process into profits at the situation of low oil prices. In 2017, a research study investigated the possibility of operating the thermal desalination plants by waste gases. This paper studied the use of waste gas that emerged from oil refineries rather than burning in the air [11]. In 2018, a novel method for real-time data validation was developed in the ORI using sensor data from the power and petrochemical plants of refining processes [12]. Finally, an energy recovery solution is offered for the pump-as-turbine technology applied in the ORI in 2019 [13].
As the literature reveals, the main concentration of the previous studies is on the optimization of ORI productions and equipment. In this way, very limited studies were focused on the energy management of the ORI to integrate the refining demand flexibility to external networks.
Based on the abovementioned facts, to the best of our knowledge, only four research studies were conducted in the area of energy management of the ORI. First of all, paper [14] presented a generalized formulation to determine the optimal operating strategy of industrial cogeneration schemes in terms of electricity and heat. The main contribution of this study was that the suggested approach addressed the grid connection to provide the demand flexibility to any kind of industry. Later, a prominent study was done to determine the flexibility potentials of the ORI among different refining processes [15]. In this study, a flow diagram was presented for Kwinana Refinery of Australia to describe what refining processes have the ability to interrupt and/or delayed start. Although this study suggested the flexibility potentials of the refining processes, the applicability of the suggested flexibilities is still a challenge due to not simulating the approach. Finally, a prominent study was conducted recently to integrate the flexibility potentials of the ORI into the external power grid [16]. It is the first time that a study has simulated the operational processes of the ORI to provide demand flexibility to the power system in response to the demand response signals. Although this paper initiates the determination of ORI flexibilities, it fails to investigate the whole flexibility potentials among the refining processes. The reason is that the study models the crude distillation units only, and supposes that the other processing units are appropriately designed to continuously process the input flow of the materials. Therefore, the possible flexibilities of the non-modeled processing units remain unknown.
To sum up the literature, Figure 1 depicts a schematic diagram to show the main objectives of the previous studies in the ORI [17][18][19][20][21][22]. Furthermore, it determines the clear need for future studies. realization of the electricity price uncertainty using a robust optimization approach. All in all, the contributions of the problem can be stated as follows: (1) Proposing a mathematical framework for whole processing units of the ORI.
(2) Integrating joint heat-power flexibility of the ORI into the power system under electricity price uncertainty. (3) Investigating the role of self-generation facilities and storages on the ORI flexibility potentials. The rest of the paper is organized as follows. In Section 2, the main industrial processes of a typical ORI plant are explained. In Section 3, the industrial processes of the ORIO are modeled [19] [18] [21] [20] [22] [17] Integration of ORI Flexibility to External Grids As the flowchart reveals, the oil production optimization and the energy consumption efficiency are two main objectives of the studies in the first and last decades of the current century, respectively. Increasing the electrical demand in power systems, demand-side flexibility is a clear need for future power systems. Therefore, despite the two abovementioned objectives, the ORI processes should be optimized to provide flexibility potential to power systems. Consequently, the integration of ORI flexibility to power grids is an essential requirement for future power systems.

Paper Contributions and Organization
Based on the literature, the existing gaps in the literature can be stated as follows: (1) Mathematical frameworks of joint heat-power management in the ORI.
(2) Integration of ORI flexibility into uncertain electricity markets.
Against the background, this paper proposes a flow-based mathematical model for the whole refining processes of the ORI to investigate the demand flexibilities among the whole processing units. In this way, the mass storage tanks are modeled mathematically between different stages of the refinery processes to store the input mass for a specific time, before being transported to the next refinery unit for further processing. The storage tanks make it possible to provide industrial flexibility to an external network without needing to interrupt or delay the start for upstream processing units. Moreover, the energy consumption of the processing units is described as a function of mass flow instead of fixed consumption. This issue was ignored in previous studies, while playing a crucial role in providing demand flexibility. Besides, to schedule the demand-side flexibility of the industry in an uncertain electricity market, the energy management of the ORI is optimized under electricity price uncertainty. Finally, the robust operation strategies of the ORI are determined in the worst-case realization of the electricity price uncertainty using a robust optimization approach. All in all, the contributions of the problem can be stated as follows: (1) Proposing a mathematical framework for whole processing units of the ORI.
(2) Integrating joint heat-power flexibility of the ORI into the power system under electricity price uncertainty. (3) Investigating the role of self-generation facilities and storages on the ORI flexibility potentials.
The rest of the paper is organized as follows. In Section 2, the main industrial processes of a typical ORI plant are explained. In Section 3, the industrial processes of the ORIO are modeled mathematically. Section 4 describes the co-generation facilities of the industry. In Section 5, the mathematical formulation of an industrial boiler is illustrated. In Section 6, the framework of energy cost optimization is explained. The time framework of the industrial processes is described in Section 7. In Section 8, the solution methodology, as well as the robust optimization approach, are stated. Section 9 illustrates the integration of the demand-side flexibility to the external grid qualitatively. In Section 10, the simulation results are stated and discussed. Finally, Section 11 concludes the study.

Description of Refinery Processes
In this section, the working procedures of a typical oil refinery industry are described briefly. In this paper, the study aims to explore the possibilities of demand-side flexibility among different refining processes of an ORI. To achieve the aim, the whole refining processes are split into three main sections, as follows: (1) Section 1: Primary refining processes (PRP), including the crude distillation unit (CDU).
In the first stage, i.e., PRP, the crude oil is transferred to CDU, as a fractioning column, to be heated at about 400 • C. The crude oil, which is a combination of various hydrocarbons, is fractionated to refined products. i.e., wet gas, kerosene, naphtha, diesel, gas oil, and residual fractions. The output flows are cooler and less-volatile components, progressively condensing to liquids. The output products are entered into Section 2, i.e., SRP, for further refining.
The second stage, i.e., SRP, comprises four main refining units. First of all, the wet gas is processed in the GRU, to be split into liquefied petroleum gas (LPG), naphtha, and fuel gas. In the HTU, the kerosene and naphtha are hydrotreated to meet clean fuel requirements [23]. In the third process, the FCC converts the high-boiling, high-molecular-weight hydrocarbon fractions of crude oils, i.e., heavy oil gas, into more valuable gasoline and other products. The FCC is one of the most important refining processes used in an ORI. Finally, the VDU processes the atmospheric residue from the CDU to produce three or four waxy distillate side cuts.
In the third stage, i.e., FRP, the output productions of the SRP are further processed to be converted into marketable petroleum products. In this stage, the CRU is a chemical process used to convert petroleum refinery naphtha distilled from HTU into high-octane liquid products, e.g., gasoline. In this unit, two sub-processes including isomerization and alkylation are performed to enrich the naphtha. In the DHU, the feedstock, i.e., diesel and kerosene, is processed to reduce the Sulphur content. In this unit, the H 2 S is produced in addition to the diesel and kerosene. In this stage, DCU, LPU, APU, and visbreaking are four sub-processes which are supplied from the VDU. First of all, the DCU heats the residual oil feed up to its thermal cracking temperature in a furnace with multiple parallel passes. This unit fractionates the heavy, long-chain hydrocarbon molecules of the residual oil into fuel gas, coke, and gasoline [3]. Secondly, the LPU is the final hydrofinishing step to remove the aromatic content and wax. This unit improves the product's physicochemical properties to meet the color and stability requirements. Fuel gas, waxes, and lube oil are the marketable productions of this unit. Thirdly, the APU processes the asphalt stock to produce high-quality asphalt for roadstone coating objectives. Finally, visbreaking is a processing unit whose aim is to reduce the quantity of residual oil to increase the yield of more valuable middle distillates, e.g., gas oil. Heating in a furnace, the large hydrocarbon molecules are fractionated to small quantities of light hydrocarbons with lower viscosity.
Energies 2020, 13, 4874 5 of 25 In this section, the main refining units of the ORI is illustrated briefly. Detailed descriptions of the refining units are not within the scope of this study. The enthusiastic readers are encouraged to study book [3] for further clarifications. In the next sections, the proposed structure of the refining procedures is formulated mathematically.

Formulation of Oil Refinery Industry
In this section, the refining processes of the ORI are formulated mathematically. To achieve the aim, the PRP and SRP are formulized individually. Regarding the FRP, while the FRP's procedures depend heavily on the SRP operation, it is assumed that the FRP is operated continuously, receiving feedstock from the SRP. Therefore, the mathematical formulations and operational constraints of FRP are ignored, to avoid increasing complexity and intractability.
First of all, the mathematical structure of the PRP is modeled as follows: In this model, Equations (1) and (2) illustrate the electricity and heat consumption of CDU as a function of variable material flow, respectively. Equation (3) describes the relationship between input and output material flows of PRP and SRP. Equation (4) shows the state of storage (SoS) for the CDU. In this way, the SoS depends on the previous SoS, input, and output material flows. Equality (5) states that the input flow of the storage is supplied from CDU. Besides, Equality (6) expresses that the output flow from the storage supplies the SRP unit.
The mathematical model of PRP, i.e., Equations (1)- (6), is subject to the following constraints: Inequality (7) limits the material flow of CDU between lower and upper thresholds. While the electricity and heat consumptions of the CDU depend on the variable material flow, Equations (8) and (9) bound the variations of the electricity and heat consumptions, respectively. Inequality (10) limits the storage capacity of the CDU.
The PRP unit is comprised of one unit, i.e., CDU. The output material of the CDU supplies the SRP unit, which includes four refinery processes. Based on the abovementioned facts, the mathematical formulations of the SRP can be presented as follows: ∀i ∈ {Θ} = {GRU, HTU, FCC, VDU} : (11) Energies 2020, 13, 4874 6 of 25 In this model, Equation (11) describes the total electricity and heat consumption of SRP as the summation of demand of i refinery units. Equation (12) states the electricity and heat consumptions of i refinery units as the function of variable material flow in a matrix form. Note that [I] i×i is an identity matrix, which is the i × i square matrix with ones on the main diagonal and zeros elsewhere. Equality (13) ensures the material flow balance in the SRP units. In this way, the total input flow to the SRP must be equal to the summation of input flows to i refinery units. Equation (14) states the SoS for i units of SRP in the matrix form. In this way, the input flow of storage for subprocess i is a fraction of total material flow to the SRP. This constraint is expressed by Equation (15).
Following a similar pattern, the mathematical model of SRP, i.e., (11)- (15), must meet the following constraints: In these constraints, inequalities (16)- (19) determine the lower and upper thresholds for material flow, electricity consumption, heat demand, and storage capacity for refinery subprocesses of the SRP, respectively. Equality (20) ensures that the total production of the ORI meets the total ordered value of the consumers. This is an important constraint that guarantees the industry's production without interruption or reduction.
Finally, to give a general overview of the refinery processes of the ORI, a schematic diagram is depicted in Figure 2. The basic structure is extracted from [3]. In this figure, the material storages, which are shown in blue boxes, are added to refinery units to increase the demand flexibility of the refinery industry.

Co-Generation Units
The ORI consumes a lot of energy in terms of electricity and heat (steam). Generally, the ORIs are equipped with self-generation facilities to supply the required electricity as a stand-alone grid. In this way, the ORI has a high capacity to supply the power grid during power shortage. Therefore, the ORI can be operated in two modes, including stand-alone and grid-connected. Besides, some refining processes consume a large amount of steam. Broadly, the steam demand of the ORI is supplied by the industrial boilers. However, some parts of steam demand can be supplied by the co-generation units. As a result, power-only units should be substituted by the combined heat and power (CHP) unit. All in all, the mathematical formulations of the CHP units can be stated as follows: Equation (21) shows the cost function of CHP in terms of power and heat generations. Equation (22) illustrates the gas consumption of the CHP as a function of the power-heat generation, by considering the local gas heat value and generation efficiency. The cost function of the CHP, i.e., Equation (21), is subject to the following constraints Inequality (23) states that the upper and lower boundaries of electricity generation of the CHP unit are a function of the heat generation of the unit. In the same way, constraint (24) illustrates that the upper and lower boundaries of heat generation of the CHP are a function of the electricity generation. These constraints make the feasible operation range (FOR) of the CHP into a polygon area. The parametric FOR is depicted in Figure 3. Equations (25) and (26)

Co-Generation Units
The ORI consumes a lot of energy in terms of electricity and heat (steam). Generally, the ORIs are equipped with self-generation facilities to supply the required electricity as a stand-alone grid. In this way, the ORI has a high capacity to supply the power grid during power shortage. Therefore, the ORI can be operated in two modes, including stand-alone and grid-connected. Besides, some refining processes consume a large amount of steam. Broadly, the steam demand of the ORI is supplied by the industrial boilers. However, some parts of steam demand can be supplied by the cogeneration units. As a result, power-only units should be substituted by the combined heat and power (CHP) unit. All in all, the mathematical formulations of the CHP units can be stated as follows: Equation (21) shows the cost function of CHP in terms of power and heat generations. Equation (22) illustrates the gas consumption of the CHP as a function of the power-heat generation, by considering the local gas heat value and generation efficiency. The cost function of the CHP, i.e., Equation (21), is subject to the following constraints Inequality (23) states that the upper and lower boundaries of electricity generation of the CHP unit are a function of the heat generation of the unit. In the same way, constraint (24) illustrates that the upper and lower boundaries of heat generation of the CHP are a function of the electricity generation. These constraints make the feasible operation range (FOR) of the CHP into a polygon area. The parametric FOR is depicted in Figure 3. Equations (25) and (26)

Industrial Boiler
The ORIs consume a large amount of steam in the refinery processes. The co-generation units can supply some part of steam demand. However, in many cases, the steam demand is high, and the co-generation units are not able to cope with the full steam demand of the refinery processes. Therefore, industrial boilers are considered to compensate for the lack of steam generation. The cost function of an industrial boiler is described as follows: Equation (27) shows the cost function of the boiler as a function of heat generation. The heat generation of the boiler is bounded to lower and upper thresholds by inequality (28). Note that α Bo , β Bo, and γ Bo are coefficients of the cost function.

Energy Cost Optimization
In this study, the problem aims to optimize the energy consumption/production of the ORI to provide structural flexibility to the external networks, i.e., IEM, meeting the daily ordered value of final production. Therefore, the objective function of the problem can be stated as follows: Equation (29) illustrates that the objective function of the problem is to minimize the operation cost of the ORI. The objective function is comprised of three terms. The first term is the procurement cost from the power grid. The second term shows the cost function of the CHP unit which was modeled in (21)- (26). The third term states the cost function of the industrial boiler which was formulized in (27) and (28). Equation (30) explains the procurement cost from the power grid. In this way, the ORI can sell the excess of generated electricity to the main grid (Π Grid < 0) or purchase the deficit of power from the network (Π Grid > 0).
In addition to the operational constraints of the refinery processes, CHP unit and industrial boiler, i.e., Equations (1)-(28), the energy management of the ORI is subject to the following constraints: Equation (31) illustrates the electrical demand balance of the ORI, which is the summation of power procurement from the grid and power generation of the CHP. On the other hand, Equation (32) shows that the total electricity consumption of the ORI is equal to the electrical demand of PRP plus the electrical demand of SRP. Following a similar pattern, Equation (33) expresses that the total steam demand of the ORI is the summation of the steam generation of the CHP and the boiler. From the demand side, Equation (34) describes the total demand of the ORI as the summation of steam demand in PRP and SRP. Total thermal energy needed to generate steam in boiler and CHP is illustrated by Equations (35) and (36), respectively.
Finally, Equation (37) describes the upper and lower thresholds of transactive power. In detail, the inequality states that the upper bound of traded power, i.e., purchased power from the main grid Π Grid > 0, is equal to the nominal electrical demand of the ORI. Besides, the lower bound of traded power, i.e., sold power to the main grid Π Grid < 0, is equal to the maximum electricity generation capacity of the CHP.

Time Framework
Generally, energy management problems are considered based on hourly time slots. In the industrial sector, many research studies optimized the operational processes of heavy industries, e.g., cement plants and metal smelting factories, on an hourly basis. In the industries with low interdependency between industrial sub-processes, the hourly basis is a practical time framework to avoid increasing complexity in modeling. In contrast, in the industries with high interdependency, the hourly basis may fail to optimize the industrial processes effectively. In this regard, if a heavy interdependency is considered between refinery processes in the ORI, the time framework of the problem should be split into sub-hourly time slots. To address the sub-hourly time framework, an operation flow graph is developed in this study in accordance with [15]. Figure 4 describes the schematic diagram for the operation flow graph of two consecutive refinery stages.
Energies 2020, 13, x FOR PEER REVIEW 10 of 25 demand in PRP and SRP. Total thermal energy needed to generate steam in boiler and CHP is illustrated by Equations (35) and (36), respectively. Finally, Equation (37) describes the upper and lower thresholds of transactive power. In detail, the inequality states that the upper bound of traded power, i.e., purchased power from the main grid Π Grid > 0, is equal to the nominal electrical demand of the ORI. Besides, the lower bound of traded power, i.e., sold power to the main grid Π Grid < 0, is equal to the maximum electricity generation capacity of the CHP.

Time Framework
Generally, energy management problems are considered based on hourly time slots. In the industrial sector, many research studies optimized the operational processes of heavy industries, e.g., cement plants and metal smelting factories, on an hourly basis. In the industries with low interdependency between industrial sub-processes, the hourly basis is a practical time framework to avoid increasing complexity in modeling. In contrast, in the industries with high interdependency, the hourly basis may fail to optimize the industrial processes effectively. In this regard, if a heavy interdependency is considered between refinery processes in the ORI, the time framework of the problem should be split into sub-hourly time slots. To address the sub-hourly time framework, an operation flow graph is developed in this study in accordance with [15]. Figure 4 describes the schematic diagram for the operation flow graph of two consecutive refinery stages. To elaborate the procedure, suppose that the refinery process i+1 is supplied by the refinery subprocesses i1, i2, …, iN. Because the process i+1 receives the raw materials from N refinery subprocesses, the operation of the process i may start only if the operations of sub-processes i1, i2, …, iN are finished. The parameter τn is the weighting factor multiplied by the sub-hourly time slot. For example, the operational process to supply process i + 1 with sub-process i1 takes τ1 × Tm time. Therefore, the start-up time of sub-process i + 1 is described as follows: Note that Tm is the sub-hourly time slot (minute). Moreover, it is assumed that the refinery subprocesses i1, i2, …, iN are not concurrent. In contrast, if two processes are performed concurrently, the biggest processing time is replaced in Equation (38). There is the same pattern for more than two concurrent sub-processes. To elaborate the procedure, suppose that the refinery process i+1 is supplied by the refinery sub-processes i 1 , i 2 , . . . , i N . Because the process i+1 receives the raw materials from N refinery sub-processes, the operation of the process i may start only if the operations of sub-processes i 1 , i 2 , . . . , i N are finished. The parameter τ n is the weighting factor multiplied by the sub-hourly time slot. For example, the operational process to supply process i + 1 with sub-process i 1 takes τ 1 × T m time. Therefore, the start-up time of sub-process i + 1 is described as follows:

Sub-processes in
Note that T m is the sub-hourly time slot (minute). Moreover, it is assumed that the refinery sub-processes i 1 , i 2 , . . . , i N are not concurrent. In contrast, if two processes are performed concurrently, the biggest processing time is replaced in Equation (38). There is the same pattern for more than two concurrent sub-processes.

Solution Methodology
In this study, the ORI can purchase/sell the deficit/excess of electrical energy from/to the power network, i.e., the wholesale electricity market. Generally, the electricity price of the wholesale market is a variable with imperfect data [25]. Therefore, the problem is under electricity price uncertainty. Addressing the electricity price as a stochastic variable, a non-deterministic approach is adopted to solve the program. To achieve the aim, a robust optimization approach is used as the solution methodology. In the next subsections, first of all, the electricity price is modeled and uncertainty bound. Afterwards, an iterative procedure is used to determine the robust strategies of the ORI against the uncertain electricity price. The robust strategies mean the optimized strategies in the worst-case realization of the electricity price uncertainty.

Electricity Price Uncertainty
In this study, the problem aims to co-optimize the joint electricity-heat procurement under electricity price uncertainty. The ORI can be connected to the main grid to compensate for the lack of electricity when the power system faces a power shortage or negative power imbalance. In contrast, the ORI prefers to purchase power from the main grid when the power system experiences the power excess or positive imbalance. In the former, the electricity price is high; therefore, the ORI should procure the required energy from the self-generation facilities as much as possible. Moreover, the excess power generation can be injected into the power system to help the power system making the load balance. Adversely, in the latter, the electricity price is low. In such s situation, the ORI may prefer to shut the self-generation facilities down to be supplied from the main grid. Making a decision about the generation unit commitment, the electricity price plays a crucial role. While the electricity price is a stochastic variable with imperfect data, the applicable studies should address the price uncertainties in the electricity market. In this study, to incorporate the electricity price uncertainty into the program, an envelope bound is considered for the electricity price uncertainty. The envelope bound is modeled as follows [26]: Equality (39) determines a robustness region Ψ for the uncertain electricity price with lower and upper thresholds. The electricity price can take values within the whole interval Ψ. Therefore, to determine the robust strategies under possible realizations of the electricity price, the robustness region is portioned into M subintervals. This procedure can be stated as follows [27]: Equation (40) portions the robustness region Ψ into m = 1, . . . , M subintervals, i.e., Ψ m . Therefore, the problem can be optimized in m subintervals of the electricity price uncertainty, instead of lower and upper bounds. Note that m = {1, . . . , M} is a counter index to cover the whole interval of the uncertainty set Ψ. Figure 5 illustrates the envelope bound for the electricity price uncertainty.

Solution Methodology
In this study, the ORI can purchase/sell the deficit/excess of electrical energy from/to the power network, i.e., the wholesale electricity market. Generally, the electricity price of the wholesale market is a variable with imperfect data [25]. Therefore, the problem is under electricity price uncertainty. Addressing the electricity price as a stochastic variable, a non-deterministic approach is adopted to solve the program. To achieve the aim, a robust optimization approach is used as the solution methodology. In the next subsections, first of all, the electricity price is modeled and uncertainty bound. Afterwards, an iterative procedure is used to determine the robust strategies of the ORI against the uncertain electricity price. The robust strategies mean the optimized strategies in the worst-case realization of the electricity price uncertainty.

Electricity Price Uncertainty
In this study, the problem aims to co-optimize the joint electricity-heat procurement under electricity price uncertainty. The ORI can be connected to the main grid to compensate for the lack of electricity when the power system faces a power shortage or negative power imbalance. In contrast, the ORI prefers to purchase power from the main grid when the power system experiences the power excess or positive imbalance. In the former, the electricity price is high; therefore, the ORI should procure the required energy from the self-generation facilities as much as possible. Moreover, the excess power generation can be injected into the power system to help the power system making the load balance. Adversely, in the latter, the electricity price is low. In such s situation, the ORI may prefer to shut the self-generation facilities down to be supplied from the main grid. Making a decision about the generation unit commitment, the electricity price plays a crucial role. While the electricity price is a stochastic variable with imperfect data, the applicable studies should address the price uncertainties in the electricity market. In this study, to incorporate the electricity price uncertainty into the program, an envelope bound is considered for the electricity price uncertainty. The envelope bound is modeled as follows [26]: Equality (39) determines a robustness region Ψ for the uncertain electricity price with lower and upper thresholds. The electricity price can take values within the whole interval Ψ. Therefore, to determine the robust strategies under possible realizations of the electricity price, the robustness region is portioned into M subintervals. This procedure can be stated as follows [27]: Equation (40) portions the robustness region Ψ into m = 1, ..., M subintervals, i.e., Ψm. Therefore, the problem can be optimized in m subintervals of the electricity price uncertainty, instead of lower and upper bounds. Note that m = {1, …, M} is a counter index to cover the whole interval of the uncertainty set Ψ. Figure 5 illustrates the envelope bound for the electricity price uncertainty.

Robust Optimization Approach
Based on the abovementioned facts, the problem aims to determine the robust strategies of the ORI in the wholesale electricity market with price uncertainty. Therefore, the problem optimizes the operational strategies under the worst-case realization of the electricity price uncertainty. As a result, the objective function of the problem, i.e., (29), is restated as follows: To solve the problem, by using the duality theorem, the primal min-max problem is converted to a dual robust mixed-integer quadratic program (R-MIQP) as follows: Equation (42) presents the final R-MIOP, which is solved to determine optimized strategies. Inequality (43) describes symbols ξ t and ψ t as dual variables of corresponding constraints in the duality theorem. In order to incorporate the uncertainty set Ψ m into the R-MIQP, the step-by-step algorithm is illustrated in Algorithm 1. Determine robust decisions in worst-case realization of λ M t . 7 Increase counter index m→m + 1 8 End For

Integration of Flexibility to External Networks
As illustrated in the previous sections, the main aim of this study is to use the flexibility potentials of the ORI to overcome the external grid's limitation. Therefore, the operation of refinery processes is optimized to provide electricity regulation to the power network when a serious electricity shortage occurs or the grid reliability is jeopardized [28]. This issue is a major problem for Iran Energy Market. The Iran Power Grid suffers from a power shortage at hot midday hours of summer, i.e., July to September, when the electrical demand of air conditioning systems of residential and commercial sectors is high. Increasing the capacity of electricity generation and transmission is not an economic decision. The reason is that more than half the capacity of the electricity network is not used out of peak season. Therefore, the practical solution is to optimize the operational processes of industries that consume electricity simultaneously. In this way, the industries equipped with CHP units are satisfactory solutions.
To meet the power limitations of the external grids, the production planning department of the ORI needs to work closely with demand response experts at Iran Power Grid. Based on the weather forecasting received from Iran Meteorological Organization, the demand response experts at Iran Power Grid calculate how much demand flexibility is needed to prevent a power shortage. The amount of demand flexibility is sent to the Production Planning Department of the ORI to optimize the operational processes of the industry for the next 24 h. The production planning department makes the final decision for the operation of the ORI, meeting the industry operational requirements. In this way, minor/daily maintenance programs, crew constraints, daily/weekly ordered value of final productions, and cost data of self-generation facilities are the key factors affecting the final production schedule. In this way, the production planning department can schedule minor maintenance actions to coincide with the peak demand of the external network. These kinds of coordination help the external network to supply demand without interruption. Figure 6 clarifies the suggested coordination between Iran Power Grid, Meteorological Organization, and Production Planning Department.
Energies 2020, 13, x FOR PEER REVIEW 13 of 25 final productions, and cost data of self-generation facilities are the key factors affecting the final production schedule. In this way, the production planning department can schedule minor maintenance actions to coincide with the peak demand of the external network. These kinds of coordination help the external network to supply demand without interruption. Figure 6 clarifies the suggested coordination between Iran Power Grid, Meteorological Organization, and Production Planning Department.
To sum up the problem, Figure 7 illustrates the general structure of the proposed approach. To sum up the problem, Figure 7 illustrates the general structure of the proposed approach.

Numerical Studies
In this section, the proposed approach is implemented in the case studies. In this way, first of all, the input data are illustrated. Afterwards, the simulation results are described and discussed.

Input Data
The problem is simulated in an ORI to minimize the cost of energy consumption as well as maximize demand flexibility to the IEM. The study horizon is one day, i.e., 24 h. The problem is optimized based on hourly time resolution; therefore, Tm is chosen as 60 min.
The problem aims to determine optimized operation strategies of the ORI in the next 24 h, considering the uncertainty associated with the electricity market price. The target day is a hot day of summer when the IEM suffers from peak electricity demand due to the high electricity consumption of residential and commercial cooling systems. Therefore, the operation of the ORI is optimized to provide flexibility to the IEM in critical hours of both day and night peak hours. It is worth mentioning that the IEM has two peak durations a day in the summer. The first is the day peak that occurs between hours 12 and 16. The second is called the night peak during hours 21 to 23. The former stems from the high electrical demand of cooling systems, while the latter is caused by the high demand of lighting systems. Therefore, the demand-side flexibility of Iranian industries, especially the ORI, should be scheduled to provide power flexibility to the IEM in both day and night peak hours.
The pilot plant is a test ORI, called Pars ORI, in the south-west of Iran, where huge numbers of oil refinery plants are located in one of the most oil-rich areas in the world [29]. The total refinery capacity of the ORI is 48,000 ton/day crude oil. The scheduled vale of oil refinery is supposed to be 44,000 tons on the target day. Table 1 describes the technical characteristics of the Pars ORI. Besides, Table 2 illustrates the technical data of CHP and industrial boiler of Pars ORI.

Numerical Studies
In this section, the proposed approach is implemented in the case studies. In this way, first of all, the input data are illustrated. Afterwards, the simulation results are described and discussed.

Input Data
The problem is simulated in an ORI to minimize the cost of energy consumption as well as maximize demand flexibility to the IEM. The study horizon is one day, i.e., 24 h. The problem is optimized based on hourly time resolution; therefore, T m is chosen as 60 min.
The problem aims to determine optimized operation strategies of the ORI in the next 24 h, considering the uncertainty associated with the electricity market price. The target day is a hot day of summer when the IEM suffers from peak electricity demand due to the high electricity consumption of residential and commercial cooling systems. Therefore, the operation of the ORI is optimized to provide flexibility to the IEM in critical hours of both day and night peak hours. It is worth mentioning that the IEM has two peak durations a day in the summer. The first is the day peak that occurs between hours 12 and 16. The second is called the night peak during hours 21 to 23. The former stems from the high electrical demand of cooling systems, while the latter is caused by the high demand of lighting systems. Therefore, the demand-side flexibility of Iranian industries, especially the ORI, should be scheduled to provide power flexibility to the IEM in both day and night peak hours.
The pilot plant is a test ORI, called Pars ORI, in the south-west of Iran, where huge numbers of oil refinery plants are located in one of the most oil-rich areas in the world [29]. The total refinery capacity of the ORI is 48,000 ton/day crude oil. The scheduled vale of oil refinery is supposed to be 44,000 tons on the target day. Table 1 describes the technical characteristics of the Pars ORI. Besides, Table 2 illustrates the technical data of CHP and industrial boiler of Pars ORI.  Figure 8 describes the electricity price of the target day of the IEM in June 2017 [30]. In this figure, the upper and lower thresholds of the electricity price are shown. The electricity price is quantified within the area filled by the shadowed area. As the figure reveals, the price gap is divided into 25 intervals to optimize the operation strategies of the ORI in the worst-case realization of the electricity price.   Figure 8 describes the electricity price of the target day of the IEM in June 2017 [30]. In this figure, the upper and lower thresholds of the electricity price are shown. The electricity price is quantified within the area filled by the shadowed area. As the figure reveals, the price gap is divided into 25 intervals to optimize the operation strategies of the ORI in the worst-case realization of the electricity price.
The suggested approach is mathematically modeled in GAMS 24.1.3 [31], linked with MATLAB 2019R through gdx file interface [20]. To optimize the mathematical formulations, CPLEX [32] and CONOPT solvers [33] are used. The program is simulated in Intel-based computer hardware with 16 GB of RAM.

Results and Discussions
The main aim of the problem is to optimize the operation strategies of the test ORI, including procurement from the IEM, operation of refinery processes, and exploitation plans of CHP and boilers. Regarding the uncertain bound of electricity price, the procurement strategies are determined based on the worst-case realization of the electricity price. The suggested approach is mathematically modeled in GAMS 24.1.3 [31], linked with MATLAB 2019R through gdx file interface [20]. To optimize the mathematical formulations, CPLEX [32] and CONOPT solvers [33] are used. The program is simulated in Intel-based computer hardware with 16 GB of RAM.

Results and Discussions
The main aim of the problem is to optimize the operation strategies of the test ORI, including procurement from the IEM, operation of refinery processes, and exploitation plans of CHP and boilers. Regarding the uncertain bound of electricity price, the procurement strategies are determined based on the worst-case realization of the electricity price.
First of all, Figure 9 describes the exploitation plan of CHP in terms of power and heat generations. Subfigure (a) shows the power generation of the CHP. Based on the graph, the CHP generates moderate electricity during off-peak hours, i.e., 1 to 8. In contrast, the electricity generation increases considerably from 9 to 24 when the day and night peak durations occur. Therefore, the CHP reaches the upper threshold of power generation in critical hours of the IEM, to provide power flexibility to the electricity market. Besides, subfigure (b) illustrates the heat generation of the CHP. As the graph reveals, the CHP produces a large amount of steam during hours 2 to 9, when the steam demand of the ORI is high (see the steam demand of the ORI in Figure 10). Adversely, the steam generation of the CHP decreases significantly during DR events, i.e., 9 to 24. There are two reasons to justify this fact. Firstly, the steam demand of the ORI is mainly supplied out of DR events in hours 2 to 9 (based on Figure 10). Besides, in the DR events, electrical power is the clear need for the IEM. Therefore, considering the FOR of the CHP in Figure 3, the CHP working point reaches the upper threshold of power generation, i.e., point A, which generates a low amount of heat. Figure 10 illustrates the optimized operation of the ORI for 24 h. As subfigure (a) reveals, the largest amount of electricity consumption of the ORI is scheduled out of DR events. During the DR events, the ORI decreases the electricity consumption significantly to provide power flexibility to the upstream network. Subfigure (b) shows the electricity consumption of the PRP and SRP. Based on the graph, the two industrial sub-processes follow a similar pattern to maximize the demand-side flexibility of the ORI. Furthermore, subfigure (c) illustrates the total steam demand of the ORI. As can be seen, the steam demand of the ORI reaches the lowest point during DR events. Considering the FOR of the CHP in Figure 3, this enables the CHP to reach the upper threshold of electricity generation to overcome the power shortage in the IEM during the DR events. This is an interesting result that shows how the correlation between joint heat-electricity generation can be optimized to not only provide power flexibility to the electricity market, but also supply the joint electricity-heat demand of the industry. First of all, Figure 9 describes the exploitation plan of CHP in terms of power and heat generations. Subfigure (a) shows the power generation of the CHP. Based on the graph, the CHP generates moderate electricity during off-peak hours, i.e., 1 to 8. In contrast, the electricity generation increases considerably from 9 to 24 when the day and night peak durations occur. Therefore, the CHP reaches the upper threshold of power generation in critical hours of the IEM, to provide power flexibility to the electricity market. Besides, subfigure (b) illustrates the heat generation of the CHP. As the graph reveals, the CHP produces a large amount of steam during hours 2 to 9, when the steam demand of the ORI is high (see the steam demand of the ORI in Figure 10). Adversely, the steam generation of the CHP decreases significantly during DR events, i.e., 9 to 24. There are two reasons to justify this fact. Firstly, the steam demand of the ORI is mainly supplied out of DR events in hours 2 to 9 (based on Figure 10). Besides, in the DR events, electrical power is the clear need for the IEM. Therefore, considering the FOR of the CHP in Figure 3, the CHP working point reaches the upper threshold of power generation, i.e., point A, which generates a low amount of heat.  Figure 10 illustrates the optimized operation of the ORI for 24 h. As subfigure (a) reveals, the largest amount of electricity consumption of the ORI is scheduled out of DR events. During the DR events, the ORI decreases the electricity consumption significantly to provide power flexibility to the upstream network. Subfigure (b) shows the electricity consumption of the PRP and SRP. Based on the graph, the two industrial sub-processes follow a similar pattern to maximize the demand-side  Figure 11 describes the optimized operation of the industrial boiler. As the line graph reveals, the boiler generates a huge amount of steam out of DR events, i.e., hours 3 to 10. The reason is that the main part of the ORI operation is scheduled in this duration. To continue, the steam generation of the boiler decreases as the steam demand of the ORI reduces. It is worth mentioning that the boiler compensates for the lack of steam generation during DR events to help the CHP reach the upper threshold of power generation.  Figure 12 illustrates the hourly cumulative production of the ORI. Interpreting the figure, interesting results are obtained. First of all, the curve can be divided into two main areas representing DR events and out of DR events. The production rates for these two areas are shown with two symbolic ramps, m1 and m2. As the graph reveals, the value of m1 is larger than m2 (m1 > m2). This confirms that the industry schedules the industrial operation, mainly out of DR events. Approaching the DR duration, the ramp rate of production decreases moderately. In this way, hour 10 can be  Figure 11 describes the optimized operation of the industrial boiler. As the line graph reveals, the boiler generates a huge amount of steam out of DR events, i.e., hours 3 to 10. The reason is that the main part of the ORI operation is scheduled in this duration. To continue, the steam generation of the boiler decreases as the steam demand of the ORI reduces. It is worth mentioning that the boiler compensates for the lack of steam generation during DR events to help the CHP reach the upper threshold of power generation.  Figure 11 describes the optimized operation of the industrial boiler. As the line graph reveals, the boiler generates a huge amount of steam out of DR events, i.e., hours 3 to 10. The reason is that the main part of the ORI operation is scheduled in this duration. To continue, the steam generation of the boiler decreases as the steam demand of the ORI reduces. It is worth mentioning that the boiler compensates for the lack of steam generation during DR events to help the CHP reach the upper threshold of power generation.  Figure 12 illustrates the hourly cumulative production of the ORI. Interpreting the figure, interesting results are obtained. First of all, the curve can be divided into two main areas representing DR events and out of DR events. The production rates for these two areas are shown with two symbolic ramps, m1 and m2. As the graph reveals, the value of m1 is larger than m2 (m1 > m2). This confirms that the industry schedules the industrial operation, mainly out of DR events. Approaching the DR duration, the ramp rate of production decreases moderately. In this way, hour 10 can be   Figure 12 illustrates the hourly cumulative production of the ORI. Interpreting the figure, interesting results are obtained. First of all, the curve can be divided into two main areas representing DR events and out of DR events. The production rates for these two areas are shown with two symbolic ramps, m 1 and m 2 . As the graph reveals, the value of m 1 is larger than m 2 (m 1 > m 2 ). This confirms that the industry schedules the industrial operation, mainly out of DR events. Approaching the DR duration, the ramp rate of production decreases moderately. In this way, hour 10 can be considered as a milestone, where the industry makes it ready to reduce the energy consumption 2 h before the DR event. The gap between the milestone and the beginning time of the DR event is caused due to technical constraints of the industry when the plant cannot change the energy consumption suddenly. Heat and electrical ramp rates of industrial sub-processes are the main constraints to determine the duration of the gap time. Finally, the cumulative production meets the daily ordered value of 44 kt.
Energies 2020, 13, x FOR PEER REVIEW 18 of 25 considered as a milestone, where the industry makes it ready to reduce the energy consumption 2 h before the DR event. The gap between the milestone and the beginning time of the DR event is caused due to technical constraints of the industry when the plant cannot change the energy consumption suddenly. Heat and electrical ramp rates of industrial sub-processes are the main constraints to determine the duration of the gap time. Finally, the cumulative production meets the daily ordered value of 44 kt.  Figure 13 illustrates the power traded in the IEM. The bar graph conveys the electricity sold to the wholesale electricity market. Based on the graph, the ORI prefers to use the self-generation facilities as the main electricity supply out of DR events when the electricity market price is relatively low. Therefore, the ORI consumes the power generation of the CHP for the internal processes. In contrast, during DR events, the ORI sells much more electrical power to the electricity market when the market price reaches the highest level in the day. As can be seen, the traded power reaches the highest point in hours 12-16 and 21-22 to provide flexibility to the power system in day and night peak hours. The sold power experiences a slight reduction between hours 16 and 21. This time duration is a gap time between day and night peaks of the IPG, which is followed by the ORI considering the ramp-up/-down of the CHP. Trading power in high price hours, the ORI increases the profit. Therefore, the ORI not only participate in the peak shaving of the upstream network, but also takes advantage of increased profit. As a result, both beneficiaries, including the ORI and IEM, take advantage of cost optimization and flexibility potential, respectively.  Figure 14 describes the total electrical demands of the ORI in response to the daily demand profile of the IPG. In the summer, the IPG experiences two peak durations during a day. The day peak normally occurs when the electrical demand of residential cooling systems increases significantly, i.e., hours 12-16. The night peak emanates from the increased lighting system of residential and commercial sectors. Therefore, the responsive plants should provide power flexibility in both peak durations. In Figure 14, the daily demand profile of the IPG is depicted in subfigure (b). Based on the graph, the industry can provide applicable flexibility to the IPG in both peak hours. In  Figure 13 illustrates the power traded in the IEM. The bar graph conveys the electricity sold to the wholesale electricity market. Based on the graph, the ORI prefers to use the self-generation facilities as the main electricity supply out of DR events when the electricity market price is relatively low. Therefore, the ORI consumes the power generation of the CHP for the internal processes. In contrast, during DR events, the ORI sells much more electrical power to the electricity market when the market price reaches the highest level in the day. As can be seen, the traded power reaches the highest point in hours 12-16 and 21-22 to provide flexibility to the power system in day and night peak hours. The sold power experiences a slight reduction between hours 16 and 21. This time duration is a gap time between day and night peaks of the IPG, which is followed by the ORI considering the ramp-up/-down of the CHP. Trading power in high price hours, the ORI increases the profit. Therefore, the ORI not only participate in the peak shaving of the upstream network, but also takes advantage of increased profit. As a result, both beneficiaries, including the ORI and IEM, take advantage of cost optimization and flexibility potential, respectively.
Energies 2020, 13, x FOR PEER REVIEW 18 of 25 considered as a milestone, where the industry makes it ready to reduce the energy consumption 2 h before the DR event. The gap between the milestone and the beginning time of the DR event is caused due to technical constraints of the industry when the plant cannot change the energy consumption suddenly. Heat and electrical ramp rates of industrial sub-processes are the main constraints to determine the duration of the gap time. Finally, the cumulative production meets the daily ordered value of 44 kt.  Figure 13 illustrates the power traded in the IEM. The bar graph conveys the electricity sold to the wholesale electricity market. Based on the graph, the ORI prefers to use the self-generation facilities as the main electricity supply out of DR events when the electricity market price is relatively low. Therefore, the ORI consumes the power generation of the CHP for the internal processes. In contrast, during DR events, the ORI sells much more electrical power to the electricity market when the market price reaches the highest level in the day. As can be seen, the traded power reaches the highest point in hours 12-16 and 21-22 to provide flexibility to the power system in day and night peak hours. The sold power experiences a slight reduction between hours 16 and 21. This time duration is a gap time between day and night peaks of the IPG, which is followed by the ORI considering the ramp-up/-down of the CHP. Trading power in high price hours, the ORI increases the profit. Therefore, the ORI not only participate in the peak shaving of the upstream network, but also takes advantage of increased profit. As a result, both beneficiaries, including the ORI and IEM, take advantage of cost optimization and flexibility potential, respectively.  Figure 14 describes the total electrical demands of the ORI in response to the daily demand profile of the IPG. In the summer, the IPG experiences two peak durations during a day. The day peak normally occurs when the electrical demand of residential cooling systems increases significantly, i.e., hours 12-16. The night peak emanates from the increased lighting system of residential and commercial sectors. Therefore, the responsive plants should provide power flexibility in both peak durations. In Figure 14, the daily demand profile of the IPG is depicted in subfigure (b). Based on the graph, the industry can provide applicable flexibility to the IPG in both peak hours. In  Figure 14 describes the total electrical demands of the ORI in response to the daily demand profile of the IPG. In the summer, the IPG experiences two peak durations during a day. The day peak normally occurs when the electrical demand of residential cooling systems increases significantly, i.e., hours 12-16. The night peak emanates from the increased lighting system of residential and commercial sectors. Therefore, the responsive plants should provide power flexibility in both peak durations. In Figure 14, the daily demand profile of the IPG is depicted in subfigure (b). Based on the graph, the industry can provide applicable flexibility to the IPG in both peak hours. In addition, the electricity consumption of the ORI increases moderately between the two peak slots, i.e., hours [17][18][19]. Based on the line graph, as the ORI responds to the DR events, the peak demand of the plant is shifted out of DR events. In this way, the need for installing fast-run power generation facilities in the IPG is obviated.
Energies 2020, 13, x FOR PEER REVIEW 19 of 25 addition, the electricity consumption of the ORI increases moderately between the two peak slots, i.e., hours [17][18][19]. Based on the line graph, as the ORI responds to the DR events, the peak demand of the plant is shifted out of DR events. In this way, the need for installing fast-run power generation facilities in the IPG is obviated.  Figure 15 illustrates the role of storage in providing power flexibility to the IPG. The graph is depicted in three states, considering 100, 50, and 25 percent of the original storage capacity. As the graph reveals, decreasing the storage capacity, the power demand of the industry moves to the DR events. Therefore, the capacity of the industry to provide power flexibility to the IPG decreases noticeably.   Figure 15 illustrates the role of storage in providing power flexibility to the IPG. The graph is depicted in three states, considering 100, 50, and 25 percent of the original storage capacity. As the graph reveals, decreasing the storage capacity, the power demand of the industry moves to the DR events. Therefore, the capacity of the industry to provide power flexibility to the IPG decreases noticeably.
Energies 2020, 13, x FOR PEER REVIEW 19 of 25 addition, the electricity consumption of the ORI increases moderately between the two peak slots, i.e., hours [17][18][19]. Based on the line graph, as the ORI responds to the DR events, the peak demand of the plant is shifted out of DR events. In this way, the need for installing fast-run power generation facilities in the IPG is obviated.  Figure 15 illustrates the role of storage in providing power flexibility to the IPG. The graph is depicted in three states, considering 100, 50, and 25 percent of the original storage capacity. As the graph reveals, decreasing the storage capacity, the power demand of the industry moves to the DR events. Therefore, the capacity of the industry to provide power flexibility to the IPG decreases noticeably.   market. This is an interesting result that shows that risk-taker participants prefer to trade more energy in uncertain markets. Besides, subfigure (b) describes the robust decisions of the traded power in the electricity market. Following a similar pattern, as the robustness level increases, the risk-taker industry trades more energy in the uncertain market. Indeed, the risk-taker participants prefer to trade more energy in an uncertain electricity market. It is worth mentioning that a lower amount of robustness levels indicates lower uncertainty. A risk-averse participant prefers to work in this state. In contrast, a high amount of robustness level corresponds to higher uncertainty that is preferred by risk-taker market traders.
(1) Risk-taker market participants (2) Risk-averse market participants The risk-taker participants consider high levels of uncertainty in operational scheduling. Therefore, this type of participant prefers to participate in electricity market floors with high price uncertainty. In this study, the industry can supply the required energy from the self-generation facilities and the wholesale market. From the uncertainty viewpoint, the self-generation facilities have no uncertainty in the electricity price. In contrast, the wholesale market imposes a great deal of uncertainty in the electricity price. In such a situation, the risk-taker participants prefer to participate in the wholesale electricity market to make a profit in the uncertain electricity market. In fact, the risk-taker participants bear the burden of the market price uncertainty to make more profit. Adversely, risk-averse participants prefer not to purchase their required energy from the uncertain wholesale market. In this way, the risk-averse participants prefer to supply their energy from the selfgeneration facilities without price uncertainty.  Figure 17 illustrates the benefits of power trading in the wholesale electricity market. The benefits are described in terms of profit and flexibility. First of all, as the graph reveals, the ORI provides a relatively high income from selling energy to the wholesale market. In this way, an income of 378.7 × 10 3 $ is provided by selling power to the wholesale market. Besides, based on the graph, most energy is injected to the IPG during hours 12-16 and 20-23, i.e., day and night peak hours. Therefore, the ORI is successful to provide power flexibility to the market during the daily peak From the risk-bearing viewpoint, Figure 16 conveys two different aspects: (1) Risk-taker market participants (2) Risk-averse market participants The risk-taker participants consider high levels of uncertainty in operational scheduling. Therefore, this type of participant prefers to participate in electricity market floors with high price uncertainty. In this study, the industry can supply the required energy from the self-generation facilities and the wholesale market. From the uncertainty viewpoint, the self-generation facilities have no uncertainty in the electricity price. In contrast, the wholesale market imposes a great deal of uncertainty in the electricity price. In such a situation, the risk-taker participants prefer to participate in the wholesale electricity market to make a profit in the uncertain electricity market. In fact, the risk-taker participants bear the burden of the market price uncertainty to make more profit. Adversely, risk-averse participants prefer not to purchase their required energy from the uncertain wholesale market. In this way, the risk-averse participants prefer to supply their energy from the self-generation facilities without price uncertainty. Figure 17 illustrates the benefits of power trading in the wholesale electricity market. The benefits are described in terms of profit and flexibility. First of all, as the graph reveals, the ORI provides a relatively high income from selling energy to the wholesale market. In this way, an income of 378.7 × 10 3 $ is provided by selling power to the wholesale market. Besides, based on the graph, most energy is injected to the IPG during hours 12-16 and 20-23, i.e., day and night peak hours. Therefore, the ORI is successful to provide power flexibility to the market during the daily peak hours. To sum up, the suggested approach not only provides power flexibility to the market, but also increases the income of the industry. hours. To sum up, the suggested approach not only provides power flexibility to the market, but also increases the income of the industry. In industrial studies, the superiority of the suggested approaches should be investigated in comparison with the literature [34]. In this way, the key results are pointed out to show how the proposed approach outweighs the previous studies [35,36]. Therefore, the final results can be stated as follows: (1) Integration of joint heat-power flexibility to electricity markets with price uncertainty.
(2) Cost-effective energy management for oil refinery industries, not only to provide demand-side flexibility to the electricity market, but also to increase the industries' profit.

Conclusions
This paper proposed a novel structure to provide demand-side flexibility to the electricity market with price uncertainties. To achieve the aim, industrial sub-processes of a heavy oil refinery plant were modeled mathematically. The main feature of the problem was the integration of joint heat-power flexibility to the upstream network. To overcome the electricity price uncertainty, an iterative robust approach was suggested to determine the optimized exploitation plans of the industry under the worst-case realization of electricity prices. Moreover, to show the correlation between heat and power in providing demand-side flexibility, CHP and industrial boilers were simulated as self-generation facilities.
Simulation results showed that the CHP generated moderate values of electrical power and high values of heat out of DR events. In contrast, the CHP reached the highest level of power generation in DR events to provide flexibility to the power system. In this situation, the value of steam generation reduced significantly during DR events.
The ORI scheduled the main electricity consumption out of DR events. Therefore, the heat demand during DR events decreased considerably. This was the reason why the CHP generated less heat in DR duration. This stems from the fact that the power generation of CHP was injected into the outer network while the steam must be consumed in the internal processes.
Regarding the output production of the industry, the rate of production decreased considerably before the beginning of the DR events. In this way, a milestone can be detected in the production curve, followed by a gap time. This was a critical point for energy experts at the Department of Production Planning to respond to DR events on short or long notice. Ramp-up/-down rates of CHP and boilers played an important role in determining the value of gap time where the industrial subprocesses needed enough time to be turned down.
Finally, comparing the total electricity demand of the industry in responsive and non-responsive (traditional) states, it was shown that the plant can provide power flexibility to the upstream network; In industrial studies, the superiority of the suggested approaches should be investigated in comparison with the literature [34]. In this way, the key results are pointed out to show how the proposed approach outweighs the previous studies [35,36]. Therefore, the final results can be stated as follows: (1) Integration of joint heat-power flexibility to electricity markets with price uncertainty.
(2) Cost-effective energy management for oil refinery industries, not only to provide demand-side flexibility to the electricity market, but also to increase the industries' profit.

Conclusions
This paper proposed a novel structure to provide demand-side flexibility to the electricity market with price uncertainties. To achieve the aim, industrial sub-processes of a heavy oil refinery plant were modeled mathematically. The main feature of the problem was the integration of joint heat-power flexibility to the upstream network. To overcome the electricity price uncertainty, an iterative robust approach was suggested to determine the optimized exploitation plans of the industry under the worst-case realization of electricity prices. Moreover, to show the correlation between heat and power in providing demand-side flexibility, CHP and industrial boilers were simulated as self-generation facilities.
Simulation results showed that the CHP generated moderate values of electrical power and high values of heat out of DR events. In contrast, the CHP reached the highest level of power generation in DR events to provide flexibility to the power system. In this situation, the value of steam generation reduced significantly during DR events.
The ORI scheduled the main electricity consumption out of DR events. Therefore, the heat demand during DR events decreased considerably. This was the reason why the CHP generated less heat in DR duration. This stems from the fact that the power generation of CHP was injected into the outer network while the steam must be consumed in the internal processes.
Regarding the output production of the industry, the rate of production decreased considerably before the beginning of the DR events. In this way, a milestone can be detected in the production curve, followed by a gap time. This was a critical point for energy experts at the Department of Production Planning to respond to DR events on short or long notice. Ramp-up/-down rates of CHP and boilers played an important role in determining the value of gap time where the industrial sub-processes needed enough time to be turned down. Finally, comparing the total electricity demand of the industry in responsive and non-responsive (traditional) states, it was shown that the plant can provide power flexibility to the upstream network; up to 72% of the nominal power. All in all, the results confirmed that the approach not only provides flexibility to the electricity market, but also increased the profit of the industry.
Author Contributions: H.G.: conceptualization; methodology; software; validation; writing-original draft preparation; writing-review and editing. A.A.: visualization; supervision; project administration. All authors have read and agreed to the published version of the manuscript.
Funding: This research received no external funding.

Conflicts of Interest:
The funders had no role in the design of the study; in the collection, analyses, or interpretation of data; in the writing of the manuscript, or in the decision to publish the results.

Nomenclature
The main nomenclatures are described here. However, brief discussions are provided in the text where a mathematical formulation is presented.