Official Implementation of "Design for Descent: What Makes a Shape Grammar Easy to Optimize?" Siggraph Asia 2025
git clone https://github.com/milmillin/d4descent.git
cd d4descent
uv syncRunning the experiments requires two steps: generating the shell scripts for the experiments and running them. This can be done with the following commands:
cd runs
uv run python _rungen_arclines.py
./_generated/arclines/AL-F_OneComp.shThe _rungen_*.py will generate the shell scripts for the experiments. It will print all the generated shell scripts which you can then run.
Three grammars are tested in the paper: arclines for Arclines, trees for Tree, and ur for UnionRect grammars.
The suffixes denote objective functions: _topopt for topology optimization, _prompts for optimizing with SDS, _pngs for optimzing towards images. No suffix means optimizing towards shapes.
For ablations, uncomment parts of the code in _rungen_*.py and rerun to regenerate the shell scripts.
The repository is organized as follows:
src/d4descent/- Main package containing the optimization frameworkoptimizer.py- Core optimization algorithms and proceduresscheduler.py- Learning rate scheduling and optimization controlcontext.py- Execution context managementmetrics.py- Evaluation metrics and loggingvisualizer.py- Visualization tools for results and debuggingobject_collection.py- Management of optimizable objectstypes.py- Type definitions and interfacesutil.py- Utility functions and helpers
src/d4descent/objects/- Implementation of shape grammar objectsarclines.py- Arclines grammar implementation with curves and connectorstree.py- Tree grammar for hierarchical branching structuresur.py- UnionRect grammar for axis-aligned rectangle compositions
src/d4descent/tasks/- Task-specific implementations for different optimization objectives_base.py- Base task interface and common functionalityarclines.py- Arclines-specific optimization taskstree.py- Tree grammar optimization tasksur.py- UnionRect grammar optimization tasks
src/d4descent/losses/- Loss functions for various optimization targets_base.py- Base loss function interfaceraster.py- Rasterization-based losses for image targetssds.py- Score Distillation Sampling loss for text-to-shapetopopt.py- Topology optimization losses for structural design
src/d4descent/third_party/- Third-party implementations and utilitiespid.py- PID controller implementationsds.py- SDS-specific utilities and helperstopopt.py- Topology optimization utilities
configs/- YAML configuration files for different experimentslosses/- Loss function configurationstasks/- Task-specific configurations
runs/- Experiment generation and execution scripts_rungen_*.py- Scripts to generate shell scripts for different grammars_generated/- Auto-generated shell scripts for experiments
scripts/- Standalone optimization scripts for specific tasksoptimize_pngs.py- Image-based optimizationoptimize_prompts.py- SDS prompt optimizationoptimize_shc.py- Shape optimization
data/- Input data for experimentsarclines/- Arclines target shapespngs/- Target images for optimization
output/- Results from optimization runs (generated during execution)
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.
You are free to:
- Share — copy and redistribute the material in any medium or format
- Adapt — remix, transform, and build upon the material
Under the following terms:
- Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made.
- NonCommercial — You may not use the material for commercial purposes.