smash.Model.multiple_run#

Model.multiple_run(sample, jobs_fun='nse', wjobs_fun=None, event_seg=None, gauge='downstream', wgauge='mean', ost=None, ncpu=1, return_qsim=False, verbose=True)[source]#

Compute Multiple Run of Model.

Hint

See the User Guide for more.

Parameters:
sampleSampleResult

An instance of the SampleResult object, which should be created using the smash.generate_samples method.

jobs_fun, wjobs_fun, event_seg, gauge, wgauge, ostmultiple types

Optimization setting to run the forward hydrological model and compute the cost values. See smash.Model.optimize for more.

ncpuinteger, default 1

If ncpu > 1, perform a parallel computation through the parameters set.

return_qsimbool, default False

If True, also return the simulated discharge in the MultipleRunResult object.

verbosebool, default True

Display information while computing.

Returns:
resMultipleRunResult

The multiple run results represented as a MultipleRunResult object.

See also

MultipleRunResult

Represents the multiple run result.

SampleResult

Represents the generated sample result.

Examples

>>> setup, mesh = smash.load_dataset("cance")
>>> model = smash.Model(setup, mesh)

Get the boundary constraints of the Model parameters/states and generate a sample

>>> problem = model.get_bound_constraints()
>>> sample = smash.generate_samples(problem, n=200, random_state=99)

Compute the multiple run

>>> mtprr = model.multiple_run(sample, ncpu=4, return_qsim=True)

Access the cost values of the direct simulations

>>> mtprr.cost
array([1.2327451e+00, 1.2367475e+00, 1.2227478e+00, 4.7788401e+00,
...
       1.2392160e+00, 1.2278881e+00, 7.5998020e-01, 1.1763511e+00],
      dtype=float32)

Access the minimum cost value and the index

>>> min_cost = np.min(mtprr.cost)
>>> ind_min_cost = np.argmin(mtprr.cost)
>>> min_cost, ind_min_cost
(0.48862067, 20)

Access the set that generated the minimum cost value

>>> min_set = {key: sample[key][ind_min_cost] for key in problem["names"]}
>>> min_set
{'cp': 211.6867863776767, 'cft': 41.72451338560559, 'exc': -9.003870580641795, 'lr': 43.64397561764691}