Fractional order differential calculus applied on decision making system to smart grid management via decision trees

This article portrays the relationship between fractional order differential calculus and the computational intelligence method, applying it to the improvement of intelligent systems. The Kirchhoff Laws, represented by second order differential equations, were solved via non-integer order differential calculus. The results obtained were used in the implementation of decision trees, which allowed the decision rules to be incorporated into the controllers. The results obtained by mathematical modeling did magnify the information extracted from Kirchhoff's Laws. Due to the gain magnitude of this information, the decision trees were obtained with greater precision and accuracy. In this way, it was achieved to build a hybrid system capable of being used in the development of controllers automata that has the lower response time and highest efficiency.


Introduction
In the past 20 years, humanity's care about Ambiental impacts gained even more weight on decision making, mainly because of extreme climatic changes and its impact on nature, economy, and life quality of humans. Unfortunately, this caution about the consequence of humanity's impact took much time do bring practical solutions, and because of that, society began living a hard time with resources production and distribution.
The resource scarcity got accentuated over the last 2 years, mainly because of covid-19 pandemic, being one of the most affected areas the technological industry, as seen in Baraniuk (2021) and Wilmot. (2021) with the chips shortage, affecting from the smartphones production to the new smart automobiles manufacturing. Another sector struggling because of the pandemic and lack of previous prepare is the energy section, both power generation and power distribution, as shown in Hoskins. (2021) with some provinces in China going through a power shortage.
In Brazil, there's currently a similar problem of power generation happening because of a drastic reduction in rainfall over the last year as seen in Mota (2021), and as most of Brazil's electrical power is produced by hydroelectric systems, the country began an energy rationing and increasing the usage of thermoelectric systems, causing an increase on population's power bill.
The pandemic also brought a new era based on home office to reduce infection rates, and as this experience allowed some professional to keep on working from home, workers started to improve their own domestic offices for productivity and comfort. Nonetheless, the need of caring about the energetical consumption got even higher because of world's situation described previously on this paper, therefore this new generation of home officers lack a trustful, efficient, and simple implementation system capable of managing their inhouse office room energetical usage.
Managing inhouse power grid allows not only energy saving, but also Ambiental and living comfort for the residents, (Hagenbeck et al. 2016) presented a smart home control system to save energy using Fuzzy Techniques to perform automatic decision making, however its implementation requires some advanced analysis by individual sensors in the smart home, and manual defined Fuzzy Rules to operate the system based on conditionals. This paper, analogously, proposes a method that applies automation since the development of the conditional rules, by utilizing computational intelligence to trace the behavior patterns and return the different scenarios and later run the real time decision making.
In , the authors apply a hybrid model using Genetic Algorithm (GA) and Newton's method to optimize the energy distribution and transmission over a power grid, possible thanks to the mathematical-computational modeling of the circuit. On ), it's presented a composed model by the union of GA and Particle Swarm Optimization (PSO), this model allows quickly finding great solutions with optimal values for better operating the components in the 14-bus electrical system.
Because of modern devices and various activities over the day, the home office turns the domestic office circuit in a dynamic power grid, therefore the scenarios vary according to the combinations of active devices. This dynamic profile demands a control system appropriate to not only classify the scenarios but also to perform the decision making while the control system Research, Society andDevelopment, v. 10, n. 16, e38101623387, 2021 (CC BY 4.0) | ISSN 2525-3409 | DOI: http://dx.doi.org/10.33448/rsd-v10i16.23387 3 is online.
For this paper the authors chose to operate the circuit via a microcontroller device responsible, because it's affordable device and simply operated via multiple easy interfaces, so it fits greatly for the necessary activities. The device will operate based on an algorithm developed to work with multiple conditions described based on the multiple home circuits behaviors.
The electrical phenomena, described by the Kirchhoff Laws, were implemented by way of the Non-Integer Order Differential Equations solving results. Such strategy allowed to extract unhackneyed information about the behavior of RCL autonomous electrical circuits. It's considered that, the energy storers capacitors and inductors, such as the circuits in which they are included, do not depend only on their power sources, but also on the voltages and initial charge from the capacitors, and the current and initial flows from the inductors, since the differential equations the describe those circuits are obtained adopting the relation voltage-current from the storer devices.
In the analysis of characteristic equations, obtained by the application of differential equations with non-integer orders, it was perceived, with higher resolution, the behavior of damping intensity related to the undamped natural frequency.
The results generated by the optimized Decision Tree, trained with the input data received from the characteristic equations, shown 92.2% accuracy, ratifying the hybrid system applied is efficient and reliable.

