Design Explorer for Wallacei results analysis

  • Intro
  • Export .csv without images
  • Export .csv with images
  • Import Data to Design Explorer
  • Design Explorer Analysis
  • Conclusion
  • Useful Links

Information

Primary software used Wallacei
Software version 1.0
Course Design Explorer for Wallacei results analysis
Primary subject Analysis & simulation
Secondary subject Optimization
Level Intermediate
Last updated November 15, 2024
Keywords

Responsible

Teacher
Faculty

Design Explorer for Wallacei results analysis 0/6

Design Explorer for Wallacei results analysis link copied

In this tutorial, you’ll learn how to integrate the results from a Wallacei X optimization into Design Explorer.

In this tutorial you will learn how to use Design Explorer with the results of a Wallacei X optimization. Design Explorer is an open-source tool for exploring multi-dimensional parametric studies. It is especially useful when you have a smaller solution collection that is already curated, like the one you can export from the Wallacei simulation. It can help you quickly find preferred solutions and see relations between parameters and their influence on optimization objectives more clearly.

Design Explorer webpage with solutions
Design Explorer webpage with solutions

Exercise file

For this tutorial we used the results of a façade optimization. In the exercise file you can find a Grasshopper file with the Wallacei X component with the saved optimization results, you can use this Grasshopper file to walk through the steps of exporting a csv. Additionally, you can find a csv file with the exported results, you can use this to walk through the Design Explorer analysis steps. Here you can directly explore the uploaded dataset in Design Explorer.  

Download Array
Array (ZIP, 152 KB)

Design Explorer for Wallacei results analysis 1/6

Export .csv without images link copied

The first thing you need to do is to export a .csv file from grasshopper, as Design Explorer takes .csv files as an input. That file should include:

1.    Generation and Solution numbers (ID)
2.    Variables for each solution (Genomes)
3.    Objective fitness values for each generation

After the simulation is done running, you have access to all of them in a data tree format. You need to do some post-processing to end up with a right data tree to export as a comma separated .csv file. 

Post-processing results

Getting the genomes values using the “Decode Genome” component
Getting the genomes values using the “Decode Genome” component

First, the genomes must be decoded so that for each solution you have the variables that were used. You can use the ‘Decode Genome’ component. 

Wallacei
Wallacei X
Decode Genome

In case you have used expressions to define the sliders of the variables you have to reverse those expressions to show the correct variable values. This was the case for the optimization that ran, in this case an expression was used for the window width variable to increase the step size of the slider. 

•    You should follow the following steps. First create a list item component and select the index of the corresponding variable. 

Sets
List
List item

•    Create an expression component and add the same expression as you used for the slider. 

Maths
Script
Expression

•    Use a Replace Items component to replace the variable before the expression with the variable after the expression. 

Sets
List
Replace Items
Reverse expression used for slider
Reverse expression used for slider

Next, you need to find the population settings of the optimization. You need to extract the generations number and the solution number per individuals.  With this, we can create a tree with the respective data tree branches. By exporting these settings, the exploration of the Parallel Coordinate Plot in Design Explorer will be clearer. 

•    You can use tree statistics to extract all the paths and deconstruct paths to extract the generation number and solution number for each individual. 

Sets
Tree
Tree Statistics

•    With the match tree component, you can create the exact same tree as the variables tree. 

Sets
Tree
Match Tree

 

•    To better understand what is happening inside those components, help yourself with plugging in panels and observing how the data structure changes.

Params
Input
Panel
Data tree operations to extract the generation and solution numbers (IDs) for each data tree branch corresponding to the same solutions.
Data tree operations to extract the generation and solution numbers (IDs) for each data tree branch corresponding to the same solutions.
Merging data into data tree branches corresponding to each solution
Merging data into data tree branches corresponding to each solution

The objective output, fitness values, is already stored correctly in the tree branches per solution and generation. Therefore, we can directly move on to merging the trees into one big tree. We can combine all that data (IDs, genomes, and fitness values) for each generation into the right data tree branch. For this the “Merge” component is perfect.

Sets
Tree
Merge

Note: Always check if the paths of each data tree are corresponding to ensure the creation of the right data tree. 

Exporting CSV

After post-processing the optimization results, it’s time to prepare the data for exporting. We will export a CSV file which can be imported into Design Explorer for the analysis. 

