Skip to content

Commit 1e5c4b3

Browse files
boxcrete: V2 strength GP — final-form module layout
Introduces the V2 strength GP — a multiplicatively-gated kernel architecture that structurally enforces the physics constraint f(x, t=0) = 0 with zero posterior variance — plus the supporting public API and the saved model artifact. Module layout (each module focused on one concept): * boxcrete/concrete_model.py — SustainableConcreteModel (the multi-output joint GWP/slump/strength model) and AppendDerivedFeatures. * boxcrete/strength_model.py — public fit/load API for V2: fit_strength_gp() and load_pretrained_strength_gp(). Hosts the V2 fit factory and ChainedInputTransform composition. * boxcrete/kernels.py — kernel primitives: TimeGatedKernel, within_group_prior, ard_matern_with_within_group_prior, additive_time_kernel, build_strength_kernel_for_aug_dim, make_gated_strength_kernel_builder. * boxcrete/features.py — features and transforms: F5_ALLLOG_FEATURES, GATE_TAU, IDX, FEATURE_BUILDERS, append_engineered_features_callable, augmented_bounds, max_scale_Y, LearnableLogTimeTransform. * boxcrete/likelihoods.py — GatedGaussianLikelihood (heteroscedastic Gaussian with h(t)² gating, paired with the gated kernel) and PartialFixedNoiseLikelihood. * boxcrete/priors.py — WithinGroupShrinkagePrior + the binder / aggregate group definitions used for ARD lengthscale shrinkage. * boxcrete/slump_model.py — fit_slump_gp() for the slump model. * boxcrete/strength_model_legacy.py — V1 helpers retained for backward compatibility (get_strength_gp_input_transform). Replaces the legacy boxcrete/models.py (758 lines) with the focused modules above. Persisted artifact: * docs/model/strength_model.pt — PyTorch state_dict for the deployed V2 strength GP. load_pretrained_strength_gp() reconstructs the full SingleTaskGP from this without re-fitting. Tests: * test/test_strength_model_parity.py — guards that the V2 fit factory produces byte-equivalent posteriors to the research-side catalog at experiments/model_variant_study.py. * test/test_pretrained_loader_fidelity.py — guards that the state_dict round-trip reproduces the trained model exactly. * test/test_strength_curve_monotonicity.py — physical-constraint regression for monotonic strength evolution. * test/test_physical_constraints.py — physical-constraint regression for f(x, t=0) = 0 with zero variance under the gated kernel. * test/test_public_api.py — public API surface guard.
1 parent 348b0ac commit 1e5c4b3

30 files changed

Lines changed: 4787 additions & 2788 deletions

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ This repository contains probabilistic models and data for the
1616
2) The associated global warming potential (GWP)
1717
3) Slump prediction using Gaussian Process regression with derived features
1818

19-
as a function of their composition, consisting of cement, fly ash, slag, fine and coarse aggregate, admixtures, and water, to name a few basic ingredients. See `boxcrete/models.py` for implementation details.
19+
as a function of their composition, consisting of cement, fly ash, slag, fine and coarse aggregate, admixtures, and water, to name a few basic ingredients. See `boxcrete/concrete_model.py` for implementation details.
2020

2121
### Included Data
2222

