Distribution constraint solving method and device, electronic equipment and storage medium
By simplifying and transforming the distribution constraint expression and creating a target topology diagram to determine the solution priority, the problem of complex and inefficient distribution constraint solution in the prior art is solved, and a more efficient and accurate solution effect is achieved.
Patent Information
- Application Number
- CN202411973907.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-04-25
AI Technical Summary
When the prior art deals with distribution constraints in chip software simulation verification, the solution process is complex and inefficient, making it difficult to ensure the accuracy of the solution.
By responding to the running instructions of the target test code, the distribution constraint expression is simplified and transformed, the target topology diagram is created and the hierarchy is divided, and the solution is prioritized for the solution.
The solution process of distribution constraint expressions is simplified, and the solution efficiency and accuracy are improved.
Smart Images

Figure CN119886047A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology and the field of electronic design automation simulation tool technology, and in particular to a method, device, electronic equipment and storage medium for solving distributed constraints. Background Art
[0002] In the chip software simulation verification process, the distribution constraint module of the chip verification language System Verilog is particularly important, which involves verifying whether the design works as expected. Distribution constraint is a mechanism used in System Verilog to specify the weight distribution of random variables, which allows random numbers that conform to the specified weight distribution to be generated during the randomization process.
[0003] At present, the distribution constraint expression is mainly solved by customizing a special solution method through a specific constraint solver, which makes the solution process of the distribution constraint expression complicated.
[0004] How to simplify the process of solving distribution constraints and improve the efficiency and accuracy of solving distribution constraints are key research issues in the industry. Summary of the invention
[0005] The present invention provides a method, device, electronic device and storage medium for solving distribution constraints, so as to simplify the solution process of distribution constraints and improve the solution efficiency and accuracy of distribution constraints.
[0006] According to one aspect of the present invention, a method for solving a distribution constraint is provided, the method comprising:
[0007] In response to the running instruction of the target test code, simplify each distribution constraint expression of the target test code to obtain each simplified first distribution constraint expression;
[0008] Transforming the first distribution constraint expression to obtain a second distribution constraint expression;
[0009] Creating a target topology graph based on each target constraint of the second distribution constraint expression, and dividing each target constraint into different levels;
[0010] The solution priorities of the target constraints are determined according to the levels of the target constraints in the target topology graph, and the second distribution constraint expression is solved according to the solution priorities.
[0011] According to another aspect of the present invention, there is provided a distribution constraint solving device, the device comprising:
[0012] A first distribution constraint expression determination module is used to simplify each distribution constraint expression of the target test code in response to the running instruction of the target test code to obtain each simplified first distribution constraint expression;
[0013] A second distribution constraint expression determination module, used for transforming the first distribution constraint expression to obtain a second distribution constraint expression;
[0014] A target topology map determining module, used to create a target topology map based on each target constraint of the second distribution constraint expression, and divide each target constraint into different levels;
[0015] A solving module is used to determine the solving priority of each target constraint according to the level of each target constraint in the target topology map, and solve the second distribution constraint expression according to each solving priority.
[0016] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0017] at least one processor; and
[0018] a memory communicatively connected to the at least one processor; wherein,
[0019] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the method for solving the distribution constraint described in any embodiment of the present invention.
[0020] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the method for solving the distribution constraint described in any embodiment of the present invention when executed.
[0021] According to another aspect of the present invention, a computer program product is provided, comprising a computer program, wherein when the computer program is executed by a processor, the method for solving the distribution constraint described in any embodiment of the present invention is implemented.
[0022] The technical solution of the embodiment of the present invention simplifies each distribution constraint expression of the target test code in response to the running instruction of the target test code to obtain each simplified first distribution constraint expression; transforms the first distribution constraint expression to obtain a second distribution constraint expression; creates a target topology map based on each target constraint of the second distribution constraint expression, and divides each target constraint into different levels; determines the solution priority of each target constraint according to the level of each target constraint in the target topology map, and solves the second distribution constraint expression according to each solution priority, thereby simplifying the solution process of the distribution constraint expression and improving the solution efficiency and accuracy of the distribution constraint expression.
[0023] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0025] Figure 1 is a flow chart of a method for solving distribution constraints provided according to Embodiment 1 of the present invention;
[0026] Figure 2 is a flow chart of a method for solving distribution constraints provided according to Embodiment 2 of the present invention;
[0027] Figure 3 is a flow chart of a method for solving distribution constraints provided according to Embodiment 2 of the present invention;
[0028] Figure 4 is a schematic structural diagram of a distribution constraint solving device provided according to Embodiment 3 of the present invention;
[0029] Figure 5 It is a schematic diagram of the structure of an electronic device for implementing the method for solving the distribution constraint of an embodiment of the present invention. DETAILED DESCRIPTION
[0030] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0031] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0032] Embodiment 1
[0033] Figure 1 This is a flow chart of a distributed constraint solving method provided according to the first embodiment of the present invention. This embodiment is applicable to the case of solving distributed constraint expressions. The method can be executed by a distributed constraint solving device. The distributed constraint solving device can be implemented in the form of hardware and / or software. The distributed constraint solving device can be configured in electronic devices such as computers, servers or tablet computers. Figure 1 As shown, the method includes:
[0034] Step 110 : In response to the running instruction of the target test code, simplify each distribution constraint expression of the target test code to obtain each simplified first distribution constraint expression.
[0035] The target test code may be a System Verilog code input by a user in a software simulation tool, or other simulation code, which is not limited in this embodiment. It should be noted that System Verilog is a hardware description language (HDL, Hardware Design Language) widely used in electronic design automation, test platform development and system-level verification.
[0036] It should be noted that the distribution constraint, namely the Distribution constraint, is a mechanism used in System Verilog to specify the weight distribution of random variables. It allows the generation of random numbers that conform to the specified weight distribution during the randomization process. The distribution constraints mainly include constraints that contain variables and constraints that do not contain variables.
[0037] Optionally, in this embodiment, after receiving the running instruction of the target test code, that is, after determining that the target test code enters the runtime stage, each partial constraint expression of the target test code can be further simplified to obtain each simplified first distribution constraint expression.
[0038] It is understandable that a distribution constraint expression may include multiple ranges, and different weight distributions may exist in different ranges. Exemplarily, in an optional implementation of this embodiment, simplifying the distribution constraint expression may be simplifying each range of the distribution constraint expression.
[0039] Optionally, in the present embodiment, each distribution constraint expression of the target test code is simplified to obtain each simplified first distribution constraint expression, which may include: determining each range of the target distribution constraint expression; traversing each character in each of the ranges to determine a target string that matches the target range; weighting the target range according to the target string; and determining each first distribution constraint expression according to the weight allocation result.
[0040] Among them, the target distribution constraint expression can be one or more distribution constraints in the target test code, which is not limited in this embodiment; the target string can be ":=" or ": / ", which is not limited in this embodiment.
[0041] In an optional implementation of the present embodiment, after receiving an execution instruction of the target test code, or after determining that the target test code has entered the execution stage, the target test code can be further parsed to obtain the distribution constraints of the target test code; further, the ranges of the target distribution constraint expression can be determined; further, the characters in each range can be traversed to determine the target string that matches the target range; wherein the target range can be any range in the target distribution constraint; further, the target range can be weighted according to the target string, that is, a weight distribution rule that matches the target range is determined according to the target string, and further, the weights within the target range can be distributed according to the weight distribution rule; after all the weights within the ranges are redistributed, the first distribution constraint expression after the target distribution constraint expression is simplified can be obtained.
[0042] Optionally, in this embodiment, if the target string of the target range is ":=", then the weight allocation rule that matches the target range is to assign the specified weight to each value in the target range; if the target string of the target range is ": / ", then the weight allocation rule that matches the target range is to determine the quotient of the weight and the number of numerical values in the target range as the weight of each value in the target range.
[0043] Exemplarily, the simplified first distribution constraint expression may be LHS dist{range_item1, range_item2...}, wherein range_item represents the weight distribution within each range of the first distribution constraint expression.
[0044] Step 120: transform the first distribution constraint expression to obtain a second distribution constraint expression.
[0045] In this embodiment, after obtaining the simplified first distribution constraint expression, the first distribution constraint expression can be further transformed to obtain a second distribution constraint expression; illustratively, the expressions in each range of the first distribution constraint expression can be transformed separately, for example, the expressions in each range are converted into a standard constraint form.
[0046] Optionally, in this embodiment, transforming the first distribution constraint expression to obtain the second distribution constraint expression may include: determining the variable distribution of the first distribution constraint expression; when it is determined that the variable distribution of the first distribution constraint expression is on the left side of the equal sign of the first distribution constraint expression, abstracting the first distribution constraint expression into a third distribution constraint expression; determining the total weight of the target first distribution constraint expression based on the third distribution constraint expression; determining each target range of the third distribution constraint expression and a distribution constraint expression matching each target range based on the total weight, the upper limit value and the lower limit value of each range of the first distribution constraint expression, and the weight of each range; and obtaining the second distribution constraint expression based on each target range and an expression matching each target range.
[0047] In this embodiment, the variable distribution conditions of the first distribution constraint expression may include: only the left side (LHS) of the expression contains variables, and not only the left side of the expression contains variables.
[0048] In an optional implementation of this embodiment, after obtaining the simplified first distribution constraint expression, the variable distribution of the first distribution constraint expression can be further determined; if it is determined that the variables of the first distribution constraint expression are distributed on the left side of the equal sign of the first distribution constraint expression, that is, only the left side of the expression contains variables, then the first distribution constraint expression can be further abstracted into a third distribution constraint expression; further, the total weight of the first distribution constraint expression can be determined based on the third distribution constraint expression; further, based on the total weight, the upper limit value and the lower limit value of each range of the first distribution constraint expression and the weight of each range, each target range of the third distribution constraint expression and the distribution constraint expression matching each target range can be determined; further, the converted second distribution constraint expression can be obtained according to each determined target range and the distribution constraint expression matching each target range.
[0049] Exemplarily, when it is determined that only the left side of the first distribution constraint expression contains variables, the first distribution constraint expression can be abstracted into a third distribution constraint expression, and the abstracted third distribution constraint expression can be: LHS dist{[a:b]: / w1,[c:d]:=w2,e:=w3}; wherein a, b, c, d, e, w1, w2, w3 are constants, and a is the lower limit value of the first range, b is the upper limit value of the first range, c is the lower limit value of the second range, d is the upper limit value of the first range, e is the third range, and w1, w2, w3 are the weights of each range respectively; LHS is an expression containing only the required variables; the cumulative total weight is W=w1+(d-c+1)●w2+w3, wherein W is an expression of the total weight; wherein P represents a random variable within the total weight range, P∈[0,W).
[0050] Furthermore, the ranges of the third distribution constraint expression are transformed, and the target ranges of the obtained third distribution constraint expression and the distribution constraint expression matching the target ranges can be: when P∈[0,w1), LHS==(P / w1)*(b-a+1)+a; when P∈[w1,w1+(d-c+1)*w2), LHS==((P-w1) / (d-c+1))+c; when P∈[w1+(d-c+1)*w2,W), LHS==e.
[0051] In a specific example of this embodiment, the third distribution constraint expression is: xdist{[1:3]: / 2,[5:7]:=3,9:=4}; further, the cumulative total weight is calculated: W=2+(7-5+1)*3+4=2+6*3+4=2+18+4=24; random variable P; in this embodiment, assume that P=10; when P∈[0,2), x==(P / 2)*(3-1+1)+1; when P∈[2,20), x==((P-2) / 6)+5; when P∈[20,24), x==9; specifically, for P=10, that is, P∈[2,20), therefore x==((10-2) / 6)+5=(8 / 6)+5=1.33+5=6.33=6 (x is an integer variable, the compiler will round down).
[0052] Optionally, in this embodiment, transforming the first distribution constraint expression to obtain the second distribution constraint expression may also include: when it is determined that the variable distribution of the first distribution constraint expression is not on the left side of the equal sign of the first distribution constraint expression, abstracting the first distribution constraint expression into a fourth distribution constraint expression; wherein the upper limit value or the lower limit value of the target range of the fourth distribution constraint expression contains the target variable; determining the total weight of the target first distribution constraint expression based on the fourth distribution constraint expression; determining each target range of the fourth distribution constraint expression and a distribution constraint expression matching each target range based on the total weight, the upper limit value and the lower limit value of each range of the first distribution constraint expression, and the weight of each range; and obtaining the second distribution constraint expression based on each target range and an expression matching each target range.
[0053] In another optional implementation of this embodiment, after obtaining the simplified first distribution constraint expression, the variable distribution of the first distribution constraint expression can be further determined; if it is determined that the variable distribution of the first distribution constraint expression is not only on the left side of the equal sign of the first distribution constraint expression, that is, not only the left side of the expression contains variables, then the first distribution constraint expression can be further abstracted into a fourth distribution constraint expression; further, the total weight of the first distribution constraint expression can be determined based on the fourth distribution constraint expression; further, based on the total weight, the upper limit value and the lower limit value of each range of the first distribution constraint expression and the weight of each range, each target range of the fourth distribution constraint expression and the distribution constraint expression matching each target range can be determined; further, the converted second distribution constraint expression can be obtained according to each determined target range and the distribution constraint expression matching each target range.
[0054] Exemplarily, when it is determined that not only the left side of the first distribution constraint expression contains variables, the first distribution constraint expression can be abstracted into a fourth distribution constraint expression, and the abstracted fourth distribution constraint expression can be: LHS dist{[a:expr1]: / w1,[c:d]:=w2,e:=w3}; where a, c, d, e, w1, w2, and w3 are constants, and expr1 is an expression containing variables; the cumulative total weight is: W = w1+(d - c + 1)●w2+w3, where the random variable P ∈ [0, W), and W is the expression of the total weight.
[0055] Further, if expr1 < a, the ranges of the fourth distribution constraint expression can be further transformed. The obtained target ranges of the fourth distribution constraint expression and the distribution constraint expressions matching the respective target ranges can be: when P ∈ [0, w1] and expr1 >= a, LHS == (P / w1)*(expr1 - a + 1)+a; when P ∈ [0, w1] and expr1 < a, LHS == (P / w1)*(a - expr1 + 1)+expr1; when P ∈ [w1, w1+(d - c + 1)*w2), LHS == ((P - w1) / (d - c + 1))+c; when P ∈ [w1+(d - c + 1)*w2, W), LHS == e.
[0056] In a specific example of this embodiment, the fourth distribution constraint expression is: x dist{[1:expr1]: / 2,[5:7]:=3,9:=4}; further, the cumulative total weight is calculated as: W = 2+(7 - 5 + 1)*3+4 = 2+6*3+4 = 2+18+4 = 24; the random variable P; in this embodiment, assume P = 10; for P ∈ [0, 2] and expr1 >= 1, x == (P / 2)*(expr1 - 1 + 1)+1; for P ∈ [0, 2] and expr1 < 1, x == (P / 2)*(1 - expr1 + 1)+expr1; for P ∈ [2, 20], x == ((P - 2) / 6)+5; for P ∈ [20, 24], x == 9; in specific calculations, for P = 10: P ∈ [2, 20], so x == ((10 - 2) / 6)+5 = (8 / 6)+5 = 1.33+5 = 6.33 = 6 (x is an integer variable, and the compiler will round down).
[0057] Step 130, create a target topology graph based on the target constraints of the second distribution constraint expression, and divide the target constraints into different levels.
[0058] Optionally, in this embodiment, after the second distribution constraint expression is converted, a target topology map may be further created according to each target constraint of the second distribution constraint expression, and different constraints may be divided into different levels in the target topology map.
[0059] Optionally, in this embodiment, a target topology map is created based on each target constraint of the second distributed constraint expression, and each target constraint is divided into different levels, which may include: determining the target constraints in each second distributed constraint expression and each reference constraint in the target test code; parsing each target constraint and each reference constraint, and marking each target constraint and each reference constraint according to the parsing result to obtain each marked target constraint and each marked reference constraint; creating a target node for each marked target constraint and each marked reference constraint, and connecting each target node according to the association relationship between each target constraint and each reference constraint to obtain the target topology map; sorting the target topology map, and dividing each target constraint and each reference constraint into levels; wherein, each target constraint and each reference constraint at the same level have the same priority.
[0060] Among them, each reference constraint in the target test code may include a hard constraint or a soft constraint, which is not limited in this embodiment.
[0061] In an optional implementation of the present embodiment, after obtaining the second distributed constraint expression, each target constraint in the second distributed constraint expression and each reference constraint in the target test code can be accurately determined; further, each target constraint and each reference constraint can be parsed, and each target constraint and each reference constraint can be marked according to the parsing results to obtain each marked target constraint and each marked reference constraint; further, a target node can be created for each marked target constraint and each marked reference constraint, and each target node can be connected according to the association relationship between each target constraint and each reference constraint to obtain the target topology map; further, the target topology map can be sorted based on a sorting algorithm, and then each target constraint and each reference constraint can be hierarchically divided to obtain different levels; in the present embodiment, there is no limit on the number of target constraints and reference constraints contained in each level.
[0062] Step 140: Determine the solution priority of each target constraint according to the level of each target constraint in the target topology graph, and solve the second distribution constraint expression according to each solution priority.
[0063] Optionally, in this embodiment, after the target topology map is created, the solution priority of each target constraint can be further determined according to the level of each target constraint in the target topology map, and further, the second distribution constraint expression can be solved according to each solution priority.
[0064] It is understandable that the solving priorities of constraints at different levels in the target topology graph are different, and the solving priorities of constraints at the same level are also different.
[0065] In this embodiment, the priorities of different levels can be determined in a bottom-up order. For example, the constraints of the lowest level have the highest priority. For the constraints at the same level, the hard constraints may have the lowest priority, followed by the target constraints, and finally the soft constraints.
[0066] Optionally, in this embodiment, the solution priority of each target constraint is determined according to its level in the target topology map, and the second distribution constraint expression is solved according to each solution priority, which may include: when it is determined that the reference constraints in the target level include hard constraints and soft constraints, the target solution priority of the target level is hard constraints, target constraints and soft constraints; and each constraint in the target level is solved according to the target solution priority.
[0067] The target level may be any level in the target topology map, which is not limited in this embodiment.
[0068] In an optional implementation of this embodiment, if the target hierarchy contains the target constraint, hard constraint and soft constraint of the second distribution constraint expression, the hard constraint has the last priority, followed by the target constraint and finally the soft constraint.
[0069] The technical solution of this embodiment simplifies each distribution constraint expression of the target test code in response to the running instruction of the target test code to obtain each simplified first distribution constraint expression; transforms the first distribution constraint expression to obtain a second distribution constraint expression; creates a target topology map based on each target constraint of the second distribution constraint expression, and divides each target constraint into different levels; determines the solution priority of each target constraint according to the level of each target constraint in the target topology map, and solves the second distribution constraint expression according to each solution priority, which simplifies the solution process of the distribution constraint expression and improves the solution efficiency and accuracy of the distribution constraint expression.
[0070] Embodiment 2
[0071] Figure 21 is a flow chart of a method for solving a distribution constraint according to Embodiment 2 of the present invention. This embodiment is a further refinement of the above technical solution. The technical solution in this embodiment can be combined with each optional solution in one or more of the above embodiments. Figure 2 As shown, the method includes:
[0072] Step 210: compile the target test code, and determine various attribute information of the target test code according to the compilation result.
[0073] The attribute information may include at least one of the following: a random variable, a constraint, and a number of solutions.
[0074] Optionally, in this embodiment, before the target test code is run, the target test code needs to be compiled, and attribute information such as random variables, constraints, and number of solutions in the target test code is determined based on the compilation result.
[0075] Step 220 : In response to the running instruction of the target test code, simplify each distribution constraint expression of the target test code to obtain each simplified first distribution constraint expression.
[0076] Step 230: transform the first distribution constraint expression to obtain a second distribution constraint expression.
[0077] Step 240: Create a target topology graph based on each target constraint of the second distribution constraint expression, and divide each target constraint into different levels.
[0078] Step 250: Determine the solution priority of each target constraint according to the level of each target constraint in the target topology graph, and solve the second distribution constraint expression according to each solution priority.
[0079] The solution of this embodiment can also compile the target test code before it is run, and determine the attribute information such as random variables, constraints and number of solutions in the target test code based on the compilation results, so as to obtain important information related to the target test code and provide a basis for the subsequent solution of the distribution constraint expression.
[0080] In order to better understand the method for solving the distribution constraint expression involved in this embodiment, Figure 3 is a flow chart of a method for solving a distribution constraint expression according to Embodiment 2 of the present invention, with reference to Figure 3 , which mainly includes the following steps:
[0081] Step 310: compile the System Verilog code input by the user in the software simulation tool to obtain random variables, constraints, and solution times.
[0082] Step 320: simplify each range of the distribution constraint expression during the running phase to obtain a simplified distribution constraint expression.
[0083] Step 330: transform the simplified distribution constraint expression, and transform each range into a standard constraint.
[0084] Step 340: Mark the expression converted from each range after the distribution constraint expression is converted, so as to distinguish whether it is an expression converted from the distribution constraint expression or an expression of a common constraint.
[0085] Step 350: Graph the standard constraints converted from the distributed constraints with other constraints in the user design, and divide them into levels to achieve sequential solutions.
[0086] Step 360: Create an independent priority for the constraint after the distribution constraint is converted. The priority should be between the hard constraint and the soft constraint.
[0087] Step 370: Solve the hard constraints, distributed constraints, transformed constraints and soft constraints at each level in sequence to obtain the desired results.
[0088] In a specific example of this embodiment, the distribution constraint expression contains multiple different variables:
[0089] class test;
[0090] rand int x;
[0091] rand int z;
[0092] constraint c_xy
[0093] {
[0094] z>3&&z<5;
[0095] x dist{[z:z+2]: / 8,[z+5:z+7]:=10,10:=4};
[0096] }
[0097] endclass
[0098] From the above code, we can see that the constraint c_xy contains a general constraint and a distribution constraint containing two variables. After converting the distribution constraint into the third distribution constraint:
[0099] The total accumulated weight is: W = 8 + ((z + 7) - (z + 5) + 1) · 10 + 4, where W is an expression representing the total weight;
[0100] Create a random variable P in the total weight range, P∈[0,W); further, range 1 == (z+2)-z+1
[0101] range2==(z+7)-(z+5)+1
[0102] 0=<P&&P<8→x==P / (8 / range 1)
[0103] 8=<P&&P<8+range 2*10→x==(P-8) / range 2;
[0104] 8+range 2*10=<P&&P<W→x==10
[0105] solve z before P
[0106] solve P before x
[0107] Furthermore, the transformed constraints may be solved according to steps 340 - 370 to obtain a solution of the random variable x that conforms to the probability distribution under the influence of the random variable z.
[0108] The solution of this embodiment converts the distribution constraints into general constraints, eliminating the need to design a distribution constraint solver, simplifying the distribution constraint solution process, effectively improving the versatility and efficiency of the distribution constraint solution, and reducing the cost and difficulty of the distribution constraint solution.
[0109] Embodiment 3
[0110] Figure 4 Schematic diagram of a distributed constraint solving device provided according to Embodiment 3 of the present invention. Figure 4 As shown, the device includes: a first distribution constraint expression determination module 410, a second distribution constraint expression determination module 420, a target topology map determination module 430 and a solution module 440.
[0111] The first distribution constraint expression determination module 410 is used to simplify each distribution constraint expression of the target test code in response to the running instruction of the target test code to obtain each simplified first distribution constraint expression;
[0112] A second distribution constraint expression determination module 420, configured to transform the first distribution constraint expression to obtain a second distribution constraint expression;
[0113] A target topology map determining module 430, configured to create a target topology map based on each target constraint of the second distribution constraint expression, and divide each target constraint into different levels;
[0114] The solving module 440 is used to determine the solving priority of each target constraint according to the level of each target constraint in the target topology map, and solve the second distribution constraint expression according to each solving priority.
[0115] The solution of this embodiment is to simplify each distribution constraint expression of the target test code in response to the running instruction of the target test code through the first distribution constraint expression determination module to obtain each simplified first distribution constraint expression; transform the first distribution constraint expression through the second distribution constraint expression determination module to obtain the second distribution constraint expression; create a target topology map based on each target constraint of the second distribution constraint expression through the target topology map determination module, and divide each target constraint into different levels; determine the solution priority of each target constraint according to the level of each target constraint in the target topology map through the solution module, and solve the second distribution constraint expression according to each solution priority, thereby simplifying the solution process of the distribution constraint expression and improving the solution efficiency and accuracy of the distribution constraint expression.
[0116] In an optional implementation of this embodiment, the distribution constraint expression solving device further includes: a compiling module, used to compile the target test code and determine each attribute information of the target test code according to the compilation result;
[0117] The attribute information includes at least one of the following:
[0118] Random variables, constraints, and number of solutions.
[0119] In an optional implementation of this embodiment, the first distribution constraint expression determination module 410 is specifically used to determine each range of the target distribution constraint expression;
[0120] Traversing each character in each of the ranges to determine a target character string that matches the target range;
[0121] Allocating weights to the target range according to the target character string;
[0122] The first distribution constraint expressions are determined according to the weight allocation result.
[0123] In an optional implementation of this embodiment, the second distribution constraint expression determination module 420 is specifically used to determine the variable distribution of the first distribution constraint expression;
[0124] In the case where it is determined that the variables of the first distribution constraint expression are distributed on the left side of the equal sign of the first distribution constraint expression, abstracting the first distribution constraint expression into a third distribution constraint expression;
[0125] determining a total weight of the target first distribution constraint expression based on the third distribution constraint expression;
[0126] Determine each target range of the third distribution constraint expression and a distribution constraint expression matching each target range based on the total weight, the upper limit value and the lower limit value of each range of the first distribution constraint expression, and the weight of each range;
[0127] The second distribution constraint expression is obtained based on each of the target ranges and an expression matching each of the target ranges.
[0128] In an optional implementation of this embodiment, the second distribution constraint expression determination module 420 is further specifically configured to:
[0129] In the case where it is determined that the variable distribution of the first distribution constraint expression is not on the left side of the equal sign of the first distribution constraint expression, the first distribution constraint expression is abstracted into a fourth distribution constraint expression; wherein the upper limit value or the lower limit value of the target range of the fourth distribution constraint expression contains the target variable;
[0130] determining a total weight of the target first distribution constraint expression based on the fourth distribution constraint expression;
[0131] Determine each target range of the fourth distribution constraint expression and a distribution constraint expression matching each target range based on the total weight, the upper limit value and the lower limit value of each range of the first distribution constraint expression, and the weight of each range;
[0132] The second distribution constraint expression is obtained based on each of the target ranges and an expression matching each of the target ranges.
[0133] In an optional implementation of this embodiment, the target topology map determination module 430 is specifically used to determine the target constraints in each of the second distribution constraint expressions and each reference constraint in the target test code;
[0134] Parsing each of the target constraints and each of the reference constraints, and marking each of the target constraints and each of the reference constraints according to the parsing results, to obtain each marked target constraint and each marked reference constraint;
[0135] Creating target nodes for each marked target constraint and each marked reference constraint, and connecting each target node according to the association relationship between each target constraint and each reference constraint to obtain the target topology graph;
[0136] The target topology graph is sorted, and each target constraint and each reference constraint are divided into levels; wherein each target constraint and each reference constraint at the same level have the same priority.
[0137] In an optional implementation of this embodiment, the solving module 440 is specifically configured to determine that, when the reference constraints in the target level include hard constraints and soft constraints, the target solving priority of the target level is hard constraints, target constraints, and soft constraints;
[0138] Each constraint in the target level is solved according to the target solving priority.
[0139] The distribution constraint solving device provided in the embodiment of the present invention can execute the distribution constraint solving method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0140] Embodiment 4
[0141] Figure 5 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0142] like Figure 5As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0143] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0144] The processor 11 can be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The processor 11 executes the various methods and processes described above, such as a method for solving distribution constraints, the method comprising: in response to the running instructions of the target test code, simplifying each distribution constraint expression of the target test code to obtain each simplified first distribution constraint expression; transforming the first distribution constraint expression to obtain a second distribution constraint expression; creating a target topology map based on each target constraint of the second distribution constraint expression, and dividing each target constraint into different levels; determining the solution priority of each target constraint according to the level of each target constraint in the target topology map, and solving the second distribution constraint expression according to each solution priority.
[0145] In some embodiments, the method for solving the distribution constraint may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the method for solving the distribution constraint described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to execute the method for solving the distribution constraint in any other appropriate manner (e.g., by means of firmware).
[0146] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0147] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0148] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0149] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0150] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0151] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0152] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0153] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for solving distribution constraints, characterized in that: include: In response to the running instruction of the target test code, simplify each distribution constraint expression of the target test code to obtain each simplified first distribution constraint expression; Transforming the first distribution constraint expression to obtain a second distribution constraint expression; Creating a target topology graph based on each target constraint of the second distribution constraint expression, and dividing each target constraint into different levels; The solution priorities of the target constraints are determined according to the levels of the target constraints in the target topology graph, and the second distribution constraint expression is solved according to the solution priorities.
2. The method for solving distribution constraints according to claim 1, characterized in that: Before responding to the execution instruction of the target test code, the method further includes: Compiling the target test code, and determining various attribute information of the target test code according to the compilation result; The attribute information includes at least one of the following: Random variables, constraints, and number of solutions.
3. The method for solving distribution constraints according to claim 1, characterized in that: The step of simplifying each distribution constraint expression of the target test code to obtain each simplified first distribution constraint expression includes: Determine the ranges of the target distribution constraint expressions; Traversing each character in each of the ranges to determine a target character string that matches the target range; Allocating weights to the target range according to the target character string; The first distribution constraint expressions are determined according to the weight allocation result.
4. The method for solving distribution constraints according to claim 3, characterized in that: The converting the first distribution constraint expression to obtain a second distribution constraint expression includes: Determining the variable distribution of the first distribution constraint expression; In the case where it is determined that the variables of the first distribution constraint expression are distributed on the left side of the equal sign of the first distribution constraint expression, abstracting the first distribution constraint expression into a third distribution constraint expression; determining a total weight of the target first distribution constraint expression based on the third distribution constraint expression; Determine each target range of the third distribution constraint expression and a distribution constraint expression matching each target range based on the total weight, the upper limit value and the lower limit value of each range of the first distribution constraint expression, and the weight of each range; The second distribution constraint expression is obtained based on each of the target ranges and an expression matching each of the target ranges.
5. The method for solving distribution constraints according to claim 4, characterized in that: The converting the first distribution constraint expression to obtain a second distribution constraint expression further includes: In the case where it is determined that the variable distribution of the first distribution constraint expression is not on the left side of the equal sign of the first distribution constraint expression, the first distribution constraint expression is abstracted into a fourth distribution constraint expression; wherein the upper limit value or the lower limit value of the target range of the fourth distribution constraint expression contains the target variable; determining a total weight of the target first distribution constraint expression based on the fourth distribution constraint expression; Determine each target range of the fourth distribution constraint expression and a distribution constraint expression matching each target range based on the total weight, the upper limit value and the lower limit value of each range of the first distribution constraint expression, and the weight of each range; The second distribution constraint expression is obtained based on each of the target ranges and an expression matching each of the target ranges.
6. The method for solving distribution constraints according to claim 1, characterized in that: The step of creating a target topology map based on each target constraint of the second distribution constraint expression and dividing each target constraint into different levels includes: Determine target constraints in each of the second distributed constraint expressions and each reference constraint in the target test code; Parsing each of the target constraints and each of the reference constraints, and marking each of the target constraints and each of the reference constraints according to the parsing results, to obtain each marked target constraint and each marked reference constraint; Creating target nodes for each marked target constraint and each marked reference constraint, and connecting each target node according to the association relationship between each target constraint and each reference constraint to obtain the target topology graph; The target topology graph is sorted, and each target constraint and each reference constraint are divided into levels; wherein each target constraint and each reference constraint at the same level have the same priority.
7. The method for solving distribution constraints according to claim 1, characterized in that: The determining the solution priority of each target constraint according to the level of each target constraint in the target topology graph, and solving the second distribution constraint expression according to each solution priority, includes: When it is determined that the reference constraints in the target level include hard constraints and soft constraints, the target solution priority of the target level is hard constraints, target constraints and soft constraints; Each constraint in the target level is solved according to the target solving priority.
8. A distribution constraint solving device, characterized in that: include: A first distribution constraint expression determination module is used to simplify each distribution constraint expression of the target test code in response to the running instruction of the target test code to obtain each simplified first distribution constraint expression; A second distribution constraint expression determination module, used for transforming the first distribution constraint expression to obtain a second distribution constraint expression; A target topology map determining module, used to create a target topology map based on each target constraint of the second distribution constraint expression, and divide each target constraint into different levels; A solving module is used to determine the solving priority of each target constraint according to the level of each target constraint in the target topology map, and solve the second distribution constraint expression according to each solving priority.
9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can perform the method for solving distribution constraints according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the method for solving the distribution constraints according to any one of claims 1 to 7 when executed.