Methodology
This paper joints multiple fields of study, such as mathematical modeling, circuit analysis, computational intelligence, and microcontrollers. Since it applies techniques from various areas, the following topics will describe every step from this research that compounds this paper's methodology. It is also important to emphasize that the methodology implemented in this paper, takes as a great reference the guidelines proposed by Pereira et al. (2018), in which it is presented a set of well-structured steps to the organization of scientific papers.

Mathematical modeling
This paper will apply Fractional Order Differential Calculus (FODC) in its mathematical modeling, following the process presented in . The integer order derivatives reflect the variation rate at which some phenomenon changes, the real order derivatives allows one to extract more information about such phenomenon, an example in  shows a fractional order derivative outcomes when applied to a space function, shows not only the variation of an object through space, but also brings to the user the information about the eminence of the movement, in other words, it allows one to perceive the position change before the action properly occurs as seen in Figure 1.  Figure 1) are the fractional order derivatives. It is noteworthy that the fractional derivatives outcomes provide much more information between the space and speed function, that is, the time interval from an object to leave its state of rest until initializing the proper movement. It is also important to highlight that in Figure  Through time, multiples mathematicians and physicians studied and developed the fractional order derivatives, the demonstration and structural differences occur from the diverse oriented scenarios in which each author aimed their method.
These variations, yet bringing some decision difficulties, are mostly a good characteristic, because it allows researchers to choose the best method for their situation. Between multiples possibilities, this research considered some methods to apply, but to decide it is needed to evaluate those method's definitions and applicabilities.
One of the considered methods is the Riemann-Liouville, where its derivative of fractional order α of a function x(t) is shown in Equation 1.  0 Where − 1 ≤ < + , and Γ is the Euler-Gamma function.
Another method this paper considered is Caputo's, its derivative of fractional order α of a function x(t) is defined as presented in Equation 2. Both methods are mathematically applicable to the problems this paper works with, however, as seen in (Li, C. et al, 2011), the Riemann-Liouville method grants a wider horizon of possibilities since Caputo's method works in a shorter operational range. Another important feature to help deciding the most appropriate Fractional Order Derivative method is its computational implementation capability and easiness.
As described in the next topic, this project relies on computational tasks to better precision and real-time analysis, thus the compatibility of the mathematical method and modeling shall fit this project's necessities. In (Li, C. et al, 2011) and (Brzeziński, 2016), Riemann-Liouville was the main solution method applied because of its balance between low implementation complexity, high rates of precision and accuracy, keeping the method's characteristic of being applicable in a wide quantity of functions.

Computational intelligence modeling
As said in the introduction, this research seeks to develop an algorithm that allows complete automation, since its implementation until the later execution, to accomplish that, it is inevitable to utilize some computational intelligence method.
The chosen technique, between various methods, was the Decision Tree (DT), this algorithm of computational intelligence grants great flexibility since it allows multiples utilizations as classification, regression, and prediction. (Azancort et al, 2021) presented an application of DT to improve the selection of areas for building a landfill, by discovering the control variables in multiple scenarios thanks to this computational technique. Among other possibilities, DT is also a low computational cost algorithm when compared to Artificial Neural Networks (ANN), (Ekiz et al, 2020) shows DT is also more efficient for prediction and for studies relying on small quantity of data.
To exemplify the DT working process, consider the data in Table 1.

