# Jason-RS, A Collaboration Between Agents and an IoT Platform

Hantanirina Felixie Rafalimanana, Jean Luc Razafindramintsa, Sylvain Cherrier, Thomas Mahatody, Laurent George, Victor Manantsoa

<figure><img src="image_1.png" /></figure>

## To cite this version:

Hantanirina Felixie Rafalimanana, Jean Luc Razafindramintsa, Sylvain Cherrier, Thomas Mahatody, Laurent George, et al. Jason-RS, A Collaboration Between Agents and an IoT Platform. 2nd International Conference on Machine Learning for Networking (MLN), Dec 2019, Paris, France. pp.403-413, 10.1007/978-3-030-45778-5_28. hal-03266450

HAL Id: hal-03266450

https://inria.hal.science/hal-03266450

Submitted on 21 Jun 2021

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_2.png" /></figure>
# Jason-RS, a Collaboration between Agents and an IoT Platform

Hantanirina Felixie RAFALIMANANA<fnref n="1" />, Jean Luc RAZAFINDRAMINTSA<fnref n="1" />, Sylvain CHERRIER<fnref n="2" />, Thomas MAHATODY<fnref n="1" />, Laurent GEORGE<fnref n="2" />, Victor MANANTSOA<fnref n="1" />

**Abstract.** In this article we start from the observation that REST services are the most used as tools of interoperability and orchestration in the Internet of Things (IoT). But REST does not make it possible to inject artificial intelligence into connected objects, ie it cannot allow autonomy and decision-making by the objects themselves. To define an intelligence to a connected object, one can use a Beleive Desire Intention agent (BDI an intelligent agent that adopts human behavior) such as Jason Agentspeak. But Jason AgentSpeak does not guarantee orchestration or choreography between connected objects. There are platforms for service orchestration and choreography in IoT, still the interconnection with artificial intelligence needs to be built. In this article, we propose a new approach called Jason-RS. It is a result of pairing Jason BDI agent with the web service technologies to exploit the agent capacity as a service, Jason-RS turn in Java SE and it does not need any middleware. The architecture that we propose allows to create the link between Artificial Intelligence and Services choreography to reduce human intervention in the service choreography. In order to validate the proposed approach, we have interconnected the Iot BeC³ platform and the REST agent (Jason-RS). The decision-making faculty offered by Jason-RS is derived from the information sent by the objects according to the different methods of REST (GET, POST, PUT, and DELETE) that Jason-RS offers. As a result, the objects feed the inter-agent collaborations and decision-making inside the agent. Finally, we show that Jason-RS allows the Web of Objects to power complex systems such as an artificial intelligence responsible for processing data. This performance is promising.

**Keywords:** BDI Agent, BeC³, Internet of Thing, Jason.

<footnote n="1">¹ Laboratory for Mathematical and Computer Applied to the Development Systems, University of Fianarantsoa, Madagascar</footnote>

<footnote n="2">² Université Paris-Est, Institut Gaspard Monge (LIGM), 77454 Marne-la-Vallée Cedex 2</footnote>

<footnote n="1">¹dhaliahfeli@gmail.com</footnote>

<footnote n="1">¹ razafindramintsa.jeanluc@yahoo.fr</footnote>

<footnote n="2">²sylvain.cherrier@u-pem.fr</footnote>

<footnote n="1">¹tsmahatody@gmail.com</footnote>

<footnote n="2">²laurent.george@u-pem.fr</footnote>

<footnote n="1">¹vmanantsoa@moov.mg</footnote>
# 1 Introduction

The tendency towards the Web of Object (WoO) does not cease to increase from time to time. Given the number of objects to facilitate the daily life, the number of possible interactions and the applications that one can imagine become more powerful and rich. But what are the ways to make these applications in a generic way? The object web orientation is considered as a great resource not only for managing objects [1] but also for questions of flexibility of exchanges. In the Web of Object (WoO) one is rather directed towards the use of Web Service [1].

We note that the most used Web Service type is REST<fnref n="1" /> [2] [1] [3]. REST (Representational State Transfer) or RESTful is an architecture style for building applications (Web, Intranet, Web Service). It is a set of conventions, rules and good practices to respect and not a technology in its own right. Not only REST is stateless [4] (meaning that the service consumer does not have to store information about the way he is using the service); it is designed to reduce the coupling between software pieces. In the IoT, REST may allow reconfiguration of the object, it reuse in a different application for a multiplatform application, REST service structure is easy to describe. REST allows machine to machine communication and is simpler to do than SOAP. The communication is done through the HTTP protocol. Nevertheless the possibility of using the resource via the web given by the REST, it still lacks intelligent data processing. Our contribution aim to add a complex data processing of the object web. We then opt for the reuse of our search fruit in [5] which we call Jason-RS or Jason-Rest for more precision.

Jason-RS gives the REST Web Service ability to the BDI agent Service [5]. Jason is a multi-agent platform based on the Agentspeak-L language [6] [7]. It is a platform for BDI agent, that is to say goal-oriented software agent, it is a smart agent. We have to look at the choice of the BDI agent because it is close to human behavior. [8] [9]. So the connexion of the latter with the REST Web Service allows him to publish his capacity as a Web Service. The processing of a complex action can be done inside Jason (prediction, composition of services, constraint logic programming) and could be published as a Web Service. Jason-RS can serve as an intelligent treatment center.

We focus in the collaboration between agent and IoT platform cause connected object had no intelligence, designed differently, so with this collaboration we can open in the intelligence of IoT with a sensor less, little human intervention. In our approach, we collect the information from the connected object and by Jason-RS we delegate the intelligent agent works. All change in the object behavior is sent to the agent BDI (as a perception) in order to provide a decision or to change the agent comportment. Through this perception that the agent can decide and delegate a task to agent or service choreography to object.

<footnote n="1">¹ https://www.supinfo.com/articles/single/5642-qu-est-ce-qu-une-api-rest-restful</footnote>
The rest of this article is organized as follows: Section 2 will discuss the related work of our work. Section 3 describes in general the architecture of our contribution. In section 4 we will evaluate our work through an architecture. In section 5 we discuss a discussion and open challenge. We will conclude this article with a conclusion (section 6).

## 2 Related work

In this article we propose a new form of Web Service that the WoO can use. The use of REST in WoO is not an innovative work as researchers have already done research for the implementation of the latter to allow connected objects to trade [10] [11]. The Internet of Things is a system of physical objects that can be discovered, monitored, controlled or interact with electronic devices that communicate on various network interfaces and can potentially be connected to the wider Internet.

The webs of object is a concept say recent in computing that offers a future with which object of the daily life can integrate into the web [12]. The Web of Object is considered as a subset of the Internet of Things. WoO applies to standards and software infrastructures such as REST, HTTP and URIs to create applications and services that combine and interact with a variety of network devices. The key point of the WoO is that its implementation does not involve the reinvention of the means of communication given that they use the existing standards. It also gives an easy access to a wide population of programmer that used to handle such an architecture. It facilitates the integration of the IoT in the internet. It is also a solution that can open the connection of the Industry 4.0 [13].

View the exponential increase of the connected object, to reduce the cost, the required performance and to facilitate communication in the object internet, the W3C recently launched the working group on the Web of Objects. They aim to fight the fragmentation of IoT. They developed the initial standards for the Web of Objects [14]. To facilitate service choreography for Iot Cherrier describes in his thesis a new approach based on a platform to standardize the interoperability of heterogeneous objects [15].

Castellani and Al focused on the implementation of both CoAP and EXI technology for communication between objects by adopting the REST approach [16]. They implemented the CoAP protocol to enable communication between distributed connected objects. Then they also implemented the EXI library for compressing XML data into binary.