In each branch you have values corresponding to those solutions. For the .csv file however, each solution should be like one row in the excel file, and values corresponding to it should be in different columns. Thus, you must change the data structure, so that there are a few lists that contain values for every generation and solution. Those lists are going to work as columns.

Sets
List
Partition List
Sets
Tree
Flip Matrix
Data tree structured per column
Data tree structured per column
Column names defined
Column names defined

Next, we need to define the column names, this corresponds with the ID names, variables and objectives. Create a panel with the naming off the columns. 

Params
Input
Panel

The only thing left is to export the data with the corresponding column names as .csv. There is a handy component that will allow you to do that called “Create CSV”. Connect the column names to ‘Data grid headers and the data tree to ‘Value Tree’. To see the results connect a panel to the “CSV String” output.

Creating a .csv string for export
Creating a .csv string for export
Lunchbox
Data
Create CSV
Change file location with ‘Stream Destination’
Change file location with ‘Stream Destination’

To save the csv file you must right click on the panel and click “Stream destination” to change to location of where the file will be saved to. 
–    Right click on the panel
–    Select ‘Steam Destination’

Select the right folder and give the file a name
Select the right folder and give the file a name

A ‘Grasshopper Panel Stream’ window will pop-up. Select the right folder and give the file a name. Change the document type to CSV type. Click on ‘Save’ to close the window. Now the file location is determined. 
–    Select right folder
–    Change file name
–    Change ‘Save as type’ to .csv
–    Click on save

Select ‘Stream Contents’ to export the CSV file
Select ‘Stream Contents’ to export the CSV file

The next step is to save the CSV file. Right click on the panel with the csv string and select “Stream Contents”. The CSV file is now exported and saved in the folder you assigned it to. 
–    Right click on the panel
–    Select ‘Steam Contents’

The total Grasshopper script to export a CSV file looks as follows: 

Grasshopper script for exporting CSV file
Grasshopper script for exporting CSV file

Design Explorer for Wallacei results analysis 2/6

Export .csv with images link copied

This chapter explains an advanced version of creating the CSV file and exporting images of the results. After you run an optimization algorithm it is still possible to collect images of all the solutions in the optimization. The tactic for exporting the images and csv is slightly different than creating a CSV export for Design Explorer without images. This is an alternative way to export the solutions, and we will be using Colibri from the TT Toolbox. If you don’t have this plug-in installed, do this before you start the next part of the tutorial on the Food4Rhino website of TT Toolbox

 

We are quickly going over the steps in this chapter, we expect you to have advanced knowledge of Grasshopper.

Post-processing results

Internalize data of variables and objectives from Wallacei X
Internalize data of variables and objectives from Wallacei X

First, internalize the data from the Wallacei X component of FitnessValues and Wallacei Genomes. To internalize the variables (genomes) you must first use the ‘Decode genome’ component. 

Wallacei
Wallacei X
Decode Genome

 

Use data components to internalize this data. Additionally, you can place the earlier internalized data as well.

 

Params
Primitive
Data
Script component to clean data tree of duplicates
Script component to clean data tree of duplicates

If you want to have a very clean analytics process, you should remove all the duplicate results. You can clean the data tree by finding all the unique design options by checking the variables settings. To do so you must create a python code where you loop over all the variables in each branch. Create a script component for this and input the variables data tree called ‘Gene List’. 

The output of the script is a clean tree with only unique design options. You can copy the code below and paste it in the script component, create the input ‘data_tree’ and output ‘clean_tree’. 

from Grasshopper import DataTree
from Grasshopper.Kernel.Data import GH_Path

# Create lists to store unique and duplicate branches
branches_unique = []
branches_duplicate = []

# Create an empty set to track seen branches (tuples of 3 numbers)
seen_branches = set()

# Create an empty DataTree for the output without duplicates
output_tree = DataTree[float]()

# Iterate over all paths in the data tree
for i in range(data_tree.BranchCount):
    path = data_tree.Path(i)  # Get the path of the current branch
    branch = data_tree.Branch(path)  # Get the branch as a list of values
    
    # Convert the branch to a tuple of numbers (assuming 3 items per branch)
    branch_tuple = tuple(float(item) for item in branch)
    
    # Check if this branch has already been encountered
    if branch_tuple in seen_branches:
        # If duplicate, store in the duplicate list (optional)
        branches_duplicate.append(branch_tuple)
    else:
        # If unique, store in the unique list and add to the output tree
        branches_unique.append(branch_tuple)
        seen_branches.add(branch_tuple)
        # Add the unique branch back to the output tree
        output_tree.AddRange(list(branch_tuple), path)

