M-StruGAN: An Automatic 2D-Plan Generation System under Mixed Structural Constraints for Homestays

: Existing methods for generating 2D plans based on intelligent systems usually require human-deﬁned rules, and their operations are complex. GANs can solve these problems through independent research and learning. However, they only have generative design research based on a single constraint condition, and whether they can generate a qualiﬁed design scheme under many constraints is still unclear. Therefore, this paper develops the M-StruGAN generative model based on the structural design framework of a GAN. Its application research is extended to the 2D-plan layout generation of homestay based on the constraints of hybrid structures, and the feasibility of the method is comprehensively veriﬁed through three aspects: image synthesis quality assessment, scheme rationality assessment, and scheme design quality assessment. Experimental results show that the quality of the drawings generated by M-StruGAN is qualiﬁed, designers have a high degree of acceptance of the design results of M-StruGAN, and M-StruGAN completed the learning of the critical points of the 2D layout. Finally, through the human–computer interaction application of M-StruGAN, it can be found that compared with traditional design methods, M-StruGAN based on pix2pixHD has high-deﬁnition image quality, higher design eﬃciency, lower design cost, and more stable design quality.


Introduction
Since the 20th century, with the acceleration of urbanization, the transformation and utilization of old buildings has a racted more and more a ention from all walks of life [1]. Reusing existing buildings not only realizes the sustainable development of buildings but also effectively reduces the carbon emissions of buildings [2]. During the renovation of a building, the 2D-plan layout is part of the core content of the scheme design of the building [3]. A reasonable functional layout that satisfies the space size, quantity, connection, and other relationships of the house to the greatest extent can bring comfort to people's daily lives [4]. The emergence of mass tourism has brought opportunities for the development of homestays. At the same time, it has also put forward high requirements for the design of the 2D-plan layout of homestays [5]. The 2D-plan layout of a homestay is a long and tedious task in the traditional design process, especially when it comes to complex structural constraints, which require designers to repeatedly try and modify the design process, which consumes a lot of time and energy [6,7]. The design of a 2D-plan layout mainly faces the following problems: (1) The scheme design takes a long time and needs to be revised repeatedly. (2) The cost required in the design process is relatively high. (3) The design of a 2D-plane layout requires designers to master specific professional knowledge, which requires high requirements for designers [8] (Figure 1). To sum up, the current development of homestays urgently needs to break through the problems by optimizing or even automating the design process.
The automatic generation of 2D plans is a crucial approach to addressing these limitations. Using computer-program-aided architectural scheme designs can intelligently generate floor plans for designers' references, which can bring more convenience to designers [9][10][11].
For the 2D-plan layout problem, many methods of computer-aided design consider the division of space and the requirements of architectural functions, describing them by artificially defining rules and using specific algorithms. In recent years, the generation methods have generally had four directions [12][13][14]: (1) one based on rule-based systems [15]; (2) one based on multiagent systems [16]; (3) one based on evolutionary algorithms [17]; and (4) one based on mathematical programming algorithms [18]. The one based on rule-based systems is a system for querying and rewriting computer restriction rules. Based on the rule system, Veloso et al. split the given room outline in combination with the preset shape grammar rules and, based on the industry foundation classes (IFC) standard, established the room's building information modeling (BIM) to reduce the time and labor costs of automatic production drawings [19]. However, this process has professional operation requirements, making it difficult for nonprofessionals to operate. For the direction based on multiagent systems, Paul Merrell et al. applied a Bayesian network in multiagent systems to learn the plan function relation diagram and realized the automatic generation of the plan layout relation diagram of the house by counting the conditional probability of each factor relation [20]. However, this research has yet to generate a feasible plan map from the functional relationship diagram. Regarding the direction based on evolutionary algorithms, Laignel et al. proposed a new method for automatically generating apartment layouts based on evolutionary algorithms [21]. Given an apartment's boundaries and a list of rooms, an evolutionary algorithm generates multiple floor plans with architectural and functional constraints. However, the optimizer's code se ing and result generation require real-time control by professionals. For the direction based on mathematical programming algorithms, Inoue et al. explored the layout planning of floor plans using mathematical programming algorithms [22]. However, the results of their generation cannot play a guiding role. These design directions all use wri en functions to modify the initial conditions and obtain the engineering results through calculation. In the design process, the above four directions need to adjust the parameters to control the output manually, and the operation has a certain complexity and is not universal. Furthermore, the current research shows that the accuracy of its design ability needs to be improved.
Compared with the traditional parametric design, deep learning has a more powerful learning ability [23]. It learns through automatic research in the design process and finds the laws in it, then gives reasonable results [24]. This greatly reduces the user's operational difficulty and design cost. Therefore, the algorithm framework of deep learning is expected to serve as the basic architecture of our system and contribute to the intelligent generation of 2D plans based on mixed structural constraints.

