Automatic layout method for connecting lines between models in system simulation

Through the improved A* algorithm and comprehensive cost function, automatic path planning and obstacle avoidance of connections between models in system simulation are realized, which solves the problems of unsmooth path planning and fixed inflection points in the existing technology, and provides automation and efficiency. path planning solution.

CN118734596APending Publication Date: 2024-10-01西安中锐创联科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411028797.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-30
Publication Date
2024-10-01

AI Technical Summary

Technical Problem

During the system simulation modeling process, it is difficult to implement automatic path planning for connections between models with existing technology. Especially during operations such as moving and deleting models, the path planning is not smooth and the number of inflection points is fixed, making it impossible to automatically avoid obstacles.

Method used

Using the improved A* algorithm, by adding the number of turns, Manhattan distance and running direction information to the node, using the priority queue to select the next node, and using the comprehensive cost function f(n) = a*g(n) + b*h1(n) + c*h2(n) optimizes path planning, removes useless points and inflection points, and realizes path planning for automatically avoiding obstacles.

Benefits of technology

It realizes automatic path planning and obstacle avoidance during model operation, automatically changes the number of inflection points, supports dynamic modification of paths, and improves the efficiency of path planning and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure BDA0004969342180000061
    Figure BDA0004969342180000061
  • Figure BDA0004969342180000071
    Figure BDA0004969342180000071
  • Figure BDA0004969342180000072
    Figure BDA0004969342180000072
Patent Text Reader

Abstract

The invention discloses an automatic layout method for connecting lines between models in system simulation, which comprises the following steps of: performing block diagram display on each model in the system simulation, and displaying information including the models, pictures and texts by using a graphic view framework; then node design is carried out between block diagrams, a nearby node list is obtained, the opposite direction of the current moving direction is removed, and the moving direction of the current path planning is stored; the nodes to be explored are stored through the priority queue, and the next node to be explored is selected according to the value of the comprehensive cost function; useless points between horizontal or vertical line segments in the path are removed, and then useless inflection points in the path are removed. According to the invention, the path is automatically planned by specifying the starting point and the ending point and obstacles are avoided; the planned path is as short as possible and has few corners; the planned path is as short as possible; the planned path subsequent modification supports dynamic addition and deletion of the number of corners.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of system simulation, and relates to an automatic layout method for connections between models in system simulation. Background Art

[0002] Multidisciplinary system simulation technology has gradually become an important tool for the current development of complex industrial products. Through virtual verification methods, complex systems can be verified and tested in advance, saving costs and cycles. Specifically, multidisciplinary modeling and simulation technology is implemented in a modeling and simulation software environment. Through the integration of models in different disciplines such as mechanics, control, electronics, hydraulics, pneumatics, and software into a larger multidisciplinary unified model and various simulation verifications, the dynamic and static characteristics of systems and subsystems can be quantitatively obtained.

[0003] The construction method of multidisciplinary system simulation model is an important part of multidisciplinary modeling and simulation technology. At present, there are three most widely used methods for constructing multidisciplinary system simulation models: block diagram bond diagram method and Modelica.

[0004] The block diagram is also commonly referred to as the signal flow method. It is based on block diagrams and directional block diagram connections. It is the most widely used and earliest system modeling method. It is still the mainstream modeling method in the fields of control, state diagrams, and architecture diagrams. The biggest advantage of the block diagram is that the direction of data flow and the relationship between the model interface are clear and unambiguous.

[0005] The bond graph method is a modeling theory and method proposed by scholars at the Massachusetts Institute of Technology in 1959. Its basis is the conservation of energy: that is, energy can neither be created nor destroyed, but can only be converted from one form to another. It is applicable to all fields of science and engineering. The bond graph describes the composition, conversion, logical relationship and physical characteristics of the power flow of each part of the system in a unified way. This method provides great convenience for the analysis of system dynamic characteristics and the establishment of mathematical models.

[0006] Regardless of the modeling method, the connection operation between models and path planning are an indispensable part of the modeling process. Currently, the three mainstream methods of system simulation software are: automatic obstacle avoidance method, fixed path method, and custom path method.

