A Python script for adaptive layout optimization of trusses

Linwei He, Matthew Gilbert, Xingyi SongStructural 2019

Abstract: Numerical layout optimization employing an adaptive ‘member adding’ solution scheme provides a computationally efficient means of generating (near-)optimum trusses for problems involving single or multiple load cases. To encourage usage of the method, a Python script is presented, allowing medium to large-scale problems to be solved efficiently. As well as handling multiple load cases, the short (98 line) script presented can tackle truss optimization problems involving unequal limiting tensile and compressive stresses, joint costs, and non-convex polygonal domains, with or without holes. Various numerical examples are used to demonstrate the efficacy of the script presented.

The Challenge of Structural Layout Optimization

In structural engineering, layout optimization aims to find the most efficient arrangement of bars (trusses) to support a given load within a defined design space. The traditional "ground structure" approach involves filling this space with nodes and connecting every possible pair with a potential bar.

However, this approach faces a significant scalability hurdle. As the number of nodes increases to improve design resolution, the number of potential bars grows quadratically ($O(n^2)$). A high-resolution grid can result in billions of potential members, creating a massive Linear Programming (LP) problem that quickly exhausts standard computer memory. Consequently, while powerful, this method has remained under-utilized because available educational tools often lacked the sophisticated algorithms needed to handle realistic, large-scale problems.

Figure 1: The four-step process of layout optimization: (a) defining the domain and loads, (b) nodal discretization, (c) generating the full ground structure, and (d) identifying the optimal layout.

An Adaptive "Member Adding" Solution

To overcome these limitations, the authors introduce a remarkably concise, 98-line Python script that utilizes an "adaptive member adding" scheme—a structural engineering application of column generation in optimization.

Instead of solving the entire massive problem at once, the script follows an iterative process:

  1. Initial Setup: It begins with a sparse ground structure containing only a small subset of short, adjacent members.
  2. Optimization: It solves a reduced LP problem to find the optimal volume for this small set.
  3. Dual Violation Check: Using duality theory, the script calculates the "virtual strain" across all potential members not currently in the model. If any member violates the optimality criteria (indicating it could improve the design), it is added to the set.
  4. Iteration: The process repeats until no more violations are found, guaranteeing a globally optimal solution for the given nodal grid.

The script leverages modern Python libraries like cvxpy for convex optimization, shapely for handling complex geometric boundaries, and numpy/scipy for high-performance matrix operations.

Key Insights and Results

Duality as a Scouting Tool

The core innovation is the use of dual variables (nodal displacements) to mathematically "scout" excluded bars. This allows the script to identify and invite only the members that will actually improve the structural efficiency, avoiding the need to load the entire ground structure into memory.

Practicality through Joint Costs

Pure optimization often produces "fractal-like" structures with thousands of tiny bars that are impossible to manufacture. The script includes a "joint cost" parameter that penalizes the number of connections, leading to simpler, more practical designs that are easier to build.

Performance Benchmarks

The script was validated using classic structural engineering benchmarks, such as the Michell Cantilever and non-convex domains with holes. Key performance metrics include:

  • Efficiency: For a $60 \times 30$ nodal grid, the adaptive scheme was 8.2 times faster than solving the full problem at once.
  • Scalability: When paired with a high-performance solver like MOSEK, the script solved a problem with 125 million potential members in approximately 1.9 hours on a standard laptop.
  • Accuracy: Numerical results for a standard cantilever were within 0.04% of the known theoretical analytical solution.

Limitations and Future Work

While highly efficient, the current script is limited to two-dimensional problems. Extending the logic to 3D would introduce significant geometric complexity and visualization challenges. Additionally, the formulation focuses on "plastic" design (stress limits and equilibrium) and does not explicitly account for buckling (elastic stability), which is a critical failure mode for long, slender compressive members. Finally, while the script works with open-source solvers like ECOS, its full potential for extremely large-scale problems is best realized using commercial solvers like MOSEK or GUROBI.

Summary updated

BibTeX
@inproceedings{he2019python,
  author = {Linwei He and Matthew Gilbert and Xingyi Song},
  title = {{A Python script for adaptive layout optimization of trusses}},
  booktitle = {Structural},
  year = {2019},
  doi = {10.1007/s00158-019-02226-6},
}
Figure