Collaborative method, electronic device and storage medium based on multiple constraint solvers
By adopting a collaborative method of multiple constraint solvers in the field of chip verification, the collaborative scheduler selects and propagates candidate variables, solving the problems of low constraint solution efficiency and inaccurate results in the prior art, and achieving more efficient and accurate constraint expression solutions.
Patent Information
- Application Number
- CN202410981970.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-22
- Publication Date
- 2025-06-06
- Estimated Expiration
- 2044-07-22
AI Technical Summary
In the field of chip verification, when the prior art deals with complex constraint problems, the existing types of operations that the target solver is not good at, resulting in low solution efficiency and inaccurate results.
A collaborative method based on multiple constraint solvers is adopted, and the collaborative scheduler selects candidate variables from all constraint solvers and obtains random values, and propagates them within the range of the new subconstraint set and the remaining constraint set of each constraint solver to realize collaborative calculation of all constraint solvers.
The solution efficiency and accuracy of computational constraint expressions are improved, so that all constraint solvers can work together to solve complex constraint problems.
Smart Images

Figure CN118966095B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of chip verification, and in particular to a collaborative method based on multiple constraint solvers, an electronic device and a storage medium. Background Art
[0002] In the field of chip verification, constraint satisfaction problems are often encountered in various scenarios to ensure that the functional correctness and performance indicators of the design meet predefined specifications. For example, in logic function verification, the Boolean function relationship or other logical relationship between logic gates, combinational logic circuits and sequential logic circuits needs to be satisfied, or in timing constraints, the timing design is verified by checking whether the delay constraints on all signal paths are satisfied, or in the layout and routing stage, the constraints designed to ensure the minimum spacing or avoid short circuits, etc. Constraint satisfaction problems are also designed in low-power verification, formal verification or random constraints. Many problems in the field of chip verification can be converted into constraint problems, so that they can be solved using general constraint solvers.
[0003] The general solvers used for solving constraint problems include SAT (Boolean satisfiability problem) solvers, SMT (Satisfiability modulo theories) solvers, CSP (Constraint satisfaction problem) solvers, and BDD (Binary decision diagram)-based solvers. Each type of solver is good at solving different problems. Among them, SAT solvers are good at solving bit operations; SMT solvers are good at solving combinatorial problems, such as constraint problems that combine arithmetic, Boolean logic, arrays, etc.; CSP solvers are good at arithmetic operations, relational operations, and set relational operations; BDD solvers are good at dealing with the representation and optimization of Boolean functions.
[0004] At present, when dealing with constraint problems, the corresponding constraint problems are usually classified in advance according to the operation type, divided into different operation categories, and then the appropriate target solver is matched according to the operation category, and the problem is solved by the target solver. When a complex constraint problem includes different operation types in each expression, it will be classified according to the pre-set priority rules, and the expressions will be divided into corresponding categories, and then solved by the corresponding target solver. However, when there are operation types in the expression that the target solver is not good at, the target solver has low solution efficiency and inaccurate solution results, resulting in technical problems such as low solution efficiency and inaccurate solution results for constraint expressions. Therefore, there is an urgent need for an accurate and efficient calculation method for constraint expressions using an existing solver. Summary of the invention
[0005] In view of the above technical problems, the technical solution adopted by the present invention is: a collaborative method based on multiple constraint solvers, the method comprising:
[0006] P100, obtain N types of constraint solvers CS.
[0007] P200, obtain the constraint conditions P for the expression exp to adapt to CS, where the constraints of each type of constraint solver include the original variable set V of all variables in exp, the current intermediate variable set VM generated by the current constraint solver, the other intermediate variable sets VMC of all constraint solvers except the current constraint solver, the newly added sub-constraint set CC generated by the current constraint solver, and the remaining constraint set CF that cannot be matched by N types of constraint solvers.
[0008] P300, based on P, collaboratively calculates exp, including the following loop steps:
[0009] P310, CS selects candidate variables from their respective V and VM to obtain candidate variables for each type of constraint solver.
[0010] P320, the collaborative scheduler selects L target candidate variables from all candidate variables of CS, and obtains random values of the L target candidate variables respectively, where L is greater than or equal to 1.
[0011] P330, add L target candidate variables and their random values to the list to be propagated bList.
[0012] P340, when the target candidate variable in bList is empty, the collaborative calculation result of exp is obtained and the loop ends.
[0013] P350, when the target candidate variable in bList is not empty, each constraint solver propagates bList within the scope of its respective CC and CF.
[0014] In addition, the present invention also provides a non-transitory computer-readable storage medium, in which at least one instruction or at least one program is stored, and the at least one instruction or the at least one program is loaded and executed by a processor to implement the above method.
[0015] In addition, the present invention also provides an electronic device, including a processor and the above-mentioned non-transitory computer-readable storage medium.
[0016] The present invention has at least the following beneficial effects:
[0017] The present invention relates to the field of chip verification, and in particular to a collaborative method, electronic device and storage medium based on multiple constraint solvers. The collaborative scheduler reselects a target candidate variable from the candidate variables selected by all constraint solvers and obtains a random value of the target candidate variable, and propagates the target candidate variable and its random value within the scope of a newly added sub-constraint set and a remaining constraint set of each constraint solver. The method enables all constraint solvers to perform collaborative calculations, thereby improving the efficiency and accuracy of solving the computational constraint expressions. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] 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.
[0019] Figure 1 A flowchart of a method for adapting a constraint solver provided in Embodiment 1 of the present invention;
[0020] Figure 2 A comparison flow chart before and after traversing the tree structure provided in the first embodiment of the present invention;
[0021] Figure 3 A flow chart of a method for adapting a constraint solver provided in Embodiment 2 of the present invention. DETAILED DESCRIPTION
[0022] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions 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 those skilled in the art without creative work are within the scope of protection of the present invention.
[0023] Embodiment 1
[0024] See also Figure 1 , which shows a flow chart of a method for adapting a constraint solver, the method comprising the following steps:
[0025] S100, obtaining N types of constraint solver sequences CS to be adapted and their adapted operation types; wherein CS={CS 1 ,CS 2 ,…,CS i ,…,CS N}, CS i is the i-th constraint solver in CS, and the value of i ranges from 1 to N.
[0026] Optionally, the type of constraint solver is a SAT (Boolean satisfiability problem) solver, a SMT (Satisfiability modulo theories) solver, a CSP (Constraint satisfaction problem) solver, or a BDD (Binary decision diagram) based solver. Other types of solvers in the prior art also fall within the protection scope of the present invention.
[0027] Among them, there are different types of constraint solvers in CS.
[0028] The adapted operation type refers to the operation type that the constraint solver is good at.
[0029] Optionally, the operation type adapted by the SAT solver is bit operation, and the non-adaptive operation type is arithmetic operation, relational operation and arithmetic operation. The operation types adapted by the CSP solver are arithmetic operation, relational operation and set relational operation, and the non-adaptive operation type is bit operation. The operation type adapted by the SAT solver and the CSP solver is logical operation. In the prior art, other constraint solvers and their adapted operation types also fall within the protection scope of the present invention.
[0030] S200, obtaining a constraint expression exp of a constraint solver to be adapted.
[0031] The constraint problem includes variables, constants and constraint expressions, wherein the variables are signed or unsigned bit vectors with fixed bit width.
[0032] The constraint expression includes operands and operators, and the operands are constants or variables.
[0033] Optionally, the operator is one or more of a logical operator, a bit operator, an arithmetic operator, a relational operator, an if-then-else operator, and a set relational operator. In the prior art, other operators included in the expression also fall within the protection scope of the present invention.
[0034] As an example, the constraint problem is: x is a random variable of an 8-bit vector, and the constraint expression is: x>0&&x<11.
[0035] S300, constructing a tree structure tree of the constraint expression according to exp.
[0036] It should be noted that S300 converts the text expression exp into a structured expression tree, and the structured expression is more conducive to computer processing.
[0037] Each node in the tree is an operand or an operator, and the edges between nodes are the relationships between nodes.
[0038] The methods of constructing a tree structure according to expressions in the prior art all fall within the protection scope of the present invention.
[0039] S400, traverse the tree to obtain the operation type, and obtain the constraint condition P={P 1 ,P 2 ,…,P i ,…,P N}, P i To adapt to CS i The constraint condition of P i =(V,VM i ,VMC(i),CC i ,CF), V is the original variable set of all variables in exp, VM i To adapt to CS i The current intermediate variable set generated, VMC(i) is the variable in CS except CS i Other intermediate variable sets of all constraint solvers except CC i For CS i The newly generated sub-constraint set, CF, is the remaining constraint set that cannot be matched by any of the N types of constraint solvers.
[0040] Among them, the operation type of the sub-expression corresponding to the maximum subtree obtained by traversing the tree is matched to a constraint solver that is good at processing the current operation type.
[0041] Among them, P i Can be empty. When the tree is traversed, if there is no matching CS in the tree i When the operation type is P i Is empty.
[0042] Among them, the original variable set V of all sub-constraints in P is the same, which is all the variables in exp. After traversing the tree, V is obtained.
[0043] Among them, VM i Each intermediate variable in VM is created when adapting the current constraint solver. i Each intermediate variable in CC i There is a corresponding new sub-constraint in VM i The number of elements in CC i The number of elements in VM is equal. iThe newly added sub-constraints in are defined as the mapping relationship between each current intermediate variable and the sub-expression in the exp it replaces.
[0044] Among them, when VM in VMC(i) rp The subtree where the VM is located i VM in ij When replacing, VM rp To adapt the rth constraint solver CS r The pth current intermediate variable VM generated rp , in CC ij VM rp By analogy, all generated intermediate variables will appear in all adapted sub-expressions. Therefore, when adapting CS i The constraint condition P i Includes all variables and intermediate variables: V, VM i , VMC(i). Similarly, the constraint sub-conditions adapted to other constraint solvers also include all variables and intermediate variables.
[0045] Each remaining constraint in the remaining constraint set CF is a constraint corresponding to an operation type that cannot be adapted after being adapted to the N types of constraint solvers. The remaining constraint sets of all sub-constraint conditions in P are the same.
[0046] Further, P i The jth current intermediate variable VM ij and its newly added sub-constraint CC ij The adaptation steps include:
[0047] S410, obtaining the tree structure tree′ of the last adaptation update.
[0048] During the traversal process, each adaptation is performed based on the last updated tree structure.
[0049] S420, traverse upward from the leaf nodes of tree′, and adapt CS according to the traversal i The operation type obtains the maximum subtree subtree that is suitable for i , and according to subtree i Get CS i The jth subexpression subexp ij .
[0050] Among them, subtree i The steps to obtain include:
[0051] S421, traverse upward from the leaf node along the path to the root node. When the operation type of the traversed node is adapted to CS i, continue to traverse upwards; when the operation type of the traversed operator node does not match CS i When , fall back to the last traversal of the adaptation CS i The operator node of the traversal is then returned to continue traversing on another branch. The method for determining the operation type to which the node belongs is: when traversing to the operator node, the operation type is determined according to the operator node.
[0052] S422, after traversing all potential paths, the traversal ends and the subtree is obtained i .
[0053] After traversing the entire tree, multiple matching CS can be obtained. i The largest subtree of .
[0054] In the prior art, other methods for obtaining subtree i All of the methods fall within the protection scope of the present invention.
[0055] S430, create CS i The jth current intermediate variable VM ij .
[0056] S440, subtree in tree′ i Replace with a bound VM ij 's node to obtain the updated tree structure tree".
[0057] Among them, bind VM ij The nodes are leaf nodes in the tree". The nodes in the tree include variables, operators and intermediate variables.
[0058] S450, according to VM ij and subexp ij Generate CS i New sub-constraint CC ij .
[0059] Optional, VM ij and CC ij Meets: CC ij :=VM ij ==subexp ij Among them, “:=” is a definition symbol, which means CC ij The constraint sub-condition is defined as "VM ij ==subexp ij ”, “VM ij ==subexp ij "Indicates using VM ij Represents subexp ijIn the prior art, other VM ij and subexp ij Methods of defining constraints also fall within the scope of protection of the invention.
[0060] As an example, when the VM ij When the subexpression represented is "a|(b&c)", CC ij Meets: CC ij :=VM ij ==a|(b&c).
[0061] As a preferred embodiment, S400 further includes:
[0062] S470, obtaining a remaining constraint set CF, wherein the hth remaining constraint CF ih The steps to obtain include:
[0063] S471, when traversing upward from the leaf node of tree′, obtain the target operation type to which the traversed node belongs. When the target operation type is incompatible with all N types of constraint solvers, obtain the hth incompatible subtree Usubtree ih ; and according to Usubtree ih Get the hth unsuitable subexpression Usubexp ih The method for determining the target operation type to which the node belongs is: when traversing to the operator node, the target operation type is determined according to the operator node.
[0064] S472, create the hth intermediate variable VF h .
[0065] S473, according to VF h and Usubexp ih Generate the hth remaining constraint CF of CF ih .
[0066] In the prior art, other methods for obtaining the residual constraint set all fall within the protection scope of the present invention.
[0067] As a preferred embodiment, S400 also includes: when the operation type of the current operator being traversed is compatible with L-type constraint solvers, and the last adapted constraint solver is one of the L-type constraint solvers, adapting the current operator to the last adapted constraint solver.
[0068] It is understandable that during the traversal process, the largest subtree subtree that is adapted i Replaced with the intermediate variable VM ijAnd update the tree structure tree″, and when traversing the next node, the traversal is based on tree″. When all traversals are completed, all constraints of all constraint solvers adapted by exp are obtained.
[0069] As an example, CS = {CS 1 ,CS 2}, where CS 1 For SAT solver, CS 2 is a CSP solver, CS 1 The operations that are applicable are bit operations and logical operations. 2 The applicable operations are arithmetic operations, relational operations, set relational operations, and logical operations. The constraint expression is: g->((x+(y×z))>(a|(b&c))). The tree structure of the constraint expression is tree. Please refer to Figure 2 a, which shows the tree. First, adapt CS 1 , traverse upward from the leaf nodes of the tree to obtain the adapted CS 1 The largest subtree 1 , subtree 1 The corresponding sub-expression is "a|(b&c)". Create CS 1 The first intermediate variable VM 11 , using VM 11 Replace subtree 1 , and update the tree structure to get tree′, according to VM 11 and subtree 1 Generate the first new sub-constraint: CC 11 :=VM 11 ==(a|(b&c)). The tree structure of tree′ is as follows Figure 2 b, and then adapt CS 2 , traverse upward from the leaf nodes of tree′ to obtain the adapted CS 2 The largest subtree 2 , subtree 2 The corresponding sub-expression is "((x+(y×z))>VM 11 ". Create CS 2 The first intermediate variable VM 21 , using VM 21 Replace subtree 2 , and update the tree structure to get tree″, according to VM 21 and subtree 2 Generate the first new sub-constraint: CC 21 :=VM 21 = = ((x+(y×z)) > VM11 The tree structure of tree" is as follows Figure 2 As shown in c, since the last remaining operator is "->", the operation type of this logical operation is the same as CS 1 Adaptation and CS 2 Adaptation, since the last adapted constraint solver is CS 2 In order to optimize the algorithm, we continue to adapt CS 2 , traverse upward from the leaf nodes of tree″ to obtain the adapted CS 2 The largest subtree 3 , subtree 3 The corresponding sub-expression is "g->VM 21 ". Create CS 2 The second intermediate variable VM 22 , using VM 22 Replace subtree 3 , and finally replace the tree structure with a node, according to VM 22 and subtree 3 Generate the second new sub-constraint: CC 22 :=VM 22 ==g->VM 21 After the traversal is completed, the constraint conditions P = {P 1 ,P 2}, where P 1 =(V,VM 1 ,VM 2 ,CC 1 ,CF),P 2 =(V,VM 2 ,VM 1 ,CC 2 ,CF). Among them, the original variable set V={a,b,c,x,y,z,g}, VM 1 = {VM 11}, VM 2 = {VM 21 ,VM 22}, CC 1 ={CC 11}, CC 2 ={CC 21 ,CC 22},
[0070] In summary, the present invention provides a method for adapting a constraint solver, which presets different types of constraint solvers and their adapted operation types, converts the constraint expression to be adapted into a tree structure, adapts the obtained operation type to the preset different types of constraint solvers in the process of traversing the tree structure, replaces the adapted maximum subtree with a node of an intermediate variable, and then continues to traverse and adapt, and finally completes the decomposition of the constraint expression into multiple sub-constraints adapted to different constraint solvers, and the sub-constraints obtained by each constraint solver are all operation types that the current constraint solver is good at, thereby improving the solution efficiency of the constraint solver and the accuracy of the solution results.
[0071] Embodiment 1 of the present invention also provides a non-transitory computer-readable storage medium, which can be set in an electronic device to store at least one instruction or at least one program related to implementing a method in the method embodiment. The at least one instruction or the at least one program is loaded and executed by the processor to implement the method provided in the above embodiment.
[0072] Embodiment 1 of the present invention further provides an electronic device, including a processor and the aforementioned non-transitory computer-readable storage medium.
[0073] Embodiment 1 of the present invention further provides a computer program product, which includes program code. When the program product is run on an electronic device, the program code is used to enable the electronic device to execute the steps of the method according to various exemplary embodiments of the present invention described above in this specification.
[0074] The method provided in the first embodiment of the present invention can improve the solving efficiency and solving accuracy of each solver, but there may be dependencies between multiple sub-constraints adapted by different constraint solvers. When N constraint solvers jointly solve the same constraint expression, the sub-constraints may wait for each other, resulting in low computing efficiency. Therefore, based on the first embodiment, the present invention also provides a second embodiment, which optimizes the collaborative process of N constraint solvers to improve computing efficiency.
[0075] Embodiment 2
[0076] See also Figure 3 , which shows a flow chart of a collaborative method based on multiple constraint solvers, the method comprising:
[0077] P100, obtain N types of constraint solvers CS.
[0078] Optionally, the constraint solver may also be a core algorithm of the constraint solver.
[0079] P200, obtain the constraint conditions P of each type of constraint solver in CS that adapts the constraint expression exp, where the constraints of each type of constraint solver include the original variable set V of all variables in exp, the current intermediate variable set VM generated by the current constraint solver, the other intermediate variable sets VMC of all constraint solvers except the current constraint solver, the newly added sub-constraint set CC generated by the current constraint solver, and the remaining constraint set CF that cannot be matched by N types of constraint solvers.
[0080] It should be noted that the constraint solver CS, constraint expression exp, constraint condition P and the steps for obtaining the same in the first embodiment are all applicable to the second embodiment and will not be described in detail.
[0081] As can be seen from the first embodiment, the i-th constraint solver CS i VM i The jth current intermediate variable VM ij The steps of obtaining include: when the subexpression subexp of exp ij The operation type and the i-th constraint solver CS i When the operation type that the binding is good at is adapted, subexp ij Replace with VM ij CS i CC i The jth newly added sub-constraint CC ij The acquisition steps include: according to subexp ij and VM ij Generate CS i New sub-constraint CC ij .
[0082] P300, based on P, collaboratively calculates exp, including the following loop steps:
[0083] P310, each type of constraint solver in CS selects candidate variables from V and its own VM respectively to obtain candidate variables for each type of constraint solver.
[0084] The step of selecting candidate variables is completed inside each constraint solver. The candidate variables selected by each constraint solver are original variables in the original variable set or intermediate variables in the current intermediate variable set.
[0085] Optionally, each type of constraint solver selects candidate variables according to preset internal rules, wherein the internal rules are rules for selecting variables within each type of constraint solver preset in advance by the user.
[0086] P320, the collaborative scheduler selects L target candidate variables from all candidate variables of CS, and obtains random values of the L target candidate variables respectively, where L is greater than or equal to 1, and L≤N.
[0087] Optionally, a collaborative scheduler is used to collaboratively solve multiple constraint solvers. It is a pre-designed, reusable software structure framework that is responsible for scheduling each constraint solver to collaboratively calculate and solve.
[0088] Optionally, the collaborative scheduler selects target candidate variables according to preset global rules. The global rules are rules preset in advance for reselecting target candidate variables from candidate variables of all constraint solvers. Optionally, the global rules include the frequency of occurrence of candidate variables and the value range of candidate variables. In the prior art, other rules for selecting target candidate variables also fall within the protection scope of the present invention.
[0089] P330, add L target candidate variables and their random values to the list to be propagated bList.
[0090] P340, when the target candidate variable in bList is empty, the collaborative calculation result of exp is obtained and the loop ends.
[0091] It should be noted that when the target candidate variable in bList is empty, it means that all the original variables of V in P310 and all the intermediate variables of all constraint solvers have been selected and propagated, and all variables have obtained corresponding values. At this time, the collaborative calculation result of exp can be obtained.
[0092] P350, when the target candidate variable in bList is not empty, each constraint solver propagates bList within the scope of its respective CC and CF.
[0093] It can be understood that by propagating bList, it can be ensured that within the scope of CC and CF of each constraint solver, when the value of the target candidate variable changes, all other variables and constraints affected by this change can be updated accordingly, so that the entire system can meet all constraints. This collaborative method selects the target candidate variable and its random value through the collaborative scheduler, so that N constraint solvers can perform collaborative calculations, thereby improving the calculation efficiency.
[0094] All the prior art propagation mechanisms for propagating variable values fall within the protection scope of the present invention.
[0095] It is important to understand that when the value of a variable is propagated and updated, the impact of the updated value of the variable on the constraints and other variables related to it is checked. If the updated value does not satisfy the current constraints, the values of other variables related to it are adjusted to re-satisfy the current constraints. This process is performed recursively until a stable state is reached, that is, all constraints are satisfied, or it is determined that there is no solution.
[0096] As a preferred embodiment, the P350 further includes an i-th constraint solver CS i Propagate the tth target candidate variable var t and its rth random value data r Steps:
[0097] P351, when CS i When a conflict occurs during the propagation process, it returns to the co-scheduler, which calls CS i The rollback function executes steps P3511-P3513 to roll back.
[0098] A conflict is when a variable value is changed or assigned a value that violates other existing constraints. There are many types of conflicts. For example, a logical conflict occurs when the value of a variable causes a directly related constraint to no longer hold.
[0099] Among them, each constraint solver has three functions. The first function is to select candidate variables, the second function is the propagation function, and the third function is the fallback function.
[0100] P3511, get var t The current range of t .
[0101] Among them, data r var t The random value of t var t All possible values that can be obtained theoretically. During the propagation process, if var t The value is determined, which actually reduces the range t Reduced to data r When data r When the propagation fails, it means data r The constraints cannot be met and need to be changed from rang t Excluded.
[0102] P3512, data r From rang t Exclude from the equation, and get var t The update range of rang t ′.
[0103] P3513, when rang t ' is not empty, the process returns to S310; otherwise, the return is unsuccessful, the calculation fails, and the loop of S300 is exited.
[0104] It should be noted that if rang t' is empty, indicating that there is no possible value that can satisfy all relevant constraints, that is, the constraint expression has no solution, so the calculation fails. Determining the value of each variable by this fallback method can reduce the amount of calculation and improve the calculation efficiency.
[0105] Other fallback methods for conflicts in the prior art all fall within the protection scope of the present invention.
[0106] As a preferred embodiment, the P350 further includes an i-th constraint solver CS i The propagation of the tth target candidate variable var t and its rth random value data r Steps:
[0107] P352, when CS i When no conflict occurs during the propagation process, the following steps are included:
[0108] P3521, check V, CS i The current set of intermediate variables VM i , except CS i Whether the current value range of the variable in other intermediate variable sets VMC(i) of all other constraint solvers has changed.
[0109] Among them, var t data r When changes occur, it will cause direct or indirect dependence on var t The range of other variables of has changed. That is, when var t Random value data r Once determined, the constraints associated with it will be re-evaluated, which in turn affects the legal value range of other variables that depend on these constraints. r The propagation not only updates var t The actual value of , and more importantly, the value range of the variables in all constraints is adjusted through propagation.
[0110] P3522, if it exists, gets the intersection of the value ranges before and after the change.
[0111] P3523, if the intersection is not empty, then var t andrang t Add to the list to be propagated and return P350. In this way, the values of the variables that satisfy the constraints are synchronized to all constraint solvers.
[0112] Other methods of synchronizing variable values in the prior art all fall within the protection scope of the present invention.
[0113] As a preferred embodiment, P352 also includes:
[0114] P3524, if the intersection is empty, it is determined that a conflict has occurred and the rollback process is performed according to P351.
[0115] As a preferred embodiment, P350 also includes:
[0116] P353, the co-scheduler excludes the target candidate variables whose values have been determined from bList and returns to S310. For example, the following two cases are target candidate variables whose values have been determined: First, when the random value of the current variable is successfully propagated, the value range of the current variable is the random value of the successful propagation. Second, during the propagation process, the value range of a certain variable is reduced to a value. It has been determined that the value of the current variable satisfies all constraints, so no further propagation is required.
[0117] In summary, the present invention provides a collaborative method based on multiple constraint solvers, which selects candidate variables through each constraint solver, and then selects the target candidate variable from all candidate variables again through the collaborative scheduler and obtains the random value of the target candidate variable, adds the target candidate variable and its random value to the propagation list, and each constraint solver propagates bList within the scope of its own newly added sub-constraint set and the remaining constraint set. This collaborative method enables all constraint solvers to perform collaborative calculations, thereby improving the efficiency and accuracy of solving the computational constraint expression.
[0118] An embodiment of the present invention also provides a non-transitory computer-readable storage medium, which can be set in an electronic device to store at least one instruction or at least one program related to implementing a method in a method embodiment. The at least one instruction or the at least one program is loaded and executed by the processor to implement the method provided in the above embodiment.
[0119] An embodiment of the present invention further provides an electronic device, comprising a processor and the aforementioned non-transitory computer-readable storage medium.
[0120] An embodiment of the present invention further provides a computer program product, which includes program code. When the program product is run on an electronic device, the program code is used to enable the electronic device to execute the steps of the method according to various exemplary embodiments of the present invention described above in this specification.
[0121] Although some specific embodiments of the present invention have been described in detail by way of example, it should be understood by those skilled in the art that the above examples are for illustration only and are not intended to limit the scope of the present invention. It should also be understood by those skilled in the art that various modifications may be made to the embodiments without departing from the scope and spirit of the present invention. The scope of the present invention is defined by the appended claims.
Claims
1. A collaborative method based on multiple constraint solvers, characterized in that: The method comprises: P100, obtain N types of constraint solvers CS; P200, obtain the constraint condition P of the expression exp adapted to CS, where the constraint conditions of each type of constraint solver include the original variable set V of all variables in exp, the current intermediate variable set VM adapted to the current constraint solver, the other intermediate variable sets VMC of all constraint solvers except the current constraint solver, the newly added sub-constraint set CC generated by the current constraint solver, and the remaining constraint set CF that cannot be matched by N types of constraint solvers; P300, based on P, collaboratively calculates exp, including the following loop steps: P310, CS selects candidate variables from their respective V and VM to obtain candidate variables for each type of constraint solver; P320, the collaborative scheduler selects L target candidate variables from all candidate variables of CS, and obtains random values of the L target candidate variables respectively, where L is greater than or equal to 1; P330, add L target candidate variables and their random values to the list to be propagated bList; P340, when the target candidate variable in bList is empty, the collaborative calculation result of exp is obtained and the loop ends; P350, when the target candidate variable in bList is not empty, each constraint solver propagates bList within the scope of its respective CC and CF.
2. The method according to claim 1, characterized in that The P350 also includes a class i constraint solver CS i Propagate the tth target candidate variable var t and its rth random value data r Steps: P351, when CS i When a conflict occurs during the propagation process, it returns to the co-scheduler, which calls CS i The rollback function performs the following steps to roll back: P3511, get var t The current range of t ; P3512, data r From rang t Exclude from the equation, and get var t The update range of rang t ′; P3513, when rang t When ' is not empty, return to S310; otherwise, the return is unsuccessful, the calculation fails, and the loop of P300 is exited.
3. The method according to claim 2, characterized in that The P350 also includes a class i constraint solver CS i The propagation of the tth target candidate variable var t and its rth random value data r Steps: P352, when CS i When no conflict occurs during the propagation process, the following steps are included: P3521, check V, CS i The current set of intermediate variables VM i , except CS i Whether there is a change in the current value range of the variable in the other intermediate variable sets VMC(i) of all other constraint solvers except ; P3522, if it exists, obtain the intersection of the value ranges before and after the change; P3523, if the intersection is not empty, then var t andrang t Add to the list to be broadcast and return P350.
4. The method according to claim 3, characterized in that P352 also includes: P3524, if the intersection is empty, it is determined that a conflict has occurred and the rollback process is performed according to P351.
5. The method according to claim 1, characterized in that The P350 also includes: P353, the co-scheduler excludes the target candidate variables whose values have been determined from bList and returns to P310.
6. The method according to claim 1, characterized in that The collaborative scheduler in P320 selects target candidate variables according to preset global rules.
7. The method according to claim 1, characterized in that P200 also includes: i-th type constraint solver CS i VM i The jth current intermediate variable VM ij The steps of obtaining include: when the subexpression subexp of exp ij The operation type and the i-th constraint solver CS i When the operation type that the binding is good at is adapted, subexp ij Replace with VM ij .
8. The method according to claim 7, characterized in that Also included in P200: CS i CC i The jth newly added sub-constraint CC ij The acquisition steps include: according to subexp ij and VM ij Generate CS i New sub-constraint CC ij .
9. A non-transitory computer-readable storage medium, wherein at least one instruction or at least one program is stored in the storage medium, characterized in that: The at least one instruction or the at least one program is loaded and executed by the processor to implement the method according to any one of claims 1 to 8.
10. An electronic device, characterized in that: The invention comprises a processor and the non-transitory computer-readable storage medium as claimed in claim 9.
Citation Information
Patent Citations
Preprocessing method of constraint solver input signal, electronic equipment and storage medium
CN116933015A
Constraint variable classification method, electronic equipment and storage medium
CN118013342A