Methods, systems, and storage media for predicting and warning the prices of main building materials for road construction projects.
By using a Transformer encoder with time-slice modeling and causal constraints, the inconsistency problem of main material price data in road engineering was solved, achieving stable multi-source time-series data processing and efficient risk warning, generating interpretable prediction results and action recommendations.
Patent Information
- Application Number
- CN202611282623.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-24
- Publication Date
- 2026-11-17
AI Technical Summary
Existing road engineering material price data suffers from inconsistent sampling frequencies, missing values, abnormal fluctuations, and inconsistent unit calibers. Furthermore, existing software fails to effectively constrain time location, variable lag, and future information leakage when forecasting long-term series data. This results in low stability of computer processing of multi-source time series data and low traceability of prediction results, making it difficult to generate effective risk warning results.
By using time-slice modeling, causal constraints, and quantile output, time slices are generated through patch processing. A Transformer encoder is used for embedding and causal constraints. Combined with multi-layer self-attention and feedforward networks, predicted values and early warning results for multiple quantiles are output. Risk warnings are generated by combining business thresholds and policy libraries.
It improves the stability of computer processing of multi-source time series data and the traceability of prediction results, enhances the efficiency of early warning result generation, can automatically generate graded early warnings and action suggestions, and improves the interpretability of prediction results and the efficiency of systematic processing.
Smart Images