Table 1 -Data Input Example
Test Source: Authors.
In Table 1 there are 4 Tests, also known as "observations", in which the table provides the inputs -or attributes -values of X and Y in given system, and in the last column the output values f of the system with respect to each input. Even with these few data, if one uses it as an input to a DT, one possible outcome (since the tree model may vary depending on the programming and setup utilized) is the model presented on Figure 2. Source: Authors.
The DT analyzes the input data and provides a model capable of describing the behavior of this dataset, the resultant model can predict the results of inedited inputs, as it can also guess the input combinations from a given output. Based on the conditional relations the DT established, like seen in Figure 2 (If Y ≤ 0, ≥ 0,…), the DT may also work as decision-making mechanism over the patterns the algorithm learned. Notice this example is simpler than the scenarios this paper will work with, but the intention is to easily explain the DT operation.
In this study the DT will be utilized in two different ways, the first is to analyze the circuit and elaborate a model based on the electrical grid architecture, DT is a classifier technique which its rules are produced by itself, and by so it compounds more of this paper's automation essence, so the classification property of the algorithm will be used, besides that the algorithm will also compare the attributes described in the next topic to evaluate its importance and impact on the circuit. The second application of the DT uses the algorithm decision making property, based on the possible scenarios produced by the DT at the previous step. The DT will use the FODC information gain to provide real time decisions, the computational platform will solve the differential equations developed on the mathematical modeling step according to the input and choose the better solution for this input based on the computational model developed by the classification tree.
To choose a programming language which fits the software requirements for this methodology some features must be available in the platform, as the data treatment, tools compatibility and intercommunication, besides computational cost, and results precision.  and (Costa, D. C. et al, 2020a) utilize Python Programming Language as main tool for mathematical methods, mostly because of its libraries that allow symbolic mathematics and interactive visualizations.
Nonetheless, ) present MATLAB as a more efficient working tool, mainly in applied situations that need a high quantity of variables included in their analysis, as in (Costa, D. C. et al, 2020b) and (Silva et al, 2019).
The software chosen to develop the DT and connect it to the later explained controllers is MATLAB, which name stands for Matrix Laboratory, this platform works data in matrix format to achieve higher precision in problem solving based on geometric calculus and geometric algebra, as differential geometry problems. The geometric sustenance allows MATLAB to calculate via Graphical Processing Unit (GPU), instead of relying only on Central Processing Unit (CPU), which grants better performance, in (Semenenko et al, 2020) it is presented that, in average, a GPU realizes calculations 9 to 11 times faster than a CPU.
MATLAB provides toolboxes, which are specialized groups of functions, for the DT implementation, these toolboxes optimize the development of the computational intelligence method used in this paper since it drastically reduces the quantity of Research, Society and Development, v. 10, n. 16, e38101623387, 2021 (CC BY 4.0) | ISSN 2525-3409 | DOI: http://dx.doi.org/10.33448/rsd-v10i16.23387 7 commands, and consequently the amount of code lines. Another important feature is the toolbox for system control management provided by MATLAB, better explained in the Microcontroller Functionality topic, which enables the communication between hardware and software.

Physical attributes setup
For the DT to work properly, it is needed to set a mathematical meaning to correlate the attributes, the attributes on the Tree are the variables analyzed on the circuit. One of the attributes is the Current, defined by the rate at which charge moves past a point over time, as shown in Equation 3.

= (3)
In which i is the current (in amperes) and dq is (in coulombs) the amount of charge moving past a point through a time interval dt (in seconds). Another important attribute is the potential difference (tension) between two points a and b, defined in Equation 4.

− = (4)
Where is the tension on point a, the tension on point b, i the current defined in Equation 3, and R is the resistance which may be defined as shown in Equation 5.

= (5)
In which L is the length of the wire, A is the cross-sectional area of the wire, and ρ is material's resistivity. Nonetheless, the resistivity property varies with temperature, for metals in general the variation is approximately linear over a broad temperature range (Resnick & Halliday, 2011). A material's resistivity variation is defined in this paper as presented in Equation 6.
In which 0 is a selected reference temperature, and 0 is the resistivity at such temperature. The α is known as the temperature coefficient of resistance, it means the change factor per degree of temperature change. For copper, the resistivity 0 = 1.69 × 10 −8 • when 0 = 293 , and the = 0.00404 −1 . Another attribute included in the analysis is the energy transfer, known as power, and defined as shown in Equation 7.

= (7)
Being P the rate at which energy is transferred from one point to another. The unit of power is volt-ampere, that may be describe as 1 • = (1 ) (1 ) = 1 = 1 .
As shown above, Power unit may also be represented in Watts(W).
Since this paper seeks to improve energy saving while considering the resident comfort, it is essential to include the thermal energy emitted from the domestic office electrical grid, with this objective the analysis will include the dissipated power as thermal energy. Considering a device with resistance R, the resistance may also be described as Equation 8.
It is important to notice that Equation 9 and Equation 10 applies only to the transfer of electric potential energy to thermal energy in devices with resistance.
This paper will also utilize the concepts from Kirchhoff's laws of circuits, using multichannel devices on the electrical grid. These laws are the strategies responsible for connecting the multiples variables and attributes here analyzed, the mathematical method of Kirchhoff's Laws is represented in Equation 11.
Where L is the inductance defined by Equation 12.

= (12)
In which N is the number of turns in the coil, the windings of the inductor are connected by the shared flux, and the product is called magnetic flux linkage. The inductance (L) is, therefore, a measure of the flux linkage produced by the inductor per unit of current. The unit of inductance is tesla-square meter per ampere ( • 2 / ), most often worked as henry (H), as presented in Equation 13.
The C in Equation 11, represents the rate of electrical potential between conductors caused by their stored electrical charge, also known as capacitance, this attribute described in Equation 14.

= (14)
Capacitance mainly adopted unit is Farad (F), after the English physicist Michael Faraday.
When combining Equation 11 with Equation 1, one applies the fractional order derivative principles of Riemann-Liouville to the Kirchhoff Laws of circuits, resulting in Equation 15.
These attributes will contribute to the management of the analyzed electrical grid, so was necessary to prove their mathematical relation as strategy to provide physical meaning to the DT results, otherwise the computational outcome would not be enough to guarantee the model efficiency. Furthermore, the fractional order methods will provide more information about the circuit behavior, increasing the smart metering.

Microcontroller functionality
To effectively implement the mathematical and physical models to the electrical grid through the computational system developed, it is necessary a hardware control device capable of receiving the grid inputs and correctly obey the conditionals implemented on its programming. Both Arduino and Raspberry Pi devices work with the MATLAB tools, and that's a key Research, Society and Development, v. 10, n. 16, e38101623387, 2021 (CC BY 4.0) | ISSN 2525-3409 | DOI: http://dx.doi.org/10.33448/rsd-v10i16.23387 9 feature to develop this project over the same software, since it creates a broad horizon of possibilities.
In (González & Calderón, 2019), it is presented the application of Arduino platform in automation of Smart Grid systems, ensuring low cost, because of Arduino's opensource technology. (Li, Z. et al, 2020) presents a model of intelligent office lighting system using Arduino as its main controller, combined with illuminance sensors to deal with China's office lighting energy waste. (Khairudin et al, 2019) shows the possibility of developing fuzzy logic systems in MATLAB and converting it into C/Arduino scripts, achieving immediate hardware control application in an Arduino device.
The importance of connecting the Arduino device to MATLAB represents an easier path to data and commands transfer between these platforms, since MATLAB provides a toolbox for directly converting its scripts to C codes, the communication may be executed in low computational cost, since there's no need for heavy encoding, consequently, low time delay between input and response's system. This MATLAB feature carries great importance for bringing the DT conditional structures to Arduino's grid management and controlling. It is noteworthy that the Arduino physical implementation and I/O setup is out of the scope of the paper.
The workflow of the presented methodology is represented in Figure 3. At this moment, the methodology workflow is well defined in all the addressed aspects, the flowchart illustrates the union of the steps well described on the previous topics, therefore the methodology proposed is consistent and cohesive. The next step is to analyze the practical execution of the algorithm on the running program, to evaluate parameters as precision, accuracy, computational cost, and time response.

