An Aspect-Oriented Approach to Time-Constrained Strategies in Smart City IoT Applications

: The Internet of Things (IoT) is growing rapidly in various domains, including smart city applications. In many cases, IoT data in smart city applications have time constraints in which they are relevant and acceptable to the task at hand—a window of validity (WoV). Existing algorithms, such as ex post facto adjustment, data ofﬂoading, fog computing, and blockchain applications, generally focus on managing the time-validity of data. In this paper, we consider that the functional components of the IoT devices’ decision-making strategies themselves may also be deﬁned in terms of a WoV. We propose an aspect-oriented mechanism to supervise the execution of the IoT device’s strategy, manage the WoV constraints, and resolve invalidated functional components through communication in the multi-agent system. The applicability of our proposed approach is considered with respect to the improved cost, service life, and environmental outcomes for IoT devices in a smart cities context.

The smart city is "derived from the adoption and application of mobile computing systems through practical data management networks amongst all components and layers of the city itself" [8].A smart city is an "urbanization region that collects data using several digital and physical devices . . . to manage revenues, resources and assets . . .utilized to boost performance throughout the city" [3].
In [9], the authors identify social, environmental, and economic sustainable development as prerequisites for smart cities. IoT-based and related disruptive technologies are proposed as a way of achieving these goals [9].They consider smart cities in terms of dimensions, digital transformation, sustainability, and resiliency [9].However, they note that existing research has been focused on "megacities in developed nations [9]" and that there is room for broader studies which consider smart city applications in a wider range of contexts [9].
In a survey of smart city IoT applications [2], the authors enumerate several components of smart cities in which IoT technologies take part: smart transportation, smart agriculture, smart energy, smart infrastructure, smart city services, smart homes, smart health, and smart industry.
Each of these smart city components is supported by a complex infrastructure, from the sensing layer, comprising resource-constrained edge devices, through to the business layer, comprising data analytics supported by applications and cloud services [2].To achieve these goals, the temporal aspect of data and agent behavior in such systems is critical: smart city applications must respond to changes in the environment and dynamically reconfigure themselves to provide optimal service.
In [10], the authors propose to use enterprise architecture (EA) and service-oriented architecture to support the development of smart cities.The EA approach considers four perspectives: the "business view, IT view, governance view, and security view [10]".Service-oriented architecture (SOA) "offers flexible integration and service reusability [11]" through a service-based modular architecture [11].
Other research has considered the potential for applying machine-learning strategies to improve smart city outcomes [12], the relationship between smart city policies and sustainability [13] and security and privacy risks [14].
Each of these considerations can be applied in a smart city in the form of a strategy, implemented in an executable form and disseminated to the IoT nodes in the smart city.
The distributed and real-time nature of the data in such IoT applications means that, often, these data are transient [15].Some of the data are superfluous in a given time period, while other data "may remain useful for only a specific period of time after . . .originally queried and cached" [16].In [16], we proposed that, generally, data in the IoT have a window of validity (WoV) which can be defined according to the relevance of the data at a particular time and whether an acceptable copy of the data is available.
In this paper, we consider the research question of how the problem of time-constrained strategy dissemination can be resolved with minimal resource impact.We propose that, in smart cities applications, besides the WoV of data, the strategies employed in the decisionmaking algorithms themselves may be time-constrained by a WoV.Our paper proposes a method by which the software engineering problem of how to efficiently manage the dissemination and evolution of such strategies in the IoT/smart cities context can be resolved, ensuring the timeliness and applicability of both the data and the decision-making strategies acting on them.
We propose to extend the aspect-oriented approach we took for managing timeconstrained data in smart city IoT systems [16] to the management of time-constrained strategies.Our research has broad applicability across the smart city components [2], providing a method for improving the efficiency and responsiveness of the strategies, cost, service life, and environmental outcomes in the smart cities context.The proposed approach could be applied to a wide range of data and strategies in a smart cities context, including geospatial data, IoT sensor data, health data, transport data, energy usage data, demographic data, hazard and climate data, and human information and reporting data, among others, which, in turn, drive the software implementations of smart city management strategies such as smart health, transportation, and environmental management [9].
In Section 2, we survey existing approaches to time-constrained data and strategies in smart cities.In Section 3, we present our proposed aspect-oriented mechanism which builds on our research in [16], extending and applying it to the management of time-constrained of strategies.In Section 4, we discuss the benefits of applying our proposed model to the management of time-constrained strategies in IoT systems in a smart cities context.