# Output: A data tree with duplicate branches removed
clean_tree = output_tree
Change access type and type hint of input script
Change access type and type hint of input script

Don’t forget to change the access type to ‘Tree Access’ and the type hint to ‘float’. For the input ‘data_tree’ of the script. Without these settings the GH python script will result in errors. 

Additionally, the current script only works if your data tree consists of numbers, which will always be the case if you want to check a data tree created through an optimization algorithm. 

Find path of data tree to iterate over
Find path of data tree to iterate over

First, we must create an iterator that goes over all the paths in the data tree. You can use the tree statistics and a list item to select one path at a time. 

Sets
Tree
Tree Statistics
Sets
List
List Item

 

Create a slider with the number of individuals you have in your optimization.  

Params
Input
Number Slider
Checking number of solutions in data tree
Checking number of solutions in data tree

The slider settings, maximum domain number, depend on your optimization results. In our case we have a total of 625 individuals in the optimization data tree, however the clean data tree without duplicates only has 68 designs. You can check the number of design solutions by hovering over the ‘Paths’ of the ‘Tree Statistics’ component. 

We will be re-using this path to select the branch of the individual in the variables and objectives tree. Use the ‘Tree Branch’ Component and input the variable tree and the selected path. This creates a list of the variables for the solution. Next, create a ‘List Item’ component and increase the number of items so it corresponds with the number of variables. Next, create a ‘Data’ component for each item and name the data component according to the variable. The naming of this component will be used as column names in the CSV file and should not have spaces or special characters. 

Collecting the variables of the selected solution
Collecting the variables of the selected solution
Sets
Tree
Tree Branch
Sets
List
List Item
Params
Primitive
Data
Collecting the objectives and data of the selected solution
Collecting the objectives and data of the selected solution

Do the same for the objectives tree and select the results of each objective and collected data for the selected solution. Remember to connect the right data trees of the internalized fitness values and additional data. 

As a last preparation we want to collect the generation number and solution number so we can use this as input for the CSV. We can use the ‘Deconstruct Path’, and ‘Match Tree’ to create a tree with the generation number and solution number in the same structure as the variables and objectives tree. 

Sets
Tree
Deconstruct Path
Sets
Tree
Match Tree

 

Next, we can use the same tactic as above, with the ‘Tree Branch’ and ‘List Item’ to collect the right information on the selected solution. Remember to use a ‘Data’ component to name the results accordingly. 

Sets
Tree
Tree Branch
Sets
List
List Item
Params
Primitive
Data
Collecting ID of solution
Collecting ID of solution

Lastly, you must connect the collected variables for the selected solution to the geometry creation. Go to the beginning of the script where the variables are. Create a data component for each variable and connect it to the ‘collected’ variable value of the selected solution. Now replace the variables input of the sliders with the data variable values. 

Connecting the geometry creation with the selected solution
Connecting the geometry creation with the selected solution

Exporting CSV and images

The last part is to use Colibri to create images of the design and to create a CSV file for the import of Design Explorer. First create a ‘Colibri Inputs Iterator’ and connect the SolutionNr slider to the iterator. The SolutionNr can be found in the part of the path selection. You can use a Data component to send the solution number to the path selector. 

Create Colibri Inputs Iterator
Create Colibri Inputs Iterator
Colibri
Input
Colibri Inputs Iterator
Params
Input
Number Slider
Connect solution number from Colibri Iterator with the list item index of path finder
Connect solution number from Colibri Iterator with the list item index of path finder

Don’t forget to add the data component with the solution number to the ‘List item’ index for the path finder of the solution. 

Sets
List
List Item
Params
Primitive
Data

After this, we will create an image. From the Colibri Inputs we can use the Colibri Image Settings component to create an image for each solution in the optimization algorithm. Connect the ‘Unique Name’ output with the ‘ImageSaveAsName’ input, and define the Rhino view you want to save. 

Colibri Image Setting for image creation
Colibri Image Setting for image creation
TT Toolbox
Colibri
Colibri Image Settings
Create Colibri Outputs component and connect all data for export
Create Colibri Outputs component and connect all data for export

Next, create a ‘Colibri Outputs’ component and connect all the data you want to export to the CSV file. In our case it is the generation and solution number, the variables and the objectives. Remember, the naming of the data components corresponds with the naming of the columns in the CSV file.

TT Toolbox
Colibri
Colibri Outputs

The last step is to connect everything to the ‘Colibri Aggregator’. Define the path of the empty folder you want to write to. Connect the inputs, outputs, and image settings. Lastly, connect a Boolean Toggle to the ‘Write?’ input, but be aware that once you click on true all the data inside the defined folder will be erased. 

TT Toolbox
Colibri
Colibri Aggregator
Params
Input
Boolean Toggle
Connect to the Colibri Aggregator
Connect to the Colibri Aggregator

To export the images and CSV you must activate the Colibri Aggregator and run the Colibri Iterator. However, before that you should disable all the parts in the script that you don’t need. For example, you only have to generate the geometry for the image, but you don’t have to calculate the fitness of the objectives again. The fitness objective is internalized for all the solutions in the optimization model. 

Disable the part in the script that is not needed for the geometry creation. Blue = script for geometry creation, Red = script for objective calculations
Disable the part in the script that is not needed for the geometry creation. Blue = script for geometry creation, Red = script for objective calculations

Once you have all the irrelevant part of the Grasshopper script disabled you can activate the Colibri Aggregator by changing the Boolean toggle to True. Then you can run the iterator and create the CSV file and the images by clicking on ‘Fly’ in the Colibri Inputs iterator. All the images and the CSV file will now be saved in the folder. 

Export images and CSV file
Export images and CSV file

The total Grasshopper script to export images and a CSV file looks as follows:

Grasshopper script for exporting images and CSV file
Grasshopper script for exporting images and CSV file

Design Explorer for Wallacei results analysis 3/6

Import Data to Design Explorer link copied

Now that the CSV file is created, the next step is to analyse the optimization result with Design Explorer. Design Explorer is an open-source web tool for exploring multi-dimensional parametric studies. You can find the Design Explorer Website here

Design Explorer website
Design Explorer website

Loading Data into Design Explorer

Upload data in Design Explorer by clicking on ‘Get Data’
Upload data in Design Explorer by clicking on ‘Get Data’

When you open the Design Explorer website, you can already see the similarity with the Parallel Coordinate Plot. To start exploring, upload the .csv file you just created. You can do it by clicking the “Get Data” right next to the Design Explorer logo on the top left side.

Set Data in Design Explorer
Set Data in Design Explorer

A pop-up window will open. In the pop-up window you have two options, either you load a CSV file (blue option) or you connect an online link with the data (orange option). In case you do not have images, you can directly load the CSV file. In case you have images as well you have to connect an online link and therefore, we have to follow some additional steps. 

Create Online link to data

In the next steps we will be explaining how to upload data with a google drive link. 

Go to share settings of the folder in Google Drive
Go to share settings of the folder in Google Drive

First upload the folder with the images and CSV file into Google Drive. Once all the data is uploaded, open the folder and go to the settings. Select the ‘Share’ settings. 

Copy share link
Copy share link

Change the share settings to open for everyone with link to view and copy the link. 

Copy link and load data
Copy link and load data

Paste the copied link to the google drive and click on ‘Load Data. 

Copy and save link to your project page
Copy and save link to your project page

After the data is imported into the interface a new pop-up screen will show up. Here, you can copy the ‘Link for share’. You should save this link and/or share it with your team-mates, and it will directly show your loaded dataset. 
You results are now loaded in Design Explorer and ready for the analysis.

Design Explorer for Wallacei results analysis 4/6

Design Explorer Analysis link copied

In this chapter we will show how to analyse the data in Design Explorer. Design Explorer can be a very handy tool to manually, yet quickly, sort through design solutions after the optimization is completed. It can enable you to include solutions you might otherwise miss while using only the Wallacei in-built analysis and selection tools.

We will only show the analysis of the dataset with images, as it is the same for the dataset without the images. After uploading the dataset consisting of the CSV file and images per solution the Design Explorer interface will show the Parallel Coordinate plot and the solution images. 

It might be overwhelming at first, you have all of the solutions before you. Each line represents one solution, and its placement on the column axis indicates the value for that particular variable or fitness objective. 

Design Explorer interface after uploading .csv data file
Design Explorer interface after uploading .csv data file

Preparation

Go to settings in Design Explorer
Go to settings in Design Explorer

There are a few steps you can take to make the parallel coordinate plot more organised. First go to settings. 

Set study name and date
Set study name and date

Give the Design Explorer study a name. When working on a design project it could be beneficial to also include the date. 

Add Target mark to the objectives
Add Target mark to the objectives

Scroll down to the objectives and include a target mark. For example, for our objective cost the target mark is the minimum cost. Do this for all the objective and if applicable for the additional data points. 

Additionally, you can change the scale of the data by changing the minimum and maximum values of ‘Scale range’ of each of the columns. Once done, click on ‘Set. 

If you click on ‘Save’, a json file will download. You can place this settings file in the Google Drive folder, so next time you open Design Explorer these settings are saved. 

Notice that in the Design Explorer interface the project name is added and the parallel coordinate plot settings changed. Now, we will further fine-tune the parallel coordinate plot by opening the sliders on the left. Click on the arrow icon on the left top called ‘Show Sliders’.

Design Explorer interface after adjusting settings
Design Explorer interface after adjusting settings
Show and hide column in the parallel coordinate plot
Show and hide column in the parallel coordinate plot

In the left toolbar you can check which column you want to include in the parallel coordinate plot. In our case we can hide the solutionNR, generation number, and solution number. 

Once done, you can click on the ‘Show sliders’ arrow at the left top again to close the menu. 

Change line colour by clicking on a column
Change line colour by clicking on a column

You can change the order of the line colours by a single click on a column. Be aware that the blue lines are always at the top (maximum) of the scale and the red lines are always at the bottom (minimum) of the scale.

 
Additionally, you can reverse the order of the values of a column by double clicking on a column name. 

The parallel coordinate plot is now organised and ready to use for analysis. 

Organised parallel coordinate plot
Organised parallel coordinate plot

Recognizing patterns

Notice that you can move the columns around, changing their order as it suits you. If you click on the name of a column, you can drag the column to a new position. You can use this same technique to recognize patterns in the data. 

In this example you can see that a high window height leads to a lower number of unique panels and a lower total number of panels. 

Changing the order of column to analyse data
Changing the order of column to analyse data

Brushing

You can also filter solutions within each of the column, this technique is called brushing. In this way you can focus on a selection of the data. It can be done by selecting (with the mouse) a range you’d like to include on a chosen column. The solutions that fit into those brackets are shown under the parallel coordinate plot. 

Brushing Design Explorer solutions
Brushing Design Explorer solutions

Individual solutions

You can investigate how individual solutions relate to the total dataset by clicking on an image of the solution. The interface will change slightly, showing the image of the solution, the overview of the design aspects in the attributes panel and to location on the parallel coordinate plot. The location of the solution on the parallel coordinate plot is highlighted in a bold line.

Investigating a single solution in Design Explorer
Investigating a single solution in Design Explorer

Design Explorer for Wallacei results analysis 5/6

Conclusion link copied

Congratulations on completing this tutorial! Now, you’re equipped not only to optimize data but also to visualize all potential solutions and choose the one that best meets your goals. You’ve learned how to extract data, including images, from Wallacei and Grasshopper and turn it into a .CSV file using the Colibri plugin. You also explored two methods for importing data into Design Explorer, depending on whether your .CSV file includes images. Finally, you gained skills in reading, analysing, and filtering solutions in Design Explorer. With this knowledge, you’re now ready to visualize all your options and make informed choices based on your objectives. Take it further by experimenting with your own data—explore, analyse, and find the solutions that work best for you!

Design Explorer for results exploration
Design Explorer for results exploration

Final exercise file

The first part of the tutorial was about exporting a CSV and images through Grasshopper. You can find the final Grasshopper file here the geometry for the optimization as the adjusted script to generate the CSV file and images. Additionally, you can find a csv file with the exported results, you can use this to walk through the Design Explorer analysis steps. Here you can directly explore the uploaded dataset in Design Explorer.  

Download Array
Array (ZIP, 228 KB)
Grasshopper script with two options to export a CSV file
Grasshopper script with two options to export a CSV file

Design Explorer for Wallacei results analysis 6/6

Useful Links link copied