-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
630 additions
and
34,634 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ name: client-R-cran-package | |
|
||
on: | ||
push: | ||
pull_request: | ||
branches: | ||
- 'main' | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ name: client-R-git-package | |
|
||
on: | ||
push: | ||
pull_request: | ||
branches: | ||
- 'main' | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ name: client-c++-example | |
|
||
on: | ||
push: | ||
pull_request: | ||
branches: | ||
- 'main' | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ name: client-c++ | |
|
||
on: | ||
push: | ||
pull_request: | ||
branches: | ||
- 'main' | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ name: client-python-emcee | |
|
||
on: | ||
push: | ||
pull_request: | ||
branches: | ||
- 'main' | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ name: client-python-example | |
|
||
on: | ||
push: | ||
pull_request: | ||
branches: | ||
- 'main' | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ name: client-python-pymc | |
|
||
on: | ||
push: | ||
pull_request: | ||
branches: | ||
- 'main' | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ name: client-python-qmcpy | |
|
||
on: | ||
push: | ||
pull_request: | ||
branches: | ||
- 'main' | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ name: client-python-raw | |
|
||
on: | ||
push: | ||
pull_request: | ||
branches: | ||
- 'main' | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ name: client-python-tinyDA | |
|
||
on: | ||
push: | ||
pull_request: | ||
branches: | ||
- 'main' | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ name: client-python | |
|
||
on: | ||
push: | ||
pull_request: | ||
branches: | ||
- 'main' | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ __pycache__/ | |
build/ | ||
.ipynb_checkpoints/ | ||
.vscode/ | ||
.idea/ | ||
kubernetes/setup/secret.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
function check_sgmk() | ||
|
||
% An aux function to check and download the sparse grids matlab kit | ||
|
||
if exist('create_sparse_grid', 'file')==0 | ||
% the sgmk is not found in the current path, so either we don't have it or we are not in the right subfolder | ||
|
||
if exist('sparse-grids-matlab-kit', 'dir')==0 | ||
% there is no subfolder -> we don't have sgmk. Need to download it (if we haven't yet) and unzip | ||
|
||
if exist('sgmk.zip', 'file')==0 | ||
% zip not found, let's download it | ||
|
||
try | ||
disp('Sparse Grids Matlab Kit not found, downloading from github (https://github.com/lorenzo-tamellini/sparse-grids-matlab-kit/)...'); | ||
opts = weboptions; | ||
opts.CertificateFilename=(''); % No idea why this is needed | ||
opts.Timeout = 100; % a larger timeout (in ms, default 5), just in case internet is slow today | ||
websave('sgmk.zip', 'https://github.com/lorenzo-tamellini/sparse-grids-matlab-kit/archive/refs/heads/main.zip', opts); | ||
disp('... done'); | ||
catch ME | ||
fprintf('\nAutomatic download from github failed. Try manual download, from either github or project website https://sites.google.com/view/sparse-grids-kit. Download the latest version in .zip and name it sgmk.zip \n\n') | ||
error(ME.identifier,ME.message); | ||
end | ||
end | ||
|
||
% now we have the zip, unzip | ||
try | ||
disp('unzipping ...'); | ||
unzip('sgmk.zip','sparse-grids-matlab-kit'); | ||
disp('done'); | ||
catch ME | ||
error('%s. Automatic unzipping failed. Please extract sgmk.zip here', ME.message); | ||
end | ||
end | ||
|
||
% ready to add to path. Mind the double folder | ||
cd('sparse-grids-matlab-kit/sparse-grids-matlab-kit-main'); | ||
addpath(genpath(pwd)) | ||
disp('added Sparse Grids Matlab Kit to path') | ||
cd('../..'); | ||
|
||
else | ||
% the sgmk is found in the current path, we're good to go | ||
|
||
disp('Sparse Grids Matlab Kit is already in Matlab''s path') | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
clear | ||
|
||
% Analytic-gaussian-mixture. Use the sparse grids matlab kit as a high-dimensional quadrature tool to compute the | ||
% integral of the posterior density function (pdf) defined in the benchmark. The problem is a bit challenging so even a poor result is | ||
% ok, this is just for testing the client. The pdfs in the benchmark is not normalized so the integral should be | ||
% around 3 | ||
|
||
% add the Sparse Grids Matlab Kit to your path | ||
check_sgmk() | ||
% run these commands too if you haven't umbridge in your path | ||
% currdir = pwd; | ||
% cd ../../matlab/ | ||
% addpath(genpath(pwd)) | ||
% cd(currdir) | ||
|
||
% also, start the Analytic-gaussian-mixture container | ||
% sudo docker run -it -p 4243:4243 linusseelinger/benchmark-analytic-gaussian-mixture | ||
|
||
% uri of the service running the server | ||
uri = 'http://localhost:4243'; | ||
|
||
% HTTPModel is an object provided by the UM-Bridge Matlab client. | ||
% model = HTTPModel(uri, 'posterior'); | ||
model = HTTPModel(uri, 'posterior','webwrite'); % let's use webwrite, it's much faster | ||
|
||
% model.evaluate(y) sends a request to the server to evaluate the model at y. Wrap it in an @-function: | ||
f = @(y) model.evaluate(y); | ||
|
||
% define the sparse grid. Here we create it a basic one, but it can be as sophisticated as the user wants | ||
N=2; | ||
w=7; | ||
% it is convenient to define the quadrature domain by a matrix D. IF the domain is [a b] x [c d], take each interval | ||
% as a column, so that | ||
% D = [a c ; | ||
% b d ]; | ||
domain = [-5.5 -5; | ||
5 5.5]; | ||
knots = {@(n) knots_CC(n,domain(1,1),domain(2,1),'nonprob'), @(n) knots_CC(n,domain(1,2),domain(2,2),'nonprob')}; | ||
S = create_sparse_grid(N,w,knots,@lev2knots_doubling); | ||
Sr = reduce_sparse_grid(S); | ||
f_evals = evaluate_on_sparse_grid(f,Sr); | ||
|
||
% from here on, do whatever UQ analysis you want with the values contained in f_evals. Here we just check that | ||
% the pdf integrates to 3 (the benchmark is not normalized). Note that the values returned by the container | ||
% and stored in f_evals are actually the log-posterior, so we need to take their exponent before computing the integral | ||
|
||
Ev = quadrature_on_sparse_grid(exp(f_evals),Sr) | ||
|
||
|
||
% We also plot the sparse grids interpolant of the function in the benchmark | ||
figure | ||
plot_sparse_grids_interpolant(S,Sr,domain,exp(f_evals),'nb_plot_pts',80) | ||
figure | ||
plot_sparse_grids_interpolant(S,Sr,domain,f_evals,'with_f_values') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.