In the paper [2], they discuss how to create an event SOA. They found a new approach for coordinating IoT's services with the resource service. They named EDSOA the result of their research. It is an asynchronous SOA and responsive it can be considered as an event based service. We have inspired by this approach for the technical aspect of Jason-RS.

The Web of Object is used in almost any IoT field even in the field of health. On what [17] proposed a new instance of cloud server and set up data collection services
on the heterogeneous devices they use. This aims to improve online health service by properly implementing the architectural web object principle for remote control.

Based on WoO, [4] describes the object-based web architecture that adopts the principle of Resource Oriented Architecture (ROA), hence the basis of RESTful. They implemented a smart gateway for smart meters. This allows the connected object management servers to keep track of the status and movements of the objects.[2] the HTTP protocol is used to facilitate access to the service. The answer emitted is in JSON format. The architecture proposed by [4] allows developers to use web programming languages such as (HTML, Python,...).

All of the research cited above are interesting from the point of view of exposure and communication capacity in the Internet of Things. Each with its strong point in communication and interconnection in the world of IoT. They all almost used the REST Web Service. But for us, a simple service is not enough not only to bathe the connected objects in the artificial intelligence but also to treat in intelligent way the data captured at the level of the objects. This treatment helps automatic decision-making thanks to the intelligent BDI agent that has the same reasoning mode as humans. We focus our research on the intelligent Web Service, that is, a Web Service associated with artificial intelligence in order to reduce human intervention to the orchestration of services in connected objects and decision-making. We have exploited here our previous research work, Jason-RS. An intelligent Web Service with BDI agents that perform the resolution and automation of certain tasks thanks to their ability to cooperate and exchange using the AgenSpeak (L) agent language. These agents may then exhibit functionality as a Web Rest Service. Jason-RS has the methods used in REST (GET, PUT, POST, and DELETE) to ensure the dialog with heterogeneous clients.

# 3 Proposed Architecture

## 3.1 General architecture

In this section we discuss the general architecture of our approach. As we are in the world of the IoT there is a mean of communication: the network. There are many types of networks today for the connectivity of objects such as wifi, Bluetooth for common devices, LoraWAN for IoT devices using long distance communication, and ZigBee, 6LowPan, EnOcean, Zwave for short range communication devices, etc. As connected objects do not have enough memory space and very limited energy to feed themselves permanently so it is important to outsource most of its function. Although the design of its objects is different (ie the objects are heterogeneous), a standardization platform is important to allow inter-object choreography. Taking into account all these parameters we have our control center server constituted by the Jason-RS server and the IoT server illustrated by Fig. 1. Generally the IoT server is a centralized platform of (Cloud, big data) whether it is an IoT server that administers the objects.

Jason plays a complex problem solver role as well as the complex system such as optimization ... The autonomous and goal-oriented capability through the BDI agent that it implements allows it to perform a task reasonably. This capability is now exploitable through a distributed component as a service [5] through Jason-RS. Then the
objects can use it not only to send the sensor data but also to initiate a decision-making
process at the agent level.

Communication between the IoT and the web is done through the HTTP protocol.
With Jason-RS we can use all the existing methods of the REST and most importantly
there is an interaction with the agent. As a result we can send data to the central control
servers via the POST method. We can also retrieve the data or decision made by the
GET method. JASON-RS recognizes directly the task that will send back to the agent.

At the agent level as soon as the service is called by the objects or other platform,
the agent reacts and changes state in relation to the perception it receives from it envi-
ronment.

<figure><img src="image_3.png" /><figcaption>Fig. 1. General architecture of the JASON-RS implementation in the Web of Object</figcaption></figure>

We have already studied in our article [5] the publication of Jason's BDI agent ca-
pability as a Web Service. We have proposed an approach allows deploying and run-
ning Web Services (REST and SOAP) pairs with a Jason BDI agent in java SE envi-
ronment. We didn't use a modern Web-App server or application server, and we didn't
developed a different middleware cause it requires a lot of time. Deploying an agent
inside a server is a tedious task. Then in our strategy, we reused the existing Java fram-
works called Non-Blocking Input Output. A small illustration for brightening the archi-
tecture is shown in Fig.2.
<figure><img src="image_4.png" /><figcaption>Fig. 2. General architecture of the JASON-RS micro-service [5]</figcaption></figure>

Jason-RS offers an opportunity to exploit the world-class logic, which is embedded in Jason. It can associate them with other elements or heterogeneous application. When we can manipulate first-order logic, we can imagine a kind of possibility of complex problem solving as well as the common problem in artificial intelligence. What is interesting here is that the reasoning mode of Jason agent is near the human reasoning mode to achieve a goal. Jason-RS aims to outsource the capacity present in Jason as a service.

This initial Jason-RS that we have exploited with the collaboration with the Iot platform to intelligently process the data received from the connected object. By exploiting the horn clause and the first-order logic included in Jason we will use this ability to decide the action of objects. Then we take into account the behavior of the objects as perception for the agents.

To validate our approach we tested the interoperability of Jason-RS and heterogeneous objects choreographed with BeC³.

## 3.2 Application of the architecture with a python object and BeC3

**Scenario.** To illustrate and motivate our approach, we introduce a concrete application using the following scenario. We take the example of the disposal of household waste in our paper [5]. Waste disposal agents have waste disposal costs that vary according to time constraints, people, distances traveled and evacuation loads. A decision-maker who gives these opinions to optimize the evacuation of waste thanks to the information
that the evacuator agents gives him. Information of each of its agents could be changed thanks to the perception emitted by different connected objects. The Fig. 3 illustrates the application of this scenario. We used BeC³ for the service Mashup. BeC³ is a composer who allows a user to choreograph heterogeneous objects. In our experimentation we have created sensor objects choreographed in BeC³ with other objects. This sensor sends the data captured via Jason-RS in POST for the agents to change the perception of the Jason agent (receiver agent). A decision-maker analyzes the present data and the cost of performing the tasks for each of his agents in order to decide which one is durable, and which one can perform a task at lower cost.

The sensor is controlled by the Python version of service compatible with BeC³. When the service is launched, it can send a POST request to BeC³ to identify itself and then another POST request to set up its feature handled by the device. Any mashup designed by a user can then be assured by a communication the service on each object. The decision made by the agent could be consumed via a GET request to the Jason-RS.

<figure><img src="image_5.png" /><figcaption>Fig. 3. Application interaction between object choreography and Jason-RS</figcaption></figure>

# 4 Result and discussion

We tested this approach in two different objects: a python object, a mobile phone. We used Jason-RS to communicate the BeC³ platform with choreographed objects and BDI agents who take the place of a decision maker instead of a human being (such as it is originally designed in BeC³).
There is a demo script (in Python) APIDemo.py in Pylite project (resources dir). We have used xmpp<fnref n="2" /> server for login, its specificity is the presence. So as we describe in the section 3 we must log in BeC³ in order to create a virtual programmable object:

```json
POST /login with content
{
  "username": {xmpp login},
  "password": {xmpp password},
  "service": {xmpp service (for example im.bec3.com)}
}
```

After login, create a BeC³ object with the following JSON format:

```json
POST /feature with content
{
  "name": "tot2",
  "path" : "truc/bidul21",
  "type": "switch",
  "details": "ooo",
  "widget": "none",
  "MQTT": false
}
```

Available types are accelerometer, button, buzzer, gauge, gps, These object can be delete, update.

```json
DELETE /feature/{id}
PUT /feature/{id}
{
  "data": {data (dependent of object type)}
}
```

One object is associate with one BDI agent. To connect BeC³ an URL is available from Jason-RS. To change the agent BDI perception a POST request is send by this url format:

```json
POST jason_rs_based_url/object_agent/
{
  "data": value_from_python_object
}
```

To receive a decision from BDI agent, Jason-RS provide an URL that we can consume:

```http
GET jason_rs_based_url/agent_decider/decision
```

<footnote n="2">² https://xmpp.org/</footnote>
The following sequence diagram presented in Fig.4 shows the exchange between these two platforms

<figure><img src="image_6.png" /><figcaption>Fig. 4. Sequence diagram for communication between object a Jason agent by Jason-RS</figcaption></figure>

We analyzed the performance of our approach via a browser.

<table><caption>**Table 1.** The calculation time of the exchanges between the objects and Jason-RS</caption><thead><tr><th>Device</th><th>Method REST</th><th>Task</th><th>Duration (millisecond)</th></tr></thead><tbody><tr><td>Python Object</td><td>GET</td><td>Consumation WS</td><td>200-450</td></tr><tr><td>Smart Phone</td><td>POST, GET</td><td>Sending data</td><td>428-1000</td></tr></tbody></table>

We tested our approach on both devices. During our experiment the return is almost <= 1000 ms. Our test area are done through the WIFI network so the discussion field is open for other types of networks available for the Internet of Things.

Agent-based internet of things is an interested field of research now [18], in the face of these works, we focus in the technical side of things, and we compare in table 2 what differentiates our approach compared to the state of the art.

<table><caption>**Table 2.** Comparison with a similar research domain work</caption><thead><tr><th>Work in field Jason agent and IoT</th><th>Agent flexibility in internet</th><th>Horn Logic</th><th>Taking in count Heterogeneity of IoT</th></tr></thead><tbody><tr><td>[19]</td><td>?</td><td>yes</td><td>?</td></tr><tr><td>[20]</td><td>?</td><td>?</td><td>yes</td></tr></tbody></table>
<table><tr><td>[21]<br>Jason-RS and<br>IoT Platform</td><td>?</td><td>yes</td><td>?</td></tr><tr><td></td><td>yes</td><td>yes</td><td>yes</td></tr></table>

So in our approach we taking in count the heterogeneity of IoT by using a platform BeC³. To permit an automatic decision making we exploit the horn logic provided in Jason. This collaboration permit a flexibility in interacting between agent and heterogeneous connected object.

## 5 Conclusion

This article describes our contribution on service improvement in the world of Web of Object. We have integrated our previous Jason-RS research work into the sensor device connected to the web. Object of the IoT do not support the execution of artificial intelligence within themselve because there resources are very limited. Our approach is towards the decentralization of this AI treatment with Jason-RS. Not only is Jason-RS a Web Service but it has an artificial intelligence BDI engine running. So the complex data processing in the connected web object is provided by the Jason. The communication is done through HTTP protocol as it is more flexible and commonly adopted in the world of web. We tested our approach with a Mashup service platform for heterogeneous connected objects called BeC³. Our approach therefore allows the object connected to the web to open up to data processing with artificial intelligence as well as complex systems itself. As perspective we are considering the automatic injection of service inside the connected object to reduce the human task of defining the service choreography.

## References

1. Laine, M. (2012). Restful Web Services for the internet of things. Online]. Saatavilla: http://media.tkk.fi/webservices/personnel/markku_laine/restful_web_services_for _the_in-ternet_of_things.pdf.

2. Gupta, P., Mokal, T. P., Shah, D. D., & Satyanarayana, K. V. V. (2018). Event-Driven SOA-Based IoT Architecture. In International Conference on Intelligent Computing and Applications (pp. 247-258). Springer, Singapore.

3. Wilde, E. (2007). Putting things to REST.

4. Guinard, D., Trifa, V., & Wilde, E. (2010, November). A resource oriented architecture for the Web of Objects. In IoT (pp. 1-8).

5. Rafalimanana, H. F., Razafindramintsa, J. L., Ratovondrahona, A. J., Mahatody, T., & Manantsoa, V. (2018, December). Publish a Jason Agent BDI Capacity as Web Service REST and SOAP. In *International conference on the Sciences of Electronics, Technologies of Information and Telecommunications* (pp. 163-171). Springer, Cham.

