A bi-level model for a closed-loop agricultural supply chain considering biogas and compost

In today’s competitive marketplace, to increase customer satisfaction and profitability, supply chain management has become more prominent. Therefore, thorough planning and designing the supply chain by seeing all levels and units are essential to growing the efficiency of the entire supply chain. In the present study, an eight-echelon network is designed for a closed-loop agricultural supply chain. These eight echelons are consisting of suppliers, farms, distribution centers (DCs), customers, recycling depots, biogas centers, compost production centers, and biogas applicants. To design the agricultural logistics network, a bi-level programming mathematical model is presented. The first objective seeks to minimize total costs of the upper-level which consist of shipping costs, construction costs, production costs, inventory holding costs, and buying costs. Besides, the second objective attempts to maximize total profits of the lower-level using subtraction of incomes from the costs which the total income is calculated by selling manufactured biogas and compost to its applicants. Since the bi-level programming problems are part of the NP-hard class and due to the computational complexity of the problems, the meta-heuristic algorithms are utilized to solve the formulated problem. To this end, two meta-heuristics consisted of Genetic Algorithm (GA) and Stochastic Fractal Search (SFS) are employed. Moreover, two hybrid metaheuristics created from these algorithms which include GA-SFS and SFS-GA are suggested to search for more appropriate solutions. Finally, various comparisons and analyses are performed to evaluate the model’s performance and the capabilities of the solution methods and the results showed the superiority of SFS-GA over other methods. Also, the results imply that considering biogas and compost can not only prevent environmental pollution, but also lead to profitability and the production of new products. Therefore, using this plan in countries that have agricultural products and also do not produce fossil fuels can be more attractive and practical.


