Truss Analysis Program Design
Source: examples/grammar/truss_analysis_program_design.py
Introduction
Build and evaluate a truss design using Truss Analysis Program mechanics.
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 design_research_problems as derp
4
5
6def main() -> None:
7 """Create a feasible truss and print key evaluation metrics."""
8 problem = derp.get_problem("truss_analysis_program_design")
9 state = problem.initial_state()
10
11 state = problem.add_joint(state, x=-3.446939, y=1.847708)
12 state = problem.add_joint(state, x=-0.410204, y=1.835182)
13 state = problem.add_joint(state, x=2.834694, y=1.860235)
14
15 for start_joint_id, end_joint_id in (
16 (1, 4),
17 (4, 2),
18 (2, 5),
19 (5, 3),
20 (1, 6),
21 (6, 4),
22 (4, 7),
23 (7, 2),
24 (2, 8),
25 (8, 5),
26 (6, 7),
27 (7, 8),
28 ):
29 state = problem.add_member(state, start_joint_id=start_joint_id, end_joint_id=end_joint_id, size_index=8)
30
31 evaluation = problem.evaluate(state)
32 print(problem.metadata.problem_id)
33 print("joint-count", evaluation.joint_count)
34 print("member-count", evaluation.member_count)
35 print("mass-kg", round(evaluation.mass_kg, 3))
36 print("min-fos", round(evaluation.min_fos, 3))
37 print("is-stable", evaluation.is_stable)
38 print("is-acceptable", evaluation.is_acceptable)
39
40
41if __name__ == "__main__":
42 main()
Expected Results
Run Command
PYTHONPATH=src python3 examples/grammar/truss_analysis_program_design.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.