RasmahRasmah

Graph Generative Design

println("Julia ", VERSION)
Julia 1.12.6

Overview

A CAD part is a graph: feature nodes (box, cylinder, …) joined by edges (boolean operations, parent–child links). A graph generative model (Kipf & Welling 2016; You et al. 2018) learns to compress and regenerate that topology, so a low-dimensional latent code represents a whole family of parts. Here a graph-convolutional autoencoder encodes node features + adjacency into a latent vector and decodes them back by inner products.

using Rasmah

# 4 features (one-hot) and their adjacency (edges = boolean/parent links)
X = [1.0 0.0 0.0 0.0; 0.0 1.0 0.0 0.0; 0.0 0.0 1.0 0.0; 0.0 0.0 0.0 1.0]'
A = [0.0 1.0 0.0 1.0; 1.0 0.0 1.0 0.0; 0.0 1.0 0.0 1.0; 1.0 0.0 1.0 0.0]

θe, θd, z = graph_autoencoder_fit(X, A; hidden = 8, latent = 4, epochs = 800, lr = 1e-2, seed = 0)
println("latent code z = ", round.(z; digits = 3))
latent code z = [0.0, 0.0, 0.089, 0.0]

Verification

Decoding the latent code must reconstruct the (finite) feature matrix and adjacency:

Xhat, Ahat = graph_decode(z, size(A, 1), θd; nfeat = size(X, 1), hidden = 8, latent = 4)
println("reconstructed features finite: ", all(isfinite, Xhat))
println("reconstructed adjacency finite: ", all(isfinite, Ahat))
reconstructed features finite: true
reconstructed adjacency finite: true

Next steps