1 Introduction

According to the UN’s estimates of world population, the current population is 8 million, and even with declining fertility rates, it is predicted to reach 8.6 billion in 2030 and 9.8 billion in 2050 [1]. Global warming is being caused by the environmental stress that an expanding population and various businesses, especially agriculture, are putting on the globe. Consequently, in order to support this population growth, food production should increase by at least 70% [2]. Numerous heinous acts degrade the land, which lowers the quality of crops; chemical runoff contributes to dead zones and endangers marine life. As a result, the use of smart technologies like the Internet of Things (IoT), unmanned aerial vehicles (UAVs), Information and Communication Technologies (ICT), artificial intelligence (AI), and machine learning in agriculture may play a significant role in offering solutions to pressing these problems of insufficient chemical application, poor drainage, and irrigation and yield prediction including shortage of food as well as wastage of resources [3, 4].

Farmers in the past had trouble growing a crop in any certain location. They do not know what kind of plant is best to grow in a particular location. They carefully assess the changes in the land and apply the necessary fertilizers to increase crop production. For the quick rise in the production of crops, smart agriculture is a new and advanced form of technology. It is crucial to consider smart agriculture in today’s highly digitalized world in order to automate and keep an eye on agricultural-related activities. In order to meet the demand for natural resources caused by a growing population, it is also imperative to expand production. It thus lowers the price, labor time, and other parameters too. Increasing productivity and choosing the right crop based on soil and water conditions are two related problems. Apart from that, optimal water requirements, minimal use of fertilizers & pesticides, and animal intrusion detection systems are also problems associated with real-world agriculture. To solve this, IoT has come into the frame. IoT is essentially a vast web-based network that links devices for enhanced functionality [5, 6]. Figure 1 shows various applications of IoT in smart agriculture.

Fig. 1
figure 1

Applications of IoT in smart agriculture

Agriculture might be characterized as a combination of services to get the desired outcome. The level of the user’s demands has increased to the point where they cannot be met by a single service. Service composition (SC) results from this. It can be defined as an aggregation of basic services; they cannot simply be created by connecting a number of services. QoS is a crucial parameter in SCP [7]. It is crucial to choose services in accordance with the requirements of the users and the QoS with identical functionality rather than only the functionality of the services. Due to the possibility of huge QoS with non-linear effects on the service composition objective function, it is an NP-hard problem. Thus, cannot be solved using traditional optimization approaches [8]. For such complex problems, meta-heuristics approaches are the best alternative to use. These may be classified as bio-inspired approaches (Krill herd algorithm, artificial hummingbird, etc.), physical approaches (Harmony search algorithm, memetic algorithm, etc.), evolutionary approaches (genetic algorithm, differential evolution, etc.), and swarm intelligence-based approaches (ant colony optimization, particle swarm optimization, etc.) [9]. These approaches provide solutions for a single objective. So, in order to solve multiple objectives in a single run, multi-objective optimization is used to get Pareto optimal solutions [10].

In modern times, digitalization is accomplished through the internet and numerous devices, including PCs, laptops, and many others. As a result, data gathers and, in some circumstances, becomes unmanageable. Hence, extraction of critical information becomes difficult [11]. Also, uncertainties present in the data is extremely difficult to handle and a prime concern for today’s agriculturalists. To deal with uncertainty in information extraction, statistical approaches were initially applied in agriculture. Later, the membership function was used to introduce the fuzzy set (FS) to manage uncertainty. However, building a membership feature is a crucial matter that calls for experience [12]. Hence, the aim is to reframe SCP using a fuzzy logic (FL) controller along with NSGA-II as an optimization technique to obtain a Pareto optimal solution set.

Following are the summarized objectives of this paper

  1. 1.

    Service composition is done by considering the production of apple crop with time and cost as QoS parameters to be minimized.

  2. 2.

    Comparison of three state-of-art to find which one is providing a better Pareto optimal solution.

  3. 3.

    Using fuzzy logic controller to check the influence of uncertainties on service composition problem by taking various case scenarios.

  4. 4.

    Optimization using NSGA-II approach to obtain Pareto optimal solution set for the defined multi-objective optimization problem.

  5. 5.

    Statistical comparison of few possible case scenarios approaches.

The roadmap of the remaining paper is as follows: Section 2 explains a few insights of related work. Section 3 defines the service composition problem along with the fuzzy control system whereas experimental setup and results are demonstrated in Section 4. Eventually, Section 5 concludes the paper.

2 Literature Work

