Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.7.0 #232

Merged
merged 497 commits into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
497 commits
Select commit Hold shift + click to select a range
b10825e
rename cov_gpu to kernel, and refactor with class structure
nbarlowATI May 19, 2021
108dac9
preparatory work for adding Matern52 kernel
nbarlowATI May 19, 2021
9358b74
add C++ test for Matern kernel
nbarlowATI May 20, 2021
951e952
first implementation of Matern52 kernel
nbarlowATI May 20, 2021
e3be2cb
minor corrections to docstrings
nbarlowATI May 20, 2021
eaea045
implement deriv wrt x for Matern52 kernel
nbarlowATI May 28, 2021
92105b1
Merge branch 'feature/gpu-matern-kernel' of https://github.com/alan-t…
nbarlowATI May 28, 2021
5676999
add deriv wrt theta for Matern52 kernel
nbarlowATI Jun 1, 2021
95392bb
Merge pull request #179 from alan-turing-institute/feature/gpu
nbarlowATI Jun 4, 2021
cfb2921
refactor - put typedefs into types.hpp and more utility functions int…
nbarlowATI Jun 4, 2021
4015cfd
add kernel functions to replicate python functionality via pybind11
nbarlowATI Jun 4, 2021
ef7097f
rename cov_gpu to kernel
nbarlowATI Jun 4, 2021
08cd2c0
fix kernel check in GPU test
nbarlowATI Jun 4, 2021
77245f3
add pybind11 interface for Matern52Kernel
nbarlowATI Jun 11, 2021
cef19d7
revert to using Python kernels for gp.kernel interface in GaussianPro…
nbarlowATI Jun 11, 2021
2e92a1c
only import kernel_type from LibGPGPU if gpu is available (fix Travis…
nbarlowATI Jun 11, 2021
2fa532c
first implementation of const mean function
nbarlowATI Jun 14, 2021
db65c55
first implementation of const mean function
nbarlowATI Jun 14, 2021
2fbcf1e
implement const mean function for predict
nbarlowATI Jun 17, 2021
e8fb5e3
add logpost_deriv for mean function
nbarlowATI Jun 18, 2021
118a53a
add fixed mean and polynomial mean to C++
nbarlowATI Jun 22, 2021
4f0afae
add fixed mean and polynomial mean to C++
nbarlowATI Jun 22, 2021
f9cae4d
add fixed mean and polynomial mean to C++
nbarlowATI Jun 22, 2021
d2abad6
refactor logic around meanfunc in GaussianProcessGPU and add function…
nbarlowATI Jun 22, 2021
89e0912
add test for C++ implementation of mean function
nbarlowATI Jun 23, 2021
fe563c6
pass BaseMeanFunc from python to C++, so get rid of no-longer-needed …
nbarlowATI Jun 23, 2021
5fec9f1
add more useful exception messages
nbarlowATI Jun 23, 2021
d071a1a
use mat52_ prefix for Matern52 kernel rather than just mat_
nbarlowATI Jun 23, 2021
41a7b44
Merge branch 'devel' into feature/gpu-matern-kernel
nbarlowATI Jun 23, 2021
018279c
Merge pull request #182 from alan-turing-institute/feature/gpu-matern…
nbarlowATI Jun 23, 2021
f2975dc
change import in test_GPUMeanFunction to not give errors if HPU unava…
nbarlowATI Jun 23, 2021
248bb76
Merge remote-tracking branch 'origin/devel' into feature/gpu-meanfunc
nbarlowATI Jun 23, 2021
446ac5f
rename gpu_basic to test_gpu_basic
nbarlowATI Jul 26, 2021
8bd978e
rename gpu_kernel to test_gpu_kernel
nbarlowATI Jul 26, 2021
1bf3858
rename gpu_test_utils to test_gpu_utils
nbarlowATI Jul 26, 2021
9c68df0
rename gpu_cholesky to test_gpu_cholesky
nbarlowATI Jul 26, 2021
59f742e
add basic test for nlopt minimization
nbarlowATI Jul 26, 2021
1938164
rename gpu_meanfunc.cu to test_meanfunc.cu
nbarlowATI Jul 26, 2021
7106841
start implementing GP_MAP fitting in C++
nbarlowATI Jul 26, 2021
b376196
C++ test for DenseGP_GPU
nbarlowATI Jul 26, 2021
24e47df
modify logic about when to refit in logpost getter
nbarlowATI Jul 26, 2021
18bc9e1
cache current theta in C++ class
nbarlowATI Jul 28, 2021
bc07ed2
further steps towards C++ implementation of fit_GP_MAP
nbarlowATI Jul 28, 2021
3c7c83f
almost-working C++ fitting with nlopt
nbarlowATI Jul 28, 2021
f531b55
use dlib optimizer for fitting
nbarlowATI Aug 3, 2021
6969055
use dlib optimizer for fitting
nbarlowATI Aug 3, 2021
e9317c3
refactor, store nugget value in C++ rather than python
nbarlowATI Aug 3, 2021
258093f
refactor, store nugget value in C++ rather than python
nbarlowATI Aug 3, 2021
9d89cb1
use C++ fitting for GPU implementation
nbarlowATI Aug 3, 2021
7ae8494
use raw strings for regex, and add property for current_logpost
nbarlowATI Aug 3, 2021
67517ac
add properties for current_logpost and invQt, and use raw strings in …
nbarlowATI Aug 3, 2021
73283e3
set nugget type in C++ class when instantiating python GaussianProces…
nbarlowATI Aug 3, 2021
4c981d5
tweak fitting tests for GPU implementation
nbarlowATI Aug 3, 2021
4ad8c03
add function to find dlib in setup.py
nbarlowATI Aug 3, 2021
7ecb1d6
Merge pull request #183 from alan-turing-institute/feature/gpu-meanfunc
nbarlowATI Aug 6, 2021
1f0c9d1
basic implementation of parameters object with tests
edaub Aug 11, 2021
d09b400
updated parameters object to allow data to be none
edaub Aug 11, 2021
93f24bb
make ZeroMeanFunc the default for DenseGP_GPU
nbarlowATI Aug 12, 2021
dd90ff9
modified GP class to use GPParams class, plust additional unit tests …
edaub Aug 12, 2021
cf8f24e
fixed up parameter changes in SequentialDesign
edaub Aug 12, 2021
0ecde23
fixed MOGP class and fitting routines plus tests for new params class
edaub Aug 12, 2021
b1e66c3
tweaked transformations to be correct and added docstrings
edaub Aug 16, 2021
b44197d
added params class to API docs
edaub Aug 16, 2021
889e1ee
fixed up setup.py to correct error due to setuptools change (#189)
edaub Aug 16, 2021
f17d316
reset version number in setup.py for starting work on next release (#…
edaub Aug 16, 2021
cea2bf1
Fix merge conflicts from devel-to-master PR (#187)
nbarlowATI Aug 16, 2021
83609a7
fixed typo in GPParams.set_data to correct assertion
edaub Aug 16, 2021
b57b6aa
first implementation of C++ MOGP class
nbarlowATI Aug 17, 2021
ba49997
add classmethod to construct GaussianProcessGPU from pybind11 object
nbarlowATI Aug 17, 2021
f371bb7
factored out transforms to enable easier change and re-use
edaub Aug 17, 2021
aed6300
rename gp_gpu.hpp to densegp_gpu.hpp
nbarlowATI Aug 17, 2021
6220ab8
rename gp_gpu.cu to bindings.cu
nbarlowATI Aug 17, 2021
b4957e5
move bindings.cu to correct directory
nbarlowATI Aug 17, 2021
ae0c24f
rename test_gp_gpu to test_densegp_gpu
nbarlowATI Aug 18, 2021
995f11d
rename test_gp_gpu to test_densegp_gpu
nbarlowATI Aug 18, 2021
ee6f880
rename gp_gpu.cu to bindings.cu
nbarlowATI Aug 18, 2021
b9edfbc
rename gp_gpu.hpp to densegp_gpu.hpp
nbarlowATI Aug 18, 2021
5778e14
add MultiOutputGP_GPU to __init__.py
nbarlowATI Aug 18, 2021
140b981
try to ensure that C++ gp objects don't get destroyed by Python garba…
nbarlowATI Aug 18, 2021
3a6fe15
add more accessor functions for pybind to use, and remove obsolete te…
nbarlowATI Aug 18, 2021
a641ab2
first commit of python wrapper for C++ MOGP class
nbarlowATI Aug 18, 2021
6931667
remove debug output from constructor and destructor
nbarlowATI Aug 18, 2021
8d765e3
first functional versions of fitting multi-output GP via C++/GPU fitting
nbarlowATI Aug 18, 2021
b0bdaeb
First attempt at passing meanfunc, kernel, nugget, through MOGP_GPU
nbarlowATI Sep 9, 2021
a6b619d
updated tutorial to use params class
edaub Sep 10, 2021
149d8e1
converted list implementation of priors into a class
edaub Aug 17, 2021
36e3155
added solver for default correlation priors and lognormal prior distr…
edaub Aug 18, 2021
4790d89
refactored prior application code
edaub Sep 7, 2021
ae9c87d
added class method to create default priors
edaub Sep 7, 2021
45d81d0
changed default prior behavior to use default priors
edaub Sep 8, 2021
8fb1f84
got default priors working and tested out
edaub Sep 10, 2021
3b86d93
WIP debugging crashes
nbarlowATI Sep 14, 2021
90d1b4e
updated GP class to use design matrices
edaub Sep 20, 2021
962c855
updated fitting tests to conform to new gp interface
edaub Sep 20, 2021
56f6d28
fixed history matching tests to conform to gp class changes
edaub Sep 20, 2021
624d262
fixed an issue with mice design and disabled an outdated test
edaub Sep 20, 2021
e9a3ff2
fixed mogp docstring to avoid mention of mean function details
edaub Sep 21, 2021
55fd148
removed mean function from the data array in the params object
edaub Sep 21, 2021
d373bff
add tests for C++ multi-output GP
nbarlowATI Sep 21, 2021
9233389
add mogp fitting to C++ fitting test
nbarlowATI Sep 21, 2021
94ad253
Avoid segmentation fault in MOGP GPU fitting when checking fit status
nbarlowATI Sep 21, 2021
5b9ad03
test cloning of mean functions in C++
nbarlowATI Sep 21, 2021
ef6d75f
remove inputs from arguments of get_n_params
nbarlowATI Sep 21, 2021
5427c8f
implemented mean priors and refactored other clasess in priors to acc…
edaub Sep 22, 2021
b0c75ea
make DenseGP_GPU::get_n_params() return the total number of parameter…
nbarlowATI Sep 22, 2021
b7e4c1b
ensure we reset fit status for emulators where fitting fails
nbarlowATI Sep 22, 2021
83f9d4e
add 'n' accessor function to multioutputgp_gpu
nbarlowATI Sep 22, 2021
c586004
add accessor function for n, add default values for meanfunc, kernel_…
nbarlowATI Sep 22, 2021
e94a245
WIP modify list comprehension in functions to get fitted/unfitted emu…
nbarlowATI Sep 22, 2021
22273de
test cloning of mean function
nbarlowATI Sep 22, 2021
612d4a4
modify test now that DenseGP_GPU::fit no longer takes nugget_type arg…
nbarlowATI Sep 22, 2021
507254b
comment out debug output
nbarlowATI Sep 23, 2021
d93186c
add C++ methods to get indices of fit or failed-fit emulators in mult…
nbarlowATI Sep 23, 2021
3847e23
refactored priors class for fitting changes and added backup default …
edaub Sep 27, 2021
2c5185d
added weak priors class and refactored parameter transformations to c…
edaub Sep 28, 2021
e13e752
fixed up GP and MOGP classes to use new prior class
edaub Sep 29, 2021
4d2b98e
improved clarity of priors interface to MOGP class
edaub Sep 30, 2021
cf0440d
re-worked kernel code to remove covariance and avoid unneeded square …
edaub Oct 1, 2021
c64849f
added uniform kernels
edaub Oct 1, 2021
e0a86b9
updated base kernel in GP-based classes
edaub Oct 1, 2021
60b5b98
fixed GP class to handle new kernel interface
edaub Oct 1, 2021
34c15d8
corrected error in LHD implementation to remove deprecated function
edaub Oct 1, 2021
a99477b
implemented product form of kernel
edaub Oct 5, 2021
7f96807
fixed a few remaining issues with kernel refactor
edaub Oct 5, 2021
d9ff9d4
update setup.py such that it also finds dlib if present in /usr/local
nbarlowATI Oct 7, 2021
7055c82
add GPU/CPU timing comparison as a benchmark
nbarlowATI Oct 7, 2021
c1e44cc
look in standard locations for dlib library, as well as LD_LIBRARY_PATH
nbarlowATI Oct 13, 2021
a7a010b
add gpu_parallel benchmark to Makefile
nbarlowATI Oct 13, 2021
6d745fb
make running gpu timing benchmark on CPU optional
nbarlowATI Oct 13, 2021
ec50c93
Add compiler and linker flags for openmp, and modify find_dlib functi…
nbarlowATI Oct 13, 2021
f59ab60
remove commented-out debug output
nbarlowATI Oct 13, 2021
9542b07
remove commented-out debug output, and add missing implementation for…
nbarlowATI Oct 13, 2021
7ec42ad
fix merge conflicts
nbarlowATI Oct 13, 2021
669352d
added methods to get number of parameters
edaub Oct 27, 2021
1536581
fixed priors to handle different numbers of correlation lengths
edaub Oct 27, 2021
41a0ffc
re-worked parameters to be able to fully specify how things are fit
edaub Oct 28, 2021
0230bdf
changed nugget setting to only throw errors when changing forbidden v…
edaub Nov 1, 2021
b86867b
integrated new priors and params into GP class
edaub Nov 2, 2021
77c420b
fixed up MOGP class for new params/priors
edaub Nov 2, 2021
996e422
fixed fitting to handle updated GP classes
edaub Nov 3, 2021
d0eaf8e
skipped over MICEFastGP tests as they don't work with the new interface
edaub Nov 3, 2021
89df98b
reworked cholesky routines to give unfiorm interface
edaub Oct 6, 2021
4248ee6
fixed up tests and hessian to handle new linalg functions
edaub Nov 3, 2021
1743f49
updated documentation pages to reflect new classes
edaub Nov 3, 2021
f6fef9f
fixed problem in RTD build by fixing minimum sphinx version
edaub Nov 8, 2021
b853b35
fix handling of not-fit emulators - remove C++ exception that was thr…
nbarlowATI Nov 8, 2021
3fe069d
renamed inverse choleskly class
edaub Nov 9, 2021
44314fc
changed logdet function in ChoInv class
edaub Nov 10, 2021
4661f33
added additional linear algebra functions
edaub Nov 10, 2021
ed9e152
added method for multiplying design matrix by prior mean in MeanPriors
edaub Nov 10, 2021
fa94d64
Merge pull request #196 from alan-turing-institute/feature/multi-outp…
nbarlowATI Nov 12, 2021
2f4d6c9
fix merge conflicts
nbarlowATI Nov 12, 2021
b2cb1a7
renamed logdet_cov in MeanPriors for consistency
edaub Nov 16, 2021
ec94a9a
fixed issues with linalg routines
edaub Nov 16, 2021
a14c8a3
implemented analytical mean functions and derivatives
edaub Nov 16, 2021
fa47038
removed hessian computation
edaub Nov 16, 2021
20b1d1c
remove unused and obsolete imports from MultiOutputGP_GPU.py
nbarlowATI Nov 17, 2021
57c96f3
updated some docstrings in GP class
edaub Nov 18, 2021
b2e3326
steps towards adding and using GPPriors for hyperparameters
nbarlowATI Nov 18, 2021
5689791
GP with Parameters and Priors Classes (#203)
edaub Nov 18, 2021
e92a991
updated more docstrings
edaub Nov 23, 2021
7f1f123
updated Kernel docstrings
edaub Nov 23, 2021
39bf771
wrote docstrings for linalg routines
edaub Nov 23, 2021
7cebc4e
added docstrings to priors module
edaub Nov 24, 2021
0cee225
add test for gppriors C++
nbarlowATI Nov 24, 2021
5efb58f
WIP add GPPriors classes
nbarlowATI Nov 24, 2021
0f44cc1
add utility function to test instanceof
nbarlowATI Nov 24, 2021
663e3f0
change from static methods in GPParams to virtual methods, to be used…
nbarlowATI Nov 24, 2021
5a86e2d
merged devel into feature branch
edaub Nov 24, 2021
93874f2
bumped version number for merge
edaub Nov 24, 2021
e2dcd5a
restored kernel file to devel version with some docstring modifications
edaub Nov 24, 2021
2c25efc
add bindings for C++ priors
nbarlowATI Nov 30, 2021
7af06a5
removed fitting covariance flag from GPParams
edaub Dec 6, 2021
735cecb
removed fitting covariance from priors
edaub Dec 6, 2021
0f15cd2
removed fit covariance flag from GPParams
edaub Dec 6, 2021
9a373d5
added GP demos for different kernels
edaub Dec 8, 2021
5c7f59a
make use of GPPriors and GPParams
nbarlowATI Dec 20, 2021
f216f4e
make use of GPPriors and GPParams
nbarlowATI Dec 20, 2021
cf7b2e6
make use of GPPriors and GPParams
nbarlowATI Dec 20, 2021
1ce030e
make use of GPPriors and GPParams
nbarlowATI Dec 20, 2021
b4aa8b2
add enum for Prior type
nbarlowATI Dec 20, 2021
a3d4af8
add more C++ tests
nbarlowATI Dec 20, 2021
7efc290
remove GPU references from MultiOutputGP.py, since this is now implem…
nbarlowATI Dec 20, 2021
154dffd
add functionality via bindings to perform operations on individual em…
nbarlowATI Dec 21, 2021
58a569a
factor out functionality to get prior parameters in order to set them…
nbarlowATI Dec 21, 2021
84bc1c5
throw runtime error if fitting did not converge for GPU version
nbarlowATI Dec 21, 2021
4b445b0
return Eigen vects rather than std::vectors from log posterior methods
nbarlowATI Dec 21, 2021
df634cf
function to set flag that params have been fit
nbarlowATI Dec 21, 2021
3639d06
use GPParams, add ability to set nugget priors, remove commented out …
nbarlowATI Dec 21, 2021
cd860fc
test GPParams functionality
nbarlowATI Dec 21, 2021
def646e
update tests for GPU implementation
nbarlowATI Dec 21, 2021
ca7d56c
fix merge conflicts
nbarlowATI Dec 21, 2021
56ba349
comment out non-working GPU test for now
nbarlowATI Dec 21, 2021
a511ee5
update C++ test for GPParams object and transforms
nbarlowATI Dec 22, 2021
afba280
ensure nugget is dealt with for uncertainties in MOGP, in C++ impleme…
nbarlowATI Dec 22, 2021
b3a60bb
remove some unused data members. Ensure that mean params get reset w…
nbarlowATI Dec 22, 2021
f0ca88d
Change to meaning of theta vector to include both meanfunc params and…
nbarlowATI Dec 22, 2021
cbc93b9
ensure nugget is dealt with for uncertainties in MOGP, in C++ impleme…
nbarlowATI Dec 22, 2021
527b445
Change to meaning of theta vector to include both meanfunc params and…
nbarlowATI Dec 22, 2021
2cb9525
change meaning of n_params so that it now takes into account whether …
nbarlowATI Dec 22, 2021
a4dac47
sample from mean priors to get starting values for fitting
nbarlowATI Jan 5, 2022
c9970df
update docstrings
nbarlowATI Jan 5, 2022
002bf25
fix test - if not using fitted nugget, don't modify theta element
nbarlowATI Jan 6, 2022
b036b0c
take care that device vector for hyperparameters is correct size
nbarlowATI Jan 6, 2022
336244f
ensure that we set the nugget size correctly for fitted nugget
nbarlowATI Jan 6, 2022
a21e45f
remove debug printout
nbarlowATI Jan 6, 2022
828282b
Feature/analytical mean (#209)
edaub Jan 18, 2022
c26774c
Merge branch 'main' into v0.6.0
edaub Feb 4, 2022
f41fdbe
updated version number for new release
edaub Feb 4, 2022
5e0dc7d
remove references to gpu from MultiOutputGP.py - now use MultiOutputG…
nbarlowATI Feb 9, 2022
e4979a9
correct behaviour for no theta for both CPU and GPU implementations
nbarlowATI Feb 9, 2022
faf81ba
redefine n_params for consistency with CPU implementation
nbarlowATI Feb 9, 2022
dede77e
redefine n_params for consistency with CPU implementation
nbarlowATI Feb 9, 2022
11358f7
consistency with CPU version (correct number of params for theta0)
nbarlowATI Feb 9, 2022
776fc3f
only set nugget as last element of theta if nugget_type is fit
nbarlowATI Feb 9, 2022
a07cfc1
Bump version number
nbarlowATI Feb 10, 2022
b97a0e4
Fix/mean predictions (#221)
edaub Feb 18, 2022
4716329
implemented maximin LHC design (#222)
edaub Mar 4, 2022
35c3dd5
Update doc example to use fix_GP_MAP
ots22 Mar 7, 2022
9c3ce03
Update doc comments in DimensionReduction and add reference
ots22 Mar 7, 2022
110f777
Fix link
ots22 Mar 7, 2022
0912e43
Merge branch 'devel' into fix/dim-reduction-docs
ots22 Mar 8, 2022
d33ae95
Update setup.py
ots22 Mar 8, 2022
a6781d7
Merge pull request #224 from alan-turing-institute/fix/dim-reduction-…
ots22 Mar 8, 2022
6586a99
matched GPU class by adding additional methods and tests to MOGP class
edaub Mar 25, 2022
0979cd3
updated ubuntu and python versions in travis build to fix problem wit…
edaub Mar 29, 2022
0a98382
Merge branch 'devel' into feature/mogp_methods
edaub Mar 29, 2022
95b8879
Make GPU implementation of MultiOutputGP return an array of size n_em…
nbarlowATI Apr 1, 2022
8ef36e8
merge latest changes
nbarlowATI Apr 5, 2022
d10a11b
consolidation and test fixes after merging latest changes in
nbarlowATI Apr 6, 2022
da017b1
make n_corr return a vector for multi-output gps
nbarlowATI Apr 6, 2022
6508f5f
steps towards tidying up GPU priors - enable different distributions …
nbarlowATI Apr 7, 2022
236ac41
streamline and make more flexible the way of getting prior parameters…
nbarlowATI Apr 8, 2022
ccb3b1c
move to kwargs for create_prior_params
nbarlowATI Apr 8, 2022
59d8520
MOGP methods to match GPU (#225)
edaub Apr 8, 2022
d4b55d3
fix arguments in calls to functions that create and set priors
nbarlowATI Apr 11, 2022
30f0314
n_data to n_params in tests
nbarlowATI Apr 11, 2022
6451303
remove unnecessary second setting of meanfunc and data parameters in …
nbarlowATI Apr 11, 2022
087f916
Multi-Output History Matching (#210)
edaub Apr 11, 2022
fe61d53
ensure that nug_size is always initialized
nbarlowATI Apr 11, 2022
2dad83b
add comment describing RNG seed setting, and re-remove create_nug_pri…
nbarlowATI Apr 12, 2022
8091adb
merge latest devel changes
nbarlowATI Apr 12, 2022
05e1231
Feature/validation (#226)
edaub May 4, 2022
9e9ec64
merge devel
nbarlowATI May 6, 2022
6a83a03
fix mistake introduced by merge with devel
nbarlowATI May 6, 2022
443b0d4
make extra certain that fitting fails for test
nbarlowATI May 6, 2022
768fd30
add comment around creation of default priors saying that meanfunc pa…
nbarlowATI May 6, 2022
a32c868
add comments about MeanFunc parameters getting weak priors, and also …
nbarlowATI May 6, 2022
c233e2d
Merge pull request #211 from alan-turing-institute/feature/gpu_priors
nbarlowATI May 6, 2022
a1498e9
fixed version number for release
edaub May 9, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: python
dist: focal
python:
- "3.7"
- "3.9"
install:
- pip install 'numpy>=1.19'
- pip install -r requirements.txt
Expand Down
27 changes: 27 additions & 0 deletions docs/demos/multioutput_tutorial.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.. _multioutput_tutorial:

Multi-Output Tutorial
=====================

*Note: This tutorial requires Scipy version 1.4 or later to run the simulator.*

This page includes an end-to-end example of using ``mogp_emulator`` to perform model calibration
with a simulator with multiple outputs. Note that this builds on the main tutorial with a
second output (in this case, the velocity of the projectile at the end of the simulation),
which is able to further constrain the NROY space as described in the first tutorial.

.. literalinclude:: ../../mogp_emulator/demos/multioutput_tutorial.py

One thing to note about multiple outputs is that they must be run as a script with a
``if __name__ == __main__`` block in order to correctly use the multiprocessing
library. This can usually be done as in the example for short scripts, while for more
complex analyses it is usually better to define functions (as in the benchmark for
multiple outputs).

More Details
------------

More details about these steps can be found in the :ref:`methods` section, or on the following page
that goes into :ref:`more details <methoddetails>` on the options available in this software library.
For more on the specific implementation detials, see the various
:ref:`implementation pages <implementation>` describing the software components.
1 change: 1 addition & 0 deletions docs/implementation/DimensionReduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ Utilities
.. rubric:: References
.. [Fukumizu1] https://www.ism.ac.jp/~fukumizu/software.html
.. [FL13] Fukumizu, Kenji and Chenlei Leng. "Gradient-based kernel dimension reduction for regression." Journal of the American Statistical Association 109, no. 505 (2014): 359-370
.. [LG17] Liu, Xiaoyu and Guillas, Serge. "Dimension Reduction for Gaussian Process Emulation: An Application to the Influence of Bathymetry on Tsunami Heights." SIAM/ASA Journal on Uncertainty Quantification 5, no. 1 (2017): 787-812 https://doi.org/10.1137/16M1090648
15 changes: 15 additions & 0 deletions docs/implementation/ExperimentalDesign.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,19 @@ The ``LatinHypercubeDesign`` Class
:members:
:inherited-members:

.. automethod:: __init__

**********************************
The ``MaxiMinLHC`` Class
**********************************

.. _MaxiMinLHC:

.. automodule:: mogp_emulator.ExperimentalDesign.MaxiMinLHC
:noindex:

.. autoclass:: mogp_emulator.ExperimentalDesign.MaxiMinLHC
:members:
:inherited-members:

.. automethod:: __init__
1 change: 1 addition & 0 deletions docs/implementation/implementation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ mogp_emulator Implementation Details
GaussianProcessGPU
MultiOutputGP
fitting
validation
MeanFunction
formula
Kernel
Expand Down
9 changes: 9 additions & 0 deletions docs/implementation/validation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.. _validation:

**********************************
The ``validation`` Module
**********************************

.. automodule:: mogp_emulator.validation
:members:
:noindex:
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ details, and some included benchmarks.
be used are:

demos/gp_demos
demos/multioutput_tutorial
demos/gp_kernel_demos
demos/mice_demos
demos/historymatch_demos
Expand Down
32 changes: 19 additions & 13 deletions docs/intro/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ the two input parameters of the drag coefficient :math:`C` and the initial veloc
and returning a single value, which is :math:`x` at the end of the simulation.

.. literalinclude:: ../../mogp_emulator/demos/projectile.py
:lines: 1-3,12-43,46-
:lines: 1-80

Parameter Space
~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -103,7 +103,7 @@ distributions are fairly common due to their simplicity.
To construct our experimental design and draw samples from it, we do the following:

.. literalinclude:: ../../mogp_emulator/demos/tutorial.py
:lines: 1-4,24-28
:lines: 1-5,25-29

This constructs an instance of :ref:`LatinHypercubeDesign <LatinHypercubeDesign>`, and
creates the underlying distributions by providing a list of tuples. Each tuple gives the
Expand Down Expand Up @@ -131,11 +131,13 @@ by passing the GP object to the ``fit_GP_MAP`` function, which returns the same
GP object but with the parameter values estimated.

.. literalinclude:: ../../mogp_emulator/demos/tutorial.py
:lines: 33-37
:lines: 34-40

While the function is called ``fit_GP_MAP`` (MAP means Maximum A Posteriori),
in this case we have not provided any prior information on the parameter values,
so it results in MLE.
By default, if no priors are specified for the hyperparameters then defaults
are chosen. In particular, for correlation lengths, default priors are fit
that attempt to put most of the distribution mass in the range spanned by
the input data. This tends to stabilize the fitting and improve performance,
as fewer iterations are needed to ensure a good fit.

Following fitting, we print out some of the hyperparameters that are estimated.
First, we print out the correlation lengths estimated for each of the input
Expand All @@ -162,15 +164,19 @@ and the uncertainty. This is done with the ``predict`` method of
:ref:`GaussianProcess <GaussianProcess>`:

.. literalinclude:: ../../mogp_emulator/demos/tutorial.py
:lines: 44-52
:lines: 46-55

``predictions`` is an object containing the mean and uncertainty (variance)
of the predictions. A GP assumes that the outputs follow a Normal Distribution,
so we can perform validation by asking how many of our validation points mean estimates
are within 2 standard deviations of the true value. Usually for this example this is
about 8/10, so not quite as we would expect if it were perfectly recreating the
function. However, we will see that this still is good enough in most cases
for the task at hand.
are within 2 standard deviations of the true value by computing the standard errors
of the emulator predictions on the validation points. ``mogp_emulator`` contains
a number of methods of automatically validating an emulator given some validation
points, including computing standard errors (see the :ref:`validation <validation>`
documentation for more details). Usually for this example we would expect
about 8/10 to be within 2 standard devations, so not quite as we would expect if
it were perfectly recreating the function. However, we will see that this still is
good enough in most cases for the task at hand.

History Matching
~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -206,7 +212,7 @@ and Monte Carlo sampling (especially in only 2 dimensions). Then, we create a
Yet" (NROY). This is done as follows:

.. literalinclude:: ../../mogp_emulator/demos/tutorial.py
:lines: 58-65
:lines: 60-68

First, we set a large number of samples and draw them from the experimental design object. Then,
We construct the :ref:`HistoryMatching <HistoryMatching>` object by giving the fit GP
Expand All @@ -226,7 +232,7 @@ surrogate model for reference. This plotting command is only executed if ``matpl
installed:

.. literalinclude:: ../../mogp_emulator/demos/tutorial.py
:lines: 5-10,69-
:lines: 6-11,71-

which should make a plot that looks something like this:

Expand Down
24 changes: 7 additions & 17 deletions mogp_emulator/DimensionReduction.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""This module provides classes and utilities for performing dimension
reduction. Currently there is a single class :class:`mogp_emulator.gKDR` which implements
the method of Fukumizu and Leng [FL13]_.
reduction. There is a single class :class:`mogp_emulator.gKDR` which
implements the method of Fukumizu and Leng [FL13]_, and which can be
used jointly with Gaussian process emulation as in [LG17]_.

Example: ::

Expand Down Expand Up @@ -120,21 +121,11 @@ class gKDR(object):

"""Dimension reduction by the gKDR method.

See link [Fukumizu1]_ (and in particular, [FL13]_) for details of
the method.

Note that this is a simpler and faster method than the original
"KDR" method by the same authors (but with an added
approximation). The KDR method will be implemented separately.
See [Fukumizu1]_, [FL13]_ and [LG17]_.

An instance of this class is callable, with the ``__call__``
method taking an input coordinate and mapping it to a reduced
coordinate.

Note that this class currently implements a *direct* translation
of the Matlab implementation of KernelDeriv (see link above) into
Python/NumPy. It is due to be replaced with a Fortran
implementation, but this should not affect the interface.
"""

def __init__(self, X, Y, K=None, X_scale = 1.0, Y_scale = 1.0, EPS=1E-8, SGX=None, SGY=None):
Expand Down Expand Up @@ -378,18 +369,17 @@ def tune_parameters(cls, X, Y, train_model, cXs=None, cYs=None,
within the kernel, minimizing the the loss from a
Gaussian process regression:

>>> from mogp_emulator import gKDR
>>> from mogp_emulator import GaussianProcess
>>> from mogp_emulator import gKDR, GaussianProcess, fit_GP_MAP
>>> X = ...
>>> Y = ...
>>> dr, loss = gKDR.tune_parameters(X, Y, GaussianProcess.train_model)
>>> dr, loss = gKDR.tune_parameters(X, Y, fit_GP_MAP)
>>> gp = GaussianProcess(dr(X), Y)

Or, specifying some optional parameters for the lengthscales,
the maximum value of `K` to use, the number of folds for
cross-validation, and producing verbose output:

>>> dr, loss = gKDR.tune_parameters(X, Y, GaussianProcess.train_model,
>>> dr, loss = gKDR.tune_parameters(X, Y, fit_GP_MAP,
... cXs = [0.5, 1.0, 2.0], cYs = [2.0],
... maxK = 25, cross_validation_folds=4, verbose = True)

Expand Down
115 changes: 103 additions & 12 deletions mogp_emulator/ExperimentalDesign.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
import scipy.stats
from scipy.spatial.distance import pdist
from inspect import signature

class ExperimentalDesign(object):
Expand Down Expand Up @@ -235,13 +236,13 @@ def _draw_samples(self, n_samples):
"""
raise NotImplementedError

def sample(self, n_samples):
def sample(self, n_samples, **kwargs):
"""
Draw parameter samples from the experimental design

This method implements drawing parameter samples from the experimental design. The method does
this by calling the ``_draw_samples`` method to obtain samples from the :math:`[0,1]^n` hypercube,
where :math:`n` is the number of parameters. The ``sample``method then transforms these samples
where :math:`n` is the number of parameters. The ``sample`` method then transforms these samples
drawn from the low level method to the actual parameter values using the PPF functions provided
when initilizing the object. Note that this method also checks that all parameter values are
finite; if any ``NaN`` values are returned, an error will be raised.
Expand All @@ -250,6 +251,9 @@ def sample(self, n_samples):
using a different protocol only needs to change the ``_draw_samples`` method. This makes it
simpler to define new designs, as only a single method needs to be altered.

Also accepts a ``kwargs`` argument to allow other derived classes to implement additional
keyword arguments.

:param n_samples: Number of samples to be drawn from the design (must be a positive integer)
:type n_samples: int
:returns: Samples drawn from the design parameter space as a numpy array with shape
Expand All @@ -261,16 +265,13 @@ def sample(self, n_samples):
assert n_samples > 0, "number of samples must be positive"

sample_values = np.zeros((n_samples, self.get_n_parameters()))
random_draws = self._draw_samples(n_samples)
random_draws = self._draw_samples(n_samples, **kwargs)

assert np.all(random_draws >= 0.) and np.all(random_draws <= 1.), "error in generating random samples"

for (dist, index) in zip(self.distributions, range(self.get_n_parameters())):
try:
sample_values[:,index] = dist(random_draws[:,index])
except:
for sample_index in range(n_samples):
sample_values[sample_index, index] = dist(random_draws[sample_index,index])
for sample_index in range(n_samples):
sample_values[sample_index, index] = dist(random_draws[sample_index,index])

assert np.all(np.isfinite(sample_values)), "error due to non-finite values of parameters"

Expand Down Expand Up @@ -406,7 +407,7 @@ def __init__(self, *args):
self.method = "Monte Carlo"
super().__init__(*args)

def _draw_samples(self, n_samples):
def _draw_samples(self, n_samples, **kwargs):
"""
Low level method for drawing random samples from a Monte Carlo design

Expand Down Expand Up @@ -546,7 +547,7 @@ def __init__(self, *args):
self.method = "Latin Hypercube"
super().__init__(*args)

def _draw_samples(self, n_samples):
def _draw_samples(self, n_samples, **kwargs):
"""
Low level method for drawing random samples from a Latin Hypercube design

Expand All @@ -560,7 +561,7 @@ def _draw_samples(self, n_samples):

:param n_samples: Number of samples to be drawn from the design (must be a positive integer)
:type n_samples: int
:returns: Random Monte Carlo samples drawn from the :math:`[0,1]^n` hypercube as a numpy
:returns: Random samples drawn from the :math:`[0,1]^n` hypercube as a numpy
array with shape ``(n_samples, n_parameters)``
:rtype: ndarray
"""
Expand All @@ -580,4 +581,94 @@ def _draw_samples(self, n_samples):

assert np.all(random_samples >= 0.) and np.all(random_samples <= 1.), "error in generating latin hypercube samples"

return random_samples
return random_samples

class MaxiMinLHC(LatinHypercubeDesign):
def __init__(self, *args):
"""
Class representing a one-shot design of experiments with uncorrelated parameters using
MaxiMin Latin Hypercube Sampling

This class provides an implementation for a class for designing experiments to sample
the parameter space of a complex model using MaxiMin Latin Hypercube sampling. MaxiMin
LHCs repeatedly draw samples from the base LHC design, keeping the realization that
maximizes the minimum pairwise distance between all design points. Because of this,
MaxiMin designs tend to spread their samples closer to the edge of the parameter
space and in many cases result in more accurate sampling than a single LHC draw.

The parameter space can be specified in a variety of ways, but essentially the user must
provide a Probability Point Function (PPF, or inverse of the Cumulative Distribution Function)
for each input parameter. Each PPF function takes a single numeric input and maps from
the interval :math:`[0,1]` to the desired parameter distribution value for a given parameter,
and each parameter has a separate function describing its distribution. Note that this makes
the assumption of no correlations between any of the parameter values (a future version may
implement an experimental design where there are such parameter correlations). Once the
design is initialized, a desired number of samples can be drawn from the design, returning
an array holding the desired number of samples from the parameter space.

Internally, the class holds the set of PPFs for all of the parameter values, and samples are
drawn by calling the ``sample`` method. To draw the samples, the ``_draw_samples`` is used
to generate a series of points in the :math:`[0,1]^n` hypercube using MaxiMin Latin Hypercube
sampling, where :math:`n` is the number of paramters. This set of samples from the Latin
Hypercube is then mapped to the parameter space using the given PPF functions.

Unlike Monte Carlo sampling, Latin Hypercube designs attempt to sample more uniformly from the
parameter space. Latin Hypercube sampling ensures that each sample is drawn from a different
part of the space for each parameter. For example, if four samples are drawn, then for each
parameter, one sample is guaranteed to be drawn from each quartile of the distribution. This
ensures a more uniform sampling when compared on Monte Carlo sampling, but requires slightly
more computation to generate the samples. Note however, that for very large numbers of parameters,
Latin Hypercubes still may not sample very efficiently. This is due to the fact that the size of
the parameter space grows exponentially with the number of dimensions, so a fixed number of
samples will sample the space more poorly as the number of parameters increases.
"""
self.method = "MaxiMinLHC"
super().__init__(*args)

def _draw_samples(self, n_samples, n_tries=1000, **kwargs):
"""
Sampling method for MaxiMin LHCs

Iterates over multiple LHCs and return the one that maximizes the
minimum distance between pairs of points. The number of iterations
over which to look for this MaxiMin critera can be specified by
``n_tries``.

Distances are computed by ``scipy.spatial.distance.pdist``. Any
additional ``kwargs`` passed here will be sent on to the ``pdist``
function.

:param n_samples: Number of samples to be drawn from the design (must be a positive integer)
:type n_samples: int
:param n_tries: Number of LHC realizations to use in maximizing
the MaxiMin criteria
:type n_tries: int
:param **kwargs: Keyword arguments to be passed to the
``scipy.spatial.distance.pdist`` function.
:returns: Random Monte Carlo samples drawn from the :math:`[0,1]^n` hypercube as a numpy
array with shape ``(n_samples, n_parameters)``
:rtype: ndarray
"""

n_samples = int(n_samples)
assert n_samples > 0, "number of samples must be positive"
assert n_tries > 0, "n_tries must be a positive integer"
n_tries = int(n_tries)

n_parameters = self.get_n_parameters()

best_samples = np.empty((n_samples, n_parameters))
max_dist = -np.inf

for i in range(n_tries):
random_samples = super()._draw_samples(n_samples)
min_dist = np.min(pdist(random_samples, **kwargs))
if min_dist > max_dist:
max_dist = min_dist
best_samples = random_samples

assert np.all(best_samples >= 0.0) and np.all(
best_samples <= 1.0
), "error in generating latin hypercube samples"

return best_samples
Loading