NestedMonteCarlo

Monte Carlo sampler for nested loops of parameters.

Overview

This sampler is meant to emulate a nested loop of Monte Carlo samples. Columns of the sampling matrix are only sampled with a frequency based on which loop they are a part of. Columns associated with the inner most loop are sampled at each row and columns associated with outer loops are sampled once its inner loop is complete. The number of rows in each loop is defined by the "num_rows" parameter, where the first entry is the outer most loop and the last entry is the inner loop. Each of the entries in this parameter must be associated with a set of distributions specified with "distributions" which define the sampler columns.

Example Input Syntax

The following example defines a Monte Carlo sampler with three nested loops. The outer loop has 10 samples, the middle has 5, and the inner has 2. The columns are defined by 5 distributions, the first three are associated with the outer loop, the second 2 with the middle, and the last one with the inner.

[Samplers]
  [nested_mc]
    type = NestedMonteCarlo
    num_rows = '10 5 2'
    distributions = 'uniform uniform uniform; uniform uniform; uniform'
  []
[]
(contrib/moose/modules/stochastic_tools/test/tests/samplers/nested_monte_carlo/nested_monte_carlo.i)

The resulting matrix is 5 columns and 100 rows (10×5×210\times 5 \times 2), which is shown below. As a result, the fifth column changes every row, the third and fourth column changes every 2 rows, and the firth 3 columns change every 10 rows.

