-
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.
Merge pull request #22 from UM-Bridge/main
Pull request to update my branch
- Loading branch information
Showing
10 changed files
with
66 additions
and
61 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 |
---|---|---|
@@ -1,11 +1,18 @@ | ||
% Analytic-Banana benchmark. Approximate log-posterior density in TT format | ||
% Check for (and download) TT Toolbox | ||
check_tt; | ||
|
||
uri = 'http://localhost:4243'; | ||
model = HTTPModel(uri,'posterior'); | ||
model = HTTPModel(uri, 'posterior'); | ||
|
||
% TT demo with umbridge model | ||
tol = 1e-6; | ||
x = linspace(-5,5,33); | ||
TTlogLikelihood = amen_cross(numel(x)*ones(2,1), @(i)model.evaluate(x(i)), tol, 'vec', false) | ||
tol = 1e-5; | ||
d = model.get_input_sizes | ||
x = linspace(-5,5,33); % A uniform grid on [-5,5]^d for analytic-banana | ||
% TTlogLikelihood = amen_cross(numel(x)*ones(d,1), @(i)model.evaluate(x(i)), tol, 'vec', false) | ||
tic; | ||
TTlogLikelihood = greedy2_cross(numel(x)*ones(d,1), @(i)model.evaluate(x(i)), tol, 'vec', false) | ||
toc | ||
|
||
% benchmark-analytic-banana: 44.138067 seconds with 'send' engine | ||
% 4.250689 seconds with 'webwrite' engine |
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,8 @@ | ||
using UMBridge | ||
|
||
url = "http://localhost:4242" | ||
|
||
val = UMBridge.evaluate(url, "forward" ,[[1,3]], Dict()) | ||
|
||
print(val) | ||
|
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
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
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
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,16 @@ | ||
function output_json = send_data(self, uri, value) | ||
if strcmpi(self.send_engine, 'send') | ||
r = matlab.net.http.RequestMessage('POST'); | ||
r.Body = matlab.net.http.MessageBody(value); | ||
resp = send(r, uri); | ||
self.check_http_status(resp); | ||
output_json = jsondecode(resp.Body.string); | ||
else | ||
opts = weboptions('Timeout', inf, 'RequestMethod', 'POST'); | ||
opts.MediaType = 'application/json'; | ||
output_json = webwrite(uri, value, opts); | ||
if ~isa(output_json, 'struct') | ||
output_json = jsondecode(output_json); | ||
end | ||
end | ||
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