SmartMDAO 1.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. smartmdao-1.1.0/.coverage +0 -0
  2. smartmdao-1.1.0/.gitignore +15 -0
  3. smartmdao-1.1.0/.python-version +1 -0
  4. smartmdao-1.1.0/LICENSE +7 -0
  5. smartmdao-1.1.0/PKG-INFO +138 -0
  6. smartmdao-1.1.0/README.md +123 -0
  7. smartmdao-1.1.0/htmlcov/.gitignore +2 -0
  8. smartmdao-1.1.0/htmlcov/class_index.html +361 -0
  9. smartmdao-1.1.0/htmlcov/coverage_html_cb_dd2e7eb5.js +735 -0
  10. smartmdao-1.1.0/htmlcov/favicon_32_cb_c827f16f.png +0 -0
  11. smartmdao-1.1.0/htmlcov/function_index.html +881 -0
  12. smartmdao-1.1.0/htmlcov/index.html +207 -0
  13. smartmdao-1.1.0/htmlcov/keybd_closed_cb_900cfef5.png +0 -0
  14. smartmdao-1.1.0/htmlcov/status.json +1 -0
  15. smartmdao-1.1.0/htmlcov/style_cb_9ff733b0.css +389 -0
  16. smartmdao-1.1.0/htmlcov/z_1cc922e2ca963af3___init___py.html +121 -0
  17. smartmdao-1.1.0/htmlcov/z_1cc922e2ca963af3_cache_py.html +247 -0
  18. smartmdao-1.1.0/htmlcov/z_1cc922e2ca963af3_core_py.html +171 -0
  19. smartmdao-1.1.0/htmlcov/z_1cc922e2ca963af3_executor_py.html +187 -0
  20. smartmdao-1.1.0/htmlcov/z_1cc922e2ca963af3_logging_config_py.html +139 -0
  21. smartmdao-1.1.0/htmlcov/z_1cc922e2ca963af3_main_py.html +105 -0
  22. smartmdao-1.1.0/htmlcov/z_1cc922e2ca963af3_models_py.html +145 -0
  23. smartmdao-1.1.0/htmlcov/z_1cc922e2ca963af3_optimization_py.html +166 -0
  24. smartmdao-1.1.0/htmlcov/z_1cc922e2ca963af3_solvers_py.html +385 -0
  25. smartmdao-1.1.0/htmlcov/z_1cc922e2ca963af3_utils_py.html +119 -0
  26. smartmdao-1.1.0/htmlcov/z_1cc922e2ca963af3_visualization_py.html +410 -0
  27. smartmdao-1.1.0/htmlcov/z_698b4efdaffa8f63___init___py.html +121 -0
  28. smartmdao-1.1.0/htmlcov/z_698b4efdaffa8f63_cache_py.html +247 -0
  29. smartmdao-1.1.0/htmlcov/z_698b4efdaffa8f63_core_py.html +171 -0
  30. smartmdao-1.1.0/htmlcov/z_698b4efdaffa8f63_executor_py.html +187 -0
  31. smartmdao-1.1.0/htmlcov/z_698b4efdaffa8f63_logging_config_py.html +139 -0
  32. smartmdao-1.1.0/htmlcov/z_698b4efdaffa8f63_main_py.html +105 -0
  33. smartmdao-1.1.0/htmlcov/z_698b4efdaffa8f63_models_py.html +145 -0
  34. smartmdao-1.1.0/htmlcov/z_698b4efdaffa8f63_optimization_py.html +166 -0
  35. smartmdao-1.1.0/htmlcov/z_698b4efdaffa8f63_solvers_py.html +385 -0
  36. smartmdao-1.1.0/htmlcov/z_698b4efdaffa8f63_utils_py.html +119 -0
  37. smartmdao-1.1.0/htmlcov/z_698b4efdaffa8f63_visualization_py.html +410 -0
  38. smartmdao-1.1.0/pyproject.toml +34 -0
  39. smartmdao-1.1.0/pytest.ini +9 -0
  40. smartmdao-1.1.0/run_all.py +54 -0
  41. smartmdao-1.1.0/scripts/adapt_external_functions_with_same_name.py +113 -0
  42. smartmdao-1.1.0/scripts/basic_ml_orchestrator.py +93 -0
  43. smartmdao-1.1.0/scripts/basic_solvers_demo.py +78 -0
  44. smartmdao-1.1.0/scripts/caching_hybrid_solver.py +160 -0
  45. smartmdao-1.1.0/scripts/caching_linear_solver.py +149 -0
  46. smartmdao-1.1.0/scripts/define_pipeline_via_decorators.py +72 -0
  47. smartmdao-1.1.0/scripts/golinsky_benchmark_mdo.py +177 -0
  48. smartmdao-1.1.0/scripts/hs71_benchmark_mdo.py +141 -0
  49. smartmdao-1.1.0/scripts/ideal_pipeline_demo.py +109 -0
  50. smartmdao-1.1.0/scripts/sellar_benchmark_mda.py +88 -0
  51. smartmdao-1.1.0/scripts/sellar_benchmark_mdo_openturns.py +148 -0
  52. smartmdao-1.1.0/scripts/sellar_benchmark_mdo_scripy.py +138 -0
  53. smartmdao-1.1.0/scripts/ssbj_analytical_benchmark_mdo.py +176 -0
  54. smartmdao-1.1.0/scripts/three_level_iterative_solver.py +156 -0
  55. smartmdao-1.1.0/smartmdao/__init__.py +24 -0
  56. smartmdao-1.1.0/smartmdao/cache.py +150 -0
  57. smartmdao-1.1.0/smartmdao/core.py +74 -0
  58. smartmdao-1.1.0/smartmdao/executor.py +90 -0
  59. smartmdao-1.1.0/smartmdao/logging_config.py +42 -0
  60. smartmdao-1.1.0/smartmdao/main.py +8 -0
  61. smartmdao-1.1.0/smartmdao/models.py +48 -0
  62. smartmdao-1.1.0/smartmdao/optimization.py +69 -0
  63. smartmdao-1.1.0/smartmdao/solvers.py +288 -0
  64. smartmdao-1.1.0/smartmdao/utils.py +22 -0
  65. smartmdao-1.1.0/smartmdao/visualization.py +313 -0
  66. smartmdao-1.1.0/tests/__init__.py +0 -0
  67. smartmdao-1.1.0/tests/test_basic.py +7 -0
  68. smartmdao-1.1.0/tests/test_cache.py +54 -0
  69. smartmdao-1.1.0/tests/test_coverage_gap.py +228 -0
  70. smartmdao-1.1.0/tests/test_executor.py +47 -0
  71. smartmdao-1.1.0/tests/test_optimization.py +120 -0
  72. smartmdao-1.1.0/tests/test_pipeline_and_viz.py +31 -0
  73. smartmdao-1.1.0/tests/test_solvers.py +61 -0
  74. smartmdao-1.1.0/uv.lock +1389 -0
