From 96bdbe3d856921a82439ddace41753bb30a1da6c Mon Sep 17 00:00:00 2001 From: Linus Seelinger Date: Fri, 6 Dec 2024 16:18:38 +0100 Subject: [PATCH] Update parallel tutorial qmcpy client --- tutorial/qmcpy-client-l2-sea.py | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/tutorial/qmcpy-client-l2-sea.py b/tutorial/qmcpy-client-l2-sea.py index 76f0878..d190a0e 100644 --- a/tutorial/qmcpy-client-l2-sea.py +++ b/tutorial/qmcpy-client-l2-sea.py @@ -11,31 +11,11 @@ args = parser.parse_args() print(f"Connecting to host URL {args.url}") -# Wrap a given model and fix its last parameters to 0 -class TwoInputModel: - def __init__(self, model): - self.model = model - - def get_input_sizes(self, config={}): - return [2] - - def get_output_sizes(self, config={}): - return self.model.get_output_sizes() - - def __call__(self, theta, config={}): - return self.model([[theta[0][0], theta[0][1], 0,0,0,0,0,0,0,0,0,0,0,0,0,0]], config) - - def supports_evaluate(self): - return True - - # Set up umbridge model and model config -l2sea_model = umbridge.HTTPModel(args.url, "forward") -l2sea_fixed_design_params = TwoInputModel(l2sea_model) -config = {"fidelity": 7} +l2sea_model = umbridge.HTTPModel(args.url, "benchmark_UQ") # Get input dimension from model -d = l2sea_fixed_design_params.get_input_sizes(config)[0] +d = l2sea_model.get_input_sizes(config)[0] # Froud [0.25,0.41] # Draft [-6.6, -5.7] @@ -43,7 +23,7 @@ def supports_evaluate(self): dnb2 = qp.DigitalNetB2(d) gauss_sobol = qp.Uniform(dnb2, lower_bound=[0.25,-6.6], upper_bound=[0.41,-5.7]) -integrand = UMBridgeWrapper(gauss_sobol, l2sea_fixed_design_params, config, parallel=False) +integrand = UMBridgeWrapper(gauss_sobol, l2sea_model, config, parallel=1) qmc_sobol_algorithm = qp.CubQMCSobolG(integrand, abs_tol=1e-1, n_init = 256, n_max = 256) solution,data = qmc_sobol_algorithm.integrate()