6. A. S. Rao, « AgentSpeak(L): BDI agents speak out in a logical computable language », in *Agents Breaking Away*, vol. 1038, W. Van de Velde et J. W. Perram, Éd. Berlin, Heidelberg: Springer Berlin Heidelberg, 1996, p. 42-55.
7. A. Ricci, R. H. Bordini, et J. F. Hübner, « AgentSpeak(ER): An Extension of AgentSpeak(L) improving Encapsulation and Reasoning about Goals », p. 3, 2018.

8. Norling, E. (2003, July). Capturing the quake player: using a bdi agent to model human behaviour. In *Proceedings of the second international joint conference on Autonomous agents and multiagent systems* (pp. 1080-1081). ACM.

9. Kamphorst, B., van Wissen, A., & Dignum, V. (2009, November). Incorporating BDI agents into human-agent decision making research. In *International Workshop on Engineering Societies in the Agents World* (pp. 84-97). Springer, Berlin, Heidelberg.

10. Ciortea, A., Boissier, O., & Ricci, A. (2017, October). Beyond physical mashups: Autonomous systems for the Web of Objects. In *Proceedings of the Eighth International Workshop on the Web of Objects* (pp. 16-20). ACM.

11. Kovatsch, M., Hassan, Y. N., & Mayer, S. (2015, October). Practical semantics for the Internet of Things: Physical states, device mashups, and open questions. In *2015 5th International Conference on the Internet of Things (IOT)* (pp. 54-61). IEEE.

12. D. Guinard, « A Web of Objects application architecture: Integrating the real-world into the web », PhD Thesis, ETH Zurich, 2011.

13. Kim, J. H. (2017). A review of cyber-physical system research relevant to the emerging IT trends: industry 4.0, IoT, big data, and cloud computing. *Journal of Industrial Integration and Management*, 2(03), 1750011.

14. « W3C Web of Objects at W3C ».https://www.w3.org/WoO/.

15. Cherrier, S., Salhi, I., Ghamri-Doudane, Y. M., Lohier, S., & Valembois, P. (2014). BeC 3: behaviour crowd centric composition for IoT applications. *Mobile Networks and Applications*, 19(1), 18-32.

16. Castellani, A. P., Gheda, M., Bui, N., Rossi, M., & Zorzi, M. (2011, June). Web Services for the Internet of Things through CoAP and EXI. In *2011 IEEE International Conference on Communications Workshops (ICC)* (pp. 1-6). IEEE.

17. L. Pescosolido, R. Berta, L. Scalise, G. M. Revel, A. De Gloria, et G. Orlandi, « An IoT-inspired cloud-based Web Service architecture for e-Health applications », in *2016 IEEE International Smart Cities Conference (ISC2)*, Trento, Italy, 2016, p. 1-4.

18. Savaglio, C.; Ganzha, M.; Paprzycki, M.; Bădică, C.; Ivanović, M.; Fortino, G. Agent-based Internet of Things: State-of-the-art and research challenges. Future Gener. Comput. Syst. 2020, 102, 1038–1053.

19. Ciortea, A., Boissier, O., Zimmermann, A., & Florea, A. M. (2016, November). Responsive decentralized composition of service mashups for the internet of things. In *Proceedings of the 6th International Conference on the Internet of Things* (pp. 53-61). ACM.

20. Singh, M. P., & Chopra, A. K. (2017, June). The internet of things and multiagent systems: Decentralized intelligence in distributed computing. In 2017 IEEE 37th International Conference on Distributed Computing Systems (ICDCS) (pp. 1738-1747). IEEE.

21. Novais, P., & Konomi, S. (2016, October). From raw data to agent perceptions for simulation, verification, and monitoring. In Intelligent Environments 2016: Workshop Proceedings of the 12th International Conference on Intelligent Environments (Vol. 21, p. 66). IOS Press.