Modular architecture shape design recursive algorithm

The architecture and architectural shape of a building plays an important role in the interior housing design, many concepts have been developed to optimize this and to have a housing that reflects both visual and architectural comfort or even thermal one. The evolution of these houses however is not controlled, modular architecture has appeared because among its basic principles is being built from modules that can be assembled, then separately modified or even disassembled, the advantage of this typology of architecture is that it is fast in execution, light in installation and above all has very little impact on the environment in which it is part. These buildings are characterized by more dynamic geometries, which results in a very rich architectural language and an interesting sky line, however, to be able to project all the possibilities is a challenge in itself. In this article the discrete geometry is treated through the development of an algorithm that illustrates the process that allows to expose all possible cell combinations, the latter represents the basic module of modular architecture, the most attracting choices will be arranged to illustrate the formal and architectural optimization of a house. In this study the emphasis will be placed on the mathematical part in order to highlight the relationship between geometry and its influence on the final architectural rendering.


INTRODUCTION
Discrete geometry is a subgraph of square meshes composed of an infinity of several unit cells paired edge to edge, with adjacent cells forming the edges of the graph. These studies have a long history in the scientific literature, but they were first presented by Solomon Golomb, then by Martin Gardner in his American columns Scientific "Mathematical Games" [1], and by several research articles by David Klarner. They are now one of the most popular subjects in the field of mathematical recreation and have attracted the interest of mathematicians, physicists, biologists and computer scientists [2]. Work on the analogy between mathematics and the rest of the disciplines is now omnipresent, particularly between architecture and geometry, which are undeniably linked at the morphological and structural levels. Discrete geometry is applied in modular architecture, the latter is characterized, in the design phase, by the use of identical combined cells, by juxtaposition and/or superposition [3]. Among the adheres of modular architecture existing today, the architecture of containers, indeed this metal box is a standard product so considered as a basic cell, mainly used for logistics [4]. This archetype is inclined to be studied from a purely analytical point of view, and therefore the overview on the number of combination possibilities is difficult to visualize it without a numerical processing. These combinatorial morphologies have a relative impact, these impacts are mainly of an aesthetic nature, but also structural.
However, from a practical point of view these constructions face physical constraints that limit the choices in terms of purely morphological possibilities, because, for structural reasons, for example, the superposition of 15 containers cannot be achieved. From an architectural point of view, this type of construction reflects a strong ecological approach [5], insofar as the reuse of used containers is possible, therefore, during the design phase the architect decides on the number of cells, in this case containers, required for the projects, thus meeting the specifications from the surface point of view, and thus satisfy the criteria required by the project, the use of discrete geometry is first of all a temporal and morphological optimization, having the choice would considerably facilitate the design, while being in conformity with reality. In this article, the main objective is to demonstrate the possibility of using discrete geometry in real conditions to serve modular architecture and architects who explore all possibilities. In this paper we showed that the concept of recursion and its application contributes greatly to the success of architectural projects of this type, more specifically we describe in the following section graphically and analytically an algorithmic approach to illustrate the possible combinatorial forms.
As already said, this section describes the basic recursive algorithms that generate all possible shapes with a predefined number of cells. The cells must be adjacent and every cell in the shape must be located above another cell or on the ground (see figure below) We first describe the basic recursive algorithm, outline its drawbacks and then we present a second algorithm that corrects the imperfections of the first.

Basic recursive algorithm
The recursive algorithm used to generate all possible shapes composed of + 1 cells is shown below (figure 2). The algorithm has two input arguments. The first argument is a binary 2D matrix whose elements have 0 value except for a single element whose value is 1 and which represents the initial cell. The second argument is the number of cells to be added to the initial one. For each cell the algorithm checks its closest neighbours located in East, North and West directions. In the North direction (line 17 of the algorithm) whenever the location value is 0 the value is set to 1. In East direction, whenever the location value is 0 the value is set to 1 if and only if there is the ground or a cell in the South-East direction (constraint 1 line 11). In West direction, whenever the location value is 0 the value is set to 1 if and only if there is the ground or a cell in the South-West direction (constraint 2 line 23) (see figure 2). These two constraints allow to construct a subclass of 2D Polyminos [6] that correspond to physical construction: there is no suspended cell, each cell in the generated shape has a support cell or the ground. When a location value is set to 1, the same algorithm is executed with input arguments corresponding to the updated 2D matrix and number of cells minus one (lines 13, 19 and 25). The algorithm execution is stopped when the number of cells to be added is equal to 0. The output of the algorithm is a 3D array (TabConfig) in which each slice is a binary 2D matrix corresponding to a shape. Algorithm 1.

Improved recursive algorithm
The major drawback of the basic recursive algorithm is that it generates, among all possible shapes, subsets of identical shapes. From an algorithmic point of view, due to its recursive processing, the identical shapes are in fact different shapes because the algorithm takes into account these two following points: a) for a given spatial occupation the cells are differentiated as we can see in configuration B. (see Figure3) b) spatial occupation of the shape as we can see in configuration D. and C. below. (see Figure   3).

Figure 3. algorithm translation of the same shape
After the launch of the algorithm, the generation of shapes is efficient but we face the problem of N-uplet, which is the phenomenon of having duplicate, triplate, quadruplicate..., indeed we are witnessing the graphic generation of the same shapes, several times.
In order to reduce the number of identical shapes resulting from the remark in a. we added a condition in the algorithm (line 23) (see Figure 4) which avoids to generate shapes that are only translations of shapes already generated.
To eliminate the identical shapes resulting from the remark in b. we added lines of code starting at line 37 to line 45. This additional processing allows to verify that each generated shape is unique by comparing it with previously stored shapes. If there exists among the stored shapes a shape identical to that which has been generated then it is not memorized in the TabConfig array.

SIMULATION RESULTS
In this section we present results obtained by executing the second algorithm (see Figure 4) written in MATLAB. We have set the number of cells to 5 ( = 4) and in order to execute properly the algorithm we run the following script:   In the table below we have reported the results of the algorithm with different number of . The execution time is measured on a CPU running at 1Ghz frequency (see Table 2).

Quantitative analysis
We can see from the table above that the number of shapes with + 1 cells are equal to 2 . To prove this result let us note by the number of adjacent cells on the ground (see Table 1). For each value of , varying between 1 to + 1, the number of shapes resulting from the positioning of + 1 − cells on cells are showed by the equation (1): The total number of shapes is then:

CONCLUSIONS
Developing an algorithmic script based on recursive geometries, and allowing the generation of all morphologies is a considerable time saving, for architects and all other professionals working in the construction sector. Indeed, thanks to this contribution, we can claim to have a global vision of all the possibilities from a purely geometric point of view, then the architect decides on the choice best suited to his specifications, both aesthetically, by choosing the volumetric composition that corresponds perfectly to urban language, and spatially by optimizing the interior layout that will form the spatial composition of the inhabitants. in addition thanks to this analytical work we are now also able to predict, from the beginning, the number of exact possibilities we can have, and those of course according to the conditions we have issued. That said, this optimization can indeed satisfy both constraints at the same time, and in this perspective, future work will focus on combining several criteria in an optimization, more precisely energy optimization, which today represents a major challenge and an international challenge.