1 Introduction

Scheduling of production systems is an active research field and important for almost all kinds of industries (Harjunkoski et al. 2014; Castro et al. 2018). Recently, research in scheduling increasingly focuses on energy aspects (Gahm et al. 2016), where new challenges arise from more volatile electricity prices and more energy supply from renewable energy sources (Merkert et al. 2015; Mitsos et al. 2018).

Large energy-intensive production systems are often supplied by on-site energy systems. Still, the on-site energy system is commonly not considered during the scheduling of the production system. Scheduling of production and energy systems is commonly performed sequentially: First, the production system is scheduled, and, second, the energy system is scheduled for the fixed energy demand. The fixed energy demand during energy system optimization can result in unnecessarily high energy cost because the production system does not account for the performance of the energy system. Integrated scheduling of production and energy system can reduce total cost. Agha et al. (2010) consider integrated scheduling of production and energy systems for operation. Leenders et al. (2020) extend the integrated scheduling of production and energy systems by the provision of control reserve, whereas Leenders et al. (2019b) also consider the synthesis of both systems. Thereby, the integrated scheduling assumes that the production system has full control over the energy system as well as complete information of the energy systems optimization problem.

However, in practice, systems are often operated by different companies. Thus, distributed optimization is performed. For this purpose, Allman and Zhang (2020) propose a solution algorithm to coordinate the optimization between different companies, i.e., an industrial process and its customers. The proposed algorithm considers that the different systems do not share their internal optimization problems with the other systems. The algorithm uses the method of Alternating Direction Method of Multipliers for distributed optimization (Boyd et al. 2010).

Wenzel et al. (2020) propose an algorithm to coordinate between different production plants in a large production site. Shared resources couple the production plants. The algorithm iteratively coordinates between the systems to meet the network balance of shared resources. The algorithm in Wenzel et al. (2020) is based on extensive earlier work of the authors, e.g., in Wenzel et al. (2016) an algorithm is proposed to adjust the prices for shared resources. Maxeiner and Engell (2020) compare different dual-based methods for the distributed optimization and apply the methods to a case study with coupled semi-batch reactors. The reactors are coupled by a maximum for the combined feed flow rate.

Distributed optimization is important to take confidential issues into account while optimizing large industrial sites. In practice, each system often optimizes to its own objective and the decisions are taken sequentially. In this case, the overall problem cannot be considered as a single-level problem but should rather be considered as a hierarchical problem. This class of problem can be modeled as a Stackelberg game where the leader decides first, and subsequently, the follower decides according to the leader’s decision. Here, we consider a production site where the production system (leader) decides first by optimizing its objective, and the energy system (follower) satisfies the resulting energy demand while optimizing its own objective.

In a prior contribution (Leenders et al. 2019a, 2021), we proposed a method to coordinate the scheduling of production and energy systems with different objectives without requiring the subsystems to share their internal optimization problems. Since only incomplete information is shared, the method does not guarantee to identify the optimal solution in terms of the leader’s objective. Also other authors solved Stackelberg games for energy systems with exchange of incomplete information, e.g., between a utility company and customers (Maharjan et al. 2013; Soliman and Leon-Garcia 2014; Yu and Hong 2016). In contrast to our previous work, in this work, we let the production system consider the energy system’s response with complete information. Thus, we consider complete information as in the integrated optimization but the production system does not have the full control over the energy system. Hence, we model the optimization problem as a bilevel problem with mixed-integer decision variables in the upper and lower level. The bilevel problem enables the identification of an optimal solution point for the production system in the given Stackelberg game situation. With the bilevel problem, we consider the sequential decision making between energy and production systems which is the common way to schedule their operation (Agha et al. 2010; Zhao et al. 2014; Zulkafli and Kopanos 2016). As an alternative, one can think of setting up a contract for demand-side management between the systems. Depending on the design of the demand-side management contract, an integrated optimization or a bilevel optimization should be applied. If the demand-side management contract is designed so that the energy system cannot decide anything anymore on its own, an integrated optimization will provide the best solution. If the demand-side management contract allows for independent decisions of the energy system, the demand-side management contract will result in additional constraints in the bilevel problem. Thus, a Stackelberg game remains, and the bilevel problem would provide the optimal solution for the production system.

In bilevel problems, misaligned optimization problems are considered by an upper level (leader) and a lower level (follower). This hierarchical structure is realized by embedding the lower-level optimization problem in the constraints of the upper-level optimization problem.

To the best of our knowledge, this work is the first to model the scheduling of production and energy systems as a bilevel problem. In the bilevel problem, the production system is considered as the upper level, and the energy system is the lower level. Here, we can model a bilevel problem since the production system has complete information on the energy system. The assignment of production system to the upper level and energy system to the lower level is chosen, since we assume that the production system announces its schedule first, and subsequently, the energy system fulfills the energy demand resulting from the production schedule. This is the same order of decision making as in the sequential optimization, which is the most used in industry (Pablos et al. 2021). Compared to the sequential optimization, the production system considers the sequential decision making in the bilevel optimization and benefits from this knowledge.

The resulting bilevel problem is characterized by a nonconvex lower-level problem. For this class of bilevel problems, solution algorithms are available for: non-linear bilevel programming problems (NLBP) (Mitsos et al. 2008; Tsoukalas et al. 2009a, b; Wiesemann et al. 2013; Kleniati and Adjiman 2014a, b), mixed-integer non-linear bilevel programming problems (MINLBP) (Mitsos 2010; Djelassi et al. 2019), and mixed-integer linear bilevel programming problems (MILBP) (Zeng and An 2014; Hemmati and Smith 2016; Fischetti et al. 2016; Yue et al. 2019).

In literature, others looked at scheduling based on a bilevel problem. Avraamidou and Pistikopoulos (2019) proposed an algorithm based on multi-parametric programming to solve a MILBP. In their case study, the authors design and schedule a process with two production stages for three products. Yokoyama et al. (2019) solve a MILBP between a central power energy system and a distributed co-generation system. The problem is solved by an algorithm that uses a Karush-Kuhn-Tucker reformulation. Kostarelou and Kozanidis (2021) propose a heuristic solution algorithm to solve a MILBP for the optimal price-bidding in day-ahead electricity markets. In the MILBP, the upper level is the electricity producer and the lower level is a electricity consumer. The heuristic solution algorithm is compared to an exact solution algorithm and shows less computational requirements. Recently, Wogrin et al. (2020) present a review on applications of bilevel optimization in energy and electricity markets. As a challenge for further research, the authors identify lower-level problems including unit-commitment constraints with binary variables.

The production system considered in this paper results in a MILBP with coupling equality constraints, where the lower-level problem has unit commitment constraints with binary variables, i.e., binary variables if a unit is idle or running and binary variables for modeling part-load performance. For its solution, we build on our previous work (Djelassi et al. 2019) that provides an extension of the methods in Mitsos et al. (2008) and Mitsos (2010). The extension allows the presence of coupling equality constraints. We use our previously proposed algorithm since this algorithm precedes other algorithms, which allowed us to collect lots of experience with this algorithm. From this experience and the performance in applications of industrial-scale problems, we expect a good performance of the algorithm. Furthermore, the original algorithm can solve bilevel problems involving non-linearities. In the algorithm proposed in this paper, we could model non-linearities in the upper-level problem.

The algorithms from our previous work (Mitsos et al. 2008; Mitsos 2010) solve bilevel programs by successively approximating the response of the lower-level program by a discretization of the lower-level feasible set. In Djelassi et al. (2019), we cope with the presence of coupling equality constraints by separating the lower-level variables into independent and dependent variables. Then, the independent variables are discretized as per the original algorithms, while the dependent variables are represented as variables which are fixed by the coupling equality constraints.

On the one hand, the bilevel problem of production system scheduling with an energy system as follower is a special case to the one considered in Djelassi et al. (2019), which allows us to skip certain subproblems of the algorithm. On the other hand, in Djelassi et al. (2019) we assume a known set of dependent lower-level variables, which are fixed uniquely by the coupling equality constraints. In our case, this assumption is violated in the sense that there exists no fixed set of dependent variables but rather a known number of dependent variables. For this purpose, we propose a procedure that determines the set of dependent variables. The choice of the dependent variable changes based on the energy system’s optimal solution. The identification of the dependent variables is part of an augmented algorithm.

This paper is organized as follows. In Sect. 2, we present the bilevel problem to be solved, i.e., scheduling of production and energy system. In Sect. 3, the algorithm is presented as well as the optimization problems used in the algorithm. In Sect. 4, we apply the algorithm to two case studies. The case studies are based on the production scheduling example from Kondili et al. (1993) and the energy system model from Voll et al. (2013) and are extended to a bilevel problem. With the case studies, we present the performance of the algorithm, and demonstrate the merits to solve bilevel problems instead of integrated and sequential optimization problems. For comparison, we also apply the method from Leenders et al. (2019a) for incomplete information exchange to the case studies. In Sect. 5, conclusions are presented.

2 Bilevel problem for scheduling production and energy systems

In this section, first, we introduce the bilevel problem to be solved, i.e., scheduling of production and energy systems. Second, we analyze the properties of the lower-level problem. With the properties, we devise a method for generating discretization points.

2.1 Formulation of the bilevel problem

