Equipment space layout optimization method and system based on genetic algorithm
Through the optimization method of equipment space layout based on genetic algorithms, the problem of inefficient layout design of complex equipment cabinets in traditional manual methods is solved, automated layout and efficient equipment installation guidance are realized, and the quality of layout design is improved.
Patent Information
- Application Number
- CN202411086601.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-08
- Publication Date
- 2024-11-01
AI Technical Summary
Traditional manual methods are inefficient in the space layout design of complex electromechanical equipment cabinets, prone to errors, and it is difficult to ensure the rationality and feasibility of the layout.
Using the device spatial layout optimization method based on genetic algorithm, by obtaining the actual proportions of electromechanical devices, abstracting the device shape, establishing a layout optimization model, using genetic algorithms to search globally, generating the layout optimal solution, and performing collision detection during the animation generation process , adjust the installation direction of the equipment.
The automatic layout of electromechanical equipment has been realized, the layout efficiency and rationality of the results have been improved, manual intervention has been reduced, the quality of equipment system layout design has been improved, and convenient installation guidance has been provided to installers.
Smart Images

Figure CN118886327A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of space layout optimization, and in particular to a method and system for optimizing equipment space layout based on a genetic algorithm. Background Art
[0002] Mechanical and electrical equipment occupies a certain space in a building, so it needs to be arranged reasonably to ensure that the equipment does not affect the normal use of the building. For example, power equipment needs to be located in the power room or equipment room of the building, ventilation equipment needs to be located in the air-conditioning room of the building, and lighting equipment needs to be located on the ceiling of the building. During the layout process, the ease of use and maintenance of the equipment must also be considered to facilitate the staff to inspect and maintain the equipment. In the field of modern engineering, the design and layout of complex electromechanical systems face many challenges, among which the spatial layout design of electromechanical equipment is particularly important. The traditional manual layout method is not only inefficient, but also prone to errors, especially when the equipment layout involves complex factors, such as the relationship between equipment, installation process and other factors. Therefore, it is necessary to improve a method suitable for optimizing the spatial layout of complex equipment cabinets to solve the problem of low efficiency in the spatial layout of complex equipment cabinets. Summary of the invention
[0003] In view of this, an embodiment of the present invention provides a method and system suitable for optimizing the spatial layout of a complex equipment cabinet, so as to solve the problem of low efficiency in the current spatial layout of a complex equipment cabinet.
[0004] The technical solution adopted by the present invention is: In a first aspect, the present invention provides a method for optimizing equipment space layout based on a genetic algorithm, comprising: Acquiring an actual proportion of the electromechanical device, and abstracting the shape of the electromechanical device according to the actual proportion to obtain an abstract structure of the device; Modeling is performed in the layout space according to preset constraints and the device abstract structure to obtain a layout optimization model; Based on the layout optimization model, a genetic algorithm is used to perform a global search in the layout space to obtain an optimal layout solution; An animation is generated in the layout space according to the optimal layout solution, and collision detection of the equipment installation process is performed during the animation generation process. The moving direction of the equipment in the animation is adjusted according to the collision detection result to obtain the final equipment installation demonstration animation.
[0005] Furthermore, the actual proportion of the electromechanical device is obtained, and the shape of the electromechanical device is abstracted according to the actual proportion to obtain the device abstract structure, including: The length, width and height dimensions of various electromechanical equipment are collected, and the shape of each electromechanical equipment is uniformly regarded as a rectangular structure. Each electromechanical equipment is abstracted into a corresponding equipment abstract structure according to the actual length, width and height ratio.
[0006] Furthermore, the modeling is performed in the layout space according to the preset constraint conditions and the device abstract structure to obtain a layout optimization model, including: According to preset constraints and size parameters of various device abstract structures, a first objective function and a second objective function of device layout are respectively constructed; Based on the first objective function and the second objective function, equipment modeling is performed in the layout space to obtain a layout optimization model for the arrangement of the electromechanical equipment in the Y-axis direction.
[0007] Furthermore, according to the preset constraints and the size parameters of the various device abstract structures, the first objective function and the second objective function of the device layout are respectively constructed, including: Preset constraints are set according to the layout requirements during the device layout process. The preset constraints include a first constraint and a second constraint. The first constraint is that during the device layout process, devices cannot overlap. The first constraint is specifically expressed as: ; in, x i 、y i 、z i are the spatial coordinates of each electromechanical device in the current layout, X i 、Y i 、Z i are the dimensions of each electromechanical device in the XYZ direction respectively; The second constraint condition is that the layout of the electromechanical equipment in the Y direction should not exceed the height H of the equipment cabinet. The second constraint condition is specifically expressed as: ; According to the preset constraints and in combination with the size parameters of the abstract structure of the electromechanical equipment, a first objective function for optimizing the volume occupied by the electromechanical equipment in the equipment cabinet and a second objective function for optimizing the placement of the electromechanical equipment in the equipment cabinet are constructed; The first objective function M1 is expressed as: ; Among them, T max Indicates the highest horizontal position of the device in the current layout; T minIndicates the lowest horizontal position of the equipment in the current layout; L indicates the length of the equipment cabinet; W indicates the width of the equipment cabinet; The second objective function M2 is expressed as: ; in, V i Indicates the size of each device ; X i 、Y i 、Z i They are the dimensions of each device in the XYZ directions; y i Indicates the Y-axis coordinate of the device in the current layout.
[0008] Furthermore, based on the layout optimization model, a genetic algorithm is used to perform a global search in the layout space to obtain an optimal layout solution, including: Obtaining the layout scheme output by the layout optimization model in the layout space, and taking the coordinate values of each electromechanical device on the Y axis in a layout scheme as individuals, randomly initializing and generating an initial population with multiple different initial individuals; The fitness function is used to calculate the population fitness of each initial individual in the initial population, and high-quality individuals are selected from the initial individuals according to the preset fitness value during the calculation process; Perform crossover and mutation operations on high-quality individuals to generate a new population, and iterate the population fitness calculation on the new population until the number of iterations reaches the set value, and then output the optimal individual; The coordinate values of each electromechanical device in the optimal individual on the Y-axis are used as the optimal layout solution of the electromechanical device in the layout space.
[0009] Furthermore, the random initialization generates an initial population having a plurality of different initial individuals, including: Presetting a layout template that meets the space constraints of the equipment cabinet, wherein the layout template includes a high-quality template, a common template, and a low-quality template; Generate a random two-digit decimal number P between [0, 1] a , if P a If P is between [0, 0.2], the individual template is selected as a high-quality template. a If P is between [0.2, 0.8], the individual template uses the common template. a If the value is between [0.8, 1], the individual template uses a low-quality template; After determining the layout template selected by the current individual, generate a random number P in [0, 1] b , if P b< 0.5, then subtract a first random number from the individual's gene fragment. If P b If the value is ≥ 0.5, a first random number is added, and the random numbers of the gene fragments are changed cyclically until all the gene fragments of the current individual have completed the random change and the initial individual is obtained; the first random number is a random number uniformly distributed between 0 and 1; Multiple initial individuals with different gene fragments are combined to obtain an initial population.
[0010] Furthermore, the process of constructing the fitness function includes: The first objective function and the second objective function are normalized to obtain corresponding first objective parameters and second objective parameters respectively; the first objective parameter is specifically expressed as: ; The second target parameter is specifically expressed as: ; in, y i ’ It is the Y-axis coordinate value of each device in the equipment cabinet in the inferior template; Calculate the mean of the highest and lowest horizontal positions of the equipment in the current layout scheme to obtain the value D1; at the same time, calculate the mean of the highest and lowest horizontal positions of the equipment in the inferior template given above to obtain the value D2. Compare the values D1 and D2 to obtain the third target parameter of the fitness function. The third target parameter is expressed as: ; in, T ’ max Indicates the highest horizontal position of the equipment in the inferior template; T ’ min Indicates the lowest horizontal position of the equipment in the inferior template; Detect all devices in the layout plan, record the number F4 of devices in the layout plan that exceed the layout space of the equipment cabinet and overlap with other devices in volume, and use the product of the number F4 of devices and the preset penalty value as the penalty function; The first target parameter, the second target parameter, the third target parameter and the penalty function are weighted and summed to obtain the fitness function F: ; in, ω 1 , ω 2 , ω 3are the weights of the first target parameter, the second target parameter, and the third target parameter respectively.
[0011] Furthermore, the step of selecting high-quality individuals from the initial individuals according to the preset fitness value includes: Take the inverse of the fitness function value of each initial individual calculated in the initial population to get the inverse value GL i ; Calculate all reciprocal values GL i The accumulated value Sum is the inverse value GL of each initial individual i Compare with the accumulated value Sum to obtain the normalized probability value of the initial individual in the initial population; The normalized probability values of all initial individuals are converted into cumulative probabilities, a preset fitness value is randomly generated, and the initial individuals whose cumulative probabilities are greater than the preset fitness value are screened out as high-quality individuals.
[0012] Furthermore, the animation is generated in the layout space according to the optimal layout solution, and collision detection of the equipment installation process is performed during the animation generation process, and the moving direction of the equipment in the animation is adjusted according to the collision detection result to obtain the final equipment installation demonstration animation, including: Obtaining the current device coordinates and the target location coordinates of the electromechanical device from the optimal layout solution, and calculating the direction vector between the current device coordinates and the target location coordinates; Generate an animation for installing electromechanical equipment in the layout space according to the direction vector, and move the electromechanical equipment along the direction vector for one frame; During the movement of the electromechanical device, the coordinate position of the moving electromechanical device is taken as the center of the box-shaped area, and the size of the moving electromechanical device is taken as the diameter of the box-shaped area for collision detection. If there are other devices in the box-shaped area, the collision adjustment mode is entered to change the direction vector of the electromechanical device and move the electromechanical device according to the changed direction vector. If there are no other devices in the box-shaped area, the difference distance between the current device coordinates and the target position coordinates is calculated in each frame, and the moving speed of the electromechanical device in each frame is reduced by adjusting the difference distance; It is determined whether the phase difference is less than a preset threshold value. If so, the electromechanical equipment has been successfully installed at the target position. At this time, switch to the next electromechanical equipment for installation operation until all electromechanical equipment are successfully placed at the predetermined installation position, and obtain the equipment installation demonstration animation in the layout space.
[0013] In a second aspect, an embodiment of the present invention provides a device space layout optimization system based on a genetic algorithm, comprising: The device abstraction module is used to obtain the actual proportion of the electromechanical device and abstract the shape of the electromechanical device according to the actual proportion to obtain the device abstraction structure; A model building module, used to model in the layout space according to preset constraints and the device abstract structure to obtain a layout optimization model; A layout optimization module, used to perform a global search in the layout space using a genetic algorithm based on the layout optimization model to obtain an optimal layout solution; The equipment installation demonstration module is used to generate an animation in the layout space according to the optimal layout solution, and perform collision detection of the equipment installation process during the animation generation process, and adjust the equipment movement direction in the animation according to the collision detection result to obtain the final equipment installation demonstration animation.
[0014] In summary, the beneficial effects of the present invention are as follows: The present invention provides a method and system for optimizing equipment space layout based on genetic algorithm. The method obtains the actual proportion of electromechanical equipment and abstracts the shape of the electromechanical equipment according to the actual proportion to obtain the equipment abstract structure; models are modeled in the layout space according to preset constraints and the equipment abstract structure to obtain a layout optimization model; based on the layout optimization model, a genetic algorithm is used to perform a global search in the layout space to obtain the optimal layout solution, thereby realizing the automatic layout of electromechanical equipment, reducing manual intervention in the layout process, and improving the layout efficiency. At the same time, the method of optimizing the model through the genetic algorithm ensures the rationality and feasibility of the layout result, thereby improving the quality of the layout design of the electromechanical equipment system. In addition, the present invention also generates an equipment installation demonstration animation in the layout space according to the optimal layout solution, which can provide convenient guidance for the installer. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the technical solution of the embodiment of the present invention, the drawings required for use in the embodiment of the present invention will be briefly introduced below. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work, and these are all within the protection scope of the present invention.
[0016] Figure 1 A schematic diagram of a flow chart of a method for optimizing equipment space layout based on a genetic algorithm according to the present invention; Figure 2 It is a comparison diagram of the actual equipment ratio of the present invention; Figure 3 It is a schematic diagram of the overall process of the genetic algorithm of the present invention; Figure 4 A flow chart for completely randomly generating an initial population of the present invention; Figure 5 It is a flow chart of the installation of the equipment of the present invention; Figure 6 The figure is a schematic diagram of the module structure of a genetic algorithm-based equipment space layout optimization system of the present invention. DETAILED DESCRIPTION
[0017] In order to make the purpose, technical solution and advantages of the embodiment of the present invention clearer, the technical solution in the embodiment of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiment of the present invention. It should be noted that in the embodiment of the present invention, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. If there is no conflict, the various features of the present invention and the embodiments can be combined with each other, all within the scope of protection of the present invention.
[0018] Example 1: Reference Figure 1 As shown, an embodiment of the present invention provides a schematic flow chart of a method for optimizing device space layout based on a genetic algorithm, and the method mainly includes the following steps: S1: obtaining an actual proportion of the electromechanical device, and abstracting the shape of the electromechanical device according to the actual proportion to obtain an abstract structure of the device; S2: Modeling is performed in the layout space according to preset constraints and the device abstract structure to obtain a layout optimization model; S3: Based on the layout optimization model, a genetic algorithm is used to perform a global search in the layout space to obtain an optimal layout solution; S4: Generate an animation in the layout space according to the optimal layout solution, perform collision detection of the equipment installation process during the animation generation process, adjust the moving direction of the equipment in the animation according to the collision detection result, and obtain the final equipment installation demonstration animation.
[0019] Furthermore, in the embodiment of the present invention, the actual proportion of the electromechanical device is obtained in step S1, and the shape of the electromechanical device is abstracted according to the actual proportion to obtain the device abstract structure, including: The length, width and height dimensions of various electromechanical equipment are collected, and the shape of each electromechanical equipment is uniformly regarded as a rectangular structure. Each electromechanical equipment is abstracted into a corresponding equipment abstract structure according to the actual length, width and height ratio.
[0020] Specifically, the core of all layout problems of electromechanical equipment is the placement of objects, so determining the placement of equipment is the most important link in the equipment cabinet layout optimization process. In an embodiment of the present invention, for equipment that needs to be laid out in space, the detailed features of its shape are ignored, it is abstracted only according to the actual proportion, and its shape is uniformly regarded as a rectangular structure. The length, width, and height dimensions of each device are known, and the placement method (horizontal or vertical) is also fixed. Therefore, each device is randomly arranged according to its specific constraints, and their positions are all parallel to the four sides of the equipment cabinet. Therefore, the equipment layout problem of the equipment cabinet is simplified to a continuous space layout optimization problem that satisfies specific constraints under given assumptions.
[0021] Further, in the embodiment of the present invention, in step S2, modeling is performed in the layout space according to the preset constraints and the device abstract structure to obtain a layout optimization model, including but not limited to the following sub-steps: S21, constructing a first objective function and a second objective function of the device layout respectively according to preset constraints and size parameters of multiple device abstract structures; S22. Based on the first objective function and the second objective function, perform equipment modeling in the layout space to obtain a layout optimization model for the arrangement of the electromechanical equipment of interest in the Y-axis direction.
[0022] In the embodiment of the present invention, the device can establish a layout optimization model with the optimization goal of reducing the space occupation cost of the equipment cabinet through the above problem description and related assumptions, so as to determine the reasonable equipment placement location. Figure 2 As shown in the figure, in the actual equipment cabinet model, each device is installed on a hole rack, and there are only six hole racks in the equipment cabinet, which constitutes a strong constraint on the equipment layout. Since the three-dimensional size of each device naturally determines the location of the installation hole rack, this means that the coordinates of the device on the X-axis and Z-axis are relatively fixed. Therefore, layout optimization only needs to study and optimize its coordinates on the Y-axis.
[0023] Furthermore, in the embodiment of the present invention, in sub-step S21, the first objective function and the second objective function of the device layout are respectively constructed according to the preset constraint conditions and the size parameters of the multiple device abstract structures, specifically including: The preset constraints are set according to the layout requirements during the equipment layout process. Specifically, the preset constraints include a first constraint and a second constraint; wherein the first constraint is that during the equipment layout process, the equipment cannot overlap, and the first constraint is specifically expressed as: (1); in, x i 、yi 、z i are the spatial coordinates of each electromechanical device in the current layout, X i 、Y i 、Z i They are the dimensions of each electromechanical device in the XYZ directions respectively.
[0024] Since the X-axis and Z-axis coordinates of the equipment are already subject to constraints, in the model established by the embodiment of the present invention, we only need to pay attention to the layout of the equipment in the Y direction. In order to ensure that the equipment can be installed normally in the equipment cabinet, the layout of the equipment in the Y direction should not exceed the height H of the equipment cabinet. This means that the Y-axis coordinate of each device plus the height of the device cannot exceed the upper limit of the height of the equipment cabinet. The second constraint condition is that the layout of the electromechanical equipment in the Y direction should not exceed the height H of the equipment cabinet. The second constraint condition is specifically expressed as: (2);
[0025] Under such constraints, in order to achieve the most efficient use of the space in the equipment cabinet, the goal of the embodiment of the present invention is to minimize the space occupation cost of the equipment in the equipment cabinet. This can be achieved by wrapping all the equipment with a minimum cuboid, and the volume of the cuboid is required to be as small as possible. Therefore, according to the preset constraints and the size parameters of the device abstract structure of the electromechanical equipment, the embodiment of the present invention constructs a first objective function for optimizing the volume occupied by the electromechanical equipment in the equipment cabinet and a second objective function for optimizing the placement of the electromechanical equipment in the equipment cabinet.
[0026] Specifically, the first objective function M1 is expressed as: (3); Among them, T max Indicates the highest horizontal position of the device in the current layout; T min Indicates the lowest horizontal position of the equipment in the current layout; L indicates the length of the equipment cabinet; W indicates the width of the equipment cabinet; To facilitate the installation and handling of subsequent equipment, larger equipment should be located lower in the equipment cabinet than smaller equipment. This means that the Y-axis coordinate of larger equipment should be smaller than the Y-axis coordinate of smaller equipment. In addition, all equipment should be as close to the bottom of the equipment cabinet as possible to further optimize space utilization and facilitate installation operations. Therefore, the optimization goal of the embodiment of the present invention is not only to make the equipment layout compact, but also to ensure that the placement of the equipment is conducive to installation and maintenance operations. In order to achieve this goal, the embodiment of the present invention designs a second objective function, and the second objective function M2 is expressed as: (4); in, V i Indicates the size of each device ; X i 、Y i 、Z i They are the dimensions of each device in the XYZ directions respectively; y i Indicates the Y-axis coordinate of the device in the current layout.
[0027] In order to obtain the optimal solution of the two objective functions under the constraints, the embodiment of the present invention subsequently uses a genetic algorithm for optimization.
[0028] Further, in the embodiment of the present invention, in step S3, based on the layout optimization model, a genetic algorithm is used to perform a global search in the layout space to obtain the optimal layout solution, including but not limited to the following sub-steps: S31: obtaining a layout scheme output by the layout optimization model in the layout space, and taking the coordinate values of each electromechanical device on the Y axis in a layout scheme as individuals, randomly initializing and generating an initial population having a plurality of different initial individuals; S32: Calculate the population fitness of each initial individual in the initial population using the fitness function, and select high-quality individuals from the initial individuals according to the preset fitness value during the calculation process; S33: Perform crossover and mutation operations on high-quality individuals to generate a new population, and iterate the population fitness calculation on the new population until the number of iterations reaches the set value, and then output the optimal individual; S34: taking the coordinate value of each electromechanical device in the optimal individual on the Y axis as the optimal layout solution of the electromechanical device in the layout space.
[0029] The embodiment of the present invention uses a genetic algorithm to solve the layout optimization model. Among them, the genetic algorithm (GA) is an optimization algorithm that simulates the natural evolution process and is widely used to solve complex optimization problems and search problems. It is based on Darwin's theory of evolution and the basic principles of genetics, and searches for the optimal solution or the solution space close to the optimal solution by simulating processes such as natural selection, crossover, and mutation. The genetic algorithm is not only of great significance in theory, but also demonstrates powerful processing capabilities in practical applications, especially in multi-objective optimization and high-dimensional problems.
[0030] The basic idea of genetic algorithms is to find the optimal solution by simulating the process of biological evolution. Specifically, traditional genetic algorithms include the following key concepts and steps: 1. Individual representation: A possible solution in the solution space of a problem is called an individual, which is usually represented by binary coding or other coding methods. Each individual represents a potential solution, and its encoding method can be selected according to the specific problem.
[0031] 2. Population initialization: Randomly generate a certain number of individuals as the initial population. The diversity of the initial population is the basis for the genetic algorithm to effectively search the solution space. It is usually necessary to ensure that the population has sufficient diversity to avoid premature convergence.
[0032] 3. Fitness evaluation: Calculate the fitness of each individual, that is, the quality of the solution, usually evaluated through the objective function. The fitness function is an important part of the genetic algorithm, which directly affects the effect of the selection operation and the quality of the final solution.
[0033] 4. Selection operation: select a certain number of individuals as parents according to their fitness to produce the next generation of individuals. Common selection methods include roulette selection, tournament selection, and ranking selection, which help retain good genes and eliminate inferior genes.
[0034] 5. Crossover operation: Perform a crossover operation on the parent individuals to generate new individuals. The crossover operation is one of the core mechanisms of the genetic algorithm. It generates new individuals by exchanging some gene combinations of the parent individuals, thereby increasing the diversity of the solution space.
[0035] 6. Mutation operation: Perform mutation operation on newly generated individuals to introduce new genetic information. Mutation operation can prevent the population from falling into the local optimal solution and help explore new solution space areas.
[0036] 7. Intergenerational update: Replace the original population with newly generated individuals to form a new population. Intergenerational update ensures that the population continues to evolve and optimize, gradually approaching the optimal solution through multiple iterations.
[0037] 8. Termination condition: When the preset stopping condition is reached (such as the number of iterations, the target value reaches a certain threshold, etc.), the algorithm ends and the optimal solution or a solution close to the optimal solution is output.
[0038] Genetic algorithms have the following advantages: 1. Suitable for complex, high-dimensional optimization problems: It can search in a large solution space, is independent of the specific form of the problem, and has strong adaptability.
[0039] 2. Strong global search capability: Through crossover and mutation operations, it can avoid falling into the local optimal solution and increase the chance of finding the global optimal solution.
[0040] 3. Parallel processing is possible: Genetic algorithm operations, such as fitness evaluation, selection, crossover, and mutation, can be performed simultaneously on different individuals or subpopulations, thus speeding up the search process.
[0041] 4. Flexible response to different types of problems: By adjusting the parameters of the genetic algorithm (such as population size, crossover rate, mutation rate) and operation mode, it can adapt to a variety of optimization problems.
[0042] When implementing a genetic algorithm, the following points require special attention: 1. Population diversity: The diversity of the initial population and the method of maintaining population diversity directly affect the effect of the algorithm. Premature population convergence will cause the search process to stagnate at the local optimal solution.
[0043] 2. Fitness function design: The design of the fitness function must fully reflect the objectives and constraints of the problem, which is the basis for evaluating the pros and cons of individuals.
[0044] 3. Crossover and mutation operations: The design and implementation of crossover and mutation operations need to balance the ability to explore the solution space and develop the current excellent solution. The crossover operation is mainly used to recombine existing excellent genes, while the mutation operation is used to explore new solution spaces.
[0045] In summary, genetic algorithms provide a powerful search and optimization tool by simulating the process of natural selection and biological evolution. It is widely used in solving complex optimization problems, with successful cases in fields ranging from engineering design, economic scheduling to bioinformatics. The flexibility and powerful global search capabilities of genetic algorithms make them a powerful tool for dealing with high-dimensional, nonlinear and multi-objective optimization problems.
[0046] In the embodiment of the present invention, the genetic algorithm steps used are basically the same as the traditional genetic algorithm process. For the spatial layout optimization problem discussed in the embodiment of the present invention, the individual represents the coordinate value of each device on the Y axis in a layout scheme. The population is composed of multiple different individuals, each of which represents a possible layout scheme. In some embodiments, the number of individuals in the population can be set to 100.
[0047] Reference Figure 3 As shown, in the embodiment of the present invention, the process of solving the layout optimization model by using the genetic algorithm specifically includes: First, in the population initialization stage, 100 different initial individuals are generated to ensure that the population has sufficient diversity and lay the foundation for the subsequent optimization process. Next, each individual is evaluated through fitness evaluation. The fitness function is used to measure the pros and cons of each layout scheme. The selection operation selects a certain number of high-quality individuals through the fitness value. These individuals will be used as parents to generate the next generation of population.
[0048] In the crossover operation stage, the selected high-quality individuals undergo genetic recombination, and new individuals are generated through the crossover operation. The mutation operation performs genetic mutations on the newly generated individuals and introduces new genetic information to increase the diversity of the population and prevent premature convergence. After the crossover and mutation operations are completed, the inferior individuals in the initial population are eliminated, and the newly generated high-quality individuals are incorporated into the initial population, completing an update iteration of the population. This process is repeated continuously, and after multiple iterations, each generation of the population will evolve towards a better solution space.
[0049] The iteration process continues until the preset number of iterations is reached, and the high-quality individuals finally retained are the optimal layout solutions found by the genetic algorithm. In this way, the genetic algorithm can find a satisfactory equipment layout solution under given constraints, thereby improving space utilization efficiency and the rationality of the overall layout.
[0050] In the embodiment of the present invention, the genetic algorithm is compared with other commonly used layout optimization algorithms, and the advantages and disadvantages are as follows: Advantages: (1) Strong global search capability: Genetic algorithms can perform global searches in a wide range of search spaces by simulating the selection, crossover, and mutation in the biological evolution process in nature. This enables genetic algorithms to avoid falling into local optimal solutions and find better global optimal solutions. It can handle highly complex optimization problems, especially those with complex and multi-peaked solution spaces.
[0051] (2) Strong adaptability: Genetic algorithms have strong adaptability and can handle various types of optimization problems, including nonlinear problems, multidimensional problems, and problems with complex constraints. Whether it is an optimization problem in continuous space or discrete space, genetic algorithms can effectively find feasible solutions.
[0052] (3) Parallel computing: Genetic algorithms are very suitable for parallel computing. In the calculation process of each generation, the fitness evaluation and operation of different individuals can be carried out simultaneously, which greatly improves the computing efficiency. The ability of parallel computing gives genetic algorithms a significant advantage in dealing with large-scale problems and can converge to the optimal solution more quickly.
[0053] (4) Good robustness: Genetic algorithms are less sensitive to initial conditions and parameter selection, and show good robustness. Even when the initial population selection is not ideal, genetic algorithms can still gradually optimize the solution through the evolutionary process, thereby achieving better results. In addition, the ability to adapt to parameters also enables genetic algorithms to maintain good performance in different types of optimization problems.
[0054] Disadvantages: (1) High computational complexity: Genetic algorithms require a large number of individual evaluations and operations, which results in a large amount of computation. In the computation process of each generation, it is necessary to evaluate the fitness of all individuals in the population and perform operations such as selection, crossover, and mutation, which makes the computational complexity of genetic algorithms high. When dealing with large-scale problems, the demand for computing resources also increases accordingly.
[0055] (2) Slow convergence: Although genetic algorithms have powerful global search capabilities, they are slow in finding the global optimal solution. Since they need to gradually optimize the solution through multiple generations of evolution, genetic algorithms usually require a large number of iterations to converge to the optimal solution. This feature is particularly evident when dealing with complex optimization problems. Complex parameter settings: Parameters such as crossover probability, mutation probability, and population size need to be carefully adjusted.
[0056] (3) Complex parameter settings: The performance of genetic algorithms depends on the settings of multiple parameters, such as crossover probability, mutation probability, and population size. Different optimization problems may require different parameter settings, and finding the right combination of parameters requires a lot of experiments and debugging. The complexity of parameter settings increases the difficulty of applying genetic algorithms, and careful adjustment and optimization are required in practical applications.
[0057] In summary, compared with other commonly used layout optimization algorithms, genetic algorithms have obvious advantages in global search capability, adaptability and robustness, and are suitable for solving complex multi-dimensional optimization problems. In practical applications, it is possible to consider combining genetic algorithms with other optimization algorithms to form a hybrid algorithm to fully utilize the advantages of each algorithm and overcome its shortcomings, thereby improving the optimization efficiency and solution quality.
[0058] Furthermore, in the embodiment of the present invention, the random initialization in sub-step S11 to generate an initial population having a plurality of different initial individuals includes: Presetting a layout template that meets the space constraints of the equipment cabinet, wherein the layout template includes a high-quality template, a common template, and a low-quality template; Generate a random two-digit decimal Pa between [0, 1]. If Pa is between [0, 0.2], the individual template uses a high-quality template. If Pa is between [0.2, 0.8], the individual template uses an ordinary template. If Pa is between [0.8, 1], the individual template uses a low-quality template. After determining the layout template selected by the current individual, generate a random number Pb in [0, 1]. If Pb < 0.5, subtract a random number from the gene fragment of the individual. If Pb ≥ 0.5, add a random number. Repeat the process of changing the random number of the gene fragment until all the gene fragments of the current individual have completed the random change and the initial individual is obtained. Multiple initial individuals with different gene fragments are combined to obtain an initial population.
[0059] Specifically, in the embodiment of the present invention, population initialization is the first step of the genetic algorithm, which involves randomly generating a certain number of individuals as the initial population. This step is crucial in the genetic algorithm because a good initialization can significantly accelerate the convergence speed of the algorithm and find a better solution.
[0060] First, the population initialization needs to determine the representation method of the individuals. In the spatial layout optimization process of the embodiment of the present invention, the object of optimization is the coordinate value of each device on the Y-axis. Therefore, for two different spatial layout schemes, the Y-axis coordinate value of different devices is the only variable, which means that in the genetic algorithm of the embodiment of the present invention, each individual has only one chromosome. In the simulation experiment, there are 17 devices in the equipment cabinet, so the chromosome of each individual in the population contains 17 gene fragments. The process of representing chromosomes as genes is called encoding. Common encoding formats include binary encoding and floating-point encoding, while binary encoding is used in the embodiment of the present invention.
[0061] Binary encoding is to map the independent variable from decimal to N-bit binary, and N depends on the accuracy required by the research. In the simulation, the Y-axis coordinate range of the equipment cabinet is [0, 100], and the solution accuracy is 0.1, then ; Therefore, when the research requires an accuracy of 0.1, at least 10 digits are required to use binary encoding. Then the actual solution accuracy is: ; After determining the representation of individuals, the next step is to determine the size of the population, that is, the number of individuals in the population. The population size usually affects the search ability and convergence speed of the algorithm. In general, the larger the population, the wider the search space is covered, thereby increasing the possibility of finding the optimal solution, but it also increases the complexity and time cost of the calculation. In the embodiment of the present invention, the specific impact of the population size on the results of the genetic algorithm is not studied in detail, but a common setting is adopted to set the population size to 100. This number can ensure that the population has enough diversity to conduct extensive searches, and can also maintain a balance between computational complexity and convergence speed.
[0062] The next step is to randomly generate individuals to form the initial population. The population initialization needs to maintain a certain degree of randomness to ensure that the population contains diversity and avoid falling into a local optimal solution.
[0063] The present invention provides two schemes for generating an initial population, namely, completely random generation and template random generation. The following embodiments of the present invention will introduce the two schemes in detail.
[0064] For completely random generation of the initial population, completely random generation of individuals means that the parameters of each individual are obtained by random generation and are not affected by any artificial initial settings. Completely random generation of the initial population can make individuals evenly distributed in the entire solution space, thereby enhancing the global search ability of the algorithm. This method helps to find potential excellent solutions in the entire solution space. At the same time, randomly generated populations usually have high diversity, that is, individuals in the population will have different genetic combinations. This diversity helps to avoid the problem of premature convergence of the algorithm and falling into the local optimal solution, thereby increasing the possibility of the algorithm finding the global optimal solution. In this way, the genetic algorithm can explore the solution space more comprehensively and find better solutions.
[0065] But at the same time, completely randomly generating the initial population may result in low fitness for most individuals in the population, which reduces the algorithm's search efficiency. In this case, the algorithm may require more iterations to converge to a better solution. In addition, a completely randomly generated population may introduce too much randomness, which increases the instability of the algorithm. This may cause the algorithm to produce widely different results in different runs, which is not conducive to the stability and repeatability of the results. Excessive randomness may also cause the algorithm to fall into fluctuations during the search process, increasing the difficulty of finding the global optimal solution. Therefore, although completely randomly generating the initial population can enhance global search capabilities and diversity, it is also necessary to weigh the possible reduction in efficiency and stability issues.
[0066] Reference Figure 4 The flowchart of completely random generation of the initial population is shown. When generating the initial population, the first random number is first generated as the Y-axis coordinate value of the first device, and it is substituted into the detection function to detect whether the current device meets the space constraint of the equipment cabinet. If not, a random number is regenerated until the detection meets the space constraint. Passing the detection means that the first device has been successfully placed in the equipment cabinet, and we begin to place subsequent objects in sequence. Unlike the first device, after the subsequent random Y-axis coordinate value is generated, it is necessary not only to detect whether it meets the space constraint of the equipment cabinet, but also to detect whether the current device has a volume overlap with the previously placed device. In the subsequent placement process, if a device generates random numbers 10,000 times in a loop and does not meet the constraint requirements, it is considered that there is a problem with the placement of the first device, and the individual generation this time is discarded, and the placement starts again from the first device.
[0067] Through experiments, it is found that completely randomly generating the initial population has application difficulties. Due to the existence of the mounting hole frame, the X value and Z value of each device are relatively fixed, which imposes a strong constraint on the device position. In the simulation experiment, after the Y-axis values of 9 devices are randomly generated, due to the large volume of the 10th device, the current space actually does not have coordinates that meet the space constraints and can accommodate the 10th device, and there are 5 devices with similar large volumes to the 10th device. This is a dilemma that is difficult to overcome when generating the initial population completely randomly. Therefore, the embodiment of the present invention abandons completely randomly generating the initial population and instead selects templates to randomly generate the initial population.
[0068] Template random generation of the initial population is a common method for initializing the population of genetic algorithms. By setting a template or rule, individuals that meet the conditions are randomly generated according to the template as the initial population. This method is simple and direct, easy to implement and understand. At the same time, the diversity of generated individuals can be controlled by template design to avoid individuals in the population being too similar. By using a template, certain guiding information can be introduced in the initial stage to improve the quality of the initial population, thereby improving the convergence speed of the algorithm in the early stage. However, due to the limitations of the template rules, the search process may be limited to the solution space defined by the template, affecting the global search capability. Although the template random generation of the initial population improves the fitness and diversity of the population to a certain extent, careful trade-offs need to be made when designing the template to avoid over-constraints in the search space and omissions of potential solutions.
[0069] In the algorithm, the embodiment of the present invention provides three layout templates that meet the space constraints of the equipment cabinet. For ease of understanding, they are called high-quality template, ordinary template, and low-quality template. The three templates correspond to three different fitness levels. The high-quality template has the best fitness level, the ordinary template is second, and the low-quality template has the worst fitness level. When generating the initial population, first generate a random two-digit decimal number P between [0, 1]. a If Pa is between [0, 0.2], the individual template is selected as a high-quality template. If P a If P is between [0.2, 0.8], the individual template uses the common template. a If the template is between [0.8, 1], the template of the individual is a low-quality template. After determining the template selected by the current individual, in order to avoid individuals in the population being too similar, it is necessary to make random changes to the gene fragments in the individual to increase diversity. Generate a random number P between [0, 1] b , if P b < 0.5, then the gene fragment subtracts a new first random number, otherwise a new first random number is added, and the cycle continues until all gene fragments of the current individual have completed random changes. Among them, the first random number subtracted or added to the gene fragment is a newly generated random number, which is specifically a random number uniformly distributed between 0 and 1.
[0070] In the simulation experiment, due to the use of a template that meets the space constraints of the equipment cabinet, most of the individuals in the generated initial population meet the initial constraints, which greatly facilitates the subsequent evolution process. Although compared with the completely random generation of the initial population, the template randomly generated initial population may not cover the entire solution space, resulting in the search results being limited to the range defined by the template, but in the evolution process, this defect can be compensated by reasonably setting the crossover probability and mutation probability. In addition, due to the regularization of the generated individuals, the population generation process is relatively stable, which is conducive to the stability and convergence of the algorithm. Taking these factors into consideration, the embodiment of the present invention finally selected the method of randomly generating the initial population by template to improve the initial efficiency of the algorithm and ensure the effectiveness of the subsequent evolution process.
[0071] Furthermore, the fitness function plays a vital role in the genetic algorithm. It evaluates the quality of each individual in the solution space, thereby determining the individual's chance of survival and reproduction in the evolutionary process. The design of the fitness function directly affects the performance and efficiency of the genetic algorithm. A well-designed fitness function can not only effectively distinguish high-quality individuals from low-quality individuals, but also guide the algorithm to converge quickly to the optimal solution area. Therefore, the precise design and reasonable implementation of the fitness function is one of the key factors for the successful application of the genetic algorithm, and has a decisive influence on the final effect of the algorithm.
[0072] Referring to the objective function and constraint conditions given in the above embodiment of the present invention, the fitness function of the genetic algorithm should be multi-objective optimization. Under the premise of satisfying the equipment cabinet space constraint, the layout should try to meet the following conditions: 1. Minimize the space cost of equipment in the equipment cabinet; 2. Larger devices should be located lower in the cabinet than smaller devices, i.e., the Y-axis coordinate of larger devices should be smaller than that of smaller devices; 3. All equipment should be as close to the bottom of the equipment cabinet as possible, that is, the Y-axis coordinate value of all equipment should be as small as possible.
[0073] Under the above layout conditions, in order to make the layout plan meet the spatial constraint requirements of the equipment cabinet, the embodiment of the present invention introduces a penalty function in the fitness function. The penalty function is used to penalize individuals that do not meet the problem constraints to prevent these individuals from being selected or preferred during the evolution process, thereby affecting the algorithm's search effect and the quality of the solution. In the spatial layout process of the embodiment of the present invention, there are two hard constraints: one is that the equipment cannot exceed the layout space of the equipment cabinet, and the other is that the equipment cannot overlap with each other. By introducing a penalty function in the fitness function, individuals that do not meet these hard constraints are appropriately penalized to ensure that the algorithm can effectively search for high-quality layout plans that meet the spatial constraint requirements.
[0074] Based on the above conditions, the process of constructing the fitness function of the embodiment of the present invention includes: First, the first objective function and the second objective function are normalized to obtain the corresponding first objective parameter and second objective parameter. In order to minimize the space occupation cost of the equipment in the equipment cabinet, the embodiment of the present invention is described as follows: in the layout plan, a rectangular parallelepiped as small as possible is used to contain all the equipment. The ratio of the volume of the rectangular parallelepiped to the volume of the entire layout space of the equipment cabinet is the first objective parameter F1 of the fitness function. The first objective parameter is specifically expressed as: (5); For larger devices, they should be located at a lower position in the equipment cabinet than those with smaller devices, that is, the Y-axis coordinates of larger devices should be smaller than those with smaller devices. The embodiment of the present invention describes it as follows: In the layout plan, the values obtained by multiplying the volume of each device by the Y-axis value of its coordinates are accumulated to obtain the value C1. At the same time, the values obtained by multiplying the volume of each device in the inferior template given in the above embodiment by the Y-axis value of its coordinates are calculated, and the values are accumulated to obtain the value C2. By comparing the two numbers, the second target parameter F2 of the fitness function can be obtained. Therefore, the second target parameter is specifically expressed as: (6) in, y i ’ It is the Y-axis coordinate value of each device in the equipment cabinet in the inferior template; All devices should be as close to the bottom of the equipment cabinet as possible, that is, a minimum cuboid is used to cover all devices in the current layout space, and the center of the cuboid should be as close to the bottom of the equipment cabinet as possible. The embodiment of the present invention describes it as follows: in the layout scheme, the average of the highest horizontal position and the lowest horizontal position of the equipment in the current layout scheme is calculated to obtain a value D1; at the same time, the average of the highest horizontal position and the lowest horizontal position of the equipment in the inferior template given above is calculated to obtain a value D2, and the values D1 and D2 are compared to obtain the third target parameter of the fitness function. The third target parameter is expressed as: (7) in, T ’ max Indicates the highest horizontal position of the equipment in the inferior template; T ’ min Indicates the lowest horizontal position of the equipment in the inferior template; For the penalty function, all devices in the layout plan are tested, the number of devices F4 in the layout plan that exceed the layout space of the equipment cabinet and overlap with other devices is recorded, and the product of the number of devices F4 and the preset penalty value is used as the penalty function. In the embodiment of the present invention, the preset penalty value is set to 10000.
[0075] Multi-objective optimization usually involves multiple competing or conflicting optimization objectives, which may have different importance and priorities. In order to effectively weigh the various objectives during the optimization process and reflect the relative importance of each objective in the overall optimization, the embodiment of the present invention chooses to use a weighted summation method to calculate the normalized objectives to obtain a single comprehensive objective value. Through weighted processing, the direction of algorithm optimization can be adjusted so that the algorithm is more inclined to optimize important objectives, thereby more effectively searching for solutions that meet the requirements. Giving different weights to different objectives can guide the algorithm to be more inclined to meet those objectives that are considered more important during the algorithm search process, thereby improving the quality and applicability of the final solution.
[0076] In summary, the embodiment of the present invention performs weighted sum processing on the first target parameter, the second target parameter, the third target parameter and the penalty function to obtain the fitness function F: (8) in, ω 1 , ω 2 , ω 3are the weights of the first target parameter, the second target parameter and the third target parameter respectively. From the objective function analysis, it can be concluded that the embodiment of the present invention requires F1, F2 and F3 to reach the smallest possible value, that is, for the layout scheme, the smaller the fitness function value, the better the layout scheme.
[0077] In the embodiment of the present invention, the selection operation, crossover operation and mutation operation in the genetic algorithm are the core evolutionary operations. The selection operation evaluates the fitness value of the individual and retains the individuals with higher fitness as the parents of the next generation of the population. This ensures that excellent genetic information can be passed on and the population develops in a more excellent direction. The core of the selection operation is to increase the probability of individuals with high fitness being selected, thereby enhancing the quality of the overall population. Through this operation, excellent individuals have a higher probability of being selected and reproducing in the genetic algorithm, while individuals with lower fitness have a lower probability of being selected, thereby gradually being eliminated. This mechanism can not only maintain the diversity of the population and avoid premature convergence to the local optimal solution, but also continuously optimize the quality of the solution through intergenerational transmission, thereby improving the global search capability and convergence speed of the algorithm.
[0078] The crossover operation selects a pair of individuals from the parent individuals and exchanges their genetic information in some way to generate new offspring individuals. In this way, the advantages of the two parent individuals can be combined to produce offspring individuals with better fitness. Specifically, the crossover operation can combine the excellent genes of the parent generation, thereby improving the overall fitness of the offspring. At the same time, the crossover operation introduces new gene combinations into the population, increasing the diversity of the population. This method of gene recombination can not only improve the exploration ability of the genetic algorithm, but also effectively prevent the algorithm from falling into the local optimal solution. By continuously performing the crossover operation, the individuals in the population gradually evolve, making it more likely to find the global optimal solution.
[0079] The mutation operation is to randomly mutate the genetic information of an individual and introduce new genetic information. This operation plays an important role in genetic algorithms. By randomly adjusting the genes of an individual, the mutation operation can break the existing genetic structure and introduce new genetic information. This can not only prevent individuals in the population from being too similar and maintain the diversity of the population, but also avoid falling into the local optimal solution during the search process. In addition, the mutation operation can help the algorithm search more comprehensively in the solution space, explore more possible solutions, and increase the probability of the algorithm finding the global optimal solution. Through appropriate mutation operations, the population can continuously generate new gene combinations, thereby continuously optimizing during the evolution process and improving overall fitness.
[0080] Furthermore, in the selection operation, the embodiment of the present invention uses a roulette wheel to implement the selection operation, that is, the selection is performed according to the proportion of the individual fitness values, and the individual with higher fitness has a greater probability of being selected. Before using the roulette wheel for selection, some operations need to be performed on the fitness function value of the individual to make it more convenient for the roulette wheel to use.
[0081] It can be seen from the fitness function in the above embodiment that the quality of the layout plan is inversely proportional to its corresponding fitness function value. In other words, excellent layout plan individuals have smaller fitness function values. In addition, for those layout plan individuals that do not meet the spatial layout constraints of the equipment cabinet, due to the existence of the penalty function, their fitness function values are much higher than those of individuals under normal circumstances. In view of this situation, the embodiment of the present invention decides to adopt the method of taking the inverse of the fitness function value of each individual. This operation can not only eliminate the interference of a large amount of data, but also provide a more convenient data processing method for subsequent roulette selection.
[0082] Therefore, in the embodiment of the present invention, high-quality individuals are screened out from the initial individuals according to the preset fitness value, including the following process: Take the inverse of the fitness function value of each initial individual calculated in the initial population to get the inverse value GL i ; Calculate all reciprocal values GL i The accumulated value Sum is the inverse value GL of each initial individual i Compare with the accumulated value Sum to obtain the normalized probability value of the initial individual in the initial population; The normalized probability values of all initial individuals are converted into cumulative probabilities, a preset fitness value is randomly generated, and the initial individuals whose cumulative probabilities are greater than the preset fitness value are screened out as high-quality individuals.
[0083] The cumulative probability roulette selection method is an intuitive and easy-to-understand selection strategy. It calculates the fitness ratio of each individual and adds these ratios to obtain a probability value (i.e., cumulative probability) ranging from 0 to 1. Subsequently, the corresponding individual is selected based on the size of the generated random number (i.e., the preset fitness value) falling within this range. This method ensures that individuals with higher fitness have a greater probability of being selected, making it more likely that good genes will be retained and passed on during the evolution process.
[0084] The cumulative probability roulette selection method can maintain the diversity of the population to a certain extent. Even individuals with lower fitness have a certain probability of being selected, which helps to prevent the population from falling into a local optimal solution too early and being unable to jump out.
[0085] There is a retention rate P in the selection operation g, the selection operation is to select a certain number of high-quality individuals from the population, and P g It is used to determine the number of selected high-quality individuals, the population size NP and the retention rate P g Multiplying them together gives the number of times the roulette wheel selection is performed. After the selection operation, the excellent individuals in the population are selected, and the next step is to perform crossover and mutation operations on these excellent individuals.
[0086] In the description of the gene segments of individuals in the above embodiment, each individual has only one chromosome, and each chromosome has 17 gene segments. There is a crossover rate P in the crossover operation. c In the crossover operation, a random number in the interval [0, 1] is first generated, and the random number is combined with P c The size relationship between the two individuals is used to determine whether a crossover operation will occur between the two individuals. When a crossover operation is determined between the individuals, a random number in the interval [1, 17] is generated to determine the crossover breakpoint position, and finally the second half of the chromosomes of the two individuals are exchanged to complete the crossover operation. Among the selected excellent individuals, two adjacent individuals need to undergo a crossover operation judgment to increase the diversity of the population.
[0087] After the high-quality individuals complete the crossover operation, they need to be mutated. The main purpose of the mutation operation is to introduce new variables, explore a wider solution space, and prevent the genetic algorithm from falling into the local optimal solution. In the description of the gene fragments above, each gene fragment is 10 bits of binary data. The mutation operation is to select the random bits of the random gene fragment of the individual for mutation after determining that the individual has mutated. There is a mutation rate P in the mutation operation. m In the mutation operation, a random number in the interval [0, 1] is first generated, and the random number is compared with P m The size relationship between the two determines whether the individual will mutate. When it is determined that the individual has mutated, a random number in the interval [0, 17] is generated to determine the gene segment where the mutation occurred, and then a random number in the interval [0, 10] is generated to determine where the 10-bit binary data in the gene segment has mutated. After completing the above random number generation, the selected position data is inverted to complete the mutation operation.
[0088] After the crossover and mutation operations, the selected high-quality individuals are significantly different from the high-quality individuals in the original population. After completing the above selection, crossover, and mutation processes, the next step is to generate a new generation of population. Population iteration is the core mechanism of genetic algorithms to search for solution space. Through iteration, individuals in the population continue to evolve, thereby searching for possible optimal solutions in the solution space. When generating a new generation of population, the first thing to do is to exclude the inferior individuals in the old generation of population. In the selection operation, the fitness function value of the individual has been converted into the selection rate. The inferior individuals have a lower selection rate. It is only necessary to sort the selection rate of the population, discard the inferior individuals with the same number of high-quality individuals, and merge the evolved high-quality individuals into the old population to generate a new generation of population. At this point, the population has completed an iteration.
[0089] This process is repeated until the maximum number of population iterations is reached, and the layout optimization is completed. The result is the final layout plan.
[0090] Further, in an embodiment of the present invention, in step S4, an animation is generated in the layout space according to the optimal layout solution, and collision detection of the device installation process is performed during the animation generation process, and the device movement direction in the animation is adjusted according to the collision detection result to obtain the final device installation demonstration animation, including but not limited to the following sub-steps: S41, obtaining the current device coordinates and the target installation position coordinates of the electromechanical device from the optimal layout solution, and calculating the direction vector between the current device coordinate position and the target installation position coordinate; S42, generating an animation for installing the electromechanical equipment in the layout space according to the direction vector, and moving the electromechanical equipment along the direction vector by one frame; S43, during the movement of the electromechanical device, taking the coordinate position of the moving electromechanical device as the center of the box-shaped area and the size of the moving electromechanical device as the diameter of the box-shaped area for collision detection, if there are other devices in the box-shaped area, entering a collision adjustment mode, changing the direction vector of the electromechanical device, and moving the electromechanical device according to the changed direction vector; S44, if there are no other devices in the box-shaped area, then the difference between the current device coordinates and the target position coordinates is calculated in each frame, and the moving speed of the electromechanical device in each frame is reduced by adjusting the difference distance; S45. Determine whether the phase difference distance is less than a preset threshold value. If so, the electromechanical equipment has been successfully installed at the target position. At this time, switch to the next electromechanical equipment for installation operation until all electromechanical equipment are successfully placed at the predetermined installation position, and obtain the equipment installation demonstration animation in the layout space.
[0091] Specifically, in an embodiment of the present invention, an embodiment of the present invention chooses to use box-shaped area detection as a collision detection method during the device installation process. By obtaining the center of the box-shaped area, that is, the coordinate position of the moving device, and by obtaining the radius of the box-shaped area, that is, the half-size of the moving device. During the movement of the device, once other objects are detected in the box-shaped area, this means that a collision has occurred with other devices during the movement of the device, and related events can be executed to avoid it. Collision detection during the movement of the device has been realized, and the last task is to realize the display of the installation process of the device, which requires the device to be placed in the final position more accurately and avoid other devices during the movement.
[0092] When the device starts to move, each device will start moving from the same starting point. In order to place the device more accurately at the final position, the embodiment of the present invention needs to design a mechanism so that the closer the device is to the target position, the slower its movement speed. To this end, the embodiment of the present invention calculates the vector between the current coordinate position of the device and the coordinate position of the target position at the beginning of each frame, and this vector will be used as the moving direction and speed of the device.
[0093] Reference Figure 5 Specifically, the device installation flow chart shown in the figure can calculate the difference between the current device coordinates and the target position coordinates in each frame, and use this distance to adjust the device's moving speed. The vector between the device and the target position can be expressed as direction = targetPosition - currentPosition, and this vector can be normalized and then multiplied by a gradually decreasing speed value. In this way, as the device gets closer and closer to the target position, its moving speed will gradually decrease until the device stops completely.
[0094] In order to detect whether the device has successfully reached the target position, the embodiment of the present invention checks the distance between the device and the target position in each frame. If the distance is less than a preset threshold, then we consider that the device has been successfully installed at the target position. At this time, switch to the next device for installation operation, repeat the above steps until all devices are successfully placed at the predetermined position, and output the final device installation demonstration animation.
[0095] During the movement of the device, if the device collides with a previously installed device, the current movement is stopped and the device enters the avoidance state, changing the direction of movement until it detects that there is no collision between the devices, and then returns to the normal movement state.
[0096] The embodiment of the present invention uses a genetic algorithm to optimize the layout problem of complex equipment cabinets, and has the following characteristics: (1) Based on the equipment cabinet layout optimization problem and the installation rack constraint problem, a multi-objective optimization mathematical model was established through comprehensive consideration to ensure that the equipment does not overlap and does not exceed the boundary, thereby improving the rationality of layout optimization.
[0097] (2) A preliminary layout scheme was obtained by using a template-based random generation initialization population method, which was used as the initial population of the genetic algorithm. The initial population was improved to make it more reasonable, thereby speeding up the optimization process.
[0098] (3) Based on the final layout plan given by the genetic algorithm, the Unity tool was used to inspect the installation process, verify the effectiveness and rationality of the spatial layout plan, and provide a reference for subsequent manual installation.
[0099] Example 2: Reference Figure 6 As shown, an embodiment of the present invention provides a device space layout optimization system based on a genetic algorithm, comprising: The device abstraction module is used to obtain the actual proportion of the electromechanical device and abstract the shape of the electromechanical device according to the actual proportion to obtain the device abstraction structure; A model building module, used to model in the layout space according to preset constraints and the device abstract structure to obtain a layout optimization model; A layout optimization module, used to perform a global search in the layout space using a genetic algorithm based on the layout optimization model to obtain an optimal layout solution; The equipment installation demonstration module is used to generate an animation in the layout space according to the optimal layout solution, and perform collision detection of the equipment installation process during the animation generation process, and adjust the equipment movement direction in the animation according to the collision detection result to obtain the final equipment installation demonstration animation.
[0100] The equipment space layout optimization system of the embodiment of the present invention obtains the actual proportion of the electromechanical equipment and abstracts the shape of the electromechanical equipment according to the actual proportion to obtain the equipment abstract structure; models the layout space according to the preset constraints and the equipment abstract structure to obtain the layout optimization model; based on the layout optimization model, the genetic algorithm is used to perform a global search in the layout space to obtain the optimal layout solution, thereby realizing the automatic layout of the electromechanical equipment, reducing manual intervention in the layout process, and improving the layout efficiency. At the same time, the method of optimizing the model through the genetic algorithm ensures the rationality and feasibility of the layout results, thereby improving the quality of the layout design of the electromechanical equipment system. In addition, the equipment space layout optimization system also generates an equipment installation demonstration animation in the layout space according to the optimal layout solution, which can provide convenient guidance for the installers.
[0101] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for optimizing equipment space layout based on genetic algorithm, It is characterized in that include: Acquiring an actual proportion of the electromechanical device, and abstracting the shape of the electromechanical device according to the actual proportion to obtain an abstract structure of the device; Modeling is performed in the layout space according to preset constraints and the device abstract structure to obtain a layout optimization model; Based on the layout optimization model, a genetic algorithm is used to perform a global search in the layout space to obtain an optimal layout solution; An animation is generated in the layout space according to the optimal layout solution, and collision detection of the equipment installation process is performed during the animation generation process. The moving direction of the equipment in the animation is adjusted according to the collision detection result to obtain the final equipment installation demonstration animation.
2. The method for optimizing equipment space layout based on genetic algorithm according to claim 1, It is characterized in that The actual proportion of the electromechanical device is obtained, and the shape of the electromechanical device is abstracted according to the actual proportion to obtain an abstract structure of the device, including: The length, width and height dimensions of various electromechanical equipment are collected, and the shape of each electromechanical equipment is uniformly regarded as a rectangular structure. Each electromechanical equipment is abstracted into a corresponding equipment abstract structure according to the actual length, width and height ratio.
3. The method for optimizing equipment space layout based on genetic algorithm according to claim 1, It is characterized in that The modeling is performed in the layout space according to the preset constraint conditions and the device abstract structure to obtain a layout optimization model, including: According to preset constraints and size parameters of various device abstract structures, a first objective function and a second objective function of device layout are respectively constructed; Based on the first objective function and the second objective function, equipment modeling is performed in the layout space to obtain a layout optimization model for the arrangement of the electromechanical equipment in the Y-axis direction.
4. The method for optimizing equipment space layout based on genetic algorithm according to claim 3, It is characterized in that According to the preset constraints and the size parameters of various device abstract structures, the first objective function and the second objective function of the device layout are constructed respectively, including: Preset constraints are set according to the layout requirements during the device layout process. The preset constraints include a first constraint and a second constraint. The first constraint is that during the device layout process, devices cannot overlap. The first constraint is specifically expressed as: ; in, x i 、y i 、z i are the spatial coordinates of each electromechanical device in the current layout, X i 、Y i 、Z i are the dimensions of each electromechanical device in the XYZ direction respectively; The second constraint condition is that the layout of the electromechanical equipment in the Y direction should not exceed the height H of the equipment cabinet. The second constraint condition is specifically expressed as: ; According to the preset constraints and in combination with the size parameters of the abstract structure of the electromechanical equipment, a first objective function for optimizing the volume occupied by the electromechanical equipment in the equipment cabinet and a second objective function for optimizing the placement of the electromechanical equipment in the equipment cabinet are constructed; The first objective function M 1 It is expressed as: ; Among them, T max Indicates the highest horizontal position of the device in the current layout; T min Indicates the lowest horizontal position of the equipment in the current layout; L indicates the length of the equipment cabinet; W indicates the width of the equipment cabinet; The second objective function M 2 It is expressed as: ; in, V i Indicates the size of each device ; X i 、Y i 、Z i They are the dimensions of each device in the XYZ directions; y i Indicates the Y-axis coordinate of the device in the current layout.
5. The method for optimizing equipment space layout based on genetic algorithm according to claim 1, It is characterized in that Based on the layout optimization model, a genetic algorithm is used to perform a global search in the layout space to obtain an optimal layout solution, including: Obtaining the layout scheme output by the layout optimization model in the layout space, and taking the coordinate values of each electromechanical device on the Y axis in a layout scheme as individuals, randomly initializing and generating an initial population with multiple different initial individuals; The fitness function is used to calculate the population fitness of each initial individual in the initial population, and high-quality individuals are selected from the initial individuals according to the preset fitness value during the calculation process; Perform crossover and mutation operations on high-quality individuals to generate a new population, and iterate the population fitness calculation on the new population until the number of iterations reaches the set value, and then output the optimal individual; The coordinate values of each electromechanical device in the optimal individual on the Y-axis are used as the optimal layout solution of the electromechanical device in the layout space.
6. The method for optimizing equipment space layout based on genetic algorithm according to claim 5, It is characterized in that The random initialization generates an initial population having a plurality of different initial individuals, including: Presetting a layout template that meets the space constraints of the equipment cabinet, wherein the layout template includes a high-quality template, a common template, and a low-quality template; Generate a random two-digit decimal number P between [0, 1] a , if P a If P is between [0, 0.2], the individual template is selected as a high-quality template. a If P is between [0.2, 0.8], the individual template uses the common template. a If the value is between [0.8, 1], the individual template uses a low-quality template; After determining the layout template selected by the current individual, generate a random number P in [0, 1] b , if P b < 0.5, then subtract a first random number from the individual's gene fragment. If P b If the value is ≥ 0.5, a first random number is added, and the random numbers of the gene fragments are changed cyclically until all the gene fragments of the current individual have completed the random change and the initial individual is obtained; the first random number is a random number uniformly distributed between 0 and 1; Multiple initial individuals with different gene fragments are combined to obtain an initial population.
7. The method for optimizing equipment space layout based on genetic algorithm according to claim 5, It is characterized in that The construction process of the fitness function includes: The first objective function and the second objective function are normalized to obtain corresponding first objective parameters and second objective parameters respectively; the first objective parameter is specifically expressed as: ; The second target parameter is specifically expressed as: ; in, y i ’ It is the Y-axis coordinate value of each device in the equipment cabinet in the inferior template; Calculate the average of the highest and lowest horizontal positions of the equipment in the current layout scheme to obtain the value D 1 ; At the same time, calculate the average of the highest and lowest horizontal positions of the equipment in the inferior template given above, and get the value D 2 , the value D 1 With the value D 2 By comparison, the third objective parameter of the fitness function is obtained, and the third objective parameter is expressed as: ; in, T ’ max Indicates the highest horizontal position of the equipment in the inferior template; T ’ min Indicates the lowest horizontal position of the equipment in the inferior template; Test all equipment in the layout plan and record the number of equipment in the layout plan that exceeds the layout space of the equipment cabinet and overlaps with other equipment. 4 , the number of devices F 4 The product of the preset penalty value is used as the penalty function; The first target parameter, the second target parameter, the third target parameter and the penalty function are weighted and summed to obtain the fitness function: ; in, ω 1 , ω 2 , ω 3 are the weights of the first target parameter, the second target parameter, and the third target parameter respectively.
8. The method for optimizing equipment space layout based on genetic algorithm according to claim 5, It is characterized in that The step of selecting high-quality individuals from the initial individuals according to the preset fitness values includes: Take the inverse of the fitness function value of each initial individual calculated in the initial population to get the inverse value GL i ; Calculate all reciprocal values GL i The accumulated value Sum is the inverse value GL of each initial individual i Compare with the accumulated value Sum to obtain the normalized probability value of the initial individual in the initial population; The normalized probability values of all initial individuals are converted into cumulative probabilities, a preset fitness value is randomly generated, and the initial individuals whose cumulative probabilities are greater than the preset fitness value are screened out as high-quality individuals.
9. The method for optimizing equipment space layout based on genetic algorithm according to claim 1, It is characterized in that The method generates an animation in the layout space according to the optimal layout solution, performs collision detection of the equipment installation process during the animation generation process, and adjusts the moving direction of the equipment in the animation according to the collision detection result to obtain the final equipment installation demonstration animation, including: Obtaining the current device coordinates and the target location coordinates of the electromechanical device from the optimal layout solution, and calculating the direction vector between the current device coordinates and the target location coordinates; Generate an animation for installing electromechanical equipment in the layout space according to the direction vector, and move the electromechanical equipment along the direction vector for one frame; During the movement of the electromechanical device, the coordinate position of the moving electromechanical device is taken as the center of the box-shaped area, and the size of the moving electromechanical device is taken as the diameter of the box-shaped area for collision detection. If there are other devices in the box-shaped area, the collision adjustment mode is entered to change the direction vector of the electromechanical device and move the electromechanical device according to the changed direction vector. If there are no other devices in the box-shaped area, the difference distance between the current device coordinates and the target position coordinates is calculated in each frame, and the moving speed of the electromechanical device in each frame is reduced by adjusting the difference distance; It is determined whether the phase difference is less than a preset threshold value. If so, the electromechanical equipment has been successfully installed at the target position. At this time, switch to the next electromechanical equipment for installation operation until all electromechanical equipment are successfully placed at the predetermined installation position, and obtain the equipment installation demonstration animation in the layout space.
10. A genetic algorithm-based equipment space layout optimization system, It is characterized in that include: The device abstraction module is used to obtain the actual proportion of the electromechanical device and abstract the shape of the electromechanical device according to the actual proportion to obtain the device abstraction structure; A model building module, used to model in the layout space according to preset constraints and the device abstract structure to obtain a layout optimization model; A layout optimization module, used to perform a global search in the layout space using a genetic algorithm based on the layout optimization model to obtain an optimal layout solution; The equipment installation demonstration module is used to generate an animation in the layout space according to the optimal layout solution, and perform collision detection of the equipment installation process during the animation generation process, and adjust the equipment movement direction in the animation according to the collision detection result to obtain the final equipment installation demonstration animation.
Citation Information
Cited By
Plant layout method and device, computer equipment, storage medium and program product
CN119622903A
Equipment layout optimization method and system in power transmission and transformation project design
CN120408915A