Introduction
Today, organizations seek to take advantage of the benefits of proper supply chain management to maintain their position in the market, create a competitive advantage and reduce costs, and generally improve the efficiency of their supply chain. Decision-makers and managers may have strategies in place to stay alive in this condition, but the favorite result will only be achieved if an accurate and comprehensive plan is used. Therefore, a detailed network design and principled supply chain planning with all levels and units in mind to increase the efficiency of the entire supply chain seem necessary (Delgoshaei et al., 2021;Tirkolaee et al., 2022aTirkolaee et al., , 2022b. Return products management, on the other hand, is a complex issue that requires decision-making at the strategic and operational levels. Problems that need to be addressed at the strategic level include determining the type of facilities needed and their location, the volume of recyclables that can be controlled or planning the flow of recycling materials (Khalilpourazari et al., 2021;Rahbari et al., 2022). On the other hand, issues related to operational planning include issues such as the time interval between recycling collection times, the number and capacity of vehicles, the relevant routing issue, and the number of workers required. Despite the close relationship between these two types of decisions, their analysis and review are usually done separately. Strategic decisions often have to be answered through political and governmental issues, while operational decisions need to be considered at lower levels, such as at the municipal level. Therefore, issues related to recycling management should be considered in the case study of different types of products in different locations (Cheraghalipour et al., 2020;Tirkolaee et al., 2021).
Reverse logistics and closed-loop supply chains are some of the most important and vital aspects of any business and include the construction, distribution of services, and support for any type of product. In developed countries today, industrial, governmental, commercial, and service organizations focus on reverse logistics processes and supply chain, which play an important role in creating the true economic value of goods and services while supporting environmental considerations (Ranjbar & Mirzazadeh, 2019). This focus is now increasing in all markets, including the industrial and advanced technology, commercial and consumer products sectors. Recent literature has shown that today, product returns are not only costly but also a means of creating value. Examples include preserving the environment, providing core resources, and increasing customer value. That potential revenues are usually greater than the costs incurred to create the necessary measures for return channels (Krikke et al., 2013;R. Lotfi et al., 2022).
On the other hand, agricultural products are one of the most important elements of the food basket of the people of the world. Iran is one of the first countries in the world where agriculture has started. According to the statistics of the 'Iranian Agricultural Jihad,' about one-third of Iran's land is agricultural, but due to poor soil and inadequate water distribution in most areas, only 12% of Iran's land is cultivated (including gardens, vineyards, and agricultural lands). 63% of arable land is still intact. In Iran, 50-60% of the capacity and talent of the lands under agricultural operations (185,000 square kilometers) are used. Iran's arable land is estimated at sixteen million hectares, of which about half is irrigated and the other half is rainfed (Agriculture Jihad, 2016). The agricultural supply chain today has a very important role in supply chain issues because of its unique structures such as the significance of food features, climate change, price changes, and the importance of supply-demand. In the classification of these topics, products are divided into two categories of perishable and non-perishable (such as grain and dried products). Also, in terms of the life cycle, they are divided into two categories: agricultural and horticultural crops (Cheraghalipour et al., 2018).
In recent years, the importance of the issue of agricultural products has grown significantly with increasing demand from concerned customers for a healthy diet (Weber et al., 2015). This has made quality and availability two important issues in all months of the year (Paksoy et al., 2012). In the last 10 years alone, the agri-food industry in general and the fresh fruit sector, in particular, have been recognized and discussed in the supply chain as a key concept for competitiveness (Tsolakis et al., 2014). Numerous studies have addressed and covered the issue of agricultural supply chain issues; but in our research, we found a research gap in the reverse logistics of products, a big problem that causes a lot of damage to this chain every year. This problem, which is the decay of products, is covered in the reverse logistics section of our proposed network. Since a significant number of manufactured products in the stages of production, distribution, target markets, etc., are decayed and unusable, it is felt that to reduce the costs of these wastes and reuse them, it is necessary to develop and analyze a closed-loop supply chain network design model (Tirkolaee et al., 2022a(Tirkolaee et al., , 2022b. It is very necessary and important to consider these concepts together. In recent years, the design of the logistics network in the supply chain has become more important than in the past. Considering the issue from the perspective of several decisionmakers, issues related to returned products, and the production of added value such as compost and biogas in the supply chain are of great importance today and have attracted the attention of many researchers. For this purpose, sufficient explanations will be provided in the present research. This study tries to develop a practical model for designing an agricultural supply chain network as much as possible, taking into account the limitations of the real world. Therefore, considering the waste and corrupted products in the agricultural supply chain, it will provide a network to collect these returns to reduce the costs of the chain and generate potential revenues from them. For this purpose, an eight-echelon network is designed for the agricultural supply chain. The suppliers are the first echelon. Farms are the second echelon to produce crops. In the third echelon, some DCs buy agricultural products from farms and send them to customers in the fourth echelon after processing. It should be noted that this network has been in operation for multiple periods, so in echelons 2-4, some of the products will become waste. These waste materials are transported to the fifth echelon for the depot, and according to management decisions, some of which are transferred to biogas production (echelon 7), and some are sent to the production of biological fertilizers (echelon 6). Finally, these biogas and biological fertilizers are sent to customers in the eighth echelon and the suppliers in the first echelon, respectively. Due to the computational complexity of the large-scale real-world problems, meta-heuristic algorithms are developed. Finally, various comparisons and analyses are performed to evaluate the model's performance and the capabilities of the solution methods. The general purpose of this study is to present a bi-level programming model and evaluate the efficiency of the closed-loop agricultural supply chain network proposed in the case study; and the special purpose of this research is to achieve an efficient method for reuse of supply chain waste in the reverse logistics sector and return of this waste to the supply chain, which will add value to this waste. This is done by making compost and biogas. To this end, two goals such as minimizing total costs and maximizing total profits are considered.
Bi-level programming problems, in the simplest form, those mathematical models for the leader and the follower are linear and their decision variables are continuous, can be converted into a MIP problem. In this case, by using the Karush-Kuhn-Tucker (KKT) conditions, the follower model can transform into a series of constraints. Then, by placing them into the constraints of the leader, a nonlinear model is created. This nonlinearity is

Agricultural supply chain
The supply chain of agricultural products today has a very important role in supply chain issues due to its unique features such as the importance of food quality, the importance of supply-demand, climate change, and price changes. As a pioneer in this field, van Berlo (1993) measured activities associated with the vegetable processing supply chain, which included the stages of planting, harvesting, processing, and marketing, and used in a mathematical model using a goal programming approach. Their model included farmer decisions to reduce chain costs and did not include location decisions. After this research, the process of using operation research in agriculture continued. For example, Jolayemi (1996) planned agricultural planning for multi-regional harvests; Allen & Schuster (2004) estimated investment and harvest to reduce crop losses using a nonlinear model in vineyards. And Rantala (2004) provided a supply chain model for seedlings that sought to minimize production and transportation costs to meet customer needs. As progress in research gradually became more advanced, additional assumptions such as product quality and shipping process were considered. For example, Ferrer et al. (2008) developed a model for deciding on harvest per season, shipping process, processing of products, and packaging in the form of a mixed-integer model (MIP) for red grapes. Their model is designed only for post-harvest planning to meet customer demand and also takes into account the cost of harvesting and reducing the quality of the product.
The expansion of problems in the agricultural supply chain is taking place with an evolutionary trend so that recently Cheraghalipour et al. (2018) developed a multi-echelon network for the citrus supply chain and using several meta-heuristic algorithms attempt to balance the chain costs and customer demand. Also, in another study, Cheraghalipour et al. (2019) sought to create a bi-level network for the rice supply chain, which reduces the cost of the chain from the perspective of two decision-makers. They used nested evolutionary algorithms to solve their proposed problem and performed management insights and sensitivity analysis on specific parameters. In addition, Anderson & Monjardino (2019) considered a kind of discount in their formulation and tried to reduce the price of wheat by using the contact structure. They validated their structure using a case study in Australia and reported that the contract was closely related to manufacturers' risk aversion. Also, Carvajal et al. (2019) used a robust programming method for the sugarcane sector in Colombia to optimize plant profits and make several tactical and strategic decisions.
In an article, Gardas et al. (2019) added value to the present data-based industry by identifying the challenges of the agricultural supply chain in India based on a careful review of the literature and the Delphi method. Therefore, laboratory and experimental decision-making methods were used to model the identified challenges, explore cause-andeffect interactions, and improve hierarchical configurations of challenges through interpretive structural modeling. The execution of this method led to the conclusion that two elements, namely limited integration into national agricultural markets and limited agricultural market infrastructure, are the most important factors. The integrated model obtained as a result of this study aims to guide agricultural policies and decision-makers to improve the performance of the agricultural supply chain in India. There are also some basic recommendations for improving the efficiency of agricultural supply chain management.
Recently, Dai & Liu (2020) conducted an in-depth study of the supply chain risk of large retail companies and then introduced the dock of agricultural supermarkets for the supply chain in the big data environment. In this study, big data was used to analyze the potential risk in the agricultural supply chain in large retail companies. From the aspects of production, processing, distribution, retail, and consumption, this research introduces new risks in the supply chain of agricultural supermarkets after the introduction of big data. In the second stage, qualitative analysis and quantitative calculation are combined to perform the risk assessment. Through experimental analysis, the ranking of all risk factors was obtained and the corresponding fuzzy assessment grade and risk assessment criteria were given. Through expert evaluation, a new risk rating was obtained, which is not much different from the results of the experimental analysis, and the experimental results were confirmed. Therefore, the development of this study is useful to avoid the risk of connecting the supply chain of agricultural supermarkets. Yan et al. (2020) also proposed a way to coordinate an agricultural supply chain with tactical purchaser behavior in mind. According to the characteristics of the supply chain of agricultural products, the beneficial performance of consumers was provided and under the integrated chain, this study focuses on the effect of consumer behavior on decision-making in the supply chain. Therefore, it counts the tactical activities of strategic users as a risk aversion factor and examines the effect of user risk on supply chain decision-making. Also, two coordination contracts based on income sharing and wholesale prices are designed for decentralized decision-making in the agricultural supply chain. Finally, through numerical analysis, the sensitivity analysis of some of the main parameters in the model is performed.

Multi-level programming
Multi-level programming was first proposed by Bracken & McGill (1973, 1974a, 1974b) as a generalized mathematical programming model. Then, their different models were examined and used by researchers. But in recent years, these methods and applications have been studied more seriously and extensively. The main concept of the multi-level programming method is that the upper-level decision-maker determines his goal or decision and then demands the desired limit from each sub-level, which is calculated alone. Then, the lower-level decisions are presented and modified by the upper-level according to the profit or the total amount obtained. This process continues until a satisfactory solution is reached. In these types of issues, the upper-level decision-maker does not have the authority or ability to decide on all decision variables. The design of financial management networks, transportation, and production planning are among the issues in which this method is used (Behnia et al., 2019). The general model of multi-level programming can be presented as follows (Migdalas et al., 1998).
In relation (2), P 1 is known as the first-level problem and is equivalent to the upper-level in the hierarchical structure. The decision-maker at this level controls the decision variable x 1 and the objective function of his level to minimize f 1 . Similarly, P k is the problem of the kth level and corresponds to the lowest level of the hierarchy. If the problem consists of only two lines, it is called a bi-level programming model. In this case, the decision-makers of the upper and lower levels are called leader and follower, respectively.
Leader-follower hierarchical decision-making problems were first raised by Stackelberg (1952), which he called bi-level programming problems. These issues have two levels that the first level decision-maker implements his decision on the second level, observes the reaction of the second level, and intends to optimize his objective function. The secondlevel decision-maker also observes the first-level decision and makes a logical decision to optimize its objective function.
In general, the following characteristics can be provided for a bi-level programming model: • Each decision-maker directly controls only certain variables.
• Different levels of decision-making are influenced by the decisions and activities of other levels, but each is trying to optimize its own decisions. • Upper-level and lower-level decision-makers know each other's level goals and constraints. • Lower-level is required to implement upper-level decisions and implementation of decisions is from top to bottom. • The goals and decision-making space of each level can be influenced by other level decisions.
The bi-level programming problem is an NP-hard problem (Bard, 1991). However, due to its many applications in practice, many methods have been proposed to solve it. Methods for solving this problem can be divided into five categories, which are presented in Table 1. (1)

Counting methods
The general idea is that the optimal solution is one of the vertex points. These methods are specific to linear bi-level programming problems and obtain the exact optimal solution Matching the lower-level methods In these methods, the problem is replaced by the KKT optimization conditions or the penalty function, so that the lower-level problem becomes a constraint on the main problem Fuzzy methods The general idea in this group of methods is to define the belonging function for objectives, constraints, variables, or a combination of them at each of the problem levels Meta-heuristic methods These methods are not exact methods and provide an approximate solution or optimal solution, which also has a good computational complexity. Tabu Search, artificial intelligence, PSO algorithm, and ant colony algorithm are in this category

Agricultural waste
Pesticides and agricultural wastes are the most dangerous contaminants in water and soil that remain in the environment for years and cause irreparable damage to life. On the other hand, effluents from the agricultural sector are one of the most harmful sources of environmental pollutants that dangerously affect the health of the environment and, consequently, the quality of citizens' life. Agricultural waste arises from production activities in the agricultural sector, which include waste, animal carcasses, and rotten agricultural products, pesticides, and chemical fertilizers (Chávez et al., 2018). According to statistics released by the FAO, about 30% of agricultural products worldwide are turned into waste, and the value of this volume of waste is estimated at $ 5 billion per year. Iran is known as one of the leading countries in the field of agricultural waste and has a high ranking compared to other countries in the same category. Waste from dates, figs, wheat, rice, wheat bran, barley bran, tomatoes, and legumes such as green pea, beans, corn, and other crops can be good sources for reproduction. Therefore, according to the mentioned importance, agricultural waste is an important and vital issue that must be addressed and prevented from entering the environment. Therefore, this study will consider the destruction of agricultural waste from the proposed supply chain by considering the production of biogas and compost. In the following, we will review some of the research conducted in the field of agricultural waste. Xiong et al. (2020) in a study examined the possibility of consuming agricultural waste and synthetic macromolecules as sources of solid carbon and investigated the effects of improving nitrogenating through nominated agricultural wastes. The capacity of carbon release and disinfection performance of corn, peanut shell, worn rice, and other materials were systematically analyzed. The results showed that for each carbon source, the first-order kinetic equation is fundamentally monitored during the carbon emission process. Synthetic polymers are more suitable for nitrogen removal in groundwater filtration, while agricultural wastes are ideal carbon sources for secondary wastewater filtration. Also, Fareed et al. (2020) stated that every year, as a result of energy production activities, large amounts of agricultural waste ash are produced from crop residues. The disposal of soil and ash produced has serious environmental and health problems, which are primarily due to groundwater pollution. In addition, the unavailability of land for further evacuation is another major problem associated with it. Due to the problems related to agricultural waste ash, in their study, three types of nanoagricultural waste ash were used to modify the adhesive and asphalt mixture. Rice husk ash, sugarcane stem ash and wheat straw ash were first reduced to nanoscale using a mill. These samples were then mixed with asphalt connector in terms of joint weight. Then, all samples of modified adhesive were tested from different perspectives. From the results, it can be concluded that the combination of each of the nano-waste ashes in the adhesive and asphalt mixture is a sustainable and environmentally friendly method for its disposal.
In another study, Mo et al. (2020) investigated the use of solid agricultural waste in concrete production. According to them, the increase in construction activities has led to the rapid depletion of natural resources, especially aggregates used in the production of concrete. Also, a large amount of solid waste is produced from the agricultural industry, especially from the Southeast Asian region, such as palm and coconut shells. Therefore, their study investigated the feasibility of these wastes as a potential alternative to conventional aggregates in concrete. The durability of concretes, especially those containing recycled waste, is often investigated. Therefore, their article seriously examines the published findings on the durability properties of concrete containing these agricultural wastes. Moreover, Adebisi et al. (2020) observed that the production of silicon by conventional processes is complex and occurs at very high temperatures. Therefore, in their research, some agricultural wastes have been used to produce silicon in a very simple way. Agricultural waste is generated and disposed improperly in the environment, and this is an environmental challenge. Burning them produces gases that can affect the weather. The United Nations has called on all governments to work together to reduce climate change. On the other hand, the potential of Nigerian solar energy encourages investment in photovoltaic technology, which requires silicon, and their study aims to develop an alternative application for some agricultural wastes as potential sources of silicon.
Due to a large number of researches in this field, the following paragraph can be summarized. Heniegal et al. (2020) studied the properties of clay bricks containing refinery sludge and agricultural waste. Zhang et al. (2020) presented a study to maximize the use of agricultural waste in high-density polyethylene composites. Bhat et al. (2020) produced low-cost, catalyst-free, high-performance super-capacitors based on porous nano-carbons from agricultural waste. Kapoor et al. (2020) evaluated the value of agricultural waste for a biogas-based circular economy in India.

Research gaps
To provide a broader literature review to find the research gaps, a summary of some articles related to the agricultural supply chain is provided in Tables 2 and 3. For this purpose, articles published in international journals, library resources, and reputable scientific sites in different years until 2020 have been used to collect information. The Elsevier, Springer, Taylor & Francis, and John Wiley databases have also been selected as reliable and easierto-access databases. Keywords including food supply chain, agricultural supply chain, perishable products, and fruit supply chain have been searched. For this purpose, 30 articles completely related to the subject of this research were selected and reviewed based on various factors to reveal the gaps.
Using the properties of Tables 2 and 3, we describe the gaps of the past researches. As it is shown in the table, 47% of these detailed research works used exact methods and then meta-heuristic algorithms with 40% took the second place of the used solution approach. However, simulation methods comprise only 13% of these studies. Therefore, exact and meta-heuristic algorithms have received more attention, which indicates the efficiency of these methods.
Also, 100% of these research works focused on forwarding flow, and only 7% of these research works considered both reverse flow and closed-loop mode. On the other hand, some layers of the network, such as recycling facilities, have only covered 7% of these research works. Therefore, these gaps, including close-loop, reverse logistics, and recycling facilities, need to be addressed in future works. In terms of the objective function, cost minimization covers 57% of these cases, which indicates the importance of this economic objective function. On the other hand, other important goals such as demand responsiveness and emission aspects have received very little attention. It is also evident that studies on apples and pears accounted for 20% of these studies, and other areas were less considered. Also, assumptions such as multi-product, bi-level, compost, and biogas with 30%, 3%, 7%, and 0% were less considered and should be covered. On the other hand, items          (Starbird, 1988     such as strategic, planting, inventory, and multi-vehicle with 37%, 30%, 37%, and 7% received less attention, respectively, and should be covered. Therefore, the innovations of this research can be listed as follows.
• Designing a new bi-level mathematical model for the closed-loop agricultural supply chain • Reuse of agricultural waste to produce compost and biogas • Introducing new, efficient, and effective nested hybrid metaheuristics for model analysis • Providing several numerical examples to validate the proposed model

Problem definition
In the desired supply chain, raw materials such as fertilizers and pesticides are supplied by various suppliers and delivered to farms. Farms send the final products to distribution centers (DCs) after production. Also, some of the products can be sent directly from the farms to the customer areas in the form of retail, which will be possible only for a limited period due to the lack of proper storage of these products by the manufacturers. An overview of the problem under study is shown in Fig. 1.
Most agricultural products are stored in warehouses or, if necessary, in the cold stores of DCs and are sent to customer areas at different times. Depending on their type (fruits, vegetables, nuts, etc.), these products are damaged and corrupted in the sectors of farms, DCs, and customer areas (such as fruit and vegetable markets), and these corrupted values are

Customers DCs Farms
Recycling depot Compost production Suppliers Biogas Biogas applicants Fig. 1 Scheme of the desired closed-loop agricultural supply chain network collected in inverse flow by the recycling depots. These wastes are sent from the recycling depot to the two sections for making biological fertilizers (compost) and the section for making biogas. The quantities of these shipments, depending on the type of waste materials, if they are not capable of producing biogas, are transferred to the biological fertilizer production department, and in practice, the quantities of these shipments are determined using a percentage coefficient. The corrupted products are transferred to the biogas production department and after the production of gas, this energy is sent to the applicants. Also, during the production of biogas, the obtained wastes are transferred to the production of biological fertilizers, so that after the production of natural fertilizers, these products are transferred to the suppliers of pesticides and agricultural fertilizers. Since various products and materials are needed to produce biogas, some of them can be covered by this proposed chain and the rest can be provided by other wastes of supply chains.
Biogas is a type of fuel gas that is a mixture of 65% methane (CH4) and 35% carbon dioxide (CO2). Biogas is a renewable energy source from agricultural products or animal manure. Biogas is the result of the fermentation process, which means the process of degrading organic matter using micro-organisms is known as anaerobic organisms. This process takes place in special tanks in which materials with heat and enzymes are decomposed in absence of oxygen. Biogas has several advantages: 1. Produces clean fuel. 2. These gases do not emit, so they do not cause pollution.

It is very efficient.
This product has another advantage because it produces scum and the remaining scum is used as biological fertilizer. However, biogas also has disadvantages: 1. Steals land and farms available to farmers to produce crops. 2. The cost of building biogas power plants is sometimes high.
Here, the closed loop mode is quite evident. In the middle part of Fig. 1, part of the recycled materials is delivered to the suppliers of the primary supply chain and part of them leave the primary chain and are transferred to the biogas production centers in the other supply chain. In this issue, it is assumed that initially, there are the number of DCs and recycling depots, and the status of other network facilities, including the reverse logistics sector in the network design process, is determined, and the location of facilities is considered. Decisions regarding the opening and closing of the facility may change during the course.
The problem can have two levels of decision-making. On one level, the main agricultural products are considered by one decision-maker and at the next level, the products of the stage of the reverse logistics will be considered by the second decision-maker. In summary, a bi-level programming model is proposed for the design of the closed-loop agricultural supply chain network (see Fig. 2). In this proposed model, decisions are made regarding the location and allocation of facilities, the amount of material and products flow between facilities in the supply chain, items related to strategies for selecting the type of vehicle, and other items.
Given the extent of the proposed problem and the use of the closed-loop network, strategic issues, and considering several goals in bi-level programming, modeling and problem solving will have their complexities and challenges. Multi-level supply chain network design problems are among the NP-hard problems  and the problem described has different dimensions and complexities. Therefore, solving it in a reasonable time, especially in medium and large sizes, will face problems, and appropriate problem-solving methods must be developed. Depending on the mathematical model and structure of the problem, these solution methods can include nested bi-level meta-heuristic algorithms.

Assumptions
The main assumptions considered in this study are explained in detail above, but some of the other assumptions are as follows: ✓ The main focus of this research is on the development of a mathematical model for the closed loop agricultural supply chain and does not tend to its implementation phase. This research also seeks to optimize the proposed model in which in addition to agricultural products as the main products of the network, to produce two new products include biogas and compost by corrupted products to add value to the network. ✓ Since this network is a supply chain of several products, so the desired products can be different and do not refer only to a specific product. For example, several types of fruits and vegetables can be selected as products. Therefore, the proposed model can be used in various fields of agriculture. ✓ The supply chain network includes suppliers, farms, DCs, customers, and reverse logistics facilities. ✓ Customers' locations are fixed and predefined. ✓ Facility capacity (supply, production, etc.) is limited. ✓ The problem is multi-period and multi-product. ✓ The initial inventory of all DCs in the first period is zero. ✓ The initial inventory is considered for suppliers in the first period. ✓ DCs and recycling depots include both existing and potential locations. ✓ Due to the perishability of products, the corruption rate is considered at three basic levels (farms, DCs, and customers). ✓ The transportation cost of products between network levels is based on the distance between points. It is assumed that several types of vehicles are available with certain capacities and costs. ✓ Only DCs can store the product. ✓ It is not possible to move the processed product between DCs.

Proposed model
This section introduces and describes the proposed mathematical model. For this purpose, first, the items required for modeling such as parameters, indices, and variables are described.

Indices
Index of suppliers f = 1, 2, …, F Index of farms d = 1, 2, …, D Index of existing and potential DCs c = 1, 2, …, C Index of customers r = 1, 2, …, R Index of existing and potential recycling depots i = 1, 2, …, I Index of compost production centers j = 1, 2, …, J Index of biogas centers l = 1, 2, …, L Index of biogas applicants p = 1, 2, …, P Index of agricultural products m = 1, 2, …, M Index of supplied raw materials t = 1, 2, …, T Index of periods v = 1, 2, …, V Index of vehicles Weight assigned to allocate waste products to biogas centers 2 Weight assigned to allocate waste products to compost production centers Coefficient for conversion of waste products to compost fpcap pft Maximum capacity of farm f for producing product p in period t sscap ms Initial supply capacity of supplier s for raw material m dhcap dpt Holding capacity of DC d for product p in period t dem pct Demand of product p by customer c in period t bdem lt Demand of biogas by applicant l in period t capr rt Maximum capacity of recycling depot r for storing products in period t capb jt

Parameters
Maximum capacity of biogas center j for storing products in period t capc it Maximum capacity of compost center i for storing products in period t Coefficient for conversion of waste products to biogas in the liter Percentage of reusable waste product in biogas centers for making compost b Big Production cost of product p in farm f hc dp Inventory holding cost of product p in DC d bc ms Buying cost of raw material m from supplier s prg j Selling price of biogas by biogas center j prc mi Selling price of raw material m by compost center i tcrb rjv Transportation cost of products between recycling depots r and biogas center j by vehicle v tcrv riv Transportation cost of products between recycling depots r and compost center i by vehicle v tcvs isv Transportation cost of products between compost center i and supplier s by vehicle v tcba jlv Transportation cost of products between biogas center j and applicant l by vehicle v tcbv jiv Transportation cost of products between biogas center j and compost center i by vehicle v pcg j Production cost of biogas in biogas center j pcv mi Production cost of raw material m in compost center i ihc ms Inventory holding cost of raw material m in supplier s

QSF msft
Quantity of supplied raw material m by supplier s to farm f in period t

MQF pft
Amount of produced agricultural product p by farm f in period t QFD pfdt Quantity of shipped product p from farm f to DC d in period t QFC pfct Quantity of shipped product p from farm f to customer c in period t QDC pdct Quantity of shipped product p from DC d to customer c in period t QFR pfrt Quantity of shipped waste product p from farm f to recycling depots r in period t QDR pdrt Quantity of shipped waste product p from DC d to recycling depots r in period t QCR pcrt Quantity of shipped waste product p from customer c to recycling depots r in period t QRB rjt Quantity of shipped waste products from recycling depots r to biogas center j in period t

QRV rit
Quantity of shipped waste products from recycling depots r to compost center i in period t

QVS mist
Quantity of shipped compost (material m) from compost center i to supplier s in period t QBA jlt Quantity of shipped biogas (liter) from biogas center j to biogas applicant l in period t QBV jit Quantity of shipped waste products from biogas center j to compost center i in period t X d Equal to 1, if DC d is constructed. Otherwise equal to 0 Y r Equal to 1, if recycling depots r is constructed. Otherwise equal to 0 IH dpt Inventoried product p in DC d at period t

ISS mst
Inventoried capacity of supplier s for raw material m in period t According to the mentioned properties and Fig. 1, two main levels of the designed network due to two expert insights, are exemplified in Fig. 2. Therefore, the proposed model is formulated as follows.

Upper-level model
subject to (2) minimize Z 1 = Shipping costs + Construction costs + Production costs + Buying costs + Holding costs (3) The objective function (2) attempts to minimize total costs of the upper-level consist of shipping costs presented in Eq. (3), construction costs presented in Eq. (4), production costs presented in Eq. (5), inventory holding costs presented in Eq. (6), and buying costs presented in Eq. (7).
Constraint (8) shows that the quantity of supplied raw materials by suppliers to farms in each period should be less than or equal to the requested amount of it by farms. Constraint (9) displays that the quantity of supplied raw materials by suppliers to farms in each period should be less than or equal to the supply capacity of suppliers. Equation (10) implies that the amount of produced agricultural products by farms in each period is related to the amount of supplied raw materials by suppliers. If this amount is less than the requested number of raw materials, it will hurt the production rate of the farms. Besides, if this amount is equal to the requested number of raw materials, it shows the full responsiveness of the demanded materials and the fraction value will be equal to 1. Therefore, the maximum capacity of farms for producing crops is multiplied with some coefficients. Here, (1-φ) shows the impact coefficient of some criteria such as irrigation and weather conditions on farm production, while φ represents the impact coefficient of raw materials (supplied by suppliers) such as fertilizers and pesticides on farm production. Equation (11) illustrates that the total agricultural products in farms minus the wasted amount can be shipped to both the DCs and customers. Restriction (12) indicates that transferring products to a potential DC is subject to its construction. Equation (13) calculates the inventory of products for DCs. This calculation is done in such a way that the inventory of the previous period plus the products received from the farms is equal to the inventory of the current period plus the products transferred from DCs to customers and recycling depots. Constraint (14) ensures that the inventoried products should be less than or equal to the holding capacity of DCs. Constraint (15) ensures that the sum of products shipped from farms and DCs is less than or equal to customers' demand. Constraint (16) counts the number of waste products shipped from farms to recycling depots. Restriction (17) shows that transporting products to a potential recycling depot is subject to its construction. Constraint (18) calculates the number of waste products shipped from DCs to recycling depots. Constraint (19) displays that shipping products to a potential recycling depot are subject to its construction. Constraint (20) computes the number of waste products shipped from customers to recycling depots. Constraint (21) shows that distributing products to a potential recycling depot is subject to its construction. Constraint (22) shows that the summation of received products to each recycling depot should not be exceeded from its maximum capacity. Equation (23) shows the initial inventoried capacity of suppliers for raw materials in the first period. Moreover, the constraints (24) and (25) show the non-negativity decision variables used in upper-level, and constraint (26) represents the binary decision variables.
Besides, the objective function (27) seeks to maximize total profits of the lower-level using subtraction of incomes from the costs. To this end, Eq. (28) calculates the total income by selling manufactured biogas and compost to its applicants and suppliers. Equation (29) also calculates the total costs of lower-level consist of shipping costs between stages and production costs of biogas and compost.
(39) QRB rjt , QRV rit , QVS mist , QBA jlt , QBV jit , ISS mst ≥ 0 ∀ all sets Constraints (30) and (32) divide the waste products received in recycling depots between biogas and compost production centers, respectively. This work done using two weighting factors which consist of ω 1 and ω 2 whose sum is equal to 1. These two weighting factors are obtained by experts' opinions. Constraint (31) shows that the summation of received products to each biogas center should not be exceeded from its maximum capacity. Also, constraint (33) shows that the summation of received products to each compost center should not be exceeded from its maximum capacity. Equation (34) shows the quantity of manufactured compost in compost centers that can be moved to suppliers. In this equality, the number of received waste products from recycling depots and biogas centers are mixed and using some procedure, the compost can be obtained. Therefore, these mixed waste products are multiplied by a conversion coefficient (conversion of waste products to compost), and the final amount of moved compost to suppliers is calculated.
Also, Eq. (35) calculates the inventoried capacity of suppliers for raw materials. To this end, inventory of the previous period plus the materials received from the compost centers and other sections is equal to the inventory of the current period plus the materials transferred from suppliers to farms. Besides, based on (Amirkhani et al., 2014), we know that compounds such as 50% water, 10% animal or human feces, and 40% rotten crops are needed to make biogas. Based on this research, 2 kg rotten crops by mixing other needed components (2.5 kg water and 0.5 kg feces) can release 1500-L biogas in 60 days, so 2 × (1500/60) = 50-L biogas release per day. Based on mentioned properties, δ = (1500/60) and in Eq. (36), this conversion coefficient is multiplied by waste products to calculate the amount of shipped biogas in liter to applicants. Constraint (37) shows that the summation of shipped biogas to applicants should not be exceeded by their demand. Equation (38) finds the number of waste products in biogas centers that can be reusable for making composts and transfers them to compost centers. Besides, the constraint (39) shows the nonnegativity decision variables used in the follower level.

Solution method
This sector describes the suggested solution methods to solve the mentioned problem. To this end, first, the encoding and decoding process is presented and then some meta-heuristic algorithms such as Genetic Algorithm (GA) and Stochastic Fractal Search (SFS) are provided. The reasons for using the meta-heuristic algorithms are the nonlinear nature of the problem and the NP-hardness of the bi-level programming (Talbi, 2013). This information is existing in the following subsectors.

Encoding and decoding
One of the most important phases in using meta-heuristic algorithms is to describe the encoding-decoding process. There are different ways to encode a problem chromosome, each for a specific problem. Since the mechanism of operation of most algorithms is performed in a continuous environment, and also our problem requires sequencing for assignment to perform, so we use the priority-based encoding approach (Gen et al., 2006). We encourage the readers to follow (Lotfi & Tavakkoli-Moghaddam, 2013) for more information. So first we fill the genes of the chromosome with random numbers between (0, 1) and then we sort them according to priority and the position of each of which are integers and are selected as allocation sequence (see Figs. 3 and 4). For example, if the chromosome with random numbers is {0.2, 0.1, 0.4, 0.8, 0.3, 0.9, 0.5}, then the allocation sequence by sorting it is equal to {6, 7, 4, 2, 5, 1, 3}. On the other hand, after encoding the problem and applying the algorithm operators to the problem chromosome, we need to calculate the variables and objective functions. Therefore, we need decoding procedures to convert the encoded problems to answers. To this end, the general form of these procedures is illustrated in Figs. 5 and 6. Figure 5 shows the allocation procedure without inventory for some sectors of chromosomes that not included inventory. Also, Fig. 6 shows the allocation procedure considering inventory for some sectors of chromosomes that included inventory. Moreover, it should be noted that the binary variable related to the opening facilities is shown in Fig. 5. This step may only apply to specific sectors of chromosomes such as sector two and sector four.

Genetic algorithm (GA)
This algorithm is proposed by John Holland (1975) and inspired by the genetic behavior of living organisms that can improve their physical condition through genetic mutations and inheritance from their parents. To this end, some random population is generated, and using two main operators (mutation and crossover), it seeks to improve the chromosome status and subsequently the state of the fitness function (Sang, 2021). Since the advent of this algorithm, various versions of it have been developed and it has also been effective in solving multi-level problems (Ma, 2016;Talbi, 2013). This algorithm is known as a model for various metaheuristic algorithms and in used in wide field of studies as a strong one such as in a joint order batching and picker routing problem (Yousefi Nejad Attari et al., 2021), location-inventory supply chain (Fathi et al., 2021), green supply chain (Gholizadeh & Fazlollahtabar, 2020), and others. Therefore, it is considered a strong and well-known algorithm in solving problems in this field, and we also use it to solve our proposed problem. It should be noted that all the algorithms used in this research are nested and among the main algorithm to calculate the high level, another lower-level algorithm is used. The pseudocode of nested bi-level GA is illustrated in Fig. 7.
Because the chromosome of this problem is filled with random numbers between (0, 1) and then an allocation sequence is obtained from the sort operator (using the gen's priority), so all the chromosomes will be feasible. Besides, according to (Demirel et al., 2014;Maghsoudlou et al., 2016;Rostami et al., 2020), single-point and double-point crossovers along with swap, displacement, insertion, and reversion mutations operators were used. These operators are performed on random number vectors to avoid the creation of decimal numbers in the allocation sequence.

Stochastic fractal search (SFS)
This algorithm is inspired by the natural phenomena of growth and created using a mathematical concept called fractal. This algorithm was first presented by (Salimi, 2015). Like most algorithms, it is population-based and starts with a randomly generated initial population (Khalilpourazari et al., 2020). Due to a large number of formulas and concepts about this algorithm, readers are advised to refer to the mentioned source. In the following, the pseudo-code of this algorithm is presented (Fig. 8). Because the chromosome of this problem is filled with random numbers between (0, 1) and then an allocation sequence is obtained from the sort operator (using the gen's priority), so all the chromosomes will be feasible. Besides, all operators are performed on random number vectors to avoid the creation of decimal numbers in the allocation sequence.

Hybrid metaheuristics
Moreover, two hybrid metaheuristics based on SFS and GA are used to search for more appropriate answers. To this end, GA-SFS and SFS-GA are used that for example in GA-SFS, the genetic algorithm works on upper-level and stochastic fractal search works on lower-level. The opposite case is also established for SFS-GA. Since the descriptions for each algorithm are described separately, we will refrain from further explanations about these hybrid algorithms. It is important to note that here each algorithm (GA or SFS) is used only for a specific level and the other level uses a different algorithm.

Example
This section reports some generated examples to verify model performance and also adjusts the values of algorithm parameters. More information is presented in the following subsections.

Parameter setting
In this section, some numerical examples are generated randomly to set proposed model parameters. These generated examples are illustrated in Table 4, and also the values of periods and vehicles are fixed by 6 and 5, respectively, for all generated examples. It is necessary to consider several agricultural products, for example, several types of fruits and several types of raw materials supplied by suppliers, including pesticides, chemical fertilizers, and biological fertilizers. Moreover, according to experts in this field, values of 0.6 and 0.4 were adopted for ω 1 and ω 2 , respectively. Finally, values of other parameters are reported in Table 5. Due to the lack of available information and momentary changes in the country under study, it is difficult to accurately state these values. Therefore, these numbers are close to the real world and the desired values can be changed for specific geographical areas.

Tuning parameters of algorithms
In this section, to calibrate the parameters of the applied algorithms, we have used the Taguchi method (Taguchi, 1986), which is one of the well-known methods in the design of experiments. According to the detailed information mentioned in the reference, this method uses some measures to reduce the number of experiments, therefore, we use a few experiment numbers instead of full factorial experiments. The important thing is that this method is only applicable to one objective function. Therefore, for single-objective mathematical models, it is sufficient to replace the value of the objective function of the model. Therefore, for multi-objective mathematical problems, a single value for the Taguchi method must be obtained using several types of standard multi-objective metrics. But this is a bi-level example, so according to (Kuo et al.,  To this end, it is initially desirable to report the values of the parameters of the used algorithms for different considered levels. These values are reached based on (Golshahi-Roudbaneh et al., 2017;Rahmati et al., 2013;Sarrafha et al., 2015) and illustrated in Table 6.
After setting the various levels of the algorithm parameters, it is time to run the Taguchi method using the Minitab software. After executing this method in the mentioned software, the orthogonal array L9 is selected for both algorithms. Moreover, after solving each algorithm during 30 executions, the average answer for each experiment is stored in the software. The orthogonal arrays along with resulted values of Z 1 for GA and SFS are reported in Tables 7 and 8, respectively. As a result, using the analysis of these results by the Taguchi method, the selected values of the parameters are obtained by a tool called SN diagram. Therefore, the main effects plot of SN ratios for GA and SFS are illustrated in Figs. 9 and 10, respectively. Based on Fig. 9, it can be stated that values of 0.9, 0.1, 100, and 200 are selected for Pc, Pm, N-pop, and Max iteration, respectively. Also based on Fig. 10, it can be stated that values of 1, 150, and 300 are selected for MDN, N-pop, and Max iteration, respectively. These adjusted values are also applied for the two-hybrid algorithms.    . 9 The main effects plot for SN ratios of GA Fig. 10 The main effects plot for SN ratios of SFS 6 Results and discussion

Computational results
Finally, after setting the model parameters and adjusting the parameters of the algorithms, in this section, we will solve the generated examples. It should be noted that the examples are designed in small, medium, and large dimensions to further evaluate the performance of the algorithms. Also, to encode the algorithms, MATLAB software has been used and all the results have been executed under a personal computer with Windows 10 and a Core i5 CPU processor and 4 GB of RAM. To evaluate the performance of the algorithms, criteria such as the best value of the objective functions, the worst value of the objective functions, the mean of the objective functions, the CPU time, and normalized deviations (ND) have been used. The related formula to calculate ND is presented in Eq. (40).
After executing each example using the proposed algorithms and extracting the values of mentioned criteria, we compare and analyze the results. These results are presented in Table 9 and the best value for each criterion is bolded in each example.
To analyze the results of Table 9, some diagrams are used. For example, the comparison diagram of algorithms in terms of CPU time is presented in Fig. 11. Based on this figure, the SFS-SFS has the minimum execution time for all examples. Therefore, this algorithm is the best in terms of CPU time.
Also, from the perspective of the upper-level objective function, Fig. 12 illustrates these comparisons. Since this aim is minimization type, so the algorithm with the lowest value will be selected. As it turns out, SFS-GA has the best record in examples 1, 2, 3, 5, 6, 8, 10 and 12. The SFS-SFS has also gotten the best value in examples 4, 7, and 9.
Moreover, Fig. 13 shows the assessment of algorithms in terms of the lower-level objective function. Since this objective function is a maximization type, so the algorithm with the highest value will be chosen. As is clear SFS-GA having the best performance in examples 1,4,5,6,8,9,10 and 12, while SFS-SFS has gotten the best value in examples 2, 7 and 11. Also, GA-SFS had the best performance in example 3.
Furthermore, the normalized deviation is applied to review these results as shown in Fig. 14. This figure implies that the smallest deviations in almost all examples belong to SFS-GA.
After analyzing the results, we conclude that in some criteria, SFS-GA obtained better results and in others, SFS-SFS showed better performance. Therefore, to summarize, we must use a method that specifies only one algorithm for us as the best method. For this purpose, the displaced ideal solution (DIS) method (Pasandideh et al., 2015) has been used, the general structure of this method is summarized in Eqs. (41) and (42). In the mentioned method, in the first step, the value of F i is obtained by averaging resulted values of twelve generated examples for each criterion, and then, the value of F i * is determined using the lowest values for the criteria of the upper-level objective function and the highest values for the factors related to the lower-level objective function. The minimum amounts for ND and CPU time are also chosen. Finally, the values of F i and F i * are reported in Table 10.
Finally, we normalize the values of Table 10 using formula (41) and by summing the normal values, the direct distance for each method is calculated. It should be noted that the direct distance is calculated using formula (42) and the lower the direct distance value, the more desirable the answers of the mentioned algorithm than other algorithms. The normalized values and direct distances are presented in Table 11. Finally, using the results of this method, we find that the proposed hybrid algorithm SFS-GA was selected as the best method to solve twelve generated examples among four proposed algorithms. This algorithm is selected because it has the least distance (0.047) from the ideal point. On the other hand, the SFS-SFS was selected as the second-best algorithm with a direct distance of 4.3665. It should be noted that the SFS-SFS especially in large size examples showed great in solving problems.  The results show that by using these analyses, better management in the real-world supply chain can be achieved and good results can be achieved in a reasonable time by using the proposed solution method. Therefore, by using these results, agricultural products can be allocated with proper planning, and also waste products can be used to make two new products that prevent both environmental pollution and produce clean fuel and useful biological fertilizers.

Sensitivity analysis
To further assess and analyze the performance of the suggested model in this section, sensitivity analysis is performed on some sensitive parameters of the model. The results are presented in Table 12. It should be noted that all these calculations were performed only for the first numerical example and the results were reported only for SFS-GA, which was selected as the best algorithm. To this end, five parameters that consist of product demand, biogas demand, farm capacity, ω 1 , and ω 2 are chosen to change.
Using the analysis of the results of this table, it can be seen that changes in five parameters that consist of product demand, biogas demand, farm capacity, ω 1 , and ω 2 cause changes in the number of objective functions as well as opened facilities. For instance, an increase in product demand can increase the total cost of the upper-level and slightly increase the objective function of the lower-level, which is a small increase due to the increase in the number of rotten products sent to the lower-level. On the other hand, increasing biogas demand only increases the lower level objective function. As well as increasing product demand and production capacity can also be opened additional facilities for storage. In addition, different changes are depicted for the two parameters ω 1 and ω 2 , which according to experts' opinions, the best value of 0.6 and 0.4 was selected for parameters ω 1 and ω 2 , respectively. What is important is the use of these analyses to improve the status of the systems in question by managers and experts in the field.

Conclusion
Globalization and liberalization of trade in agricultural and food products have changed the structure of markets. Conventional traditional supply-based marketing systems for agricultural and food products have given way to coordinated and market-based supply chains. To succeed in meeting these challenges, it is necessary for businesses affiliated with the agricultural sector to apply the supply chain management approach in the process of converting inputs into inputs to deliver products to the market or end-users. On the other hand, issues related to rotten agricultural products have occupied the minds and attention of many systems. To this end, in this research, an eight-echelon agricultural supply chain was designed by seeing suppliers, farms, distributors, customers, recycling depots, biological fertilizers centers, biogas centers, and biogas applicants. Then, a mathematical model based on bi-level programming was formulated. The purpose of the upper-level of this proposed model was to minimize the total costs of the leader level, while the lower-level was to maximize the total profit achieved by the difference between the sales of follower level products and the total costs of this level. Since such problems had computational complexity, two meta-heuristic algorithms along with two hybrid algorithms were used to solve the proposed problem. Also, several numerical examples in different dimensions were generated to further explore the performance of these algorithms. On the other hand, to achieve the best performance of these algorithms, their parameters were first calibrated using the Taguchi method. Finally, the results were reported and showed the superiority of SFS-GA over other methods. Also, sensitivity analysis was executed on some parameters of the model, and using the results, several insights were reported. These gotten outcomes can be beneficial for agricultural managers and organizations. Like other research, this research has its limitations. For example, the values of the parameters, constraints, and conditions included in this model are related to the specific geographical location under study and may change in other areas. Therefore, the results obtained in this research for implementation in other areas and geographical areas should be reviewed. Another limitation is the high inflation and uncertainty in this geographical location, which causes the values of cost-related parameters to vary. As a final point, several guidelines for future studies are delivered as follow. Applying uncertainty in modeling problems such as robust programming, fuzzy sets, or stochastic programming can be useful and contribute to the complexity of the model and its proximity to the real world. Utilizing new metaheuristic and heuristic algorithms can lead to better answers and even reduce problem solving time. Considering green and sustainability aspects in modeling and integrating this SCM with other SCM can also be studied.
Funding None.