The population’s rising demand has made agriculture-based IoT a priority topic for research. Smart agriculture has been the subject of a lot of research up to this point. Few discussions of literary insights in the field of smart farming have been conducted.

Qazi et al. [13] have provided a review on the use of IoT technologies and AI in the field of smart agriculture along with some future trends. They have illustrated a few IoT-based smart irrigation solutions, such as drip irrigation and aeroponics, which are both soil-based irrigation methods. It is also covered in detail together with the usage of fuzzy logic, neural networks, and Unmanned aerial vehicles (UAVs). The use of deep learning for phenotyping, pest-weed detection, and disease prediction in plants is an additional aspect covered by the authors. The authors have concluded by defining a few challenges that need to be overcome such as cyberattacks, rising technology costs, and the global Alliance for the Advancement of Coherent Wireless Sensor Technologies. They have provided examples of how these technologies will impact smart agriculture by using smart UAVs for all agricultural services, lessening the hard efforts of farmers, blockchain technology for defending against cyberattacks, 5 G for maintaining an efficient linking system, and green IoT for more prevalent future of smart agriculture. Akhter and Sofi [14] have demonstrated the strength and potential of computing tools used in agriculture, such as IoT data analytics, and machine learning. A prediction model for an apple disease known as Scab has also been proposed for apple orchards in the region of Kashmir valley. They elaborated the survey by asking farmers about the latest technologies in agriculture and their effects on yield production.

Review and surveys in the literature are most prominently focussed on using computing technologies like cloud, machine learning, IoT, and other AI techniques for making farmers and farms smart by enhancing their yield production. Fuzzy logic is another AI-based technology out of these revolutionary ones that is now renowned for making agriculture smart.

Ojha et al. [15] have provided a review on designing of fuzzy inference systems (Type-I and Type-II) using neuro-fuzzy (NFS), evolving fuzzy (EFS), genetic fuzzy (GFS), multi-objective fuzzy (MFS), and hierarchical fuzzy systems (HFS) in a way that they are connected to each other. They have linked standard fuzzy inference systems (FIS) with optimization problems to form GFS; HFS, MFS, and EFS when combined to form BFS; DFS with multi-objective and evolving viewpoints incorporates MFS and EFS concepts. Authors consider developing hybrid optimization techniques to address a variety of real-world issues.

In the case of optimization, different problem-solving approaches are employed to gather information and then used to refine the original solution. Numerous real-world optimization problems exist. Hence, it becomes necessary to get the optimal solution for each of them. The scientific community has already proposed a variety of nature-inspired optimization approaches to address these issues, but they are ineffective when faced with the dynamic adaptation of the factors that go into resolving the problems. The solution is the use of a fuzzy logic system.

Valdez et al. [16] have provided a survey on using fuzzy logic with nature-inspired techniques for solving complex optimization problems. The most relevant techniques used with fuzzy are discussed which are gravitational search algorithm (GSA), particle swarm optimization (PSO), and ant colony optimization (ACO). Authors asserted that using fuzzy logic in conjunction with optimization techniques led to better results than using an optimization algorithm alone. Guerrero et al. [17] have proposed a fuzzy logic system to dynamically adapt the parameters \(P_{a}\) (probability of discovering host bird) and \(\beta \), thus, naming as fuzzy cuckoo search algorithm (FCS) to enhance convergence rate. The proposed algorithm has been tested on five benchmark functions namely Rosenbrock, Rastringin, Spherical, Griewank, and Ackley with dimensions of 8, 16, 32, 64, and 128. Mamdani type of fuzzy system has been used for single input (\(iterations\)) and output (\(P_{a}\) or \(\beta \)) along with three fuzzy inference rules and triangular membership functions as \(high\), \(medium\), and \(low\). The paper is concluded by comparing cuckoo search with FCS(\(P_{a}\) & FCS (\(\beta \)) and demonstrating that with the increased number of dimensions, FCS (\(\beta \)) is presenting better results than other two algorithms for 4 out of 5 functions. Caraveo et al. [18] have developed a modified predatory pray optimization method based on the plant’s natural defense system using Type-2 fuzzy logic to maintain balance. By making dynamic adjustments to the variables, the traveling path of an autonomous robot has been optimized with the goal of minimizing error. Mamdani type of fuzzy controller has been used where \(angular\) \(velocity\) and \(linear\) \(velocity\) are input variables with \(left\) and \(right\) \(torques\) as the output variables. Two types of membership functions are taken — triangular type for zero terms & trapezoidal type for positive and negative terms along with nine fuzzy inference rules. Its viability has been checked by comparing it with fuzzy logic-based Bee colony optimization (FBCO). According to the results of statistical analyses, the authors’ optimization approach along with the fuzzy logic system (FLS) has greatly enhanced stability and performance.

Recent tests and studies have demonstrated that fuzzy logic models can be used to handle the environment’s ambiguous behavior in relation to agricultural data sets.

Castillo and Amador-Angulo [19] have proposed a generalized type-II fuzzy logic method for the adaptation of dynamic parameters of Bee colony optimization (BCO) algorithm for the optimization of ten mathematical functions and water tank controller, known as Fuzzy bee colony optimization (FBCO). Mamdani fuzzy system with trapezoidal membership function has been taken with two input variables (\(diversity\) and \(iteration\)) and two output variables (\(alpha\) and \(beta\) with a range of 0–1 and 2–5, respectively) along with nine fuzzy inference rules for FBCO. For first benchmark problem of water tank controller, input variables are level (\(high\), \(okay\), \(low\)) and rate (\(positive\), \(none\), \(negative\)) whereas output variable is valve with five membership functions of triangular type (\(openfast\), \(openslow\), \(nochange\), \(closeslow\), \(closefast\)), thus, a total of five inference rules. Then, for ten mathematical functions, fifteen experiments each have been performed. A comparative analysis of FBCO has been done with the original BCO, an Interval Type-II fuzzy logic controller (IT2FLC), and a Type-I fuzzy logic controller (T1FLC) and it has been observed that FBCO outperforms the others in convergence rate and better stability. Olivas et al. [20] have provided a novel method for dynamically adjusting parameters (\(\alpha \) and \(kbest\)) over the generations in gravitational search algorithm (GSA) based on interval Type-II fuzzy logic known as Fuzzy gravitational search algorithm (FGSA). They tested it by optimizing fifteen mathematical benchmark functions first and then on a fuzzy controller used for controlling hot and cold water. While optimizing mathematical functions, inputs variables are diversity (\(high\), \(medium\), and \(low\)) and iterations, ranging from 0 to 1. For output variables, \(\alpha \) ranging from 0 to 100 and \(kbest\) ranging from 0 to 1 are considered. For the fuzzy controller, inputs are \(flow\) and \(temperature\) whereas outputs are \(hot\) and \(cold\), totaling nine fuzzy inference rules. Further to verify its effectiveness, it is compared with the original GSA and T1FGSA (Type-1 Fuzzy GSA for adjusted parameters). Authors have claimed the superior performance of the proposed algorithm than the other two adjacent algorithms for performing a local or global search. Dela Cruz et al. [21] have proposed an idea of utilizing a decision support system based on fuzzy logic for water tank monitoring and control subsystem (WTMCS) in a smart farm automated irrigation system (SFAIS) in order to optimize water resources. Based on the condition of the water tank, it gives the power management system the amount of priority for turning on the pump. By monitoring the \(water\) \(level (L)\)and the \(variations\) \(in\) \(water \) \(level (DL)\), priority levels have been established. Values of \(DL\) have been defined as \(high (H)\), \(low (L)\), and \(zero (Z)\) whereas those of \(L\) are fuzzified as \(full (F)\), \(normal (N)\), and \(empty\). The priority levels are defuzzified as \(high (HP)\), \(medium (MP)\), and \(low (LP)\). In order to establish a relationship between input and output variables, they have defined a total of nine fuzzy inference \(IF-THEN\) rules for decision-making with the Center of Gravity method for defuzzification. Authors have concluded that WTMCS has a better possibility of providing the farm with ideal water and electricity resource distribution. Lavanya et al. [22] have developed a novel NPK (nitrogen, phosphorus, and potassium) sensor equipped with LDR (light-dependent resistor) and LED (light emitting diode) for the comprehensive monitoring of nutrients present in soil so that only proper number of fertilizers is used in farm. IoT is used to send information to Google Cloud for quick data retrieval whereas fuzzy logic has been deployed to detect nutrient deficiency from sensed data using the Mamdani inference model. Output levels are classified as \(very\) \(high\), \(high\), \(medium\), \(low\), and \(very\) \(low\) by taking ranges of 0.8–1, 0.5–0.8, 0.3–0.5, 0.1–0.3, and 0–0.1, respectively for defining \(IF-THEN\) rules. Its effectiveness is checked using a hardware and a software model. In hardware testing, three samples of desert soil, mountain soil, and red soil have been taken. For software simulations, data is transferred from NPK sensors to the cloud server by considering metrices like end-to-end delay, throughput, and jitter. The authors concluded that their model yields high crop production by using an accurate, minimal cost, and smart IoT system. Acharjya and Rathi [11] have proposed a crop identification model using fuzzy rough sets, real coded genetic algorithm (RCGA), regression, and k-nearest neighbor (KNN) techniques. They remove redundant attributes and divide data into training, testing, and validation parts. They analyze training data using RCGA, KNN, and regression. They compare six combinations of tournament selection, roulette wheel selection, laplace crossover, flat crossover, and simple crossover. They find FRRWLX (Fuzzy rough set roulette wheel selection with laplace crossover) as the best. Benyezza et al. [23] have proposed a fuzzy-based zoning smart irrigation system with a goal of optimizing energy and water consumption in greenhouses. For achieving it, they divided the greenhouse into different zones and employed a node in each zone with a soil moisture sensor, data was then transmitted to a fuzzy unit for optimal decision-making and the use of a cloud layer for saving data so that it could be remotely accessed. In order to check its effectiveness, a real field of six square meters has been taken to irrigate tomatoes for eight days by dividing the area into two zones. Comparative analysis has been done with three other methods proposed in the literature and it has been found that the proposed algorithm has shown an improvement of 65.22% and 26.41% in terms of energy consumption and water usage over other state-of-arts for the same testing area. Sharma et al. [24] have developed a system based on fuzzy logic to prevent pests in a field of rice and millet by continuously checking the growth of pests. The proposed system has used an IoT monitoring structure to collect the real-time data samples of weather attributes (\(temperature\), \(rainfall\), and \(humidity\)) to generate a data set. This information has been used as a training data by genetic algorithm (GA) to optimize the rules of fuzzy-based prediction systems. Conditioned data from the cloud has been used by GA to find the correlation among weather attributes with the breeding requirement of pests. This correlation has been then used as a linguistic variable of Cauchy fuzzy membership function (CMF) i.e., \(very\) \(high (VH)\), \(high (HI)\), \(moderate (MOD)\), \(low (LO)\), and \(very\) \(low (VL)\). The proposed model has been verified by testing it in the Gwalior region of Madhya Pradesh where suitable conditions for the breeding of pests in millets and rice exists. Authors have concluded that pests are occurring in very high and high scenarios and this system will help the farmers to take preventive measures beforehand.

Along with the single objective optimization, various multi-objective optimization problems are also found in the literature.

Kropp et al. [25] aimed to optimize irrigation and fertilizer scheduling for sustainable intensification, focusing on crop yield and environmental impact. Using multi-objective optimization techniques, the study integrated the Unified Non-dominated Sorting Genetic Algorithm-III (U-NSGA-III) with the Decision Support System for Agrotechnology Transfer crop model. The platform found irrigation and nitrogen schemes that reduced nitrogen usage by 26%, water usage by 48%, and nitrogen leaching by 51%. Priya et al. [26] have presented a rule-based fuzzy classification method for predicting sowing times based on environmental conditions. The three-step procedure identified sowing times for cotton, maize, and groundnut. The fuzzy inference system is designed, optimized using NSGA-2, and validated through cross-validation. Sharma et al. [27] have proposed a fuzzy inference system for crop planting in the Gwalior district of Madhya Pradesh, India. The system predicts crop planting times and pest occurrence probabilities based on weather conditions and crop traits, thereby increasing crop yield and minimizing the use of pesticides. It uses a multi-objective evolutionary algorithm to find the optimal breeding conditions.

It can be derived from the literature that AI technologies are showing an immense positive impact on making agriculture smart by improving various crop-related parameters. But it has been found that neither single objective nor multi-objective SCP has been solved yet towards making agriculture smart. As a result, the unidentified nature of SC in smart agriculture has drawn to a close. Thus, work in this paper is proposing a novel fuzzy logic system integrated with the NSGA-II optimization approach to implement service composition in smart agriculture.

3 Proposed Framework

The concepts of service composition, fuzzy logic, and optimization algorithms are presented in this section for use in smart agricultural challenges. The suggested architecture adequately explains each of the three ideas.

3.1 Service Composition Description

The concept of “service composition” is used to refer to a combination of several services. There is no predetermined way to define the service composition that has to meet user requirements. However, a number of QoS criteria, such as scalability, availability, time, throughput, and cost define the web services. Requests from users are divided into a pipeline of services. Then, for each specific atomic service, a candidate services list is established [28]. These services are functionally similar to the user’s request, but each atomic service has different QoS criteria.

The goal of this research is to offer apple crop production an ideal solution to solve multi-objective problem of associated cost and time in their fields. Assume about the “t” number of services, modeled as atomic services with unique QoS metrics, involved in growing apple crops along with their candidate services. This concept can be defined with the help of equations shown below where Eq. (1) specifies the atomic services, and Eq. (2) lists the candidate services that correspond to those atomic services [29].

$$\begin{aligned} AS_{i} = \{CS_{i,1}, CS_{i,2}, CS_{i,3}........CS_{i,k}\} \quad 1 \le i \le t \end{aligned}$$
(1)
$$\begin{aligned} CS_{ij} = \{QoS(CS_ij)\} \quad 1 \le j \le k \end{aligned}$$
(2)

The \(i_{th}\)vertex in Eq. (1) represents the \(j_{th}\) service of that vertex, and Eq. (2) demonstrates how \(CS_{ij}\) is reliant on the values of QoS attributes.

After selecting the QoS-based appropriate candidate service, the service composition can be described as in Eq. (3) given below.

$$\begin{aligned} C = \{CS_{1j}^*, CS_{2j}^*, CS_{3j}^*,..., CS_{tj}^*\} \end{aligned}$$
(3)

3.2 Phase-1: Fuzzy Logic System

Fuzzy logic (FL) is a development of Boolean logic that was formally established by Lofti Zadeh in 1965. It is a modification of the classical set theory, which is in opposition to the modal logic’s fundamentals. The advantage of using this is that it introduces the concept of confidence to check an event, allowing it to exist in a state besides true or false [30]. A key component of creating quantitative fuzzy variables is the idea of a fuzzy number. The resulting establishes are typically referred to as linguistic variables when the fuzzy numbers represent linguistic concepts, such as very large, large, medium, and so on, as understood in a particular context. Figure 2 shows an example of linguistic variable [31].

Fig. 2
figure 2

An example showing linguistic variable concept

In the above example, \(performance \) is taken as a linguistic variable that expresses the performance of a goal-oriented element (maybe a machine, person, organization, etc.) by using five distinct terms- \(very\) \(large\), \(large\), \(medium\), \(small\), \(very\) \(small\). A semantic rule, as indicated in Fig. 2, assigns one of five fuzzy numbers to each of the basic linguistic concepts. Here, the fuzzy numbers are assigned in the interval [0,100] [31].

FL is a more effective strategy for solving decision-making issues since it can replicate human flexibility in reasoning and capacity to deal with non-linearity and uncertain systems [32]. The architecture of fuzzy logic is shown in Fig. 3.

Fig. 3
figure 3

Structure of fuzzy logic system

Following are the components of a standard fuzzy logic system in detail [15].

  1. 1.

    Fuzzifier- Through the use of a membership function, this component converts quantitative numerical input from a sensor into qualitative linguistic variables. The literature contains a variety of functions; however, the most prevalent ones are Gaussian, triangular, and trapezoidal.

  2. 2.

    Knowledge base- This unit consists of a rule base and a database. Fuzzy sets (FSs) are assigned to input variables by the database which are then converted to fuzzy membership values by FSs. The rule base then creates a set of rules for rule induction by retrieving FSs from the DB. In other words, inference rules can be thought of as a group of multiple rules that connect the fuzzy inputs and outputs of the system. These laws are shown as “IF-THEN” rules: IF< \(Condition1\) > AND/OR < \(Condition2\) > (AND/OR)... Then, action on the outputs. This means rules are in the form of antecedent and consequent.

  3. 3.

    Inference Engine- The core of a Fuzzy Logic Controller (FLC) is its inference block, which uses fuzzy contribution and inference rules in FL to simulate human reasoning and cause FLC action. The controller’s linguistic fuzzy output can be derived by the numerical processing of inference rules, which can be done in a number of ways, including Larsen, Mamdani, and Sugeno. The subsequent forms of the rule types Mamdani and Sugeno, however, are different. A Sugeno-type rule takes a polynomial function as the consequent, whereas a Mamdani-type rule takes an output action. As a result, their capacity for approximation varies. The Mamdani type is better at interpretation, and the Sugeno is more accurate at approximation [33, 34].

  4. 4.

    Defuzzifier- This component is used for defuzzification. In this stage, the several commands produced by the inference engine can be combined into a single output, converting the qualitative linguistic variable into quantitative data that is numerical in nature. The two most popular defuzzification techniques are the mean of maximum (MOM) and center of gravity (COG) [35].

In case of FLS, an input can be singleton or non-singleton, depending upon the application. Their difference lies in their respective fuzzification process where a fuzzifier converts a non-singleton or singleton input to a fuzzy membership function. A FIS is a singleton FIS if it employs singleton inputs, or, more specifically, if it uses exact single value measurements as its input variables whereas in the case of non-singleton FIS, a non-singleton input is provided. Its application lies in solving real-world issues [15].

3.3 Phase-2: NSGA-II

Agricultural systems are multifunctional systems because their behavior necessitates taking into account factors like energy usage, labor cost, labor time, maintenance cost as well as implementation costs too. Therefore, a variety of evolutionary methodologies can be employed to assess various optimization goals and look for the best solution [36].

Implementation of fuzzy logic along with meta-heuristic evolutionary approaches is a thoughtful approach that allows the algorithm to conduct an intelligent search for parameter values and select those that are optimal for resolving the problem. In this paper, fuzzy logic is implemented with the NSGA-II evolutionary approach. Deb suggested NSGA-II in 2002 [37]. The approach uses the non-dominated sorting and crowding distance concept to find a collection of solutions that are uniformly distributed and to increase diversity for any multi-objective problem. Any random group of individuals is sorted using a non-dominated sorting strategy to begin the process. All non-dominated solutions are ranked number 1 in this stage and momentarily excluded from the starting population. The following collection of solutions is ranked as Number 2 in a similar way. This process is repeated until all potential sets of solutions have been ranked. The parent population is created in the following phase by using the binary tournament selection method on the existing population. The binary tournament’s selection process involves choosing any two solutions from the current population and then choosing one based on rank. The best option may not always be on the same front. The crowding distance idea is applied in that situation. After choosing the parents, the population of parents is subjected to the crossover and mutation operators in order to produce offspring. The next population is made up of the best solution from the parents and children’s combined population. This process keeps going until a termination condition is reached. It can either run for a certain number of generations or until all possible solutions have been explored.

Figure 4 describes the entire algorithm [38].

Fig. 4
figure 4

NSGA-II algorithm

3.4 Proposed Fuzzy Based Architecture

The ambiguous, untrue, and subjective behavior connected with application-based models can be resolved by fuzzy logic and fuzzy set theory models. These models have the capacity to handle the environment’s uncertain behavior in relation to agricultural data sets, according to recent experiments and studies [39]. The major goal of modelling smart agricultural systems is to determine how to best adapt the system to the kind of data set being taken into account. Agricultural data sets have a large number of highly variable and dependent uncertain attributes, making it challenging to identify a method that can deal with these uncertainties. It performs functions comparable to how the brain works and hence, can be utilized to take decisions for agriculture smartly as it can deal with ambiguity.

Thus, the proposed system describes the impact of fuzzy logic on the optimization algorithm to handle the uncertainties involved while composing services in smart agriculture. Figure 5 depicts the proposed architecture for smart agriculture.

Fig. 5
figure 5

Proposed fuzzy based architecture for service composition in smart agriculture

This architecture works on different layers of IoT structure. Data from the IoT sensors are stored in the cloud as services. Many services offer similar functionality but varying QoS characteristics. As a result, initially, services with similar functionality have been discovered during the service discovery phase. The following phase is the selection of the services from the available pool that are necessary to meet the requirements of the user. This decision is made in accordance with QoS-aware attributes. Since, the user’s requests are complex, hence, cannot be fulfilled using a single service. Hence, in the next phase, service composition is done. Many uncertain factors indirectly impact the services provided by smart agriculture. Thus, to check the impact of those factors on services, fuzzy logic controller has been used. Population has been initialized and further optimization operators have been used to get the Pareto optimal solutions which finally fulfill the user’s requests.

The Mamdani type of inference system is used in this work. \(Management\) \(Skills (MS)\), \(Farmer\) \(Skills (FS)\), and \(Weather\) \(Conditions (WC)\) are the three inputs considered. \(Time\) and \(cost\) are analyzed as outputs to examine how uncertainty will affect them. Both input and output use triangular membership functions with five and six linguistic variables, respectively. First input has been described by five fuzzy sets \(VeryLess\), \(Less\), \(Medium\), \(Good\) and \(VeryGood\) & other two has been described by \(VeryLow\), \(Low\), \(Medium\), \(High\), \(VeryHigh\) and \(VeryBad\), \(Bad\), \(Medium\), \(Good\), \(VeryGood\), respectively. For outputs, seven linguistic values taken for time are \(VeryLong\), \(Long\), \(LongMedium\), \(Medium\), \(SmallMedium\), \(Small\), \(VerySmall\) and for cost are \(VerySmall\), \(Small\), \(SmallMedium\), \(Medium\), \(LargeMedium\), \(Large\), and \(VeryLarge\). Figures 6 and 7 show the details of both input and output membership functions, respectively.

Fig. 6
figure 6

Input membership functions of fuzzy logic controller. a Management skills membership function. b Farmer skills membership function c Weather conditions membership function

Fig. 7
figure 7

Output membership functions of fuzzy logic controller. a Time membership function. b Cost membership function

Fuzzy rules have been employed to manage the controller, and two hundred and fifty IF-THEN rules based on Mamdani inference have been used. These fuzzy rules have taken into account and provided the connection between input and output variables by taking expert knowledge as well as the past experience. Few rules are tabulated in Table 1.

Table 1 Fuzzy inference rules

These rules will provide the intelligent decisions on how to select the optimal solution set for the composited services.

The combination of FLC with NSGA-II can be considered as the optimization algorithm for minimizing time and cost factors in smart agriculture and it has been achieved by carefully selecting three crucial parameters which are as follows-

  1. (a)

    Number of membership functions used.

  2. (b)

    Type of membership function used.

  3. (c)

    Adopted IF-THEN rules.

These decisions have been made in the best possible way using expert knowledge and experimental data. The flow chart for the proposed algorithm is shown in Fig. 8.

Fig. 8
figure 8

Flow chart of proposed algorithm

4 Experimental Setup and Result Analysis

This section gives an extensive description of the various parameters, solution encoding, datasets, and result analysis of the proposed approach.

4.1 Solution Encoding

This study has taken fourteen atomic services and their corresponding candidate services related with the production of apple crops. For any population “P,” there exists a set of solutions “S” and described by using a string as shown in Fig. 9. Its size is equivalent to the total number of services considered, indices representing the corresponding number, and its value shows the particular candidate of that service. Figure 9a and b define the solution encoding by taking the maximum and minimum time of services, respectively.

Fig. 9
figure 9

a Solution encoding for fourteen services by taking maximum time. b Solution encoding for fourteen services by taking minimum time

4.2 Dataset Description

A dataset from an extensive survey of farmers in the Shimla and Kullu regions of Himachal Pradesh, India, has been used to illustrate the service composition problem in agriculture. It comprises atomic services that are part of apple crop production and is employed to assess the performance of the suggested method. The dataset being used has an area definition of per hectare. Table 2 illustrates the dataset of apple crop production.

Table 2 Dataset of atomic services in smart agriculture

4.3 Parameters Description

The proposed algorithm is run on a personal computer 12th Gen Intel Core (TM) i5 @ 2.00 GHz with 16 GB RAM on MATLAB R2013a version. It has been simulated using fuzzy inference system to determine the impact of uncertainties on the defined multiple objectives. The search is stopped when the trade-off points remain constant for three consecutive iterations that is achieved in the 1000 generations. Details of parameters used for validating the algorithm’s performance are tabulated in Table 3.

Table 3 Simulation parameters

4.4 Evaluation Criterion and Result Analysis

Examining the effects of uncertainties on various services related to smart agriculture is the goal of the work presented in this paper. Increasing agricultural production, predicting rainfall, crop monitoring, and automated irrigation systems are just a few examples of the many different agriculture-related challenges that have been addressed using meta-heuristic methods in the literature. This paper therefore compared the three most common meta-heuristic approaches before identifying the best one for the service composition challenge. Comparisons of algorithms included MOGA, GSK [40], and NSGA-II.

Fig. 10
figure 10

Comparison of state-of-art algorithms

Fig. 11
figure 11

Four possible case scenarios of fuzzy implementation

Assume that each algorithm was run K times, with the results being recorded, in order to assess its performance. In order to compare different methods, the following metrics in which the fitness function is represented by (\(f_{x}\)) have been calculated. Minimizing time and cost has been taken as the multiple objectives to be optimized [41].

  1. (a)

    Average fitness function: It is a representation of the fitness function’s \((avg_{f_{(x)}})\) mean value across K runs, which can be expressed by Eq. (4):

    $$\begin{aligned} avg_{f(x)} = \frac{1}{K} \sum _{i=1}^{K} f(x_i) \end{aligned}$$
    (4)
  2. (b)

    Statistical standard deviation of fitness values: It displays the endurance and variation of the fitness values that were achieved for each algorithm during the K run. This indicates how far the optimum solution deviates from the algorithm’s mean. The algorithm converges to the same answer when the standard deviation is smaller, whereas random solutions are represented by a greater value. It can be defined by the Eq. (5) given below.

    $$\begin{aligned} \text {std}_{f(x)} = \sqrt{\frac{1}{K} \sum _{i=1}^{K} (f(x_i) - \text {avg}_{f(x)})^2} \end{aligned}$$
    (5)

    The aforementioned metrics have shown that NSGA-II performs significantly better than MOGA and GSK algorithms. Thus, to examine the impact of uncertainties on the service composition problem by applying fuzzy logic to the specified dataset, NSGA-II has been chosen. Figure 10 illustrates the comparative study of the Pareto optimal solutions from the algorithms mentioned before.

Next, to check the impact of uncertainties in the field of smart agriculture, a fuzzy logic system has been implemented and accordingly, the population has been initialized. Then, genetic operators are utilized to obtain the Pareto optimal set of solutions. Distinct values of input variables are taken to check their impact on output variables. Figure 11 shows four possible cases of fuzzy membership functions. In the first instance, which can be thought of as a normal case scenario, all three of the input membership functions — MS, FS, and WC — are equal to 0.5 which means that \(Management\) \(Skills (MS)\), \(Farmer\) \(Skills (FS)\), and \(Weather\) \(Conditions (WC)\) all are \(Medium\). For the second case, which can be thought of as the best-case scenario, MS=FS=WC=0.9 which means that \(Management\) \(Skills (MS)\) are \(VeryGood\), \(Farmer\) \(Skills (FS)\) are \(VeryHigh\) and \(Weather\) \(Conditions (WC)\) are \(VeryGood\). Third case considers the worst-case scenario with MS=FS=WC=0.2 which means that \(Management\) \(Skills (MS)\) are \(VeryLess\), \(Farmer\) \(Skills (FS)\) are \(VeryLow\) and \(Weather\) \(Conditions (WC)\) is \(VeryBad\). Fourth case is taking an intermediate case scenario with MS = 0.5, FS = 0.2 and WC = 0.8 which means that \(Managament\) \(Skills (MS)\) are \(Medium\), \(Farmer\) \(Skills (FS)\) are \(VeryLow\) and \(Weather\) \(Conditions (WC)\) are \(Good\). The normal case and intermediate scenarios are presented in different contexts where the former reflects conditions found in real life while the latter is a blend of scenarios.

It can be analyzed from Fig. 11 that the best-case scenario provides the best set of Pareto optimal solutions whereas the worst-case shows the poorer Pareto optimal solutions when compared.

Table 4 Case scenarios statistics

4.5 Statistical Analysis

Statistical analysis is the greatest method for gaining a comprehensive understanding of the results. Thus, a comparison of four possible case scenarios statistically has been summarized in Table 4. It can be observed that the best-case scenario is achieving the lowest average standard deviation, hence, making it more robust than other case scenarios.

5 Conclusion

Fuzzy logic is a powerful framework to address the uncertainties involved in various distinct services of smart agriculture. Numerous meta-heuristic-based optimization techniques have been employed in the literature to improve smart agriculture by increasing crop production, reducing fertilizer consumption, and many other methods. However, none of them have offered a framework for the service composition in smart agriculture. As a result, this study has concentrated on composing several services that are a part of smart agriculture with similar functionalities but different QoS attributes, thus, making the work presented in this paper, a novel viewpoint on smart agriculture. To achieve this, a novel architecture has been proposed for solving the multi-objective service composition problem in smart agriculture. The overall architecture consists of two phases. The impact of fuzziness on time and cost, which are two multiple objectives to be minimized, is checked in the first phase, and the results are optimized in the second. For optimization, Pareto solutions obtained from the three most commonly used meta-heuristic approaches- MOGA, GSK, and NSGA-II have been compared by doing an exhaustive simulation for K number of times. Analysis has revealed that NSGA-II is outperforming competitors. As a result, the NSGA-II optimization strategy is adopted. A dataset of services used in the production of apples has been selected to test the effectiveness of the proposed algorithm. MS, FS, and WC are taken as input membership functions whereas time and cost are output membership functions with the Mamdani inference system. The impact of fuzzy is checked for four possible case scenarios- normal case, best case, worst case, and intermediate case. When compared to other scenarios, it has been discovered that the best Pareto optimum solutions are produced by the best-case scenario with ME=FS=WC=0.9. Thus, the proposed algorithm has been successfully implemented, and the objectives have been met as expected.

This work explains the start of service composition in smart agriculture; there is still a substantial amount of unfinished scope in this field. This work can be further extended by using the concepts of artificial neural networks, machine learning, and multi-cloud service composition to make agriculture more sophisticated and intelligent. For future work, more hybrid meta-heuristics can be used to solve the same problem. In addition, multiple conflicting objectives can be optimized at the same time by taking different quality of service parameters.