Real-time calculation method and system for multi-variety and small-batch factor cost of food enterprises
Patent Information
- Application Number
- CN202610960329.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-30
- Publication Date
- 2026-09-22
AI Technical Summary
[0003]在实际落地应用中,现有方案仍存在多处与食品企业生产特性不匹配的问题
通过构建四级损耗传导特征链,量化各层级间的损耗关联与传导效应,摒弃传统统一平摊总损耗的粗放核算方式,损耗核算贴合真实生产场景;同时可分层快速定位异常损耗所属环节,经多家食品企业落地实测,损耗层级定位准确率稳定高于90%,为企业损耗管控、生产工艺优化、物料成本压降提供量化支撑数据。
Smart Images

Figure CN122798461A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of digital cost management technology for food processing enterprises, and in particular to a real-time cost calculation system and method for multiple varieties and small batches of factors in food enterprises. Background Technology
[0002] Domestic small and medium-sized food processing enterprises generally adopt a multi-SKU flexible production model. Categories such as condiments, ready-to-eat meals, and bottled beverages have rapid iteration speeds, resulting in small-scale production per batch. For a long time, industry cost accounting has relied on manual Excel summarization by financial personnel, leading to data silos, long accounting cycles, and significant deviations in calculation results. Existing publicly available cost accounting solutions, such as identifier-based food and beverage cost data accounting methods, are limited to static cost data aggregation and unit cost accounting, and have not been specifically optimized for the characteristics of multi-variety, small-batch production.
[0003] In practical applications, existing solutions still have several shortcomings that are incompatible with the production characteristics of food companies. For small and medium-sized food enterprises that frequently launch new products, the production varieties are numerous and the output per batch is small. Most varieties can only accumulate a small number of production batch data. Traditional cost calculation models rely on sufficient historical samples for training, and the calculation deviations are relatively large during the cold start phase of new products. They generally require financial personnel to make manual corrections based on experience, which is difficult to adapt to the business pace of rapid new product launches and cannot support the business needs of enterprises to quickly price new products and quickly calculate production costs.
[0004] Meanwhile, the food production loss chain is long, with losses occurring at each stage from raw material acceptance and production processing to warehousing and distribution, and losses in upstream and downstream links have a transmission effect; existing accounting schemes can only uniformly count the total loss amount, but cannot break down the contribution ratio of losses in each link, making it difficult to accurately locate the level of abnormal loss occurrence and its causes, and making it difficult to provide quantitative data basis for enterprises to control losses, improve processes, and reduce costs.
[0005] In addition, existing cost calculation systems based on AI architecture generally adopt a fixed-cycle full retraining and update mode. Small and medium-sized enterprises have limited server hardware computing power configurations, and full training will generate high computing power and time costs, making it difficult to respond in a timely manner to dynamic changes such as fluctuations in raw material procurement prices, adjustments to production line processes, and updates to food safety compliance policies, resulting in poor model calculation timeliness.
[0006] Cost calculation systems for general industrial scenarios lack customized and adapted logic for the food industry's unique characteristics, such as multi-level losses and food safety compliance cost allocation. This results in weak industry adaptability and an inability to fundamentally address the various pain points in cost calculation for small and medium-sized food enterprises. Summary of the Invention
[0007] The purpose of this invention is to overcome the above-mentioned shortcomings of the prior art and provide a method and system for real-time calculation of factor costs for food enterprises with multiple varieties and small batches. Through three core improvements, namely loss transmission feature chain, two-layer transfer learning architecture and dual-trigger incremental update mechanism, it can achieve high-precision real-time calculation of all factor costs and accurate traceability of losses under the premise of small sample and low computing power, which is suitable for the production characteristics of multiple varieties and small batches in the food industry.
[0008] To achieve the above objectives, the present invention provides a method for real-time calculation of factor costs for food enterprises with multiple varieties and small batches, comprising the following steps: S1. Collect raw data of all factor costs in the entire production chain of food enterprises, perform standardized preprocessing on the raw data, and generate a standardized factor cost dataset. S2. Construct a multi-dimensional factor cost feature set based on a standardized factor cost dataset and a loss transmission feature chain. The loss transmission feature chain connects four loss levels: raw material layer, production layer, inventory layer, and logistics layer. A loss transmission coefficient is calculated between any two adjacent levels. The loss transmission coefficient is used to characterize the impact weight of upstream level loss fluctuations on downstream level production costs. S3. Construct a factor cost calculation model with a two-layer transfer learning architecture; the two-layer transfer learning architecture includes a pre-trained general basic model and a variety fine-tuning branch corresponding to each production variety; the variety fine-tuning branch is generated by performing parameter freezing fine-tuning on the general basic model using 3 to 5 historical batch samples of corresponding varieties. S4. Input the real-time factor cost data of the current production batch into the factor cost calculation model, and output the complete full factor cost calculation results and detailed data of loss at each level for the batch. S5. Configure a dual-trigger incremental update mechanism to continuously and dynamically iterate the factor cost calculation model; the dual-trigger incremental update mechanism includes two types of triggering conditions: the residual of multiple consecutive batches of calculations exceeds the abnormal threshold, and a new production variety without a fine-tuning branch is added; when either triggering condition is met, all parameters of the remaining sub-models in the system are locked, and incremental training is carried out only for the target sub-model or the corresponding variety's fine-tuning branch.
[0009] Furthermore, the raw factor cost data is divided into six categories: raw material factor data, labor factor data, manufacturing factor data, logistics factor data, compliance factor data, and operational support factor data. The raw material data should include at least the raw material name, purchase price, purchase quantity, raw material moisture content, theoretical yield, and raw material shelf life. The human resource data shall include at least workstation configuration information, hourly rate, shift duration, piece-rate wage standard, and changeover auxiliary hours. The manufacturing element data shall include at least the equipment depreciation amortization amount, energy consumption unit price, energy consumption per batch, auxiliary material cost, and changeover cleaning time; The logistics element data shall include at least the delivery distance, cold chain transportation unit price, loss and damage threshold, and loading and unloading operation cost. The compliance data shall include at least the cost of food safety testing for a single batch, the amount of environmental protection expenses allocated, and the annual allocated cost of the production license. The operational support data includes at least the management expense allocation coefficient, the sales expense allocation coefficient, and the complete production cycle for a single batch.
[0010] Furthermore, the standardized preprocessing includes four processing steps in sequence: outlier cleaning, missing value imputation, unstructured data to structure, and unified format standardization. The outlier cleaning uses a 3σ discrimination rule to remove outlier data that deviates from the historical mean of the corresponding indicator by three times the standard deviation. The missing value imputation distinguishes between two types of data and applies different imputation strategies: missing data in production process records is imputed using linear interpolation of adjacent production batches of the same product category; and low-frequency statistical data related to compliance is imputed using the monthly average smoothing method. The unstructured data structuring conversion utilizes OCR text recognition and named entity recognition algorithms to transform paper purchase invoices, handwritten production ledgers, and paper logistics waybills into computable structured fields. The format standardization unifies all data measurement units, enterprise material coding rules, and cost statistics standards, ultimately outputting a standardized element cost dataset.
[0011] Furthermore, the loss conduction coefficient is calculated using the Pearson correlation of historical batch data, and the corresponding calculation expression is as follows:
[0012] Where i represents the loss level, and the values 1, 2, 3, and 4 correspond to the raw material level, production level, inventory level, and logistics level, respectively. This represents the loss rate of the i-th level under the k-th historical batch; represents the historical average loss rate of the i-th level; n is the total number of valid historical batches involved in the calculation; Using the calculated loss conduction coefficients at each level, a tiered accounting method for the total loss cost of a single batch is performed. The accounting expression is as follows:
[0013] in The baseline input cost for level i; Let be the actual loss rate of this production at level i; is the loss propagation coefficient from level j to level j+1.
[0014] Furthermore, the factor cost calculation model includes a raw material cost calculation sub-model, a labor cost calculation sub-model, a manufacturing expense calculation sub-model, and a comprehensive factor cost summary sub-model. The raw material cost calculation sub-model uses an LSTM neural network to adapt to the time-series fluctuation characteristics of raw material prices. The labor cost calculation sub-model integrates a linear regression algorithm and a business rule engine. The manufacturing expense calculation sub-model uses a random forest algorithm to adapt to the multi-factor nonlinear manufacturing expense characteristics. The comprehensive factor cost summary sub-model dynamically allocates fusion weights based on the historical calculation accuracy of each sub-model, with the weight values ranging from 0.2 to 0.4.
[0015] Furthermore, the training of the variety fine-tuning branch adopts a weighted transfer loss function to balance the measurement accuracy and model generalization. The loss function is defined as follows:
[0016] in The task loss is expressed in the form of mean squared error and is used to measure the accuracy of cost calculation. This is a regularization term used to limit the deviation between the fine-tuning branch parameters and the general base model parameters, thus avoiding the problem of model overfitting under small sample training. The dynamic weighting coefficient is positively correlated with the number of existing sample batches. The fewer the sample batches, the higher the weight of the regularization constraint term, thus suppressing overfitting.
[0017] Furthermore, the rule for triggering the anomaly threshold is as follows: when the relative residuals of three consecutive batches exceed the anomaly threshold, the incremental update of the corresponding sub-model is triggered, and the determination formula is:
[0018] in For the calculated relative residual of the kth batch, This is the abnormal threshold, with a default value of 10%, which can be adjusted according to peak and off-peak production seasons. For indicator functions; The rule for triggering variety switching is as follows: when the cumulative production batches of the new variety are ≥3 and there is no corresponding fine-tuning branch, the corresponding switchover is triggered. The training and judgment formula for variety fine-tuning branches is as follows:
[0019] in This represents the cumulative number of production batches for the new variety.
[0020] A real-time cost calculation system for multiple varieties and small batches of food products is provided, comprising a data acquisition module, a data preprocessing module, a feature engineering module, an AI calculation model module, and an output and iteration module. Each module communicates bidirectionally through a standardized data interface. The data acquisition module is used to connect with the enterprise's ERP, MES, WMS, TMS and financial systems to collect raw data on all factor costs throughout the entire food production chain. The data preprocessing module is used to perform anomaly cleaning, missing data filling, and format unification standardization on multi-source heterogeneous data, and output a standardized element cost dataset. The feature engineering module has a built-in loss transmission feature chain calculation unit, which is used to construct a multi-dimensional element cost feature set and simultaneously complete the calculation of loss transmission coefficients between the four loss levels. The AI calculation model module adopts a two-layer transfer learning architecture with a general basic model and a product fine-tuning branch, and has built-in multiple cost calculation sub-models to achieve rapid adaptation and calculation for small sample new products. The output and iteration module is used to output full-factor cost calculation reports and loss anomaly warning information at each level, and drives the model to continuously iterate dynamically based on the dual-trigger incremental update mechanism.
[0021] Furthermore, the AI calculation model module has a pre-trained general basic model and multiple independently configurable variety fine-tuning branches, with each fine-tuning branch uniquely corresponding to a type of production variety. Each variety fine-tuning branch is trained based on a weighted transfer loss function, and the regularization weights inside the loss function are dynamically and adaptively adjusted according to the number of valid sample batches of the corresponding variety.
[0022] Furthermore, the output and iteration module has a built-in dual-trigger logic judgment unit that monitors the frequency of continuous anomalies in the model's calculated residuals and the cumulative production status of newly added varieties in real time. When any type of update trigger condition is met, the incremental training process of the corresponding sub-model or the fine-tuning branch of the matching variety is automatically started.
[0023] Compared with the prior art, the present invention has the following beneficial technical effects: By constructing a four-level loss transmission characteristic chain, the loss correlation and transmission effect between each level are quantified, abandoning the traditional crude accounting method of uniformly amortizing total loss. The loss accounting is more in line with the real production scenario. At the same time, it can quickly locate the link to which abnormal loss belongs in a hierarchical manner. After being tested by multiple food companies, the accuracy rate of loss level location is consistently higher than 90%, providing quantitative support data for enterprises' loss control, production process optimization, and material cost reduction.
[0024] It adopts a two-layer transfer learning architecture that combines a general basic model with product fine-tuning branches, and is equipped with a weighted transfer loss function that adapts to the number of samples. Only 3 to 5 production batches of samples are needed to complete the model adaptation for new products. The relative error of the calculation during the cold start phase of new product production can be controlled within 8%, which is suitable for the business needs of food companies for high-frequency new product launches and small-batch trial production.
[0025] The dual-trigger incremental update mechanism initiates model iteration as needed based on two scenarios: abnormal residual calculation and new product launch. The update process only trains the target sub-model or the corresponding fine-tuning branch, without the need for full parameter retraining. The computational cost of model iteration is reduced by about 60% compared to the traditional full retraining solution, and the model update time is significantly reduced, making it suitable for small and medium-sized food enterprises with low-configuration server computing power. Attached Figure Description
[0026] Figure 1 This is a block diagram of the overall architecture of the real-time factor cost calculation system described in this invention; Figure 2 This is a flowchart illustrating the overall process of the real-time cost calculation method for factors of production described in this invention. Detailed Implementation
[0027] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be noted that the following embodiments are only used to explain the technical solutions of the present invention, and are not intended to limit it.
[0028] Addressing the "multiple SKUs, small batches" production characteristics prevalent in food sub-sectors such as condiments and ready-to-eat meals, existing cost estimation solutions often suffer from high calculation errors when starting new products due to a lack of historical data, and struggle to trace losses across the entire production chain in a layered manner. Furthermore, traditional AI models employ a full-update strategy, resulting in excessive computational overhead in production line environments with frequent product switching. To address these issues, this invention provides a method and system for real-time factor cost estimation for food enterprises with multiple product types and small batches. The core improvements include: constructing a four-level loss transmission feature chain (raw material, production, inventory, and logistics layers) to quantify the loss correlation between levels; building a two-layer transfer learning architecture including a general basic model and product-specific fine-tuning branches, coupled with a dynamically weighted transfer loss function to achieve rapid adaptation under small sample conditions; and setting a dual-trigger incremental update mechanism that continuously triggers anomaly thresholds and triggers new production products, significantly reducing the computational cost of model iteration while ensuring calculation accuracy.
[0029] like Figure 1As shown, the measurement system of the present invention is configured with five functional modules, which are, from top to bottom, a data acquisition module, a data preprocessing module, a feature engineering module, an AI measurement model module, and an output and iteration module. Each module is connected in series through a standardized data interface to collaboratively complete the entire process from raw data acquisition to cost result output. The system is also equipped with an independent data security module, which is responsible for data encryption, access control and backup.
[0030] like Figure 2 As shown, the calculation method of the present invention includes six core steps: data acquisition, data preprocessing, feature set construction, model initialization, real-time calculation, and dual-trigger incremental update, forming a closed-loop iterative mechanism. The technical details of all steps are fully implemented in the following embodiments.
[0031] Example 1: Application in small-scale condiment production enterprises This example selects a small condiment processing enterprise in Qingdao as the application scenario. The enterprise simultaneously puts into production 28 types of SKU products, with a minimum production scale of only 50kg per batch. Previously, the enterprise relied on its financial staff to manually calculate production costs using Excel. In the early stages of new product production, the cost calculation error was as high as 21%. When abnormal material loss occurred, it took two working days for production and financial staff to work together to manually investigate and locate the root cause of the problem. Overall, the calculation efficiency was low and the calculation accuracy was insufficient.
[0032] Step S1: Collection of Cost Data for All Business Process Elements The deployment system's data acquisition module interfaces with enterprise ERP, MES, WMS, TMS, and financial systems, covering the entire process from raw material procurement, production and processing, warehousing management, logistics and distribution, to compliant operations, collecting cost data across six major categories: Raw material information: raw material name, purchase price, purchase quantity, moisture content, theoretical yield, shelf life, and supplier information; Human resource factors: workstation configuration, hourly rate, shift length, piece-rate wage standard, auxiliary working hours for production changeover, and social security and housing provident fund sharing coefficient; Manufacturing factors: equipment depreciation amortization, energy consumption unit price, energy consumption per batch, auxiliary material and consumable costs, changeover CIP cleaning time, and equipment utilization rate; Logistics elements: delivery distance, cold chain unit price, damage rate threshold, loading and unloading costs, and single batch delivery volume; Compliance elements: batch cost of food safety testing, cost of environmental emissions allocation, annual allocation of production license, and cost of personnel compliance training; Operational support elements: management expense allocation coefficient, sales expense allocation coefficient, batch production cycle.
[0033] Data collection frequency is configured according to data characteristics: raw material prices are updated in real time with purchase orders, production and labor data are synchronized in batches, and compliance and operational data are synchronized monthly. For the large number of paper agricultural product purchase invoices retained by the company, OCR and named entity recognition technologies are used to convert them into structured data in batches, supplementing the historical dataset.
[0034] Step S2: Multi-source heterogeneous data preprocessing Four standardization processes are performed through the data preprocessing module, and the processing rules are completely consistent with those in claim 3: Outlier cleaning: Using the 3σ principle, abnormal purchase prices that deviate from the historical average by three times the standard deviation, production loss rates that exceed the process limit, and other dirty data were removed. A total of 127 outlier data were removed, accounting for 1.8% of the total original data. Missing value imputation: A small number of missing values in production records are imputed using linear interpolation of similar batches of the same product; low-frequency missing data for compliant products are imputed using monthly average smoothing, resulting in a data completeness of 99.2% after imputation. Unstructured data conversion: Converting handwritten production records and paper logistics waybills into structured data, extracting key cost fields, with an accuracy rate of 96.5%; Format standardization: unify data units, material coding rules and statistical standards, establish a full-element data dictionary, and finally output a standardized element cost dataset.
[0035] Step S3: Construction of Multi-Dimensional Factor Cost Feature Set The feature engineering module constructs a four-dimensional feature set, and the core design incorporates a four-level loss propagation feature chain. The four main dimensions of characteristics include basic cost characteristics, cost fluctuation characteristics, loss transmission characteristic chain, and compliance-related characteristics, ultimately resulting in 42 core characteristics. Among them, the loss transmission characteristic chain is set up with four levels of loss at the raw material layer, production layer, inventory layer, and logistics layer. Each level includes two core indicators: loss rate and loss amount.
[0036] The feature engineering module includes a built-in loss conduction coefficient calculation unit and a hierarchical loss accounting unit, which respectively perform the two functions of conduction coefficient calculation and hierarchical loss accounting: Based on 326 valid production batches of data from the company's historical 12 months, the loss conduction coefficient of adjacent levels is calculated through Pearson correlation analysis. The calculation formula is as follows:
[0037] The calculated conductivity coefficient from the raw material layer to the production layer is: The transmission coefficient from the production layer to the inventory layer The transmission coefficient from the inventory layer to the logistics layer This represents the weight of the quantitative impact of the loss fluctuation of the previous level on the cost of the next level.
[0038] Based on the transmission coefficient, a tiered accounting method is used to calculate the total loss cost of a single batch. The calculation formula is as follows:
[0039] The original total loss amortization method for enterprises has been replaced, and the loss accounting matching degree has been improved from 85% to 93%.
[0040] Step S4: Building a Two-Layer Transfer Learning Measurement Model The AI calculation model module adopts a two-layer transfer learning architecture of "general basic model + variety fine-tuning branch", which includes four sub-models: Raw material cost calculation sub-model: It adopts LSTM neural network to adapt to the time-series fluctuation characteristics of raw material prices. The input is raw material price, purchase batch, yield rate and raw material loss rate, and the output is the unit cost and total cost of raw materials for a single batch. Labor cost calculation sub-model: It adopts linear regression combined with a rule engine, inputs workstation hours, piece rate standard, allocation coefficient, and changeover hours, and outputs the labor cost of a single batch; Manufacturing cost calculation sub-model: adopts random forest algorithm, adapts to the multi-factor and non-linear characteristics of manufacturing cost, inputs equipment energy consumption, auxiliary material consumption, utilization rate, and changeover time, and outputs the manufacturing cost allocation value of a single batch; Comprehensive factor cost summary sub-model: The fusion weight is dynamically allocated based on the historical calculation accuracy of each sub-model. The weight range is 0.2-0.4. In this embodiment, the weight of the raw material sub-model is 0.38, the weight of the labor sub-model is 0.25, and the weight of the manufacturing sub-model is 0.37. Finally, the unit cost of all factors in a single batch, the total cost, and the proportion of each factor are output.
[0041] Model training is divided into three stages: Pre-training phase: Based on the publicly available cost dataset of the condiment industry and the full historical data of partner companies, we completed the pre-training of the general basic model and learned the general cost calculation rules; Product fine-tuning phase: Freeze the parameters of the first 8 layers of the backbone network of the base model, and fine-tune only the last 2 fully connected layers. Perform full training on 12 mature SKUs with more than 10 production batches; for 16 small-batch SKUs, perform transfer learning fine-tuning using 3-5 batches of data. The training uses a weighted transfer loss function, calculated as follows:
[0042] The dynamic weighting coefficient is when the sample size is 3 batches. Strengthen regularization constraints to avoid overfitting; when the sample size reaches 10 batches or more. The focus is on measurement accuracy.
[0043] Cold start adaptation verification: After fine-tuning, the average relative error of the validation set is ≤8% as the standard for going live. In this embodiment, the verification error of 16 small batch SKUs after fine-tuning is controlled within 7%, and all are judged to be adapted and officially launched; if the error is >8%, the reference value is output by calling the benchmark model of the same category, and fine-tuning is triggered again after accumulating 5 batches of data.
[0044] During the initial debugging phase of the model, the calculation deviation of the production changeover auxiliary time once reached 14%. After analysis, it was found that the production changeover frequency feature was not included in the artificial sub-model. After adding the corresponding feature dimensions, the deviation dropped back to within 7%.
[0045] Step S5: Real-time cost calculation and result output The batch cost data of elements collected in real time is preprocessed and then input into the calculation model. The output and iteration modules simultaneously output four types of results: the full cost calculation results of a single batch, loss stratification details, cost fluctuation prediction and anomaly warning.
[0046] In this embodiment, after a batch of production data is entered, the system outputs a complete cost report within 5 minutes; when the production loss rate of a certain batch exceeds the threshold of 15%, the system automatically triggers an early warning, locates the abnormal level as the production level, identifies the root cause as leakage in the filling equipment, and pushes equipment maintenance suggestions.
[0047] Step S6: Dual-trigger incremental update mechanism operation The output and iteration module has a built-in dual-trigger decision unit that executes a dual-trigger incremental update mechanism: The rules for determining the two types of triggering conditions are as follows: Anomaly threshold trigger: When the relative residuals of three consecutive batches exceed the anomaly threshold θ (default 10%), an incremental update of the corresponding sub-model is triggered. The determination formula is as follows:
[0048] In this embodiment, when the residual of raw material cost exceeds 10% for three consecutive batches, Trigger1=1, triggering an incremental update of the raw material cost sub-model.
[0049] Variety switch trigger: When the cumulative production batches of the new variety are ≥3 and there is no corresponding fine-tuning branch, the training of the corresponding variety fine-tuning branch is triggered. The determination formula is:
[0050] In this embodiment, when a company adds 2 new SKUs and accumulates 3 batches of production without corresponding fine-tuning branches, Trigger2=1, automatically triggering the training of the corresponding fine-tuning branches.
[0051] Incremental updates employ mini-batch gradient descent, updating only the top-level decision parameters of the corresponding sub-model while freezing the underlying feature extraction network. The number of parameters updated in a single batch is controlled to within 30% of the total update. After the update, the model is tested on a validation set. If the error is ≤5%, the model is automatically deployed to replace the old model; otherwise, the original model is retained and pushed for manual review. In this embodiment, fine-tuning training for a new SKU takes 1.5 hours, with a validation error of 6.2%, and automatic replacement occurs after meeting the deployment criteria.
[0052] Data security module configuration The system's data security module uses the AES-256 encryption algorithm to store core financial and business data. It sets up three levels of access permissions: administrator, finance, and business. It supports dual data backup on both local and cloud platforms, comprehensively protecting enterprise data security and preventing financial data leakage and tampering.
[0053] After three months of continuous operation, the actual test results showed that the cold start calculation error for new varieties decreased from 21% to 7.3%, the location of loss anomalies changed from manual investigation every two days to real-time output, the workload of financial accounting personnel per batch decreased by approximately 72%, the efficiency of per batch calculation increased by approximately 91.7%, and the average monthly computing power cost of the model decreased by approximately 62.7%, achieving the expected technical results.
[0054] Example 2: Application adapted to small-scale beverage production enterprises This embodiment uses a small bottled beverage manufacturing company as an application scenario. This company produces 16 different products, with significant differences in production capacity between peak and off-peak seasons. Its main pain points are inaccurate calculation of raw material shelf-life loss, large cost fluctuations between peak and off-peak seasons, and limited server computing power. This embodiment, based on all the technical features of the claims, is adapted and optimized for the characteristics of the beverage industry.
[0055] Adaptation and optimization content: The feature set is simplified to 32 dimensions, with a focus on enhancing the characteristics of raw material shelf-life loss and cold chain logistics loss, making it suitable for the high loss characteristics of the beverage industry. Simplify the feature dimensions of the manufacturing cost sub-model to adapt to single production line scenarios and reduce computing power requirements; The abnormal threshold is configured in a dual mode for peak and off-peak seasons: the abnormal threshold θ is tightened to 10% during the peak season (June-September) and relaxed to 18% during the off-peak season, balancing the calculation accuracy and update frequency.
[0056] Application results: The accuracy of raw material loss calculation has increased from 82% to 94%, the accuracy of cost fluctuation prediction during peak and off-peak seasons has reached 89%, and the average monthly computing power cost of model updates has been reduced by about 65% compared with the original full update mode, making it fully compatible with the computing power configuration of small and medium-sized enterprises.
[0057] The present invention has been described above by way of example with reference to the accompanying drawings. Obviously, the specific implementation of the present invention is not limited to the above embodiments. Those skilled in the art can make various modifications or variations to the present invention without departing from the technical concept of the present invention, and such modifications or variations naturally fall within the protection scope of the present invention.
Claims
1. A method for real-time calculation of factor costs for food enterprises with multiple varieties and small batches, characterized in that, Includes the following steps: S1. Collect raw data of all factor costs in the entire production chain of food enterprises, perform standardized preprocessing on the raw data, and generate a standardized factor cost dataset. S2. Construct a multi-dimensional factor cost feature set based on the standardized factor cost dataset, integrating the loss transmission feature chain; The loss transmission characteristic chain connects four loss levels: raw material layer, production layer, inventory layer, and logistics layer. A loss transmission coefficient is calculated between any two adjacent layers. The loss transmission coefficient is used to characterize the weight of the impact of upstream loss fluctuations on downstream production costs. S3. Construct a factor cost calculation model with a two-layer transfer learning architecture; the two-layer transfer learning architecture includes a pre-trained general basic model and a variety fine-tuning branch corresponding to each production variety. The variety fine-tuning branch is generated by performing parameter freezing and fine-tuning on the general basic model using 3 to 5 corresponding historical batch samples of the variety. S4. Input the real-time factor cost data of the current production batch into the factor cost calculation model, and output the complete full factor cost calculation results and detailed data of loss at each level for the batch. S5. Configure a dual-trigger incremental update mechanism to continuously and dynamically iterate the factor cost calculation model; the dual-trigger incremental update mechanism includes two types of triggering conditions: the residual of multiple consecutive batches of calculations exceeds the abnormal threshold, and a new production variety without a fine-tuning branch is added; when either triggering condition is met, all parameters of the remaining sub-models in the system are locked, and incremental training is carried out only for the target sub-model or the corresponding variety's fine-tuning branch.
2. The method for real-time calculation of factor costs according to claim 1, characterized in that, The raw cost data is divided into six categories: raw material cost data, labor cost data, manufacturing cost data, logistics cost data, compliance cost data, and operational support cost data. The raw material data should include at least the raw material name, purchase price, purchase quantity, raw material moisture content, theoretical yield, and raw material shelf life. The human resource data shall include at least workstation configuration information, hourly rate, shift duration, piece-rate wage standard, and changeover auxiliary hours; The manufacturing element data shall include at least the equipment depreciation amortization amount, energy consumption unit price, energy consumption per batch, auxiliary material cost, and changeover cleaning time; The logistics element data shall include at least the delivery distance, cold chain transportation unit price, loss and damage threshold, and loading and unloading operation cost. The compliance data shall include at least the cost of food safety testing for a single batch, the amount of environmental protection expenses allocated, and the annual allocated cost of the production license. The operational support data includes at least the management expense allocation coefficient, the sales expense allocation coefficient, and the complete production cycle for a single batch.
3. The method for real-time calculation of factor costs according to claim 1, characterized in that, The standardized preprocessing includes four steps in sequence: outlier cleaning, missing value imputation, unstructured data structuring transformation, and unified format standardization. The outlier cleaning uses a 3σ discrimination rule to remove outlier data that deviates from the historical mean of the corresponding indicator by three times the standard deviation. The missing value imputation distinguishes between two types of data and applies different imputation strategies: missing data in production process records is imputed using linear interpolation of adjacent production batches of the same product category; and low-frequency statistical data related to compliance is imputed using the monthly average smoothing method. The unstructured data structuring conversion utilizes OCR text recognition and named entity recognition algorithms to transform paper purchase invoices, handwritten production ledgers, and paper logistics waybills into computable structured fields. The format standardization unifies all data measurement units, enterprise material coding rules, and cost statistics standards, ultimately outputting a standardized element cost dataset.
4. The method for real-time calculation of factor costs according to claim 1, characterized in that, The loss conduction coefficient is calculated using the Pearson correlation of historical batch data, and the corresponding calculation expression is as follows: ; i represents the loss level, with values 1, 2, 3, and 4 corresponding to the raw material level, production level, inventory level, and logistics level, respectively. This represents the loss rate of the i-th level under the k-th historical batch; represents the historical average loss rate of the i-th level; n is the total number of valid historical batches involved in the calculation; Using the calculated loss conduction coefficients at each level, a tiered accounting method for the total loss cost of a single batch is performed. The accounting expression is as follows: ; The baseline input cost for level i; Let be the actual loss rate of the current production at level i; is the loss propagation coefficient from level j to level j+1.
5. The method for real-time calculation of factor costs according to claim 1, characterized in that, The factor cost calculation model includes a raw material cost calculation sub-model, a labor cost calculation sub-model, a manufacturing cost calculation sub-model, and a comprehensive factor cost summary sub-model; the raw material cost calculation sub-model uses an LSTM neural network to adapt to the time-series fluctuation characteristics of raw material prices; the labor cost calculation model integrates a linear regression algorithm and a business rule engine; The manufacturing cost calculation sub-model adopts the random forest algorithm to adapt to the multi-factor nonlinear manufacturing cost characteristics; the comprehensive factor cost aggregation sub-model dynamically allocates fusion weights according to the historical calculation accuracy of each sub-model, with the weight value range being 0.2 to 0.
4.
6. The method for real-time calculation of factor costs according to claim 1, characterized in that, The training of the fine-tuning branch for the aforementioned variety employs a weighted transfer loss function to balance measurement accuracy and model generalization. The loss function is defined as follows: ; The task loss is expressed in the form of mean squared error and is used to measure the accuracy of cost calculation. This is a regularization term used to limit the deviation between the fine-tuning branch parameters and the general base model parameters, thus avoiding the problem of model overfitting under small sample training. The dynamic weighting coefficient is positively correlated with the number of existing sample batches. The fewer the sample batches, the higher the weight of the regularization constraint term, thus suppressing overfitting.
7. The method for real-time calculation of factor costs according to claim 1, characterized in that, The rule for triggering the abnormal threshold is as follows: when the relative residuals of three consecutive batches exceed the abnormal threshold, the incremental update of the corresponding sub-model is triggered. The determination formula is: ; For the calculated relative residual of the kth batch, This is the abnormal threshold, with a default value of 10%, which can be adjusted according to peak and off-peak production seasons. For indicator functions; The determination rule for triggering variety switching is as follows: when the cumulative production batches of the new variety are ≥3 and there is no corresponding fine-tuning branch, the corresponding variety fine-tuning branch is triggered to start training. The determination formula is: ; This represents the cumulative number of production batches for the new variety.
8. A real-time factor cost calculation system for food enterprises with multiple varieties and small batches, characterized in that, It includes a data acquisition module, a data preprocessing module, a feature engineering module, an AI calculation model module, and an output and iteration module. Each module communicates bidirectionally through a standardized data interface. The data acquisition module is used to connect with the enterprise's ERP, MES, WMS, TMS and financial systems to collect raw data on all factor costs throughout the entire food production chain. The data preprocessing module is used to perform anomaly cleaning, missing data filling, and format unification standardization on multi-source heterogeneous data, and output a standardized element cost dataset. The feature engineering module has a built-in loss transmission feature chain calculation unit, which is used to construct a multi-dimensional element cost feature set and simultaneously complete the calculation of loss transmission coefficients between the four loss levels. The AI calculation model module adopts a two-layer transfer learning architecture with a general basic model and a product fine-tuning branch, and has built-in multiple cost calculation sub-models to achieve rapid adaptation and calculation for small sample new products. The output and iteration module is used to output full-factor cost calculation reports and loss anomaly warning information at each level, and drives the model to continuously iterate dynamically based on the dual-trigger incremental update mechanism.
9. The real-time factor cost calculation system according to claim 8, characterized in that, The AI calculation model module has a pre-trained general basic model and multiple independently configurable variety fine-tuning branches. Each fine-tuning branch uniquely corresponds to a production variety. Each variety fine-tuning branch is trained based on a weighted transfer loss function, and the regularization weights inside the loss function are dynamically and adaptively adjusted according to the number of valid sample batches of the corresponding variety.
10. The real-time factor cost calculation system according to claim 8, characterized in that, The output and iteration module has a built-in dual-trigger logic judgment unit that monitors the frequency of continuous anomalies in the model's calculated residuals and the cumulative production status of newly added varieties in real time. When any type of update trigger condition is met, the incremental training process of the corresponding sub-model or the fine-tuning branch of the matching variety is automatically started.