Lightweight two-dimensional constraint solver optimization method based on conflict interaction detection
By constructing a constraint interaction graph and implementing hierarchical conflict handling, the efficiency problem of 2D constraint solvers in interactive modification scenarios is solved, achieving accurate conflict location and reduction of computational scale, thereby improving the response speed of large-size sketch design.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- JIANGSU INSPIRE INTERNET OF THINGS TECH CO LTD
- Filing Date
- 2026-06-30
- Publication Date
- 2026-07-31
AI Technical Summary
Existing 2D constraint solvers are inefficient in incremental solving in interactive modification scenarios, suffer from inaccurate conflict localization and excessive redundant calculations, and are difficult to adapt to large-size sketch designs.
By constructing a constraint interaction graph and utilizing historical propagation fingerprints to quickly locate conflict hotspots, reversible pruning and hierarchical conflict handling are performed. Combined with intent-driven cost-optimal resolution decisions and phased incremental solutions, the computational scale and efficiency of the constraint solver are optimized.
It achieves precise location of the conflict area, significantly reduces the amount of computation, improves the response speed in large-size sketch interaction scenarios, and meets the needs of real-time interaction.
Smart Images

Figure CN122490628A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, and more specifically to a lightweight two-dimensional constraint solver optimization method based on conflict interaction detection. Background Technology
[0002] Two-dimensional constraint solvers are the core modules of two-dimensional geometric interactive systems such as parametric design and sketch modeling. They are responsible for deriving variable values that satisfy the constraint relationships based on various geometric constraints added by the user. During the interaction process, user modifications often only affect a small number of constraints, but most existing solvers will resolve the entire set of constraints. As the design scale increases, the time cost of full-scale solving will gradually increase, which cannot meet the needs of real-time interaction.
[0003] Meanwhile, most existing incremental solution methods only screen affected constraints based on topological changes, without performing targeted hierarchical processing of conflicts generated during the interaction process. This can easily lead to unnecessary full-graph propagation solutions and retain a large amount of redundant conflict resolution calculations, further reducing solution efficiency.
[0004] Therefore, in the existing technology, the incremental solution efficiency of two-dimensional constraint solvers for interactive modification scenarios is insufficient, and there are technical problems such as inaccurate conflict location, excessive redundant calculations, and difficulty in adapting to large-size sketch design. Summary of the Invention
[0005] This application provides a lightweight 2D constraint solver optimization method based on conflict interaction detection. This addresses the technical problems of existing 2D constraint solvers, such as insufficient incremental solution efficiency in interactive modification scenarios, inaccurate conflict localization, excessive redundant computation, and difficulty in adapting to large-size sketch designs. The method achieves precise conflict localization, effectively reducing the computational scale of incremental solutions. Simultaneously, hierarchical conflict handling reduces redundant resolution computations, improving the response speed of constraint solving in large-size sketch interaction scenarios and meeting the technical requirements of real-time interaction.
[0006] This application provides a lightweight two-dimensional constraint solver optimization method based on conflict interaction detection. The method includes: constructing a constraint interaction graph and performing propagation fingerprint similarity matching between the constraint interaction graph and the historical solution cache module of the lightweight two-dimensional constraint solver to determine the current interaction conflict hot zone; extracting the affected constraint subgraph from the constraint interaction graph based on the current interaction conflict hot zone, and performing reversible pruning on the affected constraint subgraph to obtain a pruned constraint subgraph with a pruning recovery identifier; constructing a conflict type hierarchical matrix of the pruned constraint subgraph, and performing resolution decision optimization through a conflict resolution cost model and the conflict type hierarchical matrix to obtain a target conflict resolution strategy; optimizing the pruned constraint subgraph according to the target conflict resolution strategy to establish an optimized constraint subgraph, and calling the lightweight two-dimensional constraint solver to perform incremental solving on the optimized constraint subgraph to obtain local constraint solution results; and calling the lightweight two-dimensional constraint solver to perform recovery verification and correction on the local constraint solution results according to the pruning recovery identifier.
[0007] In the implementation, constructing a constraint interaction graph includes: acquiring two-dimensional object data, geometric variable data, constraint relationship data, and current interaction operation data; abstracting the two-dimensional object data into object nodes, the geometric variable data into variable nodes, the constraint relationship data into constraint nodes, and the current interaction operation data into interaction event nodes; establishing multiple object variable edges based on the subordinate relationship between the two-dimensional object data and the geometric variable data; establishing multiple variable constraint edges based on the reference relationship between the geometric variable data and the constraint relationship data; establishing multiple interaction influence edges based on the influence relationship of the current interaction operation data on the two-dimensional object data, the geometric variable data, and the constraint relationship data; and connecting the object nodes, variable nodes, constraint nodes, and interaction event nodes based on the multiple object variable edges, the multiple variable constraint edges, and the multiple interaction influence edges to obtain the constraint interaction graph.
[0008] In the implementation, the constraint interaction graph is compared with the historical solution cache module of the lightweight 2D constraint solver to determine the current interaction conflict hotspot. This includes: starting from the interaction event node, performing a multilateral propagation search on the constraint interaction graph to obtain the current interaction propagation path; generating a current propagation fingerprint based on the current interaction propagation path; evaluating the similarity between the current propagation fingerprint and each historical propagation fingerprint in the historical solution cache module to obtain multiple fingerprint similarities; filtering each historical propagation fingerprint based on the multiple fingerprint similarities to obtain a similar matching fingerprint set; and mapping the conflict characteristics of the constraint interaction graph based on the similar matching fingerprint set and the historical solution cache module to obtain the current interaction conflict hotspot.
[0009] In the implementation, constructing a conflict type hierarchical matrix for the clipped constraint subgraph includes: performing geometric consistency detection on the clipped constraint subgraph to obtain geometric contradiction detection results; performing degree-of-freedom balance detection on the clipped constraint subgraph to obtain constraint balance detection results; performing redundant constraint detection on the clipped constraint subgraph to obtain constraint redundancy detection results; performing interaction intent deviation detection on the clipped constraint subgraph to obtain constraint deviation detection results; and performing matrix processing on the geometric contradiction detection results, constraint balance detection results, constraint redundancy detection results, and constraint deviation detection results to generate the conflict type hierarchical matrix.
[0010] In the implementation, the conflict resolution cost model and the conflict type hierarchical matrix are used to perform conflict resolution decision optimization to obtain the target conflict resolution strategy. This includes: reconstructing the constraint node priorities of the pruned constraint subgraph according to the interaction intent weights to obtain an intent-driven constraint priority sequence; generating a candidate conflict resolution strategy set based on the conflict type hierarchical matrix and the intent-driven constraint priority sequence; performing feasibility verification on the candidate conflict resolution strategy set to obtain a feasible conflict resolution strategy set; calculating the cost of the feasible conflict resolution strategy set according to the conflict resolution cost model to obtain multiple conflict resolution costs; and iteratively optimizing the feasible conflict resolution strategy set based on the multiple conflict resolution costs to generate the target conflict resolution strategy.
[0011] In the implementation, the lightweight two-dimensional constraint solver is invoked to perform incremental solving on the optimized constraint subgraph to obtain local constraint solution results. This includes: extracting a set of variables to be solved, a set of frozen variables, a set of effective constraints, a set of degraded constraints, and a constraint solution order queue based on the optimized constraint subgraph; locking the state of two-dimensional objects or variable nodes not affected by the current interaction operation based on the set of frozen variables, and using the set of variables to be solved as the object of this incremental solution; constructing a local incremental solution task based on the object of this incremental solution, the set of effective constraints, the set of degraded constraints, and the constraint solution order queue; invoking the lightweight two-dimensional constraint solver to solve the local incremental solution task in stages to obtain multiple feasible solution results; and selecting the feasible solution result with the smallest geometric state change and consistent with the current interaction direction from the multiple feasible solution results as the local constraint solution result.
[0012] In the implementation, based on the clipped recovery identifier, the lightweight two-dimensional constraint solver is invoked to perform recovery verification and correction on the local constraint solution result, including: writing the local constraint solution result back to the constraint interaction graph to obtain the written-back constraint interaction graph; performing recovery verification on the clipped recovery identifier based on the written-back constraint interaction graph to obtain the clipping recovery verification result; if the clipping recovery verification result meets a preset recovery threshold, outputting the local constraint solution result; if the clipping recovery verification result does not meet the preset recovery threshold, restoring the clipped recovery identifier to the optimized constraint subgraph to generate a restored extended constraint subgraph; and invoking the lightweight two-dimensional constraint solver to perform a second incremental solution on the restored extended constraint subgraph to obtain the corrected local constraint solution result.
[0013] In the implementation, the current interactive operation data includes the interactive object, interactive type, interactive direction, interactive displacement, interactive trajectory, constraint addition information, constraint deletion information, and constraint parameter modification information.
[0014] In the implementation, the pruning recovery identifier includes the pruned node identifier, the pruned edge identifier, the constraint state before pruning, the variable value before pruning, and the pruning reason.
[0015] In the implementation, the local incremental solution task includes a hard constraint solution subtask, a soft constraint approximation subtask, a degraded constraint tolerance subtask, and an interaction intent preservation subtask.
[0016] This application proposes a lightweight 2D constraint solver optimization method based on conflict interaction detection. By constructing a constraint interaction graph with multiple nodes and various edge types, and utilizing historical propagation fingerprints to quickly locate conflict hotspots, combined with reversible pruning of affected constraint subgraphs, intent-driven cost-optimal resolution decisions, and phased incremental solving with recovery verification, the computational load is significantly reduced, and the efficiency of conflict detection and resolution is greatly improved. Simultaneously, it ensures the priority satisfaction of user interaction intent and the overall stability and consistency of the constraint system. This addresses the technical problems of insufficient incremental solving efficiency in existing 2D constraint solvers for interactive modification scenarios, including inaccurate conflict localization, excessive redundant computation, and difficulty in adapting to large-size sketch designs. It achieves precise location of the conflict range, effectively reducing the computational scale of incremental solving. Furthermore, hierarchical conflict handling reduces redundant resolution computation, improving the response speed of constraint solving in large-size sketch interaction scenarios and meeting the technical requirements of real-time interaction. Attached Figure Description
[0017] To more clearly illustrate the technical solutions of the embodiments of this disclosure, the accompanying drawings of the embodiments of this disclosure will be briefly described below. Flowcharts are used in this application to illustrate the operations performed by the system according to the embodiments of this application. It should be understood that the preceding or following operations are not necessarily performed precisely in sequence. Instead, various steps can be processed in reverse order or simultaneously as needed. Furthermore, other operations can be added to these processes, or one or more steps can be removed from these processes.
[0018] Figure 1 This is a schematic diagram of the optimization method for a lightweight two-dimensional constraint solver based on conflict interaction detection, provided in an embodiment of this application.
[0019] Figure 2 This is a schematic diagram illustrating the process of constructing a constraint interaction graph in the lightweight two-dimensional constraint solver optimization method based on conflict interaction detection provided in the embodiments of this application. Detailed Implementation
[0020] To further illustrate the technical means and effects of the present invention in achieving its intended purpose, the following detailed description of the specific implementation methods, structures, features and effects of the present invention, in conjunction with the accompanying drawings and preferred embodiments, is provided below.
[0021] In this embodiment, the present application provides a lightweight two-dimensional constraint solver optimization method based on conflict interaction detection, such as... Figure 1 As shown, the method includes: Step S100: Construct a constraint interaction graph and perform propagation fingerprint similarity matching between the constraint interaction graph and the historical solution cache module of the lightweight two-dimensional constraint solver to determine the current interaction conflict hot zone; Furthermore, such as Figure 2As shown, step S100, which involves constructing a constraint interaction graph, further includes: Step S110: acquiring two-dimensional object data, geometric variable data, constraint relationship data, and current interaction operation data; Step S120: abstracting the two-dimensional object data into object nodes, the geometric variable data into variable nodes, the constraint relationship data into constraint nodes, and the current interaction operation data into interaction event nodes; Step S130: establishing multiple object variable edges based on the subordinate relationship between the two-dimensional object data and the geometric variable data; Step S140: establishing multiple variable constraint edges based on the reference relationship between the geometric variable data and the constraint relationship data; Step S150: establishing multiple interaction influence edges based on the influence relationship between the current interaction operation data and the two-dimensional object data, the geometric variable data, and the constraint relationship data; Step S160: connecting the object nodes, the variable nodes, the constraint nodes, and the interaction event nodes based on the multiple object variable edges, the multiple variable constraint edges, and the multiple interaction influence edges to obtain the constraint interaction graph.
[0022] Specifically, basic data for the current 2D drawing scene is collected from the data interface of the 2D graphics system, including: 2D object data, geometric variable data, constraint relationship data, and current interactive operation data. The 2D object data is obtained by scanning the current drawing canvas to acquire all valid graphic object data, including but not limited to the types of graphic elements such as lines, circles, rectangles, polygons, and curves. The geometric variable data consists of all geometric parameters of the 2D objects. The constraint relationship data includes various constraint conditions between or within 2D objects, including but not limited to positional constraints such as two points coinciding, lines being parallel / perpendicular, and fixed distances from points to lines; size constraints such as constant line segment length, fixed circle radius, and preset angle values; alignment constraints such as left alignment, right alignment, center alignment, or baseline alignment of multiple objects; and topological constraints such as tangency, intersection, and containment relationships between two graphics. The current interactive operation data includes the specific interactive behaviors performed by the user on the current drawing interface, including interactive objects, interaction types, interaction directions, interaction displacement, interaction trajectories, constraint addition information, constraint deletion information, and constraint parameter modification information.
[0023] Furthermore, the two-dimensional object data is abstracted into object nodes, each corresponding to an independent two-dimensional geometric object. The geometric variable data is abstracted into variable nodes, each corresponding to an independent geometric parameter, such as the endpoint coordinates of a line, the center position and radius of a circle, etc. The constraint relationship data is abstracted into constraint nodes, each corresponding to an independently effective geometric constraint condition. The current interaction operation data is abstracted into an interaction event node, recording the specific content of this user operation. After completing the abstract definition of all nodes, based on the dependency relationship between the two-dimensional object data and the geometric variable data, a two-dimensional object will contain at least one geometric variable. Therefore, starting from the object node, an object variable edge is drawn to the variable node corresponding to each geometric variable it contains, used to mark the dependency relationship between the two. Furthermore, based on the reference relationship between geometric variables and constraint relationships, each constraint condition will reference at least one geometric variable to participate in the constraint calculation. Starting from the referenced variable node, a variable constraint edge is drawn to the constraint node corresponding to the constraint condition, marking the reference relationship between the geometric variable data and the constraint relationship data. User interaction directly affects two-dimensional objects, thereby altering their geometric variables and triggering constraint rule checks. Starting from the interaction event node, the objects, variables, and constraint nodes directly affected by this interaction are identified, and a one-way interaction influence edge is established, with the interaction node pointing to the affected node. Multiple interaction influence edges are established, marking the data range affected by this user operation.
[0024] Finally, based on the multiple object variable edges, the multiple variable constraint edges, and the multiple interaction influence edges, all object nodes, variable nodes, constraint nodes, and interaction event nodes are connected to form a complete interaction graph, resulting in the final constraint interaction graph. This constraint interaction graph can reflect the relationships between various types of data in the current drawing scenario and the influence path of this interaction operation.
[0025] Further, step S100, which involves performing propagation fingerprint similarity matching between the constraint interaction graph and the historical solution cache module of the lightweight two-dimensional constraint solver to determine the current interaction conflict hotspot, also includes: performing a multilateral propagation search on the constraint interaction graph starting from the interaction event node to obtain the current interaction propagation path; generating a current propagation fingerprint based on the current interaction propagation path; evaluating the similarity between the current propagation fingerprint and each historical propagation fingerprint in the historical solution cache module to obtain multiple fingerprint similarities; filtering each historical propagation fingerprint based on the multiple fingerprint similarities to obtain a similar matching fingerprint set; and mapping the conflict characteristics of the constraint interaction graph based on the similar matching fingerprint set and the historical solution cache module to obtain the current interaction conflict hotspot.
[0026] Specifically, after obtaining the constraint interaction graph, starting from the interaction event node, a breadth-first hierarchical traversal is performed along the three types of associated edges. The first level traverses the interaction influence edges, the second level traverses the object variable edges, and the third level traverses the variable constraint edges, spreading outwards level by level until no new associated nodes or edges are added. All nodes, associated edges, and propagation levels triggered during the traversal are recorded to obtain the current interaction propagation path. Then, based on the current interaction propagation path, all triggered nodes in the propagation path, namely interaction event nodes, object nodes, variable nodes, constraint nodes, associated edges, and propagation levels, are extracted. These elements are then feature-compressed and encoded using hash encoding to generate a string corresponding to the current interaction scenario, which is the current propagation fingerprint, used to uniquely identify the scope of influence and associated features of this interaction. The current propagation fingerprint is then compared with all historical propagation fingerprints stored in the historical solution cache module to calculate the Hamming distance. Historical propagation fingerprints with a Hamming distance less than a preset threshold are filtered out to form a similarity matching fingerprint set. Each historical propagation fingerprint stored in the historical solution cache module corresponds to a historical conflict hotspot, conflict type, and solution result record.
[0027] Based on the similarity matching fingerprint set, the constraint interaction graph is mapped to conflict characteristics according to the historical solution cache module. All interaction propagation paths corresponding to the matched historical propagation fingerprints are mapped to the current constraint interaction graph. The frequency of each node in the current constraint interaction graph being mapped as a conflict hotspot is counted. Local connected regions containing nodes with frequencies exceeding a preset frequency threshold are marked as current interaction conflict hotspots, thus completing the similarity matching and conflict hotspot determination of the constraint interaction graph. The preset frequency threshold is an empirical value obtained by the historical solution cache module based on historical conflict data. It can also be adjusted according to actual solution accuracy requirements. A higher frequency threshold results in a smaller range of conflict hotspots and stronger targeting. A lower frequency threshold covers a larger range of potential conflicts, but also results in more redundant calculations during the solution process. This step allows for the direct reuse of historical solution experience to quickly locate potential conflict areas, avoiding conflict verification of all nodes in the entire graph and significantly reducing the computational load of subsequent conflict detection and solution.
[0028] Step S200: Based on the current interaction conflict hot zone, extract the affected constraint subgraph from the constraint interaction graph, and perform reversible pruning on the affected constraint subgraph to obtain a pruned constraint subgraph with a pruning recovery flag. Specifically, based on the current interaction conflict hot zone, the affected constraint subgraph is extracted from the constraint interaction graph. Starting from the marked conflict hot zone node, a layer of associated nodes and edges is extended outward along the original associated edges. All included nodes and edges are integrated into the affected constraint subgraph, ensuring that the affected constraint subgraph covers all potentially conflicting associated data ranges and avoiding omission of potential conflict points. Subsequently, the affected constraint subgraph is reversibly pruned. The pruning rule is to retain only nodes and edges within the conflict hot zone and those directly associated with the hot zone nodes. Isolated branch nodes that are only connected to the external full graph through non-constraint paths are removed from the subgraph. The pruned node identifier, pruned edge identifier, pre-pruning constraint state, pre-pruning variable value, and pruning reason are recorded as pruning recovery identifiers and stored in the additional attributes of the pruned constraint subgraph. After subsequent solution is completed, the pruned nodes can be restored to their original positions based on this identifier. By reversibly pruning, the scale of constraints that need to be solved is further reduced while preserving the complete conflict relationships. At the same time, the pruning operation does not destroy the integrity of the original constraint system. After solving, all data can be fully recovered, and finally a smaller pruned constraint subgraph containing only the core potential conflicts is obtained.
[0029] Step S300: Construct the conflict type hierarchical matrix of the clipped constraint subgraph, and perform conflict resolution decision optimization through the conflict resolution cost model and the conflict type hierarchical matrix to obtain the target conflict resolution strategy; Furthermore, step S300, which involves constructing the conflict type hierarchical matrix of the clipped constraint subgraph, further includes: performing geometric consistency detection on the clipped constraint subgraph to obtain geometric contradiction detection results; performing degree-of-freedom balance detection on the clipped constraint subgraph to obtain constraint balance detection results; performing redundant constraint detection on the clipped constraint subgraph to obtain constraint redundancy detection results; performing interaction intent deviation detection on the clipped constraint subgraph to obtain constraint deviation detection results; and performing matrix processing on the geometric contradiction detection results, the constraint balance detection results, the constraint redundancy detection results, and the constraint deviation detection results to generate the conflict type hierarchical matrix.
[0030] Specifically, geometric consistency is the foundation of two-dimensional constraint solving; all constraints within a subgraph must satisfy geometric logic. If multiple hard constraints are mutually exclusive and cannot be simultaneously satisfied, it will directly lead to solution failure. Geometric consistency checks are performed on the trimmed constraint subgraph. Before performing the geometric consistency check, preset geometric contradiction judgment conditions are established. Examples of such geometric contradiction judgment conditions include: the same line segment simultaneously maintaining two different lengths, requiring two lines to simultaneously have a mutually exclusive relationship, and other geometric contradictions that cannot be satisfied simultaneously. Based on the judgment results, the constraint nodes that generate geometric contradictions, associated variables, and contradiction types are recorded and integrated to generate a structured geometric contradiction detection result.
[0031] Furthermore, the two-dimensional constraint system possesses a fixed equilibrium logic, requiring a match between the total number of effective degrees of freedom and the total number of effective constraints. Too many constraints lead to over-constraint (insufficient degrees of freedom) and system rigidity, while too few constraints result in under-constraint (excessive freedom) and graphical instability. Quantitative calculations are used to accurately determine the constraint equilibrium state. A degree-of-freedom balance test is performed on the trimmed constraint subgraph. Specifically, the number of effective degrees of freedom for variable geometric variables within the trimmed subgraph is counted, along with the number of all activated constraints. The difference between the number of effective degrees of freedom and the number of constraints is calculated. A difference of zero indicates a good constraint, less than zero indicates an over-constraint, and greater than zero indicates an under-constraint. The constraint equilibrium test result is then obtained. Redundancy constraint detection is performed on the trimmed constraint subgraph. By traversing all constraint nodes in the subgraph, duplicate constraints, equivalent constraints, and invalid constraints are identified. Duplicate constraints are identical constraints added multiple times to the same geometric relationship; only one is required to satisfy the constraint requirement, while the rest are redundant. Equivalent constraints are constraints with different expressions but identical actual constraint effects. The invalid constraints are either empty constraints that do not affect any geometric variable degrees of freedom, or invalid constraints whose objects have been deleted. All detected redundant constraints are categorized and stored according to their redundancy type, generating a structured constraint redundancy detection result.
[0032] The clipped constraint subgraph undergoes interaction intent deviation detection. Current interaction operation data is extracted to identify the user's operation object and content. The normal graphic deformation result corresponding to the user's operation is simulated under unconstrained conditions. The graphic output result under the current constraint system is compared with the user's expected result to obtain the deviation of the interaction direction and the drag target, thus obtaining the constraint deviation detection result. Finally, the geometric contradiction detection result, the constraint balance detection result, the constraint redundancy detection result, and the constraint deviation detection result are matrixed. Conflict categories such as geometric contradiction problems, constraint balance problems, constraint redundancy problems, and interaction intent deviation problems are used as rows, and the specific conflict subtypes under the corresponding categories are used as columns. Information such as the conflict location, conflict degree, and associated nodes from each type of detection result is filled into the corresponding matrix cells. Empty cells are marked as conflict-free, ultimately generating a structured conflict type hierarchical matrix. The conflict type hierarchical matrix reflects the distribution of all potential conflicts in the current clipped constraint subgraph, providing a clear basis for subsequent resolution decisions.
[0033] Further, step S300, which involves optimizing the conflict resolution decision using the conflict resolution cost model and the conflict type hierarchical matrix to obtain the target conflict resolution strategy, includes: reconstructing the constraint node priorities of the pruned constraint subgraph based on the interaction intent weights to obtain an intent-driven constraint priority sequence; generating a candidate conflict resolution strategy set based on the conflict type hierarchical matrix and the intent-driven constraint priority sequence; verifying the feasibility of the candidate conflict resolution strategy set to obtain a feasible conflict resolution strategy set; calculating the cost of the feasible conflict resolution strategy set based on the conflict resolution cost model to obtain multiple conflict resolution costs; and iteratively optimizing the feasible conflict resolution strategy set based on the multiple conflict resolution costs to generate the target conflict resolution strategy.
[0034] Specifically, the interaction intent weight is a quantified weight value of the user's real-time editing operation priority. User-initiated interactions such as deformation and parameter modification have the highest weight, while system default constraints and static fixed rules have lower weights, ensuring that the solution prioritizes and adapts to user operation requests. Specifically, by setting priority levels for different constraint nodes, the user's interaction intent weight is determined based on the constraint node triggered by the user's operation, matching the corresponding priority level list. The weight of the highest priority constraint node is n times the weight of the lowest priority constraint node, where n is the number of priority levels. For example, if there are 5 priority levels and the lowest priority constraint node has a weight of x, then the highest priority constraint node has a weight of 5x. The constraint node priority is then reconstructed based on the interaction intent weight, and the nodes are sorted according to their interaction intent weights. If there are constraint nodes with the same weight, they are randomly sorted, thus obtaining the intent-driven constraint priority sequence.
[0035] Furthermore, based on the constraint nodes of the intent-driven constraint priority sequence, corresponding conflict features are matched in the conflict type hierarchical matrix. Then, based on the conflict features, corresponding resolution methods are matched in the historical conflict resolution strategy matching library. Using the conflict resolution of a single constraint node as the basic unit, multiple candidate conflict resolution strategies with different resolution methods are generated according to the intent-driven constraint priority sequence, resulting in a complete set of candidate conflict resolution strategies. Subsequently, each candidate strategy in the candidate conflict resolution strategy set undergoes geometric feasibility verification to determine whether executing the resolution strategy can satisfy the geometric consistency requirements of all retained constraints. Candidate strategies that fail the verification are eliminated, resulting in a set of feasible conflict resolution strategies. A conflict resolution cost model is constructed. This model quantifies the constraint adjustment cost, the overall degree of freedom fluctuation of the constraint system, and the total magnitude of the variable coordinate change after resolution, and then performs a weighted summation to obtain multiple conflict resolution costs corresponding to the set of feasible conflict resolution strategies. The constraint adjustment cost refers to the magnitude of change in constraint nodes when performing closing or adjustment operations to resolve conflicts. No change is recorded as 0, and the corresponding magnitude is determined based on the adjustment ratio. For example, if the parameter adjustment ratio is 0.1, the corresponding magnitude is 0.1. Closing a constraint node results in a magnitude of 1. The overall degree-of-freedom fluctuation of the constraint system is the absolute value of the difference between the total degree-of-freedom of the system after implementing the conflict resolution strategy and the total degree-of-freedom before implementation. The smaller the absolute value of the difference, the smaller the change in the overall structure of the original constraint system, and the higher the stability. The overall degree-of-freedom fluctuation of the constraint system is obtained by normalizing the absolute value of the degree-of-freedom difference. The total magnitude of the variable coordinate change after conflict resolution is the sum of the absolute values of the differences between the actual deformation result of the geometric figure after implementing the conflict resolution strategy and the coordinate position before implementing the conflict resolution strategy. This index is obtained by normalizing the total difference. The smaller the magnitude of the change, the smoother the deformation of the figure. Weight parameters are assigned to the constraint adjustment cost, the overall degree-of-freedom fluctuation of the constraint system, and the total magnitude of the variable coordinate change after resolution. The preferred weights are 0.4 for constraint adjustment cost, 0.3 for the overall degree-of-freedom fluctuation of the constraint system, and 0.3 for the total magnitude of the variable coordinate change after resolution. Finally, all feasible conflict resolution strategies are sorted in ascending order of total conflict resolution cost, and the candidate strategy with the lowest total cost is selected as the target conflict resolution strategy for this conflict resolution process, thus completing the conflict resolution decision optimization. This process prioritizes user interaction intent and filters the optimal solution by quantifying multi-dimensional costs. This ensures that user operational needs are met first while minimizing changes to the original constraint system and maintaining the overall stability of the graph.
[0036] Step S400: Optimize the trimmed constraint subgraph according to the target conflict resolution strategy, establish the optimized constraint subgraph, and call the lightweight two-dimensional constraint solver to perform incremental solution on the optimized constraint subgraph to obtain the local constraint solution results; Further, step S400, which calls the lightweight two-dimensional constraint solver to perform incremental solving on the optimized constraint subgraph and obtain local constraint solution results, includes: extracting the set of variables to be solved, the set of frozen variables, the set of effective constraints, the set of degraded constraints, and the constraint solution sequence queue based on the optimized constraint subgraph; locking the state of two-dimensional objects or variable nodes that are not affected by the current interaction operation based on the set of frozen variables, and using the set of variables to be solved as the object of this incremental solution; constructing a local incremental solution task based on the object of this incremental solution, the set of effective constraints, the set of degraded constraints, and the constraint solution sequence queue; calling the lightweight two-dimensional constraint solver to solve the local incremental solution task in stages and obtaining multiple feasible solution results; and selecting the feasible solution result with the smallest geometric state change and consistent with the current interaction direction from the multiple feasible solution results as the local constraint solution result.
[0037] Specifically, after obtaining the target conflict resolution strategy, adjustments and closure operations are performed on the corresponding constraint nodes in the trimmed constraint subgraph according to the target conflict resolution strategy to modify the corresponding constraint parameters and constraint states, resulting in an optimized constraint subgraph. Subsequently, based on the optimized constraint subgraph, the set of variables to be solved, the set of frozen variables, the set of effective constraints, the set of downgraded constraints, and the constraint solution order queue are extracted. The set of variables to be solved consists of geometric variables within the conflict hot zone that are affected by the conflict resolution adjustment and require recalculation of their position coordinates. The set of frozen variables consists of geometric variables outside the conflict hot zone that are not affected by this conflict adjustment and do not need to be resolved. Their original coordinates and constraint states remain unchanged, and they are locked throughout the solution process and do not participate in the calculation. The set of effective constraints consists of constraints that remain active after the conflict resolution adjustment and need to take effect. The set of downgraded constraints consists of non-core constraints that have been temporarily masked, relaxed, or downgraded in priority after being processed by the target conflict resolution strategy. They are not forcibly effective during the solution process and are only used to adapt to user interaction intentions and resolve topological conflicts.
[0038] Furthermore, based on the frozen variable set, the state of two-dimensional objects or variable nodes unaffected by the current interaction operation is locked to prevent these nodes from participating in incremental solution calculations, thereby reducing unnecessary variable calculations during the solution process and improving solution efficiency. The set of variables to be solved is used as the object of this incremental solution calculation, and coordinate update calculations are performed only on the variables within this set.
[0039] Subsequently, based on the incremental solution object, the set of effective constraints, the set of degraded constraints, and the constraint solution order queue, a local incremental solution task is constructed. This local incremental solution task includes a hard constraint solution subtask, a soft constraint approximation subtask, a degraded constraint tolerance subtask, and an interaction intent preservation subtask.
[0040] The hard constraint solving subtask is bound to all activated hard constraint conditions in the effective constraint set, requiring that the solution result of the incremental solution object must satisfy all hard constraints.
[0041] The soft constraint approximation subtask binds to soft constraints in the effective constraint set, requiring the solution result of the incremental solution object to approximate the target value of the soft constraints while satisfying the hard constraints. The degradation constraint tolerance subtask binds to constraints in the degradation constraint set, allowing the solution result to deviate from the original constraint requirements within a certain tolerance range to resolve conflicts. The interaction intent preservation subtask binds to the user's current interaction operation direction and goal, requiring the solution result to match the user's drag-and-drop and modification operation trend as much as possible, avoiding solution results that violate the user's operational intuition. Finally, based on the constraint solution order queue, the hard constraint solution subtask, soft constraint approximation subtask, degradation constraint tolerance subtask, and interaction intent preservation subtask are sequentially integrated to generate standardized and callable local incremental solution tasks. Subsequently, a lightweight two-dimensional constraint solver is called to solve the local incremental solution tasks in stages: the first stage prioritizes the completion of the hard constraint solution subtask. Based on locked frozen variables, hard constraint satisfaction calculations are performed only on the incremental solution object, excluding initial solutions that do not meet the hard constraint requirements, and obtaining a basic feasible solution set that satisfies the hard constraints. The second stage involves a soft-constraint approximation subtask on the basic feasible solution set. Using the soft-constraint objective value as the optimization direction, it filters for more suitable solutions, narrowing the range of feasible solutions. The third stage executes a degradation constraint tolerance subtask, allowing appropriate deviations from the degradation constraints within the tolerance range to further expand the feasible solution space and filter out all feasible results that satisfy the interaction intent. The fourth stage executes an interaction intent preservation subtask, verifying whether each feasible result matches the user's operation trend, retaining feasible results that conform to the operation direction, and ultimately obtaining multiple feasible solutions that satisfy all core requirements. Finally, from these multiple feasible solutions, the change in each result relative to the original geometric state is calculated, and the feasible solution with the smallest change in geometric state and consistent with the current interaction direction is selected as the final local constraint solution.
[0042] Step S500: Based on the clipped recovery identifier, call the lightweight two-dimensional constraint solver to perform recovery verification and correction on the local constraint solution results.
[0043] Further, step S500, based on the clipped recovery identifier, calls the lightweight two-dimensional constraint solver to perform recovery verification and correction on the local constraint solution result, including: writing the local constraint solution result back to the constraint interaction graph to obtain the written-back constraint interaction graph; performing recovery verification on the clipped recovery identifier based on the written-back constraint interaction graph to obtain the clipping recovery verification result; if the clipping recovery verification result meets a preset recovery threshold, outputting the local constraint solution result; if the clipping recovery verification result does not meet the preset recovery threshold, restoring the clipped recovery identifier to the optimized constraint subgraph to generate a restored extended constraint subgraph; and calling the lightweight two-dimensional constraint solver to perform a second incremental solution on the restored extended constraint subgraph to obtain the corrected local constraint solution result.
[0044] Specifically, the local constraint solution results are written back to the constraint interaction graph, updating the coordinate values and constraint states of the corresponding variables to be solved in the constraint interaction graph, resulting in the rewritten constraint interaction graph. Subsequently, based on the rewritten constraint interaction graph, the pruned node identifiers, pruned edge identifiers, pre-pruning constraint states, pre-pruning variable values, and pruning reasons of the pruned recovery identifiers are traversed. According to the information of the pruned recovery identifiers, each pruned node and edge is temporarily restored to its original topological position in the rewritten constraint interaction graph, restoring its pre-pruning constraint state and variable values. The geometric parameters of the restored nodes and the constraint relationships with adjacent nodes are verified to meet basic geometric logic. The ratio of the number of constraints meeting geometric logic to the total number of constraints associated with the restored nodes is calculated to obtain the local geometric consistency verification result. The difference between the pre-pruning variable values of the restored nodes and the associated variables in the rewritten constraint interaction graph is compared to the ratio of the maximum size of the drawing canvas to obtain the normalized variable difference value. Subtracting the normalized variable difference value from 1 yields the variable value continuity verification result. The local geometric consistency check result and the variable value continuity check result are weighted and summed equally to obtain the trimming and restoration check result. A preset restoration threshold, preferably 0.9, is set to determine the critical condition for whether the local solution result can be directly applied. When the calculated trimming and restoration check result is higher than the preset restoration threshold, it means that after the trimmed constraint node is restored, the geometric consistency of the current local solution result is good and will not cause new conflicts. The local constraint solution result can be directly output.
[0045] If the clipping recovery verification result does not reach the preset recovery threshold (i.e., the clipping recovery verification result is less than 0.9), it indicates that directly outputting the current local result will lead to significant conflicts in the recovered clipped constraints. Therefore, it is necessary to restore the clipped recovery markers to the optimized constraint subgraph, re-add the constraint nodes and edges that were originally clipped and moved out of the calculation range to the solution range, generate a recovered extended constraint subgraph containing the original clipped nodes, and then call the lightweight 2D constraint solver again to perform a second incremental solution on the recovered extended constraint subgraph. This completes the conflict resolution and constraint satisfaction calculation within a larger solution range, ultimately obtaining the corrected local constraint solution result. This ensures the geometric consistency and stability of the overall constraint system after the recovery of the clipped constraints, and avoids residual conflicts affecting subsequent editing operations.
[0046] The technical solution provided in this invention involves constructing a constraint interaction graph and performing propagation fingerprint similarity matching between the constraint interaction graph and the historical solution cache module of a lightweight two-dimensional constraint solver to determine the current interaction conflict hotspot. Based on the current interaction conflict hotspot, affected constraint subgraphs are extracted from the constraint interaction graph, and the affected constraint subgraphs are reversibly pruned to obtain pruned constraint subgraphs with pruned recovery identifiers. A conflict type hierarchical matrix of the pruned constraint subgraphs is constructed, and a conflict resolution decision optimization is performed using a conflict resolution cost model and the conflict type hierarchical matrix to obtain a target conflict resolution strategy. The pruned constraint subgraphs are optimized according to the target conflict resolution strategy to establish an optimized constraint subgraph, and the lightweight two-dimensional constraint solver is invoked to perform incremental solving on the optimized constraint subgraph to obtain local constraint solution results. Based on the pruned recovery identifier, the lightweight two-dimensional constraint solver is invoked to perform recovery verification and correction on the local constraint solution results. This invention addresses the technical problems of existing 2D constraint solvers, such as insufficient incremental solution efficiency in interactive modification scenarios, inaccurate conflict localization, excessive redundant calculations, and difficulty in adapting to large-size sketch designs. It achieves precise location of conflict areas, effectively reducing the computational scale of incremental solutions. Simultaneously, hierarchical conflict handling reduces redundant resolution calculations, improving the response speed of constraint solving in large-size sketch interaction scenarios and meeting the technical requirements of real-time interaction.
[0047] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any way. Although the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the present invention. Any person skilled in the art can make some modifications or alterations to the above-disclosed technical content to create equivalent embodiments without departing from the scope of the present invention. Any modifications, equivalent changes, and alterations made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the scope of the present invention.
Claims
1. A lightweight two-dimensional constraint solver optimization method based on conflict interaction detection, characterized in that, The method includes: Construct a constraint interaction graph and perform propagation fingerprint similarity matching between the constraint interaction graph and the historical solution cache module of the lightweight two-dimensional constraint solver to determine the current interaction conflict hot zone; Based on the current interaction conflict hot zone, the affected constraint subgraph is extracted from the constraint interaction graph, and the affected constraint subgraph is reversibly pruned to obtain a pruned constraint subgraph with a pruning recovery flag. Construct a conflict type hierarchical matrix for the clipped constraint subgraph, and perform conflict resolution decision optimization using the conflict resolution cost model and the conflict type hierarchical matrix to obtain the target conflict resolution strategy; The trimmed constraint subgraph is optimized according to the target conflict resolution strategy, an optimized constraint subgraph is established, and the lightweight two-dimensional constraint solver is called to perform incremental solution on the optimized constraint subgraph to obtain the local constraint solution results. Based on the clipped recovery identifier, the lightweight two-dimensional constraint solver is invoked to perform recovery verification and correction on the local constraint solution results.
2. The lightweight two-dimensional constraint solver optimization method based on conflict interaction detection of claim 1, wherein, Constructing a constraint interaction graph includes: Retrieve 2D object data, geometric variable data, constraint relationship data, and current interaction operation data; The two-dimensional object data is abstracted into object nodes, the geometric variable data is abstracted into variable nodes, the constraint relationship data is abstracted into constraint nodes, and the current interaction operation data is abstracted into interaction event nodes; Based on the hierarchical relationship between the two-dimensional object data and the geometric variable data, multiple object variable edges are established; Based on the reference relationship between the geometric variable data and the constraint relationship data, multiple variable constraint edges are established; Based on the influence relationship between the current interactive operation data and the two-dimensional object data, the geometric variable data, and the constraint relationship data, multiple interactive influence edges are established; Based on the multiple object variable edges, the multiple variable constraint edges, and the multiple interaction influence edges, the object nodes, the variable nodes, the constraint nodes, and the interaction event nodes are connected to obtain the constraint interaction graph.
3. The lightweight two-dimensional constraint solver optimization method based on conflict interaction detection of claim 1, wherein, The constraint interaction graph is compared with the historical solution cache module of the lightweight 2D constraint solver using propagation fingerprint similarity matching to determine the current interaction conflict hotspot, including: Starting from the interaction event node, perform a multi-sided propagation search on the constraint interaction graph to obtain the current interaction propagation path; Generate the current propagation fingerprint based on the current interaction propagation path; The current propagation fingerprint is compared with each historical propagation fingerprint in the historical solution cache module to obtain multiple fingerprint similarities; Each historically propagated fingerprint is filtered based on the multiple fingerprint similarities to obtain a set of similar matching fingerprints; Based on the similarity matching fingerprint set, the constraint interaction graph is mapped to conflict characteristics according to the historical solution cache module to obtain the current interaction conflict hot zone.
4. The lightweight two-dimensional constraint solver optimization method based on conflict interaction detection as described in claim 1, characterized in that, Constructing the conflict type hierarchical matrix of the clipped constraint subgraph includes: Perform geometric consistency detection on the clipped constraint subgraph to obtain geometric inconsistency detection results; Perform a degree-of-freedom balance test on the trimmed constraint subgraph and obtain the constraint balance test results; Redundancy detection is performed on the clipped constraint subgraph to obtain the constraint redundancy detection result; Perform interaction intent deviation detection on the clipped constraint subgraph and obtain the constraint deviation detection result; The geometric contradiction detection results, constraint balance detection results, constraint redundancy detection results, and constraint deviation detection results are matrixed to generate the conflict type hierarchical matrix.
5. The lightweight two-dimensional constraint solver optimization method based on conflict interaction detection of claim 1, wherein, The conflict resolution cost model and the conflict type hierarchical matrix are used to perform conflict resolution decision optimization to obtain the target conflict resolution strategy, including: Based on the interaction intent weight, the constraint node priority of the clipped constraint subgraph is reconstructed to obtain the intent-driven constraint priority sequence. Based on the conflict type hierarchical matrix and the intent-driven constraint priority sequence, a set of candidate conflict resolution strategies is generated. The feasibility of the candidate conflict resolution strategy set is verified to obtain the feasible conflict resolution strategy set; The cost of the feasible conflict resolution strategy set is calculated according to the conflict resolution cost model to obtain multiple conflict resolution costs. The set of feasible conflict resolution strategies is iteratively optimized based on the multiple conflict resolution costs to generate the target conflict resolution strategy.
6. The lightweight two-dimensional constraint solver optimization method based on conflict interaction detection as described in claim 1, characterized in that, The lightweight two-dimensional constraint solver is invoked to perform incremental solving on the optimized constraint subgraph to obtain local constraint solution results, including: Based on the optimization constraint subgraph, extract the set of variables to be solved, the set of frozen variables, the set of effective constraints, the set of degraded constraints, and the constraint solution order queue; Based on the set of frozen variables, the state of two-dimensional objects or variable nodes that are not affected by the current interaction operation is locked, and the set of variables to be solved is used as the object of this incremental solution. Based on the incremental solution object, the effective constraint set, the degraded constraint set, and the constraint solution order queue, a local incremental solution task is constructed. The lightweight two-dimensional constraint solver is invoked to solve the local incremental solution task in stages, and multiple feasible solution results are obtained. From the multiple feasible solutions, the feasible solution with the smallest change in geometric state and consistent with the current interaction direction is selected as the local constraint solution.
7. The lightweight two-dimensional constraint solver optimization method based on conflict interaction detection as described in claim 1, characterized in that, Based on the clipped recovery identifier, the lightweight 2D constraint solver is invoked to perform recovery verification and correction on the local constraint solution results, including: Write back the local constraint solution results to the constraint interaction graph to obtain the constraint interaction graph after writing back. Based on the write-back constraint interaction graph, the clipped recovery identifier is restored and the clipping recovery verification result is obtained. If the clipping and restoration verification result meets the preset restoration threshold, the local constraint solution result is output; If the clipping recovery verification result does not meet the preset recovery threshold, the clipped recovery identifier is restored to the optimized constraint subgraph, and a recovery extended constraint subgraph is generated; The lightweight two-dimensional constraint solver is invoked to perform a second incremental solution on the restored extended constraint subgraph to obtain the corrected local constraint solution results.
8. The lightweight two-dimensional constraint solver optimization method based on conflict interaction detection as described in claim 2, characterized in that, The current interactive operation data includes the interactive object, interactive type, interactive direction, interactive displacement, interactive trajectory, constraint addition information, constraint deletion information, and constraint parameter modification information.
9. The lightweight two-dimensional constraint solver optimization method based on conflict interaction detection as described in claim 1, characterized in that, The pruning recovery identifier includes the pruned node identifier, the pruned edge identifier, the constraint state before pruning, the variable values before pruning, and the pruning reason.
10. The lightweight two-dimensional constraint solver optimization method based on conflict interaction detection as described in claim 6, characterized in that, The local incremental solution task includes a hard constraint solution subtask, a soft constraint approximation subtask, a reduced constraint tolerance subtask, and an interaction intent preservation subtask.