Generative toilet layout design method based on genetic algorithm
Through the design method based on the genetic algorithm, the time-consuming and labor-intensive problem of the traditional design method is solved, and an efficient and intelligent bathroom layout design is realized. The generated layout satisfies a variety of constraints and improves the design efficiency and quality.
Patent Information
- Application Number
- CN202410715845.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-04
- Publication Date
- 2024-09-27
AI Technical Summary
The traditional bathroom layout design method is time-consuming and labor-intensive, and it is difficult to ensure the discovery of the optimal solution. It lacks efficient and intelligent design methods.
A generative bathroom layout design method based on genetic algorithms is adopted. By designing evaluation functions and genotype data structures, combined with collision detection and spatial detection, genetic algorithms are used to iteratively generate high-quality layout plans that meet various constraints.
It significantly improves design efficiency, reduces labor costs, and ensures the practicality and innovation of design results. The generated layout basically meets the requirements for space detection and collision detection between components.
Smart Images

Figure CN118709528A
Abstract
Description
Technical Field
[0001] The invention relates to an architectural design technology, and in particular to a generative toilet layout design method based on a genetic algorithm. Background Art
[0002] With the acceleration of urbanization and the improvement of quality of life, the effective use of building space and humanized design have become increasingly important. As an essential functional area in a building, the layout design of the bathroom is not only related to the comfort and safety of the users, but also directly affects the space utilization efficiency of the entire building. Traditional design methods rely on the designer's intuition and trial and error, which is not only time-consuming and labor-intensive, but also difficult to guarantee the discovery of the optimal solution. Therefore, exploring efficient and intelligent bathroom layout design methods has become an urgent need in the industry. Summary of the invention
[0003] To solve the above problems, a generative bathroom layout design method based on genetic algorithm is proposed. Through the genetic algorithm in machine learning, the bathroom layout that meets the architectural design standards is quickly generated.
[0004] The technical solution of the present invention is: a generative toilet layout design method based on genetic algorithm, which specifically includes the following steps:
[0005] 1) Design an evaluation function suitable for genetic algorithm layout design, and design a method for collision detection and space detection of components required for the execution of the evaluation function;
[0006] 2) Design a genotype Gene data structure suitable for genetic algorithm layout design: the Gene data structure meets the requirement of accurate evaluation of layout results based on multiple standard fitness in the evaluation function execution process of the genetic algorithm, and selects parameters in the Gene data structure that can enumerate all commonly used layout forms that meet the design requirements in the bathroom design process as random parameters;
[0007] 3) Each boundary of the bathroom to be designed is described as a Gene in the form of a data structure. All the Genes in the bathroom clearly describe the layout of the entire bathroom. All the Genes in the entire bathroom constitute a seed in the genetic algorithm;
[0008] The initial population is generated by randomly combining and changing the random parameters of each Gene to form different seeds, thereby forming the initial population;
[0009] The subsequent iteration of the population is based on the evaluation function of the legacy algorithm, which naturally selects a set proportion of high-evaluation seeds, generates a new population through crossover and mutation steps, iterates the population, and continuously evolves better solutions. When the number of iterations reaches the set value, a layout plan is obtained, which is sorted from high to low in score.
[0010] Furthermore, the final value of the evaluation function FitnessVal is calculated by four parameters (e1, e2, e3, e4).
[0011] e1 is the evaluation of the number of sanitary ware in the layout;
[0012] e2 is the evaluation of sanitary ware space detection and collision detection results within the layout;
[0013] e3 is the evaluation of the number of sanitary ware groups within the layout;
[0014] e4 is the evaluation of the difference between the ratio or quantity of sanitary ware within the layout and the target value.
[0015] Furthermore, among the four parameters of the evaluation function, e1 is of double type with a value range of (0,1), which indicates the filling rate of sanitary ware in the current layout; e2 is of double type, which indicates the ratio of the number of sanitary ware that collide in the current layout to the number of all sanitary ware in the current layout; e3 evaluates the change in the grouping of sanitary ware; e4 counts the actual number of each type of sanitary ware in the layout, and then compares it with the target ratio or target number input by the designer, and forms a corresponding evaluation score according to the comparison result.
[0016] Furthermore, the final value FitnessVal of the evaluation function is calculated in a corresponding manner according to the layout requirements of the toilet to be designed.
[0017] Further, the collision detection and space detection methods, wherein the collision detection is hard collision detection and the space detection is soft collision detection, refer to the detection of door opening areas, aisles, and spaces for human activity;
[0018] There are four specific testing situations:
[0019] e) Detection of the hard collision boundary of the sanitary ware being detected and the hard collision boundary of other sanitary ware in the layout;
[0020] f) Detection of the soft collision boundary of the sanitary ware being detected and the hard collision boundary of other sanitary ware in the layout;
[0021] g) Detection of collision between the soft collision boundary of the sanitary ware being tested and the bathroom boundary;
[0022] h) Detection of collision between the hard collision boundary of the sanitary ware being tested and the boundary of the bathroom.
[0023] Furthermore, the genotype Gene data structure is set as a data structure containing 12 parameter fields, and the data structure is parsed as follows:
[0024]
[0025]
[0026] Furthermore, the four parameters of WareTyp, Alignment, ChopFirst and ChopLast in the genotype Gene data structure are random parameters, which are used for random combination and change to form different seeds.
[0027] The beneficial effects of the present invention are as follows: the generative bathroom layout design method based on genetic algorithm of the present invention breaks through the limitation that the bathroom layout needs to be arranged and verified one by one in the previous design process, performs wall boundary analysis on the bathroom that needs to generate the layout, and directly realizes and generates the bathroom layout through the design algorithm. The generated layout basically meets the space detection requirements, collision detection requirements, sorting ratio requirements and parameter requirements set by the designer between components. The detection results and layout quality can be directly viewed, which greatly improves the design efficiency of the bathroom layout. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 It is a schematic diagram of the layout and Gene concept of the present invention;
[0029] Figure 2 It is a diagram of the algorithm for evaluating the number of sanitary ware in the layout of the present invention;
[0030] Figure 3 It is a diagram of the sanitary ware space detection and collision detection result evaluation algorithm in the layout of the present invention;
[0031] Figure 4 An evaluation algorithm diagram of the number of sanitary ware groups in the layout of the present invention;
[0032] Figure 5 An evaluation algorithm diagram of the difference between the ratio or quantity of sanitary ware in the layout of the present invention and the target value;
[0033] Figure 6 A collision detection boundary definition diagram of the present invention;
[0034] Figure 7 This is a graph showing the results of the algorithm operation of the space detection and collision detection of the present invention;
[0035] Figure 8 This is a schematic diagram of parameter setting during initialization of the genetic algorithm of the present invention. DETAILED DESCRIPTION
[0036] The present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. This embodiment is implemented based on the technical solution of the present invention, and provides a detailed implementation method and specific operation process, but the protection scope of the present invention is not limited to the following embodiments.
[0037] Genetic algorithms encode design solutions into a series of "genes", which are representations of solutions. These genes form a population. The algorithm simulates the process of natural selection and iterates the population, including selection, crossover (simulating genetic processes), mutation and other steps to continuously evolve better solutions. Among them, the evaluation function is the core component, which is used to evaluate the fitness of each solution, that is, the quality of the layout plan, which is directly related to the direction and speed of the algorithm search. For bathroom layout, the evaluation function may comprehensively consider factors such as space utilization efficiency, convenience of passage, and visual aesthetics. By applying genetic algorithms, bathroom layout design can automatically explore a huge solution space and quickly converge to a high-quality layout plan that meets multiple constraints, thereby significantly improving design efficiency and reducing labor costs, while ensuring the practicality and innovation of design results.
[0038] The present invention provides a generative toilet layout design method based on a genetic algorithm, the method comprising: designing a genotype (Gene) data structure required for layout design using a genetic algorithm, designing an evaluation function required for layout design using a genetic algorithm, and designing a method for performing collision detection and space detection on components required for executing the evaluation function.
[0039] 1. Design the genotype data structure required for layout design using genetic algorithms:
[0040] Combining the characteristics of bathroom layout in architectural design and the need to solve the full permutation problem of genotypes in genetic algorithms, such as Figure 1 The layout and Gene concept diagram shown in the figure describes each bathroom boundary as a Gene in the form of a data structure. All the Genes in the bathroom can clearly describe the layout of the entire bathroom. All the Genes in the entire bathroom constitute a seed in the genetic algorithm. The initial population is generated by randomly combining and changing the four parameters of each Gene (WareType, Alignment, ChopFirst, ChopLast) to form different seeds, thereby forming the initial population. The subsequent iteration of the population is based on the evaluation function of the legacy algorithm, and a certain proportion of highly evaluated seeds are naturally selected (Selection), and a new population is generated through steps such as crossover (Crossover, simulating the genetic process) and mutation (Mutation).
[0041] The data structure of the dedicated gene (Gene) in the algorithm is set to a data structure containing 12 parameter fields. The data structure is parsed as follows: This data structure uses the 4 parameter changes in Gene to enumerate all the commonly used layout forms that meet the design requirements in the bathroom design process (choice of ending type, choice of alignment method, and form of avoidance at corners). The 12 parameter designs of this data structure meet the requirements of the evaluation function execution process in the genetic algorithm to accurately evaluate the fitness of the layout results based on multiple standards (quantity, filling rate evaluation, collision evaluation, group number evaluation, and target value, ratio evaluation) (see the 4 evaluation rules in the evaluation function below for details). After testing, it can efficiently and automatically explore the huge solution space and quickly converge to a high-quality layout solution that meets multiple constraints.
[0042] Data type name: Gene
[0043]
[0044] 2. Evaluation functions required for layout design using genetic algorithms
[0045] The final value of the evaluation function (FitnessVal) is calculated by four parameters (e1, e2, e3, e4), and the calculation formula is:
[0046] FitnessVal=0.8*e1*(1-e2)*e3*e4
[0047] Among them, 0.8 is the coefficient or initial value, and e1, e2, e3, and e4 are calculated by the following four rules:
[0048] 1. Evaluation of the number of sanitary ware in the layout:
[0049] The calculation formula for this rule is:
[0050] e1 = c_used / c_total
[0051] Among them, e1: is of double type, with a value range of (0,1); it represents the filling rate of the sanitary ware in the current layout. c_used: is of double type, representing the sum of the lengths of the bathroom boundary lines occupied by the sanitary ware actually arranged in the current layout. The length of the Gene.Curve corresponding to each sanitary ware in the layout is calculated and summed. c_total: is of double type, representing the total length of the bathroom boundary lines in the current layout.
[0052] like Figure 2 The evaluation algorithm diagram of the number of sanitary ware in the layout shown is used to calculate the sanitary ware in all Genes in the bathroom to obtain the filling rate e1 of the sanitary ware in the current layout.
[0053] 2. Evaluation of sanitary ware space detection and collision detection results within the layout:
[0054] The calculation formula for this rule is:
[0055] e2=CollisionCount / WareCount
[0056] Among them, e2: is of double type, indicating the ratio of the number of sanitary wares that collide in the current layout to the number of all sanitary wares in the current layout. CollisionCount: is of int type, indicating the number of sanitary wares that collide in the current layout, and the collision detection method is provided in the following 3. WareCount: is of int type, indicating the number of all sanitary wares in the current layout.
[0057] like Figure 3 The sanitary ware space detection and collision detection result evaluation algorithm diagram in the layout shown is used to calculate the sanitary ware in all Genes in the bathroom to obtain the sanitary ware space inspection and collision inspection result e2 in the current layout.
[0058] 3. Evaluation of the number of sanitary ware groups within the layout:
[0059] This rule will evaluate the changes in the grouping of sanitary ware. In the design of bathroom layout, considering the rationality and aesthetics of the layout, the changes in the group (i.e. the changes in Gene.WareType) should be as few as possible. Before calculating e3, it is necessary to count the number of group changes in the current layout (GroupChange)
[0060] When GroupChange is less than half of the number of bathroom boundaries, e3 is 1.001
[0061] When GroupChange is greater than or equal to half of the number of bathroom boundaries, e3 is 0.999.
[0062] like Figure 4 The evaluation algorithm diagram of the number of sanitary ware groups in the layout shown is used to calculate the number of sanitary ware groups in all Genes in the bathroom to obtain the evaluation result e3 of the number of sanitary ware groups in the current layout.
[0063] 4. Evaluation of the difference between the proportion or quantity of sanitary ware in the layout and the target value:
[0064] This rule counts the actual number of each type of sanitary ware in the layout (an1, an2, an3), and then compares it with the target ratio (t1, t2, t3) or target number (n1, n2, n3) input by the designer, and forms a corresponding evaluation score e4 based on the comparison result (see target parameters for details). Figure 8)。
[0065] When calculating using t1, t2, t3:
[0066] The evaluation of the ratio will be calculated in three cases, namely when t1 is not 0, t2 is not 0, and t3 is not 0 (when t1, t2, and t3 are all 0, the evaluation function of this article directly returns the result as 1 and the following calculations will not be executed). The calculation methods for the three cases are similar. The following takes the case where t1 is not 0 to illustrate the calculation method:
[0067] 1) Let d2_1 and d3_1 be the degree of compliance of the ratio between the outcomes. The initial conditions are d2_1 = 1 and d3_1 = 1. When the actual ratio does not match the ratio (t) input by the user, these two values will be less than 1.
[0068] 2) TargetRatio2_1 = t2 / t1, ActualRatio2_1 = an2 / an1.
[0069] 3) d2_1 takes the minimum value between ActualRatio2_1 / TargetRatio2_1 and
[0070] TargetRatio2_1 / ActualRatio2_1.
[0071] 4) When both t2 and an2 are 0, d2_1 = 1. When t2 is 0 and an2 is not 0, d2_1 = 1 / an2. 5) Repeat steps 1)-4) to calculate d3_1 in the same way, that is, calculate the degree of compliance of the ratio between the third sanitary ware and the first sanitary ware.
[0072] 6) Return the final result e4 = d2_1 * d3_1 of the evaluation of the sanitary ware ratio.
[0073] When calculating using n1, n2, n3:
[0074] The three calculation parameters are r1 = 1, r2 = 1, r3 = 1.
[0075] Due to the characteristic of the bathroom layout design being to arrange as many as possible, when the number of sanitary wares in the generated layout is greater than the user input, there will be no reduction in evaluation.
[0076] 1) If an1 < n1, then r1 = an1 / n1
[0077] 2) If an2 < n2, then r2 = an2 / n2
[0078] 3) If an3 < n3, then r3 = an3 / n3
[0079] 4) Return e4 = r1 * r2 * r3.
[0080] like Figure 5 The evaluation algorithm diagram of the difference between the ratio or quantity of sanitary ware in the layout and the target value is shown, and the difference between the ratio or quantity of sanitary ware in the layout and the target value in the current bathroom layout is calculated to obtain the evaluation result e4.
[0081] 3. Methods for collision detection and space detection of components required for evaluation function execution
[0082] Using the detection methods of space detection (soft collision, referring to the door opening area, aisle, personnel activity space, etc.) and collision detection (hard collision), the occupancy of each sanitary ware in the layout is divided into two situations: soft collision and hard collision. In addition, various types of collision detection and scoring are performed in 2 of the above evaluation function. The specific detection situations are divided into the following four categories:
[0083] i) Detection of the hard collision boundary of the detected sanitary ware and the hard collision boundary of other sanitary ware in the layout;
[0084] j) Detection of the soft collision boundary of the sanitary ware being detected and the hard collision boundary of other sanitary ware in the layout;
[0085] k) Detection of collision between the soft collision boundary of the sanitary ware being tested and the bathroom boundary;
[0086] l) Detection of collision between the hard collision boundary of the sanitary ware being tested and the boundary of the bathroom.
[0087] like Figure 6 The collision detection boundary definition is shown:
[0088] Ware hard collision boundaries: Figure 6 Show the midline segments ab, be, ef
[0089] Ware soft collision boundaries: Figure 6 Show the midline segments bc, cd, de, bd, ec
[0090] Bathroom boundary: the extension line of the location of af (to the end of the corresponding wall)
[0091] Determination of line segment length:
[0092] The lengths of cd, be, and af are the widths set in the panel (see Figure 8 ).
[0093] The lengths of bc and de are the lengths corresponding to the minimum space required in the Unified Design Standard for Civil Buildings GB50352-2019, the General Code for Civil Buildings GB55031-2022, and the Design Standard for Urban Public Toilets CJJ14-2016.
[0094] The lengths of ab and ef are the lengths set in the panel (see Figure 8 ).
[0095] ce, bd are connected according to the above rules.
[0096] Criteria for determining collision: When the sanitary ware performs the collision detection in items a), b), c), and d) above, if any line segment in its boundary intersects with a line segment of the boundary of the object of the collision detection, it is determined that a collision occurs.
[0097] The collision detection boundaries of each type of sanitary ware will vary according to the specifications and settings in the parameter panel. Figure 7 The figure shows a schematic diagram of all boundary lines required for collision detection and space detection evaluation of a layout (the be segment is displayed and hidden to avoid confusion on the drawing).
[0098] like Figure 8 This is a schematic diagram of parameter setting during initialization of the genetic algorithm of the present invention.
[0099] In the section called Calculate Size (upper left), Figure 8 Examples 1, 2, and 3 represent different types of sanitary ware required in the bathroom layout; the length and width parameters will affect the definition of the boundary line in the collision detection method in the above evaluation function. At the same time, when the population is initialized, the parameters GridDepth and GridWidth in the data structure Gene are assigned values.
[0100] In the target value setting section, by selecting a specific ratio or minimum number, the corresponding calculation method selected by the evaluation function of the genetic algorithm when scoring the layout is controlled. Note that when the maximum number is selected, since e1 has already played a role in the quantity evaluation, the calculation of e4 will be skipped.
[0101] The initial number in the calculation parameters represents the size of the population. For example, when the initial number is 100, the number of seeds in the first and subsequent populations will be controlled at 100. The number of iterations determines the number of iterations of the population. When the number of iterations reaches the set value, the genetic algorithm will stop running and the seeds (layouts) in the current population will be displayed in the right panel in descending order according to the score.
[0102] In the lower left corner of the window are buttons for selecting the bathroom object and starting the algorithm. There is also a viewing window for the evaluation function results during the execution of the genetic algorithm, which displays the scores of the eight highest-scoring seeds in the current population.
[0103] The picture in the right panel intuitively shows the layout style and the corresponding sanitary ware quantity data corresponding to the seeds selected from the current population after the algorithm is completed.
[0104] The above-mentioned embodiments only express several implementation methods of the present invention, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.
Claims
1. A generative toilet layout design method based on genetic algorithm, characterized in that: The specific steps include: 1) Design an evaluation function suitable for genetic algorithm layout design, and design a method for collision detection and space detection of components required for the execution of the evaluation function; 2) Design a genotype Gene data structure suitable for genetic algorithm layout design: the Gene data structure meets the requirement of accurate evaluation of layout results based on multiple standard fitness in the evaluation function execution process of the genetic algorithm, and selects parameters in the Gene data structure that can enumerate all commonly used layout forms that meet the design requirements in the bathroom design process as random parameters; 3) Each boundary of the bathroom to be designed is described as a Gene in the form of a data structure. All the Genes in the bathroom clearly describe the layout of the entire bathroom. All the Genes in the entire bathroom constitute a seed in the genetic algorithm; The initial population is generated by randomly combining and changing the random parameters of each Gene to form different seeds, thereby forming the initial population; The subsequent iteration of the population is based on the evaluation function of the legacy algorithm, which naturally selects a set proportion of high-evaluation seeds, generates a new population through crossover and mutation steps, iterates the population, and continuously evolves better solutions. When the number of iterations reaches the set value, a layout plan is obtained, which is sorted from high to low in score.
2. The generative toilet layout design method based on genetic algorithm according to claim 1 is characterized in that: The final value of the evaluation function, FitnessVal, is calculated from four parameters (e1, e2, e3, e4), where e1 is the evaluation of the number of sanitary ware in the layout; e2 is the evaluation of sanitary ware space detection and collision detection results within the layout; e3 is the evaluation of the number of sanitary ware groups within the layout; e4 is the evaluation of the difference between the ratio or quantity of sanitary ware within the layout and the target value.
3. The generative toilet layout design method based on genetic algorithm according to claim 2 is characterized in that: Among the four parameters of the evaluation function, e1 is of double type, with a value range of (0,1), indicating the filling rate of the sanitary ware in the current layout; e2 is of double type, indicating the ratio of the number of sanitary ware that collide in the current layout to the number of all sanitary ware in the current layout; e3 evaluates the change in the grouping of sanitary ware; e4 counts the actual number of each type of sanitary ware in the layout, and then compares it with the target ratio or target quantity input by the designer, and forms a corresponding evaluation score based on the comparison result.
4. The generative toilet layout design method based on genetic algorithm according to claim 3 is characterized in that: The final value FitnessVal of the evaluation function is calculated in a corresponding manner according to the layout requirements of the toilet to be designed.
5. The generative toilet layout design method based on genetic algorithm according to claim 1 is characterized in that: The collision detection and space detection methods, wherein the collision detection is hard collision detection and the space detection is soft collision detection, refer to the detection of door opening areas, aisles, and personnel activity spaces; There are four specific testing situations: a) Detection of the hard collision boundary of the detected sanitary ware and the hard collision boundary of other sanitary ware in the layout; b) Detection of the soft collision boundary of the sanitary ware being detected and the hard collision boundary of other sanitary ware in the layout; c) Detection of collision between the soft collision boundary of the sanitary ware being tested and the boundary of the toilet; d) Detection of collision between the hard collision boundary of the sanitary ware being tested and the boundary of the bathroom.
6. The generative toilet layout design method based on genetic algorithm according to claim 1 is characterized in that: The genotype Gene data structure is set as a data structure containing 12 parameter fields, and the data structure is parsed as follows:
7. The generative toilet layout design method based on genetic algorithm according to claim 6 is characterized in that: The four parameters of WareTyp, Alignment, ChopFirst and ChopLast in the genotype Gene data structure are random parameters, which are used for random combination and change to form different seeds.
