Space Truss Span Mass Min

Source: examples/optimization/space_truss_span_mass_min.py

Introduction

Solve the packaged 3D space-truss mass-minimization benchmark.

Technical Implementation

This page is generated from the top-of-file module docstring and the example source code. The full script is included below for direct inspection.

 1from __future__ import annotations
 2
 3import warnings
 4
 5import design_research_problems as derp
 6from design_research_problems.problems._domains.space_truss import evaluate_space_truss_state
 7
 8
 9def main() -> None:
10    """Run the built-in structural baseline for the 3D space-truss optimizer."""
11    problem = derp.get_problem("space_truss_span_mass_min")
12    initial = problem.generate_initial_solution()
13    print(problem.metadata.problem_id)
14    print("variables", initial.shape[0])
15    try:
16        with warnings.catch_warnings():
17            warnings.filterwarnings("ignore", category=RuntimeWarning, module=r"trussme\\.components")
18            initial_evaluation = problem.evaluate(initial)
19            result = problem.solve(maxiter=64)
20            final_state = problem.decode_candidate(result.x)
21            structural = evaluate_space_truss_state(final_state)
22    except derp.MissingOptionalDependencyError as exc:
23        print(exc)
24        return
25    print("initial", round(initial_evaluation.objective_value, 3), initial_evaluation.is_feasible)
26    print("members", len(final_state.members))
27    print("mass", round(structural.mass, 3))
28    print("fos", round(structural.fos, 3))
29    print("deflection", round(structural.deflection, 3))
30    print("solve", bool(result.success))
31
32
33if __name__ == "__main__":
34    main()

Expected Results

Run Command

PYTHONPATH=src python3 examples/optimization/space_truss_span_mass_min.py

Run the command shown below from repository root. Output should summarize the problem setup, a baseline solution, or diagnostic values relevant to this example.