A Software Cost Measurement Method and System Based on Artificial Intelligence
By constructing resource consumption dependency graphs and causal graphs, and combining blockchain technology and smart contracts, the problem of isolated cost monitoring in existing technologies is solved, enabling accurate cost attribution and real-time optimization in a microservice architecture.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- 江苏省软件产品检测中心
- Filing Date
- 2026-07-02
- Publication Date
- 2026-07-31
AI Technical Summary
Existing cost monitoring methods struggle to automatically build dynamic dependency topologies between multiple levels in complex microservice architectures, resulting in cost data silos, a lack of causal inference capabilities, difficulty in accurately pinpointing specific business causes of resource consumption, and the risk of data tampering, as well as a lack of automated and real-time auditing capabilities.
By collecting structured events related to software resource consumption, a resource consumption dependency graph is constructed and transformed into a structural causal graph. Causal paths between variables are identified, a cost attribution model is built, and blockchain technology is used for evidence storage and smart contract monitoring to generate dynamic budgets in real time and optimize them.
It improves the accuracy of cost attribution and the credibility of data, achieves full traceability and verifiability of cost flow, and ensures the accuracy of budget execution.
Smart Images

Figure CN122492282A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of software cost measurement technology, and in particular to a software cost measurement method and system based on artificial intelligence. Background Technology
[0002] In the current digital technology field, with the widespread application of cloud computing, microservice architecture, and containerization technology, the complexity of enterprise IT infrastructure is increasing exponentially. Although existing cost management and resource operation technologies have achieved basic digital metering, significant technical bottlenecks still exist when facing highly dynamic and fine-grained complex systems.
[0003] Existing cost monitoring methods largely rely on static labels or billing data provided by cloud vendors, lacking a deep understanding of the correlation between underlying resource consumption and upper-level business logic. In microservice architectures, the call chains between services are intricate, and existing technologies struggle to automatically construct dynamic dependency topologies between multiple levels. This results in cost data often existing in silos, making it impossible to accurately pinpoint the specific business causes of resource consumption. Mainstream cost analysis methods are primarily based on statistical correlation analysis, inferring causes by observing synchronous trends in indicators. However, in complex distributed systems, numerous confounding variables exist, such as fluctuations in business traffic and changes in system load. Correlation does not equate to causation, and these methods lack the ability for in-depth analysis based on causal inference. They struggle to accurately quantify the true marginal effect of specific code defects, resource allocation strategies, or business behaviors on costs after eliminating confounding factors, leading to optimization decisions often relying on experience rather than scientific data. Traditional centralized database storage methods expose cost records to the risk of tampering or manipulation, and make it difficult to trace the evolution of historical states. Existing analytical methods mostly rely on manual verification after the fact, lacking automated and real-time auditing capabilities based on tamper-proof technology. This makes it difficult to provide a legally valid and credible chain of evidence when resources are contested or budgets are overrun. Summary of the Invention
[0004] In view of the aforementioned existing problems, this invention is proposed. Therefore, this invention provides an artificial intelligence-based software cost measurement method to solve the above problems.
[0005] To solve the above-mentioned technical problems, the present invention provides the following technical solution: In a first aspect, the present invention provides a software cost measurement method based on artificial intelligence, comprising: Collect structured events related to software resource consumption, acquire multi-source data and perform data fusion to construct a resource consumption dependency graph; The resource consumption dependency graph is transformed into a structural causal graph, the causal paths between variables are identified, a cost attribution model is constructed, the marginal and causal effects of multidimensional factors on costs are calculated, and dynamic cost factors are output. Based on the aforementioned causal path, a cost traceability graph is constructed, mapping cost nodes and circulation relationships into a directed acyclic graph. The graph data and circulation vouchers are stored using blockchain technology, and the costs are automatically monitored and anomaly warnings are issued through smart contract preset rules. A budget forecasting model is constructed that integrates historical cost data with the dynamic cost factors to generate a dynamic budget. The actual cost flow is monitored in real time and compared with the budget benchmark to optimize cost control.
[0006] As a preferred embodiment of the artificial intelligence-based software cost measurement method described in this invention, the construction of the resource consumption dependency graph includes: By using a full-link resource consumption probe, structured event metrics of resource consumption during application runtime are collected. The collected structured events and unstructured data from the R&D process are fused into multimodal resource consumption data to construct a multi-dimensional resource consumption context. Based on the resource consumption context, a dynamic resource consumption dependency graph is constructed, transforming discrete data into a graph structure that reflects the flow and dependency relationships of resource consumption.
[0007] As a preferred embodiment of the artificial intelligence-based software cost measurement method described in this invention, the method includes collecting structured event indicators of resource consumption during application runtime, such as: By deploying probes, resource consumption events can be defined that include tracking ID, span ID, resource type, and context information. Based on the resource consumption events, multi-dimensional resources are calculated in real time, the consumption is inferred from the intercepted interface call data, the cloud resource consumption is calculated based on the cloud interface sampling period and the resource benchmark value, and high-energy-consuming code functions are identified through CPU time statistics. By using a distributed message queue to asynchronously report serialized resource consumption event streams, child spans can automatically inherit the business context information of the parent span, generating real-time resource consumption data streams with business tags.
[0008] As a preferred embodiment of the software cost measurement method based on artificial intelligence described in this invention, the construction of a dynamic resource consumption dependency graph includes: Define a graph pattern where node types include functional requirement nodes, code submission nodes, service instance nodes, API call nodes, and resource consumption nodes, and edge types include implementation relationships, deployment relationships, call relationships, and consumption relationships. Edge attributes include deployment time, number of calls, and cost contribution, and edge weights are updated using a time window sliding mechanism. Listen to business metadata streams and resource consumption event streams, create or update nodes and edges in real time, and process historical data through exponential decay or sliding window mechanisms. Identify high-cost nodes and use the shortest path algorithm to calculate the root cause path from the cost anomaly alarm node to the code submission node, outputting a list of cost hotspots and anomaly propagation links.
[0009] As a preferred embodiment of the artificial intelligence-based software cost measurement method described in this invention, the output dynamic cost factor includes: Construct a structural causal model, transform the resource consumption dependency graph into a structural causal graph, define the causal relationships between nodes, analyze the temporal causal relationships between variables, and identify the causal path between resource consumption events and cost nodes; Based on the aforementioned causal graph and historical observation data, causal effect estimation is performed using machine learning, and the causal effect coefficients of each factor are output to quantify the net impact of variable T on outcome variable Y. The causal effect coefficients are then dynamically updated using an exponential smoothing model. The static causal effect is transformed into a dynamic cost factor, and the dynamic cost factor is modeled and calculated in real time.
[0010] As a preferred embodiment of the software cost measurement method based on artificial intelligence described in this invention, the construction of a cost tracing graph based on the causal path includes: Based on the identified causal paths, a cost traceability graph containing cost nodes, flow relationships, and subjects is constructed. Each cost event is defined as a node, and the cost flow and responsibility allocation relationship are modeled as directed edges to generate a directed acyclic graph. Data is associated with each node in the graph, and the cost transfer weight between nodes is calculated. Store the topology, node attributes, and circulation vouchers of the cost traceability graph on the blockchain, and define an on-chain transaction structure that includes cost event ID, hash value, on-chain time, and verification node signature; By using smart contracts to pre-set analysis rules, the cost flow can be automatically monitored and anomaly responses can be implemented, including budget threshold monitoring, compliance verification of cost flow paths, and anomaly triggering conditions.
[0011] As a preferred embodiment of the artificial intelligence-based software cost measurement method described in this invention, the method includes: constructing a budget prediction model that integrates historical cost data and the dynamic cost factors to generate a dynamic budget, comprising: Establish a dynamic budget model and construct a dynamic budget benchmark based on historical costs and business objectives; It compares actual costs with budget benchmarks in real time, identifies deviations and triggers early warnings, and outputs budget deviation early warning signals and anomaly analysis reports.
[0012] Secondly, the present invention provides a software cost measurement system based on artificial intelligence, comprising: The data acquisition module is used to collect structured events related to software resource consumption, acquire multi-source data and perform data fusion to construct a resource consumption dependency graph. The first construction module is used to transform the resource consumption dependency graph into a structural causal graph, identify causal paths between variables, construct a cost attribution model, calculate the marginal and causal effects of multidimensional factors on costs, and output dynamic cost factors. The second construction module is used to construct a cost traceability graph based on the causal path, map cost nodes and circulation relationships into a directed acyclic graph, and use blockchain technology to store graph data and circulation vouchers, and use smart contract preset rules to automatically monitor costs and provide early warning of anomalies. The prediction module is used to build a budget prediction model that integrates historical cost data with the dynamic cost factors, generate a dynamic budget, monitor the actual cost flow in real time and compare it with the budget benchmark for cost control and optimization.
[0013] Thirdly, the present invention provides a computer device, comprising: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions, which, when executed by the processor, implement the steps of the artificial intelligence-based software cost measurement method.
[0014] Fourthly, the present invention provides a computer-readable storage medium storing computer-executable instructions that, when executed by a processor, implement the steps of the aforementioned artificial intelligence-based software cost measurement method.
[0015] Compared with existing technologies, the beneficial effects of this invention are as follows: This invention generates dependencies and cost nodes between resources through intelligent modeling, improving the accuracy of the starting point for cost attribution; through causal inference in cost attribution analysis, it breaks through the limitations of traditional correlation analysis, deeply analyzes cost factors, identifies true causal effects, and makes cost attribution results more interpretable, providing a reliable basis for resource optimization; based on blockchain and DAG, it constructs an immutable cost flow graph, combined with automated analysis using smart contracts, achieving full traceability and verifiability of cost flows, significantly improving data credibility and security; through real-time monitoring, it dynamically balances resource allocation and cost constraints, ensuring the accuracy of budget execution. Attached Figure Description
[0016] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 This is a schematic diagram of the overall process of an artificial intelligence-based software cost measurement method according to an embodiment of the present invention. Detailed Implementation
[0018] To make the above-mentioned objects, features, and advantages of the present invention more apparent and understandable, specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of them. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the protection scope of the present invention.
[0019] Reference Figure 1 As one embodiment of the present invention, a software cost measurement method based on artificial intelligence is provided, comprising: S1 collects structured events related to software resource consumption, acquires multi-source data and performs data fusion to construct a resource consumption dependency graph; S2 transforms the resource consumption dependency graph into a structural causal graph, identifies causal paths between variables, constructs a cost attribution model, calculates the marginal and causal effects of multidimensional factors on costs, and outputs dynamic cost factors. S3 constructs a cost traceability graph based on causal paths, maps cost nodes and circulation relationships into a directed acyclic graph, and uses blockchain technology to store graph data and circulation vouchers. It also uses smart contracts to preset rules for automated cost monitoring and anomaly warning. S4. Construct a budget forecasting model that integrates historical cost data and dynamic cost factors, generate a dynamic budget, monitor the actual cost flow in real time and compare it with the budget benchmark to optimize cost control.
[0020] Preferably, constructing a resource consumption dependency graph includes: By using a full-link resource consumption probe, structured event metrics of resource consumption during application runtime are collected. The collected structured events and unstructured data from the R&D process are fused into multimodal resource consumption data to construct a multi-dimensional resource consumption context. Based on the resource consumption context, a dynamic resource consumption dependency graph is constructed, which transforms discrete data into a graph structure that reflects the flow and dependency relationships of resource consumption.
[0021] It should be noted that this step involves deploying probes in the code and infrastructure to collect resource consumption events in real time and correlate them with the business context. By integrating multi-source heterogeneous data, including structured events, unstructured documents, and code changes, a complete resource consumption context is constructed. Then, a dynamic dependency graph is built based on a graph database to visualize resource consumption flow and dependencies for root cause analysis. Through end-to-end probe tracking, multimodal data fusion, and dynamic graph construction technology, it can capture resource consumption data in real time and accurately throughout the entire R&D process, generating a cost-aware network and providing a data foundation for subsequent cost attribution and optimization.
[0022] Preferably, the structured event metrics for collecting resource consumption during application runtime include: By deploying probes, resource consumption events can be defined that include tracking ID, span ID, resource type, and context information. Based on resource consumption events, multi-dimensional resources are calculated in real time. Based on intercepted interface call data, the consumption is calculated by model inference. Based on the cloud interface sampling period and resource benchmark value, cloud resource consumption is calculated. High-energy-consuming code functions are identified through CPU time statistics. By using a distributed message queue to asynchronously report serialized resource consumption event streams, child spans can automatically inherit the business context information of the parent span, generating real-time resource consumption data streams with business tags.
[0023] Constructing a dynamic resource consumption dependency graph includes: Define a graph pattern where node types include functional requirement nodes, code submission nodes, service instance nodes, API call nodes, and resource consumption nodes, and edge types include implementation relationships, deployment relationships, call relationships, and consumption relationships. Edge attributes include deployment time, number of calls, and cost contribution, and edge weights are updated using a time window sliding mechanism. Listen to business metadata streams and resource consumption event streams, create or update nodes and edges in real time, and process historical data through exponential decay or sliding window mechanisms. Identify high-cost nodes and use the shortest path algorithm to calculate the root cause path from the cost anomaly alarm node to the code submission node, outputting a list of cost hotspots and anomaly propagation links.
[0024] In this embodiment, S1 specifically includes: S1.1 collects structured event metrics of resource consumption during application runtime through a full-link resource consumption probe. It embeds resource metrics into the code execution process to ensure the comprehensiveness and real-time nature of data collection.
[0025] Specifically, in the current system architecture, including microservices and cloud infrastructure, AI service call chains, such as Large Language Model APIs (LLM APIs) and vector databases, as well as code execution paths, are probed into critical paths using bytecode injection techniques, such as Java proxies. Critical paths can include API calls, database operations, and model inference. Resource consumption events are defined, including trace IDs, span IDs, time, resource type, consumption amount, and context information. The trace ID uniquely identifies the complete call chain of a request; the span ID identifies a specific segment within the call chain; resource types include CPU, memory, network bandwidth, and model tokens; consumption amount records resource consumption values, such as GPU usage seconds, number of tokens processed, and network bytes; and context information includes associated business information, such as request IDs, commit hashes, user IDs, and environment tags. Based on the above, resource consumption events are generated. When there are multiple span IDs under the same tracking ID, they are automatically associated with the same call chain. The child span ID automatically inherits the context information of the parent span ID to ensure context consistency. When the event contains abnormal information, it is automatically marked as an abnormal consumption tag for analysis in subsequent steps.
[0026] Furthermore, real-time resource consumption calculations are performed, including API call interception consumption, cloud resource consumption, and code performance consumption. API call interception consumption involves intercepting LLM calls, recording the number of input tokens and output tokens to calculate the total consumption, which is the sum of the input and output tokens. The input tokens represent the amount of request data received, and the output tokens represent the amount of response data generated. Cloud resource consumption involves obtaining instance CPU or GPU utilization through the cloud API and calculating consumption based on the time interval of the sampling period. This is the product of utilization, sampling period, and a resource baseline value, which can be the GPU baseline computing power, etc. Code performance consumption involves identifying high-resource-intensive functions, such as through CPU time statistics, to correlate execution time with resource consumption.
[0027] Furthermore, the generated events are reported using a distributed message queue, which sends events asynchronously. After being serialized, the events are stored in a specified topic, generating a real-time resource consumption event stream with context. Each event clearly indicates when what resources were consumed, how much was consumed, and the associated business information.
[0028] S1.2 integrates the collected structured events with unstructured data from the R&D process into multimodal resource consumption data, constructing a multi-dimensional resource consumption context and eliminating data silos. Unstructured data includes code, documents, logs, etc.
[0029] Specifically, a resource consumption data lake is constructed, and a lake-warehouse integrated table format is built. The resource consumption event stream undergoes data preprocessing such as cleaning and deduplication before being written to the resource consumption event table in the data lake. Unstructured data is collected, including requirement documents, code changes, and continuous deployment (CD) logs. Based on the requirement description, the requirement documents are processed using a Transformer-based bidirectional encoder (BERT) model to extract requirement semantic vectors, extracting keywords such as function points and performance metrics, and associating them with the requirement ID in the event. BERT is based on the encoder part of the Transformer architecture, consisting of 12 stacked bidirectional Transformer layers. During training, it considers the context to the left and right of the word simultaneously, judging the similarity between the text vector and the preset function point vector or performance metric vector by calculating the cosine similarity. The document section describes a specific function or performance requirement. Functional points refer to the business behaviors or tasks that the software must perform, such as user login and report generation. Different functional points typically correspond to different computational logic, thus consuming different amounts of resources. Performance metrics refer to the quality standards or constraints that the software must meet, such as response time less than 200 milliseconds, meeting 1000 concurrent requests per second, and accuracy greater than 95%. Performance metrics determine the upper limit of resource configuration. Code changes are identified through commit records; commit information is parsed to extract the changed file paths and line numbers, and associated with the code commit message of the event. Continuous deployment logs extract build duration, test coverage, deployment environment, etc., and are associated with deployment events to obtain the action record of the software application being deployed to the runtime environment, such as development environment, testing environment, and production environment.
[0030] Furthermore, resource consumption events are associated with code commits and deployments occurring within the same minute, and window matching is performed based on timestamps. A mapping from requirements to resource consumption events is constructed by associating requirements with requirement IDs; code changes and resource consumption events are associated with commit hash values to pinpoint consumption changes caused by those changes; and consumption in different deployment environments is distinguished by environment tags.
[0031] Define event triples. Each data source, namely resource consumption events, requirement documents, code commit records, and continuous deployment logs, is converted into the format of (entity, timestamp, attribute vector). Entity types include requirements, code commits, service instances, API calls, resource consumption, etc. Time windows are aligned with a 5-minute sliding window and a 50% window overlap. All structured events within each window, such as CPU usage, memory usage, and model lexical consumption, are aligned with unstructured metadata, including requirement change text and code commit comments, by timestamp. For unstructured text, a 128-bit locality-sensitive hash fingerprint is calculated.
[0032] For structured resource events, min-max normalization is performed, followed by a two-layer fully connected network with the input dimension being the number of event features, 128-dimensional hidden layers, and 128-dimensional output layers, mapping to a 128-dimensional vector v. e The activation function is ReLU (Rectified Linear Unit). For text-based requirement documents or code submission comments, a 768-dimensional vector is extracted using the CodeBERT pre-trained model (a Transformer-based model that understands both natural and programming languages). This vector is then reduced to a 128-dimensional vector via a linear dimensionality reduction layer to obtain v. t .
[0033] Historical data is used to collect known related sample pairs (events, text) as positive samples (e.g., a code commit hash and a CPU peak event occurring within 5 minutes thereafter). Unrelated pairs are randomly sampled as negative samples. A training model based on a noise contrast estimation loss function is used to ensure that the cosine similarity of positive sample pairs is greater than 0.8 and the cosine similarity of negative sample pairs is less than 0.3. The encoder parameters are determined after training. New events and texts are processed by the encoder to obtain vectors, and a similarity matrix is calculated. If the similarity is >0.75, a strong association edge is established, with the association type being "implementation" or "trigger." If the similarity is between 0.5 and 0.75, it is marked as an edge awaiting confirmation and added to the manual review queue. If the similarity is <0.5, no association is established.
[0034] S1.3 Construct a dynamic resource consumption dependency graph, transforming discrete data into a graph structure that reflects the flow and dependency relationships of resource consumption.
[0035] Define a graph pattern where node types include functional requirement nodes, code commit nodes, service instance nodes, API call nodes, and resource consumption nodes. Functional requirement nodes represent specific business requirements or user stories, with attributes including requirement ID, requirement type, and a requirement semantic vector extracted using the BERT model. Code commit nodes represent changes in code version control, with attributes including commit hash, committer, commit time, and code change information. Service instance nodes represent runtime microservice containers or computing units, with attributes including service name, deployment environment, and allocated hardware capacity. API call nodes represent business interface entry points, with attributes including interface path, request method, and average response time. Resource consumption nodes represent actual resource metering records, with attributes including resource type, consumption value, and timestamp of occurrence; resource types include GPU, memory, etc.; edges... The types include implementation relationships, deployment relationships, invocation relationships, and consumption relationships. The direction of the implementation relationship is from the code commit node to the functional requirement node, indicating that each code change is to implement a certain business function. The edge attributes include the number of lines of code changed, which is used to measure the complexity of the implementation. The direction of the deployment relationship is from the code commit node to the service instance node, indicating that the code commit is packaged and deployed to the service instance. The edge attributes include the deployment time, which is used to determine the time point of the version iteration. The direction of the invocation relationship is from the service instance node to the interface call node, indicating that a service instance initiates a call to a specific interface during its operation. The edge attributes include the number of calls, which is used to measure the frequency of calls. The direction of the consumption relationship is from the interface call node to the resource consumption node, indicating the resource consumption generated by a certain interface call. The edge attributes include the cost contribution, that is, the proportion of this call in the total consumption.
[0036] Furthermore, a graph construction algorithm is used to monitor message queues for business metadata streams and resource consumption event streams. When business metadata, such as a new code commit push, is received, it checks if the commit hash node exists in the graph. If not, a new node is created. It then checks if a corresponding service instance node exists; if not, a new node is created. Edges are created or updated according to the link from the code commit node to the deployment relationship to the service instance node. When a resource consumption event, such as an API call consuming a token, is received, the corresponding API call node and resource consumption node are located. An edge from the API call node to the consumption relationship to the resource consumption node is found or created. Edge e is defined as pointing from node u to v, with a weight... This represents the cumulative cost contribution up to the current time t, such as the total number of calls or the total amount of resources consumed. When a new event occurs at time t... When this occurs, the formula for updating the edge weights is: ,in, This is the last update time. The attenuation rate is denoted as In(2) / T.h T h The half-life is 24 hours. This refers to the updated edge weights, where ΔC represents the added cost contribution for this event, such as the token consumption of this API call. A time window sliding mechanism is also introduced, retaining only edges from the most recent 30 days. Historical data is aggregated into statistical nodes. When the value is less than 0.01, the edge is marked as a cold edge and will no longer participate in real-time calculations. However, historical records will be retained, and a global cleanup will be performed every 24 hours to remove all cold edges from the graph.
[0037] Furthermore, after the dynamic resource consumption dependency graph is constructed, high-cost analysis or path analysis can be performed. The PageRank algorithm is used to identify the nodes with the most concentrated consumption flows in the graph, such as high-consumption interfaces or service instances, to obtain the core nodes with the highest costs. If a node is called by a large number of services and the resource nodes it connects to have high weights, then its score is also high. An iterative formula is used to filter and output a list of the top 10 nodes with the highest scores, which are considered cost-critical nodes. The iterative formula is expressed as: ; in, Score the importance of node A. To point to a neighboring node of node A, such as when calling an API service. The weights of the edges, such as the number of calls or the amount of consumption, are determined from the node. The weight of the directed edge pointing to node A is determined by... The resource consumption value pointing to A accounts for The ratio of the total consumption value to all downstream nodes is obtained. The damping coefficient is set to 0.85, and N is the total number of nodes in the network. For nodes The importance score is calculated by assuming that all N nodes in the graph have equal importance. Each node is assigned an initial value of 1 / N or 1. Multiple iterations are performed using an iterative formula. In each iteration, the new PR value of node A is equal to the value of all upstream nodes pointing to it. The sum of the weights of the contributions.
[0038] Path analysis is performed using a shortest path algorithm to calculate the shortest or highest consumption path from functional requirements to resource consumption. The starting point is set as the total cost anomaly alarm node, and the ending point is a leaf node, such as a specific code submission or functional requirement. The weight of the edge is defined as the reciprocal of the cost contribution; the greater the contribution, the shorter the distance. The shortest path is found using Dijkstra's algorithm, and the path chain is output, such as total cost spike, payment service GPU consumption, payment API call, version v2.1 deployment, and code submission a1.
[0039] Preferably, the output dynamic cost factors include: Construct a structural causal model, transform the resource consumption dependency graph into a structural causal graph, define the causal relationships between nodes, analyze the temporal causal relationships between variables, and identify the causal path between resource consumption events and cost nodes; Based on structural causal graphs and historical observation data, causal effect estimation is performed through machine learning, and the causal effect coefficients of each factor are output to quantify the net impact of variable T on outcome variable Y. The causal effect coefficients are then dynamically updated through an exponential smoothing model. The static causal effect is transformed into a dynamic cost factor, and the dynamic cost factor is modeled and calculated in real time.
[0040] It should be noted that this step introduces causal inference technology to extract the real causal links from the constructed resource consumption dependency graph, eliminate the interference of confounding variables, and establish a dynamic factor system to quantify the marginal impact of technology decisions, data quality, computing power efficiency, etc. on costs in real time.
[0041] In this embodiment, the true causal path is identified from the dependency graph, confounding variables are removed, the marginal effect of each factor on cost is calculated, a real-time updated factor system is constructed, and the causes of cost fluctuations are analyzed, as follows: S2.1 Construct a structural causal model, transform the resource consumption dependency graph into a structural causal graph, define the causal relationships between nodes, analyze the temporal causal relationships between variables, and identify the causal path between resource consumption events and cost nodes.
[0042] Specifically, the nodes in the resource consumption dependency graph are mapped to causal variables. Variables are classified and mapped based on the node attributes in the resource consumption dependency graph. For example, the text tag extracted by the BERT model, "high concurrency demand," serves as a causal variable identifier. Causal variables include processing variables T, outcome variables Y, and confounding variables C. Processing variables are modifiable factors, such as code version and model parameter count; outcome variables are cost indicators, such as GPU time consumption and storage costs; confounding variables are variables that simultaneously affect both processing and outcome variables, such as peak business traffic. For each node, an interventionizability score is set between 0 and 1, with scores greater than 0.7 indicating a processing variable. A cost impact score is also set for nodes, with scores greater than 0.8 indicating an outcome variable. Among the remaining variables, those with a similarity value greater than 0.6 to both processing and outcome variables are considered confounding variables.
[0043] Furthermore, a causal skeleton is constructed using the Peter-Clark (PC) algorithm. This involves traversing node pairs, performing conditional independence tests, and progressively pruning the fully connected graph to obtain the causal skeleton. Statistical checks are used to remove spurious edges, and the direction of the edges is then determined. For example, spurious correlations between development time and cost are eliminated. Specifically: Connect all nodes in the graph pairwise to form a complete graph. For each pair of nodes (A, B), calculate the conditional independence with respect to other variable C. Test whether the partial correlation coefficient is 0, i.e., the null hypothesis H0, ρ=0, meaning variables A and B are conditionally independent after controlling for C. The alternative hypothesis H1, ρ≠0, is used to transform the partial correlation coefficient into a normal distribution for testing. If... After controlling C, A and B become independent, so delete the edge between A and B. Start with a single-variable condition set and gradually increase the size of the condition set until no further pruning is possible. Then, identify the collision structure and check the triple A−B−C. If... If this condition is not met, then B is the collision point between A and C. The characteristic of a collision structure is that after controlling B, the originally independent A and C become interdependent. Finally, the directions of the remaining edges are determined based on the following rules to avoid creating new collision structures and forming loops: if A←D→B and A←C→B, then A←B; if D→A←B and B←C, then A←D. The output is a directed acyclic graph (DAG) representing the causal relationships between variables.
[0044] Furthermore, based on the directed acyclic graph (DAG), causal directions are determined. A restricted model and an extended model are constructed for the time-series data (T, Y), generating a structural causal graph and marking causal directions and critical paths. The time-series data includes resource utilization, service request volume, cost metrics, and code change records. The data is aligned by timestamps to form a unified time-series dataset. The residual sum of squares (RSS) is compared using an F-test. If the extended model significantly outperforms the restricted model, then T is a Granger causative factor of Y, as detailed below: Preprocessing the time series data involves performing differencing or logarithmic transformations on the original time series, and constructing constrained and extended models, which are represented as follows: ; ; in, This is the value of the dependent variable at time t, i.e., the variable that needs to be explained at the current moment; The intercept term, a constant, represents the predicted value when all independent variables are 0, reflecting the average level of the sequence; The autoregressive coefficient represents the historical value at time ti relative to the current value. The degree of influence, i=1,2,...,p; p and q are the lag orders; For historical dependent variable values, representing the observed value of the dependent variable at time ti, the model uses historical data from the previous p time points for prediction; This is the error term; The coefficients of the external variable represent the effect of the external variable T at time tj on the current dependent variable. The degree of influence, j=1,2,...,q; Let be the historical values of the external variable, representing the observed values of the external factor at time tj, preceding q time points; then, hypothesis testing is performed, and the F-statistic is calculated, expressed as: ; in, Let be the sum of squared residuals, n be the sample size, and q be the lag order of the new variable T. If the null hypothesis is rejected, T is determined to be a Granger cause of Y, and the causal direction is output, i.e., T→Y or Y→T. The causal strength is determined by extending the model. The magnitude of the lag is determined by the significant j value, such as j=3, which indicates a lag of 3 time units.
[0045] S2.2, based on the structural causal diagram and historical observation data, uses machine learning to estimate causal effects, outputs the causal effect coefficients of each factor to quantify the net impact of variable T on outcome variable Y, and dynamically updates the causal effect coefficients using an exponential smoothing model, as detailed below: The causal effect coefficient is determined by orthogonalization deconfusion (DML). First, the relationship between Y and C is predicted using model M1. Random forests or gradient boosting trees, such as XGBoost, are then used as inputs, with the confounding variable C as the output. residual Model M2 predicts the relationship between T and C, using a neural network as input to the confounding variable C, and outputs the predicted value. residual ;right and Perform linear regression The estimated slope represents the average effect of a 1-unit change in the treatment variable on the outcome variable after controlling for confounding variables, thus yielding the causal effect coefficient. and its confidence interval, To remove the influence of confounding variables and create a pure outcome variable. These are the purified variables after removing the influence of confusing variables.
[0046] Furthermore, multiple decision trees are trained using the Causal Forest algorithm, and samples are segmented according to features. That is, the samples are divided into multiple leaf nodes according to the feature space, and each subset corresponds to a specific feature combination. The local average treatment effect of each leaf node is calculated. , For the Kth feature subset, output the heterogeneous causal effects under different scenarios. For example, in the inference service, a 10% increase in the number of parameters leads to a 5% increase in cost, but the batch processing task only increases by 2%.
[0047] S2.3 transforms static causal effects into dynamic cost factors, and performs dynamic cost factor modeling and real-time calculation, as detailed below: Define dynamic factors, including computing power elasticity factor, data quality factor, model efficiency factor, and traffic sensitivity factor, among which, computing power elasticity factor The actual utilization rate is divided by the theoretical optimal utilization rate, and then multiplied by the causal effect coefficient of utilization rate on cost. This indicates that resource utilization is below the optimal level, resulting in waste. This indicates excessive resource usage, which may lead to performance degradation. Data quality factor. The noise cost is calculated by multiplying the noise ratio by the causal effect coefficient of noise on training cost. This quantifies the data cost by the cost difference before and after data cleaning. The noise ratio is the proportion of invalid data calculated using data quality detection tools. The larger the value, the more severe the negative impact of data quality issues on costs. Model efficiency factor The cost increment required to increase accuracy by dividing the change in model parameters by the change in model accuracy and then multiplying by the causal effect coefficient of the parameter quantity on cost is used to assess this. (Flow sensitivity factor) The coefficient representing the causal effect of traffic on cost quantifies the instantaneous impact of sudden traffic surges on cost.
[0048] Furthermore, define a sliding window, such as the most recent 168 hours, and rerun the DML calculation to reflect the latest data every hour as new data flows in. Then the dynamic factor is updated through exponential smoothing: ; in, This is a smoothing coefficient that controls the weight of new data, with a value of 0.3. The causal effect coefficient is calculated for the current time window. If the data delay is less than 30 minutes, historical values are used for interpolation. An alarm is issued and manual review is required. Dynamic factors are visualized, generating a real-time heatmap showing the current value and trend of each factor. Red indicates high-cost factors. An attribution decomposition diagram is generated, breaking down cost changes into the contributions of each factor. For example, a 30% increase in cost leads to a 20% increase in traffic sensitivity factor, a 15% increase in model efficiency factor, and a 5% decrease in computing power elasticity factor. An alarm is triggered when a factor value exceeds a preset threshold. Greater than 1.2, etc.
[0049] Preferably, constructing a cost tracing map based on causal paths includes: Based on the identified causal paths, a cost traceability graph containing cost nodes, flow relationships, and subjects is constructed. Each cost event is defined as a node, and the cost flow and responsibility allocation relationship are modeled as directed edges to generate a directed acyclic graph. Data is associated with each node in the graph, and the cost transfer weight between nodes is calculated. Store the topology, node attributes, and circulation vouchers of the cost traceability graph on the blockchain, and define an on-chain transaction structure that includes cost event ID, hash value, on-chain time, and verification node signature; By using smart contracts to pre-set analysis rules, the cost flow can be automatically monitored and anomaly responses can be implemented, including budget threshold monitoring, compliance verification of cost flow paths, and anomaly triggering conditions.
[0050] It should be noted that this step involves constructing a graph, integrating the results of the cost attribution model, generating a cost traceability graph, determining the path and nodes of cost flow, storing cost data and the traceability graph on the blockchain to ensure data tamper-proof and verifiable, and automatically performing cost analysis through preset rules to achieve real-time monitoring and anomaly warning.
[0051] S3.1 Construct a Cost Traceability Graph. Based on the results of the cost attribution model, construct a directed acyclic graph (DAG) of cost flow paths to determine the generation, flow, and aggregation relationships of costs. Based on the resource consumption dependency graph, the cost attribution model output (i.e., causal paths), cost dynamic factors, and causal effect coefficients, output a cost traceability graph containing nodes, edges, and attribute labels, as detailed below: The cost nodes in the resource dependency graph, such as computing resources, storage resources, and service calls, are mapped to cost nodes in the graph. The attributes include node ID, cost type such as CPU cost / storage cost, and cost value. The processing variables and result variables in the causal graph are mapped to driver nodes and influence nodes. To construct edge relationships, based on the causal path of the cost attribution model, directed edges are established, with the direction pointing from the driving node to the influencing node. The edge weight is the causal effect coefficient, representing the intensity of the driving factor's influence on the cost. Based on the data flow relationship in the resource dependency graph, cost flow edges are established, connecting upstream and downstream cost nodes. The edge attributes include flow time, flow volume, and flow rules. Label each node with analysis attributes, such as department and data source, and label each edge with flow vouchers, such as analysis record and contract number, to generate a multi-layered directed graph that includes cost flow paths, causal relationships, and analysis attributes.
[0052] S3.2 uses a blockchain evidence storage system to store cost traceability maps and key data on the blockchain, ensuring that the data is tamper-proof and verifiable. Inputs include cost traceability maps, original cost data, and circulation vouchers, and outputs blockchain evidence records, including transaction hashes, timestamps, and verification information.
[0053] For each cost node and edge, its attributes and transfer vouchers are cryptographically hashed to generate a unique fingerprint. This fingerprint is calculated using the node ID, cost value, timestamp, and analysis attributes. The hashed data is packaged into blockchain transactions, including the transaction initiator (e.g., department ID), transaction type (e.g., cost occurrence, transfer confirmation), and data fingerprint. Asymmetric encryption is used to verify the signature. The transactions are written to the blockchain, generating immutable transaction hashes. An on-chain index is added to each node and edge in the cost traceability graph, pointing to the corresponding transaction hash.
[0054] S3.3 Automates cost flow monitoring and anomaly response through pre-set analysis rules in smart contracts. Specifically, it outputs smart contract code and trigger event records based on cost thresholds, compliance rules, and analysis process templates, as detailed below: Define rules, including cost threshold rules, which define the maximum tolerance value for each cost node; compliance verification rules, which check whether cost data meets preset compliance standards, such as budget coding and analysis process integrity; and correlation verification rules, which verify whether cost flow follows the defined path in the graph, such as storage fees—network fees—service call fees. The key functions of writing smart contracts include checking whether node costs exceed thresholds, verifying data compliance, verifying whether cost flow paths conform to the graph definition, automatically executing the contract when new block data is written, and generating alerts based on the contract content.
[0055] S3.4, based on the results of the dynamic factor model, monitors cost fluctuations in real time and generates early warning signals.
[0056] Cost data streams are accessed in real time via message queues, including new node costs and circulation events. The predicted results of a dynamic factor model are compared with actual values to calculate the deviation rate. If the deviation rate exceeds a preset threshold of 30%, it is marked as abnormal fluctuation. Based on the events triggered by smart contracts and the fluctuation detection results, an early warning report is generated, including the warning type, involved nodes, trigger time, and suggested actions, such as re-analysis or freezing circulation.
[0057] Preferably, a budget forecasting model is constructed that integrates historical cost data and dynamic cost factors to generate a dynamic budget, including: Establish a dynamic budget model and construct a dynamic budget benchmark based on historical costs and business objectives; It compares actual costs with budget benchmarks in real time, identifies deviations and triggers early warnings, and outputs budget deviation early warning signals and anomaly analysis reports.
[0058] Specifically, based on historical data and business objectives, a dynamic budget model is built to predict future budget needs; cost flow data is acquired to monitor budget execution in real time, identify deviations and generate early warnings; and budget allocation is adjusted according to early warning signals and business rules.
[0059] S4.1 Establish a dynamic budget model. Based on historical costs and business objectives, construct a dynamic budget baseline. Input historical cost data and business objectives, such as revenue targets and profit margins, and output the dynamic budget baseline value, distinguishing between time periods, departments, or projects, as detailed below: Clean historical cost data, fill in missing values, remove outliers, use mean imputation or median replacement, and align business objectives with the time granularity of cost data, such as monthly or quarterly. Using time series models or machine learning regression models, business objectives are used as features to predict future budget requirements. The model formula is as follows: ; in, Let be the budget baseline value at time t; Base budget value, intercept item; The autoregressive coefficients represent the influence weights of historical budgets. The historical budget value at time ti; This is the moving average coefficient, which is the corrected weight for historical errors; The prediction error at time tj; Weights for external factors; External factors at time t, such as business objectives, are considered. The model's predictions are then revised based on expert experience or business rules to generate hierarchical budget baselines, such as departmental, project, and cost type levels. Finally, a dynamic budget baseline table is generated, containing time-series predictions for each dimension.
[0060] S4.2 compares actual costs with the budget baseline in real time, identifies deviations, and triggers early warnings. It takes as input real-time cost data streams, dynamic budget baselines, and early warning rules, and outputs budget deviation early warning signals and anomaly analysis reports.
[0061] Cost data is accessed in real time via message queues and mapped to budget benchmarks. The deviation rate between actual costs and budget benchmarks is calculated by department, project, and time dimension. Multi-level warning thresholds are defined, such as 5%-10% for minor deviations and >10% for severe deviations. If the deviation exceeds the threshold, a warning event is triggered, which includes the warning level, warning dimension (e.g., server cost of department A), and warning suggestions (e.g., checking abnormal expenditures or applying for budget adjustments). This enables real-time monitoring and tiered warnings, reducing the risk of budget overruns.
[0062] It should be noted that this invention generates dependencies and cost nodes between resources through intelligent modeling, improving the accuracy of the starting point for cost attribution; through causal inference in cost attribution analysis, it breaks through the limitations of traditional correlation analysis, deeply analyzes cost factors, identifies true causal effects, and makes cost attribution results more interpretable, providing a reliable basis for resource optimization; based on blockchain and DAG, it constructs an immutable cost flow graph, combined with automated analysis using smart contracts, to achieve full traceability and verifiability of cost flow, significantly improving data credibility and security; through real-time monitoring, it dynamically balances resource allocation and cost constraints, ensuring the accuracy of budget execution.
[0063] The above is an illustrative scheme of an artificial intelligence-based software cost measurement method according to this embodiment. It should be noted that the technical solution of this artificial intelligence-based software cost measurement system belongs to the same concept as the above-described artificial intelligence-based software cost measurement method. Details not described in detail in the technical solution of the artificial intelligence-based software cost measurement system in this embodiment can be found in the description of the above-described artificial intelligence-based software cost measurement method.
[0064] This embodiment provides a software cost measurement system based on artificial intelligence, including: The data acquisition module is used to collect structured events related to software resource consumption, acquire multi-source data and perform data fusion to construct a resource consumption dependency graph. The first building module is used to transform the resource consumption dependency graph into a structural causal graph, identify causal paths between variables, build a cost attribution model, calculate the marginal and causal effects of multidimensional factors on costs, and output dynamic cost factors. The second construction module is used to build a cost traceability graph based on causal paths, map cost nodes and circulation relationships into a directed acyclic graph, and use blockchain technology to store graph data and circulation vouchers, and use smart contracts to preset rules for automated cost monitoring and anomaly warning. The forecasting module is used to build a budget forecasting model that integrates historical cost data and dynamic cost factors, generate a dynamic budget, monitor the actual cost flow in real time and compare it with the budget benchmark for cost control and optimization.
[0065] This embodiment also provides a computer device suitable for software cost measurement based on artificial intelligence, including: The memory and processor are used to store computer-executable instructions and execute the computer-executable instructions to implement an artificial intelligence-based software cost measurement method as proposed in the above embodiments.
[0066] This embodiment also provides a storage medium on which a computer program is stored. When the program is executed by a processor, it implements an artificial intelligence-based software cost measurement method as proposed in the above embodiments.
[0067] The storage medium proposed in this embodiment belongs to the same inventive concept as the software cost measurement method based on artificial intelligence proposed in the above embodiments. Technical details not described in detail in this embodiment can be found in the above embodiments, and this embodiment has the same beneficial effects as the above embodiments.
[0068] Based on the above description of the implementation methods, those skilled in the art can clearly understand that the present invention can be implemented using software and necessary general-purpose hardware, and of course, it can also be implemented using hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory, hard disk, or optical disk, etc., including several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods of the various embodiments of the present invention.
[0069] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.
Claims
1. An artificial intelligence based software cost measurement method, characterized by, include: Collect structured events related to software resource consumption, acquire multi-source data and perform data fusion to construct a resource consumption dependency graph; The resource consumption dependency graph is transformed into a structural causal graph, the causal paths between variables are identified, a cost attribution model is constructed, the marginal and causal effects of multidimensional factors on costs are calculated, and dynamic cost factors are output. Based on the aforementioned causal path, a cost traceability graph is constructed, mapping cost nodes and circulation relationships into a directed acyclic graph. The graph data and circulation vouchers are stored using blockchain technology, and the costs are automatically monitored and anomaly warnings are issued through smart contract preset rules. A budget forecasting model is constructed that integrates historical cost data with the dynamic cost factors to generate a dynamic budget. The actual cost flow is monitored in real time and compared with the budget benchmark to optimize cost control.
2. The software cost measurement method based on artificial intelligence as described in claim 1, characterized in that, Constructing a resource consumption dependency graph includes: By using a full-link resource consumption probe, structured event metrics of resource consumption during application runtime are collected. The collected structured events and unstructured data from the R&D process are fused into multimodal resource consumption data to construct a multi-dimensional resource consumption context. Based on the resource consumption context, a dynamic resource consumption dependency graph is constructed, transforming discrete data into a graph structure that reflects the flow and dependency relationships of resource consumption.
3. The software cost measurement method based on artificial intelligence as described in claim 2, characterized in that, The structured event metrics for resource consumption during application runtime include: By deploying probes, resource consumption events can be defined that include tracking ID, span ID, resource type, and context information. Based on the resource consumption events, multi-dimensional resources are calculated in real time, the consumption is inferred from the intercepted interface call data, the cloud resource consumption is calculated based on the cloud interface sampling period and the resource benchmark value, and high-energy-consuming code functions are identified through CPU time statistics. By using a distributed message queue to asynchronously report serialized resource consumption event streams, child spans can automatically inherit the business context information of the parent span, generating real-time resource consumption data streams with business tags.
4. The software cost measurement method based on artificial intelligence as described in claim 3, characterized in that, Constructing a dynamic resource consumption dependency graph includes: Define a graph pattern where node types include functional requirement nodes, code submission nodes, service instance nodes, API call nodes, and resource consumption nodes, and edge types include implementation relationships, deployment relationships, call relationships, and consumption relationships. Edge attributes include deployment time, number of calls, and cost contribution, and edge weights are updated using a time window sliding mechanism. Listen to business metadata streams and resource consumption event streams, create or update nodes and edges in real time, and process historical data through exponential decay or sliding window mechanisms. Identify high-cost nodes and use the shortest path algorithm to calculate the root cause path from the cost anomaly alarm node to the code submission node, outputting a list of cost hotspots and anomaly propagation links.
5. The software cost measurement method based on artificial intelligence as described in claim 4, characterized in that, The output dynamic cost factors include: Construct a structural causal model, transform the resource consumption dependency graph into a structural causal graph, define the causal relationships between nodes, analyze the temporal causal relationships between variables, and identify the causal path between resource consumption events and cost nodes; Based on the aforementioned causal graph and historical observation data, causal effect estimation is performed using machine learning, and the causal effect coefficients of each factor are output to quantify the net impact of variable T on outcome variable Y. The causal effect coefficients are then dynamically updated using an exponential smoothing model. The static causal effect is transformed into a dynamic cost factor, and the dynamic cost factor is modeled and calculated in real time.
6. The software cost measurement method based on artificial intelligence as described in claim 5, characterized in that, Constructing a cost tracing map based on the aforementioned causal path includes: Based on the identified causal paths, a cost traceability graph containing cost nodes, flow relationships, and subjects is constructed. Each cost event is defined as a node, and the cost flow and responsibility allocation relationship are modeled as directed edges to generate a directed acyclic graph. Data is associated with each node in the graph, and the cost transfer weight between nodes is calculated. Store the topology, node attributes, and circulation vouchers of the cost traceability graph on the blockchain, and define an on-chain transaction structure that includes cost event ID, hash value, on-chain time, and verification node signature; By using smart contracts to pre-set analysis rules, the cost flow can be automatically monitored and anomaly responses can be implemented, including budget threshold monitoring, compliance verification of cost flow paths, and anomaly triggering conditions.
7. The software cost measurement method based on artificial intelligence as described in claim 6, characterized in that, Construct a budget forecasting model that integrates historical cost data with the dynamic cost factors to generate a dynamic budget, including: Establish a dynamic budget model and construct a dynamic budget benchmark based on historical costs and business objectives; It compares actual costs with budget benchmarks in real time, identifies deviations and triggers early warnings, and outputs budget deviation early warning signals and anomaly analysis reports.
8. A software cost measurement system based on artificial intelligence, employing the software cost measurement method based on artificial intelligence as described in any one of claims 1 to 7, characterized in that, include: The data acquisition module is used to collect structured events related to software resource consumption, acquire multi-source data and perform data fusion to construct a resource consumption dependency graph. The first construction module is used to transform the resource consumption dependency graph into a structural causal graph, identify causal paths between variables, construct a cost attribution model, calculate the marginal and causal effects of multidimensional factors on costs, and output dynamic cost factors. The second construction module is used to construct a cost traceability graph based on the causal path, map cost nodes and circulation relationships into a directed acyclic graph, and use blockchain technology to store graph data and circulation vouchers, and use smart contract preset rules to automatically monitor costs and provide early warning of anomalies. The prediction module is used to build a budget prediction model that integrates historical cost data with the dynamic cost factors, generate a dynamic budget, monitor the actual cost flow in real time and compare it with the budget benchmark for cost control and optimization.
9. A computer device, characterized in that, include: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions, which, when executed by the processor, implement the steps of the software cost measurement method based on artificial intelligence as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, It stores computer-executable instructions that, when executed by a processor, implement the steps of the artificial intelligence-based software cost measurement method as described in any one of claims 1 to 7.