Literature Review
Deep learning is a machine learning method with great potential in generative design [25]. Deep learning can simulate the human brain's neural structure, fully extract valuable feature information in the input data, and then train, adjust, and optimize its model and obtain a reasonable model structure fi ing the input data distribution [26,27]. Generative adversarial networks (GANs), a deep learning model that uses neural networks to generate images, were first proposed in 2014 by Goodfellow et al. [28]. In recent years, GANs have also become the most promising deep learning model in unsupervised learning. It has also been applied in the fields of architecture and urban design [29]. However, the original GAN has some shortcomings in the training process: (1) There is no user control ability. That is, the generation process is random. (2) There is low resolution and low quality in the generated results ( Figure 2). The images generated by GANs are random, and it is impossible to control the category of the generated images. Deng et al. proposed an improved version based on the original GAN, the conditional generative adversarial network (cGAN) [30]. A conditional generative model is implemented by adding an additional condition to the generator (G) and discriminator (D) of the original GAN. Additional conditions can be category labels or other auxiliary information. Therefore, the proposal of cGAN enables GAN to use images and corresponding labels for training and use given labels to generate specific images in the test phase. For example, Liu Yuezhong divided data into familiar and unfamiliar data according to whether the data belong to the dataset [31]. They proposed using the conditional generative adversarial network (cGAN) to learn familiar data to process unfamiliar data to support the urban design process. The results show that the method can effectively support the decision-making process of urban graphic scheme designs. Huang W et al. used the cGAN model to effectively control the results to generate satellite images, hand-drawn architectural sketches, and architectural plan function zoning maps based on the boundary and functional training [32]. Shen et al. extracted urban information and simplified it into a floor plan and used cGAN to generate architectural layouts based on site conditions to achieve a rapid urban design method [33]. Cho Dahngyu et al. use cGAN to classify and recognize basic objects of floor plans. In summary, cGAN solves the problem that the original GAN model has no user control ability [34].
Based on cGAN, somebody proposed the pix2pix algorithm, which uses paired data for training to learn the mapping from the input image to the output image. For example, Philip Isola studied the usability of cGAN as a general solution to the image-to-image translation problem and found that using pix2pix can complete the general image translation task be er than cGAN [35]. When pix2pix realizes image-to-image translation, its application in architecture and urban design is also extensively promoted. In line with the research purpose of allowing ordinary people to participate in architectural design, Peters N used pix2pix to train a model that can automatically generate a simple layout of a building plan [36]. However, its design accuracy still needs to be high for designers to refer. Liu Yubo et al. constructed two small-sample campus layout datasets from the perspective of architects in their exploration of using deep learning to generate campus layouts [37]. Furthermore, these datasets train the pix2pix model to generate campus entrances automatically, given the campus boundary and surrounding road conditions. In summary, although pix2pix achieves image-to-image correspondence, it is difficult to generate high-quality images.
pix2pix proposes a unified framework to solve various image translation problems, while pix2pixHD be er solves the problem of high-resolution image translation based on pix2pix [38]. For example, Wang et al. built a more refined network pix2pixHD based on pix2pix, which increased the image resolution from the original 256 × 256 to 2048 × 1024 pixels and applied it to the automatic generation of simple plans in apartments [39]. The results show high-quality architectural interior design drawing generation, but it is also more time-consuming. To sum up, compared with pix2pix, pix2pixHD improves the accuracy of the entire model and dramatically improves the accuracy of the data. Therefore, M-StruGAN (the automatic 2D-plan generation system under mixed structural constraints for homestays) equipped with pix2pixHD can be er realize the control output and improve the output image quality and stability requirements in the existing architectural plan layout. Current researchers mainly focus on the pixel refinement of simple plans. There is no research on the feasibility of intelligent generation of 2D plans under the constraints of hybrid structures [40][41][42][43][44] (Figure 3). To sum up, in order to realize the intelligent generation of 2D layout drawings under the constraints of mixed structural constraints, this paper proposes an intelligent generation system, M-StruGAN (Mixed-Structure GAN), equipped with the pix2pixHD framework.