@@ -51,7 +51,7 @@ pip install -e ".[notebooks]"
5151
```python
5252
import torch
5353
from boxcrete.utils import load_concrete_strength, get_bounds
54-
from boxcrete.models import SustainableConcreteModel
54+
from boxcrete.concrete_model import SustainableConcreteModel
5555
from boxcrete.plotting import plot_strength_curve
5656

5757
# Load data and fit models
@@ -105,7 +105,7 @@ The models can be used for a variety of tasks, including but not limited to
105105

106106
## Compressive Strength Model
107107

108-
The `SustainableConcreteModel` in [`boxcrete/models.py`](boxcrete/models.py) includes a strength_model that predicts the evolution of compressive strength as a function of mixture composition. A demo is provided in [`notebooks/strength_curve_prediction_demo.ipynb`](notebooks/strength_curve_prediction_demo.ipynb), which demonstrates how the model can be used to predict the full strength development curve for any user-specified mix. A comprehensive tutorial covering prediction, calibration, Pareto frontiers, and gradient-based experimental design is available in [`notebooks/prediction_and_optimization_tutorial.ipynb`](notebooks/prediction_and_optimization_tutorial.ipynb). The model is based on Gaussian Process (GP) regression and incorporates custom modeling steps to ensure physically consistent strength evolution and calibrated uncertainty.
108+
The `SustainableConcreteModel` in [`boxcrete/concrete_model.py`](boxcrete/concrete_model.py) includes a strength_model that predicts the evolution of compressive strength as a function of mixture composition. A demo is provided in [`notebooks/strength_curve_prediction_demo.ipynb`](notebooks/strength_curve_prediction_demo.ipynb), which demonstrates how the model can be used to predict the full strength development curve for any user-specified mix. A comprehensive tutorial covering prediction, calibration, Pareto frontiers, and gradient-based experimental design is available in [`notebooks/prediction_and_optimization_tutorial.ipynb`](notebooks/prediction_and_optimization_tutorial.ipynb). The model is based on Gaussian Process (GP) regression and incorporates custom modeling steps to ensure physically consistent strength evolution and calibrated uncertainty.
109109

110110
### Strength Curve Predictions
111111

boxcrete/__init__.py

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,37 @@
44
# This source code is licensed under the MIT license found in the
55
# LICENSE file in the root directory of this source tree.
66

7-
from boxcrete.model_utils import FixedFeatureModel, LinearModel
8-
from boxcrete.models import (
7+
from boxcrete.concrete_model import SustainableConcreteModel
8+
from boxcrete.features import (
99
AppendDerivedFeatures,
10-
fit_slump_gp,
11-
fit_strength_gp,
12-
get_strength_gp_input_transform,
13-
PartialFixedNoiseLikelihood,
14-
SustainableConcreteModel,
15-
WithinGroupShrinkagePrior,
10+
F5_ALLLOG_FEATURES,
11+
FEATURE_BUILDERS,
12+
GATE_TAU,
13+
IDX,
14+
LearnableLogTimeTransform,
15+
append_engineered_features_callable,
16+
augmented_bounds,
17+
max_scale_Y,
18+
)
19+
from boxcrete.kernels import (
20+
TimeGatedKernel,
21+
additive_time_kernel,
22+
ard_matern_with_within_group_prior,
23+
build_strength_kernel_for_aug_dim,
24+
make_gated_strength_kernel_builder,
1625
)
26+
from boxcrete.likelihoods import GatedGaussianLikelihood, PartialFixedNoiseLikelihood
27+
from boxcrete.model_utils import FixedFeatureModel, LinearModel
1728
from boxcrete.plotting import (
1829
compute_loo_cv,
1930
plot_calibration,
2031
plot_feature_importance,
2132
plot_strength_curve,
2233
)
34+
from boxcrete.priors import WithinGroupShrinkagePrior, within_group_prior
35+
from boxcrete.slump_model import fit_slump_gp
36+
from boxcrete.strength_model import fit_strength_gp, load_pretrained_strength_gp
37+
from boxcrete.strength_model_legacy import get_strength_gp_input_transform
2338
from boxcrete.units import (
2439
convert_slump,
2540
convert_strength,
@@ -69,7 +84,13 @@
6984
"DEFAULT_X_COLUMNS",
7085
"DEFAULT_Y_COLUMNS",
7186
"DEFAULT_YSTD_COLUMNS",
87+
"F5_ALLLOG_FEATURES",
88+
"FEATURE_BUILDERS",
7289
"FixedFeatureModel",
90+
"GATE_TAU",
91+
"GatedGaussianLikelihood",
92+
"IDX",
93+
"LearnableLogTimeTransform",
7394
"LinearModel",
7495
"MORTAR_BOUNDS_DICT",
7596
"MORTAR_CONSTRAINTS",
@@ -80,8 +101,14 @@
80101
"STRENGTH_DISPLAY_SCALE",
81102
"SustainableConcreteDataset",
82103
"SustainableConcreteModel",
104+
"TimeGatedKernel",
83105
"UnitSystem",
84106
"WithinGroupShrinkagePrior",
107+
"additive_time_kernel",
108+
"append_engineered_features_callable",
109+
"ard_matern_with_within_group_prior",
110+
"augmented_bounds",
111+
"build_strength_kernel_for_aug_dim",
85112
"compute_loo_cv",
86113
"convert_slump",
87114
"convert_strength",
@@ -93,12 +120,16 @@
93120
"get_reference_point",
94121
"get_strength_gp_input_transform",
95122
"load_concrete_strength",
123+
"load_pretrained_strength_gp",
124+
"make_gated_strength_kernel_builder",
96125
"make_linear_coefficients",
126+
"max_scale_Y",
97127
"plot_calibration",
98128
"plot_feature_importance",
99129
"plot_strength_curve",
100130
"predict_pareto",
101131
"reduce_to_optimization_space",
102132
"slump_label",
103133
"strength_label",
134+
"within_group_prior",
104135
]

0 commit comments

Comments
 (0)