Smart Design for Resources Allocation in IoT Application Service Based on Multi-agent System and DCSP

In the present paper, we aim at solving two problems; the first problem occurring in the transformation of the IoT devices (sensors, actuators, ...) to cloud service. Therefore, we work on maintaining a smooth and efficient data transmission for the cloud and support customer applications like: data sharing, storage and processing. The second problem has two dimensions. In the first dimension, the problem is arisen in the submission of cloudlets (customer requested jobs) to Virtual Machines (VMs) in the hosts. To solve this problem, we propose scheduling algorithm for resource allocation according to the lowest cost and load. In the second dimension, the problem lies in the hosting of new VMs in the hosts. To overcome this problem, we need take into account the loads when housing new VMs in different datacenters. In this work, we suggest a resource allocation approach for services oriented IoT applications. The architecture of this approach is based on two technics: Multi Agent System (MAS) and Distributed Constraint Satisfaction Problems (DCSP). The MAS manages the physical resources, making decision and the communication between datacenters, while DCSP used to simplify the policy of the resources provisioning in Datacenters. Variables and constraints are distributed among multiple agents in different layers. The experimental results show that the efficiency of our approach is manifested in: Average System Load, Cost augmentation Rate and Available Mips.


Introduction
Internet of Things (IoT) and Cloud Computing are two paradigm technologies utilized for a wide range of application in our life. IoT is a smart system to connect physical objects with sensors to enable them to collect and share the data via the internet [18].
The cloud is type of parallel and distributed systems. It is described as a model for application execution and data storage [19], [2] Cloud infrastructure allows customers using a large number of resources such as: network, storage and applications [1]. The data centers have a large number of resources commonly known as RA [20]. In cloud computing, RA is an issue due several challenges such as complexity, heterogeneity of resource that resides in the datacenter, scheduling, virtualization, migration [2], [3].
The motivation for studying this problem comes from IoT limited properties including: limited storage capacity and complicated processes (data analysis and a lot of heterogeneity in the devices) [18]. As result, we work on satisfying users' needs by providing resources allocation with lower cost. This cost is computed on the basis of smart solutions in datacenters (best host) according the resource constraints [8]. We provide a distributed resource allocation approach based on two technics: multi agent system (MAS) [17] and distributed constraint satisfaction problems (DCSP) [5], [10], [11], [23]. Overall, our main goal is to provide high performance services and minimize the costs of resources operating.
In this paper, we study two problems related to IoT applications deployment in cloud computing. The first problem (Service Providing) occurring in the transformation of the IoT devices (sensors, actuators, …) to cloud service. Therefore, we work on a smooth and efficient data transmission for the cloud and support customer applications like data sharing, storage and processing. We suggest a number of functionalities for service providing: service creation, service publishing and service search. The second problem (Service Consumption) lies in the selection and execution of the service of resources allocation in the infrastructure of cloud computing. It occurs in two levels. In the first level, the problem is arisen in the scheduling of tasks (service cloudlet) to assign (submit) the cloudlets to the appropriate VMs taking into consideration the service's functional requirements and minimization of resources exploitation cost. In the second level, the problem lies in the hosting of new VMs in the hosts of the different datacenters according to their loads. The hosting of virtual machines has become a difficult issue in the resource allocation systems because each virtual machine is associated to a physical host according its available resources [6]. In order to solve the problem in both levels; we suggest smart solutions that depend on two techniques: The Multi Agent System (MAS) and CSP. The MAS manages the physical resources, making decision and the communication between datacenters. On the other hand, DCSP is used to simplify the policy of the resources provisioning in Datacenters.
We organize the rest of the article as follows: Section 2 presents research works as related to the subject of this paper. Section 3 offers background and basic concepts. The developed mechanism and system architecture are defined in 4 section. Section 5 presents the main scenarios of interactions in the proposed system. Section 6 provides an illustrative example to clarify our approach. The experimental results are shown in section 7, the last section concludes the paper and presents the future perspectives.

Related works
Because of the increasing demand of customers in the field of IoT in cloud infrastructure, many researchers have developed a number of methods to meet customers' demands by taking into account the efficiency of resources and operating expenses. Here, we mention some of the work done in this regard.
Ghanbari et al. [9] proposed an analytics study for resource allocation mechanisms for IoT. The Authors of this paper seek to provide a model in the IoT resource allocation which aims at reducing load balancing, minimizing operational cost and power consuming. By reviewed and discussed the advantages and disadvantages of this mechanisms, they compared several parameters in different articles such as: availability, performance, bandwidth, cost, energy, QoS, SLA, throughput, etc. Besides, there are more service quality parameters to be studied such as: self-allocation features, self-adapting, modeling and earning from studies past and current behaviour.
Ma et al. [13] suggest a model for task scheduling of the workflow in the IoT infrastructure as a service (IaaS) based on deadline constraints and cost-aware genetic optimization algorithm. To their approach is distributed at different levels according to the characteristics of cloud infrastructure due to the important features of the cloud (on-demand acquisition, heterogeneous dynamics and performance variation of VMs) so that no dependency exists between tasks at the same level. To demonstrate the feasibility of this approach, authors used the HEFT to generate individuals with the minimum completion time and cost.
Fayazi et al. [7] focus on two factors for resource allocation: the reliability and rapid implementation of the work. Therefore, they suggested cloud resource allocation based on auction mechanism. The increase and the decrease in the reliability are determined by the success or failure of the implementation. These solutions are checked by using imperialist competitive algorithm and cost function which is calculated by make span and reliability values. Beside of the diversity of the techniques used in this work, it needs more flexibility for the heterogeneous resources.
The work of Lu et al. [12] present a model to allocate the resources based on fairness evaluation framework by using two sub-models (Dynamic Demand Model (DDM) and Dynamic Node Model (DNM)) to describe the resource demand. The authors employ several typical algorithms in resource allocation like utility-based algorithm to prove their effectiveness. As strong point, this model supports the dynamic resources demands, but it does not take into account of the response time.
Mezache et al. [15] suggest a genetic algorithm for resource allocation with energy constraint in cloud computing. They focus on two levels of resource allocation: cloudlets to virtual machines and virtual machines to hosts. These levels allow adapting the resource allocation system and keeping the cloud resources updated by taking into account the current submitted cloudlets.

Background and basic concepts for IoT and cloud
In this section, we introduce some basic definitions and concepts as a background for our study.

Visions on integration internet of things and cloud computing
The hybridization (combination) between IoT and Cloud Computing generates synergy for both technologies and bring many benefits. Cloud infrastructure offers a clear advantage to IoT systems since its datacenters are able to calculate the users' needs of resources allocation efficiently. It ,thus, shortens the execution time, reduces cost and speeds big data processing [16]. This combination between IoT and Cloud Computing allows to provide a number of technical benefits to users (for example, storage, optimization of resource utilization and energy efficiency) [4], [22]. Figure 1 describes the combination between IoT and Cloud Computing.

IoT service-oriented architecture
The aim of service oriented architecture ( Figure 2) is to take advantage of the infrastructure of things and the cloud resources for obtaining a better quality of service (reduce the computing costs and improve the overall performance) [24]. The IoT services and devices are usually heterogeneous, and its resources are limited (e.g., memory, processing, bandwidth and energy). To manage such constrained environments, we need to build up a flexible architecture that is capable of managing these resources.

Components of IoT system
In Figure 3, we present four fundamental components of IoT system (function and mechanism).

• IoT devices and sensors:
Sensor is one of IoT devices that has the capability to detect, measure and collect data from the physical environment such as: light, motion, heat, pressure or similar entities [9], [21].
• IoT gateways: The IoT gateway is a bridge between sensor networks and cloud services. The role of gateway is processing the collected data from sensors, then send it the cloud computing [21].
• Cloud function: Cloud function facilitates the advanced analytics and the monitoring of IoT devices in order to shortening the execution time, reducing costs and reducing energy consumption.
• User interfaces: User interfaces are the visible and tangible part of the IoT system. They enable users to contact and monitor their activities in services that they have already subscribed using IoT system.

IoT deployed applications
In 0 The deployment of IoT devices encounters number of challenges such as: heterogeneity, storage, bandwidth, implementation of management protocols. To overcome these challenges, researchers turn to the combination between IoT and Cloud Computing. This type of combination contributes in the deployment of high, smarter applications for smarter homes and offices, smarter transportation systems, smarter hospitals, smarter enterprises and factories [4], [25].

The internet of things and multi agent systems
Thanks its characteristics (intelligence, reactivity, autonomy, mobility and the ability to perform making decision). The MAS allows an efficient management for IoT applications in the physical cloud infrastructure such as: the heterogeneity, distribution and the data management In IoT applications. Briefly, MAS provides a decentralized smart solution to frame the new problems and their solutions in the resource allocation approach for services oriented IoT applications [22].

Cloud infrastructure and constraint satisfaction problem
The Constraint Satisfaction Problem technique is used to formulate and solve several artificial intelligence related problems such as: Scheduling and Optimization [14]. In the cloud Infrastructure, we use DCSP to simplify the policy of the resources provisioning in Datacenters. DCSP problem is formulated as a distributed Variables and constraints to multiple agents. In MAS, each agent makes its proposal plan (solution) by using the distributed negotiation and satisfying its constraints. The various variables and constraints are identified, and the scenario of computing is painted accordingly.

Developing a new approach for RA in IoT
At this stage, we proposed a new RA in IoT service. Then, we discuss its System Objectives, architecture, layers, DCSP modelling and system scenario.

System objectives
This paper is interested mainly in the field of cloud of things. Particularly, it shows the importance of resource allocation in data centers. The aim of our approach is to ensure optimal management of resource allocation for service-oriented IoT applications based on decentralized intelligence in distributed computing. To achieve the stated goals i.e. load balancing (minimizing power consumption), efficiently exploiting resources and minimizing the execution time, we suggest: 1. Designing a system to manage the cloud infrastructure based on a multi-agent system for the allocation of resources in the cloud of things.
2. Developing a system to manage these resources by using two techniques: Multi-Agent System (SMA), Distributed Constraint Satisfaction Problems (DCSP).
3. Implementing and simulating the proposed system through a scenario that demonstrates the effectiveness of the proposed approach for the management of resources in the cloud of things.
In this concern, we introduce a number of concepts and rules for IoT service delivery system specifications and the resource allocation process in cloud computing as shown below: 1-Every object can be linked to many services. 2-Each service has one cloudlet request. 3-Every Cloudlet should submitted to one VM. 4-Every VM can submit more than one cloudlet. 5-Every Host can host more than one VM. 6-Every Datacenter has two types of hosts: ON hosts and OFF hosts 7-Every host has special price. 8-The relationship between the price and the load of the host has a direct impact, where the augmentation in the load causes the increment of the price.

Smart design for resources allocation in IoT applications
In this section, we are mainly interested in introducing a System Architecture for IoT Resource Allocation, its functional aspect and various layers to provide a better understanding to: how it works, how it stores and how to access to the cloud. Figure 4 describes the proposal smart design.

Layer1 (customer):
In this layer, the system focuses on customers and their requests. The customer requests are presented in term of service name and characteristics.

Layer2 (IoT Service):
This layer has a significant the role as mediator between Customer Layer and Broker Layer. It contains two agents: 1. Object agent (OA): is reactive agent that represents an IoT object (physical device). It enables to control exchange and collect data from this device in order to provide a set of services to customers. 2. Mediator agent (MA): is cognitive agent; its role is to manage the customers' requests and the provided services. The main components of this agent are given below: • Service registry: aims to allow the OA agents to publish the information about their services in term of performance and functionalities.
• Service selection: searches for a set of selected services in the registry that meet the customer request.
• Service transfer MA creates a list of requested cloudlets from the performance characteristics of the selected services. Then, it sends this list of cloudlets to Broker Agent in the next layer. Broker Agent, in turn, arranges this list of cloudlets and send it to Resources layer for the selection of the best cloudlet from this list by taking into account the resource allocation strategy in this layer.
•Service Bind: after the selection of the best cloudlet, the MA connects the customer with the provider of the service that is associated by selected cloudlet. It also allows the OA to execute this service through this cloudlet.