Results and Discussion
This paper's whole computational system was implemented on MATLAB platform, since it offers all tools needed to accomplish the methodology presented on Figure 3. The DT methods were implemented using Classification Leaner tools, however the FODC codes were completely developed by the authors.
The first result comes from the application of the FODC techniques described in the mathematical modeling section, using the input data being Capacitance (C) = 0.001 Farad, Voltage (V) = 3 Volts, Resistance (R) = 50 Ohms, Inductance (L) = Research, Society and Development, v. 10, n. 16, e38101623387, 2021 (CC BY 4.0) | ISSN 2525-3409 | DOI: http://dx.doi.org/10.33448/rsd-v10i16.23387 10 Henry and Current (i) = 17 Ampere from (Abubakar et al, 2019), in which the attributes values are shown in Table 2.   Table 2 shows the behavior of the Differential Equation from Kirchhoff Laws applied to the chosen circuit with the proper input data. Table 2 structure consists of the analysis over time, discretized on the first column, from 0 to 5 seconds with steps of one tenth of a second (1s⁄10), resulting on 51 rows of time progression. Columns 2 to 10 present the circuit behavior on the same time instant but with dissimilar orders of the Non-Integer Order Derivative (NIOD), these orders values are symbolized by α, in which the relation of α and m from Equation 15 is set by the relation below.

= + 1
This relation allows simplifying the quantity of alpha (α) values in Table 2 to work with the first and second order derivatives needed in Equation 15. One can understand that every value in the range between rows 2 to 52 and the columns 2 to 10, is the Voltage value in the circuit at a T time at a α order in the NIOD. The 11th column shows the damping rate classification of the circuit at a T time, and it's defined by the following relations.
If < √ , then the damping rate is considered STRONG, If > √ , means the damping rate is WEAK, An if = √ , the damping rate is classified as WEAK.
The Damping Rate attribute defines the circuit behavior, so it is extremely important for the construction of the DT, working as its labels, as shown in the following steps of the workflow.
With the data in Table 2, it is possible to create an initial tree as a manner to allow the computational method to first learn the conduct of the dataset, this initial execution returns a fitted binary classification decision tree according to the attribute values (voltage) in table, and each moment's response (damping rate classification). By then, the tree was implemented to execute a data classification only, and the result of this process is presented in Figure 4. The classification tree in Figure 4 may also be represented in algorithm structure as shown in Figure 5. In which x is the equivalent to the m element value in the Equation 15, the decision nodes are the NIOD orders and leaf nodes are the damping behavior classification. This classification tree brings to this research the information that, even though the NIOD extracts more information about a phenomenon, for this dataset it is only necessary the data from the second (α=.1) and tenth (α=.9) columns do describe the damping from the circuit at a given moment, so these variables may be considered the main attributes. This conclusion is important for allowing optimization of the computational cost, since it shows no need for loading the whole dataset to deal with future decision making, by reaching a reasonable classification tree with approximately 22.2% of data available data. The relation between the main attributes is shown in Figure 6. Source: Authors.
Since this paper seeks to build optimal solutions for real time smart grid management, the optimization process is indispensable for reducing input-output delay, so the next step was improving the tree for quicker results. To achieve this goal was necessary to utilize classification leaner features on MATLAB programming language, in which the authors were able to train 3 DT models, with the main difference being the Maximum Number of Splits (MNS). The models applied were Coarse Research, Society andDevelopment, v. 10, n. 16, e38101623387, 2021 (CC BY 4.0) | ISSN 2525-3409 | DOI: http://dx.doi.org/10.33448/rsd-v10i16.23387 13 Tree (MNS=4), Medium Tree (MNS=20), and Fine Tree (MNS=100), in the comparative were also included the evaluation more parameters as presented on Table 3.  Figure 7. This Coarse Tree is an optimization of the Classification Tree presented on Figure 4, reducing the quantity of decision nodes based on the estimated probabilities from each leaf node results. With the Coarse Tree, this research achieved a trained model for current and future data evaluation, this model brought many results, being the DT structure one of them, and the behavior representations of the input data, one of these representations is shown on Figure 8.  behavior. This figure displays the plotting on a z-score scaling, thus presents how far below or above a score is from the dataset mean, this "distance" is measured in units of standard deviations, as noticeable in the plot vertical axis. This illustration method didactic makes it easier to comprehend medium or large datasets, as example when zooming in the Figure 8, one can see the different damping rate classification over time instants in the analyzed time interval, this zooming generates Figure 9.

