Generative Design 101
The future of the AEC industry is extremely exciting. Converging technologies will soon disrupt the whole industry as new automated workflows emerge. Generative design is the pinnacle of these new workflows. Once a problem is thoroughly and adequately defined, all possible design variations can be produced, explored, scored, and optimized. This article will show how generative design can be used for mechanical, electrical, and plumbing (MEP) design engineering.
Before jumping into solving specific MEP problems, it is good to have a holistic understanding of what generative design is, how it works, and what is required to get there. My definition of generative design is, “a connected design process that involves generating outputs that meet certain constraints of a defined problem. The process involves identifying variables to a problem and creating a massive number of possible solutions.”
With the exception of some software programs, you cannot typically buy generative design off the shelf. Software programs such as Test Fit usually only serve to solve individual, specific problems such as multifamily layouts but not hospital layouts.
A process that can fit the needs of an individual or an individual company’s specific problem usually requires more specialized input and development. This has led to increasing popularity of Algorithmic Design. This is largely due to the ease of entry with computational design software. Autodesk was one of the first available lines of such software products. Dynamo is computational design software that connects directly to Revit. With Dynamo, parametric problems could be constructed with variable inputs.
Next came Project Fractal which ran a variety of solutions from a Dynamo script but due to problems with a high number of variables, this process was too slow to bring much value. This has been replaced by Project Refinery resulting in an optimal solution that can be found quickly using genetic algorithms (NSGA-II optimization to be exact). These genetic algorithms are the best tools to solve complex problems with a large or unknown solution.
A genetic algorithm is a calculated trial-and-error search that is inspired by Charles Darwin’s theory of natural selection where the fittest individuals (inputs variable) are selected for reproduction in order to produce offspring for the next generation of inputs. The process optimizes designs quickly by adding a feedback loop. At the end of each generation, the design is scored, or given a “fit score.” Characteristics or attributes from designs with high fitness are then used to create a new set of inputs for the design problem. This process is called “cross over.” Just like biology, the process also introduces mutation or random tweaks to the new set of inputs after each generation to provide diversity to each generation. This guarantees the algorithms will not converge on false optimal solutions. The process repeats, creating a new and improved generation until it finds the best combination of inputs.
Constructing a Generative Design Problem
Building generative design algorithms is simple, but creating an algorithm that results in useful outputs takes creativity and lateral thinking. The goal is to build a flexible and scalable framework that can be applied to an extensive number of design problems. Building a useful framework consists of first asking the right questions and gathering the right data. Next, this information and logic needs to be turned into code that not only solves the problem with a variety of inputs but also give a score to the various solutions. This is where the challenge lies and where a shift will take place in the kinds of skills that designers and engineers will need.
While researching generative design, I stumbled across a YouTube video called Super Mario OI by Seth Bling. In the video, he shows Mario flying through a level. The catch is that Mario is being controlled by artificial intelligence. The program is made of neural networks and genetic algorithms that improve Mario’s performance each time he plays through the level. I love this example, not only because I grew up playing Mario, but because it is an excellent analogy of the generative design workflow and the components needed to build a generative design framework.
We must first define our goal. Mario’s goal is to find the fastest route through the level. Next, we need to find a way to measure our stated goal. The Mario game uses a timer and the percent of level completion to measure success. A combination of these two parameters makes up the fitness function. Third, we need to build out and constrain the problem. In the Mario analogy, this is the level itself, a kind of maze or problem statement to navigate or solve. The final step is to identify the variables that can be manipulated to solve the defined problem. For Mario, it’s the combination of inputs from the controller: A, B, X, Y, Up, Down, Left, Right. Once the problem is defined in this manner, an algorithm can be trained to beat the most talented of humans.
Just like in the Mario example, a design system needs to be defined. This is the framework. Then Project Refinery will be the artificial intelligence engine that will generate the creation of design alternatives that exist in the design system finding the best combination of inputs for the excellent solution. The framework consists of four parts:
Identify Goals
The first step with any generative design workflow is to identify the exact problem we are solving. It is critical to dedicate time to the vision in order to outline key goals and possible inputs. The generative design process relies heavily on key, front-loaded information derived from users, key stakeholders, and accurate historical data. Every attempt should be made to collect and analyze as much of this data as possible.
Build Algorithm
Once all the goals are defined, we can move on to step two, defining the problem. This step requires that the problem be defined in detail yet strategically constrained. The success of the outputs depends on how the model is parameterized and constrained. Too many inputs will lead to a design space that is too big or noisy to explore. Too few inputs will not yield a big enough design space to be of value. The goal is to build a flexible model that can generate designs that can be numerically tested against the goals.
Identify Variables
The third step is to identify key input parameters to the problem and established which of these parameters are variables and which ones are fixed. Some examples of a fixed parameters include models, building code, and owner preferences. Some examples of variable parameters include the number of items, different manufacturing equipment, and positioning.
Measure
The fourth step is to establish a way to measure the success of the results. A fitness function does this. Fitness functions are used in genetic algorithms to guide simulations towards optimal design solutions. Each solution, therefore, needs to be awarded a score that indicates how close it came to meeting the overall specifications of the desired solution. These results should generate intuitive results, meaning the best/worst candidates should have the best/worst score values.
For optimization problems, simple functions such as the sum can be used as the fitness function. There are a few nonintuitive pitfalls to be aware of when creating a fitness function. For example, using an if statement where true = 0 and false = 1 or using a function that increases as solutions get better, but doesn’t identify the best solution is not so good either. These methodologies have the risk of not finding an optimal solution. This happens when the algorithm cannot converge to a single point of the fitness function.
Constructing frameworks will be illustrated in the first few simple examples to get into the flow of solving optimization problems using Project Refinery. Each problem will be constructed and solved for an optimal solution using this framework, which is summarized below.
Problem Framework
Goal—What do you want to achieve?
Constraints—Define inputs and outputs and their relationships.
Variables—What inputs can be manipulated?
Fitness Function—How will the goal(s) be measured?
Example 1: Calculus 101 with Project Refinery
When I first heard that Project Refinery could optimize a Dynamo graph, I immediately thought of the Calculus 101 problem of minimizing the surface area of a soda can. In this example, we will first solve this problem using calculus and then see how that translates to solving the problem with Dynamo and Project Refinery. We will see how under the hood Project Refinery is merely looking for a maximum or minimum of a function using calculus optimizes tactics.
Problem Framework
Goal
Minimize the amount of material to produce the can.
Inputs
? = 12oz, 355ml
Constraints
? = ??2h
h>0, ?>0
Variables
Cylinder high and radius
Fitness Function
Minimize Surface Area
Calculus Solution
The first step is to define the problem: the equation for the volume of a sphere is, where r is the radius and h is the height. We also know that the volume is fixed at 12 oz = 355 ml. The total surface area of a cylinder can be found by combining the area of the top and bottom of the can with the area of the side of the can.
The next step of the problem is to restate the problem so as to get a function of a single variable. To do this, the value equation is solved for the height (h) and then substituted into the area function. Now area can be defined by the radius and using calculus, the minimum value can be calculated.
Next, the problem needs to be constrained. The minimum value will either occur at one of the endpoints of the domain of definition or at one of the critical points. Note that the domain of this function will be (0, ∞). Clearly, we cannot have r = 0. That makes the area go to zero, which would make it tough for our can to hold any liquid. We also could not have r = ∞ since this would be a flat can with no height and this also would not hold any liquid. This means the minimum must take place between r = 0 and r = ∞.
One way you could solve this problem is to graph the equation and then find where the value is the lowest, or as we said before, we can use calculus. In a continues function, a maximum or minimum is always where the function flattens or where the derivative of the function is equal to zero. The derivative basically finds the slope of a function at any point. These locations are considered critical points. Critical points are key in finding maximum and minimum values of graphs with calculus.
In order to find out if a critical point is a maximum or minimum we calculate the second derivative. This lets us know if the slope is continually getting smaller. Looking at the graph from left to right, the slope starts out positive (the function rises), goes through zero (the flat point), and then becomes negative (the function falls). A slope that gets smaller (and goes through 0) means a maximum. If the second derivative is less than 0 the critical point is a maximum, if it is greater than 0 it is a minimum.
Using the second derivative to check that this is indeed a minimum, we have SA′′ = 4π + 1420 r 2 > 0 and thus it is a minimum. Thus, the dimensions minimizing the surface area would be r = 3.837 cm and h = 7.675 cm.
Project Refinery Solution
Now let’s look at solving the same problem using Project Refinery. Yet again the first step is to define the problem with our framework. Rather than writing out the equation for the cylinder, we can use Dynamo nodes to generate the geometry and calculate the surface area.
Constraints
A cylinder is constructed using the Cylinder.ByRadiusHeight node. The next set of the problem is to rearrange the problem to get a function of a single variable. Inside the Code Block we write an equation that finds the height as a function of radi and make the cylinder.
Variables
The inputs in the pink group control the cylinder’s geometry. The volume input is a static Code Block remadeVolum, and the radius input is a number slider node renamed R. In order for Project Refinery to know that the radius node is input, the node needs to be set as an input. To do this, right-click on the node and click “Is Input.” Just like the calculus problem, the Dynamo script needs to be constrained. By clicking on the arrow icon on. Here the minimum and maximum can be set along with the steps.
Fitness Function
The next sections involve analyzing the results using a fitness function. The surface area of the cylinder will act as the fitness function and can be easily retrieved with the Solid.Area node. In order for Project Refinery to recognize this node as an output, the node needs to be set as an output. Right-click on the node and click “Is Output.”
Project Refinery
The Dynamo graph is now ready to be optimized by Project Refinery where the design will evolve to find the most suitable options based on the constraints and goals provided. Refinery will run multiple generations of options, and each time it will take the fittest (best) options of the generation and use them to create a new generation.
Optimization Steps
1. Create a new study and select Optimize as the generation method.
2. Under Inputs make sure that all the desired variable is present.
3. For inputs that do not change on each run, set the desired value and uncheck the box alongside it.
4. Under Outputs set the optimization goal you want to achieve: Maximize, Minimize, or Ignore.
5. Set the population size, this represents the number of options that will be created in each generation.
6. Under Settings set the amount of generations you want to create. Each new generation is a range of options that falls between the two best designs of the previous generation.
7. Click Generate.
Wow! Refinery just calculated the exact same results that were found using the Calculus 101 method. This is because under the hood, Project Refinery is basically doing the same calculations to hunt for maximums and minimums of the design space. There is not magic, just math! By clicking on the solution in Refinery the Dynamo script will adjust the variables to match the Refinery solution.
Example 2: Max Multivariable Graphs
In this next example, we will further explore the relationship between standard calculus and refinery as we move to multivariable problems. We we will use the same concepts we used to solve a single-variable problem in order to solve multi-variable problems. Intuitively, when you are thinking in terms of multivariable graphs, local maxima of multivariable functions are peaks, just as they are with single-variable functions. One way a computer "learns" how to do something is to minimize or maximize some "Fitness Function." In this case, the fitness function is the equation Z+X^2+Y^2=0, and the goal is to maximize the Z component of the function.
Rather than going through all possible X and Y inputs, the genetic algorithms looks at the rate of change of X and Y inputs. In calculus, this is also known as the gradient of the function. With the gradient, the computer can tell if it’s getting closer to the optimal solution. The next step is where cross over comes in. The algorithm's feedback loop combines traits of the good scoring solution to form a new solution. This is repeated until it converges at a maximum or minimum point. With this feedback loop, problems that would take literally, hundreds to thousands and even millions of years to compute can be solved in a practical timeframe.
Problem Framework
Goal—Find maximum Z value for the Function Z+X^2+Y^2=0
Inputs—Surface
Fitness Function—Maximum Z component or minimize the normal plane
Constraint—Point on the surface of Z+X^2+Y^2=0
Variables—X and Y inputs
Dynamo Graph
Generative Design for MEP
These examples will focus on common MEP design challenges that are good candidates for generative design. We have seen from the previous examples that, thanks to Project Refinery, the AI portion of these workflows is simple. The challenge for designers is building algorithms with Dynamo that lead to good results with Project Refinery. Instead of designers solving solutions to micro problems, they need to shift their mindset to solve engineering problems more holistically and think of creative ways to measure success. It is very important to understand the foundations needed before solving problems with Project Refinery.
In each example, a goal will be set. Data will need to be collected, a parametric algorithm will need to be defined, and different solutions will be produced with Project Refinery. The selected design solution will then be integrated into the Revit model.
Data – Revit
The foundation for our MEP workflows is the collection, organization, and centralization of data. Data is the oil that makes algorithms run--with more data available, more robust and complex algorithms can be written. Revit is the fundamental piece of software to accomplish this first task.
Revit is an example of Building Information Modeling (BIM) software. BIM is the combination of 3D modeling and a database, storing attributes (parameters) for each 3D entity. The software is designed to handle complex building systems and contains the tools to document the final design. Each intelligent model created with Revit represents an entire project and is stored in a single database file. Before moving to the next level, it is necessary to standardize the database so data can be targeted and retrieved. Note that data from other sources (e.g., Excel) can be integrated as well.
Parametric Model - Dynamo
Parametric design is a process based on algorithmic thinking that combines parameters and rules that together define the relationship between design elements. MEP problems can be solved parametrically by embedding the design logic into computer code to solve problems then linking all those design steps together to solve a class of problems.
Dynamo is the programming language that lets you do just that. Dynamo connects to Autodesk Revit allowing access to the database and the geometry aspects of the building model. This data can then be analyzed and connected to define relationships and execute a sequence of actions that create flexible algorithms that can find an array of solutions to the design problem. Before getting to the top of the pyramid, generative design algorithms must be developed and tested inside Dynamo.
Generative Design - Project Refinery
At the top of the pyramid is generative design. The ability to explore, measure and rank all the different options from a problem’s design space. This is done with Project Refinery, Autodesk’s generative design beta that was used above.
Example 1: Grid of Diffusers
Selecting and laying out the diffusers for a given space is a convoluted and often overlooked process. Yet it's vital to ensure code compliance and occupancy comfort. For example, too much airflow in a diffuser will be loud and violate building code noise requirements. Also, if the spacing is not correct, there can be major air drafts causing discomfort for the occupants. Running the calculations to take these issues into account involves a few steps. First, one must guess the number of diffusers for the space to find the required cubic feet per minute (CFM) for each diffuser in a room.
Second, the CFM is used to look up performance data from the manufacturing catalog. With the performance data, the noise levels and airflow distribution patterns can be evaluated. Running this process over and over for several different layout and diffuser types to find the best solution is not practical in real-world design where time is critical.
With generative design, the computer can quickly perform this process and test all the possibilities. The ideal layout for diffusers is very similar to the circle packing algorithm (see the full class handout). Here the circle radius is the airflow distribution pattern called throw. The airstream should not have significant overlaps as this causes drafts. The same framework will be used but with the radius being a variable based on the diffuser CFM and manufacturing data. Two more components are added to the fitness function to cover the noise and comply with he codes of this complex optimization problem.
Problem Framework
The goal of this workflow is to find the optimal combination of manufacture diffuser selection and layout of diffusers for a given space that best satisfies human comfort, uses the least number of diffusers and remains code compliant.
Data Collection - Manufacture Data from Excel
Excel is the most commonly used tool for manipulating and managing data in the MEP engineering community. Dynamo can import data from Excel that can then be used. The example below shows how diffuser performance data in Excel can be brought into Dynamo and rearranged into a list that can be worked with.
Space Parameters
The building code data for spaces often depends on looking up key words in data tables. Before running the diffuser script a script needs to be ran to set all the Space information. To deal with the issue of data integrity from human error and frankly, a lack of standards fuzzy logic can be used.
Architectural room names are an example. MEP engineers need to match up room names to some type of key value to the Ashrea Ventilation standards. Fuzzy logic is a form of many-valued logic in which the truth values of variables may be any real number between 0 and 1, inclusive. It is employed to handle the concept of partial truth, where the truth value may range between completely true and completely false. This is a fitness function. There is a Dynamo package called Fuzzy Dynamo that will do the trick, comparing the room names to the list of space type names within Revit and finding the best match. The Revit space type can then be set automatically to bring in all the code data like air changes per hour, exhaust requirements and noise limits from an Excel table.
Ceiling Geometry
The real power of Dynamo over other application is its ability to easily access and view Revit elements geometries. Out of the box, Dynamo can collect elements from a project but by pulling in additional nodes from Dynamo packages, we can also get elements from a linked model. Once an element is retrieved, there are four nodes we can use to get the element’s geometry. These nodes will produce varying outputs based on the type of Revit element being accessed. The table and image below illustrate this.
For the diffuser workflow a ceiling from a linked model ceiling above a selected Revit space will be selected. The geometry of the ceiling is deconstructed to get the lower surface.
Constraint
A parametric grid of points is constrained by the ceiling surface. The table of manufacturing data also acts as a constraint.
Building Algorithm
The first step in the workflow is to select a space. The bottom surface of the ceiling is then retrieved and a grid of points is formed. From there the number of points or diffusers is known. Next, the CFM can be found by dividing the number of diffusers by the spaces required CFM. After that, the throw at that particular CFM can be found using manufacturing data and interpolation. Now the circles can be placed at each point with the correct radius. The noise is also calculated and is needed for the fitness function.
Variable
The variables for this problem are the number of divisions for the grid of points and the different manufacturing diffuser options.
Fitness Function
The fitness function is very similar to the circle packing problem (see the full class handout) but two more inputs are added to capture the noise and cost variables of the problem.
Project Refinery
Projected Refinery is then used to evaluate all the options and output the fitness function.
Integration
The final step in the generative design workflow is to integrate your chosen design. Once the optimal solution is found, Dynamo can place the diffusers’ elements into the model, and set all of the diffuser parameters. With the Sigma AEC Diffuser Pack add-in, the diffusers can also be shaped to line up with the closest open ceiling grid.
Sean Fruin is a mechanical engineer in training (EIT), design technologist, and innovator who has an ardent fascination with automation and the exploration of computational design solutions for the architecture, engineering, and construction (AEC) industry. He learned many aspects of the design industry from is work in manufacturing, general contracting, and mechanical, electrical, and plumbing (MEP) design. Sean has realized his dream by starting Sigma AEC Solutions where he has had the opportunity to explore and implement the latest technologies, hence improving efficiency and increasing quality in the AEC industry.
Want more? Download the full class handout to read on.