## 3 Problem Formulation  
We consider a building where the control system is composed by two different layers:  
* the low-level layer with the temperature controllers (one for each room);
* the high-level layer related to the optimal set-point planner. The low-level controllers are used to ensure the tracking of the reference signal and a fast rejection of disturbances (like the opening of a window for a short time interval). The control system used for this purpose (shown in Figure 1) is a standard cascade control scheme based on proportional-integral (PI) controllers. The inner loop represents the heating device, which is assumed it cannot be modified by the user. The outer loop controller determines the room temperature by acting on the set-point of the inner loop so that the output of the primary PI controller can be considered as a measure of the heat provided to the room, which is directly related to the energy. The considered problem is to find optimal set-point temperature signals (one for each room) to reduce the energy consumption by fulfilling some specific constraints required by the user. In this context, it is assumed that the user during the day, for each room, selects different constant set-points for different time intervals (for example, starting from midnight, the set-point temperature in a bedroom can be selected as 20 [\({}^{\circ}\)C] from 0 to 7 am and from 9 to 12 pm, while from 7 am to 9 pm it can be selected as 18 [\({}^{\circ}\)C]). In other words, step set-point variations are assumed to be defined by the user. We denote as \(\hat{T}_{i}\) the temperature required by the user for the \(i\)th room and as \(\hat{t}_{ij}\) the time instants when the value of the required temperature changes for the \(i\)th room, where \(i=1,\ldots,n\) (the number of rooms in the building) and \(j=1,\ldots,m_{i}\) (the number of set-point changes in a day for the \(i\)th room). The aim of the  
Figure 1: The control scheme for the temperature of the \(i\)th room. optimization strategy is to determine, starting from the values defined by the user, the set-point signals \(\hat{T}_{i}\) to be actually applied to the temperature control system of the \(i\)th room (see Section 5) to minimize the overall energy and by ensuring at the same time, that the actually achieved temperature is never lower (more than a given threshold fixed to 0.5 [\({}^{\circ}\)C]) than the temperature \(\hat{T}_{i}\) required by the user. Obviously, the optimal reference signals should not have a predefined shape. However, to keep the optimization problem simple (as it will be clear in Section 4), we define two possible kinds of reference signal \(\hat{T}_{i}\) variations (thus, yielding actually to a suboptimal solution), namely, based on step and ramp signals. In the first case, for each time \(\tilde{t}_{ij}\), the optimization algorithm must determine a time instant \(\tilde{t}_{ij}\) where to apply the set-point step to the room temperature controller. On the other side, if a ramp set-point signal is considered, two time instants \(\tilde{t}_{ij}^{-}\) and \(\tilde{t}_{ij}^{+}\) must be selected: the first is the time instant when the ramp starts and the second when the ramp ends. Of course, in both cases the final value of the set-point change is equal to the value of \(\hat{T}_{i}\) for the considered time interval. The situation is depicted in Figure 2 where a typical evolution of the room temperature is also shown.