nested_mc_0,nested_mc_1,nested_mc_2,nested_mc_3,nested_mc_4,nested_mc_5
0.79415996369959,0.15982462231328,0.39078726592784,0.93648515583347,0.65650723246426,0.55914992739402
0.79415996369959,0.15982462231328,0.39078726592784,0.93648515583347,0.65650723246426,0.85846027698738
0.79415996369959,0.15982462231328,0.39078726592784,0.61787779807406,0.51651794493403,0.69999750450889
0.79415996369959,0.15982462231328,0.39078726592784,0.61787779807406,0.51651794493403,0.096609657662421
0.79415996369959,0.15982462231328,0.39078726592784,0.086064339460231,0.79640639322102,0.20112627032648
0.79415996369959,0.15982462231328,0.39078726592784,0.086064339460231,0.79640639322102,0.73272909578813
0.79415996369959,0.15982462231328,0.39078726592784,0.6016196648075,0.32645097438846,0.82395491493935
0.79415996369959,0.15982462231328,0.39078726592784,0.6016196648075,0.32645097438846,0.9431366138502
0.79415996369959,0.15982462231328,0.39078726592784,0.050497805305664,0.68723634971943,0.4459364227904
0.79415996369959,0.15982462231328,0.39078726592784,0.050497805305664,0.68723634971943,0.98029712360967
0.38028243461317,0.96869716704782,0.53873669453663,0.58848931556147,0.51112818304236,0.64623323767235
0.38028243461317,0.96869716704782,0.53873669453663,0.58848931556147,0.51112818304236,0.42502454281666
0.38028243461317,0.96869716704782,0.53873669453663,0.75216980451615,0.63259580700936,0.63862440962825
0.38028243461317,0.96869716704782,0.53873669453663,0.75216980451615,0.63259580700936,0.84133650656509
0.38028243461317,0.96869716704782,0.53873669453663,0.25922612542033,0.31120452155916,0.5821072262284
0.38028243461317,0.96869716704782,0.53873669453663,0.25922612542033,0.31120452155916,0.28410845107953
0.38028243461317,0.96869716704782,0.53873669453663,0.1265188881212,0.80629974288962,0.058668740295329
0.38028243461317,0.96869716704782,0.53873669453663,0.1265188881212,0.80629974288962,0.51894025654813
0.38028243461317,0.96869716704782,0.53873669453663,0.11542265947313,0.043589120774432,0.32756699834067
0.38028243461317,0.96869716704782,0.53873669453663,0.11542265947313,0.043589120774432,0.12148786664822
0.99730718916737,0.65460472962729,0.16289040305263,0.24292181514593,0.89301325280808,0.53297388495288
0.99730718916737,0.65460472962729,0.16289040305263,0.24292181514593,0.89301325280808,0.53235501616889
0.99730718916737,0.65460472962729,0.16289040305263,0.038946129629407,0.70681644754024,0.61847478490214
0.99730718916737,0.65460472962729,0.16289040305263,0.038946129629407,0.70681644754024,0.32878974773965
0.99730718916737,0.65460472962729,0.16289040305263,0.81154213975626,0.50381007992968,0.34740890313408
0.99730718916737,0.65460472962729,0.16289040305263,0.81154213975626,0.50381007992968,0.37735975775135
0.99730718916737,0.65460472962729,0.16289040305263,0.37298783469202,0.92428228538685,0.53069457095046
0.99730718916737,0.65460472962729,0.16289040305263,0.37298783469202,0.92428228538685,0.2409648644282
0.99730718916737,0.65460472962729,0.16289040305263,0.18801500793513,0.30650244890552,0.30438050651964
0.99730718916737,0.65460472962729,0.16289040305263,0.18801500793513,0.30650244890552,0.51479273395906
0.35870594994289,0.11918776999319,0.69149043965046,0.11557122064414,0.58154453287355,0.29864544000591
0.35870594994289,0.11918776999319,0.69149043965046,0.11557122064414,0.58154453287355,0.33886142421342
0.35870594994289,0.11918776999319,0.69149043965046,0.14981119812282,0.22993706315161,0.38106968965054
0.35870594994289,0.11918776999319,0.69149043965046,0.14981119812282,0.22993706315161,0.44521348609397
0.35870594994289,0.11918776999319,0.69149043965046,0.56012111830447,0.12994422158617,0.33603032801912
0.35870594994289,0.11918776999319,0.69149043965046,0.56012111830447,0.12994422158617,0.67874837417499
0.35870594994289,0.11918776999319,0.69149043965046,0.601637047984,0.39732643578432,0.72309697939667
0.35870594994289,0.11918776999319,0.69149043965046,0.601637047984,0.39732643578432,0.84254158334953
0.35870594994289,0.11918776999319,0.69149043965046,0.75375495017449,0.66762381483149,0.36202165131729
0.35870594994289,0.11918776999319,0.69149043965046,0.75375495017449,0.66762381483149,0.38195745471269
0.32980548143122,0.28261448712375,0.50535468706171,0.64460925530467,0.45964810542267,0.81847566720669
0.32980548143122,0.28261448712375,0.50535468706171,0.64460925530467,0.45964810542267,0.47338839614188
0.32980548143122,0.28261448712375,0.50535468706171,0.077863343192063,0.51817606220252,0.25133702155901
0.32980548143122,0.28261448712375,0.50535468706171,0.077863343192063,0.51817606220252,0.15437811962466
0.32980548143122,0.28261448712375,0.50535468706171,0.17822207642853,0.13211220412467,0.25595657067401
0.32980548143122,0.28261448712375,0.50535468706171,0.17822207642853,0.13211220412467,0.73162514885082
0.32980548143122,0.28261448712375,0.50535468706171,0.92050310743413,0.20392791799958,0.21888396792363
0.32980548143122,0.28261448712375,0.50535468706171,0.92050310743413,0.20392791799958,0.49650922085065
0.32980548143122,0.28261448712375,0.50535468706171,0.69244630941395,0.0010048208381252,0.34903228806636
0.32980548143122,0.28261448712375,0.50535468706171,0.69244630941395,0.0010048208381252,0.13135197564184
0.0073825715951871,0.7857345902065,0.52435875807674,0.33956701599038,0.91044615624234,0.86923193546583
0.0073825715951871,0.7857345902065,0.52435875807674,0.33956701599038,0.91044615624234,0.12083281422101
0.0073825715951871,0.7857345902065,0.52435875807674,0.86776683264747,0.91058429936092,0.049011953519517
0.0073825715951871,0.7857345902065,0.52435875807674,0.86776683264747,0.91058429936092,0.72824058472368
0.0073825715951871,0.7857345902065,0.52435875807674,0.77419237672158,0.74287350244049,0.25813241878449
0.0073825715951871,0.7857345902065,0.52435875807674,0.77419237672158,0.74287350244049,0.21483296808911
0.0073825715951871,0.7857345902065,0.52435875807674,0.38934777342916,0.84339080264298,0.67073128630346
0.0073825715951871,0.7857345902065,0.52435875807674,0.38934777342916,0.84339080264298,0.7310847942101
0.0073825715951871,0.7857345902065,0.52435875807674,0.14043886292551,0.62818729091921,0.13441859823624
0.0073825715951871,0.7857345902065,0.52435875807674,0.14043886292551,0.62818729091921,0.12884000487558
0.17666919644913,0.94491169237549,0.38280574427536,0.25639820455306,0.33446706964887,0.65521773604793
0.17666919644913,0.94491169237549,0.38280574427536,0.25639820455306,0.33446706964887,0.33572281665558
0.17666919644913,0.94491169237549,0.38280574427536,0.1327947933678,0.93105632097915,0.63684625961265
0.17666919644913,0.94491169237549,0.38280574427536,0.1327947933678,0.93105632097915,0.66362144332231
0.17666919644913,0.94491169237549,0.38280574427536,0.63722210355664,0.26909712230603,0.92928677890231
0.17666919644913,0.94491169237549,0.38280574427536,0.63722210355664,0.26909712230603,0.6272905621202
0.17666919644913,0.94491169237549,0.38280574427536,0.72334413291947,0.80615544129689,0.5884608911322
0.17666919644913,0.94491169237549,0.38280574427536,0.72334413291947,0.80615544129689,0.82379603504133
0.17666919644913,0.94491169237549,0.38280574427536,0.87598332264946,0.90908693015689,0.80609742997446
0.17666919644913,0.94491169237549,0.38280574427536,0.87598332264946,0.90908693015689,0.11650026036001
0.48120557026599,0.81120301558038,0.57003090151856,0.55208699653256,0.015624781528446,0.55926743216461
0.48120557026599,0.81120301558038,0.57003090151856,0.55208699653256,0.015624781528446,0.29344717374303
0.48120557026599,0.81120301558038,0.57003090151856,0.47634113845686,0.91801915725526,0.51898428519068
0.48120557026599,0.81120301558038,0.57003090151856,0.47634113845686,0.91801915725526,0.5944916567146
0.48120557026599,0.81120301558038,0.57003090151856,0.5663959408725,0.12812797972644,0.59924327783051
0.48120557026599,0.81120301558038,0.57003090151856,0.5663959408725,0.12812797972644,0.057097816927305
0.48120557026599,0.81120301558038,0.57003090151856,0.55370543865466,0.64484017949751,0.3301799088466
0.48120557026599,0.81120301558038,0.57003090151856,0.55370543865466,0.64484017949751,0.70216264212138
0.48120557026599,0.81120301558038,0.57003090151856,0.5046304740174,0.27373025730783,0.62777287523705
0.48120557026599,0.81120301558038,0.57003090151856,0.5046304740174,0.27373025730783,0.53687643502993
0.6491335124566,0.72309514786351,0.20667575701831,0.86398243749853,0.89194235190399,0.57454568709967
0.6491335124566,0.72309514786351,0.20667575701831,0.86398243749853,0.89194235190399,0.90534637876512
0.6491335124566,0.72309514786351,0.20667575701831,0.92388941997802,0.37609929728232,0.97654756292598
0.6491335124566,0.72309514786351,0.20667575701831,0.92388941997802,0.37609929728232,0.38005822228888
0.6491335124566,0.72309514786351,0.20667575701831,0.57874714724597,0.48685779020244,0.53155188537811
0.6491335124566,0.72309514786351,0.20667575701831,0.57874714724597,0.48685779020244,0.13280714099893
0.6491335124566,0.72309514786351,0.20667575701831,0.26928506944416,0.36998211326932,0.39125911302565
0.6491335124566,0.72309514786351,0.20667575701831,0.26928506944416,0.36998211326932,0.40145734518956
0.6491335124566,0.72309514786351,0.20667575701831,0.69969006095557,0.85239185692212,0.19908788532285
0.6491335124566,0.72309514786351,0.20667575701831,0.69969006095557,0.85239185692212,0.39136128214701
0.17193515807971,0.33709128894485,0.98732097611465,0.81483023014532,0.32867472346661,0.72487827031224
0.17193515807971,0.33709128894485,0.98732097611465,0.81483023014532,0.32867472346661,0.27975768102536
0.17193515807971,0.33709128894485,0.98732097611465,0.1905532484296,0.11736534615696,0.075023413904743
0.17193515807971,0.33709128894485,0.98732097611465,0.1905532484296,0.11736534615696,0.4382558854213
0.17193515807971,0.33709128894485,0.98732097611465,0.99915744839003,0.99390375662309,0.51634423301366
0.17193515807971,0.33709128894485,0.98732097611465,0.99915744839003,0.99390375662309,0.14401490708021
0.17193515807971,0.33709128894485,0.98732097611465,0.42384744090769,0.92489797659817,0.91907748615717
0.17193515807971,0.33709128894485,0.98732097611465,0.42384744090769,0.92489797659817,0.48420178682762
0.17193515807971,0.33709128894485,0.98732097611465,0.42692040465267,0.60942777835222,0.10681207412146
0.17193515807971,0.33709128894485,0.98732097611465,0.42692040465267,0.60942777835222,0.19152539263505
(contrib/moose/modules/stochastic_tools/test/tests/samplers/nested_monte_carlo/gold/nested_monte_carlo_out_data_0001.csv)

Input Parameters

  • distributionsSets of distribution names to be sampled. Each set defines the parameters for the nested loop, with the first set being the outermost loop.

    C++ Type:std::vector<std::vector<DistributionName>>

    Unit:(no unit assumed)

    Controllable:No

    Description:Sets of distribution names to be sampled. Each set defines the parameters for the nested loop, with the first set being the outermost loop.

  • num_rowsThe number of rows for each loop of parameters. The first number represents the outermost loop.

    C++ Type:std::vector<unsigned long>

    Unit:(no unit assumed)

    Controllable:No

    Description:The number of rows for each loop of parameters. The first number represents the outermost loop.

Required Parameters

  • execute_onLINEARThe list of flag(s) indicating when this object should be executed. For a description of each flag, see https://mooseframework.inl.gov/source/interfaces/SetupInterface.html.

    Default:LINEAR

    C++ Type:ExecFlagEnum

    Unit:(no unit assumed)

    Options:NONE, INITIAL, LINEAR, NONLINEAR_CONVERGENCE, NONLINEAR, POSTCHECK, TIMESTEP_END, TIMESTEP_BEGIN, MULTIAPP_FIXED_POINT_END, MULTIAPP_FIXED_POINT_BEGIN, FINAL, CUSTOM, PRE_MULTIAPP_SETUP

    Controllable:No

    Description:The list of flag(s) indicating when this object should be executed. For a description of each flag, see https://mooseframework.inl.gov/source/interfaces/SetupInterface.html.

  • limit_get_global_samples429496729The maximum allowed number of items in the DenseMatrix returned by getGlobalSamples method.

    Default:429496729

    C++ Type:unsigned long

    Unit:(no unit assumed)

    Controllable:No

    Description:The maximum allowed number of items in the DenseMatrix returned by getGlobalSamples method.

  • limit_get_local_samples429496729The maximum allowed number of items in the DenseMatrix returned by getLocalSamples method.

    Default:429496729

    C++ Type:unsigned long

    Unit:(no unit assumed)

    Controllable:No

    Description:The maximum allowed number of items in the DenseMatrix returned by getLocalSamples method.

  • limit_get_next_local_row429496729The maximum allowed number of items in the std::vector returned by getNextLocalRow method.

    Default:429496729

    C++ Type:unsigned long

    Unit:(no unit assumed)

    Controllable:No

    Description:The maximum allowed number of items in the std::vector returned by getNextLocalRow method.

  • max_procs_per_row4294967295This will ensure that the sampler is partitioned properly when 'MultiApp/*/max_procs_per_app' is specified. It is not recommended to use otherwise.

    Default:4294967295

    C++ Type:unsigned int

    Unit:(no unit assumed)

    Controllable:No

    Description:This will ensure that the sampler is partitioned properly when 'MultiApp/*/max_procs_per_app' is specified. It is not recommended to use otherwise.

  • min_procs_per_row1This will ensure that the sampler is partitioned properly when 'MultiApp/*/min_procs_per_app' is specified. It is not recommended to use otherwise.

    Default:1

    C++ Type:unsigned int

    Unit:(no unit assumed)

    Controllable:No

    Description:This will ensure that the sampler is partitioned properly when 'MultiApp/*/min_procs_per_app' is specified. It is not recommended to use otherwise.

  • seed0Random number generator initial seed

    Default:0

    C++ Type:unsigned int

    Unit:(no unit assumed)

    Controllable:No

    Description:Random number generator initial seed

Optional Parameters

  • control_tagsAdds user-defined labels for accessing object parameters via control logic.

    C++ Type:std::vector<std::string>

    Unit:(no unit assumed)

    Controllable:No

    Description:Adds user-defined labels for accessing object parameters via control logic.

  • enableTrueSet the enabled status of the MooseObject.

    Default:True

    C++ Type:bool

    Unit:(no unit assumed)

    Controllable:No

    Description:Set the enabled status of the MooseObject.

Advanced Parameters