# ASP-Based Declarative Reasoning in Data-Intensive Enterprise and IoT Applications
## 2 The DLV-EE Framework
### Reasoning over Hive
To generate a fully customized itinerary, which results as close as possible to desiderata from the user, some profiling functionalities have been implemented; in particular, users can indicate their preferences regarding the type of _POIs_ they intend to visit expressed by numerical values between 0 and 10, for each category of points of interest. Registration (and authentication) functions have been made available to the user to associate itineraries and profiles to a specific user account. The service is made available to mobile users via an Android App called _NavTour_ (see Figure 4). When a new tour has been planned by _DLVNavigator_, it is available in the app; all the stages are reported, and the user can start the tour. When the user physically moves from one place to the next one, the app automatically keeps track of the progresses; interestingly, the tour is dynamically managed: in case the user spends more time than what was originally allotted in the schedule, a rescheduling is automatically determined, taking into account the remaining time and user preferences. For computing the tourist itinerary, _DLVNavigator_ relies on a proper ASP program consisting of two layers. The first layer is in charge of selecting a number of _POIs_ complying with some given constraints (i.e., number, duration, etc.). The selection of _POIs_ is optimized according to user preferences (e.g., how many _POIs_ for each category) and total costs (e.g., ticket prices). The second layer builds the tour by defining the sequence of _POIs_ to visit, taking into account entry/exit times and the available time budget; the tour can also be optimized according to other specific desiderata (e.g., minimizing the distances between consecutive _POIs_ in the tour). Details about the implementation and the ASP programs employed can be found at [[https://www.mat.unical.it/ricca/aspide/dlvee](https://www.mat.unical.it/ricca/aspide/dlvee)]([https://www.mat.unical.it/ricca/aspide/dlvee](https://www.mat.unical.it/ricca/aspide/dlvee)). Figure 4: The _NavTour_ Android application. (**a**) New itinerary; (**b**) Planned Tour. ### Controlling Traffic Lights in Road Crossings

In a smart city [287 ], digital technologies, such as edge devices or sensors, are scattered throughout the city to collect data. Leveraging technological solutions from different areas, such as IoT, Social Computing, and Artificial Intelligence, new information about the surrounding environment is inferred from collected data [30; 31]. Such information is used for automatizing a \"smart\" management of infrastructures, resources, and services. The following part illustrates how DLV-IoT can be used as a smart city technology. As a target use case, consider a simplified setting consisting of three roads with two crossings, namely c1 and c2, as shown in Figure 5. On each crossing, there are four traffic lights, one per each traveling direction, i.e., _s1_, _s2_, _s3_, and _s4_. For the sake of simplicity, it is supposed that vehicles can only go straight without turning right or left and that the behavior of the two crossings follows the rules listed below. * In each crossing, the two traffic lights on the same road must simultaneously have the same status; thus, they are grouped in the pairs _<s1_, _s4>_ and _<s2_, _s3>_. In addition, when _<s1_, _s4>_ have the red status, _<s2_, _s3>_ have the green status and vice-versa. Green means that vehicles can pass; red means that vehicles have to stop. * Every 10 s, the traffic lights switch their status. * In case a pedestrian wants to request to cross at a traffic light, it and its paired traffic light turn red. Consequently, the status of both traffic lights in the other pair of the same crossing switches to green. * The _green wave_ can be enabled at certain times of the day, to force the pair _<s1_, _s4>_ of both crossings _c1_ and _c2_ to become simultaneously green, while all the other traffic lights must turn red. This scenario was simulated using some _Arduino_ and _Raspberry Pi_ devices.