Figure CN123118141A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer artificial intelligence prediction and risk warning technology, and in particular to a method, system and storage medium for predicting and warning the prices of main materials for road engineering. Background Technology
[0002] Existing road construction material price data typically comes from multiple business systems and public data sources, resulting in issues such as inconsistent sampling frequencies, missing values, abnormal fluctuations, and inconsistent unit calibers.
[0003] When existing software predicts long-term series, if it does not constrain the time position, variable lag, and future information leakage, it is easy to reduce the stability of the computer's representation of intertemporal patterns.
[0004] Moreover, outputting only a single predicted value makes it difficult to provide the processor with uncertain results that can be invoked by risk rules.
[0005] Therefore, improving the stability of computer processing of multi-source time series data, the traceability of prediction results, and the efficiency of generating early warning results have become technical problems that urgently need to be solved by those skilled in the art. Summary of the Invention
[0006] In view of the above-mentioned deficiencies of the prior art, the present invention provides a method, system and storage medium for predicting the price of main materials for road engineering and risk warning. The purpose is to improve the stability of computer processing of multi-source time series data, the traceability of prediction results and the efficiency of generating warning results through time slice modeling, causal constraints and quantile output.
[0007] To achieve the above objectives, this invention discloses a method for predicting the price and providing risk warnings of main materials for road engineering. This method is a calculation and software application whereby users input parameters via a computer input device and obtain results after running the program. The method includes the following steps:
[0008] S101, Data Access and Governance, specifically:
[0009] Collect target material prices and exogenous variables through data interfaces, database connectors, or file parsing components;
[0010] The target main material price includes one or more of petroleum asphalt, asphalt mixture, steel, steel strand, cement, and ready-mixed concrete;
[0011] The exogenous variables include one or more of the following: PPI, M2, international crude oil prices, exchange rates, steel composite index, fixed asset investment, and freight rate index.
[0012] The collected target material prices and exogenous variables are mapped according to material code, specifications, unit of measurement, region, and sampling date.
[0013] Linear interpolation or forward imputation is used to fill in the missing target material prices and the missing exogenous variables;
[0014] The outliers in the target main material price and the exogenous variables are identified using the interquartile range method or a preset business threshold.
[0015] Convert data from different sources to preset units of measurement, material specifications, and price caliber including tax;
[0016] A time index is generated based on the sampling dates of the target main material prices and the exogenous variables;
[0017] The price sequence of the target main material price formed according to the time index and the exogenous variable sequence of the exogenous variable formed according to the time index are both resampled to the same weekly time granularity or the same monthly time granularity, aligned according to the corresponding time index, and the original timestamp is associated with the corresponding time index for storage, forming the target main material price sequence and exogenous variable sequence after being aligned at the same frequency;
[0018] S102. Time slice generation is performed using patch processing, specifically including:
[0019] Set the length and sliding step size for each segment;
[0020] The target main material price sequence and exogenous variable sequence after frequency alignment are divided into time slices according to the segment length and sliding step size to form a segment sequence;
[0021] A unique time position index and a relative position index within the segment are generated for each segment.
[0022] The Patch process involves dividing the continuous time series into several segments of a fixed length, i.e., several time slices, with each segment serving as a basic modeling unit.
[0023] S103. Embedding and positional encoding form multidimensional variables, specifically including:
[0024] The values in each time slice are standardized according to the mean and standard deviation of the training set, and the standardized values that exceed the preset upper and lower limits are truncated to the upper and lower limits to reduce the impact of extreme values on the embedding calculation.
[0025] Each of the aforementioned segments is mapped to a fixed-length embedding vector;
[0026] The embedding vector of each time slice is input into the Transformer prediction model, and one or more of absolute position encoding, intra-segment relative position encoding and periodic position encoding are superimposed on the embedding vector, so that the Transformer prediction model can distinguish the order and seasonal position of different time slices.
[0027] S104. Variable selection, specifically including:
[0028] Calculate the variable weights for the multidimensional variable set consisting of the target main material price and various exogenous variables, and weight the corresponding fragment embeddings according to the variable weights;
[0029] Output the weighted fragment embedding sequence;
[0030] The segment embedding is obtained by mapping the time slice in S103;
[0031] S105. Perform Transformer encoding and causal constraints on the embedding vector using Transformer encoder M5, specifically including:
[0032] Use causal masks to restrict attention to only accessing historical fragments;
[0033] Extracting long-term dependencies and patterns across fragments from multiple stacked layers;
[0034] The Transformer encoder is a sequence modeling backbone composed of multiple layers of self-attention and feedforward networks;
[0035] S106, Quantile Prediction Header Output, specifically includes:
[0036] The Transformer encoder outputs the input point prediction head, which represents the price of main materials in the next period or several future periods.
[0037] Input the representation output from the Transformer encoder into the quantile prediction head, and output the main material price prediction value at the preset quantile.
[0038] The quantile prediction head outputs at least three quantiles: 5%, 50%, and 95%. The 50% quantile is used as the median prediction value, and the 5% and 95% quantiles constitute the prediction interval.
[0039] The quantile prediction head is an output layer that outputs multiple preset quantile points in addition to point prediction, used to generate prediction intervals and risk warning inputs;
[0040] S107. Risk Coupling and Early Warning, specifically including:
[0041] Match the prediction interval with a threshold, budget, or strategy library to provide an alert level;
[0042] Generate action recommendations;
[0043] Output the point forecast value, forecast range, warning level, trigger rules and action suggestions to the dashboard, reports and upstream system interface.
[0044] Preferably, in S101, the interquartile range method determines the abnormal interval [Q1-1.5IQR, Q3+1.5IQR] according to the first quartile Q1, the third quartile Q3 and the interquartile range IQR=Q3-Q1;
[0045] The business threshold is a pre-configured allowable price range based on material category, region, and specifications;
[0046] The exogenous variables are: influencing factors other than the target main material price, including PPI, M2, international crude oil price, exchange rate, steel composite index, fixed asset investment, and freight rate index;
[0047] In S102, the length of each segment is 8 to 32.
[0048] When measured in weeks, the Patch Length is 8, 12, or 6.
[0049] When measured in months, the Patch Length is 6 or 12.
[0050] Each of the aforementioned sliding steps is: 1 to the corresponding segment length, Patch Length;
[0051] The Transformer encoder in step S105 includes 2 to 6 coding layers, each layer including a multi-head self-attention sub-layer and a feedforward network sub-layer;
[0052] The number of attention heads in the multi-head self-attention is 2 to 8, which serves as a parameter for encoding the weighted segment embedding in step S105;
[0053] Configure the time delay window according to the variable category before step S105;
[0054] In step S106, the set of quantiles output by the quantile prediction head is {5%, 50%, 95%};
[0055] During the model training phase, one or more strategies, such as early stopping, weight decay, and fragment-level random dropout, are used to suppress overfitting. After training is completed, the model parameters are stored and retrieved during the prediction phase.
[0056] In step S103, the time location information includes absolute, relative, or periodic encoding;
[0057] In step S103, one of linear mapping, lightweight one-dimensional convolution, or learnable dictionary encoding is selected to map each normalized time slice into a fixed-length embedding vector.
[0058] In step S103, time location information is injected into the embedding vector corresponding to each time slice using absolute encoding, relative encoding, and / or seasonal encoding.
[0059] The causal mask in step S105 is either a fixed mask or a learnable mask; the causal mask restricts the current time slice to only access the current and historical time slices, and penalizes intertemporal attention that does not conform to the preset time delay window through prior weights;
[0060] Step S106 uniformly adopts the quantile prediction head to output 5%, 50%, and 95% quantiles;
[0061] In step S107, the warning levels include green, yellow, orange, and red;
[0062] The proposed actions include locking in prices within a certain price range or initiating an evaluation of alternative materials two periods after the aforementioned warning level.
[0063] Preferably, in step S104, when the number of valid samples of an exogenous variable within a preset rolling window is lower than a threshold, its correlation with the target variable is lower than a threshold, or its prediction contribution is continuously lower than the minimum weight threshold, the gating weight of the corresponding exogenous variable is dynamically reduced.
[0064] When the number of valid samples of the exogenous variable within the preset rolling window, its correlation with the target variable, or its predictive contribution recovers to the preset range, the corresponding gating weight is increased.
[0065] Preferably, before performing step S105, a priori mask is generated based on business knowledge;
[0066] The prior mask is an attention visibility matrix generated based on the minimum and maximum effective lag periods between the exogenous variable and the target main material price;
[0067] When performing step S105, the prior mask and the causal mask are superimposed: the associated positions with a time lag less than the minimum effective time lag and the associated positions with a time lag greater than the maximum effective time lag are both masked, and the associated positions within the effective time lag window are allowed to participate in the attention calculation.
[0068] The superimposed mask can be used for attention calculation or as a learnable prior constraint switch.
[0069] Preferably, the variable selection and the gating are both set with a minimum weight threshold to prune redundant variables when they are opened or closed;
[0070] The minimum weight threshold is 0.5%, 1%, or 2%.
[0071] Preferably, step S105 employs L1 sparse regularization or attention weight threshold pruning to make the weights of low-contribution attention connections approach zero or be removed, thereby obtaining a sparse cross-segment dependency representation.
[0072] Preferably, online updates and retrospective assessments are also required, including:
[0073] Periodic rolling training or lightweight online updates;
[0074] Monitor prediction errors, early warning hit rates, and revenue simulations for adaptive updates of thresholds and hyperparameters;
[0075] The profit simulation includes historical backtesting of the price-locking strategy.
[0076] The present invention also provides a system for predicting the price of main materials for road engineering and risk warning, including a data access and governance module M1, a time slice generation module M2, an embedding and location encoding module M3, a variable selection / gating module M4, a Transformer encoder M5, a time delay and prior constraint module M6, a quantile prediction head module M7, a risk coupling and warning module M8, a business threshold library M9, and a visualization and interface module M10.
[0077] The data access and governance module M1 is used to collect the prices of main materials and exogenous variables, complete field mapping, outlier identification, missing value filling, time alignment and unit conversion, generate time series data, connect to data sources, including cost platform, statistical caliber library, self-built database, CSV / Excel, and output to the time slice (Patch) generation module M2.
[0078] The time slice (Patch) generation module M2 is used to divide the sequence into non-overlapping or partially overlapping time slices according to the set segment length and step size, and add time position indexes. It receives the time series data from the data access and management module M1 and outputs it to the embedding and position encoding module M3.
[0079] The embedding and position encoding module M3 is used to map each time slice to a fixed-length vector and add absolute position encoding, relative position encoding and / or periodic position encoding to the fixed-length vector to form a multidimensional variable for the Transformer prediction model to process; it receives the time slices output by M2 and outputs them to M4;
[0080] The variable selection / gating module M4 is used to perform weighted filtering of multidimensional variables and suppress noise or redundant variables; it can introduce soft gating or hard gating to exogenous variables to control their participation intensity at different time periods; it receives the output of M3 and outputs the processing results to the Transformer encoder M5;
[0081] Transformer encoder M5 is used for representation learning based on self-attention and combining causal mask and prior mask of M6 output, using only current and historical time slices to extract long-range dependencies, and sending the output representation to quantile prediction head module M7.
[0082] The time delay and prior constraint module M6 is used to set the visible minimum / maximum time delay window or causal direction for exogenous variables according to business knowledge; for example, oil prices lead by several periods to affect asphalt prices. It is embedded in the attention process of Transformer encoder M5, or as a pre-mask generator of Transformer encoder M5, outputting a mask to Transformer encoder M5.
[0083] The quantile prediction head module M7 is used to receive the output representation of the Transformer encoder M5 and output the predicted value of the main material price point for the next period or several periods, as well as the predicted values of the 5%, 50% and 95% quantiles. The 5% and 95% quantiles are used to form the prediction interval.
[0084] The risk coupling and early warning module M8 is used to match the forecast range with business thresholds, budget limits, and procurement strategy rules, triggering early warning levels and recommended actions, including "accelerate procurement" and "wait and see". It receives the output of the forecast header module M7, links with the business threshold library M9, and sends the results to the visualization and interface module M10.
[0085] The Business Threshold Library M9 is used to store thresholds, tolerance ranges, and extreme scenario configurations for categories / regions / projects, including databases for scenarios such as significant oil price fluctuations and monetary easing / tightening.
[0086] The visualization and interface module M10 is used to display historical / predictive curves, interval bands, early warning status, and contribution bar charts, and provides report export and API to upstream systems.
[0087] Preferably, a centralized server deployment or edge node deployment is adopted, either in a standalone or containerized microservice architecture;
[0088] The hardware includes at least a processor, memory, and a network interface;
[0089] The method for predicting the price of main materials for road engineering and risk warning is an executable instruction stored in memory in the form of software, which calls the data access and governance module M1, the time slice (Patch) generation module M2, the embedding and location encoding module M3, the variable selection / gating module M4, the Transformer encoder M5, the time delay and prior constraint module M6, the prediction head module M7, the risk coupling and warning module M8, the business threshold library M9, and the visualization and interface module M10.
[0090] The hardware's external data interface connects to external data sources, its internal bus connects the processor and memory, it is used for visualization via a display / web interface, and it provides REST / GraphQL interfaces to the outside world.
[0091] During runtime, the processor loads the method for predicting and risk warning of main materials prices for road engineering projects and outputs prediction results and warning information.
[0092] The present invention also provides a storage medium, including a hard disk, a solid-state drive, a ROM, RAM, an optical disk, or a flash memory, wherein program instructions are stored;
[0093] When the program instructions are executed by the processor, the above-mentioned method for predicting and warning the price of main materials for road engineering is implemented.
[0094] When executed by the processor, the method for predicting and warning the price of main materials for road engineering is completed, and prediction and warning results are generated.
[0095] The computer-readable medium contains a parameter configuration file including fragment length, time delay window, quantile set, warning threshold, and scene library index.
[0096] The beneficial effects of this invention are:
[0097] This invention integrates multi-source heterogeneous frequency data governance, time slice embedding, location encoding, variable gating, causal attention, and time-delay prior constraints into the same software processing flow, reducing future information leakage and interference from invalid variables; by simultaneously outputting point prediction values and prediction intervals through a quantile prediction head, the processor can automatically generate hierarchical warnings and action suggestions based on preset thresholds, improving the interpretability, traceability, and systematic processing efficiency of prediction results.
[0098] The following will further explain the concept, specific structure, and technical effects of the present invention in conjunction with the accompanying drawings, so as to fully understand the purpose, features, and effects of the present invention. Attached Figure Description
[0099] Figure 1 This diagram illustrates the module connection relationship of a road engineering main material price prediction and risk warning system according to an embodiment of the present invention.
[0100] Figure 2This diagram illustrates a flowchart of a method for predicting and warning the price of main materials for road engineering according to an embodiment of the present invention.
[0101] Figure 3 This diagram illustrates the processing relationship between time slices, causal masks, prior time delay constraints, and quantile prediction heads in one embodiment of the present invention. Detailed Implementation
[0102] Example: Figures 1 to 3 As shown, the method for predicting and warning the price of main materials for road engineering is executed by a computer. Users input material type, region, time granularity, number of prediction steps, and threshold parameters via input devices. The system outputs prediction results and warning information, including the following steps:
[0103] S101. Data Access and Governance: Collect prices of one or more main materials among petroleum asphalt, asphalt mixture, steel, steel strand, cement, and ready-mixed concrete, as well as exogenous variables, through the cost platform interface, enterprise internal database connector, and CSV / Excel file parsing component.
[0104] Field mapping is performed on the material code, specifications, unit of measurement, region, sampling date, and tax-inclusive caliber of the collected records; linear interpolation or forward imputation is performed on missing values; outliers are identified using interquartile range or preset business thresholds; and they are uniformly converted to preset units of measurement, specifications, and tax-inclusive caliber of prices.
[0105] A time index is generated based on the sampling date. Price records and exogenous variable records are resampled to a unified weekly or monthly frequency and aligned according to the time index. The original timestamp is stored in association with the aligned time index for traceability.
[0106] S102. Time slice generation is performed using patch processing, specifically including:
[0107] Set the length and sliding step size for each segment;
[0108] The target main material price sequence and exogenous variable sequence output by S101 are divided into time slices to form segment sequences.
[0109] A unique time position index and a relative position index within the segment are generated for each segment;
[0110] The patch process involves dividing the continuous time series into several segments of a fixed length, i.e., several time slices, with each segment serving as a basic modeling unit.
[0111] S103. Embedding and positional encoding form multidimensional variables, specifically including:
[0112] For each time slice, the statistics of the training set are standardized, and standardized values that exceed the preset upper and lower limits are truncated. This process reduces the impact of dimensional differences and extreme values on subsequent embedding calculations.
[0113] Map each segment to a fixed-length embedding vector;
[0114] Time slices are mapped to fixed-length embedding vectors, and one or more codes of absolute position, relative position within a slice, and periodic position are injected into the embedding vectors, enabling the Transformer prediction model to distinguish between slice order and seasonal position.
[0115] S104. Variable selection, specifically including:
[0116] The multidimensional variable set consisting of the target main material price and exogenous variables is weighted.
[0117] Output the weighted segment embedding sequence; the segment embedding is the result of S103 mapping the time slice into a fixed-length embedding vector;
[0118] S105. Perform Transformer encoding and causal constraints on the embedding vector using Transformer encoder M5, specifically including:
[0119] Use causal masks to restrict attention to only accessing historical fragments;
[0120] A causal mask is used to restrict access to the current moment and its historical fragments during attention computation, preventing information from "seeing the future".
[0121] Extracting long-term dependencies and patterns across fragments from multiple stacked layers;
[0122] The Transformer encoder is a sequence modeling backbone composed of multiple layers of self-attention and feedforward networks;
[0123] S106, Quantile Prediction Header Output, specifically includes:
[0124] Point Prediction Header: Outputs the point value of main material prices for the next period or several future periods;
[0125] The quantile prediction head outputs 5%, 50%, and 95% quantiles, with the 5% and 95% quantiles forming the prediction interval and the 50% quantile serving as the median prediction value.
[0126] The quantile prediction head outputs uncertainty results based on multiple preset quantiles for risk warning.
[0127] S107. Risk Coupling and Early Warning, specifically including:
[0128] Match the prediction interval with a threshold, budget, or strategy library to provide an alert level;
[0129] Generate action recommendations;
[0130] Output the point forecast value, forecast range, warning level, trigger rules and action suggestions to the dashboard, reports and upstream system interface.
[0131] In some embodiments, missing values in S101 are filled by linear interpolation or forward filling; outliers are identified by interquartile range outlier intervals [Q1-1.5IQR, Q3+1.5IQR] or by business thresholds configured by material category, region and specification.
[0132] Exogenous variables are: factors other than the target main material price, including PPI, M2, international crude oil price, exchange rate, steel composite index, fixed asset investment, and freight rate index;
[0133] In S102, the length of each segment is 8 to 32.
[0134] When measured in weeks, the Patch Length is 8, 12, or 6.
[0135] When measured in months, the Patch Length is 6 or 12.
[0136] Each sliding step is: 1 to the length of the corresponding segment, Patch Length;
[0137] The Transformer encoder in step S105 includes 2 to 6 encoding layers.
[0138] In step S105, the number of attention heads in multi-head self-attention is 2 to 8.
[0139] Configure the variable lag window before step S105. For example, the effective lag window for international crude oil prices to asphalt prices is 1 to 6 periods, the effective lag window for exchange rates is 1 to 3 periods, and the effective lag window for PPI is 1 to 4 periods.
[0140] The quantile set for step S106 is {5%, 50%, 95%}.
[0141] The model training phase employs early stopping, weight decay, and optional fragment-level random dropout strategies; after training is complete, the validation set is used to select parameters and save the model.
[0142] In step S103, the time location information includes absolute, relative, or periodic encoding;
[0143] In step S103, one of linear mapping, lightweight one-dimensional convolution, or learnable dictionary encoding is selected to map the normalized time slice into a fixed-length embedding vector.
[0144] In step S103, time position information is injected into the embedding vector corresponding to each time slice using absolute encoding, relative encoding, and / or seasonal encoding.
[0145] The causal mask in step S105 can be a fixed mask or a learnable mask; the causal mask restricts the current time slice to access only the current and historical time slices, and can be superimposed with a priori masks.
[0146] Step S106 uniformly adopts the quantile prediction head, outputting 5%, 50% and 95% quantiles.
[0147] The warning levels in step S107 include green, yellow, orange, and red.
[0148] Action recommendations include locking in prices within a certain price range or initiating an evaluation of alternative materials two phases after a red alert level.
[0149] In some embodiments, when the number of effective samples, correlation, or predictive contribution of an exogenous variable does not meet a preset threshold, step S104 dynamically reduces its gating weight; when the indicator recovers, its gating weight is increased, thereby adapting to the changes in the effectiveness of the exogenous variable at different times.
[0150] Variable selection / gating involves weighting the contributions of different variables in a multidimensional input and suppressing noisy variables.
[0151] In some embodiments, prior masks are generated based on business knowledge before performing step S105; the prior masks are generated according to the minimum effective lag and the maximum effective lag of each exogenous variable.
[0152] When performing step S105, the prior mask and the causal mask are superimposed; positions smaller than the minimum effective lag period and larger than the maximum effective lag period are masked, and positions within the effective lag window are allowed to participate in attention calculation.
[0153] Finally, the mask is applied to attention computation or as a learnable prior constraint switch.
[0154] In some embodiments, a minimum weight threshold is set for variable selection and for gating to prune redundant variables when it is turned on or off;
[0155] The minimum weight threshold can be set to 0.5%, 1%, or 2%.
[0156] In some embodiments, step S105 employs L1 sparse regularization or attention weight threshold pruning to obtain sparse cross-segment attention connections.
[0157] In practical applications, the above steps work in conjunction with the variable-level gating in step S104 to act on attention connections and input variables, respectively.
[0158] L1 sparse regularization adds a penalty term to the training loss function, which is the sum of the absolute values of the attention weights, causing the weights of low-contribution connections to approach zero.
[0159] In some embodiments, online updates and retrospective evaluations are also required, including:
[0160] Periodic rolling training or lightweight online updates;
[0161] Monitor prediction errors, early warning hit rates, and revenue simulations for adaptive updates of thresholds and hyperparameters;
[0162] The profit simulation includes historical backtesting of the price lock-in strategy.
[0163] In some embodiments, the threshold matching in step S107 can be replaced by a payoff function scoring based on opportunity cost or a triggering rule based on Monte Carlo scenario simulation; fragment masking reconstruction can be used for self-supervised pre-training during the training phase, and then fine-tuned for the price prediction task.
[0164] The present invention also provides a system for predicting the price of main materials for road engineering and risk warning, including a data access and governance module M1, a time slice generation module M2, an embedding and location encoding module M3, a variable selection / gating module M4, a Transformer encoder M5, a time delay and prior constraint module M6, a quantile prediction head module M7, a risk coupling and warning module M8, a business threshold library M9, and a visualization and interface module M10.
[0165] The data access and governance module M1 is used to collect the prices of main materials and exogenous variables, complete field mapping, outlier identification, missing value filling, time alignment and unit conversion, generate time series data, connect to data sources, including cost platform, statistical caliber library, self-built database, CSV / Excel, and output to the time slice (Patch) generation module M2.
[0166] The time slice (Patch) generation module M2 is used to divide the sequence into non-overlapping or partially overlapping time slices according to the set segment length and step size, and add time position indexes. It receives the time series data from the data access and management module M1 and outputs it to the embedding and position encoding module M3.
[0167] The embedding and position encoding module M3 is used to map each time slice into a fixed-length vector and add absolute position, relative position and / or periodic position encoding, so that the Transformer prediction model can identify the sequential relationship and seasonal position of the segments in the global sequence, forming multidimensional variables.
[0168] The variable selection / gating module M4 is used to perform weighted filtering of multidimensional variables and suppress noise or redundant variables; it can introduce soft gating or hard gating to exogenous variables to control their participation intensity at different time periods, receive the output of M3 and output the processing results to the Transformer encoder M5.
[0169] Transformer encoder M5 is used for representation learning based on self-attention, causal masking, and prior masking from the output of M6. It only uses current and historical segments to extract long-range dependencies and sends the output representation to quantile prediction head module M7.
[0170] The time delay and prior constraint module M6 is used to set the visible minimum / maximum time delay window or causal direction for exogenous variables according to business knowledge; for example, oil prices lead by several periods to affect asphalt prices. It is embedded in the attention process of Transformer encoder M5, or as a pre-mask generator of Transformer encoder M5, outputting a mask to Transformer encoder M5.
[0171] The prediction head module M7 is used to receive the output representation of the Transformer encoder M5 and output the predicted value of the main material price point for the next one or several steps, as well as the predicted values of the 5%, 50% and 95% percentiles, where the 5% and 95% percentiles are used to form the prediction interval.
[0172] The risk coupling and early warning module M8 is used to match the prediction range with business thresholds, budget limits, and procurement strategy rules, trigger early warning levels and suggested actions (such as "accelerate procurement" and "wait and see"), receive the output of the prediction header module M7, link with the business threshold library M9, and send the results to the visualization and interface module M10.
[0173] The Business Threshold Library M9 is a database used to store thresholds, tolerance ranges, and extreme scenario configurations (such as large fluctuations in oil prices, monetary easing / tightening) at the category / region / project level.
[0174] The visualization and interface module M10 is used to display historical / predictive curves, interval bands, early warning status, and contribution bar charts, and provides report export and API to upstream systems.
[0175] In some embodiments, a centralized server deployment or edge node deployment is used, either as a standalone machine or containerized with a microservice architecture;
[0176] The hardware includes at least a processor, memory, and a network interface;
[0177] The method for predicting the price of main materials for road engineering and risk warning is an executable instruction stored in memory in the form of software, which calls the data access and governance module M1, the time slice (Patch) generation module M2, the embedding and location encoding module M3, the variable selection / gating module M4, the Transformer encoder M5, the time delay and prior constraint module M6, the prediction head module M7, the risk coupling and warning module M8, the business threshold library M9, and the visualization and interface module M10.
[0178] The hardware's external data interface connects to external data sources, its internal bus connects the processor and memory, it is used for visualization via a display / web interface, and it provides REST / GraphQL interfaces to the outside world.
[0179] During runtime, the processor loads the method for predicting and risk warning of main materials prices for road engineering projects and outputs prediction results and warning information.
[0180] The present invention also provides a storage medium, including a hard disk, a solid-state drive, a ROM, RAM, an optical disk, or a flash memory, wherein program instructions are stored;
[0181] When the program instructions are executed by the processor, the above-mentioned method for predicting and warning the price of main materials for road engineering is implemented.
[0182] When executed by the processor, the method for predicting the price of main materials for road engineering and providing risk warnings is completed, and the prediction and warning results are generated.
[0183] The computer-readable medium contains parameter configuration files including fragment length, time delay window, quantile set, warning threshold, and scene library index.
[0184] In practical applications, computer-readable media containing parameter configuration files, including fragment length, time delay window, quantile set, warning threshold, and scene library index, can achieve rapid reproduction.
[0185] The specific workflow of this invention is as follows:
[0186] 1. Patch generation and embedding (located between the input and the backbone) includes:
[0187] Input: Time series of continuous prices and exogenous variables;
[0188] Processing: Slicing → Standardization → Linear mapping or lightweight convolution to form fragment vectors;
[0189] Output: A sequence of vector segments of equal length.
[0190] Its function is to break down long sequences into approximately independent learnable units, enhance local pattern extraction, and reduce the risk of overfitting.
[0191] 2. Variable selection / gating (between the embedding and the encoder) includes:
[0192] Input: Fragment vector and variable weight parameters;
[0193] Processing: Weighted fusion of each variable dimension;
[0194] Output: The denoised embedding sequence;
[0195] Its function is to improve the effective utilization of exogenous variables and reduce the interference of noise variables.
[0196] 3. The Transformer encoder (backbone) includes:
[0197] Input: Weighted embedding sequence + causal mask;
[0198] Processing: Layer-by-layer self-attention and feedforward;
[0199] Output: A high-level representation of each fragment;
[0200] Its function is to model long-distance dependencies, periodic and structural changes.
[0201] 4. Time-delay / causal priors (coupled with the encoder) include:
[0202] Input: The mask generated by the business rules;
[0203] Process: Limit the visible windows for different variables;
[0204] Output: Constrained attention map;
[0205] Its function is to explicitly inject industry knowledge and avoid erroneous attention caused by "pseudo-relevance".
[0206] 5. The prediction head (located on the output side) includes:
[0207] Point prediction head: Output point values of the multilayer sensing unit;
[0208] Uncertainty head: Multi-head or multi-branch output quantiles / distribution parameters;
[0209] Function: Provides both point values and ranges to meet risk control requirements.
[0210] The working principle of this invention is as follows:
[0211] 1. Patch segmentation + causal attention: Model long sequences with fragments, combine causal constraints to prevent future leakage, and improve stability and generalization.
[0212] 2. Variable selection / gating + time-delay prior: Explicitly utilize industry knowledge and time-delay patterns to reduce spurious correlations and enhance the efficiency of exogenous variable utilization.
[0213] 3. Quantile / Distribution Output: Improved from "only providing point values" to "providing intervals / confidence bands + scenario-based output", directly serving early warning and strategy.
[0214] 4. Integrated closed loop: Prediction, uncertainty, threshold / scenario, early warning, and suggestions are all completed within a single system, making it easy to implement in engineering projects.
[0215] Example 2: Price forecasting and risk warning for main materials in municipal road engineering (such as petroleum asphalt, steel, steel strand, etc.), using a single time granularity (e.g., weekly or monthly frequency), and optionally introducing exogenous variables (such as PPI, M2, international crude oil price, exchange rate, steel composite index, freight rate index, fixed asset investment, etc.).
[0216] S101 Data Access and Governance;
[0217] Static relationships: Data sources include cost estimation platform interfaces, internal enterprise databases, and files (CSV / Excel). Dynamic relationships:
[0218] The main material prices and exogenous variables are retrieved using the data acquisition adapter;
[0219] Perform missing fill (such as forward fill), outlier identification (such as threshold rules based on interquartile range IQR), and unify units / calibers;
[0220] All data is resampled to a uniform time granularity to form time series aligned with the same frequency. The effect is to output clean, consistent, and auditable historical sequences, eliminating the interference of differences in data caliber on model training.
[0221] S102 Time slice (Patch) generation;
[0222] Static Relationship: Set the segment length and sliding step size (e.g., segment length 12, step size 4). Dynamic Relationship: Divide the sequence into continuous segments according to the settings, forming a segment sequence, and assign a global time index and an intra-segment relative position index to each segment. Effect: Decompose long sequences into learnable basic units, making it easier to capture local patterns and reduce the risk of overfitting.
[0223] S103 Embedding and Position Encoding;
[0224] Static relationships: A combination of segment vectorization module and time-position encoding (absolute / relative / periodic encoding). Dynamic relationships: Each segment is normalized and truncated to its amplitude, then mapped to a fixed-length vector, and time-position encoding is superimposed. Effects: Unifies segment dimensions and explicitly injects temporal order and seasonal location information.
[0225] S104 Variable selection / gating (optional);
[0226] Static relationship: The gating unit is located after embedding and before the encoder. Dynamic relationship: Time-varying weights are applied to multidimensional inputs (including exogenous variables), weakening noisy variables and highlighting key factors; minimum thresholds can be set for weights to prune redundancy. Effects: Improves the efficiency of exogenous variable utilization and reduces the impact of spurious correlations.
[0227] S105 Transformer encoding (including causal constraints);
[0228] Static relationships: Encoders are stacked with 2–6 layers, and self-attention only allows "seeing the past". Dynamic relationships: Attention based on causal masks establishes long-distance dependencies between segments, extracting trends, seasonality, and structural changes. Effects: Ensures temporal causality and enhances the ability to model long dependencies.
[0229] S106 Time Delay and Prior Constraints (Optional);
[0230] Static relationship: The "prior mask" generated by business rules is coupled with the attention calculation of S105.
[0231] Dynamic relationships: For example, the effective lag window for oil prices to asphalt prices is defined as 1–6 periods; the encoder focuses only within this allowed window during the attention phase. Effects: Explicitly injects industry knowledge, suppresses ineffective or "future-gazing" attention, and reduces spurious correlations.
[0232] S107 Prediction Head Output;
[0233] Static relationship: Two heads in parallel – the point prediction head and the uncertainty head. Dynamic relationship:
[0234] The point prediction header outputs the point values of main material prices for the next few periods;
[0235] The uncertainty header outputs multiple quantiles (e.g., 5%, 50%, 95%) or distribution parameters to form prediction intervals and confidence bands. Its effect is to simultaneously obtain point values and interval estimates, meeting risk control requirements.
[0236] S108 Risk Coupling and Early Warning;
[0237] Static Relationship: Connects to the threshold / scenario library. Dynamic Relationship: Matches the prediction range with the budget / threshold / strategy rules to generate early warning levels (green / yellow / orange / red) and action suggestions (such as locking in prices when the opportunity arises, waiting and seeing, evaluating alternative materials, etc.), and pushes them to the visualization and reporting interface. Effect: Forms an integrated closed loop of prediction—uncertainty—threshold / scenario—early warning—suggestions.
[0238] Terminology and Abbreviations (Industry-standard Chinese names);
[0239] Patch (time slice): A segment of a time series divided into fixed lengths.
[0240] Transformer encoder: a sequence modeling backbone consisting of stacked self-attention and feedforward networks.
[0241] Causal Mask: A masking mechanism that restricts attention to access only current and historical information.
[0242] Variable selection / gating: A mechanism for weighted selection of multidimensional variables.
[0243] PPI (Producer Price Index); M2 (broad money supply);
[0244] CRPS (Continuous Ranked Probability Score).
[0245] Pinball loss: A commonly used loss function in quantile regression.
[0246] The preferred embodiments of the present invention have been described in detail above. It should be understood that those skilled in the art can make numerous modifications and variations based on the concept of the present invention without creative effort. Therefore, all technical solutions that can be obtained by those skilled in the art based on the concept of the present invention through logical analysis, reasoning, or limited experimentation on the basis of existing technology should be within the scope of protection defined by the claims.
Claims
1. A method for predicting the price of main materials for road engineering and early warning of risks, characterized in that, This is a calculation and software program that allows users to input parameters via a computer input device and obtain results after running the program, including the following steps: S101, Data Access and Governance, specifically: Collect target material prices and exogenous variables through data interfaces, database connectors, or file parsing components; The target main material price includes one or more of petroleum asphalt, asphalt mixture, steel, steel strand, cement, and ready-mixed concrete; The exogenous variables include one or more of the following: PPI, M2, international crude oil prices, exchange rates, steel composite index, fixed asset investment, and freight rate index. The collected target material prices and exogenous variables are mapped according to material code, specifications, unit of measurement, region, and sampling date. Linear interpolation or forward imputation is used to fill in the missing target material prices and the missing exogenous variables; The outliers in the target main material price and the exogenous variables are identified using the interquartile range method or a preset business threshold. Convert data from different sources to preset units of measurement, material specifications, and price caliber including tax; A time index is generated based on the sampling dates of the target main material prices and the exogenous variables; The price sequence of the target main material price formed according to the time index and the exogenous variable sequence of the exogenous variable formed according to the time index are both resampled to the same weekly time granularity or the same monthly time granularity, aligned according to the corresponding time index, and the original timestamp is associated with the corresponding time index for storage, forming the target main material price sequence and exogenous variable sequence after being aligned at the same frequency; S102. Time slice generation is performed using patch processing, specifically including: Set the length and sliding step size for each segment; The target main material price sequence and exogenous variable sequence after frequency alignment are divided into time slices according to the segment length and sliding step size to form a segment sequence; A unique time position index and a relative position index within the segment are generated for each segment. The Patch process involves dividing the continuous time series into several segments of a fixed length, i.e., several time slices, with each segment serving as a basic modeling unit. S103. Embedding and positional encoding form multidimensional variables, specifically including: The values in each time slice are standardized according to the mean and standard deviation of the training set, and the standardized values that exceed the preset upper and lower limits are truncated to the upper and lower limits to reduce the impact of extreme values on the embedding calculation. Each of the aforementioned segments is mapped to a fixed-length embedding vector; The embedding vector of each time slice is input into the Transformer prediction model, and one or more of absolute position encoding, intra-segment relative position encoding and periodic position encoding are superimposed on the embedding vector, so that the Transformer prediction model can distinguish the order and seasonal position of different time slices. S104. Variable selection, specifically including: Calculate the variable weights for the multidimensional variable set consisting of the target main material price and various exogenous variables, and weight the corresponding fragment embeddings according to the variable weights; Output the weighted fragment embedding sequence; The segment embedding is obtained by mapping the time slice in S103; S105. Perform Transformer encoding and causal constraints on the embedding vector using Transformer encoder M5, specifically including: Use causal masks to restrict attention to only accessing historical fragments; Extracting long-term dependencies and patterns across fragments from multiple stacked layers; The Transformer encoder is a sequence modeling backbone composed of multiple layers of self-attention and feedforward networks; S106, Quantile Prediction Header Output, specifically includes: The Transformer encoder outputs the input point prediction head, which represents the price of main materials in the next period or several future periods. Input the representation output from the Transformer encoder into the quantile prediction head, and output the main material price prediction value at the preset quantile. The quantile prediction head outputs at least three quantiles: 5%, 50%, and 95%. The 50% quantile is used as the median prediction value, and the 5% and 95% quantiles constitute the prediction interval. The quantile prediction head is an output layer that outputs multiple preset quantile points in addition to point prediction, used to generate prediction intervals and risk warning inputs; S107. Risk Coupling and Early Warning, specifically including: Match the prediction interval with a threshold, budget, or strategy library to provide an alert level; Generate action recommendations; Output the point forecast value, forecast range, warning level, trigger rules and action suggestions to the dashboard, reports and upstream system interface.
2. The road engineering main material price prediction and risk early warning method of claim 1, characterized in that, In S101, the interquartile range method determines the abnormal interval [Q1-1.5IQR, Q3+1.5IQR] according to the first quartile Q1, the third quartile Q3, and the interquartile range IQR=Q3-Q1; The business threshold is a pre-configured allowable price range based on material category, region, and specifications; The exogenous variables are: influencing factors other than the target main material price, including PPI, M2, international crude oil price, exchange rate, steel composite index, fixed asset investment, and freight rate index; In S102, the length of each segment is 8 to 32. When measured in weeks, the Patch Length is 8, 12, or 6. When measured in months, the Patch Length is 6 or 12. Each of the aforementioned sliding steps is: 1 to the corresponding segment length, Patch Length; The Transformer encoder in step S105 includes 2 to 6 coding layers, each layer including a multi-head self-attention sub-layer and a feedforward network sub-layer; The number of attention heads in the multi-head self-attention is 2 to 8, which serves as a parameter for encoding the weighted segment embedding in step S105; Configure the time delay window according to the variable category before step S105; In step S106, the set of quantiles output by the quantile prediction head is {5%, 50%, 95%}; During the model training phase, one or more strategies, such as early stopping, weight decay, and fragment-level random dropout, are used to suppress overfitting. After training is completed, the model parameters are stored and retrieved during the prediction phase. In step S103, the time location information includes absolute, relative, or periodic encoding; In step S103, one of linear mapping, lightweight one-dimensional convolution, or learnable dictionary encoding is selected to map each normalized time slice into a fixed-length embedding vector. In step S103, time location information is injected into the embedding vector corresponding to each time slice using absolute encoding, relative encoding, and / or seasonal encoding. The causal mask in step S105 is either a fixed mask or a learnable mask; the causal mask restricts the current time slice to only access the current and historical time slices, and penalizes intertemporal attention that does not conform to the preset time delay window through prior weights; Step S106 uniformly adopts the quantile prediction head to output 5%, 50%, and 95% quantiles; In step S107, the warning levels include green, yellow, orange, and red; The proposed actions include locking in prices within a certain price range or initiating an evaluation of alternative materials two periods after the aforementioned warning level.
3. The road engineering main material price prediction and risk early warning method of claim 1, wherein In step S104, when the number of valid samples of an exogenous variable within a preset rolling window is lower than a threshold, its correlation with the target variable is lower than a threshold, or its prediction contribution is continuously lower than the minimum weight threshold, the gating weight of the corresponding exogenous variable is dynamically reduced. When the number of valid samples of the exogenous variable within the preset rolling window, its correlation with the target variable, or its predictive contribution recovers to the preset range, the corresponding gating weight is increased.
4. The road engineering main material price prediction and risk early warning method of claim 1, wherein Before executing step S105, a priori mask is generated based on business knowledge; The prior mask is an attention visibility matrix generated based on the minimum and maximum effective lag periods between the exogenous variable and the target main material price; When performing step S105, the prior mask and the causal mask are superimposed: the associated positions with a time lag less than the minimum effective time lag and the associated positions with a time lag greater than the maximum effective time lag are both masked, and the associated positions within the effective time lag window are allowed to participate in the attention calculation. The superimposed mask can be used for attention calculation or as a learnable prior constraint switch.
5. The road engineering main material price prediction and risk early warning method of claim 4, wherein, The variable selection and the gating are both set with a minimum weight threshold to prune redundant variables when they are opened or closed. The minimum weight threshold is 0.5%, 1%, or 2%.
6. The road engineering main material price prediction and risk early warning method of claim 1, wherein, Step S105 employs L1 sparse regularization or attention weight threshold pruning to make the weights of low-contribution attention connections approach zero or remove them, thereby obtaining a sparse cross-segment dependency representation.
7. The road engineering main material price prediction and risk early warning method of claim 1, wherein, Online updates and retrospective assessments are also required, including: Periodic rolling training or lightweight online updates; Monitor prediction errors, early warning hit rates, and revenue simulations for adaptive updates of thresholds and hyperparameters; The profit simulation includes historical backtesting of the price-locking strategy.
8. A system for road engineering main material price prediction and risk warning method, characterized by, include: The modules are: Data Access and Governance Module M1, Time Slice Generation Module M2, Embedding and Location Encoding Module M3, Variable Selection / Gating Module M4, Transformer Encoder Module M5, Time Delay and Prior Constraint Module M6, Quantile Prediction Head Module M7, Risk Coupling and Early Warning Module M8, Business Threshold Library M9, and Visualization and Interface Module M10. The data access and governance module M1 is used to collect the prices of main materials and exogenous variables, complete field mapping, outlier identification, missing value filling, time alignment and unit conversion, generate time series data, connect to data sources, including cost platform, statistical caliber library, self-built database, CSV / Excel, and output to the time slice (Patch) generation module M2. The time slice (Patch) generation module M2 is used to divide the sequence into non-overlapping or partially overlapping time slices according to the set segment length and step size, and add time position indexes. It receives the time series data from the data access and management module M1 and outputs it to the embedding and position encoding module M3. The embedding and position encoding module M3 is used to map each time slice into a fixed-length vector and add absolute position, relative position and / or periodic position encoding, so that the Transformer prediction model can identify the sequential relationship and seasonal position of the segments in the global sequence, forming multidimensional variables; The variable selection / gating module M4 is used to perform weighted filtering of multidimensional variables and suppress noise or redundant variables; it can introduce soft gating or hard gating to exogenous variables to control their participation intensity at different time periods, receive the output of M3 and output the processing result to the Transformer encoder M5; Transformer encoder M5 is used for representation learning based on self-attention, causal masking and prior masking of M6 output, using only current and historical segments to extract long-range dependencies, and sending the output representation to quantile prediction head module M7. The time delay and prior constraint module M6 is used to set the visible minimum / maximum time delay window or causal direction for exogenous variables according to business knowledge; for example, oil prices lead by several periods to affect asphalt prices. It is embedded in the attention process of Transformer encoder M5, or as a pre-mask generator of Transformer encoder M5, outputting a mask to Transformer encoder M5. The prediction head module M7 is used to receive the output representation of the Transformer encoder M5 and output the predicted value of the main material price point for the next one or several steps, as well as the predicted values of the 5%, 50% and 95% percentiles, where the 5% and 95% percentiles are used to form the prediction interval. The risk coupling and early warning module M8 is used to match the prediction range with business thresholds, budget limits, and procurement strategy rules, trigger early warning levels and suggested actions, receive the output of the prediction header module M7, link with the business threshold library M9, and send the results to the visualization and interface module M10. The Business Threshold Library M9 is a database used to store thresholds, tolerance ranges, and extreme scenario configurations for categories / regions / projects, including situations such as significant fluctuations in oil prices and monetary easing / tightening. The visualization and interface module M10 is used to display historical / predictive curves, interval bands, early warning status, and contribution bar charts, and provides report export and API to upstream systems.
9. The road engineering main material price prediction and risk early warning method system of claim 8, wherein, It can be deployed using centralized servers or edge nodes, in standalone or containerized and microservice architectures; The hardware includes at least a processor, memory, and a network interface; The method for predicting the price of main materials for road engineering and risk warning is an executable instruction stored in memory in the form of software, which calls the data access and governance module M1, the time slice (Patch) generation module M2, the embedding and location encoding module M3, the variable selection / gating module M4, the Transformer encoder M5, the time delay and prior constraint module M6, the prediction head module M7, the risk coupling and warning module M8, the business threshold library M9, and the visualization and interface module M10. The hardware's external data interface connects to external data sources, its internal bus connects the processor and memory, it is used for visualization via a display / web interface, and it provides REST / GraphQL interfaces to the outside world. During runtime, the processor loads the method for predicting and risk warning of main materials prices for road engineering projects and outputs prediction results and warning information.
10. Storage medium, characterized in that This includes hard drives, solid-state drives, ROM, RAM, optical discs, or flash memory, which store program instructions; When the program instructions are executed by the processor, the method for predicting and warning the price of main materials for road engineering as described in any one of claims 1 to 7 is implemented. When executed by the processor, the method for predicting and warning the price of main materials for road engineering is completed, and prediction and warning results are generated. The computer-readable medium contains a parameter configuration file including fragment length, time delay window, quantile set, warning threshold, and scene library index.