[0007] The automatic obstacle avoidance method treats the model in the canvas as an obstacle. After the user specifies the starting point and the end point, the obstacle avoidance algorithm is used to automatically plan the path from the starting point to the end point. This method is simple and efficient, and the path and the model are not intertwined, and the path is clear. For example, Simulink, a visual simulation tool in MATLAB, adopts this method.

[0008] The fixed path method generates a path based on the positional relationship between the starting point and the end point according to certain rules, without obstacle avoidance, and the generated path has a fixed number of corners. For example, the SimulationX software uses this method.

[0009] The custom path method means that the path from the starting point to the end point is specified by the user, and the path is planned wherever the user clicks. For example, AMESim software and MWorks software both use this method.

[0010] In the process of system simulation modeling, the model is often moved, deleted, added, and so on. When the automatic obstacle avoidance algorithm performs path planning, it will first optimize the obstacle vertices in the global to reduce the number of vertices to make the automatic planning faster and more efficient. This preprocessing must be completed before path planning, so when the model in the canvas is moved, deleted, and so on, this part of the work needs to be done, which makes the model movement process not particularly smooth.

[0011] Because the fixed path method only considers the positions of the starting point and the end point and does not consider the obstacle avoidance problem, the planned path is often intertwined with the model; secondly, the number of turning points in the fixed path planning is fixed, which makes it inconvenient for users to customize and modify the path.

[0012] The custom path method is cumbersome to use because each turning point in the path needs to be manually specified by the user. Secondly, there is also the problem of the model and the path being intertwined because there is no automatic obstacle avoidance function during the movement of the model. Summary of the invention

[0013] The technical problem solved by the present invention is to provide an automatic layout method for connecting lines between models in system simulation, which can automatically plan paths and avoid obstacles, without affecting model operations, and the number of inflection points changes automatically.

[0014] The present invention is achieved through the following technical solutions:

[0015] An automatic layout method for connecting models in system simulation includes the following operations:

[0016] 1) Display the block diagram of each model in the system simulation, and use the graphic view framework to display information including models, pictures, and text;

[0017] 2) Design nodes between the blocks and add information to the nodes, including the current cumulative number of turns, the Manhattan distance from the current point to the end point, and the current running direction, to improve planning efficiency;

[0018] The node path planning only makes right-angle turns, increases the neighbor nodes after the step length up, down, left, and right of the current node, and obtains the number of box diagrams near the point. When the number is greater than 0, it means that it overlaps with other items and is an unavailable point;

[0019] Get the list of nearby nodes, remove the opposite direction of the current moving direction, and store the moving direction of the current path planning; then use the priority queue to store the nodes to be explored, and select the next node to be explored based on the value of the comprehensive cost function f(n);

[0020] f(n) = a*g(n)+b*h1(n)+c*h2(n), where n represents the current node, g(n) represents the number of corners from the starting point to the current node n, h1(n) represents the Manhattan distance from the current node to the end point, h2(n) represents the moving distance from the starting point to the current point, and a, b, and c are coefficients greater than 0;

[0021] 3) Remove useless points between horizontal or vertical line segments in the path, and then remove useless inflection points in the path;

[0022] The removal of useless turning points is to start from the starting point and find the point farthest from the next point that can be replaced. When the replacement point is found, the next point is replaced by the point, and the points behind the path are assigned to the new path; the above process is repeated until there are no points that can be replaced.

[0023] Compared with the prior art, the present invention has the following beneficial technical effects:

[0024] The automatic layout method of the connection lines between models in the system simulation provided by the present invention takes into account automatic obstacle avoidance, while the user's operations such as moving, deleting, and adding models are not affected, and the number of modification turning points of the subsequent path changes automatically.

[0025] The automatic layout method for connecting lines between models in system simulation provided by the present invention, based on the traditional A* algorithm, realizes automatic path planning and obstacle avoidance with specified starting point and end point based on Qt / C++ / C++; the planned path is as short as possible and has as few corners as possible; the planned path is as short as possible; and the subsequent modification of the planned path supports dynamic addition and deletion of the number of corners. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] Figure 1 Get a structural diagram for the nearby node list;

[0027] Figure 2 It is a schematic diagram of useless points between horizontal or vertical line segments;

[0028] Figure 3 is a path containing extra corners;

[0029] Figure 4To process the path after removing extra corners;

[0030] Figure 5-1 A schematic diagram of multi-corner path planning starting from the horizontal position;

[0031] Figure 5-2 A schematic diagram of a multi-corner path planning that starts vertically;

[0032] Figure 6 There are less than 10 canvas items and there are no obstacles between the start and end points;

[0033] Figure 7 There are less than 10 canvas items and there are obstacles between the start and end points;

[0034] Figure 8 For canvas items greater than 10 and less than 50;

[0035] Fig. 9 For canvas items greater than 50. DETAILED DESCRIPTION

[0036] The present invention is further described in detail below in conjunction with the embodiments, which are intended to explain the present invention rather than to limit it.

[0037] The present invention proposes an automatic layout method for connecting models in system simulation, comprising the following operations:

[0038] 1) Display the block diagram of each model in the system simulation, and use the graphic view framework to display information including models, pictures, and text;

[0039] 2) Design nodes between the blocks and add information to the nodes, including the current cumulative number of turns, the Manhattan distance from the current point to the end point, and the current running direction, to improve planning efficiency;

[0040] The node path planning only makes right-angle turns, increases the neighbor nodes after the step length up, down, left, and right of the current node, and obtains the number of box diagrams near the point. When the number is greater than 0, it means that it overlaps with other items and is an unavailable point;

[0041] Get the list of nearby nodes, remove the opposite direction of the current moving direction, and store the moving direction of the current path planning; then use the priority queue to store the nodes to be explored, and select the next node to be explored based on the value of the comprehensive cost function f(n);

[0042] f(n) = a*g(n)+b*h1(n)+c*h2(n), where n represents the current node, g(n) represents the number of corners from the starting point to the current node n, h1(n) represents the Manhattan distance from the current node to the end point, h2(n) represents the moving distance from the starting point to the current point, and a, b, and c are coefficients greater than 0;

[0043] 3) Remove useless points between horizontal or vertical line segments in the path, and then remove useless inflection points in the path;

[0044] The removal of useless turning points is to start from the starting point and find the point farthest from the next point that can be replaced. When the replacement point is found, the next point is replaced by the point, and the points behind the path are assigned to the new path; the above process is repeated until there are no points that can be replaced.

[0045] The following is an implementation example based on the traditional A* algorithm and based on Qt / C++ / C++.

[0046] An automatic layout and path planning method for connecting models in system simulation includes the following operations:

[0047] 1) Use a block diagram to display the model

[0048] The Qt / C++ language is used to implement the block diagram display of the model. The built-in graphics view framework of Qt / C++ is used to display models, pictures, texts and other information. These are collectively referred to as items in the scene. The items mentioned later represent the displayed information.

[0049] The project management and project information acquisition interfaces provided by QGraphicsScene can be used for automatic path planning, such as the items() function for obtaining the list information of items on a custom point or path, and the collidingItems() function for obtaining the list of other graphic items that collide with the current graphic item.

[0050] Use QPainterPath to store the path. After the path planning is completed, when the user drags the line, the number of inflection points in the QPainterPath path is dynamically increased or deleted according to whether it collides with other items. There is no need to modify other places, because Qt / C++'s QPainter itself provides the drawPath() function, which is used to draw paths specifically.

[0051] 2) Node design and planning (using improved A* algorithm)

[0052] The pseudo code of the A* algorithm is as follows:

[0053]

[0054]

[0055] The main points of improving the A* algorithm are as follows:

[0056] a. Changes in node structure

[0057] The nodes of the A* algorithm only save the coordinates of the current point. The cost and path information of the current point are stored in the form of a dictionary. Here, additional information is added to the node to improve the planning efficiency. The structure is changed to the following:

[0058]

[0059] Field l indicates the current distance traveled. This field is mainly used as a factor in determining the priority of the current point when the node enters the priority queue.