M-StruGAN Method
This study takes homestays as the starting point and establishes an intelligent generation method of a 2D-plan layout based on pix2pixHD under mixed structural constraints. The developed method consists of three parts: (1) implementation of M-StruGAN, including data processing methods and model training; (2) analysis of M-StruGAN generation results, including image synthesis quality assessment, scheme rationality assessment, and scheme design quality assessment; and (3) M-StruGAN application ( Figure 4).

Implementation of M-StruGAN
M-StruGAN a empts to generate a set of 2D floor plans that satisfy architectural and functional constraints and input specifications from edge maps of homestays under mixed structural constraints ( Figure 5). Additionally, it can quickly generate a 2D-plan layout that meets the functional specifications of the homestay by adjusting the input conditions.

Mixed Structural Element Extraction
During the 2D-plan design process of the homestay, to avoid large demolition and construction, the internal structure and external contour of the original living space are usually reinforced and retained. These reserved elements are the constraints in our program process, including columns, shear walls, traffic cores, courtyard space edges, building layout edges, doors, and windows ( Figure 6) [45][46][47].

Dataset Production
GANs do not have the ability to make distribution assumptions on real data. They optimize and adjust the model by continuously learning the high-dimensional features of real data and finally complete the task of sample generation through the learned model. This also makes the probability distribution and quality of the M-StruGAN design directly related to the dataset's quality. Therefore, to ensure the quality of the 2D-plan generation of an M-StruGAN's homestay, this study collected nearly 1600 sets of homestay floor plans. In addition, these drawings meet all relevant design specifications and are screened, optimized, and assessed for design quality by qualified designers. After the quality screening, 1000 floor plans that met the relevant specifications of the 2D-plan design of homestays were used to explore the layout method of M-StruGAN. This enables GAN models to improve design proficiency by learning from existing high-quality design documents, thereby significantly improving design efficiency and performance. Then, the data graphs are classified and semanticized based on the original design dataset.
Based on the filtered original flat datasets, we classify them and mark them as the corresponding A-, B-, and C-side datasets. Subsequently, the A-, B-, and C-side datasets are semantically processed to extract the primary inputs and design elements in the design images and encode them with color pa erns, thereby maintaining key design elements and corresponding 2D floorplan information. Semantic design can effectively reduce the dimension of probability distribution and improve training performance.
The A-side data processing is to extract the mixed structural elements in the dataset and mark them so the program can recognize them as input conditions. The processing of the B-side data is to keep the marks of the mixed structural elements of the A-side and then divide the floor plan into different functional areas according to functions and other color codes for each functional area. The processing of the C-side data is mainly to extract the spatial layout of the dataset and draw it with CAD. In detail, the A, B, and C terminal data correspond to three images of a homestay plan. Among them, A is the mixed structural constraints of the homestay plan, B is the functional area division of the homestay floor plan, and C is the layout of the homestay plan (Figure 7). Finally, the size of the processed A-, B-, and C-side data reshapes to 512 × 512. Since all the data scales are uniform, the datasets of these three parts also contain information on size and distance, which can be er help M-StruGAN learn the rules of the 2D-plan design of homestays. In the dataset of 1000 sets, 950 sets are used for training, and 50 sets are used for testing.

