# Residential Buildings Complex Boundaries Generation Based on Spatial Grid System
## 4 Algorithm
### Generation of 10 by 10 and 20 by 20 Arrays
The last step is labeling cells with a value of 1 as built and others, with a value of 0, as empty. Solutions are represented as an orthogonal grid of pixels and the image is created as presented in Figure 6.  
The prototype implementation of the algorithm is in Python language. All tests are done on a 3.1 GHz Intel Core I5 with 8 GB RAM. The inputs to the algorithm are numbers that represent the area of the building and the number of different generated solutions. Outputs of the algorithm are images of the layout and arrays exported in text form. In Figure 7, the results are illustrated by randomly generated layouts from using the method described in the previous chapter. Figure 5: Transformation of the 5 by 5 array into a 10 by 10 array. In this example position of number 7 in the left array dictates the position of a list of numbers [0, 0, 3, 4] in the right array. The position of number 4 is conditioned by the surrounding cells to be next to the highest surrounding cell. Figure 6: Forming the shape of the building from the array. Cells that are labeled 1 are presented as black squares and cells that are labeled 0 are white squares. This method is evaluated by producing 100 different building layout shapes for each area input. Input numbers that represent the area of the building in square meters are values from 50 to 350 by increasing the number by 25 for overall 13 different inputs. The average time for this task is calculated and the results are presented in Figure 8. For most of the input values, N calculations of 100 valid layouts takes between 2 and 3 s. For the bordering values of N, the time for calculation is higher. Results are measured by the number of edges necessary to draw the border of the building. Borders of the buildings generated by our method show that the number of edges can be a minimum of 12 and a maximum of 54. The distribution of the results is presented in Figure 9. The average values vary corresponding to the input parameter of the building area. Figure 8: Performance of the method. The graph presents the correlation between the input parameter that represents the area of the building and the average time for generating 100 results. Performance is worse for areas that are lesser than 75 or greater than 325. Figure 7: Examples of random shapes of buildings generated by our method. Buildings in this example have their floor plan area from 50 square meters (first) to 350 square meters (last). The results are compared to the results of other methods [10; 13; 18; 19] and real buildings with complex borders by the same criteria. Building floor plans are converted into a grid of the 1 by 1 m squares through the simple algorithm that is developed in order to have uniform results. The number of edges before and after conversion is the same except in some cases the area of the buildings changed no more than 5%, which we considered tolerable. First, the described method is compared to the research by [PERSON] et al. [19]. Only complete computer-generated solutions are considered. The maximum value of edges is 18 for the house with an area of 152 square meters. Figure 10 shows the distribution of the results. Next, the results from the research of [PERSON] et al. [13] are evaluated area of buildings in this research is between 85 and 155 square meters. The highest number of edges in this paper is 14 and the average value is 10. Results are presented in Figure 11.  
Figure 10: Efficiency of the method by [PERSON] et al. [19], observed based on the number of edges that are necessary to draw the shape of the building boundary. Values in this research range from 10 to 18. Figure 6.0 Efficiency of our method based on the number of edges that are necessary to draw the shape of the building boundary. The minimum value that we generated was for a 50 square meter building with a value of 12. The maximum value for a 200 square meter building was 54. The research of [PERSON] et al. [10; 18] can be observed from two aspects.