Binary file
@@ -0,0 +1,15 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
11
+
12
+ # Custom folders
13
+ results/
14
+ !results/.keep
15
+ .ipynb_checkpoints/
@@ -0,0 +1 @@
1
+ 3.11
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2026 Guilherme Cunha
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,138 @@
1
+ Metadata-Version: 2.4
2
+ Name: SmartMDAO
3
+ Version: 1.1.0
4
+ Summary: Add your description here
5
+ License-File: LICENSE
6
+ Requires-Python: >=3.11
7
+ Requires-Dist: graphviz>=0.21
8
+ Requires-Dist: h5py>=3.15.1
9
+ Requires-Dist: ipykernel>=7.1.0
10
+ Requires-Dist: matplotlib>=3.10.7
11
+ Requires-Dist: numpy>=2.3.5
12
+ Requires-Dist: openturns>=1.27
13
+ Requires-Dist: scipy>=1.17.1
14
+ Description-Content-Type: text/markdown
15
+
16
+ # SmartPipeline 🚀
17
+
18
+ SmartPipeline is a robust, Pythonic framework for building modular computational workflows. It moves beyond simple DAGs (Directed Acyclic Graphs) by supporting automatic dependency injection, cyclic/iterative solving, and integrated caching, all while keeping your code clean and readable using standard Python type hints.
19
+
20
+ Whether you are running linear data processing or highly coupled Multidisciplinary Design Optimization (MDO) problems, SmartPipeline dynamically maps your functions and solves them efficiently.
21
+
22
+ # 🌟 Key Features
23
+
24
+ - **Type-Hint Driven Dependency Injection**: No need to manually define edges. If `Step B` needs a variable `x` and `Step A` returns a variable named `x`, the pipeline connects them automatically.
25
+
26
+ - **We do the MDA, you do the MDO**: We handle the heavy lifting of Multidisciplinary Analysis (MDA) — automatically isolating and converging feedback loops. Because our architecture is completely optimizer-agnostic, you can plug our dynamic evaluator into SciPy, OpenTURNS, PyOptSparse, or any algorithm you prefer.
27
+
28
+ - **Hybrid Solver**: Automatically detects whether your pipeline is linear or contains feedback loops (cycles). It solves linear parts topologically and iterates over cyclic parts until convergence using Tarjan's Algorithm.
29
+
30
+ - **Modular Caching**: Built-in decorators (`@cached`) to cache step results in RAM, HDF5 (for large arrays), or Pickle (for complex objects) with zero boilerplate.
31
+
32
+ - **Visualization**: One-line generation of Graphviz diagrams (Flow charts or Data-Flow diagrams).
33
+
34
+ # 📦 Installation
35
+
36
+ We recommend using `uv` for lightning-fast installation, but standard `pip` works perfectly as well.
37
+
38
+ Using `uv` (Recommended):
39
+
40
+ ``` bash
41
+ uv pip install git+[https://github.com/wghami/SmartMDAO.git](https://github.com/wghami/SmartMDAO.git)
42
+ ```
43
+
44
+ Using standard `pip`:
45
+
46
+ ``` bash
47
+ pip install git+[https://github.com/wghami/SmartMDAO.git](https://github.com/wghami/SmartMDAO.git)
48
+ ```
49
+
50
+ *Note*: The visualization features require the `graphviz` system binary to be installed on your OS.
51
+
52
+ # ⚡ The Agnostic MDO Approach
53
+
54
+ `SmartPipeline` is built to let you define complex physics or engineering problems using pure, readable Python, without being locked into a specific optimization suite.
55
+
56
+ Here is how easily you can solve the classic **Sellar coupled problem** (a 2-discipline feedback loop) and optimize it using SciPy.
57
+
58
+ ``` python
59
+ import math
60
+ from scipy.optimize import minimize
61
+ from smartmdao import Pipeline, HybridSolver
62
+ from smartmdao.optimization import PipelineEvaluator
63
+
64
+ # 1. We handle the heavy lifting: Multidisciplinary Analysis (MDA)
65
+ # The HybridSolver automatically detects the cyclic dependency between y1 and y2!
66
+ pipe = Pipeline(solver=HybridSolver())
67
+
68
+ @pipe.step(outputs=["y1"])
69
+ def discipline_1(z1: float, z2: float, x1: float, y2: float) -> float:
70
+ return (z1 ** 2) + z2 + x1 - (0.2 * y2)
71
+
72
+ @pipe.step(outputs=["y2"])
73
+ def discipline_2(z1: float, z2: float, y1: float) -> float:
74
+ return math.sqrt(abs(y1)) + z1 + z2
75
+
76
+ @pipe.step(outputs=["objective"])
77
+ def compute_objective(x1: float, z2: float, y1: float, y2: float) -> float:
78
+ return (x1 ** 2) + z2 + (y1 ** 2) + math.exp(-y2)
79
+
80
+
81
+ # 2. You choose the optimizer: Agnostic Multidisciplinary Optimization (MDO)
82
+ # Map the optimizer's numeric array to our named design variables
83
+ evaluator = PipelineEvaluator(
84
+ pipeline=pipe,
85
+ design_vars=["z1", "z2", "x1"],
86
+ constants={"y2": 1.0} # Initial guess to kick off the cycle
87
+ )
88
+
89
+ # Pass the dynamically generated objective functions to ANY optimizer (SciPy, OpenTURNS, etc.)
90
+ result = minimize(
91
+ evaluator.get_objective("objective"),
92
+ x0=[1.0, 1.0, 1.0],
93
+ method='SLSQP',
94
+ bounds=[(-10.0, 10.0), (0.0, 10.0), (0.0, 10.0)]
95
+ )
96
+
97
+ print(f"Optimization Success! Objective: {result.fun:.4f}")
98
+ ```
99
+
100
+ The user retains full control over the Pythonic equations, while the `PipelineEvaluator` caches the complex cyclic MDA evaluations so the optimizer can request objectives and constraints independently without performance penalties.
101
+
102
+ # 🛠️ Architecture Overview
103
+
104
+ - `core.py`: The entry point. Manages steps and delegates execution to solvers.
105
+
106
+ - `solvers.py`: The brains.
107
+
108
+ - `DAGSolver`: For standard linear pipelines.
109
+
110
+ - `IterativeSolver`: For fixed-point iteration problems.
111
+
112
+ - `HybridSolver`: Uses Tarjan's Algorithm to decompose graphs into linear and cyclic components dynamically.
113
+
114
+ - `optimization.py`: Contains the stateful `PipelineEvaluator` bridge, providing callable factories for external optimizers.
115
+
116
+ - `executor.py:` Handles argument binding and runtime memory management.
117
+
118
+ - `visualization.py`: Generates high-quality PDF/PNG diagrams of your workflow.
119
+
120
+ # 🚀 Future Improvements & Roadmap
121
+
122
+ To make `SmartPipeline` even better, the following improvements are planned:
123
+
124
+ - **Parallel Execution**: Integrating `asyncio` or `ProcessPoolExecutor` to allow independent branches of the DAG to run in parallel.
125
+
126
+ - **Pydantic Integration**: Replace standard `dataclasses` with Pydantic models for robust runtime data validation and schema generation.
127
+
128
+ - **Checkpointing**: Allow the pipeline to pause and resume from a specific state in case of failure, serializing the entire memory dictionary.
129
+
130
+ - **Web UI**: A lightweight Flask/Streamlit dashboard to visualize pipeline progress and convergence plots in real-time.
131
+
132
+ # 🤝 Contributing
133
+
134
+ Contributions are welcome! Please feel free to submit a Pull Request.
135
+
136
+ # 📄 License
137
+
138
+ This project is licensed under the MIT License - see the [LICENSE](https://github.com/wghami/SmartMDAO/blob/main/LICENSE) file for details.
@@ -0,0 +1,123 @@
1
+ # SmartPipeline 🚀
2
+
3
+ SmartPipeline is a robust, Pythonic framework for building modular computational workflows. It moves beyond simple DAGs (Directed Acyclic Graphs) by supporting automatic dependency injection, cyclic/iterative solving, and integrated caching, all while keeping your code clean and readable using standard Python type hints.
4
+
5
+ Whether you are running linear data processing or highly coupled Multidisciplinary Design Optimization (MDO) problems, SmartPipeline dynamically maps your functions and solves them efficiently.
6
+
7
+ # 🌟 Key Features
8
+
9
+ - **Type-Hint Driven Dependency Injection**: No need to manually define edges. If `Step B` needs a variable `x` and `Step A` returns a variable named `x`, the pipeline connects them automatically.
10
+
11
+ - **We do the MDA, you do the MDO**: We handle the heavy lifting of Multidisciplinary Analysis (MDA) — automatically isolating and converging feedback loops. Because our architecture is completely optimizer-agnostic, you can plug our dynamic evaluator into SciPy, OpenTURNS, PyOptSparse, or any algorithm you prefer.
12
+
13
+ - **Hybrid Solver**: Automatically detects whether your pipeline is linear or contains feedback loops (cycles). It solves linear parts topologically and iterates over cyclic parts until convergence using Tarjan's Algorithm.
14
+
15
+ - **Modular Caching**: Built-in decorators (`@cached`) to cache step results in RAM, HDF5 (for large arrays), or Pickle (for complex objects) with zero boilerplate.
16
+
17
+ - **Visualization**: One-line generation of Graphviz diagrams (Flow charts or Data-Flow diagrams).
18
+
19
+ # 📦 Installation
20
+
21
+ We recommend using `uv` for lightning-fast installation, but standard `pip` works perfectly as well.
22
+
23
+ Using `uv` (Recommended):
24
+
25
+ ``` bash
26
+ uv pip install git+[https://github.com/wghami/SmartMDAO.git](https://github.com/wghami/SmartMDAO.git)
27
+ ```
28
+
29
+ Using standard `pip`:
30
+
31
+ ``` bash
32
+ pip install git+[https://github.com/wghami/SmartMDAO.git](https://github.com/wghami/SmartMDAO.git)
33
+ ```
34
+
35
+ *Note*: The visualization features require the `graphviz` system binary to be installed on your OS.
36
+
37
+ # ⚡ The Agnostic MDO Approach
38
+
39
+ `SmartPipeline` is built to let you define complex physics or engineering problems using pure, readable Python, without being locked into a specific optimization suite.
40
+
41
+ Here is how easily you can solve the classic **Sellar coupled problem** (a 2-discipline feedback loop) and optimize it using SciPy.
42
+
43
+ ``` python
44
+ import math
45
+ from scipy.optimize import minimize
46
+ from smartmdao import Pipeline, HybridSolver
47
+ from smartmdao.optimization import PipelineEvaluator
48
+
49
+ # 1. We handle the heavy lifting: Multidisciplinary Analysis (MDA)
50
+ # The HybridSolver automatically detects the cyclic dependency between y1 and y2!
51
+ pipe = Pipeline(solver=HybridSolver())
52
+
53
+ @pipe.step(outputs=["y1"])
54
+ def discipline_1(z1: float, z2: float, x1: float, y2: float) -> float:
55
+ return (z1 ** 2) + z2 + x1 - (0.2 * y2)
56
+
57
+ @pipe.step(outputs=["y2"])
58
+ def discipline_2(z1: float, z2: float, y1: float) -> float:
59
+ return math.sqrt(abs(y1)) + z1 + z2
60
+
61
+ @pipe.step(outputs=["objective"])
62
+ def compute_objective(x1: float, z2: float, y1: float, y2: float) -> float:
63
+ return (x1 ** 2) + z2 + (y1 ** 2) + math.exp(-y2)
64
+
65
+
66
+ # 2. You choose the optimizer: Agnostic Multidisciplinary Optimization (MDO)
67
+ # Map the optimizer's numeric array to our named design variables
68
+ evaluator = PipelineEvaluator(
69
+ pipeline=pipe,
70
+ design_vars=["z1", "z2", "x1"],
71
+ constants={"y2": 1.0} # Initial guess to kick off the cycle
72
+ )
73
+
74
+ # Pass the dynamically generated objective functions to ANY optimizer (SciPy, OpenTURNS, etc.)
75
+ result = minimize(
76
+ evaluator.get_objective("objective"),
77
+ x0=[1.0, 1.0, 1.0],
78
+ method='SLSQP',
79
+ bounds=[(-10.0, 10.0), (0.0, 10.0), (0.0, 10.0)]
80
+ )
81
+
82
+ print(f"Optimization Success! Objective: {result.fun:.4f}")
83
+ ```
84
+
85
+ The user retains full control over the Pythonic equations, while the `PipelineEvaluator` caches the complex cyclic MDA evaluations so the optimizer can request objectives and constraints independently without performance penalties.
86
+
87
+ # 🛠️ Architecture Overview
88
+
89
+ - `core.py`: The entry point. Manages steps and delegates execution to solvers.
90
+
91
+ - `solvers.py`: The brains.
92
+
93
+ - `DAGSolver`: For standard linear pipelines.
94
+
95
+ - `IterativeSolver`: For fixed-point iteration problems.
96
+
97
+ - `HybridSolver`: Uses Tarjan's Algorithm to decompose graphs into linear and cyclic components dynamically.
98
+
99
+ - `optimization.py`: Contains the stateful `PipelineEvaluator` bridge, providing callable factories for external optimizers.
100
+
101
+ - `executor.py:` Handles argument binding and runtime memory management.
102
+
103
+ - `visualization.py`: Generates high-quality PDF/PNG diagrams of your workflow.
104
+
105
+ # 🚀 Future Improvements & Roadmap
106
+
107
+ To make `SmartPipeline` even better, the following improvements are planned:
108
+
109
+ - **Parallel Execution**: Integrating `asyncio` or `ProcessPoolExecutor` to allow independent branches of the DAG to run in parallel.
110
+
111
+ - **Pydantic Integration**: Replace standard `dataclasses` with Pydantic models for robust runtime data validation and schema generation.
112
+
113
+ - **Checkpointing**: Allow the pipeline to pause and resume from a specific state in case of failure, serializing the entire memory dictionary.
114
+
115
+ - **Web UI**: A lightweight Flask/Streamlit dashboard to visualize pipeline progress and convergence plots in real-time.
116
+
117
+ # 🤝 Contributing
118
+
119
+ Contributions are welcome! Please feel free to submit a Pull Request.
120
+
121
+ # 📄 License
122
+
123
+ This project is licensed under the MIT License - see the [LICENSE](https://github.com/wghami/SmartMDAO/blob/main/LICENSE) file for details.
@@ -0,0 +1,2 @@
1
+ # Created by coverage.py
2
+ *