M-StruGAN Training and Results
As far as the system of M-StruGAN is concerned, in addition to the regular training recommended by pix2pixHD, this study also tunes its architecture by simplifying the generator architecture to generate more restricted and precise image elements.
The training of M-StruGAN was divided into two parts (Figures 8 and 9 show some typical results).   Figures 9 and 10, we can see that the test results of Model 1 are not good, and the generated B-side data are far from the real B-side data, while the test results of Model 2 reach the ideal state. The partition data trained by model 1 contain many element details and complex content, and a small amount of data training is insufficient to achieve accurate functional partition capabilities. This study improves the performance of Model 1 by carrying out the following: (1) expanding the dataset, the dataset is expanded by vertical, horizontal, and left-right mirroring methods, so that the data used for model 1 training are raised from 250 to 1000; (2) adjusting the algorithm architecture of pix2pixHD, the generator architecture of Model 1 can be simplified to generate more local and precise B-side data. The number of residual blocks in the global downsampling layer (n_downsample_global) and the global generator network (n_blocks_global) is reduced from 4 to 2 (or 1) and from 9 to 6, respectively.
Based on the above adjustments, Model 1 was retrained, in which 1000 sets of pictures were used as the dataset, 950 sets were used as the training set, and 50 sets were used as the test set. This experiment also performed 25,000 iterations and took 62 h. The final result is shown in Figure 10. From the comparison chart, it can be seen that the adjusted and trained Model 1 generates ideal results.
Finally, The loss curves of the two qualified performance models are shown is shown in Figure 11. After training, the generator_loss of the two models is 0. 38

Result Evaluation
The experimental results are shown in the figure below ( Figure 12). Although M-StruGAN uses the input data of the training dataset, the generated results are entirely different from the data results of the training dataset. As a result, M-StruGAN was able to generate data autonomously that is entirely different from the original data based on the learned 2D-plan layout rules. So far, M-StruGAN realized the generation of 2D-plan layout diagrams based on mixed-structure conditions. However, the effectiveness of the results generated by M-StruGAN, whether they can provide designers with specific design guidance, and the extent to which they guide designers to design is unknown. Therefore, to objectively evaluate the generation quality of M-StruGAN, this paper evaluates its (1) image synthesis quality, (2) scheme design rationality, and (3) scheme design quality.

Image Synthesis Quality Assessment
The generation model based on M-StruGAN can generate realistic images from new input data, but the generated images cannot distinguish minor quality differences through subjective judgment. Therefore, in order to objectively evaluate the image quality generated by M-StruGAN, this paper uses computer-vision-based synthetic image evaluation techniques, namely peak signal-to-noise ratio (PSNR) and structural similarity index (SSIM), to evaluate the similarity between the M-StruGAN output and the target image [48].
PSNR is one of the most widely used methods in evaluating synthetic images based on computer vision. It is based on error-sensitive image quality evaluation. The smaller the PSNR value, the be er the image quality [49,50]. PSNR can be calculated by the following formula: (1) (2) where MAX I 2 is the maximum possible pixel value of the image; MSE is root mean squared error (mean squared error); M and N are the length and width of the image; R and F are the output result and the reference target image, R(i,j) and F(i,j) are the gray values of the pixel at coordinates (i,j) in the image; and MAX (value range 0-255) represents the largest gray value in the image. SSIM is also an evaluation index to measure image quality. SSIM focuses more on evaluating the consistency of images in terms of brightness, color, etc., while taking into account high-frequency information such as image edges and details. The value of SSIM is calculated by the following formula: where µ x and µ y are the average gray values of R and F, σ x 2 and σ y 2 are the variance of the gray value of R and F, σ xy is the gray value covariance of R and F, and C1 and C2 are two constants close to 0. The maximum value of SSIM is 1, and the smaller the value of SSIM, the worse the similarity quality of the generated images. This study calculated and arithmetically averaged the PSNR and SSIM of 50 different 2D-plan functional partition pictures and 2D-plan layout pictures generated by M-StruGAN. The summary results are shown in Table 1. Comparing PSNR with SSIM shows that the SSIMs of the images generated by Model 1 and Model 2 are both greater than 0.8, and the average PSNR is around 30. Since the images generated by Model 1 (A to B) contain more coding information and the accuracy is difficult to grasp, the PSNR and SSIM values of this group of algorithms are smaller than those of the Model 2 (B to C) algorithm group. The evaluation results show that although the quality of the images generated by M-StruGAN does not reach the quality of the target images, it still has a certain authenticity and practicability.