[0060] Field g indicates the current accumulated number of turns.

[0061] The field h represents the Manhattan distance from the current point to the end point.

[0062] Field d indicates the current running direction. Because the planned path only makes right-angle turns, there are only four options: up, down, left, and right. The purpose of adding this field is to remove useless nodes every time a neighbor node is obtained.

[0063] b. Optimization of nearby nodes (see Figure 1 )

[0064] Because the model diagram involves frequent movement, addition, and deletion operations, the vertices in the scene are not pre-processed and optimized before path planning to reduce the number of nodes. A fixed step size is used here, and the user can customize this step size.

[0065] Use the items function of QGraphicsScene to get the number of items near the neighboring nodes of the current node after increasing the step size up, down, left, and right. If the number is greater than 0, it means that it overlaps with other items and is an unusable point.

[0066] The field d of the node stores the moving direction of the current path planning. The list of nearby nodes is obtained by excluding the opposite direction of the current moving direction because the opposite direction has been added.

[0067] c. Optimization of heuristic function

[0068] The A* algorithm uses a priority queue to store the nodes to be explored, and selects the next node to be explored based on the value of the comprehensive cost function f(n). This allows the node with the lowest cost to be explored first. The comprehensive cost function f(n) is obtained according to the following formula.

[0069] f(n)=g(n)+h(n)

[0070] Where n represents the current node, f(n) represents the comprehensive cost function, g(n) represents the actual cost from the starting point to node n, and h(n) represents the heuristic function.

[0071] Because the ultimate goal of path planning is to have as few corners as possible, as short a path as possible, and as high an efficiency as possible, we modify the above formula as follows:

[0072] f(n)=a*g(n)+b*h1(n)+c*h2(n)

[0073] Where f(n) is the same as above, g(n) indicates the number of corners from the starting point to the current node n, h1(n) indicates the Manhattan distance from the current node to the end point, h2(n) indicates the moving distance from the starting point to the current point, and a, b, and c are coefficients greater than 0. If the user focuses on as few corners as possible, the coefficient a will be set larger, if the user focuses on the path being as short as possible, the coefficient b will be set larger, and if the user focuses on being as fast as possible, the coefficient c will be set larger. For example, the following settings:

[0074] doublenew_cost=cost_so_far[current]+calcG(current,next);

[0075] doubleH1=calculateH1(next,end); / / indicates the Manhattan distance from the current node to the end point

[0076] doubleH2=calculateH2(current,next); / / indicates the distance from the starting point to the current point

[0077] frontier.put(next,new_cost+H1*0.1+H2*0.01);

[0078] 3) Post-processing of planned paths

[0079] The path obtained by the improved A* algorithm has many unnecessary points in the middle, which require post-processing because the adjacent points are obtained with a fixed step size each time.

[0080] 3.1) Remove useless points between horizontal or vertical segments in the path (such as Figure 2 As shown), the pseudo code is as follows:

[0081]

[0082]

[0083] 3.2) Remove useless turning points in the path (such as Figure 3 shown);

[0084] Since path values ​​only allow straight lines and right angles, there are only two ways to start: horizontal or vertical ( Figure 5-1 , Figure 5-2 As shown), start from the starting point to find the farthest point that can be replaced by the next point. For example, in the figure below, starting from p1, find the farthest point p2 that can be replaced. The replacement condition is that there are no obstacles between the two line segments p1->p2' and p2'->p3, and the same applies to p2". When the replacement point is found, replace p2 with the point and assign the points after the path to the new path. Repeat the above process until there are no points that can be replaced. Figure 3 The path after removing useless turning points in this way is as follows Figure 4 shown.

[0085] The following is an application example of using the method of the present invention to realize model connection.

[0086] like Figure 6 As shown, the method of the present invention is used to realize a line with less than 10 canvas items and no obstacles between the starting point and the end point;

[0087] like Figure 7 As shown, the method of the present invention is used to realize a line with less than 10 canvas items and obstacles between the starting point and the end point;

[0088] like Figure 8 As shown, the method of the present invention is used to realize the connection of canvas items greater than 10 and less than 50;

[0089] like Figure 8 As shown, the method of the present invention is applied to realize the connection of canvas items greater than 50.

[0090] The above embodiments are preferred examples for implementing the present invention, and the present invention is not limited to the above embodiments. Any non-essential additions and substitutions made by those skilled in the art based on the technical features of the technical solution of the present invention shall fall within the protection scope of the present invention.

Claims

1. A method for automatically laying out connections between models in system simulation, characterized in that: The following operations are included: 1) Display the block diagram of each model in the system simulation, and use the graphic view framework to display information including models, pictures, and text; 2) Design nodes between the blocks and add information to the nodes, including the current cumulative number of turns, the Manhattan distance from the current point to the end point, and the current running direction, to improve planning efficiency; The node path planning only makes right-angle turns, increases the neighbor nodes after the step length up, down, left, and right of the current node, and obtains the number of box diagrams near the point. When the number is greater than 0, it means that it overlaps with other items and is an unavailable point; Get the list of nearby nodes, remove the opposite direction of the current moving direction, and store the moving direction of the current path planning; then use the priority queue to store the nodes to be explored, and select the next node to be explored based on the value of the comprehensive cost function f(n); f(n) = a*g(n)+b*h1(n)+c*h2(n), where n represents the current node, g(n) represents the number of corners from the starting point to the current node n, h1(n) represents the Manhattan distance from the current node to the end point, h2(n) represents the moving distance from the starting point to the current point, and a, b, and c are coefficients greater than 0; 3) Remove useless points between horizontal or vertical line segments in the path, and then remove useless inflection points in the path; The removal of useless turning points is to start from the starting point and find the point farthest from the next point that can be replaced. When the replacement point is found, the next point is replaced by the point, and the points behind the path are assigned to the new path; the above process is repeated until there are no points that can be replaced.

2. The automatic layout method for connecting models in system simulation according to claim 1, characterized in that: It is based on Qt / C++ / C++ language to realize the block diagram display of each model in the system simulation, including displaying information such as models, pictures, and texts, which are called items in the scene; Use the project management and project information acquisition interface provided by QGraphicsScene for automatic path planning; Use QPainterPath to store the path. After the path planning is completed, when dragging the line, you can dynamically increase or delete the number of inflection points in the QPainterPath path according to whether it collides with other items.

3. The automatic layout method for connecting models in system simulation according to claim 1 or 2, characterized in that: Use the improved A* algorithm to implement node design and exploration, including node structure improvement, nearby node optimization, and heuristic function optimization; The node structure is improved to the following structure: structNode{ QPointF p; / / coordinates of the point qreal l = 0; / / current distance traveled qreal g = 0; / / Current price qreal h = 0; / / estimated cost int d = -1; / / -1 means undetermined 0 means up 1 means down 2 means left 3 means right Node(){} Node(const QPointF&point,int moved=-1):p(point),d(moved){} }; Field l indicates the current distance traveled, which is used as a factor in determining the priority of the current point; Field g indicates the current accumulated number of turns; Field h represents the Manhattan distance from the current point to the end point; Field d indicates the current running direction, including up, down, left, and right. The optimization of the nearby nodes is: Use the items function of QGraphicsScene to get the number of items near the neighboring nodes of the current node after increasing the step size up, down, left, and right; The optimization of the heuristic function is f(n)=a*g(n)+b*h1(n)+c*h2(n); If the emphasis is on having as few corners as possible, the coefficient a will be increased. If the emphasis is on having the path as short as possible, the coefficient b will be increased. If the emphasis is on being as fast as possible, the coefficient c will be increased.

4. The automatic layout method for connecting models in system simulation according to claim 1, characterized in that: The removal of useless points between horizontal or vertical line segments in the path is achieved by the following operations in sequence: List of points in the old path, list of points in the new path, first point in the old path, loop each point in the old path, the position relationship between the previous point and the current point is vertical, loop to find the farthest point that is also vertical to the previous point, the position relationship between the previous point and the current point is horizontal, loop to find the farthest point that is also horizontal to the previous point, update the previous point, and add the current point to the new path.