1. Introduction
The production of agave-based liquor holds substantial economic significance both domestically and internationally. In 2020, Mexico exported approximately 308.6 million litres of tequila, indicating that eight out of every ten litres produced were consumed abroad. The United States was the primary export destination, importing 277.8 million litres—accounting for 90% of total exports. According to official data [
1], the export value reached USD 2.355 billion, positioning agave liquor as Mexico’s second most important agro-industrial product, surpassed only by beer.
The agave production sector involves approximately 9000 producers and generates around 29,000 direct and indirect jobs. The Tequila Regulatory Council [
2] reported that in January 2010, 97,200 tonnes of agave were processed for tequila production. There are currently 625 registered distilleries and 80 bottling plants, with a continued increase in legally registered brands [
3]. In 2020, national agave production reached 1.519 million tonnes, generating a market value of MXN 31.339 billion [
4].
Production losses, or shrinkage, are a common and multifaceted phenomenon in manufacturing enterprises. These losses adversely affect operational efficiency, increase costs, and undermine the sustainability of operations. As noted by Moreno [
5], shrinkage encompasses losses incurred during manufacturing processes, including raw material waste, defective products, and inefficiencies within the supply chain.
According to [
6], production shrinkage typically refers to the loss of raw materials, products, or components during production, storage, transportation, and distribution. These losses significantly impact various operational aspects, particularly by increasing production costs due to the need for additional materials to meet production targets [
7].
Human error is a critical contributor to production losses, often resulting from incorrect actions or decisions made by personnel. As highlighted by Torres Medina [
8], such errors can severely affect operational efficiency and product quality. These errors may occur at various stages of the production process, including operational mistakes due to improper machine configuration. In the context of agave liquor production, this may involve poor calibration, leading to underfilling or inconsistent machine speeds [
9].
Mechanical failures also contribute to production inefficiencies. These failures, as described by [
10], include mechanical and technological malfunctions that disrupt production and reduce performance and efficiency, and may even cause complete production stoppages. Common causes include wear and tear from continuous use and component breakage due to overload or material fatigue.
In a related study, Cortés Mora [
11] demonstrated the application of artificial neural networks (ANNs) and artificial intelligence (AI) for identifying bottled beverages using digital image recognition [
12]. The implementation of these tools is within the principles of sustainable production. This approach, which involves training models to detect patterns, could be adapted to monitor each stage of the bottling process—such as conveyors, fillers, cappers, and labelers—thereby enhancing system control and quality assurance in agave liquor production.
2. Problem Statement
The alcoholic beverage industry is characterized by a complex production process encompassing multiple stages, from fermentation and distillation to bottling and distribution [
13]. At each stage, production losses or shrinkage represent a significant challenge, affecting both the operational efficiency and economic sustainability of organizations and making the process sustainable. Food and beverage manufacturers are forced to control product quality. The release of defective products onto the market can lead to complaints or product returns [
14]. In the case of the company, fines of up to MXN 18,000 pesos per defective product can be imposed.
Additional losses can occur during storage and transportation due to improper handling or poor storage conditions [
15]. Reducing these losses is essential to improving a company’s profitability. A well-designed strategy can lead to resource optimization, improving the efficient use of raw materials and operating inputs.
Quality improvement is also a key objective. Controlled and efficient processes ensure that production time is not wasted and that resource management is optimized throughout the operation [
16].
This study presents data collected from a company engaged in the production and bottling of alcoholic beverages. The objective is to predict the amount of material that will be wasted throughout the production process. The analysis considers potential machinery failures—specifically, conveyors, fillers, cappers, labelers, and tax label applicators—as well as human error resulting from inadequate supervision or improper handling by operators.
The amount of wasted material is calculated by quality control specialists assigned to each production line, with oversight and validation by line supervisors.
3. Methodology
The development of the predictive system began with the collection of historical data related to the agave liquor production process. This dataset included information from production plans and records of material losses (shrinkage) at each stage of the bottling process. Once compiled, the data were analyzed to identify behavioral patterns and correlations between process variables and observed losses. This analysis enabled a comprehensive understanding of the operational characteristics of the packaging system.
A detailed description of each stage in the production process was conducted, and critical control points—locations where defects most frequently occur—were documented. An artificial neural network (ANN) model was then implemented to predict losses, using the historical data for training purposes. The ANN was designed to learn from the operational conditions and performance metrics of the production lines.
To address the inherent uncertainty and subjectivity in determining which stages are most susceptible to waste, fuzzy logic was integrated into the system. This approach allows for the translation of qualitative assessments (e.g., “high,” “medium,” “low” efficiency) into quantitative values, thereby enhancing the precision of the model. The combined use of ANNs and fuzzy logic facilitates the optimization of operational efficiency, reduction of material losses, and promotion of sustainable practices within the agave liquor industry.
4. Process Description
The production process of the alcoholic beverage manufacturing and bottling company (
Figure 1) commences upon receipt of a formal request from the corporate headquarters to produce a specified quantity of product cases. These cases encompass a variety of consumer beverages, including, but not limited to, agave liquor, whisky, and vodka, each corresponding to distinct production lines. The total production volume must be fulfilled by the predetermined deadline to ensure compliance with contractual obligations. Failure to meet these production targets may result in substantial financial penalties, as the clientele primarily comprises large multinational corporations that procure these products under strict delivery agreements.
The supply chain process is initiated by requesting the appropriate quantity of raw materials required for production. These materials include bottles, caps, labels (front, top, and back), tax stamps issued by the Mexican Tax Administration Service (SAT), and packaging boxes. Upon arrival at the facility, the Quality Control Department conducts a thorough inspection of the materials, employing sampling techniques to ensure that all items meet the necessary standards for operational use. Should any discrepancies or deficiencies be identified, a formal report is issued detailing the observed non-conformities and the specific characteristics of the materials received. This documentation is managed within the receiving area of the warehouse department.
Once the liquor production is complete, the process advances to the bottling stage along the designated production lines. This begins with the transfer of the required raw materials from the warehouse to the corresponding production line, where they will be utilized in the manufacturing process. Once the materials are positioned and ready at the production line, operations commence.
The production phase initiates with the conveyor system, which facilitates the collection and movement of individual bottles along each production line. Each line operates at a specific speed, determined by the capacity and configuration of the machinery in use. The process continues to the filling station, where bottles are filled with the beverage according to the production plan established by the Plant Manager, Deputy Manager, and Department Heads, ensuring alignment with client specifications and delivery schedules.
Following the filling stage, the capping unit secures each bottle with the appropriate closure, which varies depending on the bottle design, beverage type, and product presentation. Once capped and verified for quality, the bottles proceed to the labeling station, where front, top, and back labels are applied, contingent on the product’s presentation requirements.
The final and most legally sensitive stage is the application of the tax stamp label, known as the “marbete.” This step is critical, as any failure in its execution constitutes a violation of the Mexican Federal Fiscal Code, specifically Article 82, Section XVIII. Such non-compliance may result in significant financial penalties for each improperly labeled product offered for sale through commercial distributors. The responsibility for these penalties lies with the manufacturing company.
Upon successful inspection by the Quality Control team for finished goods, the packaging process begins. This involves grouping the finished bottles into cases of twelve for efficient handling, transport, and storage. These cases are then palletized and secured by the warehouse department in preparation for shipment to the Distribution Centre (CEDIS), which is responsible for dispatching the products to their respective clients.
5. Development of the ANN-Based System
Neural Tools can be employed to predict uncertain parameters within a system. Specifically, it enables the estimation and interpretation of a target variable based on the input of numerical variables that have been previously trained and validated, thereby generating predictive outputs. A dataset comprising 3125 records was compiled from three production lines operating across two shifts, Monday through Saturday, with only one shift on Saturdays. This dataset spans from Week 1 to Week 21 of the year 2024.
Additionally, a consolidated dataset of 4577 records was obtained, capturing data related to production losses (merma) across various stages of the bottling process, including the conveyor, filler, capper, labeler, and tax stamp labeler.
The core objective of this study is to predict the quantity of production loss per shift, based on the operational conditions of the machinery during each shift. This is achieved through the analysis of historical data to evaluate how loss values are influenced at each stage of the bottling process.
Table 1 presents the production plan alongside the actual production outcomes.
Table 2 presents the historical data on the percentage of production loss (merma) recorded at each stage of the bottling process. It is important to note that the organization has established a critical threshold, stipulating that losses must not exceed 1% at any stage of the bottling operation. As illustrated in the accompanying table, the recorded values surpass this predefined limit, indicating deviations from the operational efficiency targets.
For data collection and preprocessing, the dataset was partitioned into three subsets: 70% for training the model, 20% for validation to fine-tune the parameters, and 10% for testing to evaluate final model performance. The data was divided into training sets in a strictly chronological order, ensuring that there was no information leakage and that the model evaluation reflected the actual behavior of production dynamics. These data were organized as illustrated in
Figure 2 (worker A) and
Figure 3 (worker B), which represents the training process for Production Line One. This figure also displays the relative impact of each variable involved in the production process, following the removal of outliers attributed to uncontrollable operational factors.
Prior to training, the data were subjected to a min–max scaled normalization process, allowing comparability between the input variables to be maintained and preventing magnitude differences from disproportionately affecting the model. To facilitate the interpretation and evaluation of results, standard error metrics were included, allowing the performance of the artificial neural network to be compared against a baseline and clearly quantifying the improvement achieved, the result is shown in
Table 3.
Subsequently, we can observe the training and testing datasets were employed to generate predictive outputs using the Scaled Conjugate Gradient (SCG) method in
Table 4, which has been widely recognized in the literature as one of the most efficient and suitable algorithms when implemented with the relevant statistical formulas that allow us to obtain predictive data used in the productive management of the organization.
To define the model’s design and architecture, a structure was established comprising six input variables: shift, conveyor, filler, capper, labeler, and tax stamp labeler. Based on this configuration, a single output neuron was defined to predict the volume of production loss (in litres) for both shifts.
6. Packaging Line Analysis and Loss Prediction
As shown in
Table 5, following the corresponding analyses conducted using Neural Tools, the following projections can be made: For the upcoming semester, an estimated total output of 4,856,868 bottles is anticipated. Of this total, approximately 813,815 units are expected to be lost as waste. Specifically, Shift 1 is projected to account for 47.62% of the total loss, equivalent to 387,517 defective units, while Shift 2 is expected to contribute the remaining 52.38%, corresponding to 426,299 units.
These results highlight the capper and filler as the most critical points of loss in both shifts, suggesting that targeted interventions in these stages could yield substantial improvements in efficiency and waste reduction.
These results highlight the capping and filling machines as the most critical loss points in both shifts. However, it should be noted that the conveyor and labeling machines are in second and third place, respectively, suggesting that specific interventions in these stages could produce substantial improvements in efficiency and waste reduction, since they are final stages, and, therefore, more raw material would be wasted than expected.
The distillery operates an anaerobic EGSB biodigester with a working volume of 3.5 m3, which is used to produce methane biogas. This biogas is then utilized to generate electricity via an electric generator. The electricity produced is used to power lighting systems across various areas of the facility. However, a key limitation of this electricity generation system is the inability to store the generated electricity, as doing so would incur prohibitively high costs—such as those associated with lithium battery banks.
To address this issue, the present project developed an artificial intelligence-based system for a liquor company, aimed at minimizing the discrepancy between the electricity demand of the facility’s lighting systems and the electricity generated from methane biogas derived from the distillery’s own waste. To store the biogas, a cushion-based storage system was designed and implemented, capable of holding up to 400 L of biogas, as shown in
Figure 4.
To measure biogas production from the EGSB reactor, a Cole–Parmer mass flow meter was installed. Additional work was carried out to manage the biogas produced by the reactor, including the modification of a conventional 500 L stationary LP gas tank for use with biogas at a pressure of 120 psi. This adaptation enabled the storage of up to 13,000 L of biogas, which is used to power a 12 kVA electric generator, providing approximately 3.8 h of operation per tank. The system includes a check valve at the biogas inlet, a pressure gauge at the outlet, a pressure regulator with a gauge, and a pressure switch to control the biogas compressor motor. A MOPESA-brand moisture filter and a liquid trap were also installed to ensure that the compressed biogas stored in the 500 L tank could be used directly by the 12 kVA generator, which outputs a 120 V, 60 Hz signal.
The electricity generated by the 12 kVA generator is fed into a central distribution bus that supplies power to the lighting systems throughout the facility. In this configuration, the generator acts as the agent. There is no feedback loop between the generator, the distribution bus, or the lighting systems. The only information available to the agent is the electricity demand requested by the distribution bus. The agent’s objective is to determine the optimal electricity production order size to minimize the total inventory level of generated electricity within the facility’s supply chain. Electricity demand data for the facility’s lighting systems exhibit two distinct behavioral patterns, depending on the time of day—daytime versus nighttime—as well as weather conditions (sunny versus cloudy). The parameters for the normal distribution are N(5,1), while those for the uniform distribution are U(0,10). The agent’s action space ranges from 0 to 10 units. Experiments were conducted using both distributions to evaluate the model’s robustness.
All experiments in this study employed the same hyperparameter settings to ensure valid comparisons (
Table 1). The neural network architecture consists of three layers with 128, 64, and 32 neurons, respectively. Each method was trained over 40,000 episodes. An ε-greedy strategy was used to balance exploration and exploitation. This strategy allows the agent to explore the environment before committing to an exploitation strategy. Through this iterative process, the agent refines its environmental model and gradually converges toward an optimal value function. The maximum epsilon value, ε
max = 1, decreases linearly to its minimum value, ε
min = 0.1, over the first 10,000 training episodes. The initial hyperparameter values (
Table 4) were proposed in [
17,
18]. Initially, the learning rate was set at 0.00025 and the discount factor at 0.99. However, these settings did not allow the algorithm to converge. A discount factor of 0.99 prioritizes future rewards, which is not appropriate for an infinite-horizon problem such as this. Moreover, when there is a delay between action and environmental response, a high learning rate can disrupt the learning process. The initial neural network configuration included a single hidden layer with 10 neurons as shown in the
Table 6.
The results of the Deep Q-Network (DQN) method with experience replay are illustrated in
Figure 2 In this figure, the outcomes under the normal distribution are represented by a blue line, while those under the uniform distribution are depicted in red. The average cost is notably higher under the uniform distribution compared to the normal distribution. Nevertheless, the agent’s actions (i.e., the electricity generator’s decisions) were consistent across both demand distribution types. It is important to highlight that, due to the inherent variability of the uniform distribution, electricity storage costs increase due to the variability in the lighting system’s electricity demand across the facility, resulting in a negative average inventory level. The behavior of the state variables throughout the training process is depicted in
Figure 5a–d.
Under the uniform distribution, the electricity-generating agent learned a policy of maintaining zero inventory to minimize total cost, preferring to avoid electricity storage due to the high uncertainty in demand. Conversely, under the normal distribution, the agent adopted a policy of maintaining a minimal inventory level to reduce storage costs, as the demand pattern is more predictable. In the normal distribution scenario, total cost is primarily driven by storage costs, whereas in the uniform distribution scenario, the main cost arises from electricity shortages, necessitating purchases from the Federal Electricity Commission (CFE).
7. Development of the Fuzzy Logic System
To develop the fuzzy logic system, both the operational experience and the organizational need to maintain strict control over elevated waste percentages were taken into account. Based on practical knowledge, minimizing material waste is essential and depends on several stages within the production process. Accordingly, the following variables were defined:
Organizational waste parameters were established to monitor and control losses at each stage, across all production lines and shifts. These were categorized as follows:
- (a)
Excellent: Waste range from 0.00% to 1.00%
- (b)
Acceptable: Waste range from 1.1% to 3.00%
- (c)
Poor: Waste range from 3.1% to 6.00%
These classifications apply uniformly across all stages of the production process, forming a single categorization framework. That is, the percentage of waste is assessed independently at each stage, with the optimal performance level defined as a waste rate between 0% and 1%.
The following section presents the fuzzy sets corresponding to each of the variables considered in this analysis. All variables are interrelated due to their sequential role in the production process.
As illustrated in
Figure 6, the company operates with minimal tolerance regarding raw material waste. The organizational objective is to maintain waste levels below 1.00% at each stage of the bottling process. Should waste exceed 1.1%, the performance is classified as either regular or poor, depending on the extent of the deviation by production line and shift. In cases where waste surpasses 3.00%—whether due to mechanical failure, raw material defects, or human error—it becomes mandatory to halt the production line to prevent further escalation and to determine the appropriate corrective action.
For the cumulative results of the first semester, a potential scenario was modeled using fuzzy logic. The input variables correspond to the waste percentages recorded at each stage of the production process. The system exhibits a trapezoidal behavior, with the output variable representing the total accumulated waste.
If any of the stages—conveyor, filler, capper, labeler, or tax stamp labeler—maintain a waste level within the range of 0% to 3%, the production process continues uninterrupted. However, if any of these stages exceed the 3% waste threshold, the process must be halted immediately.
The decision rules were established based on expert knowledge and were implemented within the model illustrated in
Figure 7 Only a subset of the constraints used in the fuzzy logic system is shown; inference calculations are then performed mathematically.
As the inference rules demonstrate, at any point in the production process, if a stage reaches a “Poor” rating (quantitatively defined as a scrap level greater than 3%), the system must be shut down. At that point, a diagnostic analysis must be performed to identify the root cause of the failure, whether a mechanical malfunction, an inconsistency in the raw material, or human error. The development of this system has significantly reduced the subjectivity previously associated with the variable behaviors observed in different production processes. The Mamdani fuzzy system selection process for system modeling is shown below. For defuzzification, the centroid method was used thanks to the established data and parameters that are not controllable in some operational situations.
8. Results
Through the application of artificial neural networks, it was possible to generate forecasts regarding the expected volume of production loss for the second half of the operational year as shown in
Table 7. This predictive modeling was based on the following parameters:
Input variables: shift, conveyor, filler, capper, labeler, and tax stamp labeler.
Output variable: total quantity of production loss.
Using fuzzy logic, the primary input variables influencing production loss in the bottling process were identified. Based on the recommendations generated by the fuzzy system, adjustments to machine calibration—particularly for the labeling and filling machines—were proposed.
The objective is to reduce production loss by approximately 8% to 12%, thereby enhancing process efficiency and lowering operational costs. The estimated failure rates for Shift 1 (
Table 8) and Shift 2 (
Table 9) are presented below according to the areas of the production process.
The estimated failure rates for Shift 1 are as follows:
The estimated failure rates for Shift 2 are as follows:
This artificial intelligence tool enabled more accurate prediction—and, where applicable, reduction—of losses in the agave liquor bottling system compared to traditional methods. The analysis further suggests that the root cause of the issue may lie in the raw materials used, specifically the type of bottle employed in the process.
9. Discussion
In the context of minimizing production losses in the liquor industry, various strategies have been proposed, including modifications to packaging materials and adjustments to filling parameters. As supported by studies [
19,
20], production losses may occur at multiple stages of the process, adversely affecting operational efficiency and increasing costs. However, the present study identified that the stages most strongly associated with waste generation are those involving the handling of bottles.
As noted by [
21], human error does not necessarily imply operator incompetence, but may instead result from improper machine calibration. Citing [
22], preventive maintenance significantly reduces product losses, with machinery efficiency being a key factor in minimizing waste—unlike corrective maintenance, which is the prevailing approach in the organization under study.
In [
23], a hybrid system combining artificial neural networks (ANNs) and fuzzy logic was implemented to monitor and adjust solvent concentrations during beer fermentation, thereby improving the quality of the liquid product. The present project complements that research by applying the same artificial intelligence tools during the second stage of the production process—bottling.
The optimization of industrial control systems through the integration of fuzzy logic and genetic algorithms, as demonstrated in [
24], has proven effective in enhancing process efficiency and stability. However, that study did not address the critical role of the bottling process. Given the operational demands and the importance of this stage, it is essential to define performance thresholds to optimize production. This aligns with the findings of [
25], which emphasize the importance of machine-level analysis using neural networks. Such an approach provides a foundational framework for the agave liquor bottling process, which involves five machines. Once the process is stabilized, it becomes possible to establish control values and performance ranges.
Quality control inspections are fundamental to minimizing losses and waste resulting from defective raw materials. As expressed in [
26,
27], improving the raw material intake process significantly enhances the ability to control waste during handling and processing, thereby contributing to overall production efficiency.
10. Conclusions
This article provides valuable insight into how each stage of the bottling process contributes to product loss. In comparison with previous studies, it is evident that while historical data analysis is beneficial, the integration of advanced techniques—such as machine learning, preventive maintenance, and quality control—can significantly enhance the accuracy of predictions and the overall efficiency of the process.
The present study demonstrated the effectiveness of employing artificial neural networks and fuzzy logic for the analysis and prediction of production losses in an agave liquor bottling system. Through the collection and processing of operational data, it was possible to model loss behavior within the process, identifying key patterns—particularly the increase in waste associated with bottle handling and labeling operations.
The results indicate that the combination of these two artificial intelligence techniques enables accurate forecasting and supports a proactive approach to optimizing the bottling system. Implementing these models will contribute to waste reduction by identifying the most critical stages of the process, thereby allowing for the establishment of preventive measures. Reusable components such as caps, bottles, and liquid can be recovered, enhancing operational efficiency, and promoting greater sustainability in production.
Future research may focus on the integration of additional machine learning techniques, as well as the real-time optimization of bottling parameters, to further minimize losses and improve process profitability, thereby improving the quality of the liquid product. The present project complements that research by applying the same artificial intelligence tools during the second stage of the production process—bottling.
However, that study did not address the critical role of the bottling process. Given the operational demands and the importance of this stage, it is essential to define performance thresholds to optimize production. This aligns with the findings of [
22], which emphasize the importance of machine-level analysis using neural networks. Such an approach provides a foundational framework for the agave liquor bottling process, which involves five machines. Once the process is stabilized, it becomes possible to establish control values and performance ranges.
Quality control inspections are fundamental to minimizing losses and waste resulting from defective raw materials. The study’s limitations lay in the way it collected information, as the company lacks real-time monitoring sensors. This is being discussed with the organization as future work to establish raw material counts, monitor production plan progress, and meet daily goals.