From 3d67db4802d6a30d073b79b8b7f8ff263196ee7f Mon Sep 17 00:00:00 2001 From: Marlena Weidenauer <134061260+marlenaweidenauer@users.noreply.github.com> Date: Sat, 22 Jul 2023 17:44:51 +0200 Subject: [PATCH 01/18] Update README.md added preliminary Matlab client --- clients/README.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/clients/README.md b/clients/README.md index 88f02c3..1396df1 100644 --- a/clients/README.md +++ b/clients/README.md @@ -384,3 +384,40 @@ if __name__ == "__main__": ``` [Full example sources here.](https://github.com/UM-Bridge/umbridge/blob/main/clients/python/emcee-client.py) + +## Matlab client + +The Matlab integration can be found in the [git repository](https://github.com/UM-Bridge/umbridge/tree/main/matlab). + +We use the Matlab function `addpath()` to add the specified folder. + +``` +umbridge_supported_models('http://localhost:4243‘) +model = HTTPModel('http://localhost:4243‘, 'forward'); +``` + +`umbridge_supported_models()` gives a list of models that are supported by the current server. We set up a model by connecting to the URL and selecting for example the „forward“ model. We obtain its input and output dimensions using the functions + + +``` +model.get_input_sizes() +model.get_output_sizes() +``` + +A model that expects an input consisting of a single 2D vector can be evaluated as follows. + +``` +model.evaluate([100.0, 18.0]) +model.evaluate([100.0, 18.0], config) +``` + +If the model accepts configuartion parameters, we can add those to the model evaluation. The config options accepted by a particular model can be found in the model’s documentation. + +Furthermore a model indicates wheather it supports further features. The following example evaluates the Jacobian of model output zero with respect to model input zero at the same input parameter as before. It then applies it to the additional vector given. + +``` +model.apply_jacobian([1.0,4.0],[100.0, 18.0], 0, 0) +``` +[Full example sources here.](https://github.com/UM-Bridge/umbridge/blob/main/clients/matlab/matlabClient.m) + + From 401022c9658f6ad94ed8b9fe184c19f34523f547 Mon Sep 17 00:00:00 2001 From: Marlena Weidenauer <134061260+marlenaweidenauer@users.noreply.github.com> Date: Tue, 22 Aug 2023 14:23:20 +0200 Subject: [PATCH 02/18] modified Matlab client --- clients/matlab/matlab_client.m | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 clients/matlab/matlab_client.m diff --git a/clients/matlab/matlab_client.m b/clients/matlab/matlab_client.m new file mode 100644 index 0000000..31860a5 --- /dev/null +++ b/clients/matlab/matlab_client.m @@ -0,0 +1,27 @@ +% use matlab function addpath('') + +uri = 'http://localhost:4242'; + +% Print models supported by server +umbridge_supported_models(uri) + +% Set up a model by connecting to URL and selecting the "forward" model +model = HTTPModel(uri,'forward'); + +model.get_input_sizes() +model.get_output_sizes() + +param=[0, 10.0]; + +% Simple model evaluation without config +model.evaluate(param) + +%Model evaluation with configuration parameters +config = struct('vtk_output', true, 'level', 1); +model.evaluate(param, config) + +% If model supports Jacobian action, +% apply Jacobian of output zero with respect to input zero to a vector +if model.supports_apply_jacobian() + model.apply_jacobian([1.0,4.0],param, 0, 0) +end \ No newline at end of file From 86eae5341fd080f7305e59e18b7d0e60c40db987 Mon Sep 17 00:00:00 2001 From: Marlena Weidenauer <134061260+marlenaweidenauer@users.noreply.github.com> Date: Tue, 22 Aug 2023 14:41:54 +0200 Subject: [PATCH 03/18] Update README.md added Matlab client --- clients/README.md | 73 +++++++++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/clients/README.md b/clients/README.md index 1396df1..f6738ac 100644 --- a/clients/README.md +++ b/clients/README.md @@ -181,6 +181,42 @@ if (supports_apply_jacobian(url, name)) { [Full example sources here.](https://github.com/UM-Bridge/umbridge/tree/main/clients/R) +## Matlab client + +The Matlab integration can be found in the [git repository](https://github.com/UM-Bridge/umbridge/tree/main/matlab). + +We use the Matlab function `addpath()` to add the specified folder. + +``` +umbridge_supported_models('http://localhost:4242‘) +model = HTTPModel('http://localhost:4242‘, 'forward'); +``` + +`umbridge_supported_models()` gives a list of models that are supported by the current server. We set up a model by connecting to the URL and selecting for example the „forward“ model. We obtain its input and output dimensions using the functions + + +``` +model.get_input_sizes() +model.get_output_sizes() +``` + +A model that expects an input consisting of a single 2D vector can be evaluated as follows. + +``` +model.evaluate([0, 10.0]) +model.evaluate([0, 10.0], config) +``` + +If the model accepts configuartion parameters, we can add those to the model evaluation. The config options accepted by a particular model can be found in the model’s documentation. + +Furthermore a model indicates wheather it supports further features. The following example evaluates the Jacobian of model output zero with respect to model input zero at the same input parameter as before. It then applies it to the additional vector given. + +``` +model.apply_jacobian([1.0,4.0], [0, 10.0], 0, 0) +``` + +[Full example sources here.](https://github.com/UM-Bridge/umbridge/blob/main/clients/matlab/matlab_client.m) + ## MUQ client Within the [MIT Uncertainty Quantification library (MUQ)](https://mituq.bitbucket.io), there is a ModPiece available that allows embedding an HTTP model in MUQ's model graph framework. @@ -384,40 +420,3 @@ if __name__ == "__main__": ``` [Full example sources here.](https://github.com/UM-Bridge/umbridge/blob/main/clients/python/emcee-client.py) - -## Matlab client - -The Matlab integration can be found in the [git repository](https://github.com/UM-Bridge/umbridge/tree/main/matlab). - -We use the Matlab function `addpath()` to add the specified folder. - -``` -umbridge_supported_models('http://localhost:4243‘) -model = HTTPModel('http://localhost:4243‘, 'forward'); -``` - -`umbridge_supported_models()` gives a list of models that are supported by the current server. We set up a model by connecting to the URL and selecting for example the „forward“ model. We obtain its input and output dimensions using the functions - - -``` -model.get_input_sizes() -model.get_output_sizes() -``` - -A model that expects an input consisting of a single 2D vector can be evaluated as follows. - -``` -model.evaluate([100.0, 18.0]) -model.evaluate([100.0, 18.0], config) -``` - -If the model accepts configuartion parameters, we can add those to the model evaluation. The config options accepted by a particular model can be found in the model’s documentation. - -Furthermore a model indicates wheather it supports further features. The following example evaluates the Jacobian of model output zero with respect to model input zero at the same input parameter as before. It then applies it to the additional vector given. - -``` -model.apply_jacobian([1.0,4.0],[100.0, 18.0], 0, 0) -``` -[Full example sources here.](https://github.com/UM-Bridge/umbridge/blob/main/clients/matlab/matlabClient.m) - - From 669c26b1fdee7a7af6dac2511aa07c9e05b7c4cd Mon Sep 17 00:00:00 2001 From: Marlena Weidenauer <134061260+marlenaweidenauer@users.noreply.github.com> Date: Fri, 1 Sep 2023 14:04:57 +0200 Subject: [PATCH 04/18] Update matlab_client.m changed client, connecting to a posterior model --- clients/matlab/matlab_client.m | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/clients/matlab/matlab_client.m b/clients/matlab/matlab_client.m index 31860a5..282ca20 100644 --- a/clients/matlab/matlab_client.m +++ b/clients/matlab/matlab_client.m @@ -1,12 +1,12 @@ % use matlab function addpath('') -uri = 'http://localhost:4242'; +uri = 'http://localhost:4243'; % Print models supported by server umbridge_supported_models(uri) -% Set up a model by connecting to URL and selecting the "forward" model -model = HTTPModel(uri,'forward'); +% Set up a model by connecting to URL and selecting the "posterior" model +model = HTTPModel(uri,'posterior'); model.get_input_sizes() model.get_output_sizes() @@ -16,12 +16,8 @@ % Simple model evaluation without config model.evaluate(param) -%Model evaluation with configuration parameters -config = struct('vtk_output', true, 'level', 1); -model.evaluate(param, config) - % If model supports Jacobian action, % apply Jacobian of output zero with respect to input zero to a vector if model.supports_apply_jacobian() model.apply_jacobian([1.0,4.0],param, 0, 0) -end \ No newline at end of file +end From 644b0fdc546d1af4ea428c67e080645c778627eb Mon Sep 17 00:00:00 2001 From: Marlena Weidenauer <134061260+marlenaweidenauer@users.noreply.github.com> Date: Fri, 1 Sep 2023 14:26:58 +0200 Subject: [PATCH 05/18] Update README.md changed Matlab client to posterior --- clients/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/clients/README.md b/clients/README.md index f6738ac..0296b43 100644 --- a/clients/README.md +++ b/clients/README.md @@ -188,11 +188,11 @@ The Matlab integration can be found in the [git repository](https://github.com/U We use the Matlab function `addpath()` to add the specified folder. ``` -umbridge_supported_models('http://localhost:4242‘) -model = HTTPModel('http://localhost:4242‘, 'forward'); +umbridge_supported_models('http://localhost:4243‘) +model = HTTPModel('http://localhost:4243‘, 'posterior'); ``` -`umbridge_supported_models()` gives a list of models that are supported by the current server. We set up a model by connecting to the URL and selecting for example the „forward“ model. We obtain its input and output dimensions using the functions +`umbridge_supported_models()` gives a list of models that are supported by the current server. We set up a model by connecting to the URL and selecting for example the „posterior“ model. We obtain its input and output dimensions using the functions ``` From f2cc675279b8214cd2540d7c84c5a982fb2fd184 Mon Sep 17 00:00:00 2001 From: Marlena Weidenauer <134061260+marlenaweidenauer@users.noreply.github.com> Date: Fri, 1 Sep 2023 14:30:50 +0200 Subject: [PATCH 06/18] Update matlab_client.m added model evaluation with config --- clients/matlab/matlab_client.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/clients/matlab/matlab_client.m b/clients/matlab/matlab_client.m index 282ca20..58bf25e 100644 --- a/clients/matlab/matlab_client.m +++ b/clients/matlab/matlab_client.m @@ -16,6 +16,10 @@ % Simple model evaluation without config model.evaluate(param) +%Model evaluation with configuration parameters +config = struct('a', 3.9); +model.evaluate(param, config) + % If model supports Jacobian action, % apply Jacobian of output zero with respect to input zero to a vector if model.supports_apply_jacobian() From a08ba29cbcac9b35a178e35474461d4f968b48f6 Mon Sep 17 00:00:00 2001 From: Marlena Weidenauer <134061260+marlenaweidenauer@users.noreply.github.com> Date: Fri, 1 Sep 2023 14:34:39 +0200 Subject: [PATCH 07/18] Update README.md changed matlab client, model evaluation with config --- clients/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/README.md b/clients/README.md index 0296b43..5a5ac24 100644 --- a/clients/README.md +++ b/clients/README.md @@ -204,7 +204,7 @@ A model that expects an input consisting of a single 2D vector can be evaluated ``` model.evaluate([0, 10.0]) -model.evaluate([0, 10.0], config) +model.evaluate([0, 10.0], struct('a', 3.9)) ``` If the model accepts configuartion parameters, we can add those to the model evaluation. The config options accepted by a particular model can be found in the model’s documentation. From f053ff3d99ce2b2ec635ddda642ab12de949abcf Mon Sep 17 00:00:00 2001 From: Marlena Weidenauer <134061260+marlenaweidenauer@users.noreply.github.com> Date: Fri, 8 Sep 2023 12:50:03 +0200 Subject: [PATCH 08/18] Delete clients/matlab/matlabClient.m --- clients/matlab/matlabClient.m | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 clients/matlab/matlabClient.m diff --git a/clients/matlab/matlabClient.m b/clients/matlab/matlabClient.m deleted file mode 100644 index 21caf2a..0000000 --- a/clients/matlab/matlabClient.m +++ /dev/null @@ -1,5 +0,0 @@ -uri = 'http://localhost:4243'; - -model = HTTPModel(uri,'posterior'); - -httpValue = model.evaluate([1, 3]) From f0fbcd20caa9bbccb4cd66ed3cb9d5f98762f050 Mon Sep 17 00:00:00 2001 From: Marlena Weidenauer <134061260+marlenaweidenauer@users.noreply.github.com> Date: Fri, 8 Sep 2023 12:51:15 +0200 Subject: [PATCH 09/18] Rename matlab_client.m to matlabClient.m --- clients/matlab/{matlab_client.m => matlabClient.m} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename clients/matlab/{matlab_client.m => matlabClient.m} (100%) diff --git a/clients/matlab/matlab_client.m b/clients/matlab/matlabClient.m similarity index 100% rename from clients/matlab/matlab_client.m rename to clients/matlab/matlabClient.m From 18a093e4c36c7522f0a95fdf521e7532813bfdb8 Mon Sep 17 00:00:00 2001 From: Marlena Weidenauer <134061260+marlenaweidenauer@users.noreply.github.com> Date: Fri, 8 Sep 2023 12:55:17 +0200 Subject: [PATCH 10/18] Update README.md fixed link --- clients/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/README.md b/clients/README.md index 5a5ac24..3d2f435 100644 --- a/clients/README.md +++ b/clients/README.md @@ -215,7 +215,7 @@ Furthermore a model indicates wheather it supports further features. The followi model.apply_jacobian([1.0,4.0], [0, 10.0], 0, 0) ``` -[Full example sources here.](https://github.com/UM-Bridge/umbridge/blob/main/clients/matlab/matlab_client.m) +[Full example sources here.](https://github.com/UM-Bridge/umbridge/blob/main/clients/matlab/matlabClient.m) ## MUQ client From bda7aa73f3f8b3590c71015355cdc2daffc0545d Mon Sep 17 00:00:00 2001 From: Marlena Weidenauer <134061260+marlenaweidenauer@users.noreply.github.com> Date: Fri, 8 Sep 2023 13:07:03 +0200 Subject: [PATCH 11/18] Update client-matlab.yml added repository --- .github/workflows/client-matlab.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/client-matlab.yml b/.github/workflows/client-matlab.yml index a751aeb..c844a5f 100644 --- a/.github/workflows/client-matlab.yml +++ b/.github/workflows/client-matlab.yml @@ -4,7 +4,8 @@ on: push: branches: - 'main' - + - 'marlenaweidenauer-patch-2' + jobs: test: runs-on: ubuntu-latest @@ -24,4 +25,4 @@ jobs: - name: Run all tests uses: matlab-actions/run-tests@v1 with: - source-folder: matlab; clients/matlab \ No newline at end of file + source-folder: matlab; clients/matlab From b173a6fec0c1d1fcdce6583f95d96cf30c8e802a Mon Sep 17 00:00:00 2001 From: Marlena Weidenauer <134061260+marlenaweidenauer@users.noreply.github.com> Date: Sun, 10 Sep 2023 17:22:41 +0200 Subject: [PATCH 12/18] Update client-matlab.yml changed image to analytic funnel --- .github/workflows/client-matlab.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/client-matlab.yml b/.github/workflows/client-matlab.yml index c844a5f..3b691d6 100644 --- a/.github/workflows/client-matlab.yml +++ b/.github/workflows/client-matlab.yml @@ -12,7 +12,7 @@ jobs: services: model: - image: linusseelinger/benchmark-analytic-banana + image: linusseelinger/benchmark-analytic-funnel:latest ports: - 4243:4243 From 95ab47d399a6cab236eb765b10d8f611c761a415 Mon Sep 17 00:00:00 2001 From: Marlena Weidenauer <134061260+marlenaweidenauer@users.noreply.github.com> Date: Sun, 10 Sep 2023 17:32:50 +0200 Subject: [PATCH 13/18] Update TestMatlab.m changed value corresponding to analytic funnel --- testing/clients/TestMatlab.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/clients/TestMatlab.m b/testing/clients/TestMatlab.m index d717a7f..4dc6fbf 100644 --- a/testing/clients/TestMatlab.m +++ b/testing/clients/TestMatlab.m @@ -8,7 +8,7 @@ function testConnection(testCase) model = HTTPModel(uri,'posterior'); httpValue = model.evaluate([1, 3]) - exactValue = -11.194036030183454; + exactValue = -5.147502395904501; testCase.verifyEqual(httpValue, exactValue, 'RelTol', 1e-14) end From 957119be5b464e61827f34618a1917829bf8864a Mon Sep 17 00:00:00 2001 From: Marlena Weidenauer <134061260+marlenaweidenauer@users.noreply.github.com> Date: Sun, 10 Sep 2023 17:40:20 +0200 Subject: [PATCH 14/18] Update TestMatlab.m added test jacobian function --- testing/clients/TestMatlab.m | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/testing/clients/TestMatlab.m b/testing/clients/TestMatlab.m index 4dc6fbf..44db1fc 100644 --- a/testing/clients/TestMatlab.m +++ b/testing/clients/TestMatlab.m @@ -13,6 +13,17 @@ function testConnection(testCase) end + function testApplyJacobian(testCase) + uri = 'http://localhost:4243'; + + model = HTTPModel(uri,'posterior'); + + httpValue = model.apply_jacobian([1.0,4.0], [1,3], 0, 0) + exactValue = -3.370206919896928; + testCase.verifyEqual(httpValue, exactValue, 'RelTol', 1e-14) + + end + function testBasicExample(testCase) matlabClient;; end From 0d4a70815bba7e2bd3965e0a1463d30888178efe Mon Sep 17 00:00:00 2001 From: Marlena Weidenauer <134061260+marlenaweidenauer@users.noreply.github.com> Date: Wed, 13 Sep 2023 13:37:50 +0200 Subject: [PATCH 15/18] Update README.md added documentation of Julia client --- clients/README.md | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/clients/README.md b/clients/README.md index 3d2f435..024544f 100644 --- a/clients/README.md +++ b/clients/README.md @@ -217,6 +217,47 @@ model.apply_jacobian([1.0,4.0], [0, 10.0], 0, 0) [Full example sources here.](https://github.com/UM-Bridge/umbridge/blob/main/clients/matlab/matlabClient.m) +## Julia client + +The Julia integration can be installed using Julia's builtin package manager Pkg + +``` +Pkg.add("UMBridge") +``` + +It can be used as usual via + +``` +using UMBridge +``` + +We set up a model by connection to the URL and selecting the "forward" model + +``` +model = UMBridge.HTTPModel("forward", "http://localhost:4242") +print(UMBridge.model_input_sizes(model)) +print(UMBridge.model_output_sizes(model)) +``` + +The functions UMBridge.model_input_sizes() and UMBridge.model_output_sizes() give the input and output dimension of a model, respectively. A model that expects an input consisting of a single 2D vector can be evaluated as follows + +``` +print(UMBridge.evaluate(model, [[0, 10]], Dict())) + +config = Dict("vtk_output" => true, "level" => 1); +print(UMBridge.evaluate(model, [[0, 10]], config)) +``` + +If the model accepts configuartion parameters, we can add those to the model evaluation. The config options accepted by a particular model can be found in the model's documentation. + +Models indicate whether they support further features, e.g. Jacobian or Hessian actions. The following example evaluates the Jacobian of model output zero with respect to model input zero at the same input parameter as before. It then applies it to the additional vector given. + +``` + UMBridge.apply_jacobian(model, 0, 0, [[0, 10]], [1, 4]) +``` + +[Full example sources here.](https://github.com/UM-Bridge/umbridge/blob/main/clients/julia/juliaClient.jl) + ## MUQ client Within the [MIT Uncertainty Quantification library (MUQ)](https://mituq.bitbucket.io), there is a ModPiece available that allows embedding an HTTP model in MUQ's model graph framework. From f83d5cc46b2388ef61c60190119b9734d607d1fc Mon Sep 17 00:00:00 2001 From: Marlena Weidenauer <134061260+marlenaweidenauer@users.noreply.github.com> Date: Wed, 20 Sep 2023 14:03:22 +0200 Subject: [PATCH 16/18] Update juliaClient.jl --- julia/juliaClient.jl | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/julia/juliaClient.jl b/julia/juliaClient.jl index 778ca99..bc51770 100644 --- a/julia/juliaClient.jl +++ b/julia/juliaClient.jl @@ -2,7 +2,26 @@ using UMBridge url = "http://localhost:4242" -val = UMBridge.evaluate(url, "forward" ,[[1,3]], Dict()) +# Set up a model by connecting to URL and selecting the "forward" model +model = UMBridge.HTTPModel("forward", url) +# Print model input and output dimension +print(UMBridge.model_input_sizes(model)) +print(UMBridge.model_output_sizes(model)) + +param = [[0, 10]]; + +# Simple model evaluation without config +val = UMBridge.evaluate(model, param, Dict()) print(val) +# Model evaluation with configuration parameters +config = Dict("vtk_output" => true, "level" => 1); +print(UMBridge.evaluate(model, param, config)) + +# If model supports Jacobian action, +# apply Jacobian of output zero with respect to input zero to a vector +if UMBridge.supports_apply_jacobian(model) + UMBridge.apply_jacobian(model, 0, 0, param, [1, 4]) +end + From 1f6f0d3346c88829606a4e705832499aced3fe09 Mon Sep 17 00:00:00 2001 From: Marlena Date: Sun, 8 Oct 2023 15:57:09 +0200 Subject: [PATCH 17/18] changed folder julia/juliaClient.jl -> clients/julia/juliaClient.jl --- {julia => clients/julia}/juliaClient.jl | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {julia => clients/julia}/juliaClient.jl (100%) diff --git a/julia/juliaClient.jl b/clients/julia/juliaClient.jl similarity index 100% rename from julia/juliaClient.jl rename to clients/julia/juliaClient.jl From 71e6e16dc936437f1d530c9d5a58c72bc2894c21 Mon Sep 17 00:00:00 2001 From: Linus Seelinger Date: Tue, 10 Oct 2023 11:31:35 +0200 Subject: [PATCH 18/18] Update client-matlab.yml --- .github/workflows/client-matlab.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/client-matlab.yml b/.github/workflows/client-matlab.yml index 3b691d6..4d64cae 100644 --- a/.github/workflows/client-matlab.yml +++ b/.github/workflows/client-matlab.yml @@ -4,7 +4,6 @@ on: push: branches: - 'main' - - 'marlenaweidenauer-patch-2' jobs: test: