This application is particularly interesting, as it intentionally focuses on sustainability by employing a small set of batteries rather than a large-capacity setup. Batteries are not only the most expensive component of the installation but also occupy considerable space, weigh heavily (requiring specific structural considerations in the home) and are subject to wear, necessitating periodic replacement. Moreover, replacing them generates chemical waste that requires costly processing. On the other hand, while the computational system in this specific application does not impose stringent energy consumption constraints, it is deliberately implemented on a resource-limited device for EC environments to demonstrate feasibility.
4.1. Proposed Model Description
In the proposed system, decisions regarding the proportion of the sources of consumed energy (renewable through solar panels and batteries or from the grid) are made based on the following data: the expected energy consumption in the household over the next 24 h, the renewable energy available in the batteries, the expected solar radiation based on weather forecasts, and the cost of grid electricity, which can fluctuate hourly according to a day-ahead auction, as observed in countries like Spain. For example, if sufficient renewable energy is available from the solar panels at a given time, the expected household consumption is low, and the grid electricity cost is high for that time slot, it would be preferable to use renewable energy.
The decision-making mechanism is implemented via an FRBS, which makes new decisions every hour of the day. This time interval was chosen mainly because, as shown in
Table 2, while shorter intervals allow finer control and responsiveness, the one-hour interval offers a practical trade-off aligned with electricity tariff stability and computational efficiency.
The aforementioned data is merged into the following two input variables for the FRBS to ensure a compact system:
Electricity Price Trend (EPT): This variable allows the system to predict whether the price will rise, hold steady or decline over the next 24 h. It is calculated as the slope of the linear regression line that best fits the price data recorded over the preceding 24-h window.
Energy Balance Trend (EBT): This variable merges the data corresponding to the expected energy consumption, the expected solar radiation and the amount of renewable energy stored in the batteries. In this way, the energy balance, normalized between −1 and 1, indicates whether the current energy demand can be met using renewable energy. A value of −1 represents a scenario in which no renewable energy is available, either stored or from solar radiation, meaning that the total energy demand must be covered by the conventional power grid. A value of 0 indicates that the renewable energy available at a given moment is exactly equal to the current household consumption. Conversely, values closer to 1 indicate an excess of renewable energy after meeting consumption needs. To account for the temporal evolution of this variable, the EBT is defined as the slope of the linear regression that best fits the energy balance values recorded over the previous 24-h period. This allows the system to predict whether the EBT will rise, hold steady or decline within a normalized range from 0 to 100. In this scale, a value of 0 represents a future scenario with lower energy balance values, indicating a decrease in the proportion of renewable energy relative to consumption. A value of 50 implies that the balance between renewable energy availability and expected energy consumption will remain stable. Finally, values approaching 100 suggest an increase in the availability of renewable energy to meet consumption, thereby reducing dependence on the conventional power grid.
Finally, the fuzzy system’s output will be denoted as the Energy Source for Consumption (ESC), which is defined as the proportion of renewable and grid energy to be used for covering the expected consumption. Its discourse universe is defined between 0 and 100, where 0 indicates covering 100% of consumption with renewable energy, 50 indicates splitting the consumption equally between renewable and grid energy, and 100 indicates covering 100% of consumption with grid energy.
Regarding the KB of the FRBS, the structure is deliberately compact: each of the two input variables and the output variable is represented using three linguistic labels, yielding a total of nine possible rules. The universes of discourse for all variables are normalized and discretized over the interval [0–100] to regulate and structure the optimization search space. Rather than permitting unconstrained continuous variation, the linguistic labels are allowed to modify their position and width only through discrete steps within this range. This approach improves interpretability and aligns with the way domain specialists conventionally describe these variables in percentage terms rather than as absolute quantities. For the input variables, the labels “DEC”, “HLD”, and “RIS” denote if the values tend to “decline”, “hold”, and “rise”, respectively. For the output variable, the labels “REN,” “HYB,” and “GRD” correspond to “renewable”, “hybrid”, and “grid” energy source for consumption.
Figure 10 illustrates these linguistic terms constituting the DB of the FRBS, together with the chromosome representation determined by the position and width of each label. The initial parameter values were established using expert knowledge.
The RB consist of rules defined by an expert, such as: “If the
Electricity Price Trend for the upcoming hours is estimated to
decline (indicating that the current price is higher than the upcoming hours price) and the
Energy Balance Trend is estimated to
rise (suggesting an increase in future renewable energy availability), then, the decision will favor maximizing
renewable as
Energy Source for Consumption (since the electricity price will decline and the renewable energy will rise)”.
Figure 11 illustrates the nine rules that define the RB, ensuring complete coverage of the universe of discourse.
In accordance with the scheme outlined in
Section 3.2, the system alternates between inference phases using the FRBS, during which decisions are made, and real-time DB tuning phases to address changes in the environment, such as variability among the potential household consumption patterns between weekdays and weekends. BD’s parameters fine-tuning is performed, for example, using an evolutionary algorithm implemented directly on the device. The aim of this process is to optimize the FRBS’s responses so that, given specific environmental conditions as input, the system produces the most appropriate decision to minimize energy costs.
The aforementioned tuning process has been designed using a bio-inspired metaheuristic that allows for real-time FRBS updates in a lightweight manner. Specifically, the CHC genetic algorithm has been selected, as it provides an effective balance between exploration and exploitation of the search space; moreover, it also provides a good basis to be complemented with μGAs strategies. To simplify the number of parameters to tune, a gene encoding based on the 3-tuple representation [
96] of the fuzzy system has been adopted. This representation uses one parameter for the label position and another for its width, thereby maintaining symmetry. Consequently, the chromosome comprises only 18 genes for the three variables of the system. The search space for these 18 parameters is limited, as the discourse universe has been normalized between 0 and 100. Additionally, possible values have been discretized, significantly reducing the search space.
The evolutionary algorithm’s population consists of only 10 chromosomes, which undergo crossover and evolve until just 100 trials are completed in each evolutionary run. To prevent premature convergence of the population, the model implements an incest prevention mechanism, with a crossover threshold set to a quarter of the number of genes. That is, at least 25% of the genes between two chromosomes must differ for crossover to occur. The HUX crossover operator is used, which exchanges genes between two parents to generate two offspring. Each offspring randomly inherits a gene from each parent with equal probability.
The real-time adaptation phase of the FRBS typically requires an incremental tuning mechanism, as resource-constrained devices are not capable of storing the entire growing dataset (which increases daily as new data is generated). To address this issue, a novel variant of the CHC genetic algorithm tailored for on-device online learning environments (μCHC) is proposed. This variant introduces two main modifications:
Iteratively Partial Executions on Buffered Data Batches: Since it is not feasible to execute the full algorithm on the entire dataset due to memory constraints, the algorithm is applied iteratively on smaller, buffered batches of data generated in real time. These batches temporarily store data generated during the previous 24 h in the device’s memory. The data window shifts daily, forming a new buffered batch to update the model in the next partial execution of the evolutionary algorithm.
Incremental Tuning through Implicit Restart: In order to make the tuning process incremental, the traditional restart mechanism of the CHC algorithm, which is triggered when chromosome similarity exceeds a predefined threshold, is replaced by an implicit restart. In this approach, each partial execution of the evolutionary algorithm begins by selecting the best-performing chromosome from the previous execution. This chromosome serves as the seed for the next run, enabling the model to adjust incrementally over time. Although the partial executions are not extensive enough to converge, they are sufficient to enhance accuracy as the model adapts to new data. To prevent the algorithm from converging after several partial executions, the rest of the initial population in each execution is initialized with random values consistent with each gene, thereby introducing diversity into the search process.
Figure 12 provides a detailed diagram of the novel incremental online tuning mechanism proposed: Data streams continuously into the device. Every 24 h, data instances form a buffered data batch, which is used to evaluate various models during each partial execution of the evolutionary tuning process. The model corresponding to the best chromosome is selected to infer decisions for the next 24-h data window while also serving as the seed for the tuning process on the new buffered batch in the subsequent execution.
The pseudocode of the μCHC algorithm is expressed in Algorithm 1.
| Algorithm 1. μCHC |
Input: L: chromosome length; p: population size; d: difference threshold; mt: max. trials
- 1:
d ← L/4 - 2:
Initialize (P(0)) - 3:
for each buffered batch of data in data stream do - 4:
while trials < mt do - 5:
Evaluate (P(t)) - 6:
Preserve best chromosomes from P(t) - 7:
P’(t) ← Select (P(t)) - 8:
C(t) ← Crossover (P’(t)) - 9:
Evaluate (C(t)) - 10:
Increment trials count - 11:
P(t + 1) ← Select_best (P(t), C(t)) - 12:
if P(t + 1) = P(t) then - 13:
Decrement d - 14:
if d < 0 then - 15:
d ← L/4 - 16:
P(t + 1) ← Diverge (P(t + 1)) - 17:
Update FRBS parameters with best chromosome
|
The continuous tuning of the FRBS is made possible through the rapid evaluation of chromosomes, enabled by an exact simulation of the experimental environment (a concept introduced in
Section 3.1) specifically designed for this purpose. This simulator allows the tuning algorithm to optimize the FRBS decisions in real time.
Figure 13 presents the flow diagram of the proposed incremental evolutionary DB tuning method within the overall model framework. The diagram depicts the continuous on-device operational cycle, which alternates between performing inference on each incoming instance and executing tuning procedures on buffered batches of data.
4.3. Experimental Platform Configuration
During the tuning phase, an exact simulation mechanism was implemented to evaluate the cost associated with each DB. This mechanism does not rely on external simulation software; instead, it is executed directly on the device to assess the decisions produced by each chromosome over the buffered batch of real data. The simulation mechanism continuously updates the levels of renewable energy stored in the battery system, considering both consumed and generated energy based on solar radiation. Each day, the cost of conventional energy, solar radiation forecast data, the amount of renewable energy available, and the expected consumption are obtained.
From these inputs, the model evaluates the cost of decisions based on consumption. This enables the system to infer real-time decisions while continuously adjusting to environmental changes on the device itself, optimizing the cost of its decisions.
For validation on the device, no simulation software was employed. Instead, Python 3.10 scripts running on a host computer replayed real datasets as a chronological input stream to the Arduino Nano 33 BLE Sense, allowing the device to operate under realistic conditions. The TinyOL Linguistic Fuzzy system was fully implemented in C and executed on the microcontroller, ensuring that all membership-function computations, DB evaluation and decisions occurred physically on the device.
In real time, the device receives continuous updates from the following data sources: the electricity price, expressed in euros per kWh, is retrieved through the ESIOS API (
https://api.esios.ree.es/ (accessed on 8 December 2025)), while household energy consumption data, expressed in kWh, is provided by the electricity distribution company (
https://cecsa.oficinavirtual.sercide.com/followup-supply (accessed on 8 December 2025)). Additionally, average annual solar radiation data, expressed in Wh/m
2 is periodically updated from the Andalusian Energy Agency service (
https://www.agenciaandaluzadelaenergia.es/ (accessed on 8 December 2025)). These streams enable the system to maintain online learning on the device by incrementally updating its internal parameters as new observations arrive.
During the experimentation period, all data was collected coherently, ensuring consistency in terms of date and geolocation, which facilitates integration. The data collection period ranged from 1 November 2023 to 30 September 2024, resulting in a dataset of 8016 records defined by seven columns: hour, day, month, year, electricity cost (in €/kWh), household consumption (in kWh), and solar radiation (in Wh/m2). These records correspond to the province of Huelva, located in southwestern Spain.
Figure 15 presents the pre-processed data in tabular format, indexed by date and time, ready for use in the simulation and training process.
Figure 16 graphically represents a sample of the data used, corresponding to 24 h on 25 July 2024. The graph displays the variation in energy prices (blue), household consumption (red), and solar radiation intensity (green).
Based on the household consumption data shown in
Table 4, analyzed hourly and daily, the simulator was found to work best with the following configuration: two solar panels with a total generation capacity of 1 kWh (500 Wh each) and a battery system with a total storage capacity of 5 kWh.
4.4. Result Analysis
To evaluate the effectiveness of the proposed approach, we compared the FRBS under both deployment paradigms: a static TinyML configuration and an adaptive TinyOL configuration that enables lightweight on-device updates. This distinction allows us to assess the behavior of the model when its parameters remain fixed versus when they evolve in response to incoming data. For contextual comparison, we also include the FRBS baseline, initialized as shown in
Figure 10 and
Figure 11. The performance results in terms of cost optimization and computational resource usage are presented and discussed throughout the remainder of this subsection.
First, the total cost savings percentage was compared for the same household energy consumption using different systems. The results, depicted in
Figure 17, show that, initially, incorporating solar panels into the household achieves a cost saving of 25% (represented in blue) compared to using only grid energy. Secondly, when a battery storage system is added, the savings slightly increase to 26% (represented in brown). Using a decision-making process managed by the initial static FRBS, cost savings reach 25.7% (represented in violet), which surpasses the system with panels but does not outperform the system with batteries. Fourth, the red bar represents the statically adjusted fuzzy model (TinyML-based), meaning it is adjusted only once at the beginning. Finally, managing renewable energy usage through the proposed online tuning mechanism (TinyOL-based) achieves a 27% cost saving (represented in green). The TinyOL model demonstrates better results than the static TinyML model, as the former adapts to changes occurring throughout the testing period.
The impact of online tuning was further analyzed by comparing the monthly cost savings percentage between the static TinyML-based FRBS (represented in red) and the online adaptive TinyOL-based FRBS (represented in green) in
Figure 18, month by month during the experimentation period. Notably, the improvement observed in month 8 is significant, as it includes a partial vacation period with a markedly different consumption profile due to sudden changes on two specific occasions. The adaptive model achieves significantly better results compared to the static system.
Focusing on a specific month, July 2024,
Figure 19 illustrates that the system with the online adaptive FRBS, which adjusts daily using data from the previous day, achieves notable savings peaks on certain days (shown in green) compared to the static system (shown in red). For instance, this is evident on Friday, 5 July 2024. Moreover, variations were identified between high-consumption days, such as non-working days and working days. These behavioral changes influence the savings percentage achieved, with minimal peaks observed on Saturdays.
Finally,
Figure 20 shows the impact of decisions made at each hour (the minimum unit available to evaluate the model’s performance). In this case, the online adaptive FRBS achieves better results during periods of high consumption and renewable energy availability (from 7 to 10 a.m. and 12 to 2 p.m.), where the FRBS’s decisions have greater weight.
Overall, accumulated gains of TinyOL FRBS compared to Tiny ML FRBS in terms of cost savings percentage is 1.17% from 1 November 2023 to 30 September 2024.
Table 5 shows monthly cost savings percentage of TinyOL compared to TinyML, supplementing
Figure 18. Similarly,
Table 6 shows daily cost savings percentage, supplementing
Figure 19, and
Table 7 shows hourly cost savings percentage, supplementing
Figure 20.
The proposed μCHC operates under a fixed number of trials. Let denote the number of fitness evaluations performed during one buffered batch. Since all selection and crossover operations are constant-time for a fixed population size, the total runtime is linear in the number of trials. Therefore, the time complexity is . In our implementation, each buffered batch uses trials.
The memory footprint is constant because both the population size (10 chromosomes) and the FRBS parameter dimensionality (17 parameters per chromosome) are fixed. The algorithm therefore requires storage for integer parameters, yielding a constant-space design. Formally, space complexity is .
Regarding the computational resource consumption of the model, global variables utilize 45,760 bytes out of the 262,144 bytes available in RAM, equivalent to only 17% of the total. Of this, 180 bytes are used to maintain the FRBS in memory (DB: 3 variables × 3 labels × 2 parameters × 4 bytes (int) + RB: 9 rules × 3 labels identifier × 4 bytes (int)), 288 bytes to store the daily buffered data batch (24 examples × 3 variables × 4 bytes (float)), and 680 bytes for the μCHC evolutionary algorithm’s population (10 chromosomes × 17 parameters × 4 bytes (int)).
In terms of processing speed, the time required for a partial tuning using the proposed evolutionary algorithm is 217 milliseconds. Specifically, the time taken to evaluate each chromosome on the buffered data batch is only 2 milliseconds, while inferring a decision using the FRBS each hour takes 0.03 milliseconds. To quantify the energy consumption of the model, a base power consumption of 0.125 W (5 V × 0.025 A) was considered. Therefore, the estimated energy required per inference is 3.75 μJ (0.03 ms × 0.125 W), whereas each partial tuning consumes approximately 27.1 mJ (217 ms × 0.125 W). These results demonstrate that an economic processor suitable for IoT tasks can efficiently implement the proposed compact model, supporting both low-energy inference and occasional tuning operations, and could even accommodate more frequent intervention intervals without significant energy overhead.
It is important to clarify that the purpose of this case study is to validate the behavior of the proposed adaptive mechanism under evolving operating conditions rather than to characterize long-term energy consumption patterns. The available dataset includes several phases where the underlying conditions change, providing controlled forms of concept drift that are sufficient for evaluating whether the system can adapt effectively. Accordingly, the experimental analysis focuses on the stability and responsiveness of the online tuning process, rather than on modelling extended temporal dynamics of energy consumption.
The results demonstrate that the proposed model for designing fuzzy systems at the edge with online tuning not only significantly improves cost savings by adjusting in real-time to changing environmental conditions, but also operates efficiently on low-resource IoT devices. The compact implementation of the selected evolutionary model, optimized for online learning environments, strikes an appropriate balance between accuracy and computational resource consumption, enabling continuous adjustment without compromising the device’s processing or memory capacity. Furthermore, the evaluation model based on a real-time exact simulator facilitates the rapid assessment of chromosomes, ensuring that the system can adapt efficiently within the required time frame.
The analysis using different measurement units (annual, monthly, daily and hourly) highlights that the online adaptive FRBS achieves greater cost savings in the selected application compared to a model that employs a static FRBS, adjusted only once during the design phase.
The resulting fuzzy DB as of 30 September 2024 is shown in
Figure 21. For comparison, the initial FRBS, depicted in
Figure 10, is overlaid using dotted gray lines.
Following the notion that rule-based models constitute transparent and intrinsically interpretable model systems [
15,
16,
17,
18,
19,
20,
21], we quantify the interpretability of our fuzzy model using standard structural and semantic indicators commonly employed in interpretable FRBS design. First, the Rule-Base Complexity (RBC) [
112] remains extremely compact, with only 9 rules and 2 antecedents per rule, which lies at the lower end of typical FRBS structures and enhances cognitive accessibility. Second, the Linguistic Label Compactness Index (LLCI) [
113], based on the 18 parameters of the symmetric triangular labels, reflects the reduced parametric burden characteristic of highly interpretable fuzzy models. Third, the Membership Function Overlap Index (MFOI) [
113] remains low (0.25 initially and 0.08 after online adaptation), indicating controlled overlap and low ambiguity between terms, values consistent with the range of high interpretability reported in the literature. Finally, to address the requirement that trustworthy AI systems maintain interpretability over time and avoid semantic drift, we compute a Semantic Stability Index (SSI) [
114] of 0.87, showing that the linguistic meaning of the labels remains largely preserved after online tuning. Together, these indicators demonstrate that the proposed FRBS retains both structural transparency and semantic consistency throughout the learning process.
Overall, these results support the viability of the proposed model as an effective solution for online adjustment of the FRBS at the edge, laying the groundwork for future research on integrating adaptive learning techniques into IoT devices.
Beyond the specific scenario evaluated in this section, the proposed online-adaptive linguistic fuzzy approach presented in
Section 3 exhibits strong potential for scalability across a wide range of application domains. Because the mechanism relies on incremental adaptation of interpretable fuzzy DB, it can be transferred to any context where systems must operate under non-stationary conditions using limited computational resources. This includes online calibration of embedded controllers, adaptive decision-making in autonomous robots, real-time sensor fusion in IoT monitoring networks, and evolving quality-assessment or anomaly-detection modules in industrial settings. The fact that the adaptation process only requires compact data buffers and lightweight evolutionary updates facilitates deployment in heterogeneous platforms, from microcontrollers to edge devices. These characteristics demonstrate that the proposed method is not restricted to the use case presented, but constitutes a general framework with broad universality and expansion potential.