A New Approach for Crop Rotation Problem in Farming 4.0

. Technology and innovations have long improved farming over the world and, as Industry 4.0 quickly spread, farmers have embraced high-level automation and data exchange, driving a transformation called Farming 4.0. Consequently, precise and even real-time field information have become easily accessible. Though, analyzing all this information requires great skills and tools, like mathematical knowledge and powerful computational algorithms to reach farmers expectations. This research explores the Crop Rotation Problem (CRP) and its relevance for the integration of Precision Agriculture (PA) and farm management. This paper presents a new mathematical approach for the CRP based on the nutrient balance and crop requirements, increasing the sustainable appealing of the problem. A real-encoded genetic algorithm (GA) was developed for optimization of the CRP. The results indicate good performance in mid and long-term crop scheduling.


Introduction
Technological advances have been widely shaped agriculture.Innovations in sensor devices and embedded systems have improved tillage and crop yields.Efficiency in resources management and autonomous data acquisition turned out to be essential among farmers.As Industry 4.0 thoughts have pushed ahead manufacturing units, agriculture also moves toward a transformation called Farming 4.0, or also referred to as Agriculture 4.0.In general, important developments in automation have been noticed, related to Precision Agriculture expansion [1] [2].
Precision agriculture (PA) follows from the integration of crop management and information technologies.The field measurement of crop requirements and the proper supply of these demands are promoted by PA and intend to improve crop production and resource consumption, approaching sustainable ideas and reducing environment impacts [3] [4].Industry 4.0 relies on digital technologies, such as Big Data, Internet of Things (IoT) and Artificial Intelligence (AI), to enhance production systems and reach the highest level of cooperation and mobility.In agriculture, connectivity has been expanding allied with IoT and transforming the whole infrastructure.This trend has been noticed in farm equipment: connected tractors, spray devices with route optimization devices and other advanced machines, which are able to gather data and even share information with their manufactures for maintenance purposes [5].
Besides farm technologies stand as advanced as industrial applications, production planning remains a challenging task in agriculture.Aside from monoculture, scheduling crops in a large set of fields rely on market outcomes, weed, and pest control or weather forecasts.Searching for strict mathematical approaches remains quite unusual, relying much on the farmer expertise and short-term goals.
According to USDA, Latin American agricultural GDP growth ought to recover strength in a short-term period marked by recession and slow growth, which relates mainly to Brazil and Argentina economic instability [6].Brazil is one of the greatest food producers in the world.Investments in agrarian researches and development are quite expressive, they reached 1.82% of Brazilian GDP in 2013 [7].Therefore, agrarian researches present as much potential as industrial ones for Latin America economies.
This research paper acknowledges the importance of CRP in the Farming 4.0 developments.The proposed mathematical model for CRP bases on fertilization management techniques, such as nutrient budgets.
The main contribution of this paper relies on the relevance of the proposed model supporting farm management decisions.It achieves profitable solutions and evaluates the resource balance, providing valuable insights in the crop sequence.
To accomplish a broad range of CRP scenarios, optimization techniques ought to provide solutions for small and sizeable instances of the problem.The proposed evolutionary algorithm presents good results in the large instances where the deterministic method takes large amounts of time.The stochastic approach in this paper combined with the deterministic method ensures that the proposed model can assist agrobusiness management providing solutions for many scenarios.
The subsection 1.1 presents a review about the CRP approaches in the literature.Section 2 establishes the relationship to industrial and service systems.Section 3 presents the proposed model and its details.The optimization techniques are discussed in Section 4 and the attained results in Section 5.The conclusion and further steps of this research presents in Section 6.

Discussion on Previous Works
The CRP has been extensively researched.Distinguished approaches and mathematical models have enriched widely the available literature.The complexity related to this NP-hard problem is the main reason for continuous innovation.Heuristic and metaheuristic approaches are quite common among applied techniques.
A review of the stochastic and deterministic methods applied to the CRP presented in [8] and pointed out that the deterministic approach has been successful in some specific models, though lacks in efficient over sizeable instances of the problem.Although there is no agreement among researches about the best method, evolutionary and hybrid algorithms are promising, due to the high flexible structure of genetic algorithms.
Concerned about a large amount of consumed resources and the environmental impact of monoculture farming, the research presented in [9] discussed an optimization model for CRP, based on organic farming concepts.A new column generation algorithm combined with a greedy heuristic was developed and generated solution for this proposed model of the CRP.
The research presented in [10] analyzed hybrid metaheuristic algorithms in search of quality solutions for the CRP.Attaining feasibility presented to be a hard task on the proposed model, to overcome this hurdle, the initial population was generated by a heuristic procedure.The hybrid algorithms with local search and with Simulating Annealing presented good results in this related work.
Multi-objective approaches for the CRP are quite contemporary.A bi-objective approach presents in [11], it acknowledges that profitability and diversity of crop rotation are conflicted goals and provides a bi-objective model that explores both objectives.

Relationship to Industrial and Service Systems
Based on a vast area of expertise, Operational Research deals with problems regardless of the context in which they arise.Problems in which the objective is to determine, according to one criterion, the best choice within a set of alternatives.The development of the areas of engineering, computing, and economics has been characterized by the increasing use of optimization models as paradigms for representation and resolution of decision-making problems.
Scheduling Problems represent a class of significant decision-making problems in optimization.Numerous companies and service systems face problems regarding task sequencing, which can be caused by improper allocation of resources and poorly defined processes.The areas affected by these problems are diverse: industry, manufacturing, agriculture, process management, transportation, among others.We can optimize processes by performing task sequencing planning, which results in improved production flow control, meeting deadlines, and scheduling tasks to better utilize available resources.
Solutions of this type of problem are not obtained in closed forms.Instead, they are determined by algorithms: a sequence of procedures applied repeatedly to the problem until the best solution is obtained.According to the adopted formulation (fundamentally dependent on the parameters), we can solve the problem exactly in polynomial time, or even deal with NP-class problems.In these cases, it is necessary to abandon the search for an optimal solution to seek a quality solution, through heuristic procedures.
The present research aims to provide a valuable method to analyze information only acquired by the current state of interconnection between physical and cyber world, such as actual crop nutrient requirements.And, although the proposed methodology applies to agrarian management, the concepts of Industry 4.0 are embraced in this research.The perception of this work exceeds agricultural environment by the integration of planning, profit and production requirements.

Crop Rotation Problem
The proposed mathematical model for the CRP is described ahead and bases on mathematical approaches presented in [9] [10].The nutrient balance concept presented in the model relates to researches in [12] [13] and bases on the surface nutrient budget idea.
• : size of the crop set; The objective function presented in eq. 1 evaluates crop schedule profits and fertilization costs.Besides crop budgets already cover fertilization costs, the objective function also incurs these costs to minimize the number of consumed resources.
The constraint set in eq. 2 prevents adjacent areas to hold the same crop family scheduled in the same period and the constraint set in eq. 3 ensures that crops from the same family shall not be scheduled in sequence on each crop field.
The constraint set in eq. 4 prevents scheduling more than one crop in the same period, in other words, it is a spatial restriction.Fertilization balances are established in equations 5, 6 and 7, following the concept of surface nutrient budget.The production requirements for each crop are evaluated by the constraint set in eq. 8.The constraint set in eq. 9 ensures that crop scheduling happens just in the proper planting period, denying allocation outside this window.The decision variables   are Boolean type and each one represents the schedule of the crop "i" in the period "j" on the field "k" and the fertilization variables (F N  , F P  and F   ) are real values.
In order to enlighten the mathematical model and its constraints, a sample solution of the CRP is presented in Table 1.

Table 1.
A crop schedule solution attained by the proposed model for the CRP.The left side presents the crop schedule in a 24 periods interval (each period corresponds to a 15-day interval).The right side presents the related families to the sequence.The constraint set in eq. 2 prevents the same family in adjacent crops.This can be verified in the sample solution in Table 1, according to the adjacent plots presented in Table 2.
Table 2.The adjacency among plots for this solution presents on the left side.Each row represents adjacent plots from the row index.Additionally, the right side shows each plot area.
Table 3 shows that the crops from the same family can be schedule again in the same plot after a period defined by , which satisfy the constraint set in eq. 3.
Table 3. Partial view of the previous sample solution.It shows how the problem fits the constraint set.
Nutrient constraints in eq. 5, 6 and 7 are quite intuitive and rely on supplying the required inputs from the scheduled crops on the interval  in each plot "k".Reaching production requirements follows from constraint set in eq. 8 and scheduling in the proper planting period from eq. 9.The fertilization inputs and the attained production from sample solution are not presented for assumption of easy understandability.
The presented CRP model requires data about the crop features and the market.Usual planting dates were gathered from [14], average prices and production statistics based on [15].Crop budget for the established profitability were mainly taken from [16] and, in some cases, updated with production and average prices from [15].The crop nutrient requirements were acknowledged from [17].

𝛽 𝛽 4 Methodology
Evolutionary algorithms are computational procedures for solving problems, resulting from the iterative application of heuristic techniques, which makes these algorithms capable of promoting the search for a solution in a huge space of possibilities, in a very flexible way [18].Evolutionary Algorithms work with a population formed by a set of individuals.The coding of the individuals (representation of possible solutions to the problem) is the most important step of the algorithm.The adaptation function allows assigning each element of the search space (individual) a value that is used as a measure of performance.In optimization problems, this function incorporates all aspects of the objective function.During the generations, this population is evaluated.The most suitable ones tend to be selected and can undergo modifications in their characteristics through crossover and mutation operators, generating descendants; finally, the more adapted go to the next generation, resulting in individuals getting more fit, while others tend to disappear.Some characteristics of these methods deserve to be highlighted: flexibility, generality, ability to escape from great locations, ability to deal with complex problems for which it is not possible or difficult to obtain a detailed description, as well as being less susceptible to form or continuity [19] [20] [21].
For the development of the approach proposed in this work, we chose the Genetic Algorithm (GA) [22], because it is a classic method, one of the first Evolutionary Algorithms proposed in the literature and easily adapted to any problem, besides being extensively applied in the different areas of engineering.The functionalities of the algorithm proposed in this work were implemented with the concern of respecting the physical and operational characteristics of the problem.The coding technique and the main operators to approach this work are described ahead.

Encoding and Decoding
The binary decision variables in the CRP might appear rather suitable for binary encoded genetic algorithms, but evaluations showed that performance decreases on mid-term and long-term planning.Also, the binary GA requires hybrid approaches to improve performance [9] [10].The proposed GA based on the real encoding technique presented ahead.
The left side of Fig. 3 presents the data structure which holds all the feasible combinations of crop, period and plot.The right side presents a chromosome that holds two memory positions, one has a real number and the second one is an integer index related to the previous data structure.

Table 4.
Real-encoded information in the GA.The left side presents a support data structure with all the possible crop allocations and the right side shows the chromosome filled with floating numbers.
Decoding process initializes with sorting the chromosome according to the real numbers.The highest priority returns an index that represents the first crop to be allocated, then the process continuous until there are no more possible allocations.Table 5. Decoding process.The chromosome is sorted according to the floating values.The second column of the chromosome holds the index related to the support data structure.Decoding follows down this priority list until there is no more availability in the schedule.
The fertilization variables have direct correspondence to the chromosome values, apart from the schedule priority list and without requiring any decode technique.