Layer3 (Broker Layer):
The role of this layer is to manage the resources between IoT service and Resources layer. The broker agent (BA) manages the list of cloudlet requests, free VMs list, performance and delivery of cloud resources. The main role of this agent is to arrange a list of cloudlets, then send to Resources layer.

Layer4 (Resources layer):
is the most important layer in the system due to its role in the managing, processing and selecting the best RA for the cloudlet in two levels: local level (between HA agents in the same datacenter) and the global level (between DCA agents of the cloud). This layer contains three types of agents. We introduce these agents and clarify the relationship between them by Figure 5.

Relationships between DCA and HA agents
DCSP problem is formulated as a distributed Variables and constraints to multiple agents. In MAS, each agent makes its proposal plan (solution) by using the distributed negotiation and satisfying its constraints. The various variables and constraints are identified, and the scenario of computing is painted accordingly.

Defining of the variables
In this section, we show the most important variables and their definitions Table 2.

Constraints
The aim of this section is to select the best solution for any task in DCSP systems. We thus need to define a set of constraints by using the previous defined variables that correspond to system requirements.

Constraint 1 (Service Usability)
: verifies a service S that meets customer request R; it should satisfy the nonfunctional characteristics of the customer request according to the following constraint: Constraint 2 (Service Capacity): allows the service to handle new customer request. Before representing customer request in term of cloudlet, it should respect its capacity limitation:

Constraint 3 (Cloudlet Submission ability):
virtual machine has already a set of M cloudlets. In order to submit more cloudlet m', this condition must be satisfied: Where:

Constraint 4 (VM Hosting ability):
To allow a Host J hosting a new virtual machine l' (free or migrated VM), we must verify these conditions: Where:

Constraint 5 (Ranking of Host Agents):
The ranking Algorithm is based on mipsPrice. In case of finding two Hosts with the same price, then we must use mipsLoad:

Constraint 6 (Best VM Hosting Selection):
The selection of the best host between different hosts j and j' for hosting VM, it is organized on the basis of Hosting Cost:

R(Rep)
The requested Reputation. Naturel number

S(Av)
The Availability of the service. Rate value (%)

S(Cap)
The Capacity of the service: it is the number of requests can be handled per unit of time. Naturel number/time

S(Rep)
The Reputation of the service. Naturel number

S(hr)
The sum of current handled requests by the service.

Host (ram)
Size of host's ram Naturel Number

Host(bw)
Bandwidth of the host Real number

Host(Storage)
Size of the host's storage Naturel Number

Host(mips_load)
The energy of the host, the Capacity of Processors used in accordance to the total capacity of Processors in the host.

Host(mips_price)
Unit price of mips in the host Real number, obtained from proposed model for every host Pe(mips) Capacity of the Processor Real number

VM(size)
VM's hard disc Size Naturel Number

VM(ram)
Size of the ram Naturel Number

VM(bw)
Bandwidth of the VM Real number

VM(mips)
Sum of Capacities of the Processors of the VM Real number

VM(Costj)
The hosting Cost of the VM in the host J Real number (DA)

CL(length)
Size of the of CL. Real number

CL(file size)
Total size of files of CL Real number

CL(output size)
Size of the result of the execution of CL Real number

CL(nbr_pe)
Max number of Processors of CL Naturel Number

CL(mips)
Capacity of the Processors of Cl Real number

Cl(Costlj)
it is the cost of resource exploitation of the submitted Cl in the VM l which is hosted in the host j Real number (DA)

Scenario of interactions in the proposed system
In this section, we present the main scenarios to provide and select RA for IoT service in the proposed system. Also, we illustrate the interactions between Agents by sequence diagrams where there are two object agents (OA1, OA2) and two datacenters agents (DCA1, DCA2). Every datacenter has two Host Agents (HA1, HA2).

Global interaction
In this section, we explain the global interactions in the proposed system on three main levels: IoT Service request, Cloudlets Submission and Hosting Virtual Machines. The Search Algorithm and diagram in Figure 6 present the detailed descriptions for these interactions.

Cloudlets submission
The process of cloudlets submission in datacenter and their hosts is illustrated in Figure 7. In addition, the Planning Algorithm (Algorithm1) illustrates the process of cloudlets submission inside the Hots.   Return BCL end.

Hosting virtual machines
In a case where there is no VM resource available, we launch the Hosting Virtual Machines to submit the requested Cloudlets. The BA starts the process of hosting free virtual machines as illustrated in Figure.8.

Illustrative example
To illustrate our approach, we consider an example and discuss a case study of an IoT Application for smart transport system. We discuss this case study from two dimensions:

IoT service deployment
First dimension: we focus on the aspect of the defining, publishing and searching services in addition to the different characteristics of these services and the customers' requests. We show a scenario of using this dimension by the following steps: Step 1: A company has IoT application for smart taxi. It provides the service of reservation of autonomous cars and tracking (monitoring program to be executed in the cloud) the car during the trip.
Step 2: Each autonomous car (physical IoT) is connected to an agent (object agent) in the cloud (IoT layer). This agent publishes information about his service in MA services registry. The Table 3 illustrates some characteristics of the service in term of functional and nonfunctional.   Table 3: Services characteristics.
Step 3: The customer requests a car (service) via introducing the nonfunctional characteristics: availability, reputation and the type of desired trip.
Step 4: First, the MA searches in the registry the available services that meet the customer request. In order to select the best service from the found services, the MA converts these services into cloudlets by using resources requirements (from functional characteristics), and sends them to BA in the next layer.

Service selection in cloud computing (Planning procedure)
After obtaining the output (convert services to cloudlets) of the first dimension. We discuss how to the execution of the planning procedure in the second dimension in the cloud system functionality. We propose the cloud infrastructure that has two imaginary datacenters: where datacenter 1 has four hosts and three hosts for datacenter 2. In addition, there are eleven (11) Virtual machines (VMs) hosted in these different hosts. These VMs has already hosted thirty (30) Cloudlets, and BA needs to host seven (07) other requested cloudlets (CL31 … CL37) in these Vms. In this case, the system looks forward to check the best resource allocation process for these cloudlets according to the cost and energy consumption as shown in the following steps. Step 1 (requests): BA distributes the received list of cloudlets to all DCA. As result, every DCA informs his HA agents who are in ON state to start the ranking process.  Step 2 (Interne Negotiation 1 "Ranking process"): After, the HA agents (in ON state) share their prices and rank themselves into ascending order by the price. As illustrated in Table 5   Step 3 (Interne Negotiation 2 "Planning"): After the ranking process, the first HA in the each DCA gets the list of cloudlets from his DCA, and starts the planning procedure by checking available resources in the hosted VMs of his Host and verifies the constraint C1. If there are Cloudlets and VMs that verify C1, then the first HA selects the best cloudlet that satisfies the constraint C7. The first HA sends the selected cloudlet to the DCA in the term of (cloudlet, VM, host, cost) as reply. At the end of his procedure, it sends the rest of cloudlets (they do not satisfy C1) to the next HA in the ranking list to consider them in his planning procedure. This process is repeated continuously until the last HA in the ranking list or there is no rest cloudlet.
Otherwise, in case of there is no Cloudlet that satisfies C1 in any HA, this HA retransmits the whole of the list of cloudlets to the next HA in the ranking list to consider his planning procedure.

Step 4 (Local solution building):
After the planning, every DCA receives the solution from HA agents and selects the best solution, which satisfies C7, and consider it as his local solution. Table 6 illustrates the local solutions in DC1 and DC2 for CL31 and CL37.
Step 5 (External Negotiation) : The DCA agents share their solutions and negotiate to select the best solution using the best price (to satisfy C7). The DCA that is the owner of the best solution sends his solution to BA to build the global solution as illustrated in Table7.  Step 6 (Show solutions and confirmation): After building the global solution, BA agent sends the cloudlet to MA. As result, MA sends the associated service of the cloudlet as response for customer request, enables (confirms) OA to launch the tracking device of the car and allows the customer to use the car with the lowest cost.

Simulation experiments
To evaluate the performance of our approach, we used CloudSim [15] which is a Java based and extensible simulation framework for resource allocation algorithms.
In this section, we discuss the experimental configuration and the results obtained by using our approach.

Experimental configuration
We define the different parameters in our experiments as follows: datacenters, hosts, virtual machines, Processors and cloudlet as shown in Table 8.

Simulation results
In this section, we present the experimental results and show the efficiency of our proposed approach by making a comparison between three solutions (First Fit algorithm (FF), the proposed Genetic Algorithm (GA) of Mezache et al. [15] and our algorithm (MD)). MD is built on MAS  Available Mips (AM)). In the experiments, the customer request (Service Request) will be submitted to the IoT system for processing this request. In this case, the proposed system converts this request to a list of cloudlets (network bandwidth, Storage, CUP and load consumed) in order to fulfill this request with lowest cost by using our algorithm (MD). The main goal of our algorithm (MD) is to balance between the cost and energy of Datacenters hosts. The obtained results show that this goal is achieved through the common characteristics (metrics) that are shown as follow:

a) Average System Load (ASL)
This metric represents the energy consumption. The importance of this metric lies in specifying the datacenters status and reducing energy consumption in their hosts. Usually, the ideal system average load gives us a balance between the different hosts inside their datacenters. Figure 9 presents Average Load by the number of requested cloudlets (FF, GA, MD). The obtained results show the efficiency of our algorithms (MD) in getting a lower values of Average System Load (ASL) compared to FF and GA algorithms. The obtained (ASL) values after using our algorithm (MD) improves over the in terms of Average System Load, so that it does not exceed 50%.

b) Cost augmentation Rate (CR)
This metric represents the Cost augmentation rate by cloudlets number. The importance of this metric is manifested in reduce the costs of resources exploitation. The values of (CR) in Figure 10 demonstrate the positive contribution of our algorithm (MD) on reducing cost with almost of all groups. Our algorithm (MD) maintains the augmentation rate (CR) between (105% -190%) except for the first groups (500 and 1000) where the GA has lower values in (CR). This due to the efficiency of our algorithm (MD) with groups which have an important number of cloudlets (more than 1000).

c) Available Mips (AM)
This metric represents the Available Mips by Cloudlets. The importance of this metric lies in measuring the computing performance and increasing Available Mips in datacenters. The more MIPS available for the datacenter, the lower cost of the resources exploitation. In Figure 11, we observe that the values of AM obtained by GA are bigger than the values of other algorithms in groups that have less than 1000 cloudlets. While, our algorithm (MD) has better values of AM when the number of cloudlets increases over 1000.

Conclusions and future work
In this paper, we addressed a new approach for Resource Allocation (RA) in Internet of Things. Our approach is based to decentralized intelligence into distributed computing by using two technics: MAS and DCSP. In this hybridization, variables are used to present the resources. While the rules and policies are presented by constraints. They are distributed among multiple agents in the different layers of the system. The experiments show that the use of DCSP beside MAS pave the way for new efficient paradigms in solving problems related not only to Resource Allocation but also to provide smart solutions which are helpful to synchronize the IoT application services with computing devices. The obtained results show that the efficiency of our approach is manifested in: (1) reducing energy consumption in datacenters by about   Despite the provided advantages of our approach, we highlight the need of extending in its architecture to support other specific cases for IoT applications. Big data are generated day-to-day from the system, causing many challenges such as, the heterogeneity, scalability and simultaneous accessibility.
In future research, we are looking for enhancing our approach by using more techniques of resources in IoT application services and extending the procedures by exploiting other approaches as: Search Approximation Algorithms, Artificial Intelligence and Fog environments.