Plan Rationality Assessment
More complex than image quality assessment is the quality assessment of generative designs, which requires reasonable consideration of the rationality of 2D-plan functional designs. Through a literature review, the authors found that Amazon Mechanical Turk (AMT) perception evaluation is a commonly used method for judging the rationality of generated results, that is, judgment by professionals from a professional perspective [51]. Therefore, this study develops a designer perceptual-based evaluation method to evaluate the rationality of the 2D-plan layouts generated by M-StruGAN based on the extensive use of ATM-aware evaluation. Designer perception evaluation is the most direct evaluation method for the quality of automatic plane generation. A total of 25 experienced architectural designers were invited for this evaluation experiment. Ten of them are senior experts (with more than 15 years of work experience) and 15 are in-service designers or graduate students. During the interview, they were asked to evaluate the following two parts of the 2D-plan based on their experience and perception: 1. Judging whether the 2D-plan is generated by artificial intelligence or drawn by a designer. 2. Evaluate and score the rationality of the 2D-plan design drawings.
Additionally, according to the collected and statistical evaluation results, the corresponding analysis indicators were put forward, where S EP-1 is the success rate of deception to judge whether the 2D plan is AI-or designer-generated, expressed by Equation (4), S EP-2 is the score made by the designer based on the design scheme, expressed by Equation (5). η ex and η nonex are weight coefficients for expert vs. nonexpert scores, as in Equation (6).
N ex and N noex are the numbers of experts and nonexperts, N F and N T are the numbers of misjudgments and correct judgments of the design, N img is the number of evaluation images, S j is the score of image J, σ ex and σ nonex are the scores of experts' and nonexperts' standard deviation, and F and H are the averages of expert and nonexpert scores. The determination of the weight coefficient in the equation refers to the coefficient based on the variation method proposed by Diakoulaki et al., wherein a smaller variation coefficient corresponds to a higher weight. The questionnaire is presented in Table 2.

Look at the Two Pictures below and Answer the Questions Question
Answer Options 1. Please distinguish whether the above 2D-plan drawing is generated by AI or designed by designers. The result statistics are shown in Table 3. In conclusion, M-StruGAN meets the requirements of high efficiency and high quality in the preliminary scheme design of 2D plans. Although the overall rationality of the preliminary 2D plan generated by M-StruGAN is not as good as the designer's optimized design, it is believed that the initial setup of M-StruGAN will be a good starting point for subsequent optimization. Moreover, with the continuous optimization of M-StruGAN, the gap between its design and the designer's design will gradually narrow.

Design Quality Assessment
To evaluate the quality of the scheme generated by M-StruGAN, we analyzed its generation scheme according to the design elements of the floor plan and judged how it can be er assist the design. This mainly includes (1) whether the room type is complete [52], (2) whether the area of the room is within a reasonable range [53], (3) whether the bay and depth of the room meet the needs of users [54][55][56], (4) whether the room has natural lighting [57], (5) room accessibility [58], and (6) whether the adjacency of the rooms is correct (Figure 13) [59][60][61][62][63]. In addition to design quality, design efficiency, economy, and stability of design quality are also crucial. The performance of the output of M-StruGAN was tested against these criteria to assess how well M-StruGAN understands certain architectural factors. This study evaluated a total of 50 2D-plan drawings automatically generated by M-StruGAN, and the authors analyzed it according to the above six design criteria. We found that 98% of the 2D-plan solutions were fully functional ( including living room, kitchen, dining room, bathroom, guest room, and utility room), and more than 95% of the area of the rooms is within a reasonable range. The depth of 90% of the rooms meets the needs of use, the lighting of more than 70% of the rooms meets the sunlight requirements, the accessibility of 90% of the solutions is good, and the adjacency relationship between the rooms of more than 80% of the solutions is correct (Figure 14). These results show that M-StruGAN learned the "design rules" in the 2D-plan layout of homestays and can handle the interrelationships between various functions well.

Human-Computer Interaction Application
The purpose of this research is not only to realize the automatic generation of layout results by machines but also, hopefully, to apply the results in the real design process to assist designers or users in rapid design ideas, so as to provide a possible thinking scheme. In response to this problem, we provide users with a simple M-StruGAN interface. This intelligent aided design webpage can directly use the model we trained for the 2D-plan design of homestays. It can quickly and automatically generate layout results and feedback to the user according to the mixed-structure information input by the user (Figures 15 and 16).  By comparing the timeliness and economy of M-StruGAN and designer designs, we find that it takes about 3.5 h for a designer to design a 2D-plan preliminary design for a homestay, while M-StruGAN takes 10 min or less. M-StruGAN is about 20 times more efficient than a designer's design. The cost of designing a plan for the designer pays hourly or monthly wages according to the time and workload. At the same time, M-StruGAN only needs to complete the previous model training to continuously generate plans with zero cost. The quality stability of the designer's design scheme is related to the designer's design experience. In contrast, the design quality of M-StruGAN is related to the training dataset, so its design quality is stable and has nothing to do with the user's experience level (Table 4).

Conclusions and Discussion
This paper proposes an intelligent 2D-plan generation method based on mixed structural constraints for homestays. The purpose of this method is to quickly and efficiently generate the corresponding function layout diagram by giving the conditions of the mixed structural constraints, thereby effectively reducing the designer's workload. Then, the image synthesis quality, scheme design rationality, and scheme design quality of the generated results of M-StruGAN are evaluated. It can provide designers with effective architectural layout schemes and has broad application prospects in auxiliary design. Finally, we apply it to human-computer interaction. The user can modify the structural conditions according to the requirements and obtain the generated results in time. To sum up, M-StruGAN provides architects with a preliminary homestay layout and improves the quality and efficiency of 2D layout design. The conclusions drawn are as follows: 1. The trained M-StruGAN can generate 2D plans based on mixed structural constraints. 2. This study used three evaluation methods: image synthesis quality assessment, scheme rationality assessment, and scheme design quality assessment. Image synthesis quality assessment quantifies and confirms the drawing generation quality of M-StruGAN; the rationality evaluation of the scheme shows that designers have a high degree of acceptance of the M-StruGAN design; and the scheme design quality evaluation shows that M-StruGAN has completed learning 2D layout design elements. 3. Through the human-computer interaction application of M-StruGAN, it can be found that compared with traditional design methods, M-StruGAN based on pix2pixHD has high-definition image quality, higher design efficiency, lower design cost, and more stable design quality. Therefore, M-StruGAN has a high application prospect in aided design.
The 2D-plan generation method based on mixed constraints proposed in this study can be well applied in plan layout with structural constraints. In terms of the design method, the design method of M-StruGAN is very in line with the 2D-plan creation process of architectural designers. In terms of design efficiency, this method of directly generating 2D-plan functional zoning diagrams and scheme layout diagrams from the first draft drawing limited by structural conditions saves the tedious process of drawing sketches in the middle and dramatically improves the efficiency of scheme design. From the perspective of application scenarios, M-StruGAN can also meet the needs of designers for scheme deliberation, and this repetitive modification work does not consume too much from computers. More scheme comparison means a more refined design, and this system helps designers to focus more on creative ideas.
In addition to generating the layout of homestays with mixed structural restrictions, M-StruGAN can also be applied to the layout and renovation design of museums, garages, and teaching buildings. In fact, with the saturation of urban construction, any design that needs to relayout and reuse the original building functions can use a similar method to deliberate on the floor plan.
However, this study also found that although M-StruGAN was initially applied in 2D-plan functional layouts, there are still limitations, such as unstable model training, blurred image recognition, and insufficient output solutions. For example, the design quality evaluation results of M-StruGAN show that M-StruGAN has some unexpected problems in the functional layout, and there are significant errors in meeting the room's natural lighting. In addition, the intelligent generation algorithm pix2pixHD used in this study, in terms of image generation quality, can already meet the resolution requirements of 2D-plan scheme diagrams. However, it can only be used as a design reference for designers and cannot be directly applied to detailed design engineering. Although the data resources of architectural 2D plans are sufficient, collecting and processing data is currently a particularly time-consuming task. Therefore, the generation system proposed in this study needs further improvement in intelligent data processing.