designers
Create the experimental design using either a simple one-shot Latin hypercube or through the LOO sampling methods for both single and multi-level GPs. Repulsion points can also be added and their effect calculated through the pseudo expected improvement (PEI) class.
Sampling Methods
compute_single_level_loo_samples
Single level leave-one-out design points.
compute_multi_level_loo_samples
Multi level leave-one-out design points.
oneshot_lhs
Latin hypercube sampling.
PEI Calculator
repulsion_points
Current set of repulsion points.
add_repulsion_points
Add simulator points to repulsion points.
compute
Compute pseudo expected improvement for a given input.
expected_improvement
Calculate expected improvement for a given input.
repulsion
Calculate repulsion factor for a given input.
Computing Leave-One-Out
compute_loo_gp
Calculate a leave-one-out GP.
compute_loo_errors_gp
Calculate a GP trained on leave-one-out errors.
compute_loo_prediction
Make a prediction from GP minus leave-one-out point.
compute_multi_level_loo_error_data
Calculate multi-level leave-one-out errors.
compute_multi_level_loo_errors_gp
Calculate a GP trained on multi-level leave-one-out errors.
compute_multi_level_loo_prediction
Make a prediction for a Multi-level GP minus leave-one-out point.
PEICalculator
A calculator of pseudo-expected improvement (PEI) for Gaussian processes.
Implements the PEI detailed in Mohammadi et. al. (2022)[1]. The functionality in this class applies to Gaussian processes that have been trained on data with inputs lying in the supplied simulator domain.
If additional_repulsion_pts
is provided, then these simulator inputs will be used as
repulsion points when calculating pseudo-expected improvement of the LOO errors GP (in
addition to the training inputs for the provided Gaussian process and the
pseudopoints, which are always used as repulsion points). The additional
repulsion points must belong to the simulator domain domain
.
Deep copies of the supplied gp
and domain
are stored internally upon initialisation of a new
instance and subsequently used for calculations. This means that if the supplied gp
or domain
are modified after creation of a PEICalculator
instance, then this
won't affect the instance's behaviour. As a typical example, if a PEICalculator
instance pei
is created with gp
and gp
is then trained on new data, then this
won't be reflected in the calculation of pseudo-expected improvement, repulsion or
expected improvement using pei
. To calculate these values for the updated gp
,
a new PEICalculator
instance would need to be created with the new version of
gp
.
Parameters:
-
domain
(SimulatorDomain
) –The domain of a simulation.
-
gp
(AbstractGaussianProcess
) –A Gaussian process model, which is trained on data where the simulator inputs are in
domain
. -
additional_repulsion_pts
(Optional[Collection[Input]]
, default:None
) –A collection of simulator inputs from
domain
that should be used as repulsion points when computing pseudo-expected improvement.
Attributes:
-
repulsion_points
(tuple[Input]
) –(Read-only) The current set of repulsion points used in calculations; as a tuple with no repeated elements.
Raises:
-
ValueError
–If any of the new repulsion points don't belong to the supplied simulator domain.
Examples:
>>> domain = SimulatorDomain(...)
>>> gp_model = AbstractGaussianProcess(...)
>>> pei_calculator = PEICalculator(domain, gp_model)
>>> pei_value = pei_calculator.compute(trial_point)
Notes
This class computes the PEI for given inputs in a simulation domain, which features both expected improvement and a repulsion factor. Large values of pseudo-expected improvement indicate new inputs that reduce predictive uncertainty while not being too close to already-seen inputs. Optimising against PEI supports the search of experimental designs that balances exploration and exploitation of the input space.
References
[1] Mohammadi, H. et al. (2022) "Cross-Validation-based Adaptive Sampling for Gaussian process models". DOI: https://doi.org/10.1137/21M1404260
Source code in exauq/core/designers.py
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 |
|
repulsion_points: tuple[Input]
property
(Read-only) The current set of repulsion points used in calculations.
add_repulsion_points(repulsion_points)
Add simulator inputs to the set of repulsion points.
Updates the internal set of repulsion points used in the repulsion factor
calculation. The additional repulsion points must belong to the simulator domain
for this object (i.e. self.domain
). Simulator inputs very positively
correlated with repulsion points result in low repulsion values, whereas inputs
very negatively correlated with repulsion points result in high repulsion values.
Parameters:
-
repulsion_points
(Collection[Input]
) –The inputs to be added to the repulsion points set.
Raises:
-
ValueError
–If any of the new repulsion points don't belong to this object's simulator domain.
Examples:
>>> repulsion_points = [Input(4.0, 5.0), Input(4.1, 5.1)]
>>> pei_calculator.add_repulsion_points(repulsion_points)
Source code in exauq/core/designers.py
compute(x)
Compute the pseudo-expected improvement (PEI) for a given input.
Parameters:
-
x
(Input
) –The simulator input to calculate PEI for.
Returns:
-
Real
–The computed PEI value for the given input.
Examples:
Notes
This method calculates the PEI at a given point x
, which is the product of the
expected improvement (EI) and the repulsion factor. The PEI is a metric used in
Bayesian optimisation to balance exploration and exploitation, taking into account
both the potential improvement over the current best target and the desire to
explore less sampled regions of the domain.
Source code in exauq/core/designers.py
expected_improvement(x)
Calculate the expected improvement (EI) for a given input.
If the standard deviation of the prediction is within the default
tolerance exauq.core.numerics.FLOAT_TOLERANCE
of 0 then the EI returned is 0.0.
Parameters:
-
x
(Input
) –The simulator input to calculate expected improvement for.
Returns:
-
Real
–The expected improvement value for the given input.
Examples:
Notes
This method computes the EI of the given input point x
using the Gaussian
process stored within this instance. EI is a measure used in Bayesian optimisation
and is particularly useful for guiding the selection of points in the domain where
the objective function should be evaluated next. It is calculated based on the
model's prediction at x
, the current maximum target value, and the standard
deviation of the prediction.
Source code in exauq/core/designers.py
repulsion(x)
Calculate the repulsion factor for a given simulator input.
This method calculates a repulsion effect of a given point x
in relation to
other, stored repulsion points. It is calculated as the product of terms 1 -
correlation(x, rp)
, where rp
is a repulsion point and the correlation is
computed with the Gaussian process supplied at this object's initialisation. The
repulsion factor approaches zero for inputs that tend towards repulsion points
(and is equal to zero at repulsion points). This can be used to discourage the
selection of points near already sampled locations, facilitating exploration of
the input space.
Parameters:
-
x
(Input
) –The simulator input to calculate the repulsion factor for.
Returns:
-
Real
–The repulsion factor for the given input.
Examples:
Source code in exauq/core/designers.py
compute_delta_coefficients(levels, correlations=1)
Calculate the delta coefficients from the Markov-like correlations.
The levels argument creates the correlations for the number of levels that there are. If a sequence is passed then this is expected to be a range of levels for the mlgp. Optionally, you can simply pass the number of levels as an integer and this will create the correlations up to that level.
By default the constant correlation of 1 is applied to every level if no correlation is provided. Note that the correlations only run to level \(L - 1\) as it denotes the correlation between that level and the one above. If a 'Real' value is provided, then this value is provided for every level in the multi-level correlations object.
Parameters:
-
levels
(Union[Optional[Sequence[int]], int]
) –The number of levels or a tuple of levels for the coefficients to be calculated for.
-
correlations
(Union[MultiLevel[Real], Real]
, default:1
) –The Markov-like correlations between simulators at successive levels.
Returns:
-
MultiLevel[Real]:
–The delta coefficients calculated from the correlations across levels.
Source code in exauq/core/designers.py
1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 |
|
compute_loo_errors_gp(gp, domain, loo_errors_gp=None)
Calculate a Gaussian process trained on normalised expected squared leave-one-out (LOO) errors.
The errors are computed from the supplied Gaussian process, gp
. This involves
training a Gaussian process (GP) for each leave-one-out subset of the training data of
gp
and calculating the normalised expected squared error at the left-out training
point for each intermediary GP. Note that the intermediary leave-one-out GPs are fit
to data using the fitted hyperparameters from the supplied gp
, which avoids costly
re-estimation of hyperparameters. The resulting errors, together with the
corresponding left out simulator inputs, form the training data for the output GP. The
output GP is trained with a lower bound on the correlation length scale parameters
(see the Notes section).
By default, the returned AbstractGaussianProcess
object will be a deep copy of
gp
trained on the leave-one-out errors. Alternatively, another
AbstractGaussianProcess
can be supplied that will be trained on the leave-one-out
errors and returned (thus it will be modified in-place as well as returned).
Parameters:
-
gp
(AbstractGaussianProcess
) –A Gaussian process to calculate the normalised expected squared LOO errors for.
-
domain
(SimulatorDomain
) –The domain of a simulator that the Gaussian process
gp
emulates. The data on whichgp
is trained are expected to have simulator inputs only from this domain. -
loo_errors_gp
(Optional[AbstractGaussianProcess]
, default:None
) –Another Gaussian process that is trained on the LOO errors to create the output to this function. If
None
then a deep copy ofgp
will be used instead.
Returns:
-
AbstractGaussianProcess
–A Gaussian process that is trained on the normalised expected square LOO errors of
gp
. Ifloo_errors_gp
was supplied then (a reference to) this object will be returned (except now it has been fit to the LOO errors).
Raises:
-
ValueError
–If any of the training inputs in
gp
do not belong to the simulator domaindomain
.
Notes
The lower bounds on the correlation length scale parameters are obtained by
multiplying the lengths of the domain's dimensions by sqrt(-0.5 / log(10**(-8)))
.
Source code in exauq/core/designers.py
186 187 188 189 190 191 192 193 194 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 224 225 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 |
|
compute_loo_gp(gp, leave_out_idx, loo_gp=None)
Calculate a leave-one-out (LOO) Gaussian process.
The returned Gaussian process (GP) is obtained by training it on all training data
from the supplied GP except for one datum (the 'left out' datum). It is trained using
the fitted hyperparameters from the supplied Gaussian process gp
.
By default, the returned AbstractGaussianProcess
object will be a deep copy of
gp
trained on the leave-one-out data. Alternatively, another
AbstractGaussianProcess
can be supplied that will be trained on the leave-one-out
data and returned (thus it will be modified in-place as well as returned). This can
be more efficient when repeated calculation of a LOO GP is required.
Parameters:
-
gp
(AbstractGaussianProcess
) –A Gaussian process to form the basis for the LOO GP.
-
leave_out_idx
(int
) –The index for the training datum of
gp
to leave out. This should be an index of the sequence returned by thegp.training_data
property. -
loo_gp
(Optional[AbstractGaussianProcess]
, default:None
) –Another Gaussian process that is trained on the LOO data and then returned. If
None
then a deep copy ofgp
will be used instead.
Returns:
-
AbstractGaussianProcess
–A Gaussian process that is trained on all training data from
gp
except the datum that is left out.
Raises:
-
ValueError
–If the supplied
AbstractGaussianProcess
hasn't been trained on any data.
Source code in exauq/core/designers.py
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 |
|
compute_loo_prediction(gp, leave_out_idx, loo_gp=None)
Make a prediction from a leave-one-out (LOO) Gaussian process (GP) at the left out point.
The LOO Gaussian process (GP) is obtained by training it on all training data from the
supplied GP except for one datum (the 'left out' datum). It is trained using the
fitted hyperparameters from the supplied Gaussian process gp
.
By default, the LOO GP used will be a deep copy of gp
trained on the leave-one-out
data. Alternatively, another AbstractGaussianProcess
can be supplied that will be
trained on the leave-one-out data. This can be more efficient when repeated
calculation of a LOO GP is required.
Parameters:
-
gp
–A Gaussian process to form the basis for the LOO GP.
-
leave_out_idx
–The index for the training datum of
gp
to leave out. This should be an index of the sequence returned by thegp.training_data
property. -
loo_gp
(Optional[AbstractGaussianProcess]
, default:None
) –Another Gaussian process that is trained on the LOO data and then used to make the prediction at the left-out simulator input. If
None
then a deep copy ofgp
will be used instead.
Returns:
-
GaussianProcessPrediction
–The prediction of the LOO Gaussian process at the left out simulator input.
Source code in exauq/core/designers.py
compute_multi_level_loo_error_data(mlgp)
Calculate multi-level leave-one-out (LOO) errors.
This involves computing normalised expected squared errors for GPs based on a
leave-one-out (LOO) cross-validation across all the levels. For each simulator input
in the training data of mlgp
, the normalised expected squared error of the
prediction of an intermediary LOO multi-level GP at the input is calculated. The
intermediary LOO multi-level GP involves computing a single-level LOO GP at the level
of the left out input (see compute_loo_errors_gp
). A copy of the GP at the
appropriate level in mlgp
is used for this intermediary LOO GP and the corresponding
hyperparameters found in mlgp
are used when fitting to the data.
Parameters:
-
mlgp
(MultiLevelGaussianProcess
) –A multi-level GP to calculate the errors for.
Returns:
-
MultiLevel[tuple[TrainingDatum]]
–Multi-level data consisting of the simulator inputs from the training data for
mlgp
and the errors arising from the corresponding leave-one-out calculations.
Raises:
-
ValueError
–If the GP at some level within
mlgp
has not been trained on more than one datum.
See Also
compute_multi_level_loo_prediction
:
Calculate the prediction of a LOO multi-level GP at a left-out training input.
Source code in exauq/core/designers.py
1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 |
|
compute_multi_level_loo_errors_gp(mlgp, domain, output_mlgp=None)
Calculate the multi-level Gaussian process (GP) trained on normalised expected squared leave-one-out (LOO) errors.
The returned multi-level GP is obtained by training it on training data calculated
with compute_multi_level_loo_error_data
. This involves computing normalised
expected squared errors for GPs based on a leave-one-out (LOO) cross-validation across
all the levels. The resulting errors, together with the corresponding left out
simulator inputs, form the training data for the output GP. The
output GP is trained with a lower bound on the correlation length scale parameters for
each level (see the Notes section).
By default, the returned multi-level GP will be a deep copy of mlgp
trained on the
error data. Alternatively, another multi-level GP can be supplied that will be trained
on the error data and returned (thus it will be modified in-place as well as
returned).
Parameters:
-
mlgp
(MultiLevelGaussianProcess
) –A multi-level GP to calculate the normalised expected squared LOO errors for.
-
domain
(SimulatorDomain
) –The domain of a simulator that the multi-level Gaussian process
mlgp
emulates. The data on which each level ofmlgp
is trained are expected to have simulator inputs only from this domain. -
output_mlgp
(Optional[MultiLevelGaussianProcess]
, default:None
) –Another multi-level GP that is trained on the LOO errors to create the output to this function. If
None
then a deep copy ofmlgp
will be used instead.
Returns:
-
MultiLevelGaussianProcess
–A multi-level GP that is trained on the normalised expected square LOO errors arising from
mlgp
. Ifoutput_mlgp
was supplied then (a reference to) this object will be returned (except now it has been fit to the LOO errors data).
Raises:
-
ValueError
–If the set of levels for
output_mlgp
is not equal to those inmlgp
(whenoutput_mlgp
is notNone
).
See Also
compute_multi_level_loo_error_data
:
Calculation of the leave-one-out error data used to train this function's output.
Notes
The lower bounds on the correlation length scale parameters are obtained by
multiplying the lengths of the domain's dimensions by sqrt(-0.5 / log(10**(-8)))
.
Note that the same lower bounds are used for each level.
Source code in exauq/core/designers.py
1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 |
|
compute_multi_level_loo_prediction(mlgp, level, leave_out_idx, loo_gp=None)
Make a prediction from a multi-level leave-one-out (LOO) Gaussian process (GP) at the left out point.
The multi-level LOO prediction at the left-out simulator input is a sum of
predictions made for each level in the given multi-level GP. The contribution at the
level containing the left out training datum (defined by level
) is the prediction
made by the LOO GP at the given level in mlgp
(see compute_loo_prediction
). The
contributions at the other levels are based on predictions made by the GPs in mlgp
at these levels under the assumption of a zero prior mean.
The formula for calculating the leave-one-out prediction assumes that none of the levels in the multi-level GP share common training simulator inputs; a ValueError will be raised if this is not the case.
Parameters:
-
mlgp
(MultiLevelGaussianProcess
) –A multi-level Gaussian process to form the basis for the multi-level LOO GP.
-
level
(int
) –The level containing the datum to leave out.
-
leave_out_idx
(int
) –The index for the training datum of
mlgp
to leave out, at the levellevel
. -
loo_gp
(Optional[AbstractGaussianProcess]
, default:None
) –A Gaussian process that is trained on the LOO data and then used to make the prediction for
level
at the left-out simulator input. IfNone
then a deep copy of the GP at levellevel
inmlgp
will be used instead.
Returns:
-
GaussianProcessPrediction
–The prediction at the left out training input, based on the multi-level LOO GP described above.
Raises:
-
ValueError
–If there is a shared training simulator input across multiple levels in
mlgp
.
Source code in exauq/core/designers.py
840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 |
|
compute_multi_level_loo_samples(mlgp, domain, costs, batch_size=1, additional_repulsion_pts=None, seeds=None)
Compute a batch of design points adaptively for a multi-level Gaussian process (GP).
Implements the cross-validation-based adaptive sampling for multi-level Gaussian process models, as described in Kimpton et. al. (2023)[1]. This involves computing a multi-level GP that is trained on normalised expected squared errors arising from a multi-level leave-one-out (LOO) cross-validation. The design points returned are those that maximise weighted pseudo-expected improvements (PEIs) of this multi-level LOO errors GP across levels, where the PEIs are weighted according to the costs of computing the design points on simulators at the levels.
The costs
should represent the successive differences costs of running each level's
simulator on a single input. For example, if the level costs were 1, 10, 100 for levels
1, 2, 3 respectively, then 1, 11, 110 would need to be supplied if successive differences
was the chosen method for calculating costs.
If additional_repulsion_pts
is provided, then these points will be added into the
calculations at the level they are allocated to in the PEI.
If seeds
is provided, then the seeds provided for the levels will be used when
maximising the pseudo-expected improvement of the LOO errors GP for each level (a
sequence of seeds will be generated level-wise to find each new simulator input
in the batch). Note that None
can be provided for a level, which means the maximisation
at that level won't be seeded. Providing seeds does not necessarily mean calculation of the
output design points is deterministic, as this also depends on computation of the LOO
errors GP being deterministic.
The adaptive sampling method assumes that none of the levels in the multi-level GP share common training simulator inputs; a ValueError will be raised if this is not the case.
Parameters:
-
mlgp
(MultiLevelGaussianProcess
) –The multi-level GP to create the design points for.
-
domain
(SimulatorDomain
) –The domain of a simulator that the multi-level Gaussian process
mlgp
emulates. The data on which each level ofmlgp
is trained are expected to have simulator inputs only from this domain. -
costs
(MultiLevel[Real]
) –The costs of running a simulation at each of the levels.
-
batch_size
(int
, default:1
) –The number of new design points to compute. Should be a positive integer.
-
additional_repulsion_pts
(Optional[MultiLevel[Collection[Input]]]
, default:None
) –A multi-level collection of hand-chosen Input repulsion points to aid computation of samples.
-
seeds
(Optional[MultiLevel[int]]
, default:None
) –A multi-level collection of random number seeds to use when maximising pseudo-expected improvements for each level. If
None
then none of the maximisations will be seeded.
Returns:
-
MultiLevel[tuple[Input]]
–A MultiLevel tuple of inputs containing all of the new design points at the correct level
Raises:
-
ValueError
–If any of the training inputs in
mlgp
do not belong to the simulator domaindomain
. -
ValueError
–If any of the levels defined in
mlgp
does not have an associated cost. -
ValueError
–If there is a shared training simulator input across multiple levels in
mlgp
.
See Also
compute_multi_level_loo_errors_gp
:
Computation of the multi-level leave-one-out errors GP.
PEICalculator
:
Pseudo-expected improvement calculation.
GaussianProcessPrediction.nes_error
:
Normalised expected squared error for a prediction from a Gaussian process.
[optimisation.maximise
][exauq.utilities.optimisation.maximise] :
Global maximisation over a simulator domain, used on pseudo-expected improvement
for the multi-level LOO errors GP.
References
[1] Kimpton, L. M. et al. (2023) "Cross-Validation Based Adaptive Sampling for Multi-Level Gaussian Process Models". arXiv: https://arxiv.org/abs/2307.09095
Source code in exauq/core/designers.py
1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 |
|
compute_single_level_loo_samples(gp, domain, batch_size=1, additional_repulsion_pts=None, loo_errors_gp=None, seed=None)
Compute a new batch of design points adaptively for a single-level Gaussian process.
Implements the cross-validation-based adaptive sampling for emulators, as described in Mohammadi et. al. (2022)[1]. This involves computing a Gaussian process (GP) trained on normalised expected squared errors arising from a leave-one-out (LOO) cross-validation, then finding design points that maximise the pseudo-expected improvement of this LOO errors GP.
If additional_repulsion_pts
is provided, then these simulator inputs will be used as
repulsion points when calculating pseudo-expected improvement of the LOO errors GP (in
addition to pseudopoints, which are always used as repulsion points). The additional
repulsion points must belong to the simulator domain domain
. See PEICalculator
for further details on repulsion points and exauq.core.modelling.SimulatorDomain
for further details on pseudopoints.
By default, a deep copy of the main GP supplied (gp
) is trained on the leave-one-out
errors. Alternatively, another AbstractGaussianProcess
can be supplied that will
be trained on the leave-one-out errors (and so modified in-place), allowing for the
use of different Gaussian process settings (e.g. a different kernel function).
If seed
is provided, then this will be used when maximising the pseudo-expected
improvement of the LOO errors GP (a sequence of seeds will be generated to find each new
simulator input in the batch). Providing a seed does not necessarily mean calculation
of the output design points is deterministic, as this also depends on computation of
the LOO errors GP being deterministic.
Parameters:
-
gp
(AbstractGaussianProcess
) –A Gaussian process to compute new design points for.
-
domain
(SimulatorDomain
) –The domain of a simulator that the Gaussian process
gp
emulates. The data on whichgp
is trained are expected to have simulator inputs only from this domain. -
batch_size
(int
, default:1
) –The number of new design points to compute. Should be a positive integer.
-
additional_repulsion_pts
(Optional[Collection[Input]]
, default:None
) –A collection of simulator inputs from
domain
that should be used as repulsion points when computing pseudo-expected improvement. -
loo_errors_gp
(Optional[AbstractGaussianProcess]
, default:None
) –Another Gaussian process that is trained on the LOO errors as part of the adaptive sampling method. If
None
then a deep copy ofgp
will be used instead. -
seed
(Optional[int]
, default:None
) –A random number seed to use when maximising pseudo-expected improvement. If
None
then the maximisation won't be seeded.
Returns:
-
tuple[Input]
–The batch of new design points.
Raises:
-
ValueError
–If any of the training inputs in
gp
do not belong to the simulator domaindomain
.
See Also
compute_loo_errors_gp
:
Computation of the leave-one-out errors Gaussian process.
PEICalculator
:
Pseudo-expected improvement calculation.
SimulatorDomain.calculate_pseudopoints
:
Calculation of pseudopoints for a collection of simulator inputs.
GaussianProcessPrediction.nes_error
:
Normalised expected squared error for a prediction from a Gaussian process.
[optimisation.maximise
][exauq.utilities.optimisation.maximise] :
Global maximisation over a simulator domain, used on pseudo-expected improvement
for the LOO errors GP.
References
[1] Mohammadi, H. et al. (2022) "Cross-Validation-based Adaptive Sampling for Gaussian process models". DOI: https://doi.org/10.1137/21M1404260
Source code in exauq/core/designers.py
709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 |
|
compute_zero_mean_prediction(gp, x)
Make a prediction at an input based on a Gaussian process but with zero prior mean.
Parameters:
-
gp
(AbstractGaussianProcess
) –A Gaussian process.
-
x
(Input
) –A simulator input to make the prediction at.
Returns:
-
GaussianProcessPrediction
–The prediction made at
x
by a Gaussian process having the same covariance asgp
but zero prior mean.
Raises:
-
ValueError
–If
gp
hasn't been trained on any data.
Source code in exauq/core/designers.py
create_data_for_multi_level_loo_sampling(data, correlations=1)
Prepare data from the simulators to be ready for multi-level adaptive sampling.
For the implementation of creating the successive simulator differences used by
compute_multi_level_loo_samples
, the data needs to satisfy the correct delta
calculations calculated between level \(L\) and \(L-1\) for the same inputs.
It must then be ensured that there are no repeats of inputs across the different
levels and hence are removed from the data as it makes no mathematical sense to have
repeated inputs across the multi-level GP with differing outputs.
Parameters:
-
data
(MultiLevel[Sequence[TrainingDatum]]
) –Training data for the simulator at that level.
-
correlations
(Union[MultiLevel[Real], Real]
, default:1
) –The Markov-like correlations between simulators at successive levels
Returns:
-
MultiLevel[Sequence[TrainingDatum]
–A MultiLevel Sequence of TrainingDatum recalculated with deltas calculated and repeated inputs across levels removed.
Source code in exauq/core/designers.py
1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 |
|
oneshot_lhs(domain, batch_size, seed=None)
Create a "one-shot" design for a simulator using the Latin hypercube method.
The Latin hypercube sample generates points in the unit square to spatially fill the domain as best as possible. It is then rescaled to match the design of the simulator. The algorithm is implemented from the Scipy package using the provided domain and number of design points chosen (see notes for further details).
Parameters:
-
domain
(SimulatorDomain
) –The domain of a simulator, defining the bounded input space over which the Latin hypercube will be generated.
-
batch_size
(int
) –The number of design points to create within the domain.
-
seed
(Optional[int]
, default:None
) –A number to seed the random number generator used in the underlying optimisation. If
None
then no seeding will be used.
Returns:
-
tuple[Input, ...]
–The inputs for the domain generated by the Latin hypercube and scaled to match the design of the simulator, returned as a tuple of inputs.
Notes
The Scipy documentation for the Latin hypercube: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.qmc.LatinHypercube.html