Existing Approaches
In this section, we review several existing approaches to the general problem of time constraints in smart city IoT systems and discuss their limitations with respect to timeconstrained strategies.We then discuss several potential approaches to software updates in IoT systems, highlighting their shortcomings with respect to time-constrained strategies.Then, we review our prior research on aspect-oriented approaches to the WoV of data.

Time-Constrained Data in Smart Cities
Due to their resource constraints, IoT applications in smart cities contexts often operate such that their data are time-constrained into a window of validity (WoV) [11,[16][17][18].In many smart city applications, such as smart transportation, the correctness and applicability of the data may be strongly impacted by the ability to communicate it upstream within the WoV [19].
In [16], we proposed to model the WoV of IoT device data according to two parameters: whether the data are relevant to the decision-making algorithm at a particular time, and whether an acceptable version of the data is cached locally.When the decision-making algorithm which runs on the IoT data attempts to access data which is not in its WoV, the supporting software infrastructure is engaged either to fetch the data for the first time or to update an invalidated, locally cached copy [16] (Figure 1).

Time-Constrained Data in Smart Cities
Due to their resource constraints, IoT applications in smart cities contexts oft erate such that their data are time-constrained into a window of validity ( [11,16,17,18].In many smart city applications, such as smart transportation, the co ness and applicability of the data may be strongly impacted by the ability to commu it upstream within the WoV [19]. In [16], we proposed to model the WoV of IoT device data according to two pa ters: whether the data are relevant to the decision-making algorithm at a particular and whether an acceptable version of the data is cached locally.When the decision ing algorithm which runs on the IoT data attempts to access data which is not in its the supporting software infrastructure is engaged either to fetch the data for the firs or to update an invalidated, locally cached copy [16] (Figure 1).There are various practical approaches used to resolve data in IoT systems whe are outside their WoV.In [19], the authors propose an algorithmic framework to a ex post facto, for temporal and spatial discrepancies caused by communications los smart transportation data to improve the quality and precision of the data.This app is suitable where the data is collected into a dataset for later analysis but is less where decisions must be made based on the real-time values of IoT sensors.
Others have proposed offloading the data from less capable edge devices to capable mobile devices such as unmanned aerial vehicles (UAV) [11,20].In theor There are various practical approaches used to resolve data in IoT systems when they are outside their WoV.In [19], the authors propose an algorithmic framework to adjust, ex post facto, for temporal and spatial discrepancies caused by communications losses in smart transportation data to improve the quality and precision of the data.This approach is suitable where the data is collected into a dataset for later analysis but is less useful where decisions must be made based on the real-time values of IoT sensors.
Others have proposed offloading the data from less capable edge devices to more capable mobile devices such as unmanned aerial vehicles (UAV) [11,20].In theory, this approach would improve the real-time data gathering and processing in the IoT network; however, in practice, the deployment of swarms of autonomous vehicles may not be feasible or available with sufficient coverage at scale in a smart city.Other potential obstacles to this approach include the high level of heterogeneity typical of IoT devices and their limited capacity to communicate with complex, moving platforms such as UAVs.

Fog Computing
One method which seeks to achieve the same offloading benefits without the associated complexity of mobile physical platforms is fog computing [21][22][23][24].The exact definition of fog computing is yet to be formally set, but, generally, it can be described as "a paradigm that extends the cloud and integrates edge and IoT, while providing a new, horizontally scalable highly virtualized layer that distributes computing, control and networking capabilities" [22].In [24], the authors describe the relationship between fog and cloud computing as a "computational paradigm that aims to bring the benefits of the cloud closer to end devices. . .highly integrated with the cloud, but with the processing also being carried out at the edge of the network, enabling the execution of applications that [previously] were not possible due to the high latency that existed between the devices and the cloud".
An example of a smart city architecture using fog nodes as an intermediary between the smart city cloud and deployed IoT devices is shown in Figure 2.This architecture creates a middleware tier called the 'fog' between the high-cost, high-capability cloud, and the constrained edge device.Thus, some of the real-time decision-making logic may be carried out in the fog node, close to the edge devices, while complex, data-intensive applications can run in the cloud with an acceptable level of latency.
approach would improve the real-time data gathering and processing in the IoT network; however, in practice, the deployment of swarms of autonomous vehicles may not be feasible or available with sufficient coverage at scale in a smart city.Other potential obstacles to this approach include the high level of heterogeneity typical of IoT devices and their limited capacity to communicate with complex, moving platforms such as UAVs.

Fog Computing
One method which seeks to achieve the same offloading benefits without the associated complexity of mobile physical platforms is fog computing [21][22][23][24].The exact definition of fog computing is yet to be formally set, but, generally, it can be described as "a paradigm that extends the cloud and integrates edge and IoT, while providing a new, horizontally scalable highly virtualized layer that distributes computing, control and networking capabilities" [22].In [24], the authors describe the relationship between fog and cloud computing as a "computational paradigm that aims to bring the benefits of the cloud closer to end devices… highly integrated with the cloud, but with the processing also being carried out at the edge of the network, enabling the execution of applications that [previously] were not possible due to the high latency that existed between the devices and the cloud." An example of a smart city architecture using fog nodes as an intermediary between the smart city cloud and deployed IoT devices is shown in Figure 2.This architecture creates a middleware tier called the 'fog' between the high-cost, high-capability cloud, and the constrained edge device.Thus, some of the real-time decision-making logic may be carried out in the fog node, close to the edge devices, while complex, data-intensive applications can run in the cloud with an acceptable level of latency.The essential characteristics of fog computing include the contextual location awareness, low latency, geographical distribution, heterogeneity, interoperability and federation, real-time interactions, scalability, and agility of federated, fog-node clusters [25].The essential characteristics of fog computing include the contextual location awareness, low latency, geographical distribution, heterogeneity, interoperability and federation, real-time interactions, scalability, and agility of federated, fog-node clusters [25].Many smart cities applications of IoT technology aim for a close temporal connection between the data gathered by IoT sensors and their use in the environment [23].To this end, in [23], the authors present a scalable model to "process data close to sensors and distributed in the fog while data are stored in the cloud" [23].Thus, fog computing presents a promising approach to managing the WoV problem for data in smart city applications of IoT.

Many smart cities applications of IoT technology aim for a close temporal connection
In [21], the authors propose a framework named PIAF (Processing Intelligent Agent running on Fog infrastructure) for maximizing the distribution of time-critical data streams processing on the fog infrastructure using MAS.The PIAF workflow comprises the following steps: the selection of the time-critical data stream, splitting the data stream into sub-tasks, prioritization, allocation, execution, tracking, and storage [21].
However, a limitation of this approach is that there "is no unique architecture that can be deployed to represent all industries' structures and behaviors" [21].We, thus, find that, while fog computing provides a promising approach to handling time-constrained data, there is still the question of how to manage the domain-specific behavioral aspect-the decision-making strategy which functions on these data-as it is distributed across the IoT devices.

Time-Constrained Strategies
A time-constrained strategy can be defined as some algorithm, implemented as executable instructions, which operates on data in order to make decisions in an IoT system, where parts of the algorithm have relevance and acceptability constraints according to some WoV.
Just as there are various IoT smart city applications in which the data are timeconstrained, we propose that there are, similarly, various applications where the decisionmaking strategy itself is time-constrained and may not be applicable to the problem domain outside some WoV.
In our considerations of future research directions in [16], we suggested one such example in the smart agriculture context, where certain IoT devices measure various crop parameters, with a decision-making strategy implemented on other devices (such as fog nodes) to control the irrigation of crops.In our example, while the data that drive the decision-making strategy (e.g., meteorological parameters, soil measurements, etc.) are time-constrained, the decision-making strategy itself may also change in accordance with externalities such as seasonal changes and even policy changes (e.g., the water authority may make a substantial change to the water quota, necessitating a new strategy for water allocation).
Supposing that the irrigation strategy is implemented in a fog node physically located in each field, some mechanism must be incorporated in the software engineering design of the fog node to enable it to manage the time validity of the components of its decisionmaking process.It must recognize when its local strategy is outside its WoV and resolve this either through interaction with the high-level cloud infrastructure or with other fog-level agents in the MAS.
Another potential practical application of time-constrained strategies could be to improve energy efficiency in the smart city infrastructure.For example, a smart city could potentially have thousands of streetlights which activate according to a lighting strategy.Rather than simply having the lights turn on and off at particular times of the day, the lighting strategy could be updated regularly, taking into account the dawn and dusk times, moon phase, individual light locations/conditions, and expected weather conditions.Thus, the lights could be activated optimally, providing better safety for pedestrians and motor vehicles while also reducing unnecessary activation time, thereby improving energy usage and cost at scale.
The software architectures required to support such applications would make use of the orchestration capabilities of the cloud to disseminate up-to-date strategies to the fog nodes [24].In the context of IoT software architecture, it is desirable that any such mechanism be easily implementable in the resource-constrained environments typical of IoT devices and fog computing [16].

Software Updates in an IoT Context
There are several existing approaches to the implementation of updating functionality in IoT devices.The Internet Engineering Task Force (IETF) has established a working group on Software Updates for Internet of Things (SUIT) which aims to create a standard for the secure updating of IoT firmware [26].However, the SUIT architecture is primarily concerned with the secure dissemination process and does not specifically address time constraints arising from the WoV of the decision-making process [26].
Another approach to updating IoT devices makes use of distributed ledger technologies and smart contracts to run executable code over the blockchain without the intervention of a trusted third party [27][28][29].Smart contracts have the advantage of being able to incorporate a time constraint for the WoV into the execution of the contract; however, they do not provide a standardized software engineering mechanism for managing the associated WoV in the code of the IoT device itself.Another disadvantage of blockchain-based approaches is the relatively high computational overhead which may present a barrier to implementation in constrained IoT devices [27,30,31].
A recent approach which does consider the time constraint of data is the Age of Information (AoI) approach which seeks to optimize the rate at which information is sent from IoT devices with respect to the devices' power and resource usage [32].AoI is a "metric that captures how frequently the information status at a destination node . . .needs to be updated through status update transmissions from a source node" [32].The AoI approach in [32] uses a scheme where different processes in an IoT agent are prioritized according to their importance and AoI values, considered as an optimization problem.
In [33], the authors approach the AoI from the perspective of an energy-constrained edge-caching node, similar in concept to a fog-computing node in that it processes and caches IoT data close to the edge of the network.The authors propose a time-slotted model which splits the activity of such a node into two phases: a data delivery phase, in which data are transmitted from the edge-caching node to the consumers, and a status updating phase, in which the edge-caching node updates its local copy of the IoT sensor data [33].

Aspect-Oriented Approach to the WoV Problem for Data
Aspect-oriented software design (AOSD) is a programming paradigm that localizes cross-cutting concerns into separate modules, called aspects [34].An aspect-oriented program, then, contains "a standard object-oriented model, with the addition of aspects-an organizational construct which co-locates code pertaining to a cross-cutting concern, even when the execution takes place in different classes" [16].
A mechanism called an aspect weaver is used to match particular signatures in the object-oriented model, such as calls to a method or database, and inject relevant crosscutting code from the aspect into the execution flow of the program [35].
In [16], we proposed an aspect-oriented mechanism for software architecture in IoT systems with WoV constraints on the data, with the goal of simplifying the architecture of IoT systems which rely on time-constrained data.In [16], we proposed a bespoke aspect weaver responsible for maintaining a table which maps data members in the object-oriented software architecture to the real-time status of their WoVs [16].
At runtime, the aspect weaver intercepts calls to data members in the IoT device's object-oriented code.When a call is made to a time-constrained data member, the aspect weaver checks if the data member's value is up-to-date according to its WoV [16].If so, the regular execution flow of the object-oriented program is continued, accessing the data member's value in memory as per a regular object-oriented program [16].However, where a data member's WoV is invalidated, the aspect weaver uses network communications with other agents in the MAS to acquire an up-to-date value, which is then injected into the object-oriented program's memory [16].
The aspect-oriented approach has the advantage of addressing both components of the WoV: relevance, through the on-demand resolution of invalidated data, and acceptability, which may be implemented through some metric such as AoI.Critically, because the aspect code is out-of-band from the regular execution flow of the program, it can be applied 'aftermarket' to existing IoT device code without extensive changes to the existing codebase.

Proposed Aspect-Oriented Approach to Time-Constrained Strategies
In this section, we first discuss some of the limitations of the existing approaches.Then, we present our proposed aspect-oriented approach to time-constrained strategies and the resolution of missing or invalidated data through an MAS.Finally, we present our proposed aspect-oriented approach to the problem of time-constrained strategies.

Limitations of the Existing Approaches and Motivation
The AoI-based approaches are perhaps the most promising candidates presently in the literature for incorporating time constraints in IoT data.However, they are generally focused on the time validity of IoT data flowing in the direction from the IoT device to the consumer, rather than addressing the WoV of executable strategies by which the edge devices themselves make decisions.
Thus, there is a need for an approach to updating functionality which fully integrates time constraints on the functional decomposition of the IoT device's strategy.Additionally, IoT systems run on complex, heterogeneous software stacks.
Time constraints on sections of executable code are not inherently integrated into existing programming languages as native constructs.Integrating such changes in an object-oriented environment would necessitate a fundamental change in approach to how these systems are coded, severely limiting the feasibility of practical implementations unless some mechanism can be provided to retroactively apply the WoV constraints to existing executable code.
To this end, we propose that an aspect-oriented approach is ideal for this software architectural problem.

Resolution of Invalidated Data through the MAS
To achieve the inter-agent resolution of invalidated data, we propose to use the MAS framework we developed previously in other research: the Intelligence Transfer Model (ITM) [16,36].The ITM is a software architectural model which aims to improve the fault tolerance and reliability in the MAS through the transfer of 'intelligent activities' which encapsulate the situational awareness, decision-making logic, and agency of the agents in the MAS [36].Intelligent activities may comprise both data and executable code, as well as unresolved references to other intelligent activities which may exist locally at an agent, or require resolution from the MAS [36].
The ITM achieves improved fault tolerance and reliability by first decomposing the graph of a complex executable function into its constituent steps (method calls, attempts to access data variables, etc.), separating the knowledge of how to execute some task from the physical capability of an agent to actually execute it [36].The ITM then distributes this knowledge redundantly in the MAS, even to agents who do not have the capacity to physically execute the task [36].
Under this task-based redundancy model, knowledge of the individual components of a task is replicated amongst agents in the MAS, regardless of their ability to actually perform the task, as opposed to an agent-based redundancy model in which entire agents must be replicated [36].Thus, when new agents join the MAS that do have the required physical capability, they can learn the knowledge of how to execute the task from the existing agents in the MAS [36].
In [36], we developed a candidate implementation of the ITM in which the transfer of intelligent activities was achieved through this real-time sharing of parts of the object model between agents in the MAS and their on-demand injection into the control flow of the program at runtime.We propose that this method of communicating task components between agents can be combined with the WoV mechanism we proposed in [16] to achieve a WoV treatment of the executable components of strategies in IoT devices.

Resolution of Invalidated Strategies through the MAS
A time-constrained strategy is essentially a set of executable instructions and data which potentially make use of other functionality and data which may or may not be acceptable and available at the local agent.These executable instructions need not necessarily be a complete, self-contained program.Rather, the strategies may be modular units of code (such as classes) which can be serialized and transferred between agents in the MAS according to the Strategy design pattern [37,38].
At any given time, different components of the algorithm, represented as calls to methods in the Strategy object, may be in differing WoV states (Figure 3).
of intelligent activities was achieved through this real-time sharing of parts of the object model between agents in the MAS and their on-demand injection into the control flow of the program at runtime.We propose that this method of communicating task components between agents can be combined with the WoV mechanism we proposed in [16] to achieve a WoV treatment of the executable components of strategies in IoT devices.

Resolution of Invalidated Strategies through the MAS
A time-constrained strategy is essentially a set of executable instructions and data which potentially make use of other functionality and data which may or may not be acceptable and available at the local agent.
These executable instructions need not necessarily be a complete, self-contained program.Rather, the strategies may be modular units of code (such as classes) which can be serialized and transferred between agents in the MAS according to the Strategy design pattern [37,38].
At any given time, different components of the algorithm, represented as calls to methods in the Strategy object, may be in differing WoV states (Figure 3).The example in Figure 3 shows the functional decomposition of a strategy comprising six executable components (A-F) at some time t, of which only A and B are within their WoVs (i.e., both relevant and acceptable) at t.No acceptable versions of components C, D, and E are available, perhaps due to their age.Thus, some resolution action will be required to update components C, D, and E when the strategy is executed.
At time t, an acceptable version of component F exists on the device and could be called without further resolution action being necessary.However, at time t, there are no components within their WoV which call F. Thus, the relevance of F to the strategy cannot be determined until the intermediary D is resolved, as, conceivably, an up-to-date version of D may not require F. Should an up-to-date version of D be acquired which references F, component F will immediately enter its WoV without any further resolution action being needed.

Applying the Aspect-Oriented Approach to Time-Constrained Strategies
In developing the software architecture to support time-constrained strategies, we add an additional dimension to the ITM model, integrating it with the aspect-oriented approach we took in [16] for time-constrained data.Thus, in our proposed model, additional out-of-band metadata are maintained by the aspect weaver on the WoV status of each functional component of the strategy.
There are various approaches which may be used to achieve this, the most general being a simple mapping table, with more complex potential solutions including modifying the in-memory representation of the Strategy object to include a WoV field according to the particular constructs of the programming language in use.
Code in the Strategy object may call functions which may or may not yet exist locally, or be within a valid WoV, on the local agent.The aspect-oriented mechanism in the device's infrastructure supervises the execution of the device's main program, intervening to update and acquire, on demand, those executable components of the strategy which are not within a valid WoV.Where calls are made to components of the strategy whose WoVs are invalidated, the aspect weaver may acquire up-to-date versions of the functionality from other agents in the MAS and inject them directly into the object model of the executing program.
Figure 4 shows the architecture of a strategy-based IoT system implementing a WoV resolution component.The Strategy object contains the functional code for implementing the strategy on the IoT device.When a call is made to a functional component, the aspect weaver suspends the normal flow of execution and runs the code in the resolver.The resolver handles the invalidation of the WoV, acquiring the necessary code from other fog nodes or from the cloud.On completion of this process, the control flow is returned to the Strategy object, with the necessary updates injected into the codebase.We propose that the ITM's loosely coupled architecture for transferring intelligent activities is ideal for time-constrained strategy applications because it enables a complex strategy to be broken down into its constituent functional components, each of which may be shared and updated between agents in the MAS.
The resulting efficiencies achieved by sharing only those functional components of an algorithm that are time-sensitive, when scaled up across an entire smart city, have positive implications for such metrics as energy consumption, communications overhead, and latency.In the next section, we discuss some of these potential benefits in the context of a smart city.

Benefits of Applying Our Approach in the Context of a Smart City
In this research, we have proposed a method for managing time-constrained strategies at the granular level of functional decomposition.We also applied technological methods we developed in previous research [16,36] to enable the updating of IoT device functionality at runtime at this granular level of functionality.In the context of smart cities, there are several areas where this approach improves upon existing methods.We propose that the ITM's loosely coupled architecture for transferring intelligent activities is ideal for time-constrained strategy applications because it enables a complex strategy to be broken down into its constituent functional components, each of which may be shared and updated between agents in the MAS.
The resulting efficiencies achieved by sharing only those functional components of an algorithm that are time-sensitive, when scaled up across an entire smart city, have positive implications for such metrics as energy consumption, communications overhead, and latency.In the next section, we discuss some of these potential benefits in the context of a smart city.

Benefits of Applying Our Approach in the Context of a Smart City
In this research, we have proposed a method for managing time-constrained strategies at the granular level of functional decomposition.We also applied technological methods we developed in previous research [16,36] to enable the updating of IoT device functionality at runtime at this granular level of functionality.In the context of smart cities, there are several areas where this approach improves upon existing methods.
Firstly, the act of updating the IoT device's strategy and core functionality is in and of itself non-trivial in the context of the resource-constrained and heterogeneous nature of IoT software.Extant research efforts such as SUIT [26] focus on creating standards for updating device firmware.However, this approach is accompanied by complex security, maintenance, and scale considerations, as well as a need to manage the downtime of devices and services.
Our approach to updating the device functionality is far more flexible, as we achieve this goal through the runtime injection of the necessary functional components directly into the object model using an out-of-band, aspect-oriented mechanism as shown in Figure 4.The disadvantage of our approach in comparison to firmware updates is that the dynamic nature of our approach does not provide for persistence.Thus, where IoT devices are reset, they must re-acquire any updates to their functionality at runtime.The specific characteristics of the smart city application will dictate where this is reasonable and where a persistent firmware update is more appropriate.
Another area of improvement is in the decentralization of the update process and the potential for agents to learn strategies from each other.In the context and scale of a smart city, decentralized approaches provide benefits in terms of reliability, fault tolerance, availability, latency, and survivability.While decentralization is not exclusive to our approach, it is key to it insofar as agents may acquire up-to-date versions of strategy components from any other agent in the system.This capacity for the inter-agent sharing of strategies and their components lays a foundation for various artificial intelligence applications in which intelligent agents may communicate, co-operate, and teach each other better strategies for accomplishing tasks (Figure 5).characteristics of the smart city application will dictate where this is reasonable and where a persistent firmware update is more appropriate.Another area of improvement is in the decentralization of the update process and the potential for agents to learn strategies from each other.In the context and scale of a smart city, decentralized approaches provide benefits in terms of reliability, fault tolerance, availability, latency, and survivability.While decentralization is not exclusive to our approach, it is key to it insofar as agents may acquire up-to-date versions of strategy components from any other agent in the system.This capacity for the inter-agent sharing of strategies and their components lays a foundation for various artificial intelligence applications in which intelligent agents may communicate, co-operate, and teach each other better strategies for accomplishing tasks (Figure 5).The practical implementation of our proposed mechanism in a smart city should also include a plan for its security.Generally, security is an essential component of the design of any form of software update in a deployed/production environment.This consideration is compounded by the physical accessibility of devices across a smart city and the corresponding challenge of physically securing both the devices and the access points to the smart city network which may run over the public internet.Additionally, the large number of IoT devices on the network and their heterogeneity make spoofing and the connection of unauthorized hosts a feasible method of attack.
In the case of our proposed model, executable code is acquired from agents in a de- The practical implementation of our proposed mechanism in a smart city should also include a plan for its security.Generally, security is an essential component of the design of any form of software update in a deployed/production environment.This consideration is compounded by the physical accessibility of devices across a smart city and the corresponding challenge of physically securing both the devices and the access points to the smart city network which may run over the public internet.Additionally, the large number of IoT devices on the network and their heterogeneity make spoofing and the connection of unauthorized hosts a feasible method of attack.
In the case of our proposed model, executable code is acquired from agents in a decentralized system.Thus, ideally, this code should be wrapped in a trust and verification mechanism prior to usage in the field.Security and trust in IoT systems are ongoing areas of research [39][40][41] which are outside the scope of this work.However, the ITM, which we propose to use as the basis for MAS communication in our approach, is designed to integrate into the OSI seven-layer model at the application layer.Trust, encryption, and other security technologies can, thus, be easily integrated into the Presentation and Session layers in our model.
Another key area in which our approach improves outcomes in the smart city context is in terms of communications traffic, and, by extension, power consumption.In contrast with a full firmware update, which may require the transmission of a full image over the network, our approach transmits only those components of a strategy for which the WoV constraints determine an update is necessary (Figure 6).with a full firmware update, which may require the transmission of a full image over the network, our approach transmits only those components of a strategy for which the WoV constraints determine an update is necessary (Figure 6).A reduction in communications usage between IoT devices improves both their overall energy usage and service life [42,43].Thus, by reducing the communications overhead associated with strategy updates at the scale of an entire smart city, both cost and environmental savings can be achieved.A reduction in communications usage between IoT devices improves both their overall energy usage and service life [42,43].Thus, by reducing the communications overhead associated with strategy updates at the scale of an entire smart city, both cost and environmental savings can be achieved.

Contributions to Theory
In this paper, we have proposed a novel approach for managing time-constrained strategies in IoT systems in a smart cities context, building on previous research in which we proposed a mechanism for the management of time-constrained data in IoT systems.This research aligns with the broad smart city research goals to improve resource usage, sustainability, and tailored service provided to the residents of smart cities.
Our approach uses an aspect-oriented mechanism to supervise the execution of a strategy, maintain an account of the window of validity (WoV) of different functional components, and resolve components whose WoV is invalidated.

Contributions to Practitioners
In this paper, we presented two scenarios in which our proposed approach could be applied to improve outcomes in smart agriculture and in optimizing smart city energy usage.However, the proposed approach has general applicability to the design and management of IoT devices in various smart cities contexts with the potential to improve cost, service life, and environmental outcomes through the economical use of communications for strategy updates.
Another key practical advantage of the aspect-oriented approach is its ability to localize the code considerations for the management of the WoV of strategies in an out-of-band manner, independent of the functional implementation of the strategy itself.Considering the time constraint to be an independent dimension of the software design process, the aspect-oriented approach enables a greatly simplified software architecture to be developed.Additionally, it enables the independent development and maintenance of both the strategy itself, and the time-constraint validation process, facilitating the future evolution of each separately.

Limitations and Future Work
This study has considered the potential applications of an aspect-oriented approach to managing the dissemination of strategies in a smart cities context.Although, in earlier research, we have demonstrated the mechanisms upon which our proposal is based, access to a functioning smart city or simulator was not available during this study, and, as such, we were not able to test our approach on a live smart city system.
Therefore, future work may experiment with a practical implementation, perhaps based in a simulator.Another further area of inquiry will be to investigate how the WoV constraints may be seamlessly integrated into programming languages and compilers.Other potential future avenues of research include the trust and security platform on which our proposed approach may sit, and the issue of persistence on the edge device.

Figure 1 .
Figure 1.Example execution flow in our model for managing time validity of data in IoT s according to their window of validity (WoV).

Figure 1 .
Figure 1.Example execution flow in our model for managing time validity of data in IoT systems according to their window of validity (WoV).

Figure 2 .
Figure 2. Smart city architecture with fog computing.

Figure 2 .
Figure 2. Smart city architecture with fog computing.

Figure 3 .
Figure 3. Example functional decomposition of a strategy showing the WoV status of different components (A-F) in the algorithm at some time t.

Figure 3 .
Figure 3. Example functional decomposition of a strategy showing the WoV status of different components (A-F) in the algorithm at some time t.

Figure 4 .
Figure 4. Proposed aspect-oriented mechanism for managing the resolution of time-constrained strategies.

Figure 4 .
Figure 4. Proposed aspect-oriented mechanism for managing the resolution of time-constrained strategies.

Figure 5 .
Figure 5.A smart city implementing an aspect-oriented mechanism which facilitates the synthesis of local strategies through inter-agent sharing of functional components in an MAS.

Figure 5 .
Figure 5.A smart city implementing an aspect-oriented mechanism which facilitates the synthesis of local strategies through inter-agent sharing of functional components in an MAS.

Figure 6 .
Figure 6.Comparison of the firmware-update and aspect-oriented approach to managing the time validity of strategies, showing the lower overhead in the aspect-oriented approach to reach the same goal state.

Figure 6 .
Figure 6.Comparison of the firmware-update and aspect-oriented approach to managing the time validity of strategies, showing the lower overhead in the aspect-oriented approach to reach the same goal state.