The bilevel problem considers scheduling the production system in the upper level and scheduling the energy system in the lower level. The decision variables of the upper level, i.e., production systems, are the continuous variables \(\mathbf{x } \in {\mathbb {R}}^{n_x}\) and the binary variables \(\mathbf{y } \in \{0,1\}^{n_y}\). \(\mathbf{x }\) includes the energy demand \({\dot{E}}_{t,e}^\text {demand}\) in each time step t and for each energy form e. We denote the joint upper-level variables as \(\mathbf{w }:=(\mathbf{x },~ \mathbf{y })\). The decision variables of the lower level, i.e., energy system, have the same notation as it is common in energy system modeling and are the power supplied by the energy conversion units \(\dot{\mathbf{V }}'\in {\mathbb {R}}^{n_V}\) and the operational state of the energy conversion units \(\mathbf{o }' \in \{0,1\}^{n_o}\). As it is the common notation in bilevel modeling, the decision variables of the lower level are written with a prime symbol \('\). For the representation of the lower-level variables in the upper-level problem, the prime symbol \('\) is omitted. The mixed-integer linear bilevel problem (MILBP) considered in this paper has the following form:

$$\begin{aligned} \min _{\mathbf{w }, \dot{\mathbf{V }}, \mathbf{o }, {\dot{E}}_{t,e}^\text {demand}}\,&~f^\text {u} (\mathbf{w }, \dot{\mathbf{V }}, \mathbf{o }) = {\mathbf{c }^\text {PS}}^{T} \mathbf{w } + {\mathbf{c }^\text {U,ES,V}}^{T} \dot{\mathbf{V }} + {\mathbf{c }^\text {U,ES,o}}^{T} \mathbf{o } \end{aligned}$$
(1)
$$\begin{aligned} \text {s.t. }&\mathbf{A }^\text {PS} \mathbf{w }\le \mathbf{b }^\text {PS} \end{aligned}$$
(2)
$$\begin{aligned}&(\dot{\mathbf{V }}, \mathbf{o }) \in \arg \min _{\dot{\mathbf{V }}', \mathbf{o }'}~~f^\text {l}(\dot{\mathbf{V }}', \mathbf{o }')={\mathbf{c }^\text {L,ES,V}}^{T} \dot{\mathbf{V }}' + {\mathbf{c }^\text {L,ES,o}}^{T} \mathbf{o }' \end{aligned}$$
(3)
$$\begin{aligned}&~~~~~~~~~~~~~~\text {s.t. }\sum _{u \in U}{{{\dot{V}}_{t,u,e}}^{'}}={\dot{E}}_{t,e}^\text {demand}, \forall t\in T, e\in E \end{aligned}$$
(4)
$$\begin{aligned}&~~~~~~~~~~~~~~~~~~~\dot{\text {V}}_{t,u,e}^{-}(o_{t,u}') \le {\dot{V}}_{t,u,e}' \le \dot{\text {V}}_{t,u,e}^{+}(o_{t,u}'), \forall t \in T, u \in U, e\in E \end{aligned}$$
(5)
$$\begin{aligned}&~~~~~~~~~~~~~~~~~~~\text {a}_{u} \cdot o_{t,u}'= \text {b}_{u} \cdot {\dot{V}}_{t,u,e_1}' -{\dot{V}}_{t,u,e_2}', \forall t \in T, (u,e_1,e_2) \in C \end{aligned}$$
(6)

The upper-level optimization problem (scheduling of the production system) is presented in Eqs. (1) and (2) and the lower-level optimization problem (scheduling of energy system) in Eqs. (3)–(6).

The upper-level objective \(f^\text {u}(\mathbf{w }, \dot{\mathbf{V }}, \mathbf{o })\) considers production cost \({\mathbf{c }^\text {PS}}^{T} \mathbf{w }\) and energy cost to be paid by the production system \({\mathbf{c }^\text {U,ES,V}}^{T} \dot{\mathbf{V }} + {\mathbf{c }^\text {U,ES,o}}^{T} \mathbf{o }\). The vectors \({\mathbf{c }^\text {PS}}^{T}\), \({\mathbf{c }^\text {U,ES,V}}^{T}\) and \({\mathbf{c }^\text {U,ES,o}}^{T}\) describe the cost depending on the upper- and lower-level variables. \(\mathbf{w }\) are the upper-level variables, and thus, the variables of the production system. \(\dot{\mathbf{V }}\) and \(\mathbf{o }\) represent the lower-level variables in the upper level. Constraints of the upper level consider the production recipe, task duration, etc. Here, we model the production system as a mixed-integer linear problem and summarize the constraints in matrix form with \(\mathbf{A }^\text {PS}\) and \(\mathbf{b }^\text {PS}\) as parameters of the production system. In the case study, we model the production system as a batch production system and use the State-Task-Network formulation (Kondili et al. 1993). However, also other models of the production system could be used in the upper level.

The lower-level objective \(f^\text {l}(\dot{\mathbf{V }}', \mathbf{o }')\) considers cost of the energy system \({\mathbf{c }^\text {L,ES,V}}^{T} \dot{\mathbf{V }}'\) \(+{\mathbf{c }^\text {L,ES,o}}^{T} \mathbf{o }'\) to supply the production system with energy. \({\mathbf{c }^\text {L,ES,V}}^{T}\) and \({\mathbf{c }^\text {L,ES,o}}^{T}\) are vectors for the cost depending on the lower-level variables. The lower-level constraints consider energy balances, part-load performance, the operational limits of energy conversion units etc. \(\dot{\mathbf{V }}'\) is a vector of the power \({\dot{V}}_{t,u,e}'\) of energy form e provided by energy conversion unit u in time step t. \(\mathbf{o }'\) is a vector of the operational state \(o_{t,u}'\) of energy conversion unit u in time step t. \(o_{t,u}'\) is a binary variable and equals 1 if energy conversion unit u is operated in time step t. \(\dot{\mathbf{V }}'\) and \(\mathbf{o }'\) are the decision variables of the energy system.

The coupling equality constraints between lower and upper level, i.e., energy balances, are stated separately (Eq. (4)). In the coupling equality constraints, variables of the upper level are the energy demands of the production system \({\dot{E}}_{t,e}^\text {demand}\) for each energy form e in time step t. To clarify that this is an upper level decision variable, we also write \({\dot{E}}_{t,e}^\text {demand}\) under the min operator, even if it is an entry of the vector \(\mathbf{w }\). Variables of the lower level in the coupling equality constraints are the power \({\dot{V}}_{t,u,e}'\) of energy form e provided by energy conversion unit u in time step t.

In general, the behavior of energy conversion units is nonlinear, e.g., by a variable efficiency (Goderbauer et al. 2016). As it is common in energy system modeling, we linearize this nonlinear unit behavior by piecewise-affine linear functions (Voll et al. 2013). For an easier separation into dependent and independent variables in the proposed algorithm (c.f. Sect. 3.2), we model each segment of the piecewise-affine linear function as a separate energy conversion unit. Their operational states are connected via constraints. In the case study, we use the energy system model from Voll et al. (2013). However, also other energy system models could be used in the lower-level problem. Still, the part-load performance needs to be modeled by piecewise-affine functions, and all equations need to be linear as we assume this in our proof (Sect. 2.2 and Appendix B).

Here, all inequality constraints of the lower level are reformulated as parametric upper and lower bounds of the entries of \(\dot{\mathbf{V }}'\). Thereby, \(\dot{\text {V}}_{t,u,e}^{-}(o_{t,u}')\) and \(\dot{\text {V}}_{t,u,e}^{+}(o_{t,u}')\) are affine linear functions (Eq. (5)). In Eq. (6), the connection between two energy forms is modeled. These connections appear only for specific energy conversion units, e.g., combined-heat-and-power engines which supply electricity and heat simultaneously. These energy conversion units u with the corresponding two energy forms \(e_1\) and \(e_2\) are summarized in the set C. \(\text {a}_{u}\) and \(\text {b}_{u}\) are parameters to describe the connection between the energy forms.

2.2 Properties of the lower-level problem

The purpose of the energy system model (lower-level problem) is to identify optimal schedules with a medium time resolution, e.g., one hour. Thus, we neglect dynamics such as ramping constraints. Furthermore, we model an energy system without storage. Hence, no constraints to connect time steps need to be considered within the energy system model. Still, the algorithm is suitable to consider storage units, ramping constraints, and other constraints that connect time steps. For this purpose, the discretization points introduced later need to be defined for a specific energy-demand curve and not for single energy demands. We expect that this extension would result in increased computational times.

In this paper, the lower-level decisions at one time step are independent of the decisions at all other time steps. Therefore and by linearity of the lower-level objective, the lower-level problem can be decomposed in a lower-level problem for each time step. The optimization problem of the lower level for a single time step t is:

$$\begin{aligned} \min _{\dot{\mathbf{V }}_{t}, \mathbf{o }_{t}}&f^\text {l}_{t}(\dot{\mathbf{V }}_{t}, \mathbf{o }_{t})={\mathbf{c }_t^\text {L,ES,V}}^{T} \dot{\mathbf{V }}_{t} + {\mathbf{c }_t^\text {L,ES,o}}^{T} \mathbf{o }_{t} \end{aligned}$$
(7)
$$\begin{aligned}&\text {s.t. } \sum _{u \in U}{{{\dot{V}}_{t,u,e}}}={\dot{E}}_{t,e}^\text {demand}, \forall e\in E \end{aligned}$$
(8)
$$\begin{aligned}&~~~~~\dot{\text {V}}_{t,u,e}^{-}(o_{t,u}) \le {\dot{V}}_{t,u,e} \le \dot{\text {V}}_{t,u,e}^{+}(o_{t,u}), \forall u \in U, e\in E \end{aligned}$$
(9)
$$\begin{aligned}&~~~~~\text {a}_{u} \cdot o_{t,u}= \text {b}_{u} \cdot {\dot{V}}_{t,u,e_1} - {\dot{V}}_{t,u,e_2}, \forall (u,e_1,e_2) \in C. \end{aligned}$$
(10)

The decision variables of the lower level are the output power of the energy conversion units \(\dot{\mathbf{V }}_{t}\) and the operational state of the energy conversion units \(\mathbf{o }_{t}\).

In Sect. 3, we present the algorithm to solve the bilevel problem from Eqs. (1)–(6). In the algorithm, we use the property that there always exists an optimal solution of the lower-level problem where all except one energy conversion unit per energy form e are operated at one of their operational limits, which we prove in the following two Propositions.

Proposition 1

Let the lower-level problem be given for a single energy form e and one time step t as

$$ \begin{aligned} \min _{\dot{\mathbf{V}}_{t,e}, \mathbf{o}_{t}}&f^\text {l}_{t,e}(\dot{\mathbf{V}}_{t,e}, \mathbf{o}_{t})\ \ \quad\quad ={\mathbf{c}_{t,e}^\text {L,ES,V}}^{T} \dot{\mathbf{V }}_{t,e} + {\mathbf{c }_{t}^\text {L,ES,o}}^{T} \mathbf{o}_{t}\\&\text {s.t. }\sum _{u \in U}{{{\dot{V}}_{t,u,e}}} \quad \quad ={\dot{E}}_{t,e}^\text {demand}\\&~~~~~\dot{\text {V}}_{t,u,e}^{-}(o_{t,u}) \quad \quad \le {\dot{V}}_{t,u,e} \le \dot{\text {V}}_{t,u,e}^{+}(o_{t,u}), \forall u \in U \end{aligned} $$
(11)

Therein, \(\dot{\mathbf{V }}_{t,e}\) is the vector of power supplied by the energy conversion units and \(\mathbf{o }_{t}\) is the vector of the operational state of each energy conversion unit. Note that the constraints to connect the energy forms (Eq. (10)) are omitted because only one energy form is considered.

For this problem, there exists an optimal solution in which at most one energy conversion unit is not operated at one of its operating limits. More precisely, let Problem (11) be feasible and let \((\mathbf{o }_{t}^*, \dot{\mathbf{V }}_{t,e}^*)\) be globally optimal in Problem (11). Then, there exists a solution \((\mathbf{o }_{t}^*, \tilde{\dot{\mathbf{V }}}_{t,e}\)) that is also globally optimal in Problem (11) and for which there exists at most one \(u \in U\) such that

$$\begin{aligned} \dot{\text {V}}_{t,u,e}^-(\mathbf{o }_{t}^*)< \tilde{{\dot{V}}}_{t,u,e} < \dot{\text {V}}_{t,u,e}^+(\mathbf{o }_{t}^*). \end{aligned}$$
(12)

Proof

Consider the case that \((\mathbf{o }_{t}^*, \dot{\mathbf{V }}_{t,e}^*)\) is given such that for zero or one \(u \in U\) the following equation hold:

$$\begin{aligned} \dot{\text {V}}_{t,u,e}^-(\mathbf{o }_{t}^*)< {\dot{V}}_{t,u,e}^* < \dot{\text {V}}_{t,u,e}^+(\mathbf{o }_{t}^*). \end{aligned}$$
(13)

Then, the result is proven immediately with \(\tilde{\dot{\mathbf{V }}}_{t,e} = \dot{\mathbf{V }}_{t,e}^*\).

Now consider instead that \(u_1, u_2 \in U, u_1 \ne u_2\) be given such that

$$\begin{aligned} \dot{\text {V}}_{t,u,e}^-(\mathbf{o }_{t}^*)< {\dot{V}}_{t,u,e}^* < \dot{\text {V}}_{t,u,e}^+(\mathbf{o }_{t}^*), \quad \forall u \in \{u_1, u_2\} \end{aligned}$$
(14)

and

$$\begin{aligned} {\dot{V}}_{t,u,e}^* = \dot{\text {V}}_{t,u,e}^-(\mathbf{o }_{t}^*) \vee {\dot{V}}_{t,u,e}^* = \dot{\text {V}}_{t,u,e}^+(\mathbf{o }_{t}^*), \quad \forall u \in U \setminus \{u_1, u_2\}. \end{aligned}$$
(15)

Then, it follows from construction of Eq. (11) that all elements of the set

$$\begin{aligned} \begin{aligned} M = \{(\mathbf{o }_{t}^*, \dot{\mathbf{V }}_{t,e}) |&{\dot{V}}_{t,u,e} = {\dot{V}}_{t,u,e}^*, \forall u \in U \setminus \{u_1, u_2\}\\&\wedge \dot{\text {V}}_{t,u,e}^-(\mathbf{o }_{t}^*) \le {\dot{V}}_{t,u,e} \le \dot{\text {V}}_{t,u,e}^+(\mathbf{o }_{t}^*), \forall u \in \{u_1, u_2\}\\&\wedge {\dot{V}}_{t,u=u_1,e} + {\dot{V}}_{t,u=u_2,e} = {\dot{V}}_{t,u=u_1,e}^* + {\dot{V}}_{t,u=u_2,e}^*\} \end{aligned} \end{aligned}$$
(16)

are feasible in Eq. (11). \(\dot{\mathbf{V }}_{t,e}^*\) is an optimal solution of an linear program on a facet of the feasible set. Accordingly, all points on that facet (points in M) are optimal in Eq. (11).

The point \((\mathbf{o }_{t}^*, \tilde{\dot{\mathbf{V }}}_{t,e})\) with \(\tilde{{\dot{V}}}_{t,u,e} = {\dot{V}}_{t,u,e}^*, \forall u \in U \setminus \{u_1, u_2\}\) and

$$\begin{aligned} \begin{aligned} \tilde{{\dot{V}}}_{t,u=u_1,e}&= {{\dot{V}}}_{t,u=u_1,e}^* + \min \{{{\dot{V}}}_{t,u=u_1,e}^+(\mathbf{o }_{t}^*) - {{\dot{V}}}_{t,u=u_1,e}^*, {{\dot{V}}}_{t,u=u_2,e}^* - {{\dot{V}}}_{t,u=u_2,e}^-(\mathbf{o }_{t}^*)\}\\ \tilde{{\dot{V}}}_{t,u=u_2,e}&= {{\dot{V}}}_{t,u=u_2,e}^* - \min \{{{\dot{V}}}_{t,u=u_1,e}^+(\mathbf{o }_{t}^*) - {{\dot{V}}}_{t,u=u_1,e}^*, {{\dot{V}}}_{t,u=u_2,e}^* - {{\dot{V}}}_{t,u=u_2,e}^-(\mathbf{o }_{t}^*)\} \end{aligned} \end{aligned}$$
(17)

lies within M and satisfies either \(\tilde{{\dot{V}}}_{t,u=u_1,e} = {\dot{V}}_{t,u=u_1,e}^+(\mathbf{o }_{t}^*)\) or \(\tilde{{\dot{V}}}_{t,u=u_2,e} = {\dot{V}}_{t,u=u_2,e}^-(\mathbf{o }_{t}^*)\), proving the desired property. Note that in an optimal solution where two energy conversion units are not operated at their operational limits the cost factors \({c_{t,u,e}^\text {L,ES,V}}\) for these energy conversion units are equal. Otherwise, a change in the supplied power by the energy conversion units could result in a lower objective function value.

Finally, if there are more than two \(u \in U\) with \(\dot{\text {V}}_{t,u,e}^-(\mathbf{o }_{t}^*)< {\dot{V}}_{t,u,e}^* < \dot{\text {V}}_{t,u,e}^+(\mathbf{o }_{t}^*)\), the above construction can be applied successively until the same result is reached. \(\square \)

We proved that there exists a solution for which only one energy conversion unit is not operated at one of its operational limits if there is only one form of energy e. More generally, in Appendix B, we show that the number of energy conversion units not operated at one of their operational limits can be reduced to the number of energy forms or below.

3 Algorithm to solve the bilevel problem

In Sects. 3.13.3, we first present the algorithm and second, in Sect. 3.4, we present the optimization problems considered in the algorithm, i.e., lower-bounding problem, lower-level problem, and auxiliary problem.

3.1 Algorithm

The proposed algorithm is based our algorithm from Djelassi et al. (2019). In Djelassi et al. (2019) we use discretization points from optimal lower-level solutions for representing the lower-level objective in the upper-level problem. We assume that the lower-level variables are split into sets of dependent and independent variables. These sets are treated then differently in the discretization: independent variables are fixed and dependent variables are determined by the equality constraints.

In the bilevel problem in this paper, the choices for dependent and independent variables change for each discretization point. In the previous section and in the appendix, we proved that there are at most as many energy conversion units not operated at their operational limits as there are energy forms e considered. Thus, we can always set the power of the energy conversion units not operated at their operational limits as the dependent variables. The power supply by the energy conversion units operated at their operational limits are then the independent variables. Hence, there are at most as many dependent variables in an optimal solution point of the lower-level problem as energy forms are supplied by the energy system (c.f. Sect. 2.2).

We use these properties to identify discretization points from lower-level solutions, which means we identify independent and dependent variables. Thereby, the algorithm can solve the mixed-integer linear bilevel problem of production and energy system scheduling stated in Sect. 2.1.

In the following Sect. 3.2, we introduce the discretization points used in the algorithm. Afterward, we present the steps of the algorithm in Sect. 3.3.

3.2 Discretization points

A discretization point defines the independent and dependent variables for an optimal lower-level solution. Therein, the independent variables are fixed and the dependent variables are determined by the equality constraints. Discretization points are used to represent optimal lower-level solutions in the upper-level problem.

In the bilevel problem of scheduling production and energy systems, the energy balances are the only coupling constraints between the upper- and the lower-level problem. The energy balance is given in Eq. (4) and repeated here:

$$\begin{aligned} \sum _{u \in U}{{{\dot{V}}_{t,u,e}}}={\dot{E}}_{t,e}^\text {demand}, \forall t\in T, e\in E. \end{aligned}$$
(18)

The energy demands \({\dot{E}}_{t,e}^\text {demand}\) are the upper-level variables in the energy balance and the powers \({\dot{V}}_{t,u,e}\) provided by each energy conversion unit u are the lower-level variables. Thus, the only variable from the upper-level problem in the lower-level problem are the energy demands \({\dot{E}}_{t,e}^\text {demand}\). Since discretization points are used to define optimal lower-level solutions in the upper level, discretization points are defined for given energy demands \({\dot{E}}_{t,e}^\text {demand}\). Thus, discretization points indicate the power supplied by each energy conversion unit if a particular energy demand occurs.

In Sect. 2.2 and Appendix B, we proved that there exists an optimal solution in which the number of energy conversion units not operated at one of their operational limits is less or equal to the number of energy forms e considered. We identify this optimal solution in the auxiliary problem (Sect. 3.4.3). This optimal solution is only valid for a specific energy demand. However, suppose we vary this energy demand, keep the power of the energy conversion units operated at their operational limits fixed, and compensate for the variation by adjusting the power of the energy conversion units not operated at their operational limits. In that case, the solution is still feasible until an energy conversion unit exceeds its operational limits. In this range of validity, the lower-level objective function value identified by the discretization point provides a lower-level feasible solution and, therefore, an upper bound of the lower-level objective function. Still, within the range of validity of a discretization point, another discretization point can give a tighter upper bound. We call the energy conversion units not operated at their operational limits free energy conversion units. These units define the dependent variables. The energy conversion units operated at their operational limits are named discretized energy conversion units and are the independent variables. For discretized energy conversion units, the operation is fixed in the discretization point k. These energy conversion units are either idle (index-set: \(D_{k}^\text {zero}\)) or operated at their minimal or maximal load (index-sets: \(D_{k}^\text {min}\) and \(D_{k}^\text {max}\)). Thus, the energy \({\dot{V}}^\text {D}_{k,t,u=d, e}\) supplied by these discretized energy conversion units is fixed in the discretization point k:

$$\begin{aligned} {\dot{V}}^\text {D}_{k,t,u=d, e}&=0,&\forall k \in K, t \in T, d \in D_{k}^\text {zero}, e \in E \end{aligned}$$
(19)
$$\begin{aligned} {\dot{V}}^\text {D}_{k,t,u=d, e}&= \dot{\text {V}}^\text {min}_{u=d, e},&\forall k \in K, t \in T, d \in D_{k}^\text {min}, e \in E \end{aligned}$$
(20)
$$\begin{aligned} {\dot{V}}^\text {D}_{k,t,u=d, e}&= \dot{\text {V}}^\text {max}_{u=d, e},&\forall k \in K, t \in T, d \in D_{k}^\text {max}, e \in E. \end{aligned}$$
(21)

Here, \(\dot{\text {V}}^\text {min}_{u, e}\) and \(\dot{\text {V}}^\text {max}_{u, e}\) are the minimal and maximal load of energy conversion unit u, respectively.

For each discretization point k, time point t, and energy form e, the power of one energy conversion unit u is not fixed, and thus, is free. These free energy conversion units are summarized by the set \(d^\text {free}_{k,f}\). The index f counts the free energy conversion units for each discretization point k.

To fulfill each energy demand, the power of the free energy conversion units \({\dot{V}}^\text {D}_{k,t,u=d^\text {free}_{k,f}, e} \) is not limited. This unlimited power can lead to power values \({\dot{V}}^\text {D}_{k,t,u=d^\text {free}_{k,f},e}\) outside the operational limits of the free energy conversion unit. Outside the operational limits, the upper bound on the lower-level objective function is not considered anymore (c.f. Appendix A, Eq. (22) and Eq. (23)).

3.3 Steps of the algorithm

Algorithm 1 solves the MILBP by a lower-bounding problem, lower-level problem and auxiliary problem. The lower-bounding problem is a finite (discretization-based) relaxation of the MILBP. The lower-level problem is solved for fixed upper-level variables. The lower-level optimal solution is used to evaluate the upper-level objective to generate an upper bound. This upper bound is valid in our case since there are no upper-level constraints depending on the lower-level variables. Bilevel optimality of the upper-bounding solution is assessed based on the lower bound provided by the lower-bounding problem. In an auxiliary problem, discretization points are identified from the solutions of the lower-level problem. The algorithm repeatedly solves these problems while the lower-bounding problem is tightened by adding discretization points until the optimality tolerance \(\epsilon ^\text {u}\) between upper and lower bound is reached.

figure a

Our algorithm exploits the structure of the lower-level problem. In the lower-level problem, all constraints are written for each time step and no constraint connect the time steps. The objective function only sums the cost of each time step. Thus, the lower-level problem can be decomposed into individual optimization problems for each time step t. Each of these individual optimization problems is parameterized only by its energy demand \({\dot{E}}_{t,e}^\text {demand}\). The solution obtained at one time step constitutes a valid discretization point for all time steps because discretization points are defined for energy demands in a single time step which can occur in multiple time steps. Thus, probably fewer iterations are needed to solve the bilevel problem. In general, the algorithm might also be suitable to consider constraints that connect time steps in the lower-level constraints. In this case, each discretization point defines the lower-level solution for a specific energy-demand curve of the whole time horizon.

The algorithm terminates in finite time because there is a finite number of possible discretization points. The number is finite because there is a maximum number of combinations of free energy conversion units and discretized energy conversion units. In the worst case, an enumeration of all the discretization points would be necessary. However, in our applications of the algorithm, we observe that the algorithm does much better in practice and only needs a few iterations.

3.4 Subproblems of the algorithm

In this section, we present the optimization problems considered in the algorithm: lower-bounding problem, lower-level problem and auxiliary problem. To make the explanation more specific, we present the algorithm for the supply of two energy forms e, i.e., heat and electricity. These energy forms are assumed to be supplied by boilers, combined-heat-and-power engines, and electricity grids.

3.4.1 Lower-bounding problem (LBD)

The lower-bounding problem is the upper-level optimization problem (production system) while considering the constraints of the lower-level problem (energy system) and the lower-level objective by discretization points.

In the 1st iteration and, thus, without discretization points, the lower-bounding problem is composed from Eqs. (1), (2), (4), (5) and (6). Thus, in the 1st iteration, the lower-bounding problem corresponds to the integrated scheduling, where the production system has full control over the energy system.

After the 1st iteration, the optimal solutions of lower-level problems are considered by discretization points K. A discretization point represents the optimal solution of the lower-level problem for a particular energy demand. The lower level’s objective resulting from a discretization point \(\text {f}_{k,t}^\text {l,Discr. Point}\) is an upper bound on the lower-level objective \(f_{t}^\text {l,LBD}\) in the discretizaion points range of validity (Sect. 3.2). We model this upper bound by a big-M formulation:

$$\begin{aligned} f_{t}^\text {l,LBD} \le \text {f}_{k,t}^\text {l,Discr. Point} + \text {M}^\text {obj} \cdot (1-\beta _{k,t}^\text {obj}), \forall k \in K, t \in T. \end{aligned}$$
(22)

The objective function value is only constrained if the binary variable \(\beta _{k,t}^\text {obj}\) equals 1. \(\beta _{k,t}^\text {obj}\) equals 1 if the power of the free energy-conversion units is within the range of validity of the discretization point. Note that for a specific energy demand multiple discretization points can give an upper bound on the objective function.

The binary variables \(\beta _{k,t,f}^\text {lower}\) and \(\beta _{k,t,f}^\text {upper}\) identify if the power of the free energy conversion unit \({\dot{V}}^\text {D}_{k,t,u=d^\text {free}_{k,f}, e}\) is lower or higher than the operational limits. Thus, Eq. (23) ensures that the upper bound on the objective function in Eq. (22) is used if the power of the free energy conversion units is within their operational limits:

$$\begin{aligned} \sum _{f \in \{1,2\}} (\beta _{k,t,f}^\text {upper}+\beta _{k,t,f}^\text {lower})+\beta _{k,t}^\text {obj} \ge 1, \forall k \in K, t \in T. \end{aligned}$$
(23)

In Appendix A, equations are stated to identify if the power of the free energy conversion units is within the operational limits.

3.4.2 Lower-level problem (LLP)

The lower-level problem is the operation optimization of the energy system for a given energy demand. The lower-level problem can be solved independently for each time step t because there are no constraints that connect time steps in the lower-level. The lower-level problem was already stated in Eqs. (7)-(10). Compared to the algorithm in Djelassi et al. (2019), here we do not have to evaluate in the upper-bounding problem if the lower-level solution is feasible for the upper level. The evaluation is not necessary, since there are no lower-level variables in the constraints of the upper level. Hence, we can directly use the lower-level problem solutions to evaluate the upper-level objective.

3.4.3 Auxiliary problem

The auxiliary problem identifies the discretization points from each lower-level solution. In discretization points, as few as possible energy conversion units are not operated at their operational limits. Thus, the objective of the auxiliary problem is to minimize the number of free energy conversion units (units that are not operated at their operational limits) while retaining the objective of the lower-level solution. The auxiliary problem considers the constraints of the lower-level problem. Because no constraints connecting time steps are considered in the lower-level problem, an auxiliary problem can be solved for each time step.

For each energy conversion unit, we define the 4 binary variables \(\alpha _{t,u}^{\text {min}}\), \(\alpha _{t,u}^{\text {max}}\), \(\alpha _{t,u}^{\text {zero}}\) and \(\alpha _{t,u}^{\text {free}}\). \(\alpha _{t,u}^{\text {min}}\) and \(\alpha _{t,u}^{\text {max}}\) identify if the energy conversion unit is operated at its minimal or maximal operational limit, respectively. \(\alpha _{t,u}^{\text {zero}}\) identifies if the energy conversion unit is idle. \(\alpha _{t,u}^{\text {free}}\) identifies if the energy conversion unit is operated between its operational limits.

The objective function of the auxiliary problem

$$\begin{aligned} \min _{ \dot{\mathbf{V }}^\text {aux}_{t}, \mathbf{o }^\text {aux}_t} {\sum _{u \in U}{\alpha _{t,u}^{\text {free}}}} \end{aligned}$$
(24)

is the minimization of the number of free energy conversion units in time step t.

In the constraints, the objective function value of the lower-level problem calculated with the variables of the auxiliary problem \(f_{t}^\text {l,aux}\) needs to be equal or lower than the objective function value from the lower-level problem \(\text {f}_{t}^\text {l,LLP}\):

$$\begin{aligned} f_{t}^\text {l,aux} \le \text {f}_{t}^\text {l,LLP}. \end{aligned}$$
(25)

The constraints of the lower-level problem need to hold in the auxiliary problem (Eqs. (8)–(10)). Additional constraints define the 4 binary variables \(\alpha _{t,u}^{\text {min}}\), \(\alpha _{t,u}^{\text {max}}\), \(\alpha _{t,u}^{\text {zero}}\) and \(\alpha _{t,u}^{\text {free}}\).

An energy conversion unit u is either operated at its operational limits, operated between its operational limits (free), or idle. Thus, for the sum of the binary variables we can state:

$$\begin{aligned} \alpha _{t,u}^{\text {min}} + \alpha _{t,u}^{\text {max}} + \alpha _{t,u}^{\text {zero}} + \alpha _{t,u}^{\text {free}}=1, \forall u \in U. \end{aligned}$$
(26)

As stated at the beginning of Sect. 3.4, we show the equations to identify the energy conversion units at their operational limits for electricity grids, boilers and combined-heat-and-power engines. Electricity grids are an example of energy conversion units without an operational limit. Boilers and combined-heat-and-power engines are examples for energy conversion units with upper and lower operational limits. Combined-heat-and-power engines are also an example for energy conversion units connecting two energy forms.

We model two electricity grids, one for the supply with electricity and one for the feed-in of electricity into the grid. For the electricity grids, the 4 binary variables are defined in the following: The electricity grids have no upper operational limits and zero is the lower operational limit of the electricity grids. Thus, \(\alpha _{t,u}^{\text {max}}\) and \(\alpha _{t,u}^{\text {zero}}\) are defined to be zero:

$$\begin{aligned} \alpha _{t,u}^{\text {max}}=0, \forall u \in D^\text {Grid} \end{aligned}$$
(27)
$$\begin{aligned} \alpha _{t,u}^{\text {zero}}=0, \forall u \in D^\text {Grid}. \end{aligned}$$
(28)

\(D^\text {Grid}\) is a set containing all electricity grids.

We identify if the electricity grid is at the lower operational limit (\(\alpha _{t,u}^{\text {min}}=1\)) by:

$$\begin{aligned} {\dot{V}}_{t,u,e=\text {el}}^\text {aux} \le (1-\alpha _{t,u}^{\text {min}}) \cdot \text {M}_{e=\text {el}}^\text {max}, \forall u \in D^\text {Grid}. \end{aligned}$$
(29)

\(\text {M}_{e=\text {el}}^\text {max}\) is a sufficiently large number such that the electricity demand from the electricity grid or the electricity supply to the electricity grid never exceeds this number. Thus, a electricity grid is identified as the free energy conversion unit for electricity (\(\alpha _{t,u}^{\text {free}}=\) 1) if the power \({\dot{V}}_{t,u,e=\text {el}}^\text {aux}\) is greater than 0.

The constraints to define the 4 binary variables for boilers and combined-heat-and-power engines are given in the following: heat and electricity outputs are connected for a combined-heat-and-power engine. Thus, if a combined-heat-and-power engine is operated at its operational limit in heat supply, also the operational limit in the electricity supply is reached. Consequently, we identify if a combined-heat-and-power engine is operated at its operational limit only for one energy form, i.e., heat. We identify if the power of a combined-heat-and-power engine or a boiler is at its lower operational limit by:

$$ {\dot{V}}_{t,u,e=\text {heat}}^\text {aux} \le\dot{\text {V}}^\text {max}_{u,e= \text {heat}} - \alpha _{t,u}^{\text {min}} \cdot (\dot{\text {V}}^\text {max}_{u,e= \text {heat}}-\dot{\text {V}}^\text {min}_{u,e=\text {heat}}), \nonumber \forall u \in D^{\text {CHP}} \cup D^{Boiler}.$$
(30)

If \(\alpha _{t,u}^{\text {min}}\) equals 0, the supplied power \({\dot{V}}_{t,u,e=\text {heat}}^\text {aux}\) needs to be lower or equal than the heat supply in maximal load \(\dot{\text {V}}^\text {max}_{u,e=\text {heat}}\). If \(\alpha _{t,u}^{\text {min}}\) equals 1, the supplied power \({\dot{V}}_{t,u,e=\text {heat}}^\text {aux}\) needs to be lower or equal than the heat supply in minimal part-load \(\dot{\text {V}}^\text {min}_{u,e=\text {heat}}\) . Since the other constraints require that if a unit is operated the supplied power is greater or equal than the minimal part-load, the unit is operated at its minimal operational limit. \(D^{CHP}\) and \(D^{Boiler}\) are sets with all combined-heat-and-power engine and boilers, respectively.

If a combined-heat-and-power engine or a boiler is operated at its upper operational limit \(\dot{\text {V}}^\text {max}_{u,e=\text {heat}}\) is identified by:

$$ {\dot{V}}_{t,u,e=\text {heat}}^\text {aux} \ge\dot{\text {V}}^\text {max}_{u,e=\text {heat}} \cdot \alpha _{t,u}^{\text {max}}, \nonumber \forall u \in D^{\text {CHP}} \cup D^{Boiler}.$$
(31)

A similar explanation as for Eq. (30) applies for the upper operational limit.

Whether a combined-heat-and-power engine or a boiler is idle is identified by checking if the power is within the upper and lower operational limit:

$${\dot{V}}_{t,u,e=\text {heat}}^\text {aux} \ge(1-\alpha _{t,u}^{\text {zero}}) \cdot \dot{\text {V}}^\text {min}_{u,e=\text {heat}}, \nonumber \forall u \in D^{\text {CHP}} \cup D^{Boiler} $$
(32)
$${\dot{V}}_{t,u,e=\text {heat}}^\text {aux} \le(1-\alpha _{t,u}^{\text {zero}}) \cdot \dot{\text {V}}^\text {max}_{u,e=\text {heat}}, \nonumber \forall u \in D^{\text {CHP}} \cup D^{Boiler}.$$
(33)

Thus, if the heat supply \({\dot{V}}_{t,u,e=\text {heat}}^\text {aux}\) is between the operational limits, the binary variables \(\alpha _{t,u}^{\text {min}}\), \(\alpha _{t,u}^{\text {max}}\) and \(\alpha _{t,u}^{\text {zero}}\) are zero and Eq. (26) sets \(\alpha _{t,u}^{\text {free}}\) to 1. In this case, the corresponding unit is identified as a free energy conversion unit for heat.

3.4.4 Integration of auxiliary problem in lower-level problem

It should be mentioned that the auxiliary problem can also be integrated into the lower-level problem if the number of free energy conversion units is known. For this purpose, the following constraints should be added:

$$\begin{aligned} \sum _{u \in U} \alpha _{t,u}^{\text {free}} \le \text {M}^\text {free}, \forall t \in T. \end{aligned}$$
(34)

Again, \(\alpha _{t,u}^{\text {free}}\) identifies if an energy conversion unit u is not operated at its operational limits (\(\alpha _{t,u}^{\text {free}}\)=1). The sum over \(\alpha _{t,u}^{\text {free}}\) is constrained by the number of allowed free energy conversion units \(\text {M}^\text {free}\). For the considered energy system in this paper, the energy system can supply 2 energy forms, and the maximum number of free energy conversion units \(\text {M}^\text {free}\) is 2 (c.f. Sect. 2.2).

In this paper, we use the auxiliary problem and present a more general formulation in which an identification of the number of free energy conversion units is not necessary.

4 Case studies

The algorithm is applied to solve the bilevel problem for scheduling production and energy system to two case studies. The production system is modeled based on the State-Task-Network formulation for batch production systems (Kondili et al. 1993). The production system in the case studies is based on the case study from Kondili et al. (1993) (Fig. 1). In both case studies, we use the same energy system model from Voll et al. (2013). The models of both systems are described in detail in our previous publication (Leenders et al. 2019a).

In the two case studies, the energy systems differ: in the first case study (CHP subsidies), we consider: 3 boilers (\(4\,\hbox {MW}\), \(1.5\,\hbox {MW}\), \(0.5\,\hbox {MW}\)) and 1 combined-heat-and-power engine (\(3.5\,\hbox {MW}\)) which are connected to the electricity grid and the gas grid. In the second case study (Grid alternative), we consider: 3 boilers (\(4\,\hbox {MW}\), \(1.5\,\hbox {MW}\), \(0.5\,\hbox {MW}\)) and 2 combined-heat-and-power engines (\(1.5\,\hbox {MW}\), \(1.5\,\hbox {MW}\)) which are connected to the electricity grid and the gas grid. The big-M parameters in Eqs. (22) and (29) cannot be calculated exactly. Thus, the values need to be defined big enough to properly model the reformulation as well as small enough to prevent bad numerical behavior. In the case studies, we didn’t experience any bad behavior from the choice of our big-M parameters.

For both case studies, we compare the bilevel optimization with three other optimization approaches: integrated optimization, sequential optimization and the method for incomplete information exchange from Leenders et al. (2019a). In the method from Leenders et al. (2019a), the energy system responds approximated demand-dependent energy cost to the production system. The production system uses this information as basis for optimization. Thereby, the production system takes the misaligned objectives into account.

We recall that the integrated optimization of production and energy system optimizes both systems to the objective of the production system (upper-level objective). For the production system, the integrated optimization is the ideal benchmark leading to the lowest cost, since, the energy system is operated in favor of the production system.

The sequential optimization is the most common optimization approach. In the sequential optimization, the production system is first minimized to the production cost. Therein, the production system has no information on the energy system. Thus, just the upper-level problem is solved. The result is the production schedule and the energy demand. Subsequently, the energy system is optimized to the objective of the energy system. The energy demand is given by the previous production system optimization.

If we consider the situation of the production system as the leader and the energy system as the follower, both the integrated and the sequential optimization yield suboptimal solutions for the production system. The solutions are suboptimal because the response of the energy system is too optimistic or not anticipated, respectively. Although the solution of the integrated optimization promises the lowest costs for the production system, the energy system would follow its objective instead of the objective of the production system. To model this behavior, we fix the solution of the integrated optimization for the production system (upper level) variables and optimize subsequently the energy system (lower level). The cost increase for the production system is called regret since it expresses the excess costs that arise if a cooperative energy system is wrongly assumed. In contrast, the bilevel formulation assumes an independent energy system. Thus, the solution of the bilevel formulation provides the minimal realizable cost.

The algorithm and the benchmarks are executed on an Intel(R) Xeon(R) CPU E5-1660 v3 with 3 GHz running on openSUSE Tumbleweed with Kernelversion 4.17.13. The algorithm is implemented and the subproblems are written in C++ based on an early version of libALE (Djelassi and Mitsos 2019). The algorithm works in interaction with GAMS such that the subproblems are automatically formulated with their input data as GAMS code. The subproblems are then solved with GAMS 25.1.3 (GAMS Development 2018) using CPLEX 12.8.0.0 (IBM Corporation 2017) applying 8 threads. The sequential optimization and the integrated optimization problems are also formulated in GAMS 25.1.3 (GAMS Development 2018) and solved with CPLEX 12.8.0.0 (IBM Corporation 2017) applying 8 threads. The time limit for all optimization problems is set to \(1000\,\hbox {s}\), working memory is set to 30 GB, and the allowed absolute gap is \(10^{-3}\). The optimality tolerance of the upper-level objective function \(\epsilon ^\text {u}\) is set to 0.01. We choose such tight tolerances, since the optimization problems are solved fast and, thereby, we can identify the exact benefits of the bilevel solution compared to the common sequential and integrated optimization.

Fig. 1
figure 1

Production system of the case studies. The production system is a batch production system and based on the example of Kondili et al. (1993). The illustration is adapted from Leenders et al. (2019b). The circles represent the states of the products. Thus, S1, S2, and S3 are raw materials, and S7 and S10 are final products. The rectangles represent the tasks. As additional information, the form of the energy demand as well as the equipment that can be used to perform the task is given. The numbers beside the arrows give the production and consumption fraction of the tasks. E: Equipment; S: State; El.: Electricity

4.1 CHP subsidies

In this case study, the energy system gets subsidies for electricity produced by the combined-heat-and-power engines, as it is the case, e.g., in Germany. The subsidies are not forwarded to the production system resulting in misaligned objectives. In Sect. 4.1.1, we describe the detailed setup and objectives. In Sect. 4.1.2, we present and discuss the results of the case study.

4.1.1 Formulation

In the bilevel problem for CHP subsidies, the production system is scheduled in the upper-level problem for minimizing its production and energy cost. In the lower-level problem, the operation of the energy system is optimized. In the lower-level problem, the binary variables are: for each energy conversion unit and time step, a binary variable to decide if the energy conversion unit is operated, and a binary variable that allows to only buy electricity from the grid or either sell electricity to the grid at the same time.

The energy system gets subsidies for electricity produced by the combined-heat-and-power engines, but the subsidies are not forwarded to the production system. The amount of subsidies are the German subsidies paid for combined-heat-and-power engine with a capacity over \({2} \,\hbox {MW}\). The subsidies and energy prices are provided in Table 1. The prices for energy from the grid are not equal in the case studies to distinguish the case studies further.

Table 1 Energy cost and subsidies of case study CHP subsidies. \(p^{CHP,sell}\) and \(p^{CHP,prod}\) are subsidies for electricity from combined-heat-and-power engines sold to the grid or consumed on-site, respectively. \(p^\text {gas}\) is the gas price. \(p^{el,buy}\) and \(p^{el,sell}\) is the electricity price for purchase and selling, respectively

In the following, we present the detailed formulation of the objective functions: The objective function of the production system \(f^\text {u}\) is the production cost \({\mathbf{c }^\text {PS}}^{T} \mathbf{w }\) and the energy cost to be paid by the production system (\({\mathbf{c }^\text {U,ES,V}}^{T} \dot{\mathbf{V }} + {\mathbf{c }^\text {U,ES,o}}^{T} \mathbf{o }\)):

$$\begin{aligned} \begin{aligned} f^\text {u}(\mathbf{w },\dot{\mathbf{V }},\mathbf{o })&= {\mathbf{c }^\text {PS}}^{T} \mathbf{w }+ {\mathbf{c }^\text {U,ES,V}}^{T} \dot{\mathbf{V }} + {\mathbf{c }^\text {U,ES,o}}^{T} \mathbf{o }\\&= \sum _{t \in T} {\Delta } t \cdot \sum _{j \in J} \sum _{i \in I} \sum _{{t}'=t-{\Delta }t_{i,j} }^{t} \Big ( W_{{t}',i,j} \cdot OC^{fix}_{i,j} + B_{{t}',i,j} \cdot OC^{var}_{i,j}\Big )\\&\quad + \sum _{t \in T} {\Delta } t \cdot \sum _{s \in S}V_{t,s} \cdot OC_{s}^{stor}\\&\quad + \sum _{t \in T} {\Delta } t \cdot \Big (p^\text {gas} \cdot U^{gas}_{t} + p^{el,buy} \cdot V_{t,u=grid^{buy}, e=\text {el}} - p^{el,sell} \cdot V_{t,u=grid^{sell}, e=\text {el}}\Big ). \end{aligned} \end{aligned}$$
(35)

The production cost \({\mathbf{c }^\text {PS}}^{T} \mathbf{w }\) consider fix cost \(OC^{fix}_{i,j}\) and variable cost \(OC^{var}_{i,j}\) for running task i on production unit j. \(W_{t,i,j}\) is a binary variable and equals 1 only in time step t when task i started on production unit j. \(B_{t,i,j}\) equals the batch size only in time step t when task i started on production unit j. Furthermore, variable cost \(OC_{s}^{stor}\) is considered for storing amount \(V_{t,s}\) of product s in time step t.

The energy cost \({\mathbf{c }^\text {U,ES,V}}^{T} \dot{\mathbf{V }} + {\mathbf{c }^\text {U,ES,o}}^{T} \mathbf{o }\) considers cost for purchasing gas, purchasing electricity, and revenues for selling electricity. The cost for electricity results from purchasing electricity \(V_{t,u=grid^{buy}, e=\text {el}}\) for a price of \(p^\text {el,buy}\). The revenues from selling electricity result from selling electricity \(V_{t,u=grid^{sell}, e=\text {el}}\) for a price of \(p^\text {el,sell}\). The cost for gas results from purchasing gas \(U^{gas}_{t}\) for the price of \(p^\text {gas}\). The amount of consumed gas is calculated by an affine function depending on \({\dot{V}}_{t,u,e=\text {heat}}\) and \(o_{t,u}\). For the cost to be paid to the energy system, a profit margin of the energy system could be added. Here, we assume only a profit margin for the energy system by subsidies for running combined-heat-and-power engines.

The objective function of the energy system is the cost to be paid by the energy system:

$$\begin{aligned} \begin{aligned} f^\text {l}(\dot{\mathbf{V }}, \mathbf{o })&= {\mathbf{c }^\text {L,ES,V}}^{T} \dot{\mathbf{V }} + {\mathbf{c }^\text {L,ES,o}}^{T} \mathbf{o }\\&= \sum _{t \in T} {\Delta } t \cdot \Bigg [p^\text {gas} \cdot U^{gas}_{t} + p^{el,buy} \cdot V_{t,u=grid^{buy}, e=\text {el}} \\&\quad - \Big (p^{el,sell} + p^{CHP,sell}\Big ) \cdot V_{t,u=grid^{sell}, e=\text {el}} \\&\quad - p^{CHP,prod} \cdot \Big ({\dot{E}}^\text {demand}_{t,e=\text {el}} - V_{t,u=grid^{buy}, e=\text {el}}\Big ) \Bigg ]. \end{aligned} \end{aligned}$$
(36)

These cost result from purchasing gas and electricity, revenues for selling electricity, and subsidies for running combined-heat-and-power engines. The cost for gas is again calculated by the amount of gas \(U^{gas}_{t}\) and the price of gas \(p^\text {gas}\). The cost for electricity is calculated by the bought electricity \(V_{t,u=grid^{buy},e=\text {el}}\) and the price for electricity \(p^\text {el,buy}\). The revenues for selling electricity result from selling electricity \(V_{t,u=grid^{sell}, e=\text {el}}\) for a price of \(p^\text {el,sell}\). The revenues for selling electricity are increased by the subsidies \(p^{CHP,sell}\) for electricity produced by the combined-heat-and-power engines. Further subsidies \(p^{CHP,prod}\) are gathered for electricity produced by the combined-heat-and-power engines and not sold to the grid.

The case study CHP subsidies considers a time horizon of 12 h. Each time step has the same length \({\Delta }t\) of 1 h. In the last time step of the time horizon, the production system has supply 56 t of S7 and 108 t of S10. The parameters for equipment size, storage size, and operational cost of the production system are the same as in Leenders et al. (2019a). The parameters of the energy conversion units are taken from Voll et al. (2013).

4.1.2 Results

The optimal bilevel solution (\(f^{u,bilvl}={4936}\,\)€) saves \(3.3\,\%\) of the cost for the production system compared to the sequential optimization (\(f^{u,seq}={5106}\,\)€, c.f. Figure 2). The method from Leenders et al. (2019a) results in \(f^{u,inc.inf.}={5077}\,\)€ cost for the production system and saves \(0.6\,\%\) compared to the sequential optimization. The integrated optimization results in even lower cost (\(f^{u,int}={4637}\,\)€) than the bilevel optimization and saves \(9.2\,\%\) compared to sequential optimization. However, as mentioned previously, the integrated optimization assumes full cooperation of the energy system, which is not given in this case study. If we subsequently optimize the energy system to calculate the regret, the cost for the energy system decreases, but cost increases for the production system (\(f^{u,corr. int}={5117}\,\)€). The cost increase for the production system (regret) is \(9.4\,\%\). The regret results in even higher cost for the production system than in the sequential optimization (\(0.2\,\%\)). Thus, the bilevel optimization provides the minimal, realizable cost for the production system (Fig. 2).

The substantial cost benefits arise in the integrated optimization because the combined-heat-and-power engines are not operated (c.f. Fig. 3). Thus, no heat and electricity are supplied by the combined-heat-and-power engines and instead by the boilers and the electricity grid. Electricity from the electricity grid is cheaper for the production system, but for the energy system, the subsidies make the combined-heat-and-power engines more beneficial. Thus, the production system favors that the energy system supplies electricity from the grid and the energy system favors to supply the electricity by the combined-heat-and-power engines. In the sequential optimization, \(45.9\,\%\) of the electricity is covered by the combined-heat-and-power engines. In hours where the energy system can produce more electricity than demanded, the energy system sells additional electricity to the grid.

In the bilevel optimization, \(20.1\,\%\) of the electricity demand is covered by combined-heat-and-power engines because the energy system significantly benefits when using combined-heat-and-power engines. The production system chooses a demand profile which results in low supply of electricity by the combined-heat-and-power engines due to the relatively high cost of electricity covered by combined-heat-and-power engines.

Fig. 2
figure 2

In the case study CHP subsidies, cost from the bilevel and the alternative optimization approaches differ. In the integrated optimization, the cost of the production system is minimized in a single-level optimization. The cost of regret is added after a subsequent optimization of the energy system. In the sequential optimization, first, the production system is optimized without considering energy cost. Subsequently, the energy system is optimized. The method from Leenders et al. (2019a) uses incomplete information and reduces the cost slightly (Incomplete inf.)

Fig. 3
figure 3

Heat demand in the case study CHP subsidies. The heat demands are plotted for: a bilevel optimization b integrated optimization, and c sequential optimization

The subproblems of the bilevel algorithm, the method from Leenders et al. (2019a), the integrated optimization, and the sequential optimization are solved within the time limit and, thus, are solved to the predefined gap.

The sequential optimization and integrated optimization are solved each within \(2\,\hbox {s}\). The method from Leenders et al. (2019a) solves the problem in \(23\,\hbox {s}\). The proposed algorithm solves the bilevel optimization problem in \(262\,\hbox {s}\) and needs 4 iterations. The lower-level problem and the auxiliary problem are always solved well below \(1\,\hbox {s}\). The solution time of the lower-bounding problem increases with each iteration with \(<1\,\hbox {s}\), \(12\,\hbox {s}\), \(72\,\hbox {s}\) and \(178\,\hbox {s}\). The solution time increases since discretization points are added in each iteration. The algorithm identifies 13 discretization points in total. From the first iteration, 7 discretization points are identified, from the second iteration, 5 additional discretization points are identified, and finally in the third iteration, 1 additional discretization point is identified. With these 13 discretization points in the fourth iteration, the lower-bounding problem reaches the same result as the evaluation of the lower-level solution in the upper-level objective and the algorithm terminates with the optimal bilevel solution. As expected, the cost resulting from the lower-bounding problem (LBD) increase in each iteration (Fig. 4), because in each iteration we add tightening constraints by the discretization points. No such trend exists for the optimal solution of the sum of the cost from the lower-bounding problem and the additional cost from evaluation of the lower-level solution in the upper-level objective. Similar to the integrated optimization, these additional cost are named regret because they also arise from a subsequent optimization of the energy system. Since the lowest cost can only be reached by the optimal solution of the bilevel problem, the cost from the lower-bounding problem and the regret are never lower than the optimal solution of the bilevel problem (Fig. 4).

Fig. 4
figure 4

Total cost for the production system in the case study CHP subsidies from the lower-bounding problem (LBD) and additional cost by evaluation of the lower-level solution in the upper-level objective (regret). The cost for the production system from the lower-bounding problem (LBD) increase with each iteration

4.2 Grid alternative

In this case study, the energy system is only connected to the gas grid. Thus, the energy system provides heat and electricity, while it provides electricity only by combined-heat-and-power engines. The production system can buy additional electricity directly from the electricity grid. First, we describe the detailed setup and the objectives (Sect. 4.2.1). Second, we present the results (Sect. 4.2.2).

4.2.1 Formulation

In the bilevel problem of Grid alternative, the production system is scheduled in the upper level to minimize its production and energy cost. The energy system is scheduled in the lower level. In the lower-level problem, we have the binary variables as in the case study CHP subsidies (Sect. 4.1.1).

In this case study, the production system pays a predefined price for heat and electricity to the energy system. Additionally, the production system is directly connected to the grid and can purchase electricity from the grid. Thus, the energy system has to cover the heat demand but not the electricity demand. The energy prices are given in Table 2.

Table 2 Energy price of case study Grid alternative. \(p^{heat}\) and \(p^{el}_{ES}\) are the prices for heat and electricity to be paid by the production system to the energy system, respectively. \(p^{el}_{grid}\) is the price for the production system for electricity from the grid. \(p^\text {gas}\) is the gas price and \(p^{el,sell}\) is the electricity price for the energy system

The objective function of the upper level (production system) is \(f^\text {u}(\mathbf{w }, \dot{\mathbf{V }}, \mathbf{o })\) and considers production cost \({\mathbf{c }^\text {PS}}^{T} \mathbf{w }\) and energy cost (\({\mathbf{c }^\text {U,ES,V}}^{T} \dot{\mathbf{V }} + {\mathbf{c }^\text {U,ES,o}}^{T} \mathbf{o }\)) to be paid by the production system.:

$$\begin{aligned} \begin{aligned} f^\text {u}(\mathbf{w }, \dot{\mathbf{V }}, \mathbf{o }) =&{\mathbf{c }^\text {PS}}^{T} \mathbf{w }+ {\mathbf{c }^\text {U,ES,V}}^{T} \dot{\mathbf{V }} + {\mathbf{c }^\text {U,ES,o}}^{T} \mathbf{o }\\ =&{\mathbf{c }^\text {PS}}^{T} \mathbf{w } +\sum _{t \in T} {\Delta } t \cdot \Big [p^{heat} \cdot {{E}}^\text {demand}_{t,e=\text {heat}}\\&+p^{el}_{ES} \cdot \Big ({{E}}^\text {demand}_{t,e=\text {el}} - V_{t,u=grid^{buy}, e=\text {el}}\Big ) + p^{el}_{grid} \cdot V_{t,u=grid^{buy}, e=\text {el}}\Big ]. \end{aligned} \end{aligned}$$
(37)

The production cost \({\mathbf{c }^\text {PS}}^{T} \mathbf{w }\) is the same as in CHP subsidies (Eq. (35)). The energy cost \({\mathbf{c }^\text {U,ES,V}}^{T} \dot{\mathbf{V }}+ {\mathbf{c }^\text {U,ES,o}}^{T} \mathbf{o }\) consider cost for purchasing heat and electricity from the energy system as well as cost for electricity purchased directly from the grid. The cost for heat is calculated by the heat demand \({{E}}^\text {demand}_{t,e=\text {heat}}\) and the price for heat \(p^{heat}\). The cost for electricity from the energy system is calculated by the price for electricity from the energy system \(p^{el}_{ES}\) and the difference of electricity demand \({{E}}^\text {demand}_{t,e=\text {el}}\) and electricity already bought from the grid \(V_{t,u=grid^{buy}, e=\text {el}}\). The cost for electricity from the grid is calculated by the price for electricity from the grid \(p^{el}_{grid}\) and the amount of electricity bought from the grid \(V_{t,u=grid^{buy}, e=\text {el}}\).

The objective function of the lower level (energy system) is to maximize the profit (equal to minimization of negative profit). The profit of the energy system \(P_{}^\text {L,ES}\) considers revenues from selling heat and electricity to the production system, cost for purchasing gas and revenues for selling electricity to the grid:

$$\begin{aligned} \begin{aligned} f^\text {l}(\dot{\mathbf{V }}, \mathbf{o }) =&{\mathbf{c }^\text {L,ES,V}}^{T} \dot{\mathbf{V }} + {\mathbf{c }^\text {L,ES,o}}^{T} \mathbf{o }=-P^\text {L,ES}\\ =&-\sum _{t \in T} {\Delta } t \cdot \Big [p^{heat} \cdot {{E}}^\text {demand}_{t,e=\text {heat}}+p^{el}_{ES} \cdot \Big ({{E}}^\text {demand}_{t,e=\text {el}} - V_{t,u=grid^{buy}, e=\text {el}}\Big )\\&-p^\text {gas} \cdot U^{gas}_{t}+p^{el,sell} \cdot V_{t,u=grid^{sell}, e=\text {el}}\Big ]. \end{aligned} \end{aligned}$$
(38)

The revenues from heat are calculated by the heat demand \({{E}}^\text {demand}_{t,e=\text {heat}}\) and the price for heat \(p^{heat}\). The revenues from selling electricity to the production system are calculated by the price for electricity \(p^{el}_{ES}\) and the difference between electricity demand \({{E}}^\text {demand}_{t,e=\text {el}}\) and electricity already bought from the grid \(V_{t,u=grid^{buy}, e=\text {el}}\). The cost of purchasing gas results from purchasing amount of gas \(U^{gas}_{t}\) to run the energy conversion units and the price for gas \(p^\text {gas}\). The amount of consumed gas is calculated by an affine function depending on \({\dot{V}}_{t,u,e=\text {heat}}\) and \(o_{t,u}\). The revenues from selling electricity result from selling amount of electricity \(V_{t,u=grid^{buy}, e=\text {el}}\) for a price of \(p^\text {el,sell}\).

In the last time step of the time horizon, the production system has supply the same amount as in the case study CHP subsidies, i.e., 56 t of S7 and 108 t of S10. All other parameters are the same as in CHP subsidies.

4.2.2 Results

Again, the bilevel optimization provides the minimal realizable cost for the production system (\(f^{u,bilvl}={6689}\,\)€). The bilevel optimization saves \(3.2\,\%\) compared to sequential optimization (\(f^{u,seq}={6910}\,\)€, Fig. 5). In this case study, the method from Leenders et al. (2019a) reaches the same cost (\(f^{u,inc.inf.}={6689}\,\)€) as the bilevel optimization. Still, as shown in the previous case study CHP subsidies, the identification of the bilevel solution is not guaranteed. The integrated optimization (\(f^{u,int}={5170}\,\)€) would result in \(25.2\,\%\) cost savings for the production system compared to the sequential optimization. As in CHP subsidies, the integrated optimization results in the best objective for the production system, but the solution from the integrated optimization is again not applicable in practice. The cost for the integrated optimization is increased after a subsequent lower-level optimization (\(f^{u,corr. int}={6989}\,\)€). The regret is \(26.3\,\%\) and consequently, the cost for the production system is even \(1.1\,\%\) higher than from the sequential optimization.

The cost benefits by the integrated optimization arise from energy supply by the combined-heat-and-power engines (c.f. Fig. 6). The combined-heat-and-power engines are operated such that electricity demand is totally supplied by the combined-heat-and-power engines, because, in this case study, electricity from the energy system is cheaper than electricity from the grid for the production system. In the sequential optimization and in the bilevel optimization, only \(4\,\%\) and \(4.8\,\%\) of electricity demand is covered by combined-heat-and-power engines respectively. This low coverage of electricity by the combined-heat-and-power engines is caused because the energy system does not prefer to use combined-heat-and-power engines to cover the electricity demand. This difference in the use of the combined-heat-and-power engines results in the large cost differences between the integrated optimization and the other approaches.

Fig. 5
figure 5

In the case study grid alternative, cost from the bilevel and alternative optimization approaches differ. In the integrated optimization, the cost of the production system is minimized in a single-level optimization. The cost of regret is added after a subsequent optimization of the energy system. In the sequential optimization, first, the production system is optimized without considering energy cost. Subsequently, the energy system is optimized. In this case study, the method from Leenders et al. (2019a) using incomplete information reaches the cost from the bilevel optimization (Incomplete inf.)

Fig. 6
figure 6

Heat demand in the case study grid alternative. The heat demands are plotted for: a bilevel optimization b integrated optimization, and c sequential optimization

The sequential and integrated optimizations are solved within \(2\,\hbox {s}\). The method from Leenders et al. (2019a) solves the problem within \(30\,\hbox {s}\). The proposed algorithm solves the bilevel optimization problem in \(153\,\hbox {s}\) and needs 3 iterations. The lower-level problem and the auxiliary problem are always solved well below \(1\,\hbox {s}\). The solution time of the lower-bounding problem increases with each iteration with \(<1\,\hbox {s}\), \(84\,\hbox {s}\) and \(68\,\hbox {s}\). The algorithm identifies 7 discretization points. Thus, fewer discretization points than time steps are needed, meaning that some discretization points are valid and used for multiple time steps. In the first iteration, 4 discretization points are identified, and in the second iteration, 3 discretization points are identified. The algorithm terminates in the third iteration and the optimal solution of the bilevel problem is identified.

As expected, the cost resulting from the lower-bounding problem increase in each iteration (Fig. 7) and the cost resulting from the evaluation of the lower-level solution in the upper-level objective does not show a trend.

The case studies show that the proposed algorithm solves the bilevel problem efficiently with only a few iterations. Furthermore, the identified bilevel solution considers the misaligned objectives of production and energy system and if complete information on the energy system is available, the bilevel solution allows for the best solution in practical application.

Fig. 7
figure 7

Total cost for the production system in the case study grid alternative from the lower-bounding problem (LBD) and from the evaluation of the lower-level solution in the upper-level objective (regret). The cost for the production system from the lower-bounding problem (LBD) increase with each iteration

5 Conclusions

The scheduling of production systems with on-site energy systems is commonly performed sequentially. An integrated optimization of both systems to an overall objective seems beneficial, but often, in practice, both systems have conflicting objectives. Bilevel optimization problems consider conflicting objectives between decision-makers, i.e., a leader and a follower, and thus, lead to a more realistic modeling.

In this paper, we formulate a bilevel problem for production and energy system scheduling. To solve this bilevel problem, we select the relevant parts from the algorithm in Djelassi et al. (2019) and add a procedure to identify dependent and independent variables. Thereby, we can solve the bilevel problem of production and energy system scheduling.

The algorithm iteratively solves the bilevel problem, while 3 optimization problems are solved in each iteration: lower-bounding problem, lower-level problem, and auxiliary problem. In the lower-bounding problem, discretization points bound the lower-level objective function by solutions from the lower-level problem in previous iterations.

The algorithm is successfully applied to two case studies based on literature examples for scheduling a production system and an energy system. The solution of the bilevel problem reaches cost savings of \(3.3\,\%\) and \(3.2\,\%\) compared to the sequential optimization, and \(3.5\,\%\) and \(4.3\,\%\) compared to an integrated optimization including regret. Furthermore, cost savings are realized compared to a previous method from the authors based on incomplete information exchange.

Thus, on the one hand, the proposed algorithm solves the bilevel problem. On the other hand, the solution of the bilevel problem provides the best realizable solution for scheduling a production system which is supplied by an on-site energy systems.