Garden path planning method and device based on improved firefly algorithm
By combining the improved Firefly algorithm with the garden path network topology model and the constraint of the necessary points, the mapping and constraint problems of garden path planning in the existing technology are solved, realizing efficient and accurate garden path optimization and improving the scientificity and aesthetics of garden landscape design.
Patent Information
- Application Number
- CN202411966284.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-12-05
- Estimated Expiration
- 2044-12-30
AI Technical Summary
Existing firefly algorithms struggle to effectively map individual locations to spatial layouts in garden path planning, lack quantitative analysis and optimization, and are unable to comprehensively evaluate path quality and meet various constraints, resulting in low planning efficiency and insufficient accuracy.
An improved firefly algorithm employing adaptive step size and local search strategies, combined with a garden path network topology model and mandatory point constraints, guides the population to search for and optimize the garden path layout by penalizing individuals that do not meet the constraints, ensuring that the paths cover important scenic spots.
It improves the efficiency and accuracy of garden path planning, generates optimized path layouts that meet various constraints, and enhances the scientific and aesthetic aspects of garden landscape design.
Smart Images

Figure CN119885374B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of garden path planning and design technology, and more specifically, to a garden path planning method based on an improved firefly algorithm, a computer device, a computer equipment, a computer storage medium, and a computer program product. Background Technology
[0002] In landscape design, the layout of garden path systems has a significant impact on the visitor experience and the rational utilization of garden space. Traditional garden path design relies mainly on the designer's experience and intuition, lacking quantitative analysis and optimization. To improve the scientific nature and efficiency of garden path layout, various methods using computer algorithms for garden path modeling have emerged to optimize and improve garden path planning and design schemes.
[0003] Existing technologies have utilized firefly algorithms to optimize and improve garden path planning. However, practical applications encounter the following technical challenges: First, mapping the positions of individual fireflies to the spatial layout of garden paths is no easy task. Garden paths consist of numerous nodes and segments, with varying distances and connectivity between nodes. The length, width, slope, and paving materials of segments also vary considerably, making it difficult to represent them using a unified mathematical model. Second, evaluating the overall quality of a garden path requires considering factors such as convenience, scenic views, compatibility with the terrain, and paving costs, and these factors may be contradictory. For example, a shortest and most convenient path might have a poor scenic experience or be difficult and costly to construct. Quantifying, weighting, and comprehensively evaluating the brightness value of a path based on these indicators presents a significant challenge. Third, the layout of garden paths must be coordinated with various elements such as the garden's topography, vegetation, water systems, landscape zoning, and visitor flow. Constrained by terrain conditions, landscape layout, and design concepts, finding the optimal path in small, irregular areas becomes difficult. In addition, the differences in the search capabilities of individual fireflies and the trap of local optima also pose challenges to the convergence and global optimization capabilities of the algorithm.
[0004] In their previously published papers, the inventors of this application also studied the use of the firefly algorithm for the design and optimization of garden paths. However, this method only demonstrated the feasibility and possibility of the algorithm in terms of theoretical principles, without mentioning solutions to problems such as garden modeling, constraint optimization, and algorithm complexity in the firefly algorithm, which are specific to the characteristics of garden path layout problems. Existing design methods based on the firefly algorithm still have many technical shortcomings that need to be addressed. Summary of the Invention
[0005] To address at least one deficiency or improvement need in existing technologies, this invention provides a garden path planning method, computer device, computer equipment, computer storage medium, and computer program product based on an improved firefly algorithm. By employing an improved optimization algorithm with adaptive step size and local search strategy, and by penalizing individuals that do not meet the constraints, the population is guided to search towards feasible solutions, thereby improving convergence speed and solution quality, and solving at least one of the above-mentioned deficiencies in current path planning using the firefly algorithm.
[0006] To achieve the above objectives, according to a first aspect of the present invention, a garden path planning method based on an improved firefly algorithm is provided, comprising:
[0007] Obtain landscape design drawings, extract spatial coordinate information of garden path nodes and road segments, and construct a garden path network topology model;
[0008] Design a coding scheme for individual fireflies, which establishes a mapping relationship between the location of individual fireflies and the spatial layout of garden paths by encoding the coordinates of garden path nodes and the topological connection relationships in the network topology model.
[0009] Based on the garden's topography, vegetation, water system, landscape zoning, and garden circulation constraints, an improved firefly algorithm is used to optimize the garden path layout. In the improved firefly algorithm, when updating the position of individual fireflies, individuals that do not meet the mandatory point constraint are penalized, guiding the population to search towards feasible solutions. The mandatory point constraint is combined with the garden path generation, and by adjusting the path connection relationship in the individual encoding, the optimization result is ensured to meet the scenic spot coverage requirements.
[0010] When the algorithm converges or reaches the preset maximum number of iterations, it outputs the garden path layout scheme corresponding to the current optimal firefly individual.
[0011] As a preferred technical solution of the present invention, the construction of the garden path network topology model includes:
[0012] Read the landscape design drawing file, identify and parse all layers in the drawing containing garden path information, obtain the graphic data and attribute information of all garden path objects, and obtain the initial set of garden path graphics.
[0013] Based on the initial set of garden path graphics, the garden path graphics are simplified by removing redundant nodes from the graphic data to obtain a simplified set of garden path graphics.
[0014] Based on the simplified set of garden path graphics, the information of garden path nodes and road segments is extracted to construct a garden path network topology model.
[0015] As a preferred embodiment of the present invention, the firefly individual coding scheme includes:
[0016] Real number encoding is used, and each individual firefly is represented by a set of real number codes, which includes the two-dimensional coordinates of the garden path nodes and the connection relationships between the nodes;
[0017] Initialize the firefly population by randomly generating a certain number of firefly individuals that are evenly distributed within the problem search space. Each individual represents a garden path layout scheme.
[0018] A fitness function for individual fireflies was constructed based on the evaluation indicators of garden path layout.
[0019] As a preferred embodiment of the present invention, the method of optimizing garden path layout using the improved firefly algorithm includes:
[0020] The basic constraints of the garden are obtained, including topography, vegetation and water system, landscape zoning and visitor routes, and a mathematical model for optimizing the garden path layout is established.
[0021] For important scenic spots and visitor nodes in the garden landscape, at least one of them is selected as a must-pass point, which serves as an optimization constraint to optimize the mathematical model.
[0022] An improved firefly algorithm is used to solve the above-mentioned optimized mathematical model, including: adaptively adjusting the step size of the firefly algorithm based on the fitness value of the current optimal solution; when the fitness value of the optimal solution is higher than a preset value, the step size is reduced to perform a fine search; when the fitness value of the optimal solution is lower than the preset value, the step size is increased to expand the search range; a local search strategy is introduced: for the current optimal solution, several new solutions are generated in its vicinity, and the fitness values of these solutions are evaluated; if a new solution is better than the current optimal solution, the current optimal solution is replaced by the new solution to escape local optima.
[0023] As a preferred embodiment of the present invention, the penalty for individuals that do not meet the mandatory path constraint when updating the individual firefly position specifically includes:
[0024] Based on the preset mandatory point constraints, it is determined whether the position of each firefly individual meets the constraints. If the mandatory point constraints are not met, the fitness value of the individual is penalized, reducing the probability of it being selected.
[0025] During the individual location update process, the coding information of the current individual is obtained. Based on the mandatory point constraint requirements, it is determined whether the scenic spot connection relationship in the coding covers all mandatory points. If not, the individual coding is corrected by insertion or replacement operation to obtain a feasible solution that meets the constraint conditions.
[0026] As a preferred embodiment of the present invention, the step of outputting the garden path layout scheme corresponding to the current optimal firefly individual specifically includes:
[0027] Extract the node coordinates, road segment connectivity, and road segment attribute parameters from the optimal individual;
[0028] A two-dimensional plan of the garden path layout is generated based on the node coordinates, and a three-dimensional model is created for each road segment based on the road segment attribute parameters.
[0029] The generated 2D plan view is spatially matched with the 3D model to output a garden path layout scheme, including node coordinates, road segment connection relationships, road segment attribute parameters, and a visualized 2D plan view and 3D model.
[0030] According to another aspect of the present invention, a garden path planning device based on the firefly algorithm is provided, comprising:
[0031] The model building module is configured to acquire garden landscape design drawings, extract spatial coordinate information of garden path nodes and road segments, and construct a garden path network topology model.
[0032] The coding module is configured to design coding schemes for individual fireflies. By coding the coordinates of garden path nodes and the topological connections in the network topology model, a mapping relationship is established between the location of individual fireflies and the spatial layout of the garden path.
[0033] The solution module is configured to optimize the layout of garden paths using an improved firefly algorithm, based on the garden's topography, vegetation, water system, landscape zoning, and garden circulation constraints. Specifically, when updating the individual firefly positions, individuals that do not meet the mandatory path constraint are penalized, guiding the population towards feasible solutions. By combining the mandatory path constraint with garden path generation and adjusting the path connectivity in individual encodings, the optimization results ensure that the optimization results meet the scenic spot coverage requirements.
[0034] The output module is configured to output the garden path layout scheme corresponding to the current optimal firefly individual when the algorithm converges or reaches the preset maximum number of iterations.
[0035] According to another aspect of the present invention, a computer device is provided, comprising at least one processing unit and at least one storage unit, wherein the storage unit stores a computer program that, when executed by the processing unit, causes the processing unit to perform the steps of the above-described method.
[0036] According to another aspect of the present invention, a computer-readable storage medium is provided that stores a computer program executable by an access authentication device, which, when run on the access authentication device, causes the access authentication device to perform the steps of the above-described method.
[0037] According to another aspect of the present invention, a computer program product is provided, comprising a computer program that, when executed by a processor, implements the steps of the above-described method.
[0038] In summary, compared with the prior art, the above-described technical solutions conceived by this invention can achieve the following beneficial effects:
[0039] (1) This invention provides a method for optimizing the layout of garden paths based on an improved firefly algorithm. This method extracts a garden path network topology model from garden design drawings, including node coordinates and road segment attributes. By encoding the garden path nodes and topological relationships, a mapping is established between the individual firefly positions and the garden path layout. A mandatory point constraint is introduced to ensure that the optimization results cover important scenic spots. This mandatory point constraint is combined with the generation of tour routes, and the scenic spot coverage requirements are met by adjusting the path connection relationships. This invention can automatically generate optimized garden path layout schemes under constraints such as terrain, vegetation, and landscape zoning, improving the efficiency and quality of garden landscape design.
[0040] (2) In the improved firefly algorithm provided by the present invention, the adaptive step size and local search strategy can greatly improve the convergence speed and solution quality of the algorithm and greatly optimize the efficiency of path planning.
[0041] (3) In the improved firefly algorithm provided by the present invention, when updating the position of individual fireflies, individuals that do not meet the necessary point constraints are penalized, guiding the population to search for feasible solutions, thereby greatly improving the accuracy of the firefly algorithm and greatly enhancing the accuracy of path planning. Attached Figure Description
[0042] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0043] Figure 1 A flowchart illustrating a method for optimizing garden path layout based on an improved firefly algorithm, provided as an embodiment of this application;
[0044] Figure 2This is a flowchart illustrating the process of constructing a garden path network topology model in a garden landscape path layout optimization method based on an improved firefly algorithm, as provided in one embodiment of this application.
[0045] Figure 3 This application provides a schematic diagram of the process for constructing and designing individual firefly coding schemes in a landscape path layout optimization method based on an improved firefly algorithm, as one embodiment of the present application.
[0046] Figure 4 A schematic diagram illustrating the process of solving the garden path layout optimization problem in a garden landscape path layout optimization method based on an improved firefly algorithm provided in this application embodiment; Detailed Implementation
[0047] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention. Furthermore, the technical features involved in the various embodiments of this invention described below can be combined with each other as long as they do not conflict with each other.
[0048] The terms "first," "second," "third," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or apparatuses.
[0049] like Figure 1 A specific embodiment of the garden landscape path layout optimization method based on the improved firefly algorithm of this application includes the following steps:
[0050] Step S100: Extract the spatial coordinate information of garden path nodes and road segments from the garden landscape design drawings, and construct a garden path network topology model.
[0051] Nodes represent the start, end, and intersection points of garden paths, while road segments represent the paths connecting nodes. Each road segment records attribute parameters such as length, width, and slope.
[0052] Specifically, the software interface for computer-aided design can be used to read landscape design drawings, identify and parse all layers in the drawings that contain information about garden paths, obtain the graphic data and attribute information of all garden path objects, and obtain an initial set of garden path graphics.
[0053] Based on the initial set of garden path graphics, the graphic data is preprocessed. For example, the Douglas-Peucker algorithm is used to simplify the garden path graphics, removing redundant nodes to obtain a simplified set of garden path graphics. Then, based on the geometric relationships of the graphics, an algorithm such as a line segment intersection is used. If the simplified garden path graphics intersect with other garden path graphics, the intersection is broken, and the garden path graphic set is updated. The number of endpoints of all line segments in the updated garden path graphic set that overlap with the endpoints of other line segments is determined. If the overlap is 0, this endpoint is either the start or end point of the garden path; if the overlap is 1, this endpoint is either the start or end point of the garden path, and the line segment connected to it is a valid path segment; if the overlap is greater than or equal to 2, this endpoint is an intersection node.
[0054] Obtain the coordinates of all garden path start points, garden path end points, and intersection nodes to obtain a set of garden path nodes.
[0055] For the set of garden path nodes, extract the road segment information connected to each garden path node. If both endpoints of a road segment belong to the set of garden path nodes, then this road segment is a valid road segment. Obtain the graphic data of all valid road segments to obtain the set of valid road segments.
[0056] Based on the set of valid road segments, the length attribute of each valid road segment is extracted. This is achieved by calculating the Euclidean distance between the start and end coordinates of the valid road segment. For the set of valid road segments, the width attribute of each valid road segment is extracted. This is done by identifying the width values at the start and end points of the original garden path graphic corresponding to the valid road segment, and taking the average of these values as the width attribute parameter. For the set of valid road segments, the slope attribute of each valid road segment is extracted. This is done by analyzing the contour lines in the design drawings to obtain the elevation values at the start and end points of the garden path. If there is an elevation difference between the start and end points of a valid road segment, the slope is calculated based on the elevation difference and the horizontal distance, thus obtaining the slope attribute parameter for the valid road segment.
[0057] Based on the set of garden path nodes and the set of effective road segments, as well as the length, width, and slope attributes of the effective road segments, a garden path network topology model is constructed.
[0058] The model can be represented by a directed graph, where the nodes correspond to garden path nodes and contain the coordinate information of the nodes; the edges correspond to valid road segments and contain information about the starting and ending nodes of the connected segments, as well as attributes or parameters such as the length, width, and slope of the road segments.
[0059] In a specific embodiment, landscape design drawings typically contain multiple layers, with garden path information being a crucial component. By reading the drawing file through a computer-aided design software interface, the graphic data and attribute information of the garden path layer can be identified and extracted. For example, a typical garden path layer might contain multiple paths composed of curves and straight lines, each with corresponding attributes such as width and material. Simplifying the initial garden path graphics is necessary because the original data often contains a large number of redundant nodes.
[0060] In one embodiment, simplification is achieved using the Douglas-Peucker algorithm. The Douglas-Peucker algorithm is an efficient line simplification method that reduces the number of nodes by recursively removing intermediate points whose distance is less than a threshold. For example, a winding garden path originally consisting of 100 points might be simplified to only 20 key points while still retaining its original shape and features.
[0061] The simplified garden path diagram may have intersections, requiring segmentation at these points. This step ensures each path segment is independent, facilitating subsequent network model construction. For example, two intersecting garden paths will be divided into four independent segments at the intersection. By analyzing the endpoint connections, the starting point, ending point, and intersection nodes of the garden path can be identified. These nodes form the skeleton of the garden path network. For instance, a complex garden path system might contain 5 starting and ending points and 10 intersection nodes; the coordinate information of these nodes forms the basis for building the network model. An effective path segment is the segment connecting two garden path nodes. Extracting the geometric and attribute information of these segments is crucial for building the network model. For example, an effective path segment might be 30 meters long, 2 meters wide, and have a 3% slope. These parameters are essential for subsequent path planning and analysis. The width and slope attributes of the path segments require additional processing. The width can be determined by analyzing the width values at the starting and ending points of the original diagram, while the slope needs to be calculated using contour layer information. These attributes provide important references for the practical use of the garden path. For example, a path with a steep slope may not be suitable for the elderly or wheelchair users. The final constructed garden path network topology model is a directed graph, where nodes represent key points of the garden path and edges represent effective path segments. This model can effectively represent the spatial structure and attribute characteristics of the garden path system. For example, the shortest path between two points can be easily calculated in this model, or the connectivity of the entire garden path system can be analyzed. This model provides powerful tool support for the planning, optimization, and management of garden landscapes.
[0062] Step S200: To address the garden path layout problem, a coding scheme for individual fireflies is designed. Each individual firefly represents a possible garden path layout scheme. By encoding the coordinates of garden path nodes and the topological connections in the network topology model, a mapping relationship is established between the position of the individual firefly and the spatial layout of the garden path.
[0063] A coding scheme for individual fireflies was designed to map their locations to the garden path layout, considering the coordinates of the path nodes and their topological connections. Each individual firefly is represented by a set of real-valued codes, containing the two-dimensional coordinates of the path nodes and the connections between them.
[0064] Initialize the firefly population by randomly generating a certain number of firefly individuals evenly distributed within the problem search space. Each individual represents a garden path layout scheme. The number of individuals is set according to the problem size and computing resources.
[0065] Based on the evaluation indicators of garden path layout, a fitness function for individual fireflies is constructed to calculate the fitness value of each individual firefly. The fitness function comprehensively considers factors such as the total length and connectivity of the garden path; the shorter the path and the better the connectivity, the higher the fitness value. Within an optional path, a weighted summation method can be used to calculate the fitness value.
[0066] Based on the fitness value of individual fireflies, the position of the fireflies is updated using the position update formula of the firefly algorithm, causing them to move towards individuals with higher fitness values, thereby achieving layout optimization.
[0067] In a preferred embodiment, a random perturbation term is introduced into the update formula to escape local optima. Specifically, the current optimal fitness value is calculated. If the optimal value does not change significantly after several consecutive iterations, or if the preset maximum number of iterations is reached, the algorithm is considered to have converged, and the current optimal garden path layout scheme is output. Otherwise, the algorithm returns to the previous step to continue iterative optimization.
[0068] Furthermore, by encoding the coordinates of the garden path nodes and the topological connections in the network topology model, a mapping relationship is established between the location of individual fireflies and the spatial layout of the garden path.
[0069] Based on the constructed network topology model, the particle swarm optimization algorithm is used to encode the position of each individual firefly as a particle. The dimension of the particle is equal to the number of nodes in the garden path. Each dimension indicates whether the firefly has passed through the corresponding garden path node. By calculating the Euclidean distance between the particle and the node coordinates in the network topology model, the position of the particle is mapped to the corresponding node in the spatial layout of the garden path, thus obtaining the actual position of the firefly on the garden path.
[0070] Based on the edge information in the network topology model, it is determined whether the sequence of nodes traversed by the firefly satisfies the topological connectivity of the garden path. If not, the particle positions are adjusted to meet the topological constraints. By iteratively updating the particle positions through an optimization algorithm, the firefly can cover as many garden path nodes as possible while satisfying the topological connectivity, thus obtaining the optimal spatial layout scheme of the garden path.
[0071] Furthermore, based on the position information of the optimal particles, the specific path of each firefly in the garden path spatial layout is determined. Each dimension of the particle is mapped to the coordinates of the corresponding node, forming the trajectory of the firefly's movement on the garden path. Optionally, the firefly's movement trajectory is smoothed to eliminate sharp angles and abrupt changes caused by node mapping, resulting in a more natural and continuous garden path spatial layout, thus establishing the mapping relationship between the firefly's position and the garden path layout.
[0072] Specifically, in a preferred embodiment, for example, a park has four attractions, A, B, C, and D, which are connected by roads. A is connected to B and C, B is connected to C and D, and C is connected to D. In the network topology model, A, B, C, and D are four nodes, and the lines connecting them are edges, representing direct connections between the nodes.
[0073] The position of each individual firefly is encoded as a particle, with the particle's dimension equal to the number of nodes on the garden path. Each dimension indicates whether the firefly has passed through a corresponding garden path node. For example, suppose a park has 5 nodes, numbered 1 to 5. The position of a particle can be represented as (1,0,1,0,1), indicating that the firefly has passed through nodes 1, 3, and 5. The purpose of this is to establish a correspondence between the abstract position of the firefly and the garden path nodes.
[0074] Euclidean distance is a common method for calculating the straight-line distance between two points. In garden path layout optimization, by calculating the Euclidean distance between particles and node coordinates in the network topology model, the particle's position can be mapped to the corresponding node in the garden path spatial layout. For example, assuming node A's coordinates are (10, 20) and particle P's position is (11, 21), then the Euclidean distance between particle P and node A is the square root of the sum of the squares of their coordinate differences. The result is a specific numerical value representing the proximity of the particle to the node. By calculating the Euclidean distance between each particle and all nodes, the node closest to each particle can be found, thus mapping the particle to a specific garden path node. The purpose of this is to transform the abstract numerical position of the particle into its actual position in the garden path space.
[0075] After mapping particles to nodes, it's necessary to determine whether the sequence of nodes traversed by the firefly satisfies the topological connectivity of the garden path based on the edge information in the network topology model. For example, if a firefly particle represents traversing nodes 1, 3, and 5, but there's no direct edge connecting nodes 1 and 3, then this node sequence is invalid. In this case, the particle's position needs to be adjusted, for example, replacing node 3 with node 2, which is connected to node 1, to make it conform to the topological constraints. This ensures that the generated garden path layout is feasible and avoids situations where connections are impossible.
[0076] Particle swarm optimization (PSO) iteratively updates particle positions, enabling individual fireflies to cover as many garden path nodes as possible while maintaining topological connectivity. For example, in each iteration, each particle adjusts its speed and position based on its historical best position and its global best position. Suppose a particle's current position is (1,0,1,0,1), its historical best position is (1,1,1,0,0), and its global best position is (1,1,0,1,1). Then, the particle will update its position according to certain rules, considering both optimal positions, for example, to (1,1,1,0,1), thus potentially covering more nodes.
[0077] Through continuous iteration, an optimal particle position can be found, allowing individual fireflies to cover as many garden path nodes as possible, forming a well-designed garden path layout. Based on the optimal particle position information, the specific path of the individual fireflies within the garden path spatial layout can be determined. For example, if the optimal particle position is (1,1,0,1,1), it means the firefly passes through nodes 1, 2, 4, and 5. Mapping each dimension of the particle to the coordinates of the corresponding node yields the trajectory of the firefly's movement along the garden path. For instance, if the coordinates of node 1 are (10,20), node 2 are (20,30), node 4 are (40,50), and node 5 are (50,60), then the firefly's movement trajectory is from (10,20) to (20,30) to (40,50) and then to (50,60). This process restores the abstract particle positions to concrete garden paths.
[0078] Since node mapping can lead to sharp angles or abrupt changes in the path, it is preferable to smooth the movement trajectory of the fireflies. For example, methods such as curve fitting can be used to transform the original polygonal path into a smooth curve, making the garden path layout more natural and aesthetically pleasing. For instance, an original polygonal path from (10,20) to (20,30) and then to (40,50) can be transformed into a smooth arc after smoothing, eliminating sharp angles and making the garden path appear more fluid. This improves both the aesthetics and practicality of the garden path layout.
[0079] Step S300: Based on the garden constraints, use the improved firefly algorithm to optimize the garden path layout.
[0080] Among them, the basic constraints of a garden include at least one of the following: topography, vegetation and water system, landscape zoning, and visitor routes.
[0081] Step 301: Obtain the topography, vegetation, water system, landscape zoning, and visitor routes of the garden as basic constraint information. Based on the above information, establish a mathematical model for optimizing the garden path layout, and transform the garden path layout problem into an optimization problem.
[0082] Constraints such as topography, vegetation, water systems, landscape zoning, and visitor routes form the basis for optimizing garden path layout. For example, in a mountain garden, the terrain is undulating, requiring consideration of slope and elevation changes; the water system includes streams and lakes, necessitating the rational placement of bridges along the garden paths; landscape zoning includes gardens, bamboo groves, and viewing platforms, requiring paths to connect various attractions; and visitor routes need to consider walking paths and dwell time. By incorporating these factors into a mathematical model, the garden path layout problem can be transformed into a multi-objective optimization problem.
[0083] Step 302 involves selecting at least one of the important scenic spots and visitor nodes in the garden landscape as a mandatory point, and incorporating it as an optimization constraint into the firefly algorithm to further optimize the aforementioned mathematical model. In the encoding of individual fireflies, mandatory points are treated as fixed points to ensure that the generated garden path layout must pass through these points to meet visitor needs.
[0084] Step 303 uses the improved firefly algorithm to solve the garden path layout optimization problem.
[0085] In the firefly algorithm, each firefly represents a possible garden path layout. Through information exchange and natural selection among individual fireflies, the garden path layout is continuously updated and optimized. Each firefly's location code includes the coordinates of garden path nodes and their connectivity. Fireflies communicate with each other through brightness; brighter fireflies attract brighter ones. For example, a garden path layout with a high fitness value indicates that the layout performs well in terms of total length and connectivity; its corresponding fireflies are brighter and will attract other fireflies to move closer, thus optimizing the layout.
[0086] The improved Firefly algorithm includes adaptive adjustment of the iteration step size and the selection of a local search strategy. This improvement, utilizing adaptive step size adjustment and a local search strategy, enhances the algorithm's convergence speed and solution quality. Furthermore, in the optimization process, essential pathways are specifically introduced as supplementary constraints for important scenic spots and visitor nodes in the garden landscape, further optimizing the algorithm's accuracy and efficiency.
[0087] Specifically, during the iterative process of the firefly algorithm, the step size of the firefly is adaptively adjusted based on the fitness value of the current optimal solution. When the fitness value of the optimal solution is high, the step size is decreased to perform a finer search; when the fitness value of the optimal solution is low, the step size is increased to expand the search range and improve the convergence speed of the algorithm. Secondly, based on the fitness value of the current optimal solution, the step size of the firefly is adaptively adjusted. When the fitness value of the optimal solution is higher than a preset value, the step size is decreased to perform a finer search; when the fitness value of the optimal solution is lower than a preset value, the step size is increased to expand the search range.
[0088] Δs=s0·e -λt
[0089] In the formula, Δs represents the adaptive step size of the firefly algorithm, s_0 represents the initial step size, λ represents the decay coefficient, and t represents the current iteration number. This formula describes the adaptive adjustment strategy of the step size in the firefly algorithm.
[0090] An adaptive step size adjustment strategy can improve the convergence efficiency of an algorithm. When the fitness value of the optimal solution is high, it indicates that the current solution is close to the optimal solution, and the step size should be reduced for fine-tuning. For example, when the total length of a garden path layout scheme is already short and the connectivity is good, the step size can be reduced to half of its original value to allow for fine-tuning within a local range. Conversely, when the fitness value of the optimal solution is low, the step size should be increased to expand the search range and avoid getting trapped in local optima.
[0091] Furthermore, preferably, to avoid the algorithm getting trapped in local optima, a local search strategy is introduced during the iterative process of the firefly algorithm. For the current optimal solution, several new solutions are generated in its vicinity, and the fitness values of these solutions are evaluated. If a new solution is better than the current optimal solution, the current optimal solution is replaced by the new solution to escape local optima.
[0092] For the current optimal garden path layout, several new layouts can be generated nearby. For example, by slightly randomly perturbing the coordinates of the garden path nodes or changing the connections between some nodes, five new layouts can be generated. The fitness values of these new layouts are evaluated, and if a better layout exists, it replaces the current optimal layout. The constraint of mandatory access points ensures that the garden path layout meets visitor needs. For example, in a garden, three important scenic spots need to be included in the garden path system. The coordinates of these three scenic spots are used as fixed points and remain unchanged in the individual firefly encoding, ensuring that the generated garden path layout must pass through these points. This guarantees that visitors can easily reach these important scenic spots.
[0093]
[0094] In the above formula, P(x new f(x) represents the probability of accepting the new solution. new ) and f(x current ) represent the fitness values of the new solution and the current solution, respectively, and T represents the temperature parameter. This formula is used to calculate whether to accept the newly generated solution in order to escape local optima.
[0095] In a preferred embodiment, the optimization and improvement of the firefly algorithm further includes: penalizing individuals that do not meet the mandatory pathpoint constraint when updating the individual firefly positions, guiding the population to search towards feasible solutions. By combining the mandatory pathpoint constraint with the tour route generation, and adjusting the path connectivity in the individual encoding, the optimization result ensures that it meets the scenic spot coverage requirements.
[0096] The penalty function is designed as follows: F penalty =C×(1-N) covered / N required ), where C is the penalty coefficient, N covered N represents the number of necessary points currently covered by the individual. required This represents the preset total number of necessary hops. The penalty coefficient C is adjusted according to the degree of constraint in the problem; the stronger the constraint, the greater the penalty.
[0097] Specifically, based on preset mandatory pathpoint constraints, the system determines whether the location of each firefly meets the constraints. The individual's location information is represented by a sequence code, where each element corresponds to a scenic spot, and the order of the elements indicates the visiting order of the scenic spots. By analyzing the connection relationships between scenic spots in the individual's code, it is determined whether all mandatory pathpoints are covered. If the mandatory pathpoint constraints are not met, the fitness value of that individual is penalized, reducing its probability of being selected and guiding the population towards a feasible solution.
[0098] During the individual location update process, the current individual's coding information is obtained. Based on the mandatory point constraint, it is determined whether the connection relationships of scenic spots in the coding cover all mandatory points. If not, one of the following two correction strategies is adopted: insertion operation, inserting the missing mandatory points at appropriate positions in the individual coding while deleting some non-mandatory points to ensure that the coding length remains unchanged; or replacement operation, replacing some non-mandatory points in the individual coding with the missing mandatory points, until the coverage requirement is met. The corrected individual coding is the feasible solution that satisfies the constraints.
[0099] During the firefly bioluminescence attraction phase, the coverage of the individual to the necessary points is calculated based on the order of the attractions in the individual's current code.
[0100] In a preferred embodiment, to further improve the search efficiency of the algorithm, a tabu search strategy can be used to optimize the individual position update process. Scenic spot connections that do not satisfy the mandatory point constraint are added to a tabu list, avoiding repeated visits to these invalid solutions in subsequent searches. The tabu list records a certain number of invalid connections and is updated according to the first-in, first-out principle. Simultaneously, combined with problem domain knowledge, a recommended tour order between mandatory points is pre-constructed and used as prior information for optimization, guiding the generation of scenic spot connections in individual encodings, thereby reducing the search space and improving the quality of solutions and the convergence speed of the algorithm.
[0101] Step S400: When the algorithm converges or reaches the preset maximum number of iterations, output the garden path layout scheme corresponding to the current optimal firefly individual. This scheme includes the optimized garden path node coordinates, road segment connection relationships, and attribute parameters of each road segment.
[0102] Based on the maximum number of iterations of the firefly algorithm, determine whether the current algorithm has converged or reached the maximum number of iterations. If so, obtain the garden path layout scheme corresponding to the current optimal firefly individual, and extract the node coordinates, road segment connection relationships, and road segment attribute parameters; otherwise, continue iterative optimization until the convergence condition is met or the maximum number of iterations is reached.
[0103] Using the extracted node coordinate data, a two-dimensional plan view of the garden path layout is generated using drawing software such as AutoCAD, based on the node coordinate positions. By analyzing the path segment connectivity, graph theory algorithms, such as depth-first search or breadth-first search, are used to determine whether the generated garden path plan view is a connected graph, that is, whether the topology of the garden path meets the preset connectivity requirements. If it does not meet the requirements, the process returns to the previous step, the node coordinates and connectivity are adjusted, and the plan view is regenerated until the connectivity requirements are met.
[0104] Based on the extracted road segment attribute parameters, 3D modeling software such as 3ds Max is used to create 3D models of each road segment on top of the generated 2D plan view. According to the road segment width parameter, a 3D road surface of the corresponding width is extruded from the corresponding position on the plan view; according to the road segment height parameter, the relative height of the road surface is determined; and according to the road surface material parameter, corresponding material textures are applied to the 3D model. The generated 2D plan view of the garden path is imported into the 3D modeling software, and its spatial position is matched and aligned with the existing 3D model to ensure correct correspondence in the spatial coordinate system. Then, the texture, material, and other attribute data of the 3D model are copied to the corresponding 2D plan view, giving the plan view corresponding material representation. Finally, the merged 2D plan view and 3D model data are output together to obtain a complete garden path layout scheme, including node coordinates, road segment connection relationships, road segment attribute parameters, and visualized 2D plan view and 3D model, for subsequent landscape design and construction reference.
[0105] Another embodiment of this application provides a garden path planning device based on the firefly algorithm, comprising:
[0106] The model building module is configured to acquire garden landscape design drawings, extract spatial coordinate information of garden path nodes and road segments, and construct a garden path network topology model.
[0107] The coding module is configured to design coding schemes for individual fireflies. By coding the coordinates of garden path nodes and the topological connections in the network topology model, a mapping relationship is established between the location of individual fireflies and the spatial layout of the garden path.
[0108] The solution module is configured to optimize the layout of garden paths using an improved firefly algorithm, based on the garden's topography, vegetation, water system, landscape zoning, and garden circulation constraints. Specifically, when updating the individual firefly positions, individuals that do not meet the mandatory path constraint are penalized, guiding the population towards feasible solutions. By combining the mandatory path constraint with garden path generation and adjusting the path connectivity in individual encodings, the optimization results ensure that the optimization results meet the scenic spot coverage requirements.
[0109] The output module is configured to output the garden path layout scheme corresponding to the current optimal firefly individual when the algorithm converges or reaches the preset maximum number of iterations.
[0110] Another embodiment of this application provides a computer device including at least one processing unit and at least one storage unit, wherein the storage unit stores a computer program that, when executed by the processing unit, causes the processing unit to perform the steps of the method according to any one of claims 1 to 6.
[0111] In another embodiment of this application, a computer-readable storage medium is provided, characterized in that it stores a computer program executable by an access authentication device. When the computer program is run on the access authentication device, it causes the access authentication device to perform the steps of the above-described method. The computer-readable storage medium may include, but is not limited to, any type of disk, including floppy disks, optical disks, DVDs, CD-ROMs, microdrives, as well as magneto-optical disks, ROMs, RAMs, EPROMs, EEPROMs, DRAMs, VRAMs, flash memory devices, magnetic cards or optical cards, nanosystems (including molecular memory ICs), or any type of medium or device suitable for storing instructions and / or data.
[0112] Another embodiment of this application provides a computer program product, including a computer program, characterized in that the computer program, when executed by a processor, implements the steps of the above-described method.
[0113] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0114] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0115] In the several embodiments provided in this application, it should be understood that the disclosed apparatus can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some service interface; the indirect coupling or communication connection between devices or units may be electrical or other forms.
[0116] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0117] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0118] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage device (CMD). Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned memory includes various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0119] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, which may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, etc.
[0120] The foregoing description is merely an exemplary embodiment of this disclosure and should not be construed as limiting the scope of this disclosure. Any equivalent changes and modifications made in accordance with the teachings of this disclosure shall still fall within the scope of this disclosure. Those skilled in the art will readily conceive of embodiments of this disclosure upon considering the specification and practicing the disclosure herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not described herein. The specification and embodiments are to be considered exemplary only, and the scope and spirit of this disclosure are defined by the claims.
[0121] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0122] Those skilled in the art will readily understand that the above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A garden path planning method based on an improved firefly algorithm, characterized in that, The method comprises the following steps: Obtain the garden landscape design drawings, extract the spatial coordinate information of the garden path nodes and road segments, and construct a garden path network topology model; Design a firefly individual coding scheme, encode the garden path node coordinates and the topological connection relationship in the network topology model, and establish a mapping relationship between the position of the firefly individual and the spatial layout of the garden path; According to the topography, vegetation and water system, landscape partition and garden dynamic line constraint conditions of the garden, an improved firefly algorithm is used to optimize and solve the garden path layout; in the improved firefly algorithm, when the position of the firefly individual is updated, the individual that does not satisfy the compulsory point constraint is punished to guide the population to search in the direction of the feasible solution, the compulsory point constraint is combined with the garden path generation, the path connection relationship in the individual coding is adjusted to ensure that the optimization result satisfies the scenic spot coverage requirement; When the algorithm converges or reaches the preset maximum iteration number, output the garden path layout scheme corresponding to the current optimal firefly individual; The design of the firefly individual coding scheme comprises: using real number coding, each firefly individual is represented by a group of real number codes, which contains the two-dimensional coordinates of the garden path nodes and the connection relationship between the nodes; initializing the firefly population, a certain number of firefly individuals are randomly generated by uniformly distributing in the problem search space, each individual represents a garden path layout scheme; constructing the fitness function of the firefly individual according to the evaluation index of the garden path layout; The improved firefly algorithm is used to optimize and solve the garden path layout, which comprises the following steps: obtaining the topography, vegetation and water system, landscape partition and tour dynamic line as basic constraint condition information of the garden, establishing a mathematical model of the garden path layout optimization; selecting at least one of the important scenic spots and tour nodes in the garden landscape as a compulsory point as an optimization constraint condition to optimize the mathematical model; using the improved firefly algorithm to solve the above optimized mathematical model, which comprises: according to the fitness value of the current optimal solution, the step length of the firefly is adjusted adaptively, when the fitness value of the optimal solution is higher than the preset value, the step length is reduced for fine search, when the fitness value of the optimal solution is lower than the preset value, the step length is increased to expand the search range; introducing a local search strategy, generating a plurality of new solutions near the current optimal solution, evaluating the fitness values of the plurality of new solutions, if the new solution is better than the current optimal solution, replacing the current optimal solution with the new solution, and jumping out of the local optimum.
2. The garden path planning method of claim 1, wherein, The construction of the garden path network topology model comprises: Reading the garden landscape design drawing file, identifying and analyzing all layers containing garden path information in the drawing, obtaining the graphic data and attribute information of all garden path objects, and obtaining an initial garden path graphic set; According to the initial garden path graphic set, the garden path graphics are simplified, and the redundant nodes in the graphic data are removed to obtain a simplified garden path graphic set; According to the simplified garden path graphic set, the garden path node and road segment information is extracted, and a garden path network topology model is constructed.
3. The garden path planning method of claim 1, wherein, When the position of the firefly individual is updated, the individual that does not satisfy the compulsory point constraint is punished, which comprises: According to the preset constraint condition, it is judged whether the position of each glowworm individual meets the constraint requirement. If the constraint condition is not met, the fitness value of the individual is punished, and the probability of being selected is reduced. In the individual position updating process, the encoding information of the current individual is obtained. According to the constraint requirement of the must-pass point, it is judged whether the connection relationship of the scenic spots in the encoding covers all the must-pass points. If not, the individual encoding is modified by using the insertion operation or the replacement operation to obtain a feasible solution that meets the constraint condition.
4. The garden path planning method of claim 1, wherein, The output current optimal glowworm individual corresponding garden path layout scheme, specifically includes: Extract the node coordinates, road segment connection relationship and road segment attribute parameters in the optimal individual; According to the node coordinates, a two-dimensional plan of the garden path layout is generated, and each road segment is modeled in three dimensions according to the road segment attribute parameters; The generated two-dimensional plan and three-dimensional model are spatially matched, and the garden path layout scheme is output, including node coordinates, road segment connection relationship, road segment attribute parameters, and visual two-dimensional plan and three-dimensional model.
5. A garden path planning device based on firefly algorithm, characterized in that, It includes: The model construction module is configured to obtain the garden landscape design drawing, extract the spatial coordinate information of the garden path nodes and road segments, and construct a garden path network topology model; The coding module is configured to design a glowworm individual coding scheme, encode the garden path node coordinates and the topological connection relationship in the network topology model, and establish a mapping relationship between the position of the glowworm individual and the garden path space layout; The solving module is configured to use the improved glowworm algorithm to solve the garden path layout optimization according to the topography, vegetation and water system, landscape partition and garden dynamic line constraint conditions of the garden; wherein, when the position of the glowworm individual is updated, the individuals that do not meet the constraint condition are punished to guide the population to search in the direction of feasible solution, the constraint condition of must-pass point is combined with the generation of garden path, and the connection relationship of the path in the individual coding is adjusted to ensure that the optimization result meets the scenic spot coverage requirement; The output module is configured to output the garden path layout scheme corresponding to the current optimal glowworm individual when the algorithm converges or reaches the preset maximum iteration number; The design of the glowworm individual coding scheme includes: using real number coding, each glowworm individual is represented by a set of real number coding, which contains the two-dimensional coordinates of the garden path nodes and the connection relationship between the nodes; initialize the glowworm population, generate a certain number of glowworm individuals randomly distributed in the problem search space, each individual represents a garden path layout scheme; construct the fitness function of the glowworm individual according to the evaluation index of the garden path layout; The garden path layout optimization solution using the improved firefly algorithm comprises: obtaining the basic constraint condition information of the garden including the topography, vegetation water system, landscape partition and tour dynamic line, and establishing a mathematical model of the garden path layout optimization; for important scenic spots and tour nodes in the garden landscape, at least one of which is selected to be set as a must-pass point as an optimization constraint condition to optimize the mathematical model; the improved firefly algorithm is used to solve the optimized mathematical model, which comprises: according to the fitness value of the current optimal solution, the step length of the firefly is adaptively adjusted, when the fitness value of the optimal solution is higher than a preset value, the step length is reduced for fine search, and when the fitness value of the optimal solution is lower than the preset value, the step length is increased to expand the search range; a local search strategy is introduced, for the current optimal solution, a plurality of new solutions are generated in the vicinity thereof, and the fitness values of the plurality of new solutions are evaluated, if the new solution is better than the current optimal solution, the new solution replaces the current optimal solution, and the local optimum is jumped out.
6. A computer device, comprising: The computer program is stored in the storage unit and is executable by the processing unit, and when the computer program is executed by the processing unit, the processing unit executes the steps of the method of any one of claims 1-4.
7. A computer-readable storage medium, characterized in that, The computer program is stored in the storage unit and is executable by the processing unit, and when the computer program is executed by the processing unit, the processing unit executes the steps of the method of any one of claims 1-4.
8. A computer program product comprising a computer program, characterized in that, The computer program is stored in the storage unit and is executable by the processing unit, and when the computer program is executed by the processing unit, the processing unit executes the steps of the method of any one of claims 1-4.
Citation Information
Patent Citations
Robot path planning method based on improved multi-target firefly algorithm
CN109297498A
Path planning method, device and equipment and storage medium
CN112731961A