adasurrog 0.5.1__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.
- adasurrog-0.5.1/.gitignore +9 -0
- adasurrog-0.5.1/CHANGELOG.md +53 -0
- adasurrog-0.5.1/CITATION.cff +15 -0
- adasurrog-0.5.1/CONTRIBUTING.md +32 -0
- adasurrog-0.5.1/LICENSE +21 -0
- adasurrog-0.5.1/PKG-INFO +358 -0
- adasurrog-0.5.1/PUBLISHING.md +66 -0
- adasurrog-0.5.1/README.md +289 -0
- adasurrog-0.5.1/SECURITY.md +9 -0
- adasurrog-0.5.1/examples/custom_problem.py +28 -0
- adasurrog-0.5.1/examples/plot_gene_feedback_active_learning.py +4 -0
- adasurrog-0.5.1/examples/plot_gene_feedback_checkpoints.py +4 -0
- adasurrog-0.5.1/examples/plot_legacy_gene_feedback_checkpoints.py +277 -0
- adasurrog-0.5.1/examples/train_gene_feedback_active.py +4 -0
- adasurrog-0.5.1/examples/train_gene_feedback_pod.py +4 -0
- adasurrog-0.5.1/examples/train_gene_feedback_precision.py +4 -0
- adasurrog-0.5.1/examples/universal/brusselator.yaml +18 -0
- adasurrog-0.5.1/examples/universal/custom_problem.yaml +16 -0
- adasurrog-0.5.1/examples/universal/lotka_volterra.yaml +22 -0
- adasurrog-0.5.1/examples/universal/robertson.yaml +30 -0
- adasurrog-0.5.1/examples/universal/seir.yaml +18 -0
- adasurrog-0.5.1/pyproject.toml +118 -0
- adasurrog-0.5.1/src/adasurrog/__about__.py +3 -0
- adasurrog-0.5.1/src/adasurrog/__init__.py +111 -0
- adasurrog-0.5.1/src/adasurrog/active_learning.py +287 -0
- adasurrog-0.5.1/src/adasurrog/auto_transforms.py +140 -0
- adasurrog-0.5.1/src/adasurrog/benchmarks/__init__.py +186 -0
- adasurrog-0.5.1/src/adasurrog/checkpoint.py +159 -0
- adasurrog-0.5.1/src/adasurrog/cli.py +99 -0
- adasurrog-0.5.1/src/adasurrog/config.py +76 -0
- adasurrog-0.5.1/src/adasurrog/examples/__init__.py +0 -0
- adasurrog-0.5.1/src/adasurrog/examples/gene_feedback_active.py +826 -0
- adasurrog-0.5.1/src/adasurrog/examples/gene_feedback_common.py +263 -0
- adasurrog-0.5.1/src/adasurrog/examples/gene_feedback_ode.py +240 -0
- adasurrog-0.5.1/src/adasurrog/examples/gene_feedback_precision.py +692 -0
- adasurrog-0.5.1/src/adasurrog/examples/plot_gene_feedback_active_learning.py +85 -0
- adasurrog-0.5.1/src/adasurrog/examples/plot_gene_feedback_checkpoints.py +206 -0
- adasurrog-0.5.1/src/adasurrog/metrics.py +16 -0
- adasurrog-0.5.1/src/adasurrog/models/__init__.py +27 -0
- adasurrog-0.5.1/src/adasurrog/models/pod.py +646 -0
- adasurrog-0.5.1/src/adasurrog/ode_data.py +295 -0
- adasurrog-0.5.1/src/adasurrog/pipeline.py +697 -0
- adasurrog-0.5.1/src/adasurrog/problem.py +116 -0
- adasurrog-0.5.1/src/adasurrog/progress.py +82 -0
- adasurrog-0.5.1/src/adasurrog/py.typed +0 -0
- adasurrog-0.5.1/src/adasurrog/refinement.py +350 -0
- adasurrog-0.5.1/src/adasurrog/state.py +67 -0
- adasurrog-0.5.1/src/adasurrog/trainer.py +308 -0
- adasurrog-0.5.1/src/adasurrog/transforms.py +30 -0
- adasurrog-0.5.1/src/adasurrog/universal_cli.py +133 -0
- adasurrog-0.5.1/src/adasurrog/universal_model.py +192 -0
- adasurrog-0.5.1/tests/conftest.py +17 -0
- adasurrog-0.5.1/tests/test_active_learning.py +86 -0
- adasurrog-0.5.1/tests/test_checkpoint.py +15 -0
- adasurrog-0.5.1/tests/test_package.py +22 -0
- adasurrog-0.5.1/tests/test_pod.py +33 -0
- adasurrog-0.5.1/tests/test_precision.py +110 -0
- adasurrog-0.5.1/tests/test_trainer.py +41 -0
- adasurrog-0.5.1/tests/test_universal.py +102 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to AdaSurroG are documented here.
|
|
4
|
+
|
|
5
|
+
## 0.5.1 — 2026-07-14
|
|
6
|
+
|
|
7
|
+
### Packaging
|
|
8
|
+
|
|
9
|
+
- prepared a release-ready PyPI project with centralized version metadata;
|
|
10
|
+
- replaced placeholder author and license metadata;
|
|
11
|
+
- added the `py.typed` marker for typed-package discovery;
|
|
12
|
+
- added formal installation, publishing, citation, contribution, and security documentation;
|
|
13
|
+
- added `adasurrog --version` and `adasurrog info` commands;
|
|
14
|
+
- retained legacy example entry points while documenting the universal pipeline as the default.
|
|
15
|
+
|
|
16
|
+
### Validation
|
|
17
|
+
|
|
18
|
+
- added package metadata and CLI tests;
|
|
19
|
+
- verified wheel and source-distribution construction;
|
|
20
|
+
- verified package installation and command-line entry points from the built wheel.
|
|
21
|
+
|
|
22
|
+
## 0.5.0 — 2026-07-14
|
|
23
|
+
|
|
24
|
+
- introduced `ODEProblem` and the universal fixed-data ODE pipeline;
|
|
25
|
+
- added pilot diagnostics, automatic mixed state transforms, adaptive output-time selection,
|
|
26
|
+
automatic POD rank selection, weighted-POD comparison, automatic polynomial selection, and
|
|
27
|
+
automatic residual-network sizing;
|
|
28
|
+
- added unified checkpoint loading through `AdaSurrogate`;
|
|
29
|
+
- added Robertson, Lotka–Volterra, Brusselator, and SEIR benchmarks;
|
|
30
|
+
- reused pilot trajectories in the fixed training design.
|
|
31
|
+
|
|
32
|
+
## 0.4.1 — 2026-07-14
|
|
33
|
+
|
|
34
|
+
- fixed MPS-to-CPU float64 model transfer for L-BFGS refinement;
|
|
35
|
+
- separated the AdamW handoff target from the final refinement target.
|
|
36
|
+
|
|
37
|
+
## 0.4.0 — 2026-07-14
|
|
38
|
+
|
|
39
|
+
- added polynomial-backbone plus residual-network coefficient regression;
|
|
40
|
+
- added float64 full-batch L-BFGS refinement and high-precision diagnostics.
|
|
41
|
+
|
|
42
|
+
## 0.3.0 — 2026-07-14
|
|
43
|
+
|
|
44
|
+
- added an experimental pool-based active-learning workflow.
|
|
45
|
+
|
|
46
|
+
## 0.2.0 — 2026-07-14
|
|
47
|
+
|
|
48
|
+
- introduced POD coefficient surrogates and multi-condition checkpoint plotting.
|
|
49
|
+
|
|
50
|
+
## 0.1.0 — 2026-07-14
|
|
51
|
+
|
|
52
|
+
- introduced time/accuracy-bounded training, progress reporting, resumable checkpoints, and
|
|
53
|
+
generic PyTorch train/evaluation callbacks.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
message: "If you use AdaSurroG in research, please cite the software release."
|
|
3
|
+
title: "AdaSurroG: Automatic high-precision surrogate modeling for parameterized ODE systems"
|
|
4
|
+
type: software
|
|
5
|
+
authors:
|
|
6
|
+
- name: "AdaSurroG Developers"
|
|
7
|
+
version: 0.5.1
|
|
8
|
+
date-released: 2026-07-14
|
|
9
|
+
license: MIT
|
|
10
|
+
keywords:
|
|
11
|
+
- surrogate modeling
|
|
12
|
+
- ordinary differential equations
|
|
13
|
+
- proper orthogonal decomposition
|
|
14
|
+
- scientific machine learning
|
|
15
|
+
- systems biology
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
## Development setup
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
python -m venv .venv
|
|
7
|
+
source .venv/bin/activate
|
|
8
|
+
python -m pip install -e ".[dev]"
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quality checks
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
ruff check .
|
|
15
|
+
ruff format --check .
|
|
16
|
+
pytest
|
|
17
|
+
python -m build
|
|
18
|
+
python -m twine check dist/*
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Contributions should preserve the fixed-data universal pipeline as the stable default. Experimental
|
|
22
|
+
training strategies should remain opt-in and should include fixed validation/test comparisons.
|
|
23
|
+
|
|
24
|
+
New ODE benchmarks should:
|
|
25
|
+
|
|
26
|
+
- implement the public `ODEProblem` interface;
|
|
27
|
+
- use deterministic parameter bounds and initial conditions;
|
|
28
|
+
- include a state Jacobian when practical;
|
|
29
|
+
- include tests that verify finite right-hand-side and Jacobian evaluations;
|
|
30
|
+
- document the numerical behavior the benchmark is intended to exercise.
|
|
31
|
+
|
|
32
|
+
Public API changes should update `README.md`, `CHANGELOG.md`, type annotations, and tests.
|
adasurrog-0.5.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AdaSurroG Developers
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
adasurrog-0.5.1/PKG-INFO
ADDED
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: adasurrog
|
|
3
|
+
Version: 0.5.1
|
|
4
|
+
Summary: Automatic high-precision surrogate modeling for parameterized ODE systems.
|
|
5
|
+
Author: AdaSurroG Developers
|
|
6
|
+
Maintainer: AdaSurroG Developers
|
|
7
|
+
License: MIT License
|
|
8
|
+
|
|
9
|
+
Copyright (c) 2026 AdaSurroG Developers
|
|
10
|
+
|
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
in the Software without restriction, including without limitation the rights
|
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
furnished to do so, subject to the following conditions:
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be included in all
|
|
19
|
+
copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
SOFTWARE.
|
|
28
|
+
License-File: LICENSE
|
|
29
|
+
Keywords: ordinary-differential-equations,proper-orthogonal-decomposition,pytorch,reduced-order-modeling,scientific-machine-learning,surrogate-model,systems-biology
|
|
30
|
+
Classifier: Development Status :: 4 - Beta
|
|
31
|
+
Classifier: Intended Audience :: Science/Research
|
|
32
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
33
|
+
Classifier: Operating System :: OS Independent
|
|
34
|
+
Classifier: Programming Language :: Python :: 3
|
|
35
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
39
|
+
Classifier: Topic :: Scientific/Engineering
|
|
40
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
41
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
42
|
+
Classifier: Typing :: Typed
|
|
43
|
+
Requires-Python: >=3.10
|
|
44
|
+
Requires-Dist: numpy>=1.24
|
|
45
|
+
Requires-Dist: rich>=13.7
|
|
46
|
+
Requires-Dist: torch>=2.1
|
|
47
|
+
Provides-Extra: all
|
|
48
|
+
Requires-Dist: matplotlib>=3.8; extra == 'all'
|
|
49
|
+
Requires-Dist: pyyaml>=6.0; extra == 'all'
|
|
50
|
+
Requires-Dist: scipy>=1.11; extra == 'all'
|
|
51
|
+
Provides-Extra: dev
|
|
52
|
+
Requires-Dist: build>=1.2; extra == 'dev'
|
|
53
|
+
Requires-Dist: matplotlib>=3.8; extra == 'dev'
|
|
54
|
+
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
|
|
55
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
56
|
+
Requires-Dist: pyyaml>=6.0; extra == 'dev'
|
|
57
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
58
|
+
Requires-Dist: scipy>=1.11; extra == 'dev'
|
|
59
|
+
Requires-Dist: twine>=5.1; extra == 'dev'
|
|
60
|
+
Provides-Extra: ode
|
|
61
|
+
Requires-Dist: scipy>=1.11; extra == 'ode'
|
|
62
|
+
Provides-Extra: plot
|
|
63
|
+
Requires-Dist: matplotlib>=3.8; extra == 'plot'
|
|
64
|
+
Requires-Dist: scipy>=1.11; extra == 'plot'
|
|
65
|
+
Provides-Extra: universal
|
|
66
|
+
Requires-Dist: pyyaml>=6.0; extra == 'universal'
|
|
67
|
+
Requires-Dist: scipy>=1.11; extra == 'universal'
|
|
68
|
+
Description-Content-Type: text/markdown
|
|
69
|
+
|
|
70
|
+
# AdaSurroG
|
|
71
|
+
|
|
72
|
+
AdaSurroG trains fast, differentiable surrogate models for parameterized ordinary
|
|
73
|
+
differential equation systems. It is designed for repeated-query scientific workflows such as
|
|
74
|
+
parameter studies, uncertainty quantification, optimization, and systems-biology simulation.
|
|
75
|
+
|
|
76
|
+
The default high-precision pipeline uses a fixed high-fidelity dataset and combines:
|
|
77
|
+
|
|
78
|
+
- automatic state transforms for multiscale variables;
|
|
79
|
+
- adaptive fixed output-time selection from pilot trajectories;
|
|
80
|
+
- proper orthogonal decomposition (POD) trajectory compression;
|
|
81
|
+
- a Chebyshev polynomial coefficient backbone;
|
|
82
|
+
- a residual PyTorch network;
|
|
83
|
+
- time/accuracy-bounded AdamW training;
|
|
84
|
+
- deterministic CPU float64 full-batch L-BFGS refinement;
|
|
85
|
+
- resumable atomic checkpoints and explicit accuracy diagnostics.
|
|
86
|
+
|
|
87
|
+
AdaSurroG trains one surrogate per mechanistic ODE model. The pipeline is generic: users provide
|
|
88
|
+
the ODE definition, parameter bounds, initial conditions, and time interval rather than manually
|
|
89
|
+
designing a new neural architecture for each model.
|
|
90
|
+
|
|
91
|
+
## Installation
|
|
92
|
+
|
|
93
|
+
Install the universal ODE pipeline:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
python -m pip install "adasurrog[universal]"
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Install plotting utilities and all runtime extras:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
python -m pip install "adasurrog[all]"
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
For development from a source checkout:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
python -m pip install -e ".[dev]"
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Python 3.10–3.13 is supported. PyTorch is a required dependency. SciPy is required for generating
|
|
112
|
+
ODE reference trajectories, and PyYAML is required for YAML-based training configurations.
|
|
113
|
+
|
|
114
|
+
## Quick start: built-in benchmark
|
|
115
|
+
|
|
116
|
+
List the included benchmark models:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
adasurrog-benchmark --list
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Train a surrogate for the SEIR benchmark:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
adasurrog-benchmark \
|
|
126
|
+
--problem seir \
|
|
127
|
+
--train 192 \
|
|
128
|
+
--validation 48 \
|
|
129
|
+
--test 48 \
|
|
130
|
+
--target-rmse 0.002 \
|
|
131
|
+
--training-seconds 900 \
|
|
132
|
+
--lbfgs-seconds 300
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
The pipeline writes its dataset, checkpoints, pilot diagnostics, and final certification report
|
|
136
|
+
under the selected run directory.
|
|
137
|
+
|
|
138
|
+
## YAML training
|
|
139
|
+
|
|
140
|
+
```yaml
|
|
141
|
+
problem:
|
|
142
|
+
factory: benchmark:seir
|
|
143
|
+
|
|
144
|
+
sampling:
|
|
145
|
+
pilot_trajectories: 24
|
|
146
|
+
train_trajectories: 192
|
|
147
|
+
validation_trajectories: 48
|
|
148
|
+
test_trajectories: 48
|
|
149
|
+
time_points: 128
|
|
150
|
+
seed: 17
|
|
151
|
+
|
|
152
|
+
accuracy:
|
|
153
|
+
target_rmse: 0.002
|
|
154
|
+
target_p99: 0.01
|
|
155
|
+
pod_floor_fraction: 0.30
|
|
156
|
+
|
|
157
|
+
budget:
|
|
158
|
+
training_seconds: 900
|
|
159
|
+
lbfgs_seconds: 300
|
|
160
|
+
|
|
161
|
+
surrogate:
|
|
162
|
+
weighted_pod: auto
|
|
163
|
+
rank_candidates: [4, 8, 12, 16, 24, 32, 48, 64]
|
|
164
|
+
polynomial_degrees: [1, 2, 3, 4]
|
|
165
|
+
|
|
166
|
+
runtime:
|
|
167
|
+
run_directory: runs/universal_seir
|
|
168
|
+
device: mps
|
|
169
|
+
lbfgs_device: cpu
|
|
170
|
+
resume: auto
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Run it with:
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
adasurrog-train examples/universal/seir.yaml
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
On Apple Silicon, AdamW may run on MPS while float64 L-BFGS runs on CPU.
|
|
180
|
+
|
|
181
|
+
## Define a custom ODE problem
|
|
182
|
+
|
|
183
|
+
```python
|
|
184
|
+
import numpy as np
|
|
185
|
+
|
|
186
|
+
from adasurrog import ODEProblem
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def create_problem() -> ODEProblem:
|
|
190
|
+
def rhs(time, state, parameters):
|
|
191
|
+
del time
|
|
192
|
+
production, degradation = parameters
|
|
193
|
+
return np.array([production - degradation * state[0]])
|
|
194
|
+
|
|
195
|
+
def jacobian_state(time, state, parameters):
|
|
196
|
+
del time, state
|
|
197
|
+
return np.array([[-parameters[1]]])
|
|
198
|
+
|
|
199
|
+
return ODEProblem(
|
|
200
|
+
name="production_degradation",
|
|
201
|
+
state_names=("concentration",),
|
|
202
|
+
parameter_names=("production", "degradation"),
|
|
203
|
+
parameter_lower=np.array([0.1, 0.05]),
|
|
204
|
+
parameter_upper=np.array([10.0, 2.0]),
|
|
205
|
+
time_span=(0.0, 20.0),
|
|
206
|
+
rhs_function=rhs,
|
|
207
|
+
initial_condition_function=lambda parameters: np.array([0.0]),
|
|
208
|
+
jacobian_state_function=jacobian_state,
|
|
209
|
+
)
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Reference the factory from YAML:
|
|
213
|
+
|
|
214
|
+
```yaml
|
|
215
|
+
problem:
|
|
216
|
+
factory: my_models.production_degradation:create_problem
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Parameters currently require strictly positive lower bounds because the default pipeline uses a
|
|
220
|
+
normalized log-parameter box.
|
|
221
|
+
|
|
222
|
+
## Python API
|
|
223
|
+
|
|
224
|
+
```python
|
|
225
|
+
from pathlib import Path
|
|
226
|
+
|
|
227
|
+
from adasurrog import (
|
|
228
|
+
AccuracyConfig,
|
|
229
|
+
AutoPipelineConfig,
|
|
230
|
+
BudgetConfig,
|
|
231
|
+
SamplingConfig,
|
|
232
|
+
UniversalODEPipeline,
|
|
233
|
+
)
|
|
234
|
+
from my_models.production_degradation import create_problem
|
|
235
|
+
|
|
236
|
+
config = AutoPipelineConfig(
|
|
237
|
+
sampling=SamplingConfig(
|
|
238
|
+
pilot_trajectories=16,
|
|
239
|
+
train_trajectories=128,
|
|
240
|
+
validation_trajectories=32,
|
|
241
|
+
test_trajectories=32,
|
|
242
|
+
time_points=96,
|
|
243
|
+
),
|
|
244
|
+
accuracy=AccuracyConfig(target_rmse=1e-3),
|
|
245
|
+
budget=BudgetConfig(training_seconds=600, lbfgs_seconds=180),
|
|
246
|
+
run_directory=Path("runs/production_degradation"),
|
|
247
|
+
)
|
|
248
|
+
|
|
249
|
+
surrogate, report = UniversalODEPipeline(create_problem(), config).fit()
|
|
250
|
+
print(report.status, report.validation_rmse, report.test_rmse)
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## Load and query a trained surrogate
|
|
254
|
+
|
|
255
|
+
```python
|
|
256
|
+
import numpy as np
|
|
257
|
+
|
|
258
|
+
from adasurrog import AdaSurrogate
|
|
259
|
+
|
|
260
|
+
surrogate = AdaSurrogate.load(
|
|
261
|
+
"runs/production_degradation/checkpoints/universal_best.pt",
|
|
262
|
+
device="cpu",
|
|
263
|
+
)
|
|
264
|
+
|
|
265
|
+
trajectory = surrogate.predict(
|
|
266
|
+
parameters=np.array([2.0, 0.4]),
|
|
267
|
+
)
|
|
268
|
+
|
|
269
|
+
selected_times = surrogate.predict(
|
|
270
|
+
parameters=np.array([2.0, 0.4]),
|
|
271
|
+
time=np.linspace(0.0, 20.0, 50),
|
|
272
|
+
)
|
|
273
|
+
|
|
274
|
+
check = surrogate.check_domain(np.array([2.0, 0.4]))
|
|
275
|
+
print(check.inside)
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
Physical query times are accepted directly. A checkpoint contains the POD representation,
|
|
279
|
+
coefficient model, state transforms, parameter domain, time grid, and training report; the
|
|
280
|
+
original training dataset is not required for inference.
|
|
281
|
+
|
|
282
|
+
## Stopping and checkpoint behavior
|
|
283
|
+
|
|
284
|
+
Training is controlled by a validation target and a cumulative wall-clock budget instead of a
|
|
285
|
+
fixed epoch count. Checkpoints preserve model, optimizer, scheduler, AMP scaler, training state,
|
|
286
|
+
and random-number-generator state.
|
|
287
|
+
|
|
288
|
+
Typical outputs include:
|
|
289
|
+
|
|
290
|
+
```text
|
|
291
|
+
runs/<problem>/
|
|
292
|
+
├── data/fixed_dataset.npz
|
|
293
|
+
├── pilot_diagnostics.json
|
|
294
|
+
├── universal_diagnostics.json
|
|
295
|
+
└── checkpoints/
|
|
296
|
+
├── best.pt
|
|
297
|
+
├── latest.pt
|
|
298
|
+
├── lbfgs_best.pt
|
|
299
|
+
├── lbfgs_latest.pt
|
|
300
|
+
└── universal_best.pt
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
Use `resume: auto` to continue from the most recent compatible checkpoint.
|
|
304
|
+
|
|
305
|
+
Inspect a checkpoint:
|
|
306
|
+
|
|
307
|
+
```bash
|
|
308
|
+
adasurrog checkpoint-info runs/my_model/checkpoints/universal_best.pt
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
Inspect the installed environment:
|
|
312
|
+
|
|
313
|
+
```bash
|
|
314
|
+
adasurrog info
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
## Accuracy diagnostics
|
|
318
|
+
|
|
319
|
+
The final report classifies a run as one of:
|
|
320
|
+
|
|
321
|
+
- `certified`;
|
|
322
|
+
- `representation_limited`;
|
|
323
|
+
- `regression_limited`;
|
|
324
|
+
- `data_limited`;
|
|
325
|
+
- `optimization_limited`;
|
|
326
|
+
- `tail_error_limited`.
|
|
327
|
+
|
|
328
|
+
The report includes the validation and test errors, POD representation floor, selected POD rank,
|
|
329
|
+
selected polynomial model, and regression amplification over the POD floor. A failure to reach a
|
|
330
|
+
target is therefore reported diagnostically rather than hidden behind a final loss value.
|
|
331
|
+
|
|
332
|
+
## Included benchmark models
|
|
333
|
+
|
|
334
|
+
- Robertson kinetics: severe stiffness, conservation, and scale separation;
|
|
335
|
+
- Lotka–Volterra: nonlinear oscillation and phase sensitivity;
|
|
336
|
+
- Brusselator: limit-cycle dynamics and nearby bifurcation behavior;
|
|
337
|
+
- SEIR: nonnegative compartment dynamics, conservation, and a transient peak.
|
|
338
|
+
|
|
339
|
+
## Legacy and experimental commands
|
|
340
|
+
|
|
341
|
+
The distribution retains the gene-feedback examples and the earlier pool-based active-learning
|
|
342
|
+
prototype for reproducibility. The recommended production path is `adasurrog-train` or the
|
|
343
|
+
`UniversalODEPipeline`; active learning is not part of the default automatic pipeline.
|
|
344
|
+
|
|
345
|
+
## Current scope
|
|
346
|
+
|
|
347
|
+
Version 0.5.1 supports continuous parameterized ODE initial-value problems with strictly positive
|
|
348
|
+
parameter bounds and fixed simulation horizons. Global unweighted or metric-weighted POD is used
|
|
349
|
+
for trajectory representation. Event resets, discontinuous controls, automatic state/time-blocked
|
|
350
|
+
POD, nonlinear latent representations, and derivative-supervised training are not yet automatic.
|
|
351
|
+
|
|
352
|
+
## Reproducibility and citation
|
|
353
|
+
|
|
354
|
+
See `CITATION.cff` for citation metadata. Release history is recorded in `CHANGELOG.md`.
|
|
355
|
+
|
|
356
|
+
## License
|
|
357
|
+
|
|
358
|
+
AdaSurroG is distributed under the MIT License.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Publishing AdaSurroG to PyPI
|
|
2
|
+
|
|
3
|
+
## 1. Verify metadata
|
|
4
|
+
|
|
5
|
+
Review these files before release:
|
|
6
|
+
|
|
7
|
+
- `pyproject.toml`;
|
|
8
|
+
- `src/adasurrog/__about__.py`;
|
|
9
|
+
- `README.md`;
|
|
10
|
+
- `CHANGELOG.md`;
|
|
11
|
+
- `CITATION.cff`;
|
|
12
|
+
- `LICENSE`.
|
|
13
|
+
|
|
14
|
+
Replace the team-level author metadata with personal or institutional metadata if desired.
|
|
15
|
+
|
|
16
|
+
## 2. Clean and validate
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
rm -rf build dist *.egg-info
|
|
20
|
+
ruff check .
|
|
21
|
+
ruff format --check .
|
|
22
|
+
pytest
|
|
23
|
+
python -m build
|
|
24
|
+
python -m twine check dist/*
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## 3. Test the wheel locally
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
python -m venv .release-test
|
|
31
|
+
source .release-test/bin/activate
|
|
32
|
+
python -m pip install "dist/adasurrog-0.5.1-py3-none-any.whl[universal]"
|
|
33
|
+
adasurrog --version
|
|
34
|
+
adasurrog-benchmark --list
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## 4. TestPyPI upload
|
|
38
|
+
|
|
39
|
+
Use an API token through the environment or interactive prompt. Do not put the token in a source
|
|
40
|
+
file or shell history.
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
python -m twine upload --repository testpypi dist/*
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Test installation from TestPyPI while allowing dependencies to come from the main package index:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
python -m pip install \
|
|
50
|
+
--index-url https://test.pypi.org/simple/ \
|
|
51
|
+
--extra-index-url https://pypi.org/simple/ \
|
|
52
|
+
"adasurrog[universal]==0.5.1"
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## 5. Production upload
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
python -m twine upload dist/*
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
PyPI release files are immutable. If an upload is incorrect, increment the package version and
|
|
62
|
+
build a new release rather than attempting to replace the existing files.
|
|
63
|
+
|
|
64
|
+
Trusted Publishing through a repository workflow is preferred once a source repository is set up.
|
|
65
|
+
The included `.github/workflows/publish.yml` is a starting point and requires a configured PyPI
|
|
66
|
+
environment with trusted-publisher permissions.
|