Decision flow execution method, device, computer equipment and storage medium
By dynamically judging and responding to node type operations in the decision flow execution stack, the problem of lack of flexibility and inefficiency in decision flow execution in traditional technology is solved, and more efficient and flexible decision flow execution is achieved.
Patent Information
- Application Number
- CN202410483443.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-22
- Publication Date
- 2025-03-21
- Estimated Expiration
- 2044-04-22
AI Technical Summary
Traditional state machine-based decision flow execution technology lacks flexibility and is difficult to cope with complex decision logic and dynamic changes, and is prone to deadlocks or race conditions, resulting in weak scheduling flexibility and low execution efficiency of decision process.
By obtaining the type information of the current node in the decision flow execution stack, judging and responding to operations of different node types based on the type, including branch nodes, admission nodes and decision nodes, dynamically managing the execution status and transfer of the decision flow, avoiding excessive dependence on the association between nodes.
It improves the execution efficiency and flexibility of decision flow, reduces the occurrence of concurrent errors, and can more effectively deal with complex decision logic and dynamic changes in scenarios.
Smart Images

Figure CN118363725B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a decision flow execution method, apparatus, computer equipment and storage medium. Background Art
[0002] With the development of computer technology, decision engine technology has emerged. The decision flow execution engine is a key module in the decision engine. With the continuous advancement of data processing capabilities and algorithm technology, the design and implementation of decision engines are also constantly evolving.
[0003] In traditional technology, a state machine-based scheduler is usually used to implement it, that is, a state machine model is used to describe and manage the execution status of the decision process. The state machine defines the possible states in the decision process and the transition conditions between states, as well as the actions or operations performed in each state. However, since the state machine is highly dependent on predefined states and transition conditions between states, the management and control of the process often lack flexibility, making it difficult to cope with complex decision logic or dynamically changing scenarios, and prone to concurrent errors such as deadlocks or race conditions, resulting in weak scheduling flexibility and low efficiency in decision process execution. Summary of the invention
[0004] Based on this, it is necessary to provide a decision flow execution method, device, computer equipment and storage medium that can improve the efficiency of decision process execution in response to the above technical problems.
[0005] In a first aspect, a decision flow execution method is provided, which is applied to a decision flow execution engine, and the decision flow execution engine is used to execute a pre-edited decision flow, and the method includes:
[0006] When it is detected that there is an element in the decision flow execution stack, the type information of the current node at the top of the decision flow execution stack is obtained;
[0007] Determine the type of the current node according to the type information; wherein the type of the current node is at least one of a branch node, an access node, and a decision node;
[0008] In response to the current node being a branch node, pushing the start nodes corresponding to each branch into the decision flow execution stack in sequence;
[0009] In response to the current node being an admission node, obtaining admission condition information corresponding to the admission node, determining whether the target execution object satisfies the admission condition information, and if so, pushing a child node of the admission node into a decision flow execution stack; and
[0010] In response to the current node being a decision node, the execution rule of the decision node is obtained, the corresponding decision is executed according to the execution rule, and after the decision node is popped from the decision flow execution stack, the child node corresponding to the decision node is pushed into the decision flow execution stack.
[0011] In some embodiments, the method further includes: in response to the target execution object not satisfying the admission condition information, deleting the branch corresponding to the admission node from the decision flow.
[0012] In some embodiments, the starting node corresponding to each branch is pushed into the decision flow execution stack in turn, including: sorting the branches corresponding to the branch nodes according to a preset logical order, pushing the starting node of each branch into the decision flow execution stack in turn according to the sorting result, and traversing and executing the nodes in each branch in turn.
[0013] In some embodiments, the nodes in each branch are traversed and executed in sequence, including: determining whether all nodes under the current branch have been executed, and determining whether the current branch is in exclusive execution mode; in response to all nodes under the current branch being executed and the current branch being in exclusive execution mode, entering into execution of the next branch; and in response to all nodes under the current branch not being executed, or the current branch being in non-exclusive execution mode, continuing into execution of the next node of the current branch.
[0014] In some embodiments, the method further includes: before pushing the child node into the decision flow execution stack, obtaining the access count information of the child node to be pushed, and comparing the access count information with a preset access threshold; in response to the access count information being greater than the access threshold, deleting the child node to be pushed and its corresponding branch from the decision flow; and in response to the access count information being less than the access threshold, pushing the child node to be pushed into the decision flow execution stack.
[0015] In some embodiments, the type of the current node further includes a start node, and the method further includes: in response to the current node being the start node, popping the start node and pushing its child nodes into the decision flow execution stack.
[0016] In some embodiments, when it is detected that there are elements in the decision flow execution stack, before obtaining the type information of the current node at the top of the decision flow execution stack, the method also includes: creating an empty decision flow execution stack, the decision flow execution stack is used to store the nodes to be visited; pushing the start node of the decision flow into the decision flow execution stack, and marking the start node as visited.
[0017] In some embodiments, the decision flow is a flowchart structure, a hash table is used to store the nodes in the decision flow, and an adjacency table is used to store the connection relationship between the nodes in the decision flow.
[0018] In a second aspect, a decision flow execution device is also provided, which is applied to a decision flow execution engine, and the decision flow execution engine is used to execute a pre-edited decision flow, and the device includes:
[0019] An information acquisition module, used for acquiring type information of a current node at the top of the decision flow execution stack when detecting that there is an element in the decision flow execution stack;
[0020] A type determination module, used to determine the type of the current node according to the type information; wherein the type of the current node is at least one of a branch node, an access node, and a decision node;
[0021] A first execution module, configured to, in response to the current node being a branch node, push the start node corresponding to each branch into the decision flow execution stack in sequence;
[0022] a second execution module, configured to, in response to the current node being an admission node, obtain admission condition information corresponding to the admission node, determine whether the target execution object satisfies the admission condition information, and if so, push a child node of the admission node into a decision flow execution stack; and
[0023] The third execution module is used to obtain the execution rule of the decision node in response to the current node being a decision node, execute the corresponding decision according to the execution rule, and after popping the decision node from the decision flow execution stack, push the child node corresponding to the decision node into the decision flow execution stack.
[0024] According to a third aspect, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of any one of the methods of the first aspect when executing the computer program.
[0025] According to a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the steps of any one of the methods of the first aspect are implemented.
[0026] The above-mentioned decision flow execution method, device, computer equipment and storage medium perform different push or execution operations according to the type of the current node in combination with the decision flow execution stack. Since each node responds to different actions with the decision flow execution stack according to the different type classification, the execution process of the decision flow does not overly rely on the dependency relationship between each node. Since the decision flow execution stack is cleverly used to store the nodes to be executed, by combining the characteristics of the stack and the classification and processing strategy of the nodes, the execution process focuses on the type and state of the current node, rather than the relationship between each node. Moreover, each node popped out from the stack is the current deepest node on the current search path. Therefore, it is possible to explore as deep as possible along the depth direction, thereby improving the decision flow execution efficiency and execution capability of the decision flow execution engine without increasing the complexity of the entire decision flow execution engine. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 A flowchart of a decision flow execution method in some embodiments;
[0028] Figure 2 is a schematic diagram of a decision flow in some embodiments;
[0029] Figure 3 A schematic diagram of a strategy for pushing and popping nodes into and out of a decision flow execution stack in some embodiments;
[0030] Figure 4 A schematic diagram of the interaction logic between the internal structural units of the decision flow execution engine in some embodiments;
[0031] Figure 5 It is a structural block diagram of a decision flow execution device in some embodiments;
[0032] Figure 6 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0033] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0034] The decision flow execution method provided in this application can be applied to Figure 4 In the application environment shown. Figure 4 A schematic diagram of the interaction logic between the internal structural units of the decision flow execution engine in some embodiments is shown.
[0035] In some embodiments, the decision flow execution engine may include a decision flow control unit, a decision node execution unit, an admission node execution unit, a branch node execution unit, and a decision flow execution stack. Among them, each unit in the above-mentioned decision flow execution engine can be implemented in whole or in part by software, hardware, and a combination thereof. The above-mentioned units can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above-mentioned units.
[0036] It is worth noting that the division of the various units in the above-mentioned decision flow execution engine is only one of the implementable methods, and is not used to limit the execution subject or execution order of the various steps of the decision flow execution method proposed in this application. Other unit division structures that can implement the decision flow execution method proposed in this application are also included in the protection scope of this application.
[0037] In some embodiments, Figure 1 As shown, a decision flow execution method is provided, which is described by taking the method applied to a decision flow execution engine as an example, and may include the following steps:
[0038] Step S102: when it is detected that there is an element in the decision flow execution stack, the type information of the current node at the top of the decision flow execution stack is obtained.
[0039] The decision flow execution stack is implemented based on a stack, which is a type of linear list that allows insertion or deletion operations at one end. The top of the stack is the end of the decision flow execution stack that allows insertion and deletion operations, as opposed to the bottom end of the stack that does not allow insertion and deletion operations. The decision flow execution stack is used to store nodes to be accessed. The current node refers to the node element at the top of the decision flow execution stack.
[0040] Specifically, after determining that there is an element in the decision flow execution stack, the decision flow control unit obtains the type information of the first element (node) at the top of the stack from the decision flow execution stack, that is, the type information of the current node.
[0041] Step S104: determining the type of the current node according to the type information; wherein the type of the current node is at least one of a branch node, an access node and a decision node.
[0042] Specifically, the nodes in the decision flow can be divided into different types, and the type of the current node at the top of the decision flow execution stack can be dynamically determined. Depending on the type of the node, it is determined whether to use different processing strategies such as pushing, deleting or executing the decision flow execution stack.
[0043] Among them, the decision node is a node in the flowchart of the decision flow that carries the corresponding execution rule, the branch node is a node that controls the division of independent branches from the trunk or main branch of the decision flow, and the access node refers to a node virtualized by the access condition information carried by the edge in the flowchart of the decision flow. Among them, the access condition information can be pre-edited according to the upper-level business logic, which is not limited here, and can include a single judgment rule or a combination of multiple rules.
[0044] Step S106: In response to the current node being a branch node, the start nodes corresponding to the branches are pushed into the decision flow execution stack in sequence.
[0045] Specifically, when the decision flow control unit determines that the type of the current node is a branch node, by analyzing the connection logic between the branches under the branch node, the starting nodes of each branch (that is, all or part of the child nodes of the current branch node) are sorted according to the connection relationship between the nodes of the pre-edited decision flow, and the branch node execution unit can be called to push each starting node into the decision flow execution stack in turn. That is, after each starting node is pushed into the decision flow execution stack, recursion is performed downward for other nodes on the corresponding branch until the branch is determined to be executed, and then the starting node of the next branch is pushed in sequence, and so on, until all branches are executed, the branch node is popped out from the decision flow execution stack.
[0046] Among them, the child node involved in this application refers to the direct subordinate node of a node in the tree flowchart of the decision flow. In the tree flowchart of the decision flow, the child node is the direct subordinate node of a node, that is, the node connected to it by an edge. In the tree flowchart of the decision flow, except for the root node at the top of the tree, other nodes may have one or more parent nodes and zero or more child nodes.
[0047] Step S108: In response to the current node being an admission node, obtaining admission condition information corresponding to the admission node, determining whether the target execution object satisfies the admission condition information, and if so, pushing the child node of the admission node into the decision flow execution stack.
[0048] Specifically, when the decision flow control unit determines that the type of the current node is an access node, it obtains the access condition information corresponding to the access node, and instructs the access node execution unit to determine whether the target execution object satisfies the access condition information. When it is determined that the target execution object satisfies the access condition information, the child node corresponding to the current access node can be pushed into the decision flow execution stack.
[0049] Step S110: In response to the current node being a decision node, the execution rule of the decision node is obtained, the corresponding decision is executed according to the execution rule, and after the decision node is popped from the decision flow execution stack, the child node corresponding to the decision node is pushed into the decision flow execution stack.
[0050] Specifically, when the decision flow control unit determines that the type of the current node is a decision node, it obtains the execution rule corresponding to the current decision node, and instructs the decision node execution unit to execute the corresponding decision according to the execution rule. After the decision corresponding to the current decision node is executed, the current decision node can be popped from the decision flow execution stack and its child node can be pushed into the decision flow execution stack. At this time, the node at the top of the decision flow execution stack is the most recently pushed child node.
[0051] The above-mentioned decision flow execution method performs different push or execution operations in combination with the decision flow execution stack according to the different types of the current node. Since each node responds to different actions with the decision flow execution stack according to the different types, the execution process of the decision flow does not overly rely on the dependency relationship between each node. Since the decision flow execution stack is cleverly used to store the nodes to be executed, by combining the characteristics of the stack and the classification and processing strategy of the nodes, the execution process focuses on the type and state of the current node, rather than the relationship between each node. Moreover, each node popped out from the stack is the current deepest node on the current search path. Therefore, it is possible to explore as deep as possible along the depth direction, thereby improving the decision flow execution efficiency and execution capability of the decision flow execution engine without increasing the complexity of the entire decision flow execution engine.
[0052] In some embodiments, the method further includes: in response to the target execution object not satisfying the admission condition information, deleting the branch corresponding to the admission node from the decision flow.
[0053] The target execution object refers to the object to be processed or searched, which is equivalent to the input parameter of the decision flow. The decision flow searches or matches the adapted decision flow execution result for the target execution object according to the decision flow.
[0054] In this embodiment, if the target execution object does not meet the access condition information, the access node and the corresponding branch path under the access node can be pruned. After the pruning operation, the branch path corresponding to the access node and the nodes in the branch path are no longer added to the decision flow execution stack, and therefore are no longer executed.
[0055] In this embodiment, through the intelligent pruning strategy, the decision flow execution engine can timely prune invalid branches, thereby reducing the search space and improving the search efficiency. This intelligent pruning capability enables the decision flow execution engine to focus more on branches that may produce solutions, thereby speeding up the search speed and further improving the efficiency of decision flow execution.
[0056] In some embodiments, the type of the current node further includes a start node, and the method further includes: in response to the current node being the start node, popping the start node and pushing its child nodes into the decision flow execution stack.
[0057] In some embodiments, when it is detected that there are elements in the decision flow execution stack, before obtaining the type information of the current node at the top of the decision flow execution stack, the method also includes: creating an empty decision flow execution stack, the decision flow execution stack is used to store the nodes to be visited; pushing the start node of the decision flow into the decision flow execution stack, and marking the start node as visited.
[0058] Specifically, before the decision flow is executed, an empty stack can be created as a decision flow execution stack. Then, the decision flow control unit can obtain the start node of the decision flow flowchart, push the obtained start node into the decision flow execution stack, and mark the start node as visited. At this time, the decision flow execution stack pushed with the start node is no longer an empty stack. Therefore, in response to the existence of elements in the decision flow execution stack, the step of obtaining the type information of the current node at the top of the decision flow execution stack is entered. Since the start node is marked as visited, the start node can no longer be executed, but the start node can be popped out of the decision flow execution stack, and then the child node corresponding to the start node is pushed into the decision flow execution stack.
[0059] In some embodiments, the method further includes: before pushing the child node into the decision flow execution stack, obtaining the access count information of the child node to be pushed, and comparing the access count information with a preset access threshold; in response to the access count information being greater than the access threshold, deleting the child node to be pushed and its corresponding branch from the decision flow; and in response to the access count information being less than the access threshold, pushing the child node to be pushed into the decision flow execution stack.
[0060] In this embodiment, the execution times of each node are controlled on the decision flow execution engine side according to the visit times information of the child nodes, without relying on the pre-edited business logic of the upper layer. Even if there is an error in the process planning of the decision flow, it is possible to determine whether to cyclically push the child nodes into the decision flow execution stack based on the underlying logic on the decision flow execution engine side. If the child node is visited too many times, corresponding pruning operations are performed, so that the search depth can be flexibly controlled to avoid falling into infinite recursion or overly deep search paths, thereby improving the efficiency and performance of the algorithm.
[0061] In some embodiments, the starting node corresponding to each branch is pushed into the decision flow execution stack in turn, including: sorting the branches corresponding to the branch nodes according to a preset logical order, pushing the starting node of each branch into the decision flow execution stack in turn according to the sorting result, and traversing and executing the nodes in each branch in turn.
[0062] In this embodiment, when the current node is a branch node, the branches corresponding to the branch node can be sorted. The branches can be sorted from left to right in the flowchart of the decision flow. Of course, they can also be sorted according to a preset sorting rule or a preset branch priority level. According to the sorting result, the starting node of the first-ranked branch is first pushed into the decision flow execution stack, and the nodes of the branch are recursively executed downward until the branch is determined to be executed. The starting node of the second-ranked branch is pushed into the decision flow execution stack, and so on, until all branches of the current branch node are executed, and the branch node is popped from the decision flow execution stack.
[0063] In some embodiments, the nodes in each branch are traversed and executed in sequence, including: determining whether all nodes under the current branch have been executed, and determining whether the current branch is in exclusive execution mode; in response to all nodes under the current branch being executed and the current branch being in exclusive execution mode, entering into execution of the next branch; and in response to all nodes under the current branch not being executed, or the current branch being in non-exclusive execution mode, continuing into execution of the next node of the current branch.
[0064] In this embodiment, it is determined whether all nodes under the current branch have been executed, and whether the current branch is in exclusive execution mode. Through the dual determination conditions, the accuracy of the determination can be improved, thereby avoiding missed execution. Among them, the exclusive execution mode of the branch means that during the execution process, when a branch node is encountered, only one branch will be executed, rather than executing multiple branches at the same time. This execution mode ensures that the program has only one execution path at each moment, avoiding the confusion and uncertainty that may be caused by the simultaneous execution of multiple branches.
[0065] In some embodiments, the decision flow is a flowchart structure, a hash table is used to store the nodes in the decision flow, and an adjacency table is used to store the connection relationship between the nodes in the decision flow.
[0066] The graph structure of the present embodiment can effectively represent the logical structure of the decision flow, and support fast node access and traversal. If the data structure is not optimized, the configuration structure of the traditional decision flow is a loop nested structure, the data is bloated and the decision flow of the graph structure cannot be realized, and only the tree structure can be supported. However, the decision flow of the graph structure of the present embodiment is a kind of adjacency list structure, which is composed of a vertex array and an edge linked list array, each vertex array element corresponds to a vertex in the graph, and each element of the edge linked list array corresponds to the linked list of the edge connected to the corresponding vertex. This structure has many advantages. For sparse graphs (the number of edges is much smaller than the number of vertices), the adjacency list only stores the vertex (node) and edge information of the edge, saving a lot of space. For a given vertex, the adjacency list can quickly find all the vertices connected to it, and only needs to traverse the edge linked list corresponding to the vertex, and the time consumption and complexity are reduced. In addition, the adjacency list structure is easy to implement, and supports dynamic addition and deletion of vertices and edges, because only the pointer of the linked list needs to be adjusted. The storage method of the adjacency list is more conducive to cache performance, because the data of adjacent vertices are usually stored adjacently in the memory, which can more effectively utilize the cache, thereby improving access efficiency. Applying the flowchart of the decision flow with the structure of this embodiment to the decision flow execution engine involved in this application can further improve the efficiency and flexibility of decision execution.
[0067] Below, please refer to Figure 2 and Figure 3 , Figure 2 FIG. 1 is a flowchart showing a decision flow in some embodiments. Figure 3 A schematic diagram showing strategies for pushing and popping nodes in a decision flow execution stack in some embodiments.
[0068] For example, the access condition information can be age information. As shown in the figure, the access condition information corresponding to access node A is: age <= 20, the access condition information corresponding to access node B is: age > 20, and the access condition information corresponding to access node C is: age > 50. Assume that the target execution object (variable parameter) is: the age value is 60 years old. Then the execution path of the entire decision flow can be:
[0069] Start node->decision node A->branch node A->admission node (age <= 20), does not meet the admission conditions, pruning->admission node (age> 20)->decision node C->branch node B->admission node (age> 50)->decision node D.
[0070] After executing decision node D, the branch node B->admission node (age>50)->decision node D is executed in a loop according to the pre-edited logic until the execution times of branch node B exceeds the preset threshold. After pruning operation, the execution of the entire decision flow is completed.
[0071] Flowchart based on decision flow To implement the above execution process, the decision flow execution engine can refer to the operation flow chart of the decision flow execution stack according to the different node types. Figure 3 As shown. Figure 3 The order from (1) to (6) in the figure schematically illustrates the push and pop strategy of the decision flow execution stack for nodes.
[0072] like Figure 3 As shown, the following may be included:
[0073] (1) First, create an empty decision flow execution stack, push the start node into the decision flow execution stack, and mark it as visited.
[0074] (2) At this time, the decision flow execution stack into which the start node is pushed is no longer an empty stack. Therefore, in response to the existence of an element in the decision flow execution stack, the step of obtaining the type information of the current node at the top of the decision flow execution stack is entered. Since the start node is marked as visited, the start node is no longer executed. Instead, the start node is popped out of the decision flow execution stack, and then the child node corresponding to the start node (decision node A) is pushed into the decision flow execution stack.
[0075] (3) Obtain the type information of decision node A. After determining that it is a decision node, execute the corresponding decision according to its corresponding execution rule. After the execution is completed, pop decision node A from the decision flow execution stack and push its child node (branch node A) into the decision flow execution stack.
[0076] (4) Obtain the type information of branch node A. After determining that it is a branch node, sort its branches and then push the starting nodes of each branch in sequence. First, push the starting node of the first branch (access node A) and obtain the access condition information corresponding to access node A. For example, for Figure 2 In the decision flow, the target execution object is age 60, and the admission condition information of admission node A is age <= 20. Therefore, the admission condition is not met, and the admission node A is popped out of the decision flow execution stack, and its corresponding branch is pruned.
[0077] (5) The starting node (access node B) of the second branch of branch node A is pushed into the decision flow execution stack. After determining that the type of the newly pushed node is an access node, the corresponding access condition information of access node B is obtained. For example, the access condition information of access node B is age>20. Therefore, the target execution object meets the access condition, so the branch is retained and recursively downward.
[0078] (6) When all branches of branch node A are executed, branch node A is popped from the decision flow execution stack.
[0079] Next, a more detailed description of the decision flow execution method involved in this application is given in conjunction with an application example. Figure 4 As shown, Figure 4 The following is a flowchart of the interaction between various units in the decision flow execution engine in some embodiments. Specifically, the following steps may be included:
[0080] S1. Obtaining a start node. Specifically, the decision flow control unit reads a start node from the decision flow.
[0081] S2. Push the start node into the decision flow execution stack. Specifically, the decision flow control unit marks the start node as visited and pushes it into the decision flow execution stack.
[0082] S3. When the stack is not empty, obtain the type information of the current node at the top of the stack. Specifically, when the decision flow control unit detects that there are elements in the decision flow execution stack, it obtains the type information of the current node at the top of the stack that is most recently pushed.
[0083] S4. Determine the type. The decision flow control unit determines which type of node the current node belongs to based on the type information of the current node.
[0084] S5. In response to the current node being a decision node, obtain execution rules and indicate execution strategy. Specifically, when the current node is determined to be a decision node, the decision flow control unit obtains the execution rules corresponding to the decision node and indicates the decision node execution unit to execute the decision.
[0085] S6. Execute the corresponding decision according to the execution rule. Specifically, the decision node execution unit executes the corresponding decision according to the corresponding execution rule to realize the search work corresponding to the decision node.
[0086] S7. Pop the decision node and push its child nodes in. Specifically, after executing the decision corresponding to the current decision node, the decision node execution unit pops the decision node from the decision flow execution stack and pushes its child nodes into the decision flow execution stack.
[0087] S8. In response to the current node being a branch node, the child nodes are sorted from left to right according to the connection order. Specifically, when the current node is determined to be a branch node, the decision flow control unit sorts the child nodes of the branch node from left to right according to the preset connection order, and instructs the branch node execution unit to push the starting node of each branch in turn, and recursively downward.
[0088] S10. Traverse and execute each node in each branch. Specifically, the branch node execution unit traverses each branch in sequence to complete the execution of each branch.
[0089] S11. In response to the current node being an admission node, the admission condition information is obtained. Specifically, when the current node is determined to be an admission node, the admission condition information corresponding to the current admission node is obtained, and the admission node execution unit is instructed to make a judgment.
[0090] S12. If the access condition is met, its child nodes are pushed in. Specifically, when the access node execution unit determines that the access condition is met, its child nodes are pushed in and the access node is marked as visited.
[0091] S13. If the admission condition is not met, prune. Specifically, when the admission node execution unit determines that the admission condition is not met, the admission node and its corresponding branch are pruned.
[0092] This application example is based on a decision flow execution method based on depth-first search, combined with a decision flow execution stack, and uses the DFS (Depth First Search) algorithm to traverse the decision process. Compared with the rule system of traditional technology, it has higher search efficiency and flexibility, can traverse the decision tree or state space more quickly, and quickly find the optimal solution or the appropriate decision path, and has better adaptability and scalability. In addition, by setting intelligent pruning and depth limitation strategies in the execution logic, intelligent pruning and depth limitation strategies are introduced to dynamically adjust the search depth according to real-time data and environmental changes, and perform intelligent pruning and decision-making based on search results. Compared with the fixed search depth or pruning rules of traditional methods, it can more effectively reduce the search space and improve the system's scheduling capabilities and execution efficiency.
[0093] It should be understood that although Figure 1 and Figure 4 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1 and Figure 4 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0094] In some embodiments, Figure 5 As shown, a decision flow execution device is provided, including: an information acquisition module 501, a type judgment module 502, a first execution module 503, a second execution module 504 and a third execution module 505, wherein:
[0095] The information acquisition module 501 is used to acquire the type information of the current node at the top of the decision flow execution stack when detecting that there is an element in the decision flow execution stack;
[0096] A type determination module 502 is used to determine the type of the current node according to the type information; wherein the type of the current node is at least one of a branch node, an access node, and a decision node;
[0097] A first execution module 503, configured to, in response to the current node being a branch node, push the start node corresponding to each branch into the decision flow execution stack in sequence;
[0098] The second execution module 504 is used to obtain the admission condition information corresponding to the admission node in response to the current node being an admission node, determine whether the target execution object satisfies the admission condition information, and if so, push the child node of the admission node into the decision flow execution stack; and
[0099] The third execution module 505 is used to obtain the execution rule of the decision node in response to the current node being a decision node, execute the corresponding decision according to the execution rule, and after popping the decision node from the decision flow execution stack, push the child node corresponding to the decision node into the decision flow execution stack.
[0100] In some embodiments, the second execution module 504 is further configured to delete the branch corresponding to the admission node from the decision flow in response to the target execution object not satisfying the admission condition information.
[0101] In some embodiments, the first execution module 503 is also used to sort the branches corresponding to the branch nodes according to a preset logical order, push the starting node of each branch into the decision flow execution stack in turn according to the sorting result, and traverse and execute the nodes in each branch in turn. In some embodiments, the first execution module 503 is also used to determine whether all nodes under the current branch have been executed, and determine whether the current branch is in an exclusive execution mode; in response to all nodes under the current branch being executed and the current branch being in an exclusive execution mode, enter the execution of the next branch; and in response to all nodes under the current branch not being executed, or the current branch being in a non-exclusive execution mode, continue to enter the execution of the next node of the current branch.
[0102] In some embodiments, the type judgment module 502 is also used to obtain the access count information of the child node to be pushed into the decision flow execution stack before pushing the child node into the decision flow execution stack, and compare the access count information with a preset access threshold; in response to the access count information being greater than the access threshold, deleting the child node to be pushed and its corresponding branch from the decision flow; and in response to the access count information being less than the access threshold, pushing the child node to be pushed into the decision flow execution stack.
[0103] In some embodiments, the type determination module 502 is further configured to, in response to the current node being a start node, pop the start node and push its child nodes into the decision flow execution stack.
[0104] In some embodiments, the type determination module 502 is further used to create an empty decision flow execution stack, which is used to store nodes to be visited; push the start node of the decision flow into the decision flow execution stack, and mark the start node as visited.
[0105] For the specific definition of the decision flow execution device, please refer to the definition of the decision flow execution method above, which will not be repeated here. The various modules in the above-mentioned decision flow execution device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0106] In some embodiments, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 6 As shown. The computer device includes a processor, a memory, and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a decision flow execution method is implemented.
[0107] Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0108] In some embodiments, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the following steps are implemented when the processor executes the computer program: when detecting the existence of an element in a decision flow execution stack, obtaining type information of a current node at the top of the decision flow execution stack; determining the type of the current node according to the type information; wherein the type of the current node is at least one of a branch node, an access node, and a decision node; in response to the current node being a branch node, pushing the start nodes corresponding to each branch into the decision flow execution stack in sequence; in response to the current node being an access node, obtaining access condition information corresponding to the access node, determining whether the target execution object satisfies the access condition information, and if so, pushing the child nodes of the access node into the decision flow execution stack; and in response to the current node being a decision node, obtaining the execution rule of the decision node, executing the corresponding decision according to the execution rule, and after popping the decision node from the decision flow execution stack, pushing the child nodes corresponding to the decision node into the decision flow execution stack.
[0109] In some embodiments, when the processor executes the computer program, the following steps are further implemented: in response to the target execution object not satisfying the admission condition information, deleting the branch corresponding to the admission node from the decision flow.
[0110] In some embodiments, when the processor executes the computer program, the following steps are also implemented: sorting the branches corresponding to the branch nodes according to a preset logical order, pushing the starting node of each branch into the decision flow execution stack in turn according to the sorting results, and traversing and executing the nodes in each branch in turn.
[0111] In some embodiments, the processor also implements the following steps when executing a computer program: determining whether all nodes under the current branch have been executed, and determining whether the current branch is in an exclusive execution mode; in response to all nodes under the current branch being executed and the current branch being in an exclusive execution mode, entering into execution of the next branch; and in response to all nodes under the current branch not being executed, or the current branch being in a non-exclusive execution mode, continuing into execution of the next node of the current branch.
[0112] In some embodiments, when the processor executes the computer program, the following steps are also implemented: before pushing a child node into the decision flow execution stack, obtaining the access count information of the child node to be pushed, and comparing the access count information with a preset access threshold; in response to the access count information being greater than the access threshold, deleting the child node to be pushed and its corresponding branch from the decision flow; and in response to the access count information being less than the access threshold, pushing the child node to be pushed into the decision flow execution stack.
[0113] In some embodiments, when the processor executes the computer program, the following steps are further implemented: in response to the current node being a start node, popping the start node and pushing its child nodes into the decision flow execution stack.
[0114] In some embodiments, when the processor executes the computer program, the following steps are also implemented: creating an empty decision flow execution stack, the decision flow execution stack is used to store the nodes to be visited; pushing the start node of the decision flow into the decision flow execution stack, and marking the start node as visited.
[0115] In some embodiments, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented: when it is detected that there is an element in a decision flow execution stack, the type information of the current node at the top of the decision flow execution stack is obtained; the type of the current node is determined according to the type information; wherein the type of the current node is at least one of a branch node, an access node and a decision node; in response to the current node being a branch node, the starting nodes corresponding to each branch are pushed into the decision flow execution stack in turn; in response to the current node being an access node, the access condition information corresponding to the access node is obtained, and it is determined whether the target execution object satisfies the access condition information, and if so, the child nodes of the access node are pushed into the decision flow execution stack; and in response to the current node being a decision node, the execution rule of the decision node is obtained, the corresponding decision is executed according to the execution rule, and after the decision node is popped from the decision flow execution stack, the child nodes corresponding to the decision node are pushed into the decision flow execution stack.
[0116] In some embodiments, when the computer program is executed by the processor, the following steps are further implemented: in response to the target execution object not satisfying the admission condition information, deleting the branch corresponding to the admission node from the decision flow.
[0117] In some embodiments, when the computer program is executed by the processor, the following steps are also implemented: sorting the branches corresponding to the branch nodes according to a preset logical order, pushing the starting node of each branch into the decision flow execution stack in turn according to the sorting results, and traversing and executing the nodes in each branch in turn.
[0118] In some embodiments, when the computer program is executed by the processor, the following steps are also implemented: determining whether all nodes under the current branch have been executed, and determining whether the current branch is in an exclusive execution mode; in response to all nodes under the current branch being executed and the current branch being in an exclusive execution mode, entering the execution of the next branch; and in response to all nodes under the current branch not being executed, or the current branch being in a non-exclusive execution mode, continuing to enter the execution of the next node of the current branch.
[0119] In some embodiments, when the computer program is executed by the processor, the following steps are also implemented: before pushing a child node into the decision flow execution stack, obtaining the access count information of the child node to be pushed, and comparing the access count information with a preset access threshold; in response to the access count information being greater than the access threshold, deleting the child node to be pushed and its corresponding branch from the decision flow; and in response to the access count information being less than the access threshold, pushing the child node to be pushed into the decision flow execution stack.
[0120] In some embodiments, when the computer program is executed by the processor, the following steps are further implemented: in response to the current node being the start node, popping the start node and pushing its child nodes into the decision flow execution stack.
[0121] In some embodiments, when the computer program is executed by the processor, the following steps are also implemented: creating an empty decision flow execution stack, the decision flow execution stack is used to store the nodes to be visited; pushing the starting node of the decision flow into the decision flow execution stack, and marking the starting node as visited. A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0122] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0123] In addition, the term "and / or" in this article is only a description of the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the characters in this article generally indicate that the associated objects before and after are in an "or" relationship.
[0124] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A decision flow execution method, applied to a decision flow execution engine, wherein the decision flow execution engine is used to execute a pre-edited decision flow, the method comprising: When detecting that there is an element in the decision flow execution stack, obtaining type information of a current node at the top of the decision flow execution stack; Determining the type of the current node according to the type information; wherein the type of the current node is at least one of a branch node, an access node, and a decision node; In response to the current node being a branch node, sequentially pushing the start nodes corresponding to the branches into the decision flow execution stack; In response to the current node being an admission node, obtaining admission condition information corresponding to the admission node, determining whether the target execution object satisfies the admission condition information, and if so, pushing a child node of the admission node into the decision flow execution stack; and In response to the current node being a decision node, obtaining an execution rule of the decision node, executing a corresponding decision according to the execution rule, and after popping the decision node from the decision flow execution stack, pushing a child node corresponding to the decision node into the decision flow execution stack; wherein, The method further comprises: Before pushing a child node into the decision flow execution stack, obtaining access count information of the child node to be pushed, and comparing the access count information with a preset access threshold; In response to the access count information being greater than the access threshold, deleting the child node to be pushed and its corresponding branch from the decision flow; and In response to the access count information being less than the access threshold, the child node to be pushed is pushed into the decision flow execution stack.
2. The method according to claim 1, characterized in that The method further comprises: In response to the target execution object not satisfying the admission condition information, a branch corresponding to the admission node is deleted from the decision flow.
3. The method according to claim 1, characterized in that: The step of sequentially pushing the starting nodes corresponding to the branches into the decision flow execution stack includes: The branches corresponding to the branch nodes are sorted according to a preset logical order, the starting nodes of the branches are pushed into the decision flow execution stack in sequence according to the sorting results, and the nodes in the branches are traversed and executed in sequence.
4. The method according to claim 3, characterized in that The step of sequentially traversing and executing the nodes in each branch includes: Determine whether all nodes under the current branch have been executed, and determine whether the current branch is in exclusive execution mode; In response to all nodes under the current branch being executed and the current branch being in an exclusive execution mode, entering execution of the next branch; and In response to all nodes under the current branch not being executed completely, or the current branch being in a non-exclusive execution mode, the execution of the next node of the current branch continues.
5. The method according to claim 1, characterized in that The type of the current node also includes a start node, and the method further includes: In response to the current node being a start node, popping the start node and pushing its child nodes into the decision flow execution stack; and When detecting that there is an element in the decision flow execution stack, before obtaining the type information of the current node at the top of the decision flow execution stack, the method further includes: Creating an empty decision flow execution stack, where the decision flow execution stack is used to store nodes to be accessed; The start node of the decision flow is pushed into the decision flow execution stack, and the start node is marked as visited.
6. The method according to claim 1, characterized in that The decision flow is a flow chart structure, a hash table is used to store the nodes in the decision flow, and an adjacency table is used to store the connection relationship between the nodes in the decision flow.
7. A decision flow execution device, characterized in that: Applied to a decision flow execution engine, the decision flow execution engine is used to execute a pre-edited decision flow, the device comprises: An information acquisition module, used for acquiring type information of a current node at the top of the decision flow execution stack when detecting that there is an element in the decision flow execution stack; A type determination module, configured to determine the type of the current node according to the type information; wherein the type of the current node is at least one of a branch node, an access node, and a decision node; A first execution module, configured to, in response to the current node being a branch node, push the start node corresponding to each branch into the decision flow execution stack in sequence; a second execution module, configured to, in response to the current node being an admission node, obtain admission condition information corresponding to the admission node, determine whether the target execution object satisfies the admission condition information, and if so, push a child node of the admission node into the decision flow execution stack; and A third execution module is used for obtaining an execution rule of the decision node in response to the current node being a decision node, executing a corresponding decision according to the execution rule, and after popping the decision node from the decision flow execution stack, pushing a child node corresponding to the decision node into the decision flow execution stack; The third execution module is also used to obtain the access count information of the child node to be pushed into the decision flow execution stack before pushing the child node into the decision flow execution stack, and compare the access count information with a preset access threshold; in response to the access count information being greater than the access threshold, deleting the child node to be pushed and its corresponding branch from the decision flow; and in response to the access count information being less than the access threshold, pushing the child node to be pushed into the decision flow execution stack.
8. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Power grid dispatching operation order optimum sequence generation method based on risk
CN103714491A
Dialogue management method and device and storage medium
CN113449086A
Full-automatic test data generation method based on interface process arrangement
CN114218114A