Source: Authors.
A zoomed in observation increases precision at cost of resolution, however the figure interface generated on MATLAB allows zooming in and zooming out at any moment, without any lost in the trained model data. The improved phenomenon data extraction feature surely improves more precise and complex analysis, however when uploading the software functionality to the microcontroller, it shall be able to performance decision making in the best time possible.
To achieve great processing time, it was used the observation made after analyzing the Classification Tree figure, in which is said that data from the second (α=.1) and tenth (α=.9) columns are enough to represent the studied system, reducing the data load every time a calculation is needed. Relying on this information, and combining with the different tree techniques comparative, the authors trained a model that uses Coarse Tree architecture and only the (α=.1) and (α=.9) data, resulting in an Optimized Coarse Tree, with structure presented in Figure 10. The yellow rectangles in Figure 10 show the estimated probabilities of every circuit damping rate classification in each leaf node, thus the system does not disregard a probabilistic analysis, since deterministic proposals are often rough approximations. Even though the models in Figure 7 and Figure 10 are visually similar, their difference becomes explicit when comparing their training results, as shown in Table 4. Comparing the same parameters used in Table 3, one can notice the superior results of the Optimized Coarse Tree, as the higher accuracy rate and the 4 times smaller Misclassification Cost. Even thou the Training Time was approximately 1.89 times longer, it's a fair cost over the 2.45 times faster Prediction Speed, which was able to perform nearly 13000 observations per second. It is also noticeable that, in Table 3 comparative analysis, the Training Time was the selection parameter because the other tree models performed the same Accuracy and Misclassification Cost, however the Optimized Coarse Tree results are arguably better, compensating the longer training time. The Parallel Coordinates Plot of the Optimized Coarse Tree is shown in Figure 11. Source: Authors.
As decide, only the columns 1 and 9 were used, reducing the quantity of misclassification elements to 1 and increasing the Accuracy Rate. Loading selected data instead of the whole dataset reduce the quantity of analyzed values from 459 to 102, resulting in datasheet files 3517 bytes lighter. This reduction of data loading may not look overly impressive by itself, but it shall be considered this system will be in continuous processing, repeatedly calculating the new values from the circuit, therefore this carrying out less information will directly impact on energy saving and resources usage, as CPU and RAM.

Conclusion
It is declared over this paper that its main objective was to propose and effectively build, a well-structured methodology to support the combination of mathematical and computational methods over a hybrid modeling. This proposal goal was to search for a modern and robust solution for the current energy management problems brought by recent changes in society's behavior.
Following that goal, this paper brought up a mathematical-computational modeling by using Fractional Order Differential Calculus along with Decision Tree computational intelligence model techniques, this modeling process compared different techniques of both mathematical and computational tools, as the FODC solutions methods and the DT structures.
After elaborating the whole functionality of the proposed model, this paper shows the results that prove its model viability and efficiency, the authors of this research are pleased with the built methodology, for its capability of solving the analyzed scenario of smart power management. It is expected that this methodology works as reference for other researchers, in the common goal to improve power management efficiency.
For future research, the authors of this paper plan to adjust this methodology for greater and more complex scenarios.
It is also intended to increase the algorithm's performance by the application of different computational intelligence techniques, which may provide an improvement on the Internet of Things (IOT) made possible by the 5G technology. Looking for more probabilistic analysis, future works will include Bayesian Networks implementation to better comprehend modern stochastic systems.