Enterprise raw material prediction system and method based on patchtst model
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHENGDU DIANKE ZHILIAN TECH CO LTD
- Filing Date
- 2026-05-14
- Publication Date
- 2026-08-07
AI Technical Summary
现有的深度学习方法如LSTM、GRU等在长时间序列预测中面临梯度消失问题,且计算成本高,适应性差
[0022] The beneficial effects of this invention: This invention improves the PatchTST model by using a "decomposition-modeling-integration" approach to break down complex time-series data into interpretable components. It then utilizes PatchTST's attention mechanism to capture the temporal dependencies of each component, ultimately achieving high-precision predictions through integration. Compared to directly modeling the original data, this structure better separates trend, seasonality, and stochastic factors, improving the interpretability and stability of predictions. Compared to existing technologies, this invention has the following advantages:
Smart Images

Figure CN122529619A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of intelligent manufacturing, and specifically relates to a technology for predicting the demand for raw materials in inventory. Background Technology
[0002] Raw material inventory management is a critical aspect of production and operation in manufacturing enterprises. Traditional forecasting methods, such as moving averages, exponential smoothing, and ARIMA statistical models, have limitations in handling nonlinear and multivariate raw material demand forecasting. Existing deep learning methods, such as LSTM and GRU, face the vanishing gradient problem in long-term series forecasting and suffer from high computational costs and poor adaptability. While time-series forecasting models based on the Transformer architecture have made some improvements, they still suffer from insufficient prediction accuracy, long training times, and the inability to provide reliable prediction intervals in the specific scenarios of enterprise raw material forecasting. Specifically: traditional forecasting methods (moving average, exponential smoothing, ARIMA) lack sufficient accuracy in predicting nonlinear, multivariate raw material demand; existing machine learning methods (LightGBM, XGBoost) suffer from cumulative errors in multi-step forecasting tasks, making them unsuitable for long-term forecasting needs; traditional deep learning methods (LSTM, GRU) face the vanishing gradient problem and are computationally expensive and poorly adaptable; while existing Transformer models have been improved, they lack specialized optimization designs for enterprise raw material forecasting; existing forecasting systems are mostly point-based, lacking reliable forecast intervals and failing to support risk management decisions; and they are ill-suited to adapting to sudden changes in raw material demand patterns and diverse production scenarios. Summary of the Invention
[0003] To address the aforementioned technical challenges, this invention proposes an enterprise raw material forecasting system and method based on the PatchTST model. This system can significantly improve forecasting accuracy, reduce inventory costs, optimize supply chain management efficiency, and provide strong technical support for enterprise intelligent manufacturing and digital transformation.
[0004] One of the technical solutions adopted in this invention is: a method for enterprise raw material forecasting based on the PatchTST model, which forecasts raw material demand based on an improved PatchTST model; the forecasting process includes:
[0005] S1. Automatically collect historical raw material inventory data from the enterprise's ERP system, MES system, and supply chain management system, and preprocess the historical raw material inventory data to obtain the features and external related data directly associated with the historical raw material inventory data.
[0006] S2. Construct an improved PatchTST model and predict raw material demand based on the improved PatchTST model; the improved PatchTST model includes: a data decomposition layer, a feature processing layer, a PatchTST core layer, and a component integration layer.
[0007] The data decomposition layer is used to process the historical raw material inventory data automatically collected from the enterprise's ERP system, MES system, and supply chain management system into time series decomposition data; ultimately, the historical raw material inventory data is decomposed into three components: trend component, seasonal component, and residual component.
[0008] The features of the directly related historical raw material inventory data obtained in step S1, the external related data, and the trend items, seasonal components, and residual items output by the data decomposition layer are input into the feature processing layer. The feature processing layer outputs trend features, seasonal features, and residual features.
[0009] The core layer of PatchTST includes a sequence segmentation module, a PatchTST encoder module, a feature fusion module, and a prediction head module. The sequence segmentation module processes trend features, seasonal features, and residual features into fixed-length patch sequences. The PatchTST encoder module encodes each patch sequence and outputs the encoded patch features. The feature fusion module integrates the encoded patch features into continuous time-series features. The prediction head module performs regression prediction on the fused features and outputs the future time-series prediction results for the three components.
[0010] The component integration layer is used to reassemble the prediction results of the three components into a final time series prediction;
[0011] S3. Construct a training dataset by combining the features of the directly related historical raw material inventory data obtained in step S1 with external related data, as well as the trend terms, seasonal components, and residual terms output by the data decomposition layer.
[0012] S4. Train the improved PatchTST model from step S2 based on the training dataset from step S3.
[0013] S5. Output prediction results based on the improved PatchTST model after training is completed.
[0014] The second technical solution adopted in this invention is: an enterprise raw material prediction system based on the PatchTST model, comprising: a data acquisition module and a prediction module;
[0015] The data acquisition module is used to acquire the features and externally related data of historical raw material inventory data that are directly associated with it.
[0016] The prediction module uses an improved PatchTST model to predict the characteristics of directly related historical raw material inventory data and external related data obtained by the data acquisition module.
[0017] The improved PatchTST model includes: a data decomposition layer, a feature processing layer, a PatchTST core layer, and a component integration layer.
[0018] The data decomposition layer is used to process the historical raw material inventory data automatically collected from the enterprise's ERP system, MES system, and supply chain management system into time series decomposition data; ultimately, the historical raw material inventory data is decomposed into three components: trend component, seasonal component, and residual component.
[0019] The features of the directly related historical raw material inventory data acquired by the data acquisition module, along with external related data, and the trend items, seasonal components, and residual items output by the data decomposition layer, are input into the feature processing layer. The feature processing layer outputs trend features, seasonal features, and residual features.
[0020] The core layer of PatchTST includes a sequence segmentation module, a PatchTST encoder module, a feature fusion module, and a prediction head module. The sequence segmentation module processes trend features, seasonal features, and residual features into fixed-length patch sequences. The PatchTST encoder module encodes each patch sequence and outputs the encoded patch features. The feature fusion module integrates the encoded patch features into continuous time-series features. The prediction head module performs regression prediction on the fused features and outputs the future time-series prediction results for the three components.
[0021] The component integration layer is used to reassemble the prediction results of the three components into a final time series prediction.
[0022] The beneficial effects of this invention: This invention improves the PatchTST model by using a "decomposition-modeling-integration" approach to break down complex time-series data into interpretable components. It then utilizes PatchTST's attention mechanism to capture the temporal dependencies of each component, ultimately achieving high-precision predictions through integration. Compared to directly modeling the original data, this structure better separates trend, seasonality, and stochastic factors, improving the interpretability and stability of predictions. Compared to existing technologies, this invention has the following advantages:
[0023] Improved prediction accuracy: Compared to traditional time series forecasting methods, prediction accuracy is improved by 25%-40%.
[0024] Training efficiency optimization: By improving the PatchTST architecture, training time is reduced by 60% and computational resource requirements are reduced by 50%.
[0025] Enhanced reliability: Through a probabilistic prediction mechanism, it provides upper and lower bounds for a 95% confidence interval, offering a basis for risk assessment in inventory management.
[0026] Highly adaptable: Capable of handling forecasting needs across various raw material types and time granularities, adapting to complex scenarios in enterprise production and operation.
[0027] Interpretability: Provides analysis of key influencing factors on forecast results, enhancing forecast credibility and business decision support capabilities.
[0028] High practicality: The system is designed with actual enterprise application scenarios in mind, making it easy to integrate, simple to operate, and low in maintenance costs. Attached Figure Description
[0029] Figure 1 This is an improved PatchTST model architecture provided in Embodiment 1 of the present invention;
[0030] Figure 2 This invention provides an improved PatchTST model architecture in Embodiment 2 of the present invention. Detailed Implementation
[0031] To facilitate understanding of the technical content of this invention by those skilled in the art, the following description, in conjunction with the accompanying drawings, further illustrates the invention.
[0032] Example 1
[0033] 1. Data preprocessing includes:
[0034] 11. Data Cleaning
[0035] Automatically collect historical raw material inventory data from enterprise ERP systems, MES systems, and supply chain management systems;
[0036] Data cleaning is performed using anomaly detection algorithms, including the Interquartile Range (IQR) method for detecting outliers and the Exponentially Weighted Moving Average (EWMA) method for identifying abrupt changes. Specific data cleaning rules are designed for different raw material characteristics, such as seasonal detection rules for highly seasonal raw materials and continuous detection rules for continuously produced raw materials. Missing values are handled using multivariate imputation algorithms, and high-precision completion is performed based on the intrinsic relationships between related raw materials.
[0037] Those skilled in the art should note that the automatic data collection involved here involves multiple systems, such as ERP, MES, and supply chain management systems, indicating that the system design of this invention considers cross-platform data sources. In the field of industrial intelligence, such data collection is usually achieved by calling the system's standard APIs or data interfaces (e.g., using OData, RESTful APIs, or enterprise middleware).
[0038] The collected historical raw material inventory data includes date fields, historical consumption, and historical inventory data.
[0039] 12. Data Standardization
[0040] An adaptive standardization method was adopted to select appropriate standardization strategies (Z-score, Min-Max, Robust standardization) based on the volatility characteristics of different raw materials for the historical raw material inventory data collected in step 11, as shown in Table 1.
[0041] Table 1 Standardization strategies for different raw materials
[0042]
[0043] 13. Feature data obtained based on feature engineering
[0044] 131. Characteristics directly related to historical raw material inventory data
[0045] Extract time features from the date field of the inventory record, such as weekday / month; time features are used to identify fixed cycle patterns and serve as input for seasonal flows. The cycle capture is enhanced by Fourier coding as shown in formula (1); specific month coding is input into a multi-scale patch strategy to identify quarterly purchasing peaks.
[0046] (1)
[0047] Where K represents the total number of identified cycles (e.g., annual cycle, quarterly cycle). , , : These represent amplitude, angular frequency, and phase (i.e., the output parameters of the Fourier encoder). Fourier encoding is used to process time features, such as months, to enhance the model's ability to capture periodic patterns. The process of converting discrete time features, such as month indices 1-12, into continuous periodic signals is as follows:
[0048] Input: Month indexes such as 1, 2, ..., 12;
[0049] Output: Fourier series, including amplitude, frequency, and phase.
[0050] Formula (1) is the core implementation of Fourier coding, which decomposes time features (such as months) into a combination of periodic sine waves.
[0051] Sliding window features are extracted based on historical consumption data, such as the 7-day average consumption. These features are then used to extract short-term trends and anomaly signals.
[0052] The historical inventory data is dimensionality reduced to generate compressed features. In this embodiment, PCA is used for dimensionality reduction. The compressed features are used to eliminate redundant information and improve computational efficiency.
[0053] 132. External Related Data:
[0054] Production plans and equipment status data are extracted from the MES system as production features; these production features are used to establish the causal relationship between production activities and raw material consumption.
[0055] Extract supplier delivery cycle and quality inspection duration data from the SCM system as supply chain characteristics;
[0056] Price fluctuations and related raw material index data are obtained from external APIs as market characteristics; these market characteristics are used to dynamically respond to market changes.
[0057] 2. Improved PatchTST model
[0058] like Figure 1 As shown, the improved PatchTST model comprises five core layers: data decomposition layer, feature processing layer, PatchTST core layer, and component integration layer. Each layer progresses progressively from data preprocessing to prediction output, as detailed below:
[0059] 21. Data Decomposition Layer
[0060] This system automatically collects historical raw material inventory data from enterprise ERP, MES, and supply chain management systems, performs preprocessing and time series decomposition processing on the input data, and finally decomposes the original time series data into trend items, seasonal components, and residual items, stripping away the patterns in different dimensions to achieve "divide and conquer" modeling.
[0061] 211. Time Series Decomposition Processing
[0062] Using time series decomposition algorithms (such as STL decomposition or moving average method), the original raw material inventory historical data processed in step 112 is analyzed to separate long-term trends, fixed-period fluctuations, and random noise, resulting in three independent components. The output of the data decomposition layer consists of a trend term, a seasonality term, and a residual term, all with dimensions consistent with the original data. For example, if the original data is "sales volume over 120 months," then all three components will be sequences over "120 months."
[0063] The specific process of time series decomposition is as follows:
[0064] By combining the improved STL (Seasonal-Trend Decomposition) and wavelet transform for multi-scale decomposition, different decomposition feature signals of productive data in the time and frequency domains are obtained.
[0065] Trend extraction: An adaptive moving average method is used, and the window size is automatically optimized based on the historical fluctuation frequency of the raw materials.
[0066] (2)
[0067] (3)
[0068] Wherein, α is the adaptive smoothing coefficient, which is automatically adjusted according to the fluctuation characteristics of the raw materials; , These represent the trend value at the current moment and the trend value at the previous moment, respectively. This represents the past N moments recorded, i.e., the window size; It has been expressed The average value of N data points within the sliding window corresponding to the given time; express Data at any given time. Initially, , This is the mean of the first N raw data points in all the original data.
[0069] Explanation of window size N: For high-frequency fluctuations (frequent changes): a smaller window size N is used to quickly capture short-term changes and avoid lag. For low-frequency fluctuations (gradual changes): a larger window size N is used to smooth noise and extract long-term trends. For example: For high-frequency fluctuating raw materials, whose fluctuation characteristics include demand easily affected by promotions and seasonality, and drastic daily changes (e.g., daily consumption fluctuation ±20%), N can be set to 7 to calculate a 7-day moving average. For low-frequency fluctuating raw materials (such as industrial metals), whose fluctuation characteristics include stable demand and gradual monthly changes (e.g., monthly consumption fluctuation ±5%), N can be set to 30 to calculate a 30-day moving average.
[0070] Seasonal Extraction: Using a combination of Fourier transform and wavelet analysis, the multi-periodic seasonal patterns in historical raw material inventory data are automatically identified.
[0071] (4)
[0072] (5)
[0073] in, Indicates seasonal component, Indicates the total number of recognition periods. Indicates the first Amplitude of each cycle, This indicates the identified different frequency periods. Indicates a time index. This indicates the phase of each cycle. Indicates the variance of seasonal fluctuations. Represents the fundamental variance constant. This represents the innovation impact factor. express Time residuals Represents the historical fluctuation memory coefficient
[0074] Residual term processing: A GARCH model (Generalized Autoregressive Conditional Heteroskedasticity) is used to capture the clustering effect of trend term fluctuations. Those skilled in the art will know that the extraction results of residual term components are directly related to the extraction results of trend term components. The residual term is obtained by subtracting the trend term, seasonal term, and periodic term from the original data; therefore, its accuracy directly depends on the quality of trend term extraction.
[0075] 22. Feature Processing Layer
[0076] This layer is used to standardize, enhance features, and adjust dimensions of the time features, sliding window features, dimensionality-reduced compressed features, production features, supply chain features, and market features obtained from the preprocessing in step 1, as well as the three components decomposed in step 21, to adapt to the input requirements of subsequent models. Standardization is used to eliminate differences in units of measurement, such as mapping the trend term "ten thousand yuan" and the seasonal component's "relative fluctuation" to [-1,1] or a normal distribution. Feature enhancement adds "periodic position features" to highly periodic seasonal components, such as month indices 1-12, and adds "time decay factors" to trend terms, such as year weights. Dimension alignment ensures that the time step and feature dimensions of the three components are completely consistent; for example, if the original data contains two features, "sales volume + price," then all three components are matrices of "time step × 2." The output of the feature processing layer is the preprocessed trend features, seasonal features, and residual features, with dimensions: [number of samples, time step, number of features].
[0077] 23. PatchTST Core Layer
[0078] The PatchTST core layer is the core modeling part of the network. Based on the PatchTST (Patch-based TemporalSelf-Attention Transformer) architecture, it contains four sub-modules: sequence segmentation module, PatchTST encoder module, feature fusion module, and prediction head module.
[0079] The sequence segmentation module is used to segment long temporal features into fixed-length "patches" (similar to image patches in an image), reducing the computational complexity of Transformer for long sequences. For example, for a temporal feature of "120 months", it is segmented into 10 patches according to "each patch contains 12 months of data", and each patch has a dimension of [12, number of features]. Each patch is converted into a fixed-dimensional vector through linear projection (such as from [12,2]→
[64] , which is convenient for subsequent attention calculation). The output of the sequence segmentation module is the segmented patch sequence, whose dimensions are: [number of samples, number of patches, patch vector dimension].
[0080] The PatchTST encoder module captures the temporal dependencies between patches through a multi-layer Transformer encoder, such as the correlation between the "summer sales patch" and the "autumn sales patch." Each Transformer encoder layer contains two core components: a multi-head self-attention mechanism and a feed-forward network. The multi-head self-attention mechanism calculates the association weights of each patch with all other patches; for example, it highlights the strong correlation between "one month before the Spring Festival" and "the month of the Spring Festival" through attention weights. The feed-forward network performs non-linear transformations on the attention output, such as using two linear layers plus ReLU activation to enhance feature representation. The output of the PatchTST encoder module is the multi-layer encoded patch features, with dimensions of [number of samples, number of patches, hidden layer dimension], containing temporal dependency information.
[0081] The feature fusion module integrates the encoded patch features into continuous temporal features, restoring the continuity of the time series. Specifically, it obtains fused features aligned with the input time step by concatenating patches, performing linear transformations, or upsampling (e.g., mapping the features of 10 patches back to a 120-month time series dimension). The output of the feature fusion module is the fused global temporal feature, with dimensions of [number of samples, time step, hidden layer dimension].
[0082] The prediction head module is used to perform regression prediction on the fused features, outputting the future time-series prediction results for three components. Structure: It consists of multiple linear layers + activation functions (such as ReLU). The last linear layer transforms the hidden layer features into the prediction target dimension (such as predicting the trend, seasonality, and residuals for the next 12 months) through linear mapping. The output of the prediction head module is the predicted values for the three components—Trend Prediction, Seasonality Prediction, and Residual Prediction—each with the dimension [number of samples, prediction step size, number of features], such as "future 12 months × 2 features".
[0083] 24. Ingredient Integration Layer
[0084] The component integration layer is used to recombine the prediction results of the three components into a final time series prediction, restoring the complete pattern of the original data. Specifically, the integration is performed according to the model (addition) during decomposition. For example, in the additive model: final prediction = trend prediction + seasonality prediction + residual prediction; the output of the component integration layer is the final prediction result after integration, with dimensions of [number of samples, prediction step size, number of features].
[0085] The following example illustrates the working process of the improved PatchTST model of this invention:
[0086] Taking "predicting sales for the next 12 months based on 120 months of sales data for a certain product (including seasonal fluctuations and long-term growth trends)" as an example, at the data decomposition layer: Original sales data (120 months) → decomposed into:
[0087] Trend item: Long-term growth curve (e.g., from 500 units per month to 1200 units per month);
[0088] Seasonal components: 12-month cycle fluctuations (e.g., sales in December are 30% higher than the average, and sales in February are 20% lower).
[0089] Residual term: random fluctuations (such as outliers in individual months caused by "sudden promotions").
[0090] In the feature processing layer, the sequence segmentation module divides the 120 months of features into 10 patches according to "12 months / patch" → each patch is converted into a 64-dimensional vector through linear projection → to obtain the patch sequence ([100, 10, 64]).
[0091] In the PatchTST encoding layer, multi-head self-attention calculates the association weights of 10 patches (e.g., the 10th patch (November-December) has a higher weight than the 9th patch (September-October)); the feedforward network performs a non-linear transformation on the attention output → after passing through 3 encoder layers, the encoded patch features ([100, 10, 128]) are obtained. The feature fusion module maps the 10 patch features back to a 120-month time series dimension → obtaining the fused features ([100, 120, 128]); the prediction module outputs trend predictions for the next 12 months (e.g., monthly growth to 1300 pieces), seasonality predictions (high in December, low in February), and residual predictions (random fluctuations ±50 pieces) through a linear layer.
[0092] At the component integration layer: Additive integration → Final forecast = Trend forecast + Seasonal forecast + Residual forecast → Obtain the sales forecast results for the next 12 months, such as 1,100 units in January, 950 units in February, and 1,600 units in December.
[0093] 3. Probability Prediction and Uncertainty Quantification
[0094] The training dataset is constructed using the features of the directly related historical raw material inventory data obtained in step 1, the external related data, and the three components obtained in step 21. The improved PatchTST model from step 2 is then trained based on the training dataset.
[0095] The improved PatchTST model outputs raw material demand distribution parameters, rather than single-point values:
[0096]
[0097] in, To predict variance, To predict the mean, , This is the final hidden state of the Transformer;
[0098] The training loss function is designed as a negative log-likelihood loss function:
[0099]
[0100] in, This represents the negative log-likelihood loss. The actual value (Target) Let represent the predicted mean at time t. This represents the standard deviation of the prediction at time t. This represents the constant term. Training stops when the negative log-likelihood loss converges. The meanings and values of each parameter are explained in Table 2.
[0101] Table 2. Explanation of Parameter Meaning and Value Selection Method
[0102]
[0103] The Adam optimizer and learning rate annealing strategy are used for parameter optimization. The specific parameter optimization process is a known existing technology and will not be described in detail here.
[0104] Example 2
[0105] like Figure 2 As shown, based on the improved PatchTST model in Example 1, a raw material characteristic encoder is designed to transform the physical characteristics (shelf life, batch size, supply chain characteristics) of different raw materials into feature vectors. This enhances the improved PatchTST model's ability to perceive raw material characteristics, allowing the model to better consider the differences and relationships between raw materials in subsequent processing.
[0106] Those skilled in the art should know that the improved PatchTST model cannot directly understand textual descriptions such as "short shelf life" or "large batch size" and must be converted into mathematical form.
[0107] Regarding the conversion of shelf life values, a normalization method is used, and the calculation formula is as follows: For example, raw material A (packaging material): has a short shelf life of only 30 days; normalized, it is: The improved PatchTST model interprets the following: values close to 0 indicate extremely high expiration rates, requiring short-term forecasting. For example, raw material B (a chemical raw material) has a long shelf life of 365 days; after normalization, it becomes: The improved PatchTST model can be understood as follows: a value of 1 indicates that the data can be stored for a long time and can focus on long-term trends.
[0108] The numerical conversion for batch specifications also adopts a normalization method, and the calculation formula is as follows: .
[0109] Regarding the numerical conversion of supply chain characteristics, one-hot encoding is used to transform non-numerical states (such as "high volatility" and "stable") into vectors, avoiding the model's mistaken assumption that "stable > high volatility" or vice versa. Conversion rule: High volatility = Stable = For example: Raw material A: High volatility Encoded as Raw material B: Stable supply chain Encoded as .
[0110] After the above numerical conversion, the characteristics related to each raw material are obtained. For example, the vector-related features of raw material A : (Meaning: short shelf life, small batch size, high volatility); Vector correlation characteristics of raw material B : (Meaning: long shelf life, large volume, stable).
[0111] Through formula To construct a type-aware layer, the features obtained after the feature processing layer will be processed. Characteristics related to raw materials Information such as the type and origin of raw materials is integrated and processed, and the results of the type-aware layer are output through the hyperbolic tangent activation function (Tanh).
[0112] The fusion effect of the type-aware layer: When the model processes data from raw material A and sees "0.08" (short shelf life) in the vector, the model will automatically adjust its attention mechanism, focusing more on short-term fluctuations and seasonal changes, while ignoring long-term historical trends. When the model processes data from raw material B and sees "1.0" (long shelf life) in the vector, the model will focus more on capturing long-term trends.
[0113] The output of the type-aware layer enters the subsequent PatchTST modeling process, which includes sequence segmentation, PatchTST encoder, attention mechanism, feature fusion and prediction head, and finally obtains the trend prediction, seasonality prediction and residual prediction results.
[0114] Example 3
[0115] Based on the improved PatchTST model in Example 1, an inventory constraint awareness mechanism is designed. The inventory constraint optimization layer, located after the model's prediction head and before the final output, is a crucial link connecting the model's prediction results with business decisions. Together with other modules of the model (such as the type awareness layer and the multi-timescale prediction mechanism), it constitutes a complete enterprise raw material prediction system. The inventory constraint optimization layer is a key optimization module designed for the actual scenario of enterprise inventory management, used to combine prediction results with inventory business constraints to improve the practicality of predictions.
[0116] The inventory constraint optimization layer serves as an extension module of the improved PatchTST model. It utilizes the formula... The original predicted values output by the improved PatchTST model Compared with current inventory levels Safety stock requirements Supply restrictions By combining business constraints, the forecast results are adjusted so that the forecast conforms to the time series pattern of the model and meets the actual constraints of enterprise inventory management (such as avoiding increased holding costs due to excessive inventory or stockout risks due to excessive inventory).
[0117] For example: Suppose the model predicts raw material C, and its business is shown in Table 3:
[0118] Table 3. Constraints and Value Methods for Raw Material C
[0119]
[0120] Step 1: Based on the output of the prediction header module of the improved PatchTST model, assume the predicted value for the "net demand" of raw material C next month is: This value represents the amount of consumption the market will need next month, as determined by the model based on purely historical data patterns.
[0121] Based on the information in the table above, the current inventory is 1200 units, the safety stock is 800 units, and the supply limit is 2000 units. The adjusted prediction process is as follows:
[0122] 1. Calculate the inventory deviation adjustment:
[0123] Current inventory is 400 units above safety stock, which is a positive buffer. Therefore, we can appropriately reduce the purchase recommendation by 40 units based on the original demand forecast to avoid overstocking. So this is a positive adjustment (+40).
[0124] 2. Calculate the supply restriction adjustment:
[0125] The supplier has the capacity to provide up to 2,000 units, which is a usable resource. To encourage the model to plan within its capacity, we provide a positive incentive (+100) so that the final recommended value tends to be closer to the supply ceiling, in case of potential unexpected demand.
[0126] 3. Calculate the adjusted forecast value:
[0127]
[0128] Step 2: Conduct compliance checks and output, and optimize the output layer. The system will then perform a final compliance check: Supply limit check: 1640 < 2000, supply limit met. MOQ check: 1640 ÷ 100 ≈ 16.4 lots, rounded up to 17 lots, final recommended purchase quantity is 1700 units.
[0129] Another scenario example: Current inventory is insufficient.
[0130] If current inventory (Below safety stock of 800), other conditions remain unchanged:
[0131] Inventory deviation adjustment:
[0132] Current inventory is below the safety stock level of 200 units, posing a risk of stockout. Therefore, we need to increase our procurement recommendation by 20 units based on the original demand forecast to quickly replenish to the safety level. So this is a negative adjustment (statistically -20, but the actual impact on demand is an increase).
[0133] Adjusted forecast values:
[0134] Through the specific data examples above, we can clearly see that business constraints (such as safety stock and supply limitations) are quantifiable management parameters derived from actual enterprise operations. The inventory constraint optimization layer is a post-decision processing module that integrates data-driven forecasts with business rules through an interpretable formula. The final output... It is no longer a purely statistical forecast, but a suggested value that incorporates the wisdom of business operations and can be directly used to guide procurement decisions. This design greatly enhances the practicality and operability of the forecasting system in actual business operations.
[0135] This invention provides strong support for enterprises' intelligent manufacturing and digital transformation, enabling precise, scientific, and automated raw material inventory management.
[0136] Those skilled in the art will recognize that the embodiments described herein are intended to help the reader understand the principles of the invention, and should be understood that the scope of protection of the invention is not limited to such specific statements and embodiments. Various modifications and variations can be made to the invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the invention should be included within the scope of the claims of the invention.
Claims
1. A method for predicting enterprise raw materials based on the PatchTST model, characterized in that, Raw material demand forecasting based on the improved PatchTST model; The prediction process includes: S1. Automatically collect historical raw material inventory data from the enterprise's ERP system, MES system, and supply chain management system, and preprocess the historical raw material inventory data to obtain the features and external related data directly associated with the historical raw material inventory data. S2. Construct an improved PatchTST model and predict raw material demand based on the improved PatchTST model; the improved PatchTST model includes: a data decomposition layer, a feature processing layer, a PatchTST core layer, and a component integration layer. The data decomposition layer is used to process the historical raw material inventory data automatically collected from the enterprise's ERP system, MES system, and supply chain management system into time series decomposition data; ultimately, the historical raw material inventory data is decomposed into three components: trend component, seasonal component, and residual component. The features of the directly related historical raw material inventory data obtained in step S1, the external related data, and the trend items, seasonal components, and residual items output by the data decomposition layer are input into the feature processing layer. The feature processing layer outputs trend features, seasonal features, and residual features. The core layer of PatchTST includes a sequence segmentation module, a PatchTST encoder module, a feature fusion module, and a prediction head module. The sequence segmentation module processes trend features, seasonal features, and residual features into fixed-length patch sequences. The PatchTST encoder module encodes each patch sequence and outputs the encoded patch features. The feature fusion module integrates the encoded patch features into continuous time-series features. The prediction head module performs regression prediction on the fused features and outputs the future time-series prediction results for the three components. The component integration layer is used to reassemble the prediction results of the three components into a final time series prediction; S3. Construct a training dataset by combining the features of the directly related historical raw material inventory data obtained in step S1 with external related data, as well as the trend terms, seasonal components, and residual terms output by the data decomposition layer. S4. Train the improved PatchTST model from step S2 based on the training dataset from step S3. S5. Output prediction results based on the improved PatchTST model after training is completed.
2. The enterprise raw material forecasting method based on the PatchTST model according to claim 1, characterized in that, The preprocessing process in step S1 is as follows: S11. First, an anomaly detection algorithm is used to clean the historical data of raw material inventory; S12. Standardize the cleaned data; S13. Based on feature engineering, obtain the features and external correlation data of the raw material inventory history data directly related to the data processed in step S12. Features directly related to historical raw material inventory data include: time characteristics, sliding window characteristics, and compression characteristics; external data includes: production characteristics, supply chain characteristics, and market characteristics.
3. The enterprise raw material forecasting method based on the PatchTST model according to claim 2, characterized in that, The time series decomposition process in the data decomposition layer is as follows: For historical raw material inventory data, the adaptive moving average method is used to extract the trend component; For historical raw material inventory data, a combination of Fourier transform and wavelet analysis was used to extract seasonal components; For historical raw material inventory data, the GARCH model is used to capture the clustering effect of trend term fluctuations and extract residual term components.
4. The enterprise raw material forecasting method based on the PatchTST model according to claim 3, characterized in that, The feature processing layer includes normalization, feature enhancement, and dimension alignment of its input in sequence.
5. The enterprise raw material forecasting method based on the PatchTST model according to claim 4, characterized in that, The PatchTST encoder module includes a multi-layer Transformer encoder. Each layer of the Transformer encoder contains two core components: a multi-head self-attention mechanism and a feedforward neural network. The multi-head self-attention mechanism is used to calculate the association weights of each patch with all other patches, and the feedforward neural network is used to perform a non-linear transformation on the attention output.
6. The enterprise raw material forecasting method based on the PatchTST model according to claim 5, characterized in that, The feature fusion module first concatenates the encoded Patch features, and then aligns the concatenated result with the input time step through linear transformation or upsampling, thereby outputting the fused features.
7. The enterprise raw material forecasting method based on the PatchTST model according to claim 6, characterized in that, The prediction head module consists of multiple linear layers and activation functions.
8. The enterprise raw material forecasting method based on the PatchTST model according to claim 7, characterized in that, It also includes a raw material property encoder, which converts the physical properties of different raw materials into feature vectors, and a type perceptron, which integrates the features output by the feature processing layer with the features related to the raw materials. The output of the type perceptron is used as the input of the PatchTST core layer.
9. A method for enterprise raw material forecasting based on the PatchTST model according to claim 7, characterized in that, It also includes an inventory constraint optimization layer, whose input is the output of the forecast head, and is used to combine the output of the forecast head with the current business constraints. The output of the inventory constraint optimization layer is used as the input of the component integration layer.
10. A raw material forecasting system for enterprises based on the PatchTST model, characterized in that, include: Data acquisition module, prediction module; The data acquisition module is used to acquire the features and externally related data of historical raw material inventory data that are directly associated with it. The prediction module uses an improved PatchTST model to predict the characteristics of directly related historical raw material inventory data and external related data obtained by the data acquisition module. The improved PatchTST model includes: a data decomposition layer, a feature processing layer, a PatchTST core layer, and a component integration layer. The data decomposition layer is used to process the historical raw material inventory data automatically collected from the enterprise's ERP system, MES system, and supply chain management system into time series decomposition data; ultimately, the historical raw material inventory data is decomposed into three components: trend component, seasonal component, and residual component. The features of the directly related historical raw material inventory data acquired by the data acquisition module, along with external related data, and the trend items, seasonal components, and residual items output by the data decomposition layer, are input into the feature processing layer. The feature processing layer outputs trend features, seasonal features, and residual features. The core layer of PatchTST includes a sequence segmentation module, a PatchTST encoder module, a feature fusion module, and a prediction head module. The sequence segmentation module processes trend features, seasonal features, and residual features into fixed-length patch sequences. The PatchTST encoder module encodes each patch sequence and outputs the encoded patch features. The feature fusion module integrates the encoded patch features into continuous time-series features. The prediction head module performs regression prediction on the fused features and outputs the future time-series prediction results for the three components. The component integration layer is used to reassemble the prediction results of the three components into a final time series prediction.