*4.3. Constraint*

The algorithm is subjected to the constraint that the total energy consumption of the user is less or equal to a pre-defined energy budget, *Econ*,

> *s*.*t*. *L*[*t*] ≤ *Econ* , (13)

#### *4.4. Cooperative Game Model Implementation*

A mathematical model based on cooperative game theory is developed to capture the complex interactions among the different devices. The Shapley Value algorithm based on the cooperative game implementation is applied to all participating devices to obtain the *ui* vector. Such that energy can be allocated to simultaneously maximize the *ES* and minimize the energy consumption *L* for a corresponding energy reference. The flow chart for the proposed algorithm is shown in Figure 1. Time-based and device-based satisfaction tables and power consumption for each device are established. The proposed approach is to design a consumption scheduling for a selected number of hours *n*. Additionally, we should decide time *t* to start the experiment and the number *N* of participating devices. Considering the experiment should collect energy data for the 48 h before this time *t*, then the status matrix is of size 48 × *N*. The number of possible action profiles *A*, is found (2*<sup>N</sup>*). Since each possible action profile contains the possible devices´ status, each of these possible profiles are multiplied for the correspondent Device-based satisfaction Δ according to the time of the day and the device. *PS* and *ES* are computed using Equations (2) and (6) at each time slot, respectively. Next, the worth of the coalition *v*(*Sk*) can be found for each time slot for each profile. Lastly, the group of actions with maximum SV can be selected.

To implement this algorithm the following considerations are followed:

• Players:

> Devices-agents *i* = 1, 2, . . . , *N* are considered the players.

• Actions:

Devices can be ON or OFF, so the actions would be turning ON or OFF the participant devices (players.) The *ui* array will be zeros or one depending on the device status.

• Payoffs:

Consumption and ES are combined and modeled as optimization function using the characteristic function.

• Value of coalition:

Agents form coalitions and every coalition and corresponding actions have different value. For *K* ⊆ *N*, *SK* is the group of *K* devices that agreed to make a coalition to maximize the total expected payoff *v*(*SK*) that they can achieve together. The value of a coalition for this cooperative game is,

$$v(\mathcal{S}\_K)\_t = \begin{cases} 0, & \left| L[t] \right| > E\_{ref} \cap ES'[t] < 4\\ & \left[ 1 - f\left| \frac{L[t] - P\nu\_V[t]}{\max\left( L[t], P\nu\_V[t] \right)} \right| \right] \left[ \frac{ES[t]}{\Phi} \right], P\_{PV}[t] < L[t] < E\_{ref} \\ & \left[ 1 - \left| \frac{L[t] - P\nu\_V[t]}{\max\left( L[t], P\nu\_V[t] \right)} \right| \right] \left[ \frac{ES[t]}{\Phi} \right] \text{ otherwise} \end{cases} \tag{14}$$

where *f* is a factor to penalize level of consumption among the energy reference and solar energy less than cases when less then solar energy and *PPV*[*t*] is the minimum among the set of power output of generation(*Ppv*[*t*]) and the power inverter (*Pinv*[*t*]), i.e., *PPV*[*t*] = *minPpv*[*t*], *Pinv*[*t*], for the cases with just utility and *PPV*[*t*] = *minPpv*[*t*] + *Pbat*, *Pinv*[*t*] for the cases with batteries and utility, where *Pbat* is the set of power output from batteries.

There are three levels of consumption: *L* ≤ *PPV*, *PPV* < *L* ≤ *Eref* and *L* > *Eref* . Where *Eref* would be a consumption that is acceptable, there will be penalty if it is less than *PPV* or greater than *Eref* .

**Figure 1.** Flowchart for cooperative game implementation.

#### **5. Experimental Results and Discussion**

*5.1. Case Study: House with Photovolatic System (PV) and Utility or House with PV, Batteries and Utility*

The proposed model is being validated by representing a single rural residential house that may contain a small photovoltaic (PV) system that is composed of one or more solar panels combined, a DC/AC inverter, and it is grid-connected. Figure 2 describes a generalized version of the system. Energy data to simulate the case study is obtained in two ways:


**Figure 2.** Photovoltaic (PV) system.

#### *5.2. Data Characterization for the Algorithm Calibration*

## 5.2.1. Household's Load

For the load data, a single house's devices (four of them) are analyzed, the REDD data [31] is used to represent a part of house's loads. Data that is shown in Table 2 contains average power reading for the individual circuits of the house. The REDD data was sampled every three seconds. Hence, there are 20 data points per minute. The *ui* array is an hourly vector. For this vector, it needs to be decided how much time within an hour a certain device must be ON to assign a one (1) in that time slot.


**Table 2.** Load Description.

#### 5.2.2. House Head's Satisfaction

Satisfaction matrices were generated according to author's personal experience and they are described in Tables 3 and 4. This first stage of results is simply used as a sanity check. In the Section 5.3, actual load description (see Table 5) is used for each device based on REDD database and Ogunjuyigbe et al.'s [8] work. Besides, actual values of satisfaction were used to generate Tables 6 and 7. The authors´ personal experience reflects and summarizes how devices were prioritized by most of the population in extreme conditions such as those experienced after hurricane Maria in 2017 in Puerto Rico. However, future work will include field data to build the time-based satisfaction and device-based satisfaction tables.
