Multi-Objective Optimization with Wallacei
Extension:DynamicPageList (DPL), version 2.02 : Warning: No results.
The goal of this tutorial is to optimize the distribution of openings and shades in a south façade. Particularly, the optimization seeks to find the optimal window to wall ratio and window height for a wall face with a given sill height. Moreover, it investigates which is the optimal number, distance and angle for the placement of shades of given depth in the aforementioned openings. The objective of the optimization is to maximize the amount of direct sun hours in the interior during the winter months and minimize it during the summer months. Additionally, the optimization seeks to maximize the percentage of the floor space that has sufficient ambient daylight during the year period.
Credit the Author when using these scripts for your projects!
Setting up the script
Before starting with the optimization, the Grasshopper script for running the simulations should be created.
Create reference geometry
This tutorial is based on the example demonstrated in Honeybee Intermezzo 4: Parametric creation of Openings & Shades . Following the steps described there, you should have the components as shown in the image.
Important to note:
1. In case you want to apply a different value to different components at the same time, e.g. different number of shades in each opening, you can use a Gene Pool instead of a Number Slider as input. Each gene value refers to a different component and you should again pay attention to the range of numeric values that they can get.
2. It is highly important to pay attention to the numeric range of the Number sliders that you are using as inputs, especially on the parameters which will later be applied as genomes for the optimization. Particularly, the lower and upper limits of the Number Slider or Gene Pool should reflect the practical limitations that will derive from the application of these solutions, so that all the variations tried through the optimization can potentially produce a reasonable output. For example, in the Number Slider for the number of shades, it makes sense that the numeric range is between 1-6 and it refers only to integers.
You can change the minimum and maximum values of the components by double-clicking on them.
Create a Wallacei » Wallacei X » Wallacei X component and connect the Number Sliders and Gene Pools that you want to optimize in the ‘Genes’ input.
Important to note:
Especially for this component, you should connect the inputs starting from the optimization component (Wallacei X) and linking the arrow to the input every time. If you want to connect multiple Genes, you should press Shift while linking with each one.
Create the simulations
Regarding the simulation type, for the amount of sunlight hours we will use the HB Direct Sun Hours component, whereas for finding the percentage of the space that overall has sufficient ambient daylight throughout the year period we will use the Spatial Daylight Autonomy(sDA) indicator. You can see how to set up the Annual Daylight simulation and extract the sDA indicator in Step 5B: Annual Daylight simulation. You can use the same setup in order to also calculate the solar radiation as described in Honeybee Intermezzo 11: Direct Sun Hours Simulation.
Important to note:
If you want to calculate the performance indicators for different time periods, as it happens in our case where we want to maximize the amount of sun hours for winter and minimize it for summer, you should create the simulation components - in this case the Direct Sun Hours component - twice. Each time you should specify the time period for which you are calculating the value. You can see how to do it in Honeybee Intermezzo 9: How to specify the time period in the WEA file.
Following these steps, you should have the components as shown in the image.
Regarding the HB Direct Sun Hours simulation, given that the ‘hours’ result is giving different values for each sensor grid, you should sum them altogether in order to take one cumulative numeric result. Create a Math » Operators » Mass Addition component and connect the ‘hours’ result from the HB Direct Sun Hours component to the ‘input’.
Create a Params » Primitive » Number for each of the numbers that you want to take into account for the optimization, i.e.for the direct sun hours in winter, direct sun hours in summer and sDA.
How to set the optimization objective
In the case of multiple objective algorithms you can directly connect the objectives in the ‘objectives’ input without the need to compose it into one factor as in the case of single-objective optimization. However, especially in the case of Wallacei, the algorithm is set to minimize any objective which is connected to it. In order to achieve a maximization objective, you should convert it into a minimization one by using its inverse number.
Create two Math » Polynomials » One Over X components. Connect the ‘Obj1_Radiation Winter’ and ‘Obj3_sDA percentage’ yo the 'Value' input respectively and use the ‘Result’ output to connect it to the ‘objectives’ of Wallacei X.
How to apply a constraint
Instead of only applying objectives to maximize or minimize, you could also apply constraints that you want your optimization to fulfill. This could be any kind of condition -both qualitative and quantitative- that you can check through Grasshopper.
Important to note: In case it is only a constraint that refers to the range of values that can be assigned as inputs to the design variables, you can directly apply the constraint by altering the numeric range of the Number Slider or Gene Pool.
Let’s assume that we want to apply the sDA percentage as a constraint in the optimization and, particularly, we want to achieve that at least 0.4 of the sensor grids of the floor receive sufficient daylight through the year.
What will happen is that instead of directly applying the sDA factor in the ‘Objectives’ input of Wallacei X, we will combine it with another factor. The preferred scenario is to combine it with an objective set to be maximized and make its value ~0 if the constraint is not fulfilled. In our case, we will combine it with the amount of Direct Sun Hours which are received during the winter period.
Create a Math » Script » Expression component and add the ‘Obj1_Radiation Winter’ and ‘Obj3_sDA percentage’ to the inputs. For a constraint of at least 40% regarding the sDa, set the expression as shown in the image. Connect the ‘Result’ output in the One Over X component instead of connecting only the ‘Obj1_Radiation Winter’.
How to run the optimization
Double-click on the Wallacei X component. From the interface that opens you can set the parameters related to your optimization. On the top part, you can set the size of your population by adjusting the size of each generation and the amount of generations that are going to be investigated.
After setting these, click ‘Start’ on the bottom part. When the simulation completes a first simulation, you will be able to see the statistics regarding the time per simulation as well as the overall time needed in ‘Runtime’.
Important to note: The optimizations usually take several hours to be completed. If you want to achieve faster results, e.g. for the first project phase, you can consider reducing the number of parameters or use components that do rougher but faster simulations, e.g use Ladybug components instead of Honeybee components. You can see the time needed per simulation by selecting Display (main Grasshopper toolbar) » Canvas Widgets » Profiler.
How to select solutions
After completing the optimization, you can use the tools in Wallacei Analytics and Wallacei Selection tab in order to compare the performance of the different variations produced.
Important to note: Right after completing the optimization, save your file in order to also save the results of the optimization. In this way, you can also access it in a later time by double-clicking on the WallaceiX component.
It allows users to select and visualize the performance of individual solutions of each generation. In ‘Selection’, you can select the solution you want to visualize. By clicking ‘Draw’ in the bottom part, you see the lines that refer to this solution on the graphs, whereas by clicking ‘Select’ you see the performance value of each objective and the respective Diamond Graph of the solution.
It allows users to select and visualize the performance of whole generations. In the ‘Control Panel’ click on ‘Draw Parallel Coordinate Plot’ in order to see the graph on the right. You can use the rest of the tools in the 'Control Panel' in order to select the generation you want to visualize. By clicking ‘Add’ on the bottom part, you highlight the lines respective to the performance of each generation on the Parallel Coordinate Plot.
Important to note: After selecting the variations which you want to keep, you can export the phenotypes related to them. In order to add the variations that you want to the export list, click ‘Add’ on the bottom part of Wallacei Analytics or Wallacei Selection.
How to extract the phenotypes
Firstly, go back to the script and create a Set » Tree » Entwine component. Connect in its inputs all the geometries and meshes that compose the elements of the phenotypes you want to export.
In our example, you can use a Honeybee » Visualize » HB Visualize by Type component in order to take only the meshes that you want from the HB model. Connect the ‘walls’, ‘roofs’, ‘exterior floors’, ‘apertures’ and ‘outdoor shades’ and connect them to the input branches of the Entwine component.
Connect the ‘Result’ of the Entwine component to the ‘Phenotype’ input of the WallaceiX component. Right-click on the input and select ‘Flatten’.
Go back to the WallaceiX interface and, particularly, in the Wallacei Selection tab. Click on the ‘Export’ button. You can see the process of the phenotype extraction on top of the Export list in the same tab.
Get the Results
After the completion of the Export process you can get all the respective values for each variation you selected.
Connect the output to a Wallacei » Wallacei X » Decode Genome component. Create a Params » Input » Number Slider and connect the 'Gene List' output to it in order to show the values which were used for the design variables in each of the solutions you selected.
Create a Params » Input » Number Slider and connect the 'Fitness Values' output to it in order to show the resulting values for the performance of each objective respectively.
Connect the output to a Wallacei » Wallacei X » Decode Phenotype component. Create a Set » Tree » Explode Tree component and connect the 'Meshes' output to it. Adding more branches to the 'Explode Tree' component and connect a Params » Geometry » Mesh component to each output in order to get the phenotype for each of the solutions you selected.