Genetic Operators
The presented GA uses the tournament selection as a technique to sort out individuals from the population.Tournaments happens with "k" random selected individuals; the winner is the highest fitness among them and shall be placed in the mating pool, which will generate a new offspring.
The tested crossover and mutation operators are presented in [23] [24].A brief description of Laplace Crossover technique and Power Mutation follows ahead.
• Laplace Crossover: 1) Random numbers:   ,   ∈ [0,1]   The coding and decoding generate solutions which already fit constraint set in eq. 2, 3, 4 and 9, decreasing infeasibility workarounds.To increase performance, there is a penalty method applied to the nutrient balance constraints.

Discussion on Results
The proposed model has been evaluated by a deterministic approach and by the presented GA.Glop linear solver, which is a powerful linear optimization solver developed by Google, handled the deterministic evaluations.According to Table 2, achieving exact solutions requires exhaustive computational time even in mid-term planning.
Performance of the GA was tested with 48 periods and with 72 periods in comparison with the Glop solver results.In each case, the GA ran 20 times to attain the presented results, this stochastic procedure requires several executions to validate its proper performance.The initialization process generates 1000 random individuals.Each further generation has 400 new individuals.The current population and the new population generate the mixed population, which is sorted out based on fitness and the best individuals from this population shall be in the current population.
Crossover and mutation probability are 1.00 and 0.15, respectively.The total number of generations is 300.These parameters were selected after tuning and provided the best results for the tested instances.
This research presents the proposed model as potential tool for farm management.In order to ensure the reliability of this mathematical approach, there should be optimization strategies able to manage sizeable instances of the CRP.The proposed GA and the deterministic approach are complementary techniques in this work.The first one turned out to be quite suitable for the large data analyzes, whereas the exact searches may seem extremely high-cost alternatives.
The results in table 6 and table 7 analyzes the proposed GA in terms of repeatability and stability, which are very important to ensure that the solution attained in the large instances are reasonable.Although the computational time required by the GA exceeds Glop's one, the performance of the Glop solver is undoubtedly better in the small-size problems, besides GA provides sub-optimal solutions, and so, the proposed evolutionary approach is designed to work together with deterministic methods.Table 6.Results from executions in a 60-crop database over 48 periods (2-year schedule) and 7 plots.
Table 7. Results from executions in a 60-crop database over 72 periods (3-year schedule) and 7 plots.

Conclusion
The proposed mathematical approach for the CRP enlightens agriculturally sustainable appeal without turning back on profits as the main goal of the problem.The developed algorithm achieved prospect results in a reasonable computational time and provided quality solutions for the large instances of the CRP.
This research acknowledges the potential for further developments related to CRP in sustainability and multi-objective approaches.Field crop information will increase fast and become more reliable due to observation and monitoring techniques which are driven by Precision Agriculture.Consequently, crop nutrient balance holds an important role in further developments.The real-encoding technique presents to be very powerful in the long-term analyzes of the CRP, avoiding exceeding computational time related to the infeasibility workarounds.Establishing relationship between crop scheduling and nutrient balance in the same model is the main contribution of this research and requires several agricultural cases to acknowledge the extent of this approach on the farm management.

Fitness ($) Gap
Based on the presented results, the proposed mathematical model is reliable and provides quality solutions through the deterministic approach or the proposed GA, each according to the data complexity.The proposed approach for this scheduling problem and the characteristics of the GA presented, such as the real-encoding technique, could suit many applications in the Industry 4.0.

4 . 3
• (̅ −   ),  <  ̅ +  • (  − ̅ ),  ≥  Overview of the Proposed Genetic Algorithm A random procedure generates the initial population.At first, the current population is the same as the initial population.Then, the genetic operators (selection, crossover and mutation) produce the so-called new population.The mixed population combines the current population and the new population, sorting individuals according to their fitness.Individuals with high fitness among the mixed population are selected to fill the current population and compose the next generation.The code was developed in C language to reach high efficiency.Fig.1summarizes the characteristics of the GA.