Physics Constraints¶
Soft physics constraints through virtual observations for known limits and monotonic trends.
matgpr.physics_constraints
¶
VirtualObservationSet
dataclass
¶
Physics-derived pseudo-observations for soft GPR constraints.
Virtual observations are useful when physics gives trusted anchor behavior that is not directly present in a small experimental dataset. Examples include zero-response limits, saturation values, or local monotonic trends.
These observations are soft constraints: they influence the fitted GP, but they do not mathematically guarantee global monotonicity or exact boundary behavior.
Source code in matgpr/physics_constraints.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | |
KnownLimitConstraint
dataclass
¶
Create virtual observations at a known feature limit.
This class encodes boundary behavior such as fraction = 0 at zero time,
a known saturation value at high loading, or a physically required response
at a limiting temperature/composition. The selected feature is replaced by
limit_value for each reference row while all other features are kept
unchanged.
Source code in matgpr/physics_constraints.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
generate(X_reference)
¶
Generate virtual observations from reference feature rows.
Source code in matgpr/physics_constraints.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
MonotonicTrendConstraint
dataclass
¶
Create local virtual observations that encode a monotonic trend.
The constraint shifts one feature by step and assigns a target that is
consistent with an increasing or decreasing response. For an increasing
trend and positive step, the virtual target is
y_reference + minimum_slope * step. For a decreasing trend, the sign is
reversed. Negative steps are allowed and move the anchor in the opposite
feature direction.
This is a soft data-augmentation strategy for low-data GPR workflows. It is not a replacement for derivative-constrained Gaussian-process inference.
Source code in matgpr/physics_constraints.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
generate(X_reference, y_reference)
¶
Generate monotonic virtual observations from reference rows.
Source code in matgpr/physics_constraints.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
AugmentedTrainingData
dataclass
¶
Training data after appending virtual physics observations.
Source code in matgpr/physics_constraints.py
185 186 187 188 189 190 191 192 | |
combine_virtual_observations(*virtual_observations)
¶
Combine compatible virtual-observation sets into one set.
Source code in matgpr/physics_constraints.py
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | |
append_virtual_observations(X, y, *virtual_observations, base_alpha=1e-08, observed_label='observed')
¶
Append virtual physics observations to a training dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
Real training features and targets. |
required | |
y
|
Real training features and targets. |
required | |
virtual_observations
|
VirtualObservationSet
|
One or more :class: |
()
|
base_alpha
|
float | Sequence[float] | ndarray | None
|
Observation variance for real training rows. If supplied, the returned
|
1e-08
|
observed_label
|
str
|
Label assigned to real training rows in the returned metadata. |
'observed'
|
Source code in matgpr/physics_constraints.py
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | |