diff --git a/framework/include/samplers/Sampler.h b/framework/include/samplers/Sampler.h index 25c0b163a0d7..0f393854b475 100644 --- a/framework/include/samplers/Sampler.h +++ b/framework/include/samplers/Sampler.h @@ -20,6 +20,7 @@ #include "MultiApp.h" #include "VectorPostprocessorInterface.h" #include "ReporterInterface.h" +#include "MooseRandomStateless.h" /** * This is the base class for Samplers as used within the Stochastic Tools module. @@ -138,22 +139,6 @@ class Sampler : public MooseObject, libMesh::Parallel::Communicator & getLocalComm() { return _local_comm; } protected: - /** - * Enum describing the type of parallel communication to perform. - * - * Some routines require specific communication methods that not all processors - * see, these IDs will determine how that routine is performed: - * - NONE routine is not distrubuted and things all can happen locally - * - LOCAL routine is distributed on all processors - * - SEMI_LOCAL routine is distributed only on processors that own rows - */ - enum CommMethod - { - NONE = 0, - LOCAL = 1, - SEMI_LOCAL = 2 - }; - // The following methods are the basic methods that should be utilized my most application // developers that are creating a custom Sampler. @@ -175,24 +160,27 @@ class Sampler : public MooseObject, void setNumberOfRandomSeeds(std::size_t number); /** - * Get the next random number from the generator. + * Get nth random number from the generator. + * @param n 0-based index of the random number to generate * @param index The index of the seed, by default this is zero. To add additional seeds * indices call the setNumberOfRequiedRandomSeeds method. * * @return A double for the random number, this is double because MooseRandom class uses double. */ - Real getRand(unsigned int index = 0); + Real getRand(std::size_t n, unsigned int index = 0) const; /** - * Get the next random integer from the generator within the specified range [lower, upper) - * @param index The index of the seed, by default this is zero. To add additional seeds - * indices call the setNumberOfRequiedRandomSeeds method. + * Get nth random integer from the generator within the specified range [lower, upper) + * @param n 0-based index of the random number to generate * @param lower Lower bounds * @param upper Upper bounds + * @param index The index of the seed, by default this is zero. To add additional seeds + * indices call the setNumberOfRequiedRandomSeeds method. * * @return A integer for the random number */ - uint32_t getRandl(unsigned int index, uint32_t lower, uint32_t upper); + unsigned int + getRandl(std::size_t n, unsigned int lower, unsigned int upper, unsigned int index = 0) const; /** * Base class must override this method to supply the sample distribution data. @@ -202,17 +190,6 @@ class Sampler : public MooseObject, */ virtual Real computeSample(dof_id_type row_index, dof_id_type col_index) = 0; - ///@{ - /** - * Setup method called prior and after looping through distributions. - * - * These methods should not be called directly, each is automatically called by the public - * getGlobalSamples() or getLocalSamples() methods. - */ - virtual void sampleSetUp(const SampleMode /*mode*/) {} - virtual void sampleTearDown(const SampleMode /*mode*/) {} - ///@} - // The following methods are advanced methods that should not be needed by application developers, // but exist for special cases. @@ -241,44 +218,23 @@ class Sampler : public MooseObject, /** * Method for advancing the random number generator(s) by the supplied number or calls to rand(). - * - * TODO: This should be updated if the If the random number generator is updated to type that - * supports native advancing. */ virtual void advanceGenerators(const dof_id_type count); virtual void advanceGenerator(const unsigned int seed_index, const dof_id_type count); void setAutoAdvanceGenerators(const bool state); - /** - * Helper for shuffling a vector of data in-place; the default assumes data is distributed - * - * NOTE: This will advance the generator by the size of the supplied vector. - */ - template - void shuffle(std::vector & data, - const std::size_t seed_index = 0, - const CommMethod method = CommMethod::LOCAL); - //@{ /** * Callbacks for before and after execute. * * These were added to support of dynamic sampler sizes. Recall that execute is simply to advance - * the state of the generator such that the next sample will be unique. These methods allow + * the state of the generators such that the next sample will be unique. These methods allow * operations before and after the call to generator advancement. */ virtual void executeSetUp() {} virtual void executeTearDown() {} ///@} - //@{ - /** - * Here we save/restore generator states - */ - void saveGeneratorState() { _generator.saveState(); } - void restoreGeneratorState() { _generator.restoreState(); } - //@} - /** * This is where the sampler partitioning is defined. It is NOT recommended to * override this function unless you know EXACTLY what you are doing @@ -311,11 +267,8 @@ class Sampler : public MooseObject, const std::string & name, InputParameters & parameters); /** - * Store the state of the MooseRandom generator so that new calls to - * getGlobalSamples/getLocalSamples methods will create new numbers. - * - * The execute() method is called in the init() method of this class and - * FEProblemBase::executeSamplers; it should not be called elsewhere. + * Advance MooseRandomStateless generators so that new calls to + * sample methods will create new numbers. */ void execute(); friend void FEProblemBase::objectExecuteHelper(const std::vector & objects); @@ -330,8 +283,8 @@ class Sampler : public MooseObject, */ void advanceGeneratorsInternal(const dof_id_type count); - /// Random number generator, don't give users access. Control it via the interface from this class. - MooseRandom _generator; + /// Random number generators, don't give users access. Control it via the interface from this class. + std::vector> _generators; /// Number of rows for this processor dof_id_type _n_local_rows; @@ -382,15 +335,3 @@ class Sampler : public MooseObject, /// Flag for disabling automatic generator advancing bool _auto_advance_generators; }; - -template -void -Sampler::shuffle(std::vector & data, const std::size_t seed_index, const CommMethod method) -{ - if (method == CommMethod::NONE) - MooseUtils::shuffle(data, _generator, seed_index, nullptr); - else if (method == CommMethod::LOCAL) - MooseUtils::shuffle(data, _generator, seed_index, &_communicator); - else if (method == CommMethod::SEMI_LOCAL) - MooseUtils::shuffle(data, _generator, seed_index, &_local_comm); -} diff --git a/framework/include/utils/MooseRandomPerturbation.h b/framework/include/utils/MooseRandomPerturbation.h new file mode 100644 index 000000000000..49c666285eef --- /dev/null +++ b/framework/include/utils/MooseRandomPerturbation.h @@ -0,0 +1,127 @@ +//* This file is part of the MOOSE framework +//* https://mooseframework.inl.gov +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#pragma once + +#include "MooseError.h" + +#include + +/** + * Generates a keyed pseudo-random permutation of the integers [0, n) using a + * balanced Feistel network. Given the same seed and n, the mapping is fully + * deterministic and bijective: every input in [0, n) maps to a unique output + * in [0, n). Different seeds produce statistically independent permutations. + * + * Because n need not be a power of two, the Feistel network operates on a + * padded domain of size 2^(2*half_bits) >= n and uses cycle-walking: if the + * raw output falls outside [0, n) it is re-applied until a valid index is + * reached. This guarantees termination because the padded permutation is + * itself a bijection and n > 0 ensures at least one valid output exists. + * + * The permutation is also invertible via invert(), which runs the Feistel + * rounds in reverse order. + */ +class MooseRandomPerturbation +{ +public: + /** + * Construct a permutation of [0, \p n) keyed by \p seed. + * + * @param seed 64-bit seed; split into two 32-bit subkeys for the round function. + * @param n Size of the domain to permute; must be > 0. + * @param rounds Number of Feistel rounds. More rounds improve mixing at the + * cost of throughput; 8 is sufficient for sampling applications. + */ + MooseRandomPerturbation(uint64_t seed, unsigned int n, unsigned int rounds = 8); + + /** + * Map \p x to its permuted index in [0, n). + * + * Applies the Feistel network to the padded domain and cycle-walks until + * the result falls within [0, n). + * + * @param x Input index; must satisfy x < n. + * @return A unique index in [0, n). Calling permute for every x in [0, n) + * yields each value in [0, n) exactly once. + */ + uint32_t permute(uint32_t x) const; + + /** + * Recover the original index from a permuted value, i.e. invert(permute(x)) == x. + * + * Runs the Feistel rounds in reverse order and cycle-walks back into [0, n). + * + * @param y Permuted index; must satisfy y < n. + * @return The unique x in [0, n) such that permute(x) == y. + */ + uint32_t invert(uint32_t y) const; + +private: + /** + * Apply one full pass of the balanced Feistel network over the padded + * domain [0, 2^(2*half_bits)). The result may fall outside [0, n); the + * caller is responsible for cycle-walking. + * + * @param x Input value in the padded domain. + * @return Permuted value in the padded domain. + */ + uint32_t permutePadded(uint32_t x) const; + + /** + * Invert one full pass of the Feistel network by running rounds in reverse. + * + * @param y Value in the padded domain produced by permutePadded. + * @return The original input to permutePadded that produced \p y. + */ + uint32_t invertPadded(uint32_t y) const; + + /** + * Keyed round function F(half, round) used in each Feistel step. + * + * Mixes the half-block with both subkeys and a round-dependent constant + * derived from the golden-ratio fractional bits (0x9e3779b9), then passes + * the result through a 32-bit avalanche hash (mix32). + * + * @param half The half-block value (R in the forward direction). + * @param round Zero-based round index, used to vary the constant each round. + * @return Mixed value masked to \p _half_bits width. + */ + uint32_t roundFunction(uint32_t half, unsigned int round) const; + + /** + * Return the number of bits needed to represent values in [0, n-1], i.e. + * ceil(log2(n)). Returns 0 for n == 1 (no bits needed to index a single element). + * + * @param n Must be > 0. + */ + static unsigned int ceilLog2(uint32_t n); + + /** + * Bijective 32-bit avalanche hash (finalizer from Murmur3 / degski hash). + * Used inside the round function to achieve good bit diffusion. + * + * @param x 32-bit input. + * @return Hashed 32-bit output; the mapping is invertible. + */ + static uint32_t mix32(uint32_t x); + + /// Lower 32 bits of the seed, used as the first subkey in the round function + const uint32_t _k0; + /// Upper 32 bits of the seed, used as the second subkey in the round function + const uint32_t _k1; + /// Size of the permutation domain [0, n) + const unsigned int _n; + /// Number of bits in each Feistel half-block: ceil((ceil(log2(n)) + 1) / 2) + const unsigned int _half_bits; + /// Bitmask of width _half_bits, used to keep half-block arithmetic in range + const uint32_t _half_mask; + /// Number of Feistel rounds to apply per permute/invert call + const unsigned int _rounds; +}; diff --git a/framework/include/utils/MooseRandomStateless.h b/framework/include/utils/MooseRandomStateless.h index 30a42d72501b..39180f37add2 100644 --- a/framework/include/utils/MooseRandomStateless.h +++ b/framework/include/utils/MooseRandomStateless.h @@ -146,7 +146,7 @@ class MooseRandomStateless const auto range = upper - lower; auto [it, is_new] = _randlb_generators.try_emplace( - range, [&range](mt_state * state) { return rds_iuniform(state, 0, range); }, _seed); + range, [range](mt_state * state) { return rds_iuniform(state, 0, range); }, _seed); if (is_new) it->second.advance(_advance_count); diff --git a/framework/src/problems/FEProblemBase.C b/framework/src/problems/FEProblemBase.C index 1a8de8772ae6..f9fb68d6c436 100644 --- a/framework/src/problems/FEProblemBase.C +++ b/framework/src/problems/FEProblemBase.C @@ -5035,13 +5035,7 @@ FEProblemBase::execute(const ExecFlagType & exec_type) exec_type == EXEC_SUBDOMAIN || exec_type == EXEC_NONLINEAR || exec_type == EXEC_LINEAR)) customSetup(exec_type); - // Samplers; EXEC_INITIAL is not called because the Sampler::init() method that is called after - // construction makes the first Sampler::execute() call. This ensures that the random number - // generator object is the correct state prior to any other object (e.g., Transfers) attempts to - // extract data from the Sampler. That is, if the Sampler::execute() call is delayed to here - // then it is not in the correct state for other objects. - if (exec_type != EXEC_INITIAL) - executeSamplers(exec_type); + executeSamplers(exec_type); // Pre-aux UserObjects computeUserObjects(exec_type, Moose::PRE_AUX); diff --git a/framework/src/samplers/Sampler.C b/framework/src/samplers/Sampler.C index 8b92a5f66723..105b7998a5ba 100644 --- a/framework/src/samplers/Sampler.C +++ b/framework/src/samplers/Sampler.C @@ -23,6 +23,7 @@ Sampler::validParams() ExecFlagEnum & exec_enum = params.set("execute_on", true); exec_enum.addAvailableFlags(EXEC_PRE_MULTIAPP_SETUP); + exec_enum = {EXEC_INITIAL}; params.addParam("seed", 0, "Random number generator initial seed"); params.registerBase("Sampler"); @@ -102,11 +103,12 @@ Sampler::init() seed_generator.seed(0, seed); // See the "secondary" generator that will be used for the random number generation + _generators.resize(_n_seeds); for (std::size_t i = 0; i < _n_seeds; ++i) - _generator.seed(i, seed_generator.randl(0)); - - // Save the initial state - saveGeneratorState(); + { + const auto gseed = seed_generator.randl(0); + _generators[i] = std::make_unique(gseed); + } // Mark class as initialized, which locks out certain methods _initialized = true; @@ -185,11 +187,8 @@ Sampler::execute() reinit(); if (_has_executed) - { - restoreGeneratorState(); advanceGeneratorsInternal(_n_rows * _n_cols); - } - saveGeneratorState(); + executeTearDown(); _has_executed = true; } @@ -210,11 +209,8 @@ Sampler::getGlobalSamples() "."); _next_local_row_requires_state_restore = true; - restoreGeneratorState(); - sampleSetUp(SampleMode::GLOBAL); DenseMatrix output(_n_rows, _n_cols); computeSampleMatrix(output); - sampleTearDown(SampleMode::GLOBAL); return output; } @@ -238,10 +234,7 @@ Sampler::getLocalSamples() return output; _next_local_row_requires_state_restore = true; - restoreGeneratorState(); - sampleSetUp(SampleMode::LOCAL); computeLocalSampleMatrix(output); - sampleTearDown(SampleMode::LOCAL); return output; } @@ -252,9 +245,6 @@ Sampler::getNextLocalRow() if (_next_local_row_requires_state_restore) { - restoreGeneratorState(); - sampleSetUp(SampleMode::LOCAL); - advanceGeneratorsInternal(_next_local_row * _n_cols); _next_local_row_requires_state_restore = false; if (_n_cols > _limit_get_next_local_row) @@ -273,8 +263,6 @@ Sampler::getNextLocalRow() if (_next_local_row == _local_row_end) { - advanceGeneratorsInternal((_n_rows - _local_row_end) * _n_cols); - sampleTearDown(SampleMode::LOCAL); _next_local_row = _local_row_begin; _next_local_row_requires_state_restore = true; } @@ -303,7 +291,6 @@ Sampler::computeLocalSampleMatrix(DenseMatrix & matrix) { TIME_SECTION("computeLocalSampleMatrix", 2, "Computing Local Sample Matrix"); - advanceGeneratorsInternal(_local_row_begin * _n_cols); for (dof_id_type i = _local_row_begin; i < _local_row_end; ++i) { std::vector row(_n_cols, 0); @@ -314,7 +301,6 @@ Sampler::computeLocalSampleMatrix(DenseMatrix & matrix) std::copy( row.begin(), row.end(), matrix.get_values().begin() + ((i - _local_row_begin) * _n_cols)); } - advanceGeneratorsInternal((_n_rows - _local_row_end) * _n_cols); } void @@ -333,14 +319,14 @@ Sampler::advanceGenerators(const dof_id_type count) { TIME_SECTION("advanceGenerators", 2, "Advancing Generators"); - for (std::size_t j = 0; j < _generator.size(); ++j) + for (std::size_t j = 0; j < _generators.size(); ++j) advanceGenerator(j, count); } void Sampler::advanceGenerator(const unsigned int seed_index, const dof_id_type count) { - for (std::size_t i = 0; i < count; ++i) - getRand(seed_index); + mooseAssert(seed_index < _generators.size(), "The seed number index does not exists."); + _generators[seed_index]->advance(count); } void @@ -356,18 +342,18 @@ Sampler::setAutoAdvanceGenerators(const bool state) _auto_advance_generators = state; } -double -Sampler::getRand(const unsigned int index) +Real +Sampler::getRand(std::size_t n, unsigned int index) const { - mooseAssert(index < _generator.size(), "The seed number index does not exists."); - return _generator.rand(index); + mooseAssert(index < _generators.size(), "The seed number index does not exists."); + return _generators[index]->rand(n); } -uint32_t -Sampler::getRandl(unsigned int index, uint32_t lower, uint32_t upper) +unsigned int +Sampler::getRandl(std::size_t n, unsigned int lower, unsigned int upper, unsigned int index) const { - mooseAssert(index < _generator.size(), "The seed number index does not exists."); - return _generator.randl(index, lower, upper); + mooseAssert(index < _generators.size(), "The seed number index does not exists."); + return _generators[index]->randl(n, lower, upper); } dof_id_type diff --git a/framework/src/utils/MooseRandomPerturbation.C b/framework/src/utils/MooseRandomPerturbation.C new file mode 100644 index 000000000000..ccd9db382f1b --- /dev/null +++ b/framework/src/utils/MooseRandomPerturbation.C @@ -0,0 +1,126 @@ +//* This file is part of the MOOSE framework +//* https://mooseframework.inl.gov +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#include "MooseRandomPerturbation.h" + +MooseRandomPerturbation::MooseRandomPerturbation(uint64_t seed, unsigned int n, unsigned int rounds) + : _k0(static_cast(seed)), + _k1(static_cast(seed >> 32)), + _n(n), + _half_bits((ceilLog2(n) + 1) / 2), + _half_mask((uint32_t(1) << _half_bits) - 1), + _rounds(rounds) +{ + mooseAssert(_n > 0, "n must be > 0"); + mooseAssert(_rounds > 0, "rounds must be greater than 0."); +} + +uint32_t +MooseRandomPerturbation::permute(uint32_t x) const +{ + mooseAssert(x < _n, "x must be < n"); + + uint32_t y = x; + do + { + y = permutePadded(y); + } while (y >= _n); + + return y; +} + +uint32_t +MooseRandomPerturbation::invert(uint32_t y) const +{ + mooseAssert(y < _n, "y must be < n"); + + uint32_t x = y; + do + { + x = invertPadded(x); + } while (x >= _n); + + return x; +} + +uint32_t +MooseRandomPerturbation::permutePadded(uint32_t x) const +{ + // Split x into the upper (L) and lower (R) half_bits-wide halves. + uint32_t L = (x >> _half_bits) & _half_mask; + uint32_t R = x & _half_mask; + + for (unsigned int r = 0; r < _rounds; ++r) + { + // Standard balanced Feistel step: new_L = R, new_R = L XOR F(R). + const uint32_t F = roundFunction(R, r); + const uint32_t newL = R; + const uint32_t newR = (L ^ F) & _half_mask; + L = newL; + R = newR; + } + + return ((L & _half_mask) << _half_bits) | (R & _half_mask); +} + +uint32_t +MooseRandomPerturbation::invertPadded(uint32_t y) const +{ + uint32_t L = (y >> _half_bits) & _half_mask; + uint32_t R = y & _half_mask; + + // Run rounds in reverse; recover prev_R = L then prev_L = R XOR F(prev_R). + for (int r = static_cast(_rounds) - 1; r >= 0; --r) + { + const uint32_t prevR = L; + const uint32_t F = roundFunction(prevR, static_cast(r)); + const uint32_t prevL = (R ^ F) & _half_mask; + L = prevL; + R = prevR; + } + + return ((L & _half_mask) << _half_bits) | (R & _half_mask); +} + +uint32_t +MooseRandomPerturbation::roundFunction(uint32_t half, unsigned int round) const +{ + uint32_t x = half; + x ^= _k0; + x += 0x9e3779b9U * static_cast(round + 1); // round-dependent constant + x ^= _k1; + x = mix32(x); + return x & _half_mask; +} + +unsigned int +MooseRandomPerturbation::ceilLog2(uint32_t n) +{ + mooseAssert(n > 0, "n must be > 0"); + + unsigned int bits = 0; + uint32_t v = n - 1; + while (v > 0) + { + ++bits; + v >>= 1; + } + return bits; +} + +uint32_t +MooseRandomPerturbation::mix32(uint32_t x) +{ + x ^= x >> 16; + x *= 0x7feb352dU; + x ^= x >> 15; + x *= 0x846ca68bU; + x ^= x >> 16; + return x; +} diff --git a/modules/combined/examples/stochastic/thermomech/gold/lhs_uniform_out.json b/modules/combined/examples/stochastic/thermomech/gold/lhs_uniform_out.json index 2eadd62dac47..228055e19483 100644 --- a/modules/combined/examples/stochastic/thermomech/gold/lhs_uniform_out.json +++ b/modules/combined/examples/stochastic/thermomech/gold/lhs_uniform_out.json @@ -14,83 +14,83 @@ "values": { "storage_data:dispx_center_inner:value_MEAN": { "stat": "MEAN", - "type": "std::pair >" + "type": "std::pair>" }, "storage_data:dispx_center_inner:value_STDDEV": { "stat": "STDDEV", - "type": "std::pair >" + "type": "std::pair>" }, "storage_data:dispx_center_outer:value_MEAN": { "stat": "MEAN", - "type": "std::pair >" + "type": "std::pair>" }, "storage_data:dispx_center_outer:value_STDDEV": { "stat": "STDDEV", - "type": "std::pair >" + "type": "std::pair>" }, "storage_data:dispx_end_inner:value_MEAN": { "stat": "MEAN", - "type": "std::pair >" + "type": "std::pair>" }, "storage_data:dispx_end_inner:value_STDDEV": { "stat": "STDDEV", - "type": "std::pair >" + "type": "std::pair>" }, "storage_data:dispx_end_outer:value_MEAN": { "stat": "MEAN", - "type": "std::pair >" + "type": "std::pair>" }, "storage_data:dispx_end_outer:value_STDDEV": { "stat": "STDDEV", - "type": "std::pair >" + "type": "std::pair>" }, "storage_data:dispz_inner:value_MEAN": { "stat": "MEAN", - "type": "std::pair >" + "type": "std::pair>" }, "storage_data:dispz_inner:value_STDDEV": { "stat": "STDDEV", - "type": "std::pair >" + "type": "std::pair>" }, "storage_data:dispz_outer:value_MEAN": { "stat": "MEAN", - "type": "std::pair >" + "type": "std::pair>" }, "storage_data:dispz_outer:value_STDDEV": { "stat": "STDDEV", - "type": "std::pair >" + "type": "std::pair>" }, "storage_data:temp_center_inner:value_MEAN": { "stat": "MEAN", - "type": "std::pair >" + "type": "std::pair>" }, "storage_data:temp_center_inner:value_STDDEV": { "stat": "STDDEV", - "type": "std::pair >" + "type": "std::pair>" }, "storage_data:temp_center_outer:value_MEAN": { "stat": "MEAN", - "type": "std::pair >" + "type": "std::pair>" }, "storage_data:temp_center_outer:value_STDDEV": { "stat": "STDDEV", - "type": "std::pair >" + "type": "std::pair>" }, "storage_data:temp_end_inner:value_MEAN": { "stat": "MEAN", - "type": "std::pair >" + "type": "std::pair>" }, "storage_data:temp_end_inner:value_STDDEV": { "stat": "STDDEV", - "type": "std::pair >" + "type": "std::pair>" }, "storage_data:temp_end_outer:value_MEAN": { "stat": "MEAN", - "type": "std::pair >" + "type": "std::pair>" }, "storage_data:temp_end_outer:value_STDDEV": { "stat": "STDDEV", - "type": "std::pair >" + "type": "std::pair>" } } }, @@ -159,143 +159,143 @@ { "stats": { "storage_data:dispx_center_inner:value_MEAN": [ - 0.0004041088326939742, + 0.0004043717679040656, [ - 0.0003475650268654479, - 0.0004602982259363247 + 0.0003629096334329824, + 0.00044673989434710905 ] ], "storage_data:dispx_center_inner:value_STDDEV": [ - 0.00011325320096136419, + 8.562603592126336e-05, [ - 7.720749221977145e-05, - 0.0001310562596258069 + 4.375052452809986e-05, + 0.00011000312937357351 ] ], "storage_data:dispx_center_outer:value_MEAN": [ - 0.0005005278884678082, + 0.000499834474343884, [ - 0.0004307723669538546, - 0.0005698572085465 + 0.0004499212627105325, + 0.0005510984420547323 ] ], "storage_data:dispx_center_outer:value_STDDEV": [ - 0.0001396000343509728, + 0.00010341976648193134, [ - 9.59873209101824e-05, - 0.00016082819136304936 + 5.153822106584897e-05, + 0.0001340757491301816 ] ], "storage_data:dispx_end_inner:value_MEAN": [ - 0.00042220354757272133, + 0.00041246339321122396, [ - 0.00036292320598971966, - 0.0004802587113100682 + 0.00035925540655631254, + 0.0004672438847090685 ] ], "storage_data:dispx_end_inner:value_STDDEV": [ - 0.00011844657310725845, + 0.00011141847596845155, [ - 8.535402956935216e-05, - 0.00013274621968998056 + 7.107148686334474e-05, + 0.00013249993651877294 ] ], "storage_data:dispx_end_outer:value_MEAN": [ - 0.00047962107356400564, + 0.0004700577454213585, [ - 0.0004125871750576709, - 0.000545381397451829 + 0.00041281056866434895, + 0.0005289957571748794 ] ], "storage_data:dispx_end_outer:value_STDDEV": [ - 0.00013380321010556805, + 0.00011934433484294112, [ - 9.6305339777295e-05, - 0.00014996019731950406 + 7.53665532162217e-05, + 0.00014308449995674384 ] ], "storage_data:dispz_inner:value_MEAN": [ - 0.0006146068176996869, + 0.0006084323494177848, [ - 0.0005300775586408571, - 0.0006992740716849042 + 0.0005460736042680106, + 0.0006729413499116678 ] ], "storage_data:dispz_inner:value_STDDEV": [ - 0.00017027670413966923, + 0.00012962351198686283, [ - 0.00012044010646104734, - 0.00019300687360948143 + 7.278384561664884e-05, + 0.0001644350650701214 ] ], "storage_data:dispz_outer:value_MEAN": [ - 0.0005005156786648756, + 0.0005043111537169073, [ - 0.00043066882825271694, - 0.0005704696368521462 + 0.00044903212637305653, + 0.0005608297493083688 ] ], "storage_data:dispz_outer:value_STDDEV": [ - 0.00014087023142696987, + 0.00011472460185008429, [ - 9.290413972833959e-05, - 0.00016492574440657714 + 6.61763536328713e-05, + 0.00014423714323386004 ] ], "storage_data:temp_center_inner:value_MEAN": [ - 610.5628540993606, + 611.1375564276152, [ - 601.4597169566683, - 619.4794653727993 + 600.9825855977663, + 621.0283529032234 ] ], "storage_data:temp_center_inner:value_STDDEV": [ - 18.165099228353984, + 20.568574766097694, [ - 11.671825120072699, - 21.742552655148465 + 14.072511652544023, + 23.725142318734942 ] ], "storage_data:temp_center_outer:value_MEAN": [ - 587.4326433590322, + 587.9047948967435, [ - 579.269533685599, - 595.4636082303919 + 579.2797852205647, + 596.3230537092386 ] ], "storage_data:temp_center_outer:value_STDDEV": [ - 16.308996785531754, + 17.548723222033, [ - 10.684473709401669, - 19.283828989430948 + 11.875334541449337, + 20.352520729256025 ] ], "storage_data:temp_end_inner:value_MEAN": [ - 506.8564649738913, + 506.97168653128904, [ - 500.392013609816, - 513.1751535428559 + 501.50905765962415, + 512.6145254605099 ] ], "storage_data:temp_end_inner:value_STDDEV": [ - 12.853657614875713, + 11.449133440710021, [ - 8.78622021322239, - 14.833566240217383 + 7.717806025279164, + 13.40306280112824 ] ], "storage_data:temp_end_outer:value_MEAN": [ - 508.47237817382285, + 508.58934480784075, [ - 501.90220135914876, - 514.9169755781419 + 502.87869194524137, + 514.4500480367327 ] ], "storage_data:temp_end_outer:value_STDDEV": [ - 13.115423104548583, + 11.909750258969705, [ - 8.99851193998505, - 15.079206732132011 + 8.030036243853257, + 13.99055861654749 ] ] }, @@ -313,128 +313,128 @@ true ], "data:dispx_center_inner:value": [ - 0.00031363226081832906, - 0.00046314744182851324, - 0.0005578790700146324, - 0.0004466455468283186, - 0.00025164809887231906, - 0.0005619810670246544, - 0.0003321998655771603, - 0.0004764929932546654, - 0.0002679701460826264, - 0.0003694918366385232 + 0.00038981809292440304, + 0.0005557976925779025, + 0.0004350332448897711, + 0.000392081399230247, + 0.0003254518522948608, + 0.00038286899863544194, + 0.00041863505314375995, + 0.00024257411116796943, + 0.0004039151432434001, + 0.0004975420909328994 ], "data:dispx_center_outer:value": [ - 0.00039007796096579876, - 0.0005721817754612002, - 0.0006906442852520142, - 0.0005578018776166988, - 0.00031590976554571256, - 0.0006902865047438329, - 0.00040736815174151537, - 0.000594125300476326, - 0.00032953084432749965, - 0.0004573524185474833 + 0.0004748915272611948, + 0.0006858709019064146, + 0.0005499415286560498, + 0.00048153682874098243, + 0.0004135199630174104, + 0.00048107387809846297, + 0.000521263960229656, + 0.0003028976664647329, + 0.00048328271252421777, + 0.0006040657765397197 ], "data:dispx_end_inner:value": [ - 0.0003386109057653879, - 0.0004776774463142722, - 0.0005703490275139105, - 0.000489549934994763, - 0.0002961856794561002, - 0.0005499929979688582, - 0.00030184489221078123, - 0.0005477621572643871, - 0.00026033240306902233, - 0.000389730031169731 + 0.00033738607961145774, + 0.0005781104607816505, + 0.0005630463079498737, + 0.0003682608476776031, + 0.00041590993738599034, + 0.00048439765988899205, + 0.0004566283039531367, + 0.00026548841630006796, + 0.0002538287589767906, + 0.000401577159586677 ], "data:dispx_end_outer:value": [ - 0.0003832897361658128, - 0.0005435166247736728, - 0.0006492206468518778, - 0.0005527511539334857, - 0.0003338080486335381, - 0.000629910123602057, - 0.00034827219243992413, - 0.000615519734518557, - 0.00029912505807139694, - 0.00044079741664973445 + 0.0003930969012823575, + 0.00065454706843135, + 0.0006274571684346239, + 0.0004252720468732502, + 0.00046287736765382697, + 0.0005395920551870019, + 0.0005152809018254456, + 0.00029976353679637806, + 0.0003103363910266193, + 0.0004723540167027316 ], "data:dispz_inner:value": [ - 0.0004849930035452236, - 0.0006996066042135606, - 0.0008405669756379178, - 0.0006964285954910709, - 0.00040807722872690305, - 0.0008273206267010179, - 0.0004744319281438018, - 0.0007575882345318739, - 0.0003944429634976787, - 0.0005626120165078207 + 0.0005450433920194955, + 0.0008393560005100691, + 0.000738259271373054, + 0.000569417193771181, + 0.0005495435989748031, + 0.0006386472601071033, + 0.0006496069857845152, + 0.0003780068671184486, + 0.0005001585588865534, + 0.0006762843656326241 ], "data:dispz_outer:value": [ - 0.0003844990050025078, - 0.0005754663118445223, - 0.0006921054744473546, - 0.0005456936976088935, - 0.00030682808169199316, - 0.0007107877508142916, - 0.00042324306409111627, - 0.0005732230093742781, - 0.0003409147820008975, - 0.00045239560977290065 + 0.0005064062590015968, + 0.0006817113166678684, + 0.0005107210145390209, + 0.0005045489413059262, + 0.0003801220744121496, + 0.0004482715499408034, + 0.0005093497180743623, + 0.0002961018231021565, + 0.0005502881553741723, + 0.0006555906847510166 ], "data:temp_center_inner:value": [ - 594.2121709866562, - 599.9654579842744, - 614.1781775288391, - 639.7442726531654, - 618.130643184775, - 620.3744430945519, - 591.5035410041094, - 583.1464818075847, - 631.8505780366875, - 612.5227747129634 + 610.17927549069, + 626.815107637753, + 586.3367075650242, + 635.0794787988215, + 590.1750339778115, + 580.2882734287862, + 607.9369996340075, + 608.8995121922303, + 636.3601904019406, + 629.3049851490873 ], "data:temp_center_outer:value": [ - 574.4765910423428, - 577.0911877373549, - 592.3301494759811, - 610.7499920585425, - 597.8038831448066, - 594.6663425552805, - 570.2663148871761, - 562.0595102501878, - 608.6806634819798, - 586.2017989566704 + 588.5235224173697, + 598.9554769500587, + 568.0802427555324, + 608.8508330498402, + 570.0716491779972, + 561.6250849597784, + 582.197560392131, + 586.4419109358931, + 611.2246867793485, + 603.0769815494862 ], "data:temp_end_inner:value": [ - 497.13387452581577, - 499.4986281315729, - 508.5611379369053, - 520.6591874419493, - 520.0456806536757, - 513.9836396523988, - 491.3539969015167, - 489.2217336141991, - 525.5687538073399, - 502.53801707354006 + 508.8638228634077, + 511.6706161637647, + 497.8885330024392, + 525.1086170442126, + 493.43107146438837, + 491.96259430386357, + 499.9539711342405, + 503.6012257336334, + 519.6476612124156, + 517.5887523905242 ], "data:temp_end_outer:value": [ - 497.80129128717164, - 501.2860588040267, - 509.41450736964026, - 523.4391174714061, - 521.0831922151989, - 516.54558414065, - 492.3480052448308, - 490.7849811920915, - 527.1241805008187, - 504.8968635123939 + 510.0950938303771, + 514.2663619850595, + 498.78507421392476, + 527.643844989675, + 494.2796684552679, + 493.0180624533907, + 502.2372999032566, + 504.73135246317395, + 520.9527235052088, + 519.883966279073 ] }, "time": 1.0, "time_step": 1 } ] -} +} \ No newline at end of file diff --git a/modules/stochastic_tools/examples/parameter_study/gold/main_out.json b/modules/stochastic_tools/examples/parameter_study/gold/main_out.json index ab9cc02df78a..78bab9e22776 100644 --- a/modules/stochastic_tools/examples/parameter_study/gold/main_out.json +++ b/modules/stochastic_tools/examples/parameter_study/gold/main_out.json @@ -34,19 +34,19 @@ "values": { "results_results:T_avg:value_MEAN": { "stat": "MEAN", - "type": "std::pair >" + "type": "std::pair>" }, "results_results:T_avg:value_STDDEV": { "stat": "STDDEV", - "type": "std::pair >" + "type": "std::pair>" }, "results_results:q_left:value_MEAN": { "stat": "MEAN", - "type": "std::pair >" + "type": "std::pair>" }, "results_results:q_left:value_STDDEV": { "stat": "STDDEV", - "type": "std::pair >" + "type": "std::pair>" } } } @@ -55,16 +55,16 @@ { "results": { "results:T_avg:value": [ - 290.0493845242595, - 248.6050947481139, - 192.0301321316896, - 131.58596857841474, - 272.5977017632619, - 212.76355765830587, - 151.82993831123738, - 191.70332294603384, - 148.04326716479108, - 155.07004432808066 + 156.17961016183162, + 306.07573228340254, + 203.17078602075873, + 246.81206729474246, + 154.56801377479164, + 159.1964567105364, + 242.1685936781885, + 145.87657247969565, + 169.67369581820338, + 246.42835174507476 ], "results:converged": [ true, @@ -79,45 +79,45 @@ true ], "results:q_left:value": [ - 324.27838280823414, - 278.95232322012805, - 107.37667968314861, - 99.3833233984007, - 281.57633634305506, - 182.60721896502028, - 112.2623447967543, - 125.51199465235003, - 114.6937641007055, - 169.10791450427786 + 127.16844948589197, + 316.88478857250084, + 89.51531265063498, + 305.5838688989559, + 91.93138613125674, + 81.1313397550367, + 237.03891722514692, + 129.56075708433295, + 193.615510182434, + 271.4692038738943 ] }, "stats": { "results_results:T_avg:value_MEAN": [ - 199.42784121541888, + 203.01498799672257, [ - 172.4194543916743, - 227.45755683125793 + 176.9420255889682, + 231.07449769717877 ] ], "results_results:T_avg:value_STDDEV": [ - 55.53057128319956, + 54.56353720917991, [ - 35.73264905596605, - 64.78429485236896 + 35.81792183571536, + 65.16276440764146 ] ], "results_results:q_left:value_MEAN": [ - 179.57502824720748, + 184.38995338600853, [ - 138.96130933930553, - 223.43024101745672 + 139.74476690592087, + 231.0270638692204 ] ], "results_results:q_left:value_STDDEV": [ - 84.7510259100363, + 92.60149587444442, [ - 54.29352893810827, - 98.00828658688752 + 65.72934106854788, + 104.49447867866519 ] ] }, @@ -125,4 +125,4 @@ "time_step": 2 } ] -} +} \ No newline at end of file diff --git a/modules/stochastic_tools/examples/parameter_study/gold/main_parameter_study_json.json b/modules/stochastic_tools/examples/parameter_study/gold/main_parameter_study_json.json index fcdb632af609..45ac17efe938 100644 --- a/modules/stochastic_tools/examples/parameter_study/gold/main_parameter_study_json.json +++ b/modules/stochastic_tools/examples/parameter_study/gold/main_parameter_study_json.json @@ -1,11 +1,4 @@ { - "app_name": "main", - "current_time": "Thu Nov 24 00:52:22 2022", - "executable": "/home/prinzm/projects/moose/modules/stochastic_tools/stochastic_tools-opt", - "executable_time": "Thu Nov 24 00:51:47 2022", - "libmesh_version": "3f05f40f4a45060c1fd07281f8869a4667086291", - "moose_version": "git commit e5a78d2dd0 on 2022-11-23", - "petsc_version": "3.16.6", "reporters": { "study_results": { "type": "StochasticMatrix", @@ -35,15 +28,15 @@ "row_end": 10, "type": "std::vector" }, - "q_left:value": { + "converged": { "row_begin": 0, "row_end": 10, - "type": "std::vector" + "type": "std::vector" }, - "converged": { + "q_left:value": { "row_begin": 0, "row_end": 10, - "type": "std::vector" + "type": "std::vector" } } }, @@ -65,98 +58,85 @@ "values": { "study_results_T_avg:value_MEAN": { "stat": "MEAN", - "type": "std::pair >" + "type": "std::pair>" }, "study_results_T_avg:value_STDDEV": { "stat": "STDDEV", - "type": "std::pair >" + "type": "std::pair>" }, "study_results_q_left:value_MEAN": { "stat": "MEAN", - "type": "std::pair >" + "type": "std::pair>" }, "study_results_q_left:value_STDDEV": { "stat": "STDDEV", - "type": "std::pair >" + "type": "std::pair>" } } } }, - "slepc_version": "3.16.2", "time_steps": [ { "study_results": { "BCs_left_value": [ - 105.0687460467851, - 95.47355625822676, - 133.6858803000008, - 76.34144304314813, - 116.26879639439662, - 111.00387725780324, - 89.9755556183598, - 125.19208707455101, - 84.8918738057713, - 62.47104910334905 + 86.43107141772074, + 122.05200069221836, + 154.8248039780708, + 91.15789449872489, + 102.24774372533416, + 113.80986380940087, + 106.89221906196246, + 73.46811487456017, + 63.70397474072112, + 97.49935821408447 ], "BCs_right_value": [ - 357.03632396593815, - 361.52435171068635, - 295.7599513029338, - 329.4372076059286, - 258.1523783770392, - 319.13327026743383, - 280.6905788342888, - 235.53331924148245, - 272.9476619507443, - 308.13892031560226 + 304.41508535139434, + 319.74335412876695, + 265.1485976778947, + 364.6494369136431, + 261.02395477852656, + 234.6981425970773, + 276.55686484232666, + 289.07635960756414, + 356.3628341781873, + 336.84718735758037 ], "Kernels_source_value": [ - -107.15910670106229, - -96.48408917931759, - -80.05258658101849, - -108.69437289463623, - -68.96243486264218, - -105.3455485086838, - -92.40283978150518, - -55.44867912301454, - -91.41124435192026, - -100.40511417437409 + -95.4873172427452, + -97.82700438025296, + -67.01894815966767, + -25.37728656257164, + -103.70579194016676, + -85.180897321408, + -100.29871205348329, + -107.4407727006986, + -108.80486134127398, + -90.67103508885225 ], "Materials_constant_prop_values": [ - 0.731964924462656, - 0.9781574531855683, - 2.173118050219286, - 2.466810863823885, - 0.6588319927399185, - 1.2872970311666934, - 1.9222664754083632, - 1.6118299854788039, - 1.8391509209880943, - 1.431301446492852 + 1.8588319927399186, + 0.631301446492852, + 2.373118050219286, + 1.1254926630469444, + 2.0033035889868067, + 2.135768697576436, + 0.7983002035234377, + 1.6592812786442042, + 1.4343259540894455, + 0.9394336254878097 ], "T_avg:value": [ - 290.04938452425955, - 248.6050947481139, - 192.0301321316896, - 131.58596857841474, - 272.5977017632619, - 212.76355765830587, - 151.82993831123738, - 191.70332294603384, - 148.04326716479113, - 155.07004432808066 - ], - "q_left:value": [ - 324.27838280823414, - 278.95232322012805, - 107.37667968314861, - 99.3833233984007, - 281.5763363430551, - 182.60721896502022, - 112.2623447967543, - 125.51199465235003, - 114.69376410070547, - 169.10791450427791 + 156.17961016183162, + 306.07573228340254, + 203.17078602075873, + 246.81206729474246, + 154.56801377479164, + 159.1964567105364, + 242.1685936781885, + 145.87657247969565, + 169.67369581820338, + 246.42835174507476 ], "converged": [ true, @@ -169,51 +149,63 @@ true, true, true + ], + "q_left:value": [ + 127.16844948589197, + 316.88478857250084, + 89.51531265063498, + 305.5838688989559, + 91.93138613125674, + 81.1313397550367, + 237.03891722514692, + 129.56075708433295, + 193.615510182434, + 271.4692038738943 ] }, "study_statistics": { "study_results_T_avg:value_MEAN": [ - 199.42784121541888, + 203.01498799672257, [ - 164.41164300789643, - 175.1215579031783, - 179.63649071672612, - 222.80750909796993, - 228.24452247955304, - 240.8364765209057 + 169.13882949024708, + 177.21453404553418, + 181.70176704654594, + 223.734021562986, + 230.18115555210056, + 241.06765742023526 ] ], "study_results_T_avg:value_STDDEV": [ - 55.53057128319956, + 54.56353720917991, [ - 27.9239572505363, - 35.988341073525056, - 40.46254485837603, - 61.03617238115658, - 64.24391182026277, - 68.92747211912871 + 28.350290459130058, + 35.75530084327167, + 38.55558926736545, + 63.08988890306703, + 65.25248670867552, + 70.89188038571707 ] ], "study_results_q_left:value_MEAN": [ - 179.57502824720746, + 184.38995338600853, [ - 127.89714389579183, - 140.30217166469723, - 147.87755008583505, - 213.94963867862847, - 226.01757664293672, - 242.89963487453207 + 120.33727273323575, + 137.4539926303556, + 146.62614041352407, + 218.20766241771403, + 230.1568483293251, + 247.22455240378181 ] ], "study_results_q_left:value_STDDEV": [ - 84.75102591003635, + 92.60149587444442, [ - 30.236295674060372, - 54.242504255585104, - 57.51554187325722, - 94.10009802369535, - 96.77342299793773, - 101.69761565386499 + 50.14936578669668, + 65.72726040874399, + 71.98103829014103, + 100.99787149918912, + 103.81248234840248, + 110.3558508785353 ] ] }, @@ -221,4 +213,4 @@ "time_step": 1 } ] -} +} \ No newline at end of file diff --git a/modules/stochastic_tools/examples/parameter_study/gold/main_time_out.json b/modules/stochastic_tools/examples/parameter_study/gold/main_time_out.json index 4dce80acfedd..d83c7e3e6edf 100644 --- a/modules/stochastic_tools/examples/parameter_study/gold/main_time_out.json +++ b/modules/stochastic_tools/examples/parameter_study/gold/main_time_out.json @@ -22,27 +22,27 @@ "values": { "results_results:T_avg:value_MEAN": { "stat": "MEAN", - "type": "std::pair >" + "type": "std::pair>" }, "results_results:T_avg:value_STDDEV": { "stat": "STDDEV", - "type": "std::pair >" + "type": "std::pair>" }, "results_results:T_vec:T_MEAN": { "stat": "MEAN", - "type": "std::pair, std::vector> >" + "type": "std::pair, std::vector>>" }, "results_results:T_vec:T_STDDEV": { "stat": "STDDEV", - "type": "std::pair, std::vector> >" + "type": "std::pair, std::vector>>" }, "results_results:q_left:value_MEAN": { "stat": "MEAN", - "type": "std::pair >" + "type": "std::pair>" }, "results_results:q_left:value_STDDEV": { "stat": "STDDEV", - "type": "std::pair >" + "type": "std::pair>" } } } @@ -66,117 +66,117 @@ }, "stats": { "results_results:T_avg:value_MEAN": [ - 227.60030720094375, + 229.84986123728336, [ - 211.59911273447074, - 243.53356189957967 + 215.1765065020676, + 245.20853095798202 ] ], "results_results:T_avg:value_STDDEV": [ - 32.224001362690075, + 30.380993204535383, [ - 21.510793625402826, - 37.72722063042233 + 21.140970851889726, + 35.226411758567316 ] ], "results_results:T_vec:T_MEAN": [ [ - 100.03728649023918, - 133.4778296495365, - 162.48384028722555, - 188.051130684289, - 211.0505092123101, - 232.26340135448353, - 252.41372795547323, - 272.19753963914945, - 292.3118033667247, - 313.48370617562375, - 336.5018808832716 + 101.2087045012798, + 134.92565009703006, + 164.15063512495587, + 189.8999157472577, + 213.06288290152642, + 234.43852869924322, + 254.76817411034745, + 274.76599692120124, + 295.14880195596646, + 316.66645349925597, + 340.13444213232935 ], [ [ - 89.1877100078166, - 122.39132942529507, - 150.79632646992616, - 175.34245349381396, - 197.36056040147514, - 217.29837303991772, - 235.78164499157342, - 253.44807772934217, - 270.67917088720276, - 287.9099134421469, - 305.6968444465218 + 89.17906603909316, + 123.96759101412849, + 153.3090583173315, + 178.419738540732, + 200.68278117049613, + 220.78650807065537, + 239.26704872829805, + 256.8009755221963, + 274.0815136114228, + 291.5753095937013, + 309.5406453047046 ], [ - 110.87552611148821, - 144.03132174389802, - 173.82280572209783, - 200.40976251272613, - 224.5413290489665, - 247.0066574899753, - 269.03022171404007, - 291.3788830716484, - 314.72460624099006, - 340.37966529783375, - 369.33420682827847 + 114.23225548962132, + 146.44504351187408, + 175.47037277328954, + 201.72348145419073, + 225.91368688536605, + 248.79247029208068, + 271.03115006252955, + 293.6437213635962, + 317.2441789623618, + 343.0080961816207, + 372.36721242007434 ] ] ], "results_results:T_vec:T_STDDEV": [ [ - 22.356207800918792, - 22.208466097320628, - 23.468755155769514, - 25.28497316711285, - 27.466574717536297, - 30.145117081021002, - 33.59970226257455, - 38.193861506811466, - 44.365236602908354, - 52.64103177539883, - 63.66808679500987 + 25.8426903780381, + 22.984391951183543, + 22.447743387733585, + 23.40074201382914, + 25.378378303813836, + 28.248329981188515, + 32.09889587803744, + 37.16566056218284, + 43.80820049931566, + 52.518161971820085, + 63.94417510389675 ], [ [ - 14.365157371010174, - 15.27175104128586, - 16.404089293476257, - 17.351233609445075, - 18.499818272739162, - 20.159127028400814, - 22.3783871523961, - 25.281520710769797, - 29.05523504756616, - 34.043683311777095, - 40.49801260726624 + 13.720972451092505, + 14.107275141567737, + 15.157130232670092, + 16.70187692198841, + 18.091509481646515, + 20.059699267892746, + 22.763789123268104, + 26.32029242526996, + 30.91006972209992, + 36.82073437461326, + 44.149545959043856 ], [ - 27.004136980594293, - 25.21987098118524, - 26.859666981200235, - 29.381652563445037, - 32.159584377829084, - 35.351188753788506, - 39.41196489517475, - 44.636185880773425, - 51.665096301734955, - 61.35664780987714, - 74.46063965258232 + 33.45420512774473, + 27.9142724881614, + 26.159639417248957, + 27.088701319406905, + 29.127591075189716, + 32.18850049458671, + 36.45901464355511, + 42.16640998797002, + 49.87287151025515, + 60.215941468898585, + 73.99197413762167 ] ] ], "results_results:q_left:value_MEAN": [ - 334.40543158919024, + 337.1694559544137, [ - 297.3941153023196, - 372.44672734916776 + 293.7883234460836, + 377.9934333250308 ] ], "results_results:q_left:value_STDDEV": [ - 75.04240984242925, + 86.11239740959846, [ - 52.51930696125128, - 86.1515114864844 + 57.07704677324272, + 100.4101826703486 ] ] }, @@ -201,117 +201,117 @@ }, "stats": { "results_results:T_avg:value_MEAN": [ - 209.68609338625456, + 212.74539416810111, [ - 187.2673244031301, - 232.3833989833072 + 191.74550226404986, + 234.8891616792542 ] ], "results_results:T_avg:value_STDDEV": [ - 45.38469354498731, + 43.72146846461898, [ - 29.939352219053262, - 52.85120781046609 + 29.85476758083796, + 51.21827202410676 ] ], "results_results:T_vec:T_MEAN": [ [ - 100.03728649023918, - 121.39330902751492, - 143.10756245107427, - 164.96413313356123, - 186.87913600204448, - 208.8630261073109, - 230.99071220151023, - 253.37661205781856, - 276.1521252145176, - 299.44313357895237, - 323.34508168692264 + 101.2087045012798, + 122.93820632580358, + 145.02083051103563, + 167.24151733986156, + 189.51983999521468, + 211.87159530046333, + 234.37829339079394, + 257.1616212832171, + 280.360283772439, + 304.1067451502172, + 328.5013127233042 ], [ [ - 89.1877100078166, - 109.68166308262835, - 129.8150190000199, - 149.3689682293303, - 168.70336995580948, - 187.46850865452475, - 206.2501515241357, - 224.7443152799511, - 243.0816844125283, - 261.3151494300784, - 279.5249232473376 + 89.17906603909316, + 111.24191992019675, + 132.44586222851143, + 152.7606553034981, + 172.52986251932867, + 191.84792157690794, + 210.67809954264536, + 229.38969306198652, + 247.91560249402792, + 266.4602504912865, + 285.23354221043 ], [ - 110.87552611148821, - 132.58096570077856, - 155.91718827031593, - 180.10727138568512, - 204.99738213661163, - 230.2463005385122, - 256.37573650573074, - 283.1768440174458, - 310.9314784537464, - 339.9581792303758, - 370.28851535346854 + 114.23225548962132, + 135.27624135000377, + 157.98348981328618, + 182.12931665927934, + 207.14115777606497, + 232.96462511485532, + 259.27700912339577, + 286.4110416266394, + 314.73715786666446, + 343.92277477838627, + 374.6959865099062 ] ] ], "results_results:T_vec:T_STDDEV": [ [ - 22.356207800918792, - 23.46364402403767, - 26.509588749797327, - 31.037400804009906, - 36.65284485179478, - 43.16885291005458, - 50.56462151796642, - 58.91817817180235, - 68.35394661805498, - 79.0027020809887, - 90.96505156769923 + 25.8426903780381, + 24.6195797937378, + 25.945748722149766, + 29.564199492256833, + 34.8928122903342, + 41.48838417964545, + 49.14989528839627, + 57.850354845824064, + 67.65853103493167, + 78.68002907167259, + 91.00872912667626 ], [ [ - 14.365157371010174, - 16.12615266300685, - 18.721061387018633, - 21.71707127860497, - 25.014432435209496, - 28.77193547691614, - 33.186636666942086, - 38.29037974281937, - 43.825299151650235, - 49.995563768606615, - 56.77725720674793 + 13.720972451092505, + 14.827153531591616, + 17.482311778590837, + 21.08020656422634, + 24.66665878587789, + 28.80031795713642, + 33.92034408206468, + 39.964467799883245, + 46.44873704301341, + 53.6697840655443, + 61.40768459628934 ], [ - 27.004136980594293, - 26.740489217508305, - 29.891694882426542, - 35.4630386381141, - 42.432803529425186, - 50.259438617233556, - 58.91108824109983, - 68.61110698467556, - 79.70176869656389, - 92.27554967014244, - 106.3661858088565 + 33.45420512774473, + 30.204731934633624, + 30.274140639593377, + 34.33923301454521, + 40.464789844117306, + 48.041184831385664, + 56.806106187753116, + 66.96667967595317, + 78.44707654046053, + 91.63166598801546, + 106.6342376951192 ] ] ], "results_results:q_left:value_MEAN": [ - 213.5602253723395, + 217.29501824469918, [ - 179.94689229715306, - 249.11859323607572 + 178.70999978143385, + 256.14121413926625 ] ], "results_results:q_left:value_STDDEV": [ - 69.38843707939813, + 78.77093005846885, [ - 47.66355322576302, - 79.06065151304021 + 57.02655649822905, + 88.9472178838479 ] ] }, @@ -336,117 +336,117 @@ }, "stats": { "results_results:T_avg:value_MEAN": [ - 202.51942534616902, + 205.9384474907757, [ - 177.11619791017023, - 228.7544892495245 + 181.6717414573483, + 231.8514747742719 ] ], "results_results:T_avg:value_STDDEV": [ - 52.04377791815543, + 50.74935842638249, [ - 33.89971713625179, - 60.6283771463951 + 33.85173647571717, + 60.064017901207656 ] ], "results_results:T_vec:T_MEAN": [ [ - 100.03728649023918, - 118.86620273813233, - 138.34405864400964, - 158.4156987287785, - 179.0427117123655, - 200.20472330798603, - 221.89740075377327, - 244.1284186550994, - 266.91230362616835, - 290.2649181601087, - 314.1983477806355 + 101.2087045012798, + 120.4809969833511, + 140.4005255455794, + 160.91385940166927, + 181.9846045365344, + 203.59468788352507, + 225.74226744725962, + 248.43753813283462, + 271.69736855476424, + 295.5395496741885, + 319.9774489950168 ], [ [ - 89.1877100078166, - 106.7226547053447, - 124.00267130897944, - 141.2519417477812, - 158.5072633547057, - 175.6574869552837, - 193.12541899548643, - 210.85155942603288, - 228.68598645345983, - 246.64822364606772, - 264.93701531221376 + 89.17906603909316, + 108.38059344608959, + 126.69138144022972, + 144.5669462764885, + 162.323044860229, + 180.17624148134718, + 198.05610296939872, + 216.0948628883811, + 233.99449797478815, + 252.1606916213247, + 270.627064869497 ], [ - 110.87552611148821, - 130.513918337402, - 152.124644591199, - 175.3952493861429, - 199.75033479719724, - 225.28288261135816, - 251.72156691019728, - 279.2297544130971, - 307.52722587670195, - 337.1042324777935, - 367.4172761041138 + 114.23225548962132, + 133.2351886877354, + 154.59956203068558, + 177.7639420644227, + 202.53403341667723, + 228.37878711196134, + 255.1928547703338, + 283.01982837486537, + 311.7084933228221, + 341.5870564082993, + 372.6386740847635 ] ] ], "results_results:T_vec:T_STDDEV": [ [ - 22.356207800918792, - 24.331160904892183, - 28.596845696970817, - 34.581525098603585, - 41.81115423492132, - 50.01139097290208, - 59.052564685089074, - 68.88789847322334, - 79.51204266857441, - 90.93477489973371, - 103.16383394628411 + 25.8426903780381, + 25.583435659799953, + 28.298882009768334, + 33.50899757337016, + 40.497135006618144, + 48.75085141430442, + 57.99440212213966, + 68.10285783021942, + 79.03148641546754, + 90.77187057559964, + 103.325055492579 ], [ [ - 14.365157371010174, - 16.75731833929035, - 20.43118475409347, - 24.2283266313354, - 28.226434409005357, - 32.85202471111355, - 38.156313690729114, - 43.906957367569404, - 49.91399156424246, - 56.32424909658788, - 63.15991622723397 + 13.720972451092505, + 15.58102619235251, + 19.05213499000861, + 23.558258782880447, + 28.032300543618486, + 33.04202808213796, + 39.030757451779586, + 45.613222448600126, + 52.8695378397467, + 60.49616081255192, + 68.46999849618419 ], [ - 27.004136980594293, - 27.706775434656734, - 32.21098559105086, - 39.538168051060005, - 48.37632992572655, - 58.14565475551048, - 68.7648821068091, - 80.32239776233008, - 92.82237982878107, - 106.30625868251319, - 120.94695599673304 + 33.45420512774473, + 31.26334469799443, + 33.12696037320411, + 39.252885554357086, + 47.562896772460654, + 57.15502023809991, + 68.00295936240454, + 80.02944100279807, + 92.92102493587599, + 106.93643941322188, + 122.09821120803124 ] ] ], "results_results:q_left:value_MEAN": [ - 188.28916247883237, + 192.72292482067377, [ - 150.89629887186578, - 228.4775115459579 + 150.85472637344134, + 236.08485284177823 ] ], "results_results:q_left:value_STDDEV": [ - 78.01121496824891, + 86.49404693943802, [ - 51.49237463253648, - 89.55642939997962 + 62.537159354319506, + 97.1791390699771 ] ] }, @@ -471,117 +471,117 @@ }, "stats": { "results_results:T_avg:value_MEAN": [ - 199.42784121541888, + 203.01498799672257, [ - 172.4194543916743, - 227.45755683125793 + 176.9420255889682, + 231.07449769717877 ] ], "results_results:T_avg:value_STDDEV": [ - 55.53057128319956, + 54.56353720917991, [ - 35.73264905596605, - 64.78429485236896 + 35.81792183571536, + 65.16276440764146 ] ], "results_results:T_vec:T_MEAN": [ [ - 100.03728649023918, - 117.99478931496034, - 136.64910494922373, - 155.9839320210951, - 175.98589236538982, - 196.6451925122557, - 217.95565115179284, - 239.91419346212234, - 262.51998655302566, - 285.7734268170508, - 309.6751995242629 + 101.2087045012798, + 119.6476998398806, + 138.78160948351564, + 158.59547377734606, + 179.07725858584067, + 200.21849782184364, + 222.01428495991922, + 244.46271641927132, + 267.5639660254639, + 291.3192088198413, + 315.72962396722767 ], [ [ - 89.1877100078166, - 105.5972997200732, - 121.66341816528484, - 137.78497027521246, - 153.97704350244598, - 170.47229010948837, - 187.24784364169892, - 204.27242978073463, - 221.97439188013132, - 239.5789599881704, - 257.794528530096 + 89.17906603909316, + 107.19283257936324, + 124.34292783403141, + 141.1446419787566, + 157.98461839649457, + 174.9306841464117, + 192.14543810799447, + 209.74930369537302, + 227.33469577412524, + 245.15975984495634, + 263.51033467028356 ], [ - 110.87552611148821, - 129.9363776472026, - 151.10521575206243, - 174.0417878725353, - 198.33718582877162, - 223.78986482932106, - 250.14925492029684, - 277.63527247378073, - 306.2950704824669, - 335.4739199610475, - 366.00640935482363 + 114.23225548962132, + 132.72348432566758, + 153.7528780143681, + 176.71229454817174, + 201.31922111176934, + 227.2089549310007, + 253.9323468842525, + 281.7626580460418, + 310.95090078333243, + 340.6033568990596, + 371.5538862774823 ] ] ], "results_results:T_vec:T_STDDEV": [ [ - 22.356207800918792, - 24.877788668475343, - 29.914648330847445, - 36.72682271945961, - 44.77185651908623, - 53.744683398064986, - 63.48709543336668, - 73.9191340206029, - 85.00071887515601, - 96.71086464653398, - 109.03607028323171 + 25.8426903780381, + 26.233171530388162, + 29.851691549003604, + 35.98380075042183, + 43.8230810747037, + 52.84451051607002, + 62.76398624557339, + 73.43647067012994, + 84.78951740369598, + 96.7869025789158, + 109.40888358704971 ], [ [ - 14.365157371010174, - 17.13349424114061, - 21.40405772186764, - 25.68181838417647, - 29.93087757625, - 34.92557798451628, - 40.371867265712, - 46.21441995957954, - 52.28927573960013, - 58.79143866923859, - 65.64566790299457 + 13.720972451092505, + 16.02726667799745, + 19.99098658984379, + 24.938914229480957, + 29.684783256732842, + 35.0305401348356, + 41.28280361961082, + 48.04568019466856, + 55.487474644335116, + 63.252517902054514, + 71.2033043676715 ], [ - 27.004136980594293, - 28.295427375779507, - 33.75136841839193, - 42.11447082568368, - 51.910582724061754, - 62.57678685449877, - 74.00849894068791, - 86.28031447447324, - 99.4236677775874, - 113.43489012322013, - 128.1577838222949 + 33.45420512774473, + 31.882528994639387, + 35.1519368507018, + 42.57939484422265, + 52.04903377553427, + 62.62324566309757, + 74.42736292319834, + 87.20167884503923, + 100.79086697931663, + 115.17436953310411, + 130.40034268287133 ] ] ], "results_results:q_left:value_MEAN": [ - 179.57502824720748, + 184.38995338600853, [ - 138.96130933930553, - 223.43024101745672 + 139.74476690592087, + 231.0270638692204 ] ], "results_results:q_left:value_STDDEV": [ - 84.7510259100363, + 92.60149587444442, [ - 54.29352893810827, - 98.00828658688752 + 65.72934106854788, + 104.49447867866519 ] ] }, @@ -589,4 +589,4 @@ "time_step": 4 } ] -} +} \ No newline at end of file diff --git a/modules/stochastic_tools/examples/parameter_study/gold/main_vector_out.json b/modules/stochastic_tools/examples/parameter_study/gold/main_vector_out.json index 84287950b950..001ee30e8cf3 100644 --- a/modules/stochastic_tools/examples/parameter_study/gold/main_vector_out.json +++ b/modules/stochastic_tools/examples/parameter_study/gold/main_vector_out.json @@ -14,19 +14,19 @@ "values": { "results_results:acc:T_avg:value_MEAN": { "stat": "MEAN", - "type": "std::pair, std::vector> >" + "type": "std::pair, std::vector>>" }, "results_results:acc:T_avg:value_STDDEV": { "stat": "STDDEV", - "type": "std::pair, std::vector> >" + "type": "std::pair, std::vector>>" }, "results_results:acc:q_left:value_MEAN": { "stat": "MEAN", - "type": "std::pair, std::vector> >" + "type": "std::pair, std::vector>>" }, "results_results:acc:q_left:value_STDDEV": { "stat": "STDDEV", - "type": "std::pair, std::vector> >" + "type": "std::pair, std::vector>>" } } } @@ -37,100 +37,100 @@ "results_results:acc:T_avg:value_MEAN": [ [ 299.99999999999983, - 227.60030720094375, - 209.68609338625456, - 202.51942534616902, - 199.42784121541888 + 229.84986123728336, + 212.74539416810111, + 205.9384474907757, + 203.01498799672257 ], [ [ 299.99999999999983, - 211.59911273447074, - 187.2673244031301, - 177.11619791017023, - 172.4194543916743 + 215.1765065020676, + 191.74550226404986, + 181.6717414573483, + 176.9420255889682 ], [ 299.99999999999983, - 243.53356189957967, - 232.3833989833072, - 228.7544892495245, - 227.45755683125793 + 245.20853095798202, + 234.8891616792542, + 231.8514747742719, + 231.07449769717877 ] ] ], "results_results:acc:T_avg:value_STDDEV": [ [ 3.596531072929624e-06, - 32.224001362690075, - 45.38469354498731, - 52.04377791815543, - 55.53057128319956 + 30.380993204535383, + 43.72146846461898, + 50.74935842638249, + 54.56353720917991 ], [ [ 3.596531072929624e-06, - 21.510793625402826, - 29.939352219053262, - 33.89971713625179, - 35.73264905596605 + 21.140970851889726, + 29.85476758083796, + 33.85173647571717, + 35.81792183571536 ], [ 3.596531072929624e-06, - 37.72722063042233, - 52.85120781046609, - 60.6283771463951, - 64.78429485236896 + 35.226411758567316, + 51.21827202410676, + 60.064017901207656, + 65.16276440764146 ] ] ], "results_results:acc:q_left:value_MEAN": [ [ 0.0, - 334.40543158919024, - 213.5602253723395, - 188.28916247883237, - 179.57502824720748 + 337.1694559544137, + 217.29501824469918, + 192.72292482067377, + 184.38995338600853 ], [ [ 0.0, - 297.3941153023196, - 179.94689229715306, - 150.89629887186578, - 138.96130933930553 + 293.7883234460836, + 178.70999978143385, + 150.85472637344134, + 139.74476690592087 ], [ 0.0, - 372.44672734916776, - 249.11859323607572, - 228.4775115459579, - 223.43024101745672 + 377.9934333250308, + 256.14121413926625, + 236.08485284177823, + 231.0270638692204 ] ] ], "results_results:acc:q_left:value_STDDEV": [ [ 0.0, - 75.04240984242925, - 69.38843707939813, - 78.01121496824891, - 84.7510259100363 + 86.11239740959846, + 78.77093005846885, + 86.49404693943802, + 92.60149587444442 ], [ [ 0.0, - 52.51930696125128, - 47.66355322576302, - 51.49237463253648, - 54.29352893810827 + 57.07704677324272, + 57.02655649822905, + 62.537159354319506, + 65.72934106854788 ], [ 0.0, - 86.1515114864844, - 79.06065151304021, - 89.55642939997962, - 98.00828658688752 + 100.4101826703486, + 88.9472178838479, + 97.1791390699771, + 104.49447867866519 ] ] ] @@ -139,4 +139,4 @@ "time_step": 2 } ] -} +} \ No newline at end of file diff --git a/modules/stochastic_tools/examples/parameter_study/nonlin_diff_react/gold/nonlin_diff_react_parent_normal_out_results_0002.csv b/modules/stochastic_tools/examples/parameter_study/nonlin_diff_react/gold/nonlin_diff_react_parent_normal_out_results_0002.csv index 4ff65413ca11..6259b181fddc 100644 --- a/modules/stochastic_tools/examples/parameter_study/nonlin_diff_react/gold/nonlin_diff_react_parent_normal_out_results_0002.csv +++ b/modules/stochastic_tools/examples/parameter_study/nonlin_diff_react/gold/nonlin_diff_react_parent_normal_out_results_0002.csv @@ -1,6 +1,6 @@ results:average,results:max,results:min --0.15192528466265,0.75145111880863,-1.2979446079505 --0.089445661692043,0.93626262632326,-1.2518171888509 --0.10638867604805,0.88646377923102,-1.2644460852191 --0.17513170712151,0.67877499895057,-1.314859197077 --0.1256751683602,0.83027682690795,-1.2786779016283 +-0.10536354906177,0.88987429552845,-1.2636687033743 +-0.17115334299873,0.689262725342,-1.3119784234645 +-0.093027383238454,0.92669348317043,-1.2544397917645 +-0.13873115145842,0.79073056851906,-1.2883017136964 +-0.13723896578736,0.7957236325072,-1.2871870647815 diff --git a/modules/stochastic_tools/examples/parameter_study/nonlin_diff_react/gold/nonlin_diff_react_parent_uniform_out_results_0002.csv b/modules/stochastic_tools/examples/parameter_study/nonlin_diff_react/gold/nonlin_diff_react_parent_uniform_out_results_0002.csv index a882fea32182..3baa20abc037 100644 --- a/modules/stochastic_tools/examples/parameter_study/nonlin_diff_react/gold/nonlin_diff_react_parent_uniform_out_results_0002.csv +++ b/modules/stochastic_tools/examples/parameter_study/nonlin_diff_react/gold/nonlin_diff_react_parent_uniform_out_results_0002.csv @@ -1,6 +1,6 @@ results:average,results:max,results:min --0.16041900630108,0.72574860704158,-1.3041376889883 --0.07641624627612,0.97396678526076,-1.2420552065958 --0.095185041230854,0.91930444188541,-1.2561117155132 --0.17155152769109,0.68974160651019,-1.3122663496191 --0.12378715182171,0.83625982605204,-1.2772667270986 +-0.094088605567233,0.92301737830194,-1.2552691829219 +-0.16408697458784,0.71058310503675,-1.3068498461091 +-0.082781681881638,0.95667825523881,-1.2467490661088 +-0.14447266361239,0.77362218163277,-1.2925052672106 +-0.14116995416963,0.7841409816444,-1.2900623430775 diff --git a/modules/stochastic_tools/examples/sobol/gold/main_out.json b/modules/stochastic_tools/examples/sobol/gold/main_out.json index 7895b5e26eb4..48bc5cefddd4 100644 --- a/modules/stochastic_tools/examples/sobol/gold/main_out.json +++ b/modules/stochastic_tools/examples/sobol/gold/main_out.json @@ -40,11 +40,11 @@ "values": { "results_results:T_avg:value_MEAN": { "stat": "MEAN", - "type": "std::pair >" + "type": "std::pair>" }, "results_results:q_left:value_MEAN": { "stat": "MEAN", - "type": "std::pair >" + "type": "std::pair>" } } } @@ -55,127 +55,127 @@ "results_results:T_avg:value": { "FIRST_ORDER": [ [ - 0.7079682315460529, - 0.022003810752935962, - 0.06629141722528406, - 0.12306349437144783 + 2.1263340395510633, + -0.1704186766506682, + 0.8910628142531882, + 1.3282033876672334 ], [ [ - -2.778576837390401, - -0.0923840362252813, - -0.33953641462917444, - -0.6272646085746221 + -1.9245992759047956, + -0.14744423678401847, + -0.7405474538071208, + -1.0243646808232845 ], [ - 3.1575055384065687, - 0.10810117542142149, - 0.44730763561354525, - 0.7136139871038889 + 1.6905363618407854, + 0.1450721789342176, + 0.7404629509699922, + 1.0489650198653504 ] ] ], "SECOND_ORDER": [ [ [ - 0.7079682315460529, - 5.3391885740933, - 2.213176168087708, - 3.2444306898982767 + 2.1263340395510633, + -1.5858228336921647, + -2.3644853561144674, + -2.579482734445585 ], [ - 5.3391885740933, - 0.022003810752935962, - 0.10021434300595027, - 0.03146757769484784 + -1.5858228336921647, + -0.1704186766506682, + -0.4523042536164599, + -0.367641436024306 ], [ - 2.213176168087708, - 0.10021434300595027, - 0.06629141722528406, - 0.011329509079781405 + -2.3644853561144674, + -0.4523042536164599, + 0.8910628142531882, + -1.5711186359853193 ], [ - 3.2444306898982767, - 0.03146757769484784, - 0.011329509079781405, - 0.12306349437144783 + -2.579482734445585, + -0.367641436024306, + -1.5711186359853193, + 1.3282033876672334 ] ], [ [ [ - -2.778576837390401, - -6.454549229380251, - -8.013830000296329, - -8.121033794023335 + -1.9245992759047956, + -2.4218500787437396, + -3.617008106448411, + -5.862519943209779 ], [ - -6.454549229380251, - -0.0923840362252813, - -0.8743948178853919, - -1.1316087615874393 + -2.4218500787437396, + -0.14744423678401847, + -0.832270330827527, + -2.8610595323068497 ], [ - -8.013830000296329, - -0.8743948178853919, - -0.33953641462917444, - -1.6300124540179968 + -3.617008106448411, + -0.832270330827527, + -0.7405474538071208, + -3.5757491943596618 ], [ - -8.121033794023335, - -1.1316087615874393, - -1.6300124540179968, - -0.6272646085746221 + -5.862519943209779, + -2.8610595323068497, + -3.5757491943596618, + -1.0243646808232845 ] ], [ [ - 3.1575055384065687, - 6.594936922311948, - 8.192699613090781, - 8.316284425832205 + 1.6905363618407854, + 3.1470133995628062, + 4.514567212267766, + 6.89107489125814 ], [ - 6.594936922311948, - 0.10810117542142149, - 0.9183264421363888, - 1.2152704067270645 + 3.1470133995628062, + 0.1450721789342176, + 1.0571317999622678, + 4.298526262974558 ], [ - 8.192699613090781, - 0.9183264421363888, - 0.44730763561354525, - 1.8568944936372327 + 4.514567212267766, + 1.0571317999622678, + 0.7404629509699922, + 4.456668649214556 ], [ - 8.316284425832205, - 1.2152704067270645, - 1.8568944936372327, - 0.7136139871038889 + 6.89107489125814, + 4.298526262974558, + 4.456668649214556, + 1.0489650198653504 ] ] ] ], "TOTAL": [ [ - 0.7170011239748011, - -0.23410520806105195, - 0.014050245820542373, - -0.06683002867472965 + 0.6716920085825218, + 0.42122423634195616, + 0.3537665831825715, + 0.7240444008318918 ], [ [ - 0.049115893640706565, - -2.240148385235004, - -1.5694929791243908, - -1.7111043447276533 + -0.418787576163522, + -1.0914201016146587, + -1.461531958201411, + -0.05300938717236381 ], [ - 1.8641209326473396, - 3.9534370745538534, - 3.4019193072456204, - 3.585576242089134 + 2.34661879291093, + 2.6160736708372916, + 3.0599292054684, + 1.7735775267008993 ] ] ] @@ -183,127 +183,127 @@ "results_results:q_left:value": { "FIRST_ORDER": [ [ - 0.7389200088104518, - 0.020349594867369668, - 0.22549127987918816, - 0.025694489604817107 + 1.8235469621932516, + 0.06461083007807501, + 0.49024479333618587, + 0.019712160157117343 ], [ [ - -4.091739873702765, - -0.16637293825878882, - -1.3830155445581565, - -0.21054326591717482 + -4.271886175566092, + -0.21358955122248832, + -1.1140788037385907, + -0.13405082544978414 ], [ - 3.947523492747353, - 0.1665429587899574, - 1.3267423877123623, - 0.19340501736478963 + 3.742866431612808, + 0.2143580106124228, + 1.044098143434037, + 0.11379671226869181 ] ] ], "SECOND_ORDER": [ [ [ - 0.7389200088104518, - 1.1482851633655828, - 1.3355470568848986, - 1.0958597073025564 + 1.8235469621932516, + -1.3905505375487972, + -1.468198101809389, + -1.375093249672925 ], [ - 1.1482851633655828, - 0.020349594867369668, - -0.08344803820392069, - -0.04418713548380046 + -1.3905505375487972, + 0.06461083007807501, + -0.12126951652702196, + -0.047038385516822184 ], [ - 1.3355470568848986, - -0.08344803820392069, - 0.22549127987918816, - -0.1269011054809108 + -1.468198101809389, + -0.12126951652702196, + 0.49024479333618587, + -0.2655312466346423 ], [ - 1.0958597073025564, - -0.04418713548380046, - -0.1269011054809108, - 0.025694489604817107 + -1.375093249672925, + -0.047038385516822184, + -0.2655312466346423, + 0.019712160157117343 ] ], [ [ [ - -4.091739873702765, - -9.139881163051552, - -11.458210899796187, - -8.682853541799657 + -4.271886175566092, + -5.304910750107738, + -7.760475751994446, + -5.214012530917785 ], [ - -9.139881163051552, - -0.16637293825878882, - -1.656948876741212, - -0.3918542256440673 + -5.304910750107738, + -0.21358955122248832, + -2.249348007191563, + -0.39487323449307704 ], [ - -11.458210899796187, - -1.656948876741212, - -1.3830155445581565, - -1.6848825449903648 + -7.760475751994446, + -2.249348007191563, + -1.1140788037385907, + -1.8734667070660467 ], [ - -8.682853541799657, - -0.3918542256440673, - -1.6848825449903648, - -0.21054326591717482 + -5.214012530917785, + -0.39487323449307704, + -1.8734667070660467, + -0.13405082544978414 ] ], [ [ - 3.947523492747353, - 9.818740534575209, - 11.68784380386844, - 9.752682930726047 + 3.742866431612808, + 6.469542112008098, + 8.967736860567939, + 6.0827138324513825 ], [ - 9.818740534575209, - 0.1665429587899574, - 2.1155879208584008, - 0.5543252646398215 + 6.469542112008098, + 0.2143580106124228, + 3.3271039032372682, + 0.5153962553256152 ], [ - 11.68784380386844, - 2.1155879208584008, - 1.3267423877123623, - 2.119622204584661 + 8.967736860567939, + 3.3271039032372682, + 1.044098143434037, + 2.0634135974545433 ], [ - 9.752682930726047, - 0.5543252646398215, - 2.119622204584661, - 0.19340501736478963 + 6.0827138324513825, + 0.5153962553256152, + 2.0634135974545433, + 0.11379671226869181 ] ] ] ], "TOTAL": [ [ - 0.7167820377142026, - -0.06820553511007565, - 0.28209547467004326, - -0.027625629805629437 + 0.8361004068731036, + 0.3945056560029335, + 0.346048550986653, + 0.45400871228396333 ], [ [ - -0.8931482758355531, - -5.2654851300237615, - -3.2439900542445317, - -5.111217986149409 + 0.05818944660486691, + -1.878159764251841, + -2.3161866666666224, + -1.3652499049416096 ], [ - 2.5115384112506294, - 7.2346296356909665, - 4.793000313371506, - 6.889820155566966 + 1.7554390551839805, + 3.5022906001104546, + 3.853777814700177, + 2.8919833475141856 ] ] ] @@ -311,17 +311,17 @@ }, "stats": { "results_results:T_avg:value_MEAN": [ - 197.08718601660595, + 202.8201819567622, [ - 188.41345732966371, - 205.97591428995048 + 194.29058053592289, + 211.62739771551531 ] ], "results_results:q_left:value_MEAN": [ - 174.12450852747952, + 182.62967983344282, [ - 161.95826742103895, - 186.5833699460805 + 169.07983812958125, + 196.41814128692013 ] ] }, @@ -329,4 +329,4 @@ "time_step": 2 } ] -} +} \ No newline at end of file diff --git a/modules/stochastic_tools/examples/surrogates/combined/trans_diff_2d/gold/trans_diff_main_out_results_0001.csv b/modules/stochastic_tools/examples/surrogates/combined/trans_diff_2d/gold/trans_diff_main_out_results_0001.csv index 5189647830f5..a59496449163 100644 --- a/modules/stochastic_tools/examples/surrogates/combined/trans_diff_2d/gold/trans_diff_main_out_results_0001.csv +++ b/modules/stochastic_tools/examples/surrogates/combined/trans_diff_2d/gold/trans_diff_main_out_results_0001.csv @@ -1,4 +1,4 @@ results:time_max,results:time_min -313.64132476678,304.54090373858 -334.51750052134,323.90898742192 -292.7023996007,284.55981664608 +325.99298186937,317.13412721752 +288.73838158236,280.53906825679 +306.86416626438,296.50629659072 diff --git a/modules/stochastic_tools/examples/surrogates/combined/trans_diff_2d/gold/trans_diff_surr_out_eval_surr_0001.csv b/modules/stochastic_tools/examples/surrogates/combined/trans_diff_2d/gold/trans_diff_surr_out_eval_surr_0001.csv index 0bd992021ac1..ec0e6f5cef33 100644 --- a/modules/stochastic_tools/examples/surrogates/combined/trans_diff_2d/gold/trans_diff_surr_out_eval_surr_0001.csv +++ b/modules/stochastic_tools/examples/surrogates/combined/trans_diff_2d/gold/trans_diff_surr_out_eval_surr_0001.csv @@ -1,11 +1,11 @@ np_max,np_min,pc_max,pc_min,pr_max,pr_min -290.01939959246,282.08466465288,308.73043626971,299.2572258351,287.58763512713,280.00354739104 -290.2496658815,282.02560119329,308.73043626971,299.2572258351,305.25509512257,297.10788451446 -327.47207167101,316.4214389359,308.73043626971,299.2572258351,325.14016758298,313.67344564478 -292.38993481042,281.8939353405,308.73043626971,299.2572258351,284.9382220514,273.70707341911 -324.99671688621,316.64018189049,308.73043626971,299.2572258351,330.8897225994,323.22637656949 -290.2496658815,282.02560119329,308.73043626971,299.2572258351,294.76897568764,285.70394573242 -327.47207167101,316.4214389359,308.73043626971,299.2572258351,314.32559922932,303.43167428653 -327.21883415639,316.48672773958,308.73043626971,299.2572258351,333.90210880589,324.09058655203 -327.21883415639,316.48672773958,308.73043626971,299.2572258351,318.88765872339,309.14097899645 -290.01939959246,282.08466465288,308.73043626971,299.2572258351,298.66409532721,289.31250345397 +327.21832201458,316.4862375654,308.73043683765,299.25722574663,311.07594954464,301.61328428805 +324.9962432048,316.63968885546,308.73043683765,299.25722574663,318.15186124348,308.56990663661 +292.39041261723,281.89442740611,308.73043683765,299.25722574663,293.96699026144,283.40834530545 +327.47155537994,316.42094983328,308.73043683765,299.25722574663,339.81284729332,328.2144275379 +290.01991601117,282.08515385682,308.73043683765,299.25722574663,285.12136726292,276.85670578545 +292.39041261723,281.89442740611,308.73043683765,299.25722574663,283.72793747803,273.43503536906 +290.25017843565,282.0260913867,308.73043683765,299.25722574663,297.19858337354,288.36711259122 +290.01991601117,282.08515385682,308.73043683765,299.25722574663,301.91068801082,293.96021215184 +324.9962432048,316.63968885546,308.73043683765,299.25722574663,325.15199016901,317.45192930834 +327.47155537994,316.42094983328,308.73043683765,299.25722574663,322.87002243524,312.35395486791 diff --git a/modules/stochastic_tools/examples/surrogates/cross_validation/gold/all_trainers_no_libtorch.json b/modules/stochastic_tools/examples/surrogates/cross_validation/gold/all_trainers_no_libtorch.json index 5c4cc6938b6d..3bc2a1a5bc29 100644 --- a/modules/stochastic_tools/examples/surrogates/cross_validation/gold/all_trainers_no_libtorch.json +++ b/modules/stochastic_tools/examples/surrogates/cross_validation/gold/all_trainers_no_libtorch.json @@ -23,30 +23,30 @@ "cv_scores": { "gp_surr": [ [ - 3.2275356930183645, - 6.9382000235754955, - 4.1269430459878835 + 2.9008254067550547, + 3.3214224765207, + 4.872343047673496 ] ], "np_surr": [ [ - 8.083719028320633, - 9.333672231216491, - 7.84142570247793 + 7.354381697450355, + 6.213144835306278, + 7.6440625444211845 ] ], "pc_surr": [ [ - 6.5194195639693016, - 9.725551205840329, - 7.54828644359101 + 6.6266228390674815, + 5.822613571227318, + 5.71841572666498 ] ], "pr_surr": [ [ - 3.922759001887131, - 2.827357814384898, - 1.9876099641604004 + 1.0170231353493102, + 1.0455883554267056, + 2.613372316437882 ] ] }, @@ -54,4 +54,4 @@ "time_step": 2 } ] -} +} \ No newline at end of file diff --git a/modules/stochastic_tools/examples/surrogates/cross_validation/gold/all_trainers_uniform_cv_out.json b/modules/stochastic_tools/examples/surrogates/cross_validation/gold/all_trainers_uniform_cv_out.json index a6aff6a9de25..0d64325ded65 100644 --- a/modules/stochastic_tools/examples/surrogates/cross_validation/gold/all_trainers_uniform_cv_out.json +++ b/modules/stochastic_tools/examples/surrogates/cross_validation/gold/all_trainers_uniform_cv_out.json @@ -26,37 +26,37 @@ "cv_scores": { "ann_surr": [ [ - 68.53775441538957, - 34.1827314211616, - 17.001818132623303 + 67.55734559545816, + 47.25225911013344, + 15.033675438929372 ] ], "gp_surr": [ [ - 3.2275356930183645, - 6.9382000235754955, - 4.1269430459878835 + 2.9008254067550547, + 3.3214224765207, + 4.872343047673496 ] ], "np_surr": [ [ - 8.083719028320633, - 9.333672231216491, - 7.84142570247793 + 7.354381697450355, + 6.213144835306278, + 7.6440625444211845 ] ], "pc_surr": [ [ - 6.5194195639693016, - 9.725551205840329, - 7.54828644359101 + 6.6266228390674815, + 5.822613571227318, + 5.71841572666498 ] ], "pr_surr": [ [ - 3.922759001887131, - 2.827357814384898, - 1.9876099641604004 + 1.0170231353493102, + 1.0455883554267056, + 2.613372316437882 ] ] }, @@ -64,4 +64,4 @@ "time_step": 2 } ] -} +} \ No newline at end of file diff --git a/modules/stochastic_tools/examples/surrogates/pod_rb/2d_multireg/gold/surr_out_res_0001.csv b/modules/stochastic_tools/examples/surrogates/pod_rb/2d_multireg/gold/surr_out_res_0001.csv index 86149474def9..dbce6c5e4586 100644 --- a/modules/stochastic_tools/examples/surrogates/pod_rb/2d_multireg/gold/surr_out_res_0001.csv +++ b/modules/stochastic_tools/examples/surrogates/pod_rb/2d_multireg/gold/surr_out_res_0001.csv @@ -1,3 +1,3 @@ rbpod:nodal_l2 -1697.52288241 -1558.8595174074 +932.24511956938 +1693.0041194597 diff --git a/modules/stochastic_tools/examples/surrogates/polynomial_regression/gold/normal_surr_out.json b/modules/stochastic_tools/examples/surrogates/polynomial_regression/gold/normal_surr_out.json index afe2093a09b0..58b62435efac 100644 --- a/modules/stochastic_tools/examples/surrogates/polynomial_regression/gold/normal_surr_out.json +++ b/modules/stochastic_tools/examples/surrogates/polynomial_regression/gold/normal_surr_out.json @@ -15,11 +15,11 @@ "values": { "pc_max_MEAN": { "stat": "MEAN", - "type": "std::pair >" + "type": "std::pair>" }, "pc_max_STDDEV": { "stat": "STDDEV", - "type": "std::pair >" + "type": "std::pair>" } } }, @@ -38,11 +38,11 @@ "values": { "pr_max_res_pr_max_MEAN": { "stat": "MEAN", - "type": "std::pair >" + "type": "std::pair>" }, "pr_max_res_pr_max_STDDEV": { "stat": "STDDEV", - "type": "std::pair >" + "type": "std::pair>" } } } @@ -51,16 +51,16 @@ { "pc_max_res": { "pc_max": [ - 301.1904762681637, - 301.1904762681637, - 301.1904762681637, - 301.1904762681637, - 301.1904762681637 + 301.1904761905, + 301.1904761905, + 301.1904761905, + 301.1904761905, + 301.1904761905 ] }, "pc_max_stats": { "pc_max_MEAN": [ - 301.1904762681637, + 301.1904761905, [] ], "pc_max_STDDEV": [ @@ -70,20 +70,20 @@ }, "pr_max_res": { "pr_max": [ - 293.68332732478854, - 302.8881519543555, - 306.34870043778216, - 313.9057274853894, - 290.86164495690565 + 303.1825068637954, + 282.5439011131811, + 319.856484383075, + 307.51939261606714, + 294.34829075083894 ] }, "pr_max_stats": { "pr_max_res_pr_max_MEAN": [ - 301.5375104318442, + 301.49011514539154, [] ], "pr_max_res_pr_max_STDDEV": [ - 9.40221876470318, + 14.022344466590578, [] ] }, @@ -91,4 +91,4 @@ "time_step": 1 } ] -} +} \ No newline at end of file diff --git a/modules/stochastic_tools/examples/surrogates/polynomial_regression/gold/uniform_surr_out.json b/modules/stochastic_tools/examples/surrogates/polynomial_regression/gold/uniform_surr_out.json index c44f13870ad7..5ab16b0d0b30 100644 --- a/modules/stochastic_tools/examples/surrogates/polynomial_regression/gold/uniform_surr_out.json +++ b/modules/stochastic_tools/examples/surrogates/polynomial_regression/gold/uniform_surr_out.json @@ -15,11 +15,11 @@ "values": { "pc_max_MEAN": { "stat": "MEAN", - "type": "std::pair >" + "type": "std::pair>" }, "pc_max_STDDEV": { "stat": "STDDEV", - "type": "std::pair >" + "type": "std::pair>" } } }, @@ -38,11 +38,11 @@ "values": { "pr_max_res_pr_max_MEAN": { "stat": "MEAN", - "type": "std::pair >" + "type": "std::pair>" }, "pr_max_res_pr_max_STDDEV": { "stat": "STDDEV", - "type": "std::pair >" + "type": "std::pair>" } } } @@ -51,16 +51,16 @@ { "pc_max_res": { "pc_max": [ - 301.20921978639444, - 301.20921978639444, - 301.20921978639444, - 301.20921978639444, - 301.20921978639444 + 301.2092198581574, + 301.2092198581574, + 301.2092198581574, + 301.2092198581574, + 301.2092198581574 ] }, "pc_max_stats": { "pc_max_MEAN": [ - 301.20921978639444, + 301.2092198581574, [] ], "pc_max_STDDEV": [ @@ -70,20 +70,20 @@ }, "pr_max_res": { "pr_max": [ - 295.71995044516314, - 303.9902317244653, - 304.7564391965112, - 310.3367526430951, - 294.9091916038445 + 303.12031604074934, + 294.0537036919613, + 309.8446537660086, + 306.08421546139243, + 295.87186490136196 ] }, "pr_max_stats": { "pr_max_res_pr_max_MEAN": [ - 301.9425131226158, + 301.7949507722947, [] ], "pr_max_res_pr_max_STDDEV": [ - 6.5338060579219945, + 6.707494978533452, [] ] }, @@ -91,4 +91,4 @@ "time_step": 1 } ] -} +} \ No newline at end of file diff --git a/modules/stochastic_tools/include/samplers/ActiveLearningMonteCarloSampler.h b/modules/stochastic_tools/include/samplers/ActiveLearningMonteCarloSampler.h index 8a16cb08ab83..ff0762c5f6f9 100644 --- a/modules/stochastic_tools/include/samplers/ActiveLearningMonteCarloSampler.h +++ b/modules/stochastic_tools/include/samplers/ActiveLearningMonteCarloSampler.h @@ -27,8 +27,8 @@ class ActiveLearningMonteCarloSampler : public Sampler virtual bool isAdaptiveSamplingCompleted() const override { return _is_sampling_completed; } protected: - /// Gather all the samples - virtual void sampleSetUp(const Sampler::SampleMode mode) override; + /// Gather all the samples once per timestep + virtual void executeSetUp() override; /// Return the sample for the given row and column virtual Real computeSample(dof_id_type row_index, dof_id_type col_index) override; @@ -48,9 +48,6 @@ class ActiveLearningMonteCarloSampler : public Sampler /// The maximum number of GP fails const unsigned int _num_batch; - /// Ensure that the sampler proceeds in a sequential fashion - int _check_step; - /// Number of samples requested const int & _num_samples; diff --git a/modules/stochastic_tools/include/samplers/AdaptiveImportanceSampler.h b/modules/stochastic_tools/include/samplers/AdaptiveImportanceSampler.h index b7d09570898c..f8e16955863e 100644 --- a/modules/stochastic_tools/include/samplers/AdaptiveImportanceSampler.h +++ b/modules/stochastic_tools/include/samplers/AdaptiveImportanceSampler.h @@ -52,6 +52,7 @@ class AdaptiveImportanceSampler : public Sampler, public TransientInterface virtual bool isAdaptiveSamplingCompleted() const override { return _is_sampling_completed; } protected: + virtual void executeSetUp() override; /// Return the sample for the given row (the sample index) and column (the parameter index) virtual Real computeSample(dof_id_type row_index, dof_id_type col_index) override; @@ -89,9 +90,6 @@ class AdaptiveImportanceSampler : public Sampler, public TransientInterface /// Storage for the inputs vector obtained from the reporter const std::vector> & _inputs; - /// Ensure that the MCMC algorithm proceeds in a sequential fashion - int _check_step; - /// For proposing the next sample in the MCMC algorithm std::vector _prev_value; diff --git a/modules/stochastic_tools/include/samplers/AffineInvariantDES.h b/modules/stochastic_tools/include/samplers/AffineInvariantDES.h index b6d415def76b..4beb55ea2e4b 100644 --- a/modules/stochastic_tools/include/samplers/AffineInvariantDES.h +++ b/modules/stochastic_tools/include/samplers/AffineInvariantDES.h @@ -24,7 +24,7 @@ class AffineInvariantDES : public PMCMCBase virtual int decisionStep() const override { return 2; } protected: - virtual void proposeSamples(const unsigned int seed_value) override; + virtual void proposeSamples() override; /** * Compute the differential evolution from the current state diff --git a/modules/stochastic_tools/include/samplers/AffineInvariantStretchSampler.h b/modules/stochastic_tools/include/samplers/AffineInvariantStretchSampler.h index 447344bf9859..40e4fac5e5c7 100644 --- a/modules/stochastic_tools/include/samplers/AffineInvariantStretchSampler.h +++ b/modules/stochastic_tools/include/samplers/AffineInvariantStretchSampler.h @@ -29,7 +29,7 @@ class AffineInvariantStretchSampler : public PMCMCBase const std::vector & getAffineStepSize() const; protected: - virtual void proposeSamples(const unsigned int seed_value) override; + virtual void proposeSamples() override; /// The step size for the stretch sampler const Real _step_size; diff --git a/modules/stochastic_tools/include/samplers/BayesianActiveLearningSampler.h b/modules/stochastic_tools/include/samplers/BayesianActiveLearningSampler.h index 86db83f6e503..44677d274729 100644 --- a/modules/stochastic_tools/include/samplers/BayesianActiveLearningSampler.h +++ b/modules/stochastic_tools/include/samplers/BayesianActiveLearningSampler.h @@ -34,14 +34,7 @@ class BayesianActiveLearningSampler : public PMCMCBase const std::vector & getVarSampleTries() const; protected: - virtual void proposeSamples(const unsigned int seed_value) override; - - /** - * Fill in the provided vector with random samples given the distributions - * @param vector The vector to be filled - * @param seed_value The seed value to generate random numbers - */ - virtual void fillVector(std::vector & vector, const unsigned int & seed_value); + virtual void proposeSamples() override; /// The selected sample indices to evaluate the subApp const std::vector & _sorted_indices; diff --git a/modules/stochastic_tools/include/samplers/GenericActiveLearningSampler.h b/modules/stochastic_tools/include/samplers/GenericActiveLearningSampler.h index fa9b0a38e78c..f91b9ec3d59b 100644 --- a/modules/stochastic_tools/include/samplers/GenericActiveLearningSampler.h +++ b/modules/stochastic_tools/include/samplers/GenericActiveLearningSampler.h @@ -35,17 +35,10 @@ class GenericActiveLearningSampler : public Sampler, public TransientInterface protected: /// Gather all the samples - virtual void sampleSetUp(const Sampler::SampleMode mode) override; + virtual void executeSetUp() override; /// Return the sample for the given row and column virtual Real computeSample(dof_id_type row_index, dof_id_type col_index) override; - /** - * Fill in the provided vector with random samples given the distributions - * @param vector The vector to be filled - * @param seed_value The seed value to generate random numbers - */ - virtual void fillVector(std::vector & vector, const unsigned int & seed_value); - /// Storage for distribution objects to be utilized std::vector _distributions; @@ -55,9 +48,6 @@ class GenericActiveLearningSampler : public Sampler, public TransientInterface /// The selected sample indices to evaluate the subApp const std::vector & _sorted_indices; - /// Ensure that the algorithm proceeds in a sequential fashion - int _check_step; - /// Initial values of the input params to get the MCMC scheme started const std::vector & _initial_values; diff --git a/modules/stochastic_tools/include/samplers/IndependentGaussianMH.h b/modules/stochastic_tools/include/samplers/IndependentGaussianMH.h index 77641a07eae7..dc43e75bcf2e 100644 --- a/modules/stochastic_tools/include/samplers/IndependentGaussianMH.h +++ b/modules/stochastic_tools/include/samplers/IndependentGaussianMH.h @@ -24,7 +24,7 @@ class IndependentGaussianMH : public PMCMCBase virtual int decisionStep() const override { return 2; } protected: - virtual void proposeSamples(const unsigned int seed_value) override; + virtual void proposeSamples() override; private: /// Reporter value the seed input values for proposing the next set of samples diff --git a/modules/stochastic_tools/include/samplers/LatinHypercubeSampler.h b/modules/stochastic_tools/include/samplers/LatinHypercubeSampler.h index 5646a0b396de..cba993ff5e35 100644 --- a/modules/stochastic_tools/include/samplers/LatinHypercubeSampler.h +++ b/modules/stochastic_tools/include/samplers/LatinHypercubeSampler.h @@ -11,12 +11,22 @@ #include "Sampler.h" +// Forward declarations +class MooseRandomPerturbation; + /** - * A class used to perform Monte Carlo Sampling + * Implements Latin Hypercube Sampling (LHS) over a set of distributions. + * + * For N samples and K distributions the output matrix has N rows and K columns. + * LHS divides the [0,1] probability axis into N equal-width bins and ensures + * that exactly one sample falls in each bin for every column. Within each bin + * the sample point is drawn uniformly at random, and the bin assignment for + * each column is an independent pseudo-random permutation of [0, N) seeded + * from generator 1 during executeSetUp(). * - * WARNING! This Sampler manages the generators advancement for parallel operation manually. All the - * calls to get random values from the generators occur in sampleSetUp. At the end of - * sampleSetUp all the generators should be in the final state. + * Generator usage: + * - Generator 0: within-bin uniform draws (one per computeSample call). + * - Generator 1: column shuffler seeds (one per column, drawn in executeSetUp). */ class LatinHypercubeSampler : public Sampler { @@ -26,16 +36,28 @@ class LatinHypercubeSampler : public Sampler LatinHypercubeSampler(const InputParameters & parameters); protected: - virtual void sampleSetUp(const Sampler::SampleMode mode) override; + /** + * Constructs one MooseRandomPerturbation per column, each seeded + * independently from generator 1. + */ + virtual void executeTearDown() override; + + /** + * Return the sample value for the given row and column. + * + * Maps \p row_index to a shuffled bin index via the column's permuter, + * draws a uniform random point within that bin, then transforms it through + * the column distribution's quantile function. + * + * @param row_index Global row index in [0, getNumberOfRows()). + * @param col_index Column index in [0, getNumberOfCols()). + * @return A sample drawn from distributions[col_index] respecting + * the LHS bin constraint for this row. + */ virtual Real computeSample(dof_id_type row_index, dof_id_type col_index) override; - /// Storage for distribution objects to be utilized + /// Distribution objects, one per column, whose quantile functions are sampled std::vector _distributions; - -private: - // Probability values for each distribution - std::vector> _probabilities; - - // toggle for local/global data access in computeSample - bool _is_local; + /// Per-column pseudo-random permuters that enforce the LHS bin assignment + std::vector> _shufflers; }; diff --git a/modules/stochastic_tools/include/samplers/MorrisSampler.h b/modules/stochastic_tools/include/samplers/MorrisSampler.h index c74e30932e7d..7706d7dabbb1 100644 --- a/modules/stochastic_tools/include/samplers/MorrisSampler.h +++ b/modules/stochastic_tools/include/samplers/MorrisSampler.h @@ -25,11 +25,6 @@ class MorrisSampler : public Sampler protected: virtual Real computeSample(dof_id_type row_index, dof_id_type col_index) override; - /** - * Used to setup matrices for trajectory computation - */ - virtual void sampleSetUp(const Sampler::SampleMode mode) override; - /** * Morris sampling should have a slightly different partitioning in order to keep * the sample and resample samplers distributed and make computing indices more @@ -51,8 +46,11 @@ class MorrisSampler : public Sampler */ void updateBstar(); + /// The trajectory the current _bstar represents + dof_id_type _curr_trajectory = std::numeric_limits::max(); + ///@{ - /// Matrices used for trajector computation + /// Matrices used for trajectory computation RealEigenMatrix _b; RealEigenMatrix _pstar; RealEigenMatrix _j; diff --git a/modules/stochastic_tools/include/samplers/NestedMonteCarloSampler.h b/modules/stochastic_tools/include/samplers/NestedMonteCarloSampler.h index 082c0487c7f3..d0f84a01e818 100644 --- a/modules/stochastic_tools/include/samplers/NestedMonteCarloSampler.h +++ b/modules/stochastic_tools/include/samplers/NestedMonteCarloSampler.h @@ -25,16 +25,9 @@ class NestedMonteCarloSampler : public Sampler /// Return the sample for the given row and column virtual Real computeSample(dof_id_type row_index, dof_id_type col_index) override; - /// Here we need to precompute rows that might not be assigned to this processor - virtual void sampleSetUp(const SampleMode mode) override; - /// Storage for distribution objects to be utilized std::vector _distributions; - /// The loop index for distribution - std::vector _loop_index; - /// Helper for determining if a set of columns need to be recomputed: - /// if (row_index % _loop_mod[_loop_index[col_index]] == 0) - std::vector _loop_mod; - /// Storage for row data (to be used when not recomputing a column) - std::vector _row_data; + /// Helper for determining the target row for the given column index: + /// target_row = std::floor(row_index / _col_mod[col_index]) * _col_mod[col_index] + std::vector _col_mod; }; diff --git a/modules/stochastic_tools/include/samplers/PMCMCBase.h b/modules/stochastic_tools/include/samplers/PMCMCBase.h index 26193429df35..e9cc89737f13 100644 --- a/modules/stochastic_tools/include/samplers/PMCMCBase.h +++ b/modules/stochastic_tools/include/samplers/PMCMCBase.h @@ -77,39 +77,36 @@ class PMCMCBase : public Sampler, public TransientInterface * Fill in the _new_samples vector of vectors (happens within sampleSetUp) * @param seed_value The seed for the random number generator */ - virtual void proposeSamples(const unsigned int seed_value); + virtual void proposeSamples(); // See Sampler.h for description - virtual void sampleSetUp(const Sampler::SampleMode mode) override; + virtual void executeSetUp() override; // See Sampler.h for description virtual Real computeSample(dof_id_type row_index, dof_id_type col_index) override; + /** + * Sample a random number between 0 and 1 + * @param upper_bound The upper bound provided + * @return The required index + */ + Real random(); + /** * Sample a random index excluding a specified index * @param upper_bound The upper bound provided - * @param exclude The index to be excluded from sampling - * @param seed The seed of the random number generator - * @param req_index The required index to be filled + * @return The required index */ - void randomIndex(const unsigned int & upper_bound, - const unsigned int & exclude, - const unsigned int & seed, - unsigned int & req_index); + unsigned int randomIndex(const unsigned int & upper_bound, const unsigned int & exclude); /** * Sample two random indices without repitition excluding a specified index * @param upper_bound The upper bound provided * @param exclude The index to be excluded from sampling - * @param seed The seed of the random number generator - * @param req_index1 The required index 1 to be filled - * @param req_index2 The required index 2 to be filled + * @return Pair of required indices */ - void randomIndexPair(const unsigned int & upper_bound, - const unsigned int & exclude, - const unsigned int & seed, - unsigned int & req_index1, - unsigned int & req_index2); + std::pair randomIndexPair(const unsigned int & upper_bound, + const unsigned int & exclude); /// Number of parallel proposals to be made and subApps to be executed const unsigned int _num_parallel_proposals; @@ -129,9 +126,6 @@ class PMCMCBase : public Sampler, public TransientInterface /// Upper bound for variance for making the next proposal const Real & _variance_bound; - /// Ensure that the MCMC algorithm proceeds in a sequential fashion - int _check_step; - /// Initial values of the input params to get the MCMC scheme started const std::vector & _initial_values; @@ -153,6 +147,12 @@ class PMCMCBase : public Sampler, public TransientInterface /// Initialize a certain number of random seeds. Change from the default only if you have to. const unsigned int _num_random_seeds; + /// Generator index when requesting random numbers + unsigned int _seed_index; + + /// Running index for the random number generators + std::size_t _rand_index; + /// Configuration values std::vector> _confg_values; diff --git a/modules/stochastic_tools/include/samplers/ParallelSubsetSimulation.h b/modules/stochastic_tools/include/samplers/ParallelSubsetSimulation.h index 1820c6689b27..a8ccd1e4743e 100644 --- a/modules/stochastic_tools/include/samplers/ParallelSubsetSimulation.h +++ b/modules/stochastic_tools/include/samplers/ParallelSubsetSimulation.h @@ -37,7 +37,7 @@ class ParallelSubsetSimulation : public Sampler virtual bool isAdaptiveSamplingCompleted() const override { return _is_sampling_completed; } protected: - virtual void sampleSetUp(const Sampler::SampleMode mode) override; + virtual void executeSetUp() override; virtual Real computeSample(dof_id_type row_index, dof_id_type col_index) override; /// Number of samples per subset @@ -67,9 +67,6 @@ class ParallelSubsetSimulation : public Sampler /// Maximum length of markov chains based on subset probability const unsigned int _count_max; - /// Ensure that the MCMC algorithm proceeds in a sequential fashion - int _check_step; - /// Track the current subset index unsigned int _subset; diff --git a/modules/stochastic_tools/python/moose_stochastic_tools/tests/test_visualize_sobol.py b/modules/stochastic_tools/python/moose_stochastic_tools/tests/test_visualize_sobol.py index d505ed342e3a..68e00c6c641c 100644 --- a/modules/stochastic_tools/python/moose_stochastic_tools/tests/test_visualize_sobol.py +++ b/modules/stochastic_tools/python/moose_stochastic_tools/tests/test_visualize_sobol.py @@ -22,6 +22,9 @@ sys.path.append(_stm_python_path) from moose_stochastic_tools import visualize_sobol, VisualizeSobolOptions +from moose_stochastic_tools.tests.test_visualize_statistics import CI_CELL + +DASH_CELL = r"\s*-\s*" class TestVisualizeSobol(unittest.TestCase): @@ -59,16 +62,16 @@ def makeOptions(self, *args, **kwargs): def testTotalTable(self): opt = self.makeOptions(format=1, output=self._textfile) - expect_out = "| $S_T$ (5.0%, 95.0%) CI | $\\gamma$ | $q_0$ | $T_0$ | $s$ |\n" - expect_out += "|:-------------------------|:---------------------|:----------------------|:--------------------|:----------------------|\n" - expect_out += "| $T_{avg}$ | 0.717 (0.0491, 1.86) | -0.234 (-2.24, 3.95) | 0.0141 (-1.57, 3.4) | -0.0668 (-1.71, 3.59) |\n" - expect_out += "| $q_{left}$ | 0.717 (-0.893, 2.51) | -0.0682 (-5.27, 7.23) | 0.282 (-3.24, 4.79) | -0.0276 (-5.11, 6.89) |\n" + expect_out = rf"""^\| \$S_T\$ \(5\.0%, 95\.0%\) CI\s+\|\s+\$\\gamma\$\s+\|\s+\$q_0\$\s+\|\s+\$T_0\$\s+\|\s+\$s\$\s+\| +\|:?-+\|:?-+\|:?-+\|:?-+\|:?-+\| +\| \$T_{{avg}}\$ \s*\| {CI_CELL} | {CI_CELL} | {CI_CELL} | {CI_CELL} | +\| \$q_{{left}}\$ \s*\| {CI_CELL} | {CI_CELL} | {CI_CELL} | {CI_CELL} |$""" visualize_sobol(opt) self.assertTrue(os.path.exists(self._textfile)) with open(self._textfile) as fid: out = fid.read() - self.assertEqual(out, expect_out[:-1]) + self.assertRegex(out, expect_out) os.remove(self._textfile) def testSecondOrderTable(self): @@ -78,17 +81,17 @@ def testSecondOrderTable(self): values=[self._values[0]], output=self._textfile, ) - expect_out = "| $S_{i,j}$ (5.0%, 95.0%) CI | $\\gamma$ | $q_0$ | $T_0$ | $s$ |\n" - expect_out += "|:-----------------------------|:--------------------|:-----------------------|:----------------------|:----------------------|\n" - expect_out += "| $\\gamma$ | 0.708 (-2.78, 3.16) | - | - | - |\n" - expect_out += "| $q_0$ | 5.34 (-6.45, 6.59) | 0.022 (-0.0924, 0.108) | - | - |\n" - expect_out += "| $T_0$ | 2.21 (-8.01, 8.19) | 0.1 (-0.874, 0.918) | 0.0663 (-0.34, 0.447) | - |\n" - expect_out += "| $s$ | 3.24 (-8.12, 8.32) | 0.0315 (-1.13, 1.22) | 0.0113 (-1.63, 1.86) | 0.123 (-0.627, 0.714) |\n" + expect_out = rf"""^\| \$S_{{i,j}}\$ \(5\.0%, 95\.0%\) CI\s+\|\s+\$\\gamma\$\s+\|\s+\$q_0\$\s+\|\s+\$T_0\$\s+\|\s+\$s\$\s+\| +\|:?-+\|:?-+\|:?-+\|:?-+\|:?-+\| +\| \$\\gamma\$ \s*\| {CI_CELL} | {DASH_CELL} \| {DASH_CELL} \| {DASH_CELL} \| +\| \$q_0\$ \s*\| {CI_CELL} | {CI_CELL} | {DASH_CELL} \| {DASH_CELL} \| +\| \$T_0\$ \s*\| {CI_CELL} | {CI_CELL} | {CI_CELL} | {DASH_CELL} \| +\| \$s\$ \s*\| {CI_CELL} | {CI_CELL} | {CI_CELL} | {CI_CELL} |$""" visualize_sobol(opt) self.assertTrue(os.path.exists(self._textfile)) with open(self._textfile) as fid: out = fid.read() - self.assertEqual(out, expect_out[:-1]) + self.assertRegex(out, expect_out) os.remove(self._textfile) opt = self.makeOptions( @@ -97,17 +100,17 @@ def testSecondOrderTable(self): values=[self._values[1]], output=self._textfile, ) - expect_out = "| $S_{i,j}$ (5.0%, 95.0%) CI | $\\gamma$ | $q_0$ | $T_0$ | $s$ |\n" - expect_out += "|:-----------------------------|:--------------------|:------------------------|:---------------------|:-----------------------|\n" - expect_out += "| $\\gamma$ | 0.739 (-4.09, 3.95) | - | - | - |\n" - expect_out += "| $q_0$ | 1.15 (-9.14, 9.82) | 0.0203 (-0.166, 0.167) | - | - |\n" - expect_out += "| $T_0$ | 1.34 (-11.5, 11.7) | -0.0834 (-1.66, 2.12) | 0.225 (-1.38, 1.33) | - |\n" - expect_out += "| $s$ | 1.1 (-8.68, 9.75) | -0.0442 (-0.392, 0.554) | -0.127 (-1.68, 2.12) | 0.0257 (-0.211, 0.193) |\n" + expect_out = rf"""^\| \$S_{{i,j}}\$ \(5\.0%, 95\.0%\) CI\s+\|\s+\$\\gamma\$\s+\|\s+\$q_0\$\s+\|\s+\$T_0\$\s+\|\s+\$s\$\s+\| +\|:?-+\|:?-+\|:?-+\|:?-+\|:?-+\| +\| \$\\gamma\$ \s*\| {CI_CELL} | {DASH_CELL} \| {DASH_CELL} \| {DASH_CELL} \| +\| \$q_0\$ \s*\| {CI_CELL} | {CI_CELL} | {DASH_CELL} \| {DASH_CELL} \| +\| \$T_0\$ \s*\| {CI_CELL} | {CI_CELL} | {CI_CELL} | {DASH_CELL} \| +\| \$s\$ \s*\| {CI_CELL} | {CI_CELL} | {CI_CELL} | {CI_CELL} |$""" visualize_sobol(opt) self.assertTrue(os.path.exists(self._textfile)) with open(self._textfile) as fid: out = fid.read() - self.assertEqual(out, expect_out[:-1]) + self.assertRegex(out, expect_out) os.remove(self._textfile) def testBarPlot(self): diff --git a/modules/stochastic_tools/python/moose_stochastic_tools/tests/test_visualize_statistics.py b/modules/stochastic_tools/python/moose_stochastic_tools/tests/test_visualize_statistics.py index 380cca29ff6b..d233cc58f910 100644 --- a/modules/stochastic_tools/python/moose_stochastic_tools/tests/test_visualize_statistics.py +++ b/modules/stochastic_tools/python/moose_stochastic_tools/tests/test_visualize_statistics.py @@ -23,6 +23,10 @@ from moose_stochastic_tools import visualize_statistics, VisualizeStatisticsOptions +NUM = r"[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?" +NUM_CELL = rf"\s*{NUM}\s*" +CI_CELL = rf"\s*{NUM}\s+\({NUM},\s*{NUM}\)\s*" + class TestVisualizeStatistics(unittest.TestCase): """ @@ -66,16 +70,16 @@ def testMarkdownTable(self): stat_names=self._stat_names, output=self._textfile, ) - expect_out = "| Values | Mean | Standard Deviation |\n" - expect_out += "|:----------------------------|:---------------------|:---------------------|\n" - expect_out += "| $T_{avg}$ (5.0%, 95.0%) CI | 199.4 (172.4, 227.5) | 55.53 (35.73, 64.78) |\n" - expect_out += "| $q_{left}$ (5.0%, 95.0%) CI | 179.6 (139, 223.4) | 84.75 (54.29, 98.01) |\n" + expect_out = rf"""^\| Values\s+\|\s+Mean\s+\|\s+Standard Deviation\s+\| +\|:?-+\|:?-+\|:?-+\| +\| \$T_{{avg}}\$ \(5\.0%, 95\.0%\) CI\s+\| {CI_CELL} | {CI_CELL} | +\| \$q_{{left}}\$ \(5\.0%, 95\.0%\) CI\s+\| {CI_CELL} | {CI_CELL} |$""" visualize_statistics(opt) self.assertTrue(os.path.exists(self._textfile)) with open(self._textfile) as fid: out = fid.read() - self.assertEqual(out, expect_out[:-1]) + self.assertRegex(out, expect_out) os.remove(self._textfile) # @unittest.skipIf(find_spec('kaleido') is None, "Kaleido must be installed.") @@ -101,23 +105,23 @@ def testTimeTable(self): values=["results_results:T_avg:value", "results_results:q_left:value"], output=self._textfile, ) - expect_out = "| Values | Time | Mean | Standard Deviation |\n" - expect_out += "|:-------------------------------------|-------:|:---------------------|:---------------------|\n" - expect_out += "| Average Temperature (5.0%, 95.0%) CI | 0.25 | 227.6 (211.6, 243.5) | 32.22 (21.51, 37.73) |\n" - expect_out += "| | 0.5 | 209.7 (187.3, 232.4) | 45.38 (29.94, 52.85) |\n" - expect_out += "| | 0.75 | 202.5 (177.1, 228.8) | 52.04 (33.9, 60.63) |\n" - expect_out += "| | 1 | 199.4 (172.4, 227.5) | 55.53 (35.73, 64.78) |\n" - expect_out += "| Flux (5.0%, 95.0%) CI | 0.25 | 334.4 (297.4, 372.4) | 75.04 (52.52, 86.15) |\n" - expect_out += "| | 0.5 | 213.6 (179.9, 249.1) | 69.39 (47.66, 79.06) |\n" - expect_out += "| | 0.75 | 188.3 (150.9, 228.5) | 78.01 (51.49, 89.56) |\n" - expect_out += "| | 1 | 179.6 (139, 223.4) | 84.75 (54.29, 98.01) |\n" + expect_out = rf"""^\| Values\s+\|\s+Time\s+\|\s+Mean\s+\|\s+Standard Deviation\s+\| +\|:?-+\|[-:]+\|:?-+\|:?-+\| +\| Average Temperature \(5\.0%, 95\.0%\) CI\s+\| {NUM_CELL} \| {CI_CELL} | {CI_CELL} | +\| \s*\| {NUM_CELL} \| {CI_CELL} | {CI_CELL} | +\| \s*\| {NUM_CELL} \| {CI_CELL} | {CI_CELL} | +\| \s*\| {NUM_CELL} \| {CI_CELL} | {CI_CELL} | +\| Flux \(5\.0%, 95\.0%\) CI\s+\| {NUM_CELL} \| {CI_CELL} | {CI_CELL} | +\| \s*\| {NUM_CELL} \| {CI_CELL} | {CI_CELL} | +\| \s*\| {NUM_CELL} \| {CI_CELL} | {CI_CELL} | +\| \s*\| {NUM_CELL} \| {CI_CELL} | {CI_CELL} |$""" visualize_statistics(opt) self.assertTrue(os.path.exists(self._textfile)) with open(self._textfile) as fid: out = fid.read() - self.assertEqual(out, expect_out[:-1]) + self.assertRegex(out, expect_out) os.remove(self._textfile) def testTimeTimeLine(self): diff --git a/modules/stochastic_tools/src/multiapps/SamplerFullSolveMultiApp.C b/modules/stochastic_tools/src/multiapps/SamplerFullSolveMultiApp.C index c3ab9f64ea3a..7ed848602e1e 100644 --- a/modules/stochastic_tools/src/multiapps/SamplerFullSolveMultiApp.C +++ b/modules/stochastic_tools/src/multiapps/SamplerFullSolveMultiApp.C @@ -359,6 +359,9 @@ SamplerFullSolveMultiApp::getActiveStochasticToolsTransfers(Transfer::DIRECTION std::vector SamplerFullSolveMultiApp::getCommandLineArgs(const unsigned int local_app) { + if (_mode == StochasticTools::MultiAppMode::BATCH_RESTORE) + return FullSolveMultiApp::getCommandLineArgs(local_app); + std::vector args; // With multiple processors per app, there are no local rows for non-root processors diff --git a/modules/stochastic_tools/src/samplers/ActiveLearningMonteCarloSampler.C b/modules/stochastic_tools/src/samplers/ActiveLearningMonteCarloSampler.C index 494d7ef27727..36fec7037e0f 100644 --- a/modules/stochastic_tools/src/samplers/ActiveLearningMonteCarloSampler.C +++ b/modules/stochastic_tools/src/samplers/ActiveLearningMonteCarloSampler.C @@ -42,7 +42,6 @@ ActiveLearningMonteCarloSampler::ActiveLearningMonteCarloSampler(const InputPara _flag_sample(getReporterValue>("flag_sample")), _step(getCheckedPointerParam("_fe_problem_base")->timeStep()), _num_batch(getParam("num_batch")), - _check_step(std::numeric_limits::min()), _num_samples(getParam("num_samples")) { for (const DistributionName & name : getParam>("distributions")) @@ -51,15 +50,12 @@ ActiveLearningMonteCarloSampler::ActiveLearningMonteCarloSampler(const InputPara setNumberOfCols(_distributions.size()); _inputs_sto.resize(_num_batch, std::vector(_distributions.size())); setNumberOfRandomSeeds(getParam("num_random_seeds")); + setAutoAdvanceGenerators(false); } void -ActiveLearningMonteCarloSampler::sampleSetUp(const Sampler::SampleMode /*mode*/) +ActiveLearningMonteCarloSampler::executeSetUp() { - // If we've already done this step, skip - if (_check_step == _step) - return; - if (_is_sampling_completed) mooseError("Internal bug: the adaptive sampling is supposed to be completed but another sample " "has been requested."); @@ -82,7 +78,8 @@ ActiveLearningMonteCarloSampler::sampleSetUp(const Sampler::SampleMode /*mode*/) { for (dof_id_type i = 0; i < _num_batch; ++i) for (dof_id_type j = 0; j < _distributions.size(); ++j) - _inputs_sto[i][j] = _distributions[j]->quantile(getRand(_step)); + _inputs_sto[i][j] = + _distributions[j]->quantile(getRand(i * _distributions.size() + j, _step)); } // If we do have enough failed inputs, assign them and clear the tracked ones else @@ -91,8 +88,6 @@ ActiveLearningMonteCarloSampler::sampleSetUp(const Sampler::SampleMode /*mode*/) _inputs_gp_fails.erase(_inputs_gp_fails.begin(), _inputs_gp_fails.begin() + _num_batch); } - _check_step = _step; - // check if we have finished the sampling if (_step >= _num_samples + _retraining_steps) _is_sampling_completed = true; diff --git a/modules/stochastic_tools/src/samplers/AdaptiveImportanceSampler.C b/modules/stochastic_tools/src/samplers/AdaptiveImportanceSampler.C index 1d0d7ebd9add..d65c75496b59 100644 --- a/modules/stochastic_tools/src/samplers/AdaptiveImportanceSampler.C +++ b/modules/stochastic_tools/src/samplers/AdaptiveImportanceSampler.C @@ -94,10 +94,6 @@ AdaptiveImportanceSampler::AdaptiveImportanceSampler(const InputParameters & par MCMC algorithm and proposing the next sample.*/ _prev_value.resize(_distributions.size()); - // `check_step` is a member variable for ensuring that the MCMC algorithm proceeds in a sequential - // fashion. - _check_step = 0; - // Storage for means of input values for proposing the next sample _mean_sto.resize(_distributions.size()); @@ -105,12 +101,13 @@ AdaptiveImportanceSampler::AdaptiveImportanceSampler(const InputParameters & par _std_sto.resize(_distributions.size()); setNumberOfRandomSeeds(_num_random_seeds); + setAutoAdvanceGenerators(false); } -Real -AdaptiveImportanceSampler::computeSample(dof_id_type /*row_index*/, dof_id_type col_index) +void +AdaptiveImportanceSampler::executeSetUp() { - const bool sample = _t_step > 1 && col_index == 0 && _check_step != _t_step; + const bool sample = _t_step > 1; const bool gp_flag = _gp_flag ? (*_gp_flag)[0] : false; if (sample && _is_sampling_completed) @@ -133,7 +130,7 @@ AdaptiveImportanceSampler::computeSample(dof_id_type /*row_index*/, dof_id_type for (dof_id_type i = 0; i < _distributions.size(); ++i) acceptance_ratio += std::log(Normal::pdf(_prev_value[i], 0.0, 1.0)) - std::log(Normal::pdf(_inputs_sto[i].back(), 0.0, 1.0)); - if (acceptance_ratio > std::log(getRand(_t_step))) + if (acceptance_ratio > std::log(getRand(0, _t_step))) { for (dof_id_type i = 0; i < _distributions.size(); ++i) _inputs_sto[i].push_back(_prev_value[i]); @@ -145,7 +142,7 @@ AdaptiveImportanceSampler::computeSample(dof_id_type /*row_index*/, dof_id_type } for (dof_id_type i = 0; i < _distributions.size(); ++i) _prev_value[i] = - Normal::quantile(getRand(_t_step), _inputs_sto[i].back(), _proposal_std[i]); + Normal::quantile(getRand(i + 1, _t_step), _inputs_sto[i].back(), _proposal_std[i]); } } else if (sample && !gp_flag) @@ -161,7 +158,7 @@ AdaptiveImportanceSampler::computeSample(dof_id_type /*row_index*/, dof_id_type _std_sto[i] = AdaptiveMonteCarloUtils::computeSTD(_inputs_sto[i], 1); } _prev_value[i] = - (Normal::quantile(getRand(_t_step), _mean_sto[i], _std_factor * _std_sto[i])); + (Normal::quantile(getRand(i, _t_step), _mean_sto[i], _std_factor * _std_sto[i])); } // check if we have performed all the importance sampling steps @@ -174,7 +171,10 @@ AdaptiveImportanceSampler::computeSample(dof_id_type /*row_index*/, dof_id_type // to increase the total number of steps taken. if (sample && gp_flag && _t_step > _num_samples_train) ++_retraining_steps; +} - _check_step = _t_step; +Real +AdaptiveImportanceSampler::computeSample(dof_id_type /*row_index*/, dof_id_type col_index) +{ return _distributions[col_index]->quantile(Normal::cdf(_prev_value[col_index], 0.0, 1.0)); } diff --git a/modules/stochastic_tools/src/samplers/AffineInvariantDES.C b/modules/stochastic_tools/src/samplers/AffineInvariantDES.C index bb4473fa26b4..d8ef97b52334 100644 --- a/modules/stochastic_tools/src/samplers/AffineInvariantDES.C +++ b/modules/stochastic_tools/src/samplers/AffineInvariantDES.C @@ -85,25 +85,25 @@ AffineInvariantDES::tuneParams(Real & gamma, Real & b, const Real & scale) } void -AffineInvariantDES::proposeSamples(const unsigned int seed_value) +AffineInvariantDES::proposeSamples() { unsigned int j = 0; bool indicator; - unsigned int index_req1, index_req2; + std::pair index_req; Real diff; while (j < _num_parallel_proposals) { indicator = 0; - randomIndexPair(_num_parallel_proposals, j, seed_value, index_req1, index_req2); + index_req = randomIndexPair(_num_parallel_proposals, j); for (unsigned int i = 0; i < _priors.size(); ++i) { - computeDifferential(_previous_state[index_req1][i], - _previous_state[index_req2][i], - getRand(seed_value), + computeDifferential(_previous_state[index_req.first][i], + _previous_state[index_req.second][i], + random(), _scales[i], diff); - _new_samples[j][i] = (_t_step > decisionStep()) ? (_previous_state[j][i] + diff) - : _priors[i]->quantile(getRand(seed_value)); + _new_samples[j][i] = (_t_step + 1 > decisionStep()) ? (_previous_state[j][i] + diff) + : _priors[i]->quantile(random()); if (_lower_bound) indicator = (_new_samples[j][i] < (*_lower_bound)[i] || _new_samples[j][i] > (*_upper_bound)[i]) @@ -112,13 +112,13 @@ AffineInvariantDES::proposeSamples(const unsigned int seed_value) } if (_var_prior) { - computeDifferential(_previous_state_var[index_req1], - _previous_state_var[index_req2], - getRand(seed_value), + computeDifferential(_previous_state_var[index_req.first], + _previous_state_var[index_req.second], + random(), 1.0, diff); - _new_var_samples[j] = (_t_step > decisionStep()) ? (_previous_state_var[j] + diff) - : _var_prior->quantile(getRand(seed_value)); + _new_var_samples[j] = (_t_step + 1 > decisionStep()) ? (_previous_state_var[j] + diff) + : _var_prior->quantile(random()); if (_new_var_samples[j] < 0.0 || _new_var_samples[j] > _variance_bound) indicator = 1; } diff --git a/modules/stochastic_tools/src/samplers/AffineInvariantStretchSampler.C b/modules/stochastic_tools/src/samplers/AffineInvariantStretchSampler.C index 27fd1561a03b..fd0861ba10a8 100644 --- a/modules/stochastic_tools/src/samplers/AffineInvariantStretchSampler.C +++ b/modules/stochastic_tools/src/samplers/AffineInvariantStretchSampler.C @@ -45,7 +45,7 @@ AffineInvariantStretchSampler::AffineInvariantStretchSampler(const InputParamete } void -AffineInvariantStretchSampler::proposeSamples(const unsigned int seed_value) +AffineInvariantStretchSampler::proposeSamples() { unsigned int j = 0; bool indicator; @@ -53,15 +53,15 @@ AffineInvariantStretchSampler::proposeSamples(const unsigned int seed_value) while (j < _num_parallel_proposals) { indicator = 0; - _affine_step[j] = Utility::pow<2>((_step_size - 1.0) * getRand(seed_value) + 1.0) / _step_size; - randomIndex(_num_parallel_proposals, j, seed_value, index_req); + _affine_step[j] = Utility::pow<2>((_step_size - 1.0) * random() + 1.0) / _step_size; + index_req = randomIndex(_num_parallel_proposals, j); for (unsigned int i = 0; i < _priors.size(); ++i) { _new_samples[j][i] = - (_t_step > decisionStep()) + (_t_step + 1 > decisionStep()) ? (_previous_state[index_req][i] + _affine_step[j] * (_previous_state[j][i] - _previous_state[index_req][i])) - : _priors[i]->quantile(getRand(seed_value)); + : _priors[i]->quantile(random()); if (_lower_bound) indicator = (_new_samples[j][i] < (*_lower_bound)[i] || _new_samples[j][i] > (*_upper_bound)[i]) @@ -71,10 +71,10 @@ AffineInvariantStretchSampler::proposeSamples(const unsigned int seed_value) if (_var_prior) { _new_var_samples[j] = - (_t_step > decisionStep()) + (_t_step + 1 > decisionStep()) ? (_previous_state_var[index_req] + _affine_step[j] * (_previous_state_var[j] - _previous_state_var[index_req])) - : _var_prior->quantile(getRand(seed_value)); + : _var_prior->quantile(random()); if (_new_var_samples[j] < 0.0 || _new_var_samples[j] > _variance_bound) indicator = 1; } diff --git a/modules/stochastic_tools/src/samplers/BayesianActiveLearningSampler.C b/modules/stochastic_tools/src/samplers/BayesianActiveLearningSampler.C index adfcc034f604..3d9120268c6e 100644 --- a/modules/stochastic_tools/src/samplers/BayesianActiveLearningSampler.C +++ b/modules/stochastic_tools/src/samplers/BayesianActiveLearningSampler.C @@ -37,14 +37,6 @@ BayesianActiveLearningSampler::BayesianActiveLearningSampler(const InputParamete { } -void -BayesianActiveLearningSampler::fillVector(std::vector & vector, - const unsigned int & seed_value) -{ - for (unsigned int i = 0; i < _priors.size(); ++i) - vector[i] = _priors[i]->quantile(getRand(seed_value)); -} - const std::vector> & BayesianActiveLearningSampler::getSampleTries() const { @@ -58,17 +50,23 @@ BayesianActiveLearningSampler::getVarSampleTries() const } void -BayesianActiveLearningSampler::proposeSamples(const unsigned int seed_value) +BayesianActiveLearningSampler::proposeSamples() { + auto fill_vector = [&](std::vector & vector) + { + for (unsigned int i = 0; i < _priors.size(); ++i) + vector[i] = _priors[i]->quantile(random()); + }; + /* If step is 1, randomly generate the samples. Else, generate the samples informed by the GP from the reporter "sorted_indices" */ for (dof_id_type i = 0; i < _num_parallel_proposals; ++i) { - if (_t_step <= 1) + if (_t_step < 1) { - fillVector(_new_samples[i], seed_value); + fill_vector(_new_samples[i]); if (_var_prior) - _new_var_samples[i] = _var_prior->quantile(getRand(seed_value)); + _new_var_samples[i] = _var_prior->quantile(random()); } else { @@ -82,8 +80,8 @@ BayesianActiveLearningSampler::proposeSamples(const unsigned int seed_value) reporter */ for (dof_id_type i = 0; i < _num_tries; ++i) { - fillVector(_inputs_test[i], seed_value); + fill_vector(_inputs_test[i]); if (_var_prior) - _var_test[i] = _var_prior->quantile(getRand(seed_value)); + _var_test[i] = _var_prior->quantile(random()); } } diff --git a/modules/stochastic_tools/src/samplers/GenericActiveLearningSampler.C b/modules/stochastic_tools/src/samplers/GenericActiveLearningSampler.C index e42f03d2763c..ec91291d2629 100644 --- a/modules/stochastic_tools/src/samplers/GenericActiveLearningSampler.C +++ b/modules/stochastic_tools/src/samplers/GenericActiveLearningSampler.C @@ -46,7 +46,6 @@ GenericActiveLearningSampler::GenericActiveLearningSampler(const InputParameters TransientInterface(this), _num_parallel_proposals(getParam("num_parallel_proposals")), _sorted_indices(getReporterValue>("sorted_indices")), - _check_step(0), _initial_values(getParam>("initial_values")), _num_tries(getParam("num_tries")) { @@ -62,17 +61,10 @@ GenericActiveLearningSampler::GenericActiveLearningSampler(const InputParameters // Setting the sizes for the different vectors enabling sampling and selection _inputs_all.resize(_num_tries, std::vector(_distributions.size(), 0.0)); - _new_samples.resize(_num_parallel_proposals, std::vector(_distributions.size(), 0.0)); + _new_samples.resize(_num_parallel_proposals); setNumberOfRandomSeeds(getParam("num_random_seeds")); -} - -void -GenericActiveLearningSampler::fillVector(std::vector & vector, - const unsigned int & seed_value) -{ - for (unsigned int i = 0; i < _distributions.size(); ++i) - vector[i] = _distributions[i]->quantile(getRand(seed_value)); + setAutoAdvanceGenerators(false); } const std::vector> & @@ -82,26 +74,30 @@ GenericActiveLearningSampler::getSampleTries() const } void -GenericActiveLearningSampler::sampleSetUp(const Sampler::SampleMode /*mode*/) +GenericActiveLearningSampler::executeSetUp() { - if (_t_step < 1 || _check_step == _t_step) - return; - _check_step = _t_step; + std::size_t rand_index = 0; + auto fill_vector = [&](std::vector & vector) + { + vector.resize(getNumberOfCols()); + for (const auto j : make_range(getNumberOfCols())) + vector[j] = _distributions[j]->quantile(getRand(rand_index++, _t_step + 1)); + }; /* If step is 1, randomly generate the samples. Else, generate the samples informed by the GP from the reporter "sorted_indices" */ - for (dof_id_type i = 0; i < _num_parallel_proposals; ++i) + for (const auto i : make_range(getNumberOfRows())) { - if (_t_step <= 1) - fillVector(_new_samples[i], _t_step); + if (_t_step <= 0) + fill_vector(_new_samples[i]); else _new_samples[i] = _inputs_all[_sorted_indices[i]]; } /* Finally, generate several new samples randomly for the GP to try and pass it to the reporter */ - for (dof_id_type i = 0; i < _num_tries; ++i) - fillVector(_inputs_all[i], _t_step); + for (const auto i : make_range(_num_tries)) + fill_vector(_inputs_all[i]); } Real diff --git a/modules/stochastic_tools/src/samplers/IndependentGaussianMH.C b/modules/stochastic_tools/src/samplers/IndependentGaussianMH.C index 2c6234d61dc7..b65842fcbe49 100644 --- a/modules/stochastic_tools/src/samplers/IndependentGaussianMH.C +++ b/modules/stochastic_tools/src/samplers/IndependentGaussianMH.C @@ -37,19 +37,16 @@ IndependentGaussianMH::IndependentGaussianMH(const InputParameters & parameters) } void -IndependentGaussianMH::proposeSamples(const unsigned int seed_value) +IndependentGaussianMH::proposeSamples() { - std::vector old_sample = (_t_step > decisionStep()) ? _seed_inputs : _initial_values; + std::vector old_sample = (_t_step + 1 > decisionStep()) ? _seed_inputs : _initial_values; for (unsigned int j = 0; j < _num_parallel_proposals; ++j) for (unsigned int i = 0; i < _priors.size(); ++i) { if (_lower_bound) - _new_samples[j][i] = TruncatedNormal::quantile(getRand(seed_value), - old_sample[i], - _std_prop[i], - (*_lower_bound)[i], - (*_upper_bound)[i]); + _new_samples[j][i] = TruncatedNormal::quantile( + random(), old_sample[i], _std_prop[i], (*_lower_bound)[i], (*_upper_bound)[i]); else - _new_samples[j][i] = Normal::quantile(getRand(seed_value), old_sample[i], _std_prop[i]); + _new_samples[j][i] = Normal::quantile(random(), old_sample[i], _std_prop[i]); } } diff --git a/modules/stochastic_tools/src/samplers/LatinHypercubeSampler.C b/modules/stochastic_tools/src/samplers/LatinHypercubeSampler.C index e26a3ca23e80..21a6fd46128d 100644 --- a/modules/stochastic_tools/src/samplers/LatinHypercubeSampler.C +++ b/modules/stochastic_tools/src/samplers/LatinHypercubeSampler.C @@ -9,6 +9,8 @@ #include "LatinHypercubeSampler.h" #include "Distribution.h" +#include "MooseRandomPerturbation.h" + registerMooseObjectAliased("StochasticToolsApp", LatinHypercubeSampler, "LatinHypercube"); InputParameters @@ -33,68 +35,40 @@ LatinHypercubeSampler::LatinHypercubeSampler(const InputParameters & parameters) setNumberOfRows(getParam("num_rows")); setNumberOfCols(distribution_names.size()); - setNumberOfRandomSeeds(2 * distribution_names.size()); - - // The use of MooseRandom in this Sampler is fairly complex. There are two sets of random - // generators. The first set (n = number columns) is used to generate the random probability - // within each bin of the Latin hypercube sample. The second set (n) is used to shuffle the - // probability values. Mainly due to how the shuffle operates, it is necessary for the management - // of advancement of the generators to be handled manually. - setAutoAdvanceGenerators(false); + // Generator 0: within-bin uniform draws. Generator 1: column shuffler seeds. + setNumberOfRandomSeeds(2); } void -LatinHypercubeSampler::sampleSetUp(const Sampler::SampleMode mode) +LatinHypercubeSampler::executeTearDown() { - // All calls to the generators occur in here. Calls to the random number generators - // (i.e., getRand) are complete by the end of this function. - - // Flag to indicate what vector index to use in computeSample method - _is_local = mode == Sampler::SampleMode::LOCAL; - - const Real bin_size = 1. / getNumberOfRows(); - _probabilities.resize(getNumberOfCols()); - if (mode == Sampler::SampleMode::GLOBAL) - { - for (dof_id_type col = 0; col < getNumberOfCols(); ++col) - { - std::vector & local = _probabilities[col]; - local.resize(getNumberOfRows()); - for (dof_id_type row = 0; row < getNumberOfRows(); ++row) - { - const auto lower = row * bin_size; - const auto upper = (row + 1) * bin_size; - local[row] = getRand(col) * (upper - lower) + lower; - } - shuffle(local, col + getNumberOfCols(), CommMethod::NONE); - } - } - - else + _shufflers.clear(); + for (const auto col : make_range(getNumberOfCols())) { - for (dof_id_type col = 0; col < getNumberOfCols(); ++col) - { - std::vector & local = _probabilities[col]; - local.resize(getNumberOfLocalRows()); - advanceGenerator(col, getLocalRowBegin()); - for (dof_id_type row = getLocalRowBegin(); row < getLocalRowEnd(); ++row) - { - const auto lower = row * bin_size; - const auto upper = (row + 1) * bin_size; - local[row - getLocalRowBegin()] = getRand(col) * (upper - lower) + lower; - } - advanceGenerator(col, getNumberOfRows() - getLocalRowEnd()); - - // Do not advance generator for shuffle, the shuffle handles it - shuffle(local, col + getNumberOfCols(), CommMethod::SEMI_LOCAL); - } + const auto seed = getRandl(col, 0, std::numeric_limits::max(), 1); + _shufflers.push_back(std::make_unique(seed, getNumberOfRows())); } } Real LatinHypercubeSampler::computeSample(dof_id_type row_index, dof_id_type col_index) { - // NOTE: All calls to generators (getRand, etc.) occur in sampleSetup - auto row = _is_local ? row_index - getLocalRowBegin() : row_index; - return _distributions[col_index]->quantile(_probabilities[col_index][row]); + mooseAssert(_shufflers.size() > 0, "Shufflers have not been initialized."); + + // Divide [0,1] into N equal bins of width 1/N. + const Real bin_size = 1. / getNumberOfRows(); + + // Map row_index to a shuffled bin via the column's bijective permutation. + // Because permute() is a bijection on [0, N), each row gets a distinct bin, + // which is the core LHS stratification guarantee. + const auto bin = _shufflers[col_index]->permute(row_index); + + // Draw a uniform random point within the selected bin. + const auto lower = bin * bin_size; + const auto upper = (bin + 1) * bin_size; + const Real probability = + getRand(row_index * getNumberOfCols() + col_index) * (upper - lower) + lower; + + // Transform the probability through the inverse CDF to obtain the sample value. + return _distributions[col_index]->quantile(probability); } diff --git a/modules/stochastic_tools/src/samplers/MonteCarloSampler.C b/modules/stochastic_tools/src/samplers/MonteCarloSampler.C index 4c8700bb6920..918c1cfb6a07 100644 --- a/modules/stochastic_tools/src/samplers/MonteCarloSampler.C +++ b/modules/stochastic_tools/src/samplers/MonteCarloSampler.C @@ -41,7 +41,7 @@ MonteCarloSampler::MonteCarloSampler(const InputParameters & parameters) } Real -MonteCarloSampler::computeSample(dof_id_type /*row_index*/, dof_id_type col_index) +MonteCarloSampler::computeSample(dof_id_type row_index, dof_id_type col_index) { - return _distributions[col_index]->quantile(getRand()); + return _distributions[col_index]->quantile(getRand(row_index * getNumberOfCols() + col_index)); } diff --git a/modules/stochastic_tools/src/samplers/MorrisSampler.C b/modules/stochastic_tools/src/samplers/MorrisSampler.C index f8494e925cc8..0c1c01750852 100644 --- a/modules/stochastic_tools/src/samplers/MorrisSampler.C +++ b/modules/stochastic_tools/src/samplers/MorrisSampler.C @@ -44,15 +44,11 @@ MorrisSampler::MorrisSampler(const InputParameters & parameters) { for (const auto & name : getParam>("distributions")) _distributions.push_back(&getDistributionByName(name)); + const dof_id_type nc = _distributions.size(); - setNumberOfCols(_distributions.size()); - setNumberOfRows(_num_trajectories * (_distributions.size() + 1)); -} + setNumberOfCols(nc); + setNumberOfRows(_num_trajectories * (nc + 1)); -void -MorrisSampler::sampleSetUp(const Sampler::SampleMode /*mode*/) -{ - const dof_id_type nc = getNumberOfCols(); _b = RealEigenMatrix::Ones(nc + 1, nc).triangularView(); _pstar.resize(nc, nc); _j.setOnes(nc + 1, nc); @@ -64,23 +60,32 @@ MorrisSampler::sampleSetUp(const Sampler::SampleMode /*mode*/) Real MorrisSampler::computeSample(dof_id_type row_index, dof_id_type col_index) { + const dof_id_type traj = row_index / (getNumberOfCols() + 1); const dof_id_type traj_ind = row_index % (getNumberOfCols() + 1); - if (traj_ind == 0 && col_index == 0) + if (traj != _curr_trajectory) + { + _curr_trajectory = traj; updateBstar(); + } return _distributions[col_index]->quantile(_bstar(traj_ind, col_index)); } void MorrisSampler::updateBstar() { + mooseAssert(_curr_trajectory < _num_trajectories, + "Current trajectory index is greater than the prescribed number of trajectories."); + const dof_id_type nc = getNumberOfCols(); // convenience + dof_id_type rn_ind = _curr_trajectory * nc * (nc + 1); + _pstar.setZero(); // Which parameter to perturb std::vector pchoice(nc); std::iota(pchoice.begin(), pchoice.end(), 0); for (dof_id_type c = 0; c < nc; ++c) { - const unsigned int ind = nc > 1 ? getRandl(0, 0, pchoice.size()) : 0; + const unsigned int ind = nc > 1 ? getRandl(rn_ind++, 0, pchoice.size()) : 0; _pstar(pchoice[ind], c) = 1.0; pchoice.erase(pchoice.begin() + ind); } @@ -88,23 +93,17 @@ MorrisSampler::updateBstar() _dstar.setZero(); // Direction of perturbation for (dof_id_type c = 0; c < nc; ++c) - _dstar(c, c) = getRand() < 0.5 ? -1.0 : 1.0; + _dstar(c, c) = getRand(rn_ind++) < 0.5 ? -1.0 : 1.0; // Initial value for (dof_id_type c = 0; c < nc; ++c) { - const auto lind = getRandl(0, 0, _num_levels / 2); + const auto lind = getRandl(rn_ind++, 0, _num_levels / 2); _xstar.col(c).setConstant((Real)lind * 1.0 / ((Real)_num_levels - 1)); } _bstar = _xstar + _num_levels / 4.0 / (_num_levels - 1) * ((2.0 * _b * _pstar - _j) * _dstar + _j); - - // This matrix represent _n_cols * (_n_cols + 1) samples, but so far we have only - // advanced the generator 3 * _n_cols times. For the generator state restore - // to work properly, we need to finish advancing the generator - if (nc > 2) - advanceGenerator(0, nc * (nc - 2)); } LocalRankConfig diff --git a/modules/stochastic_tools/src/samplers/NestedMonteCarloSampler.C b/modules/stochastic_tools/src/samplers/NestedMonteCarloSampler.C index fc9eca03e2c3..dff59798354d 100644 --- a/modules/stochastic_tools/src/samplers/NestedMonteCarloSampler.C +++ b/modules/stochastic_tools/src/samplers/NestedMonteCarloSampler.C @@ -40,54 +40,34 @@ NestedMonteCarloSampler::NestedMonteCarloSampler(const InputParameters & paramet // Gather distribution pointers and fill in loop index const std::size_t nloop = dnames.size(); + std::vector loop_index; for (const auto & n : make_range(nloop)) for (const auto & name : dnames[n]) { _distributions.push_back(&getDistributionByName(name)); - _loop_index.push_back(n); + loop_index.push_back(n); } // Compute what row indices need to recompute which columns - _loop_mod.resize(nloop); - std::partial_sum( - nrows.rbegin(), nrows.rend(), _loop_mod.rbegin(), std::multiplies()); - _loop_mod.erase(_loop_mod.begin()); - _loop_mod.push_back(1); + std::vector loop_mod(nloop); + std::partial_sum(nrows.rbegin(), nrows.rend(), loop_mod.rbegin(), std::multiplies()); + loop_mod.erase(loop_mod.begin()); + loop_mod.push_back(1); - // Allocate row storage - _row_data.resize(_distributions.size()); + // Fill in the mod for each column + _col_mod.resize(_distributions.size()); + for (const auto j : index_range(_distributions)) + _col_mod[j] = loop_mod[loop_index[j]]; setNumberOfRows(std::accumulate(nrows.begin(), nrows.end(), 1, std::multiplies())); setNumberOfCols(_distributions.size()); } -void -NestedMonteCarloSampler::sampleSetUp(const SampleMode mode) -{ - if (mode == Sampler::SampleMode::GLOBAL || getNumberOfRows() == 0) - return; - - dof_id_type curr_row = 0; - for (const auto & mod : _loop_mod) - { - if (getLocalRowBegin() % mod == 0) - break; - - const dof_id_type target_row = std::floor(getLocalRowBegin() / mod) * mod; - advanceGenerators((target_row - curr_row) * getNumberOfCols()); - for (const auto & j : make_range(getNumberOfCols())) - computeSample(target_row, j); - curr_row = target_row + 1; - } - restoreGeneratorState(); -} - Real NestedMonteCarloSampler::computeSample(dof_id_type row_index, dof_id_type col_index) { - const Real rn = getRand(); - const auto & loop = _loop_index[col_index]; - if (row_index % _loop_mod[loop] == 0) - _row_data[col_index] = _distributions[col_index]->quantile(rn); - return _row_data[col_index]; + const auto mod = _col_mod[col_index]; + const dof_id_type target_row = std::floor(row_index / mod) * mod; + const Real rn = getRand(target_row * getNumberOfCols() + col_index); + return _distributions[col_index]->quantile(rn); } diff --git a/modules/stochastic_tools/src/samplers/PMCMCBase.C b/modules/stochastic_tools/src/samplers/PMCMCBase.C index e4a006e73703..d093107415a9 100644 --- a/modules/stochastic_tools/src/samplers/PMCMCBase.C +++ b/modules/stochastic_tools/src/samplers/PMCMCBase.C @@ -55,9 +55,10 @@ PMCMCBase::PMCMCBase(const InputParameters & parameters) _upper_bound(isParamValid("upper_bound") ? &getParam>("upper_bound") : nullptr), _variance_bound(getParam("variance_bound")), - _check_step(0), _initial_values(getParam>("initial_values")), - _num_random_seeds(getParam("num_random_seeds")) + _num_random_seeds(getParam("num_random_seeds")), + _seed_index(0), + _rand_index(0) { // Filling the `priors` vector with the user-provided distributions. for (const DistributionName & name : @@ -92,15 +93,14 @@ PMCMCBase::PMCMCBase(const InputParameters & parameters) setNumberOfCols(_priors.size() + _confg_values.size()); // Resizing the vectors and vector of vectors - _new_samples.resize(_num_parallel_proposals, std::vector(_priors.size(), 0.0)); + _new_samples.resize(_num_parallel_proposals, _initial_values); _new_samples_confg.resize(_num_parallel_proposals * _confg_values[0].size(), std::vector(_priors.size() + _confg_values.size(), 0.0)); _rnd_vec.resize(_num_parallel_proposals); _new_var_samples.assign(_num_parallel_proposals, 0.0); setNumberOfRandomSeeds(_num_random_seeds); - - _check_step = 0; + setAutoAdvanceGenerators(false); // Check whether both the lower and the upper bounds are specified and of same size bool bound_check1 = _lower_bound && !_upper_bound; @@ -117,52 +117,51 @@ PMCMCBase::PMCMCBase(const InputParameters & parameters) } void -PMCMCBase::proposeSamples(const unsigned int seed_value) +PMCMCBase::proposeSamples() { for (unsigned int j = 0; j < _num_parallel_proposals; ++j) for (unsigned int i = 0; i < _priors.size(); ++i) - _new_samples[j][i] = _priors[i]->quantile(getRand(seed_value)); + _new_samples[j][i] = _priors[i]->quantile(random()); } void -PMCMCBase::sampleSetUp(const SampleMode /*mode*/) +PMCMCBase::executeSetUp() { - if (_t_step < 1 || _check_step == _t_step) - return; - _check_step = _t_step; - - unsigned int seed_value = _t_step > 0 ? (_t_step - 1) : 0; + // _seed_index = _t_step > 0 ? _t_step - 1 : 0; + _seed_index = _t_step; + _rand_index = 0; // Filling the new_samples vector of vectors with new proposal samples - proposeSamples(seed_value); + proposeSamples(); // Draw random numbers to facilitate decision making later on for (unsigned int j = 0; j < _num_parallel_proposals; ++j) - _rnd_vec[j] = getRand(seed_value); + _rnd_vec[j] = random(); } -void -PMCMCBase::randomIndex(const unsigned int & upper_bound, - const unsigned int & exclude, - const unsigned int & seed, - unsigned int & req_index) +Real +PMCMCBase::random() { - req_index = exclude; + return getRand(_rand_index++, _seed_index); +} + +unsigned int +PMCMCBase::randomIndex(const unsigned int & upper_bound, const unsigned int & exclude) +{ + auto req_index = exclude; while (req_index == exclude) - req_index = getRandl(seed, 0, upper_bound); + req_index = getRandl(_rand_index++, 0, upper_bound, _seed_index); + return req_index; } -void -PMCMCBase::randomIndexPair(const unsigned int & upper_bound, - const unsigned int & exclude, - const unsigned int & seed, - unsigned int & req_index1, - unsigned int & req_index2) +std::pair +PMCMCBase::randomIndexPair(const unsigned int & upper_bound, const unsigned int & exclude) { - randomIndex(upper_bound, exclude, seed, req_index1); - req_index2 = req_index1; + auto req_index1 = randomIndex(upper_bound, exclude); + auto req_index2 = req_index1; while (req_index1 == req_index2) - randomIndex(upper_bound, exclude, seed, req_index2); + req_index2 = randomIndex(upper_bound, exclude); + return {req_index1, req_index2}; } void diff --git a/modules/stochastic_tools/src/samplers/ParallelSubsetSimulation.C b/modules/stochastic_tools/src/samplers/ParallelSubsetSimulation.C index b947f962ac04..e85f1f3f0fad 100644 --- a/modules/stochastic_tools/src/samplers/ParallelSubsetSimulation.C +++ b/modules/stochastic_tools/src/samplers/ParallelSubsetSimulation.C @@ -54,7 +54,6 @@ ParallelSubsetSimulation::ParallelSubsetSimulation(const InputParameters & param _inputs(getReporterValue>>("inputs_reporter")), _step(getCheckedPointerParam("_fe_problem_base")->timeStep()), _count_max(std::floor(1 / _subset_probability)), - _check_step(0), _subset(0), _is_sampling_completed(false) { @@ -92,6 +91,7 @@ ParallelSubsetSimulation::ParallelSubsetSimulation(const InputParameters & param _markov_seed.resize(_distributions.size()); setNumberOfRandomSeeds(_num_random_seeds); + setAutoAdvanceGenerators(false); } const unsigned int & @@ -113,20 +113,23 @@ ParallelSubsetSimulation::getSubsetProbability() const } void -ParallelSubsetSimulation::sampleSetUp(const SampleMode mode) +ParallelSubsetSimulation::executeSetUp() { - if (_step <= 1 || _check_step == _step) - return; - _check_step = _step; - if (_is_sampling_completed) mooseError("Internal bug: the adaptive sampling is supposed to be completed but another sample " "has been requested."); - _subset = ((_step - 1) * getNumberOfRows()) / _num_samplessub; - const unsigned int sub_ind = (_step - 1) - (_num_samplessub / getNumberOfRows()) * _subset; + _subset = (_step * getNumberOfRows()) / _num_samplessub; + const unsigned int sub_ind = _step - (_num_samplessub / getNumberOfRows()) * _subset; const unsigned int offset = sub_ind * getNumberOfRows(); + // check if we have completed the last sample + if (_subset >= _num_subsets) + { + _is_sampling_completed = true; + return; + } + // Get and store the accepted samples input across all the procs from the previous step for (dof_id_type j = 0; j < _distributions.size(); ++j) for (dof_id_type ss = 0; ss < getNumberOfRows(); ++ss) @@ -135,10 +138,7 @@ ParallelSubsetSimulation::sampleSetUp(const SampleMode mode) // Get the accepted sample outputs across all the procs from the previous step std::vector tmp = _use_absolute_value ? AdaptiveMonteCarloUtils::computeVectorABS(_outputs) : _outputs; - if (mode == Sampler::SampleMode::GLOBAL) - _communicator.allgather(tmp); - else - _local_comm.allgather(tmp); + _communicator.allgather(tmp); for (dof_id_type ss = 0; ss < getNumberOfRows(); ++ss) _outputs_sto[ss + offset] = tmp[ss]; @@ -159,42 +159,38 @@ ParallelSubsetSimulation::sampleSetUp(const SampleMode mode) { const unsigned int soffset = (sub_ind / _count_max) * getNumberOfRows(); for (dof_id_type j = 0; j < _distributions.size(); ++j) - _markov_seed[j].assign(_inputs_sorted[j].begin() + soffset + getLocalRowBegin(), - _inputs_sorted[j].begin() + soffset + getLocalRowEnd()); + _markov_seed[j].assign(_inputs_sorted[j].begin() + soffset, + _inputs_sorted[j].begin() + soffset + getNumberOfRows()); } // Otherwise, use the previously accepted input values to propose the next set of input // values else { for (dof_id_type j = 0; j < _distributions.size(); ++j) - _markov_seed[j].assign(_inputs_sto[j].begin() + offset + getLocalRowBegin(), - _inputs_sto[j].begin() + offset + getLocalRowEnd()); + _markov_seed[j].assign(_inputs_sto[j].begin() + offset, + _inputs_sto[j].begin() + offset + getNumberOfRows()); } } - - // check if we have completed the last sample (sub_ind == _num_samplessub /getNumberOfRows() - 1) - // of the last subset (_subset == _num_subsets - 1) - if (_subset == _num_subsets - 1 && sub_ind == _num_samplessub / getNumberOfRows() - 1) - _is_sampling_completed = true; } Real ParallelSubsetSimulation::computeSample(dof_id_type row_index, dof_id_type col_index) { unsigned int seed_value = _step > 0 ? (_step - 1) * 2 : 0; + const dof_id_type n = row_index * getNumberOfCols() + col_index; Real val; if (_subset == 0) - val = getRand(seed_value); + val = getRand(n, seed_value); else { - const dof_id_type loc_ind = row_index - getLocalRowBegin(); - const Real rv = Normal::quantile(getRand(seed_value), _markov_seed[col_index][loc_ind], 1.0); + const Real rv = + Normal::quantile(getRand(n, seed_value), _markov_seed[col_index][row_index], 1.0); const Real acceptance_ratio = std::log(Normal::pdf(rv, 0, 1)) - - std::log(Normal::pdf(_markov_seed[col_index][loc_ind], 0, 1)); - const Real new_sample = acceptance_ratio > std::log(getRand(seed_value + 1)) + std::log(Normal::pdf(_markov_seed[col_index][row_index], 0, 1)); + const Real new_sample = acceptance_ratio > std::log(getRand(n, seed_value + 1)) ? rv - : _markov_seed[col_index][loc_ind]; + : _markov_seed[col_index][row_index]; val = Normal::cdf(new_sample, 0, 1); } diff --git a/modules/stochastic_tools/test/include/samplers/TestDynamicNumberOfSubAppsSampler.h b/modules/stochastic_tools/test/include/samplers/TestDynamicNumberOfSubAppsSampler.h index ccacc86204b1..cb800ce5faaa 100644 --- a/modules/stochastic_tools/test/include/samplers/TestDynamicNumberOfSubAppsSampler.h +++ b/modules/stochastic_tools/test/include/samplers/TestDynamicNumberOfSubAppsSampler.h @@ -19,5 +19,5 @@ class TestDynamicNumberOfSubAppsSampler : public MonteCarloSampler void executeSetUp() override; protected: - const dof_id_type _increment_rows; + dof_id_type _increment_rows = 0; }; diff --git a/modules/stochastic_tools/test/src/samplers/TestDynamicNumberOfSubAppsSampler.C b/modules/stochastic_tools/test/src/samplers/TestDynamicNumberOfSubAppsSampler.C index 53c4c1af7825..7132d5a437f3 100644 --- a/modules/stochastic_tools/test/src/samplers/TestDynamicNumberOfSubAppsSampler.C +++ b/modules/stochastic_tools/test/src/samplers/TestDynamicNumberOfSubAppsSampler.C @@ -21,7 +21,7 @@ TestDynamicNumberOfSubAppsSampler::validParams() TestDynamicNumberOfSubAppsSampler::TestDynamicNumberOfSubAppsSampler( const InputParameters & parameters) - : MonteCarloSampler(parameters), _increment_rows(getParam("increment_rows")) + : MonteCarloSampler(parameters) { } @@ -29,4 +29,5 @@ void TestDynamicNumberOfSubAppsSampler::executeSetUp() { setNumberOfRows(getNumberOfRows() + _increment_rows); + _increment_rows = getParam("increment_rows"); } diff --git a/modules/stochastic_tools/test/tests/actions/parameter_study_action/gold/lhs_csv_study_results_0001.csv b/modules/stochastic_tools/test/tests/actions/parameter_study_action/gold/lhs_csv_study_results_0001.csv index 64ab8d25b39b..3b13e1930165 100644 --- a/modules/stochastic_tools/test/tests/actions/parameter_study_action/gold/lhs_csv_study_results_0001.csv +++ b/modules/stochastic_tools/test/tests/actions/parameter_study_action/gold/lhs_csv_study_results_0001.csv @@ -1,16 +1,16 @@ -BCs_left_value,BCs_right_value,average:value,converged -147.4088825,1.403482935,74.40624,TRUE -115.9385818,1.776695124,58.85785,TRUE -192.3642751,1.08827833,96.72614,TRUE -131.0433815,1.825934977,66.434465,TRUE -107.7321641,1.254038906,54.49302,TRUE -105.2943998,1.042130766,53.168065,TRUE -180.8497554,1.921600619,91.3858,TRUE -179.0564018,1.677776098,90.36689,TRUE -137.0609995,1.39010546,69.225555,TRUE -194.9727904,1.51752159,98.24526,TRUE -144.638364,1.138417755,72.88821,TRUE -126.2432344,1.327498982,63.78525,TRUE -155.7706017,1.581004444,78.676,TRUE -165.5603621,1.951761761,83.75588,TRUE -167.9549861,1.623081184,84.78904,TRUE \ No newline at end of file +BCs_left_value,BCs_right_value,average:value,converged +145.294399758,1.3439883081542,73.319194034408,True +102.60524843952,1.8624323437222,52.233840391308,True +164.3767148831,1.5706099951596,82.973662439624,True +124.63836403294,1.6074221584695,63.12289309537,True +175.77060167398,1.188936954608,88.479769314687,True +167.95498609295,1.5238973517992,84.739441722422,True +107.51642210156,1.2569760845408,54.386699092521,True +134.97279036538,1.7078585198716,68.34032444289,True +130.11011963289,1.9799998336339,66.045059734513,True +186.21388297581,1.8905470258924,94.052215001318,True +187.85895658588,1.0739280338589,94.466442309889,True +151.55791443374,1.0064406438442,76.28217753848,True +196.61000678411,1.3228949674747,98.9664508762,True +153.41318827635,1.4057376226307,77.409462949134,True +118.64270928814,1.7467417513551,60.194725519485,True diff --git a/modules/stochastic_tools/test/tests/multiapps/dynamic_sub_app_number/gold/main_out.json b/modules/stochastic_tools/test/tests/multiapps/dynamic_sub_app_number/gold/main_out.json index 8730d8d516c8..87fa485a065c 100644 --- a/modules/stochastic_tools/test/tests/multiapps/dynamic_sub_app_number/gold/main_out.json +++ b/modules/stochastic_tools/test/tests/multiapps/dynamic_sub_app_number/gold/main_out.json @@ -32,12 +32,12 @@ { "storage": { "data:center": [ - 0.7479191065926474, 0.813447922433415, 0.533102496194665, 0.6550691643974668, 0.8797898413914109, - 0.5723971110046696 + 0.5723971110046696, + 0.8914972995888071 ] }, "time": 2.0, @@ -46,13 +46,13 @@ { "storage": { "data:center": [ - 0.5408404542817916, 0.889665333364593, 0.5976630446063532, 0.7760906731535501, 0.7274686842616979, 0.815483226648783, - 0.926813612580807 + 0.926813612580807, + 0.6515266700419625 ] }, "time": 3.0, diff --git a/modules/stochastic_tools/test/tests/reporters/AISActiveLearning/ais_al.i b/modules/stochastic_tools/test/tests/reporters/AISActiveLearning/ais_al.i index 1fa448b22958..c9adbb7067a9 100644 --- a/modules/stochastic_tools/test/tests/reporters/AISActiveLearning/ais_al.i +++ b/modules/stochastic_tools/test/tests/reporters/AISActiveLearning/ais_al.i @@ -28,6 +28,8 @@ use_absolute_value = true flag_sample = 'conditional/flag_sample' seed = 9874 + num_random_seeds = 100 + execute_on = 'initial multiapp_fixed_point_begin' [] [] diff --git a/modules/stochastic_tools/test/tests/reporters/ActiveLearningGP/main_adam.i b/modules/stochastic_tools/test/tests/reporters/ActiveLearningGP/main_adam.i index ce8b66ac16fc..35664b1f61fa 100644 --- a/modules/stochastic_tools/test/tests/reporters/ActiveLearningGP/main_adam.i +++ b/modules/stochastic_tools/test/tests/reporters/ActiveLearningGP/main_adam.i @@ -26,8 +26,9 @@ distributions = 'k_dist q_dist Tinf_dist' flag_sample = 'conditional/flag_sample' seed = 5 + num_random_seeds = 100 num_samples = 20 - execute_on = PRE_MULTIAPP_SETUP + execute_on = 'initial timestep_begin' [] [] diff --git a/modules/stochastic_tools/test/tests/reporters/BFActiveLearning/main_adam.i b/modules/stochastic_tools/test/tests/reporters/BFActiveLearning/main_adam.i index dc3d4f8fcd61..e6ab53f7d236 100644 --- a/modules/stochastic_tools/test/tests/reporters/BFActiveLearning/main_adam.i +++ b/modules/stochastic_tools/test/tests/reporters/BFActiveLearning/main_adam.i @@ -26,8 +26,9 @@ distributions = 'k_dist q_dist Tinf_dist' flag_sample = 'conditional/flag_sample' seed = 5 + num_random_seeds = 100 num_samples = 10 - execute_on = PRE_MULTIAPP_SETUP + execute_on = 'initial multiapp_fixed_point_begin' [] [] diff --git a/modules/stochastic_tools/test/tests/samplers/AdaptiveImportanceSampler/ais.i b/modules/stochastic_tools/test/tests/samplers/AdaptiveImportanceSampler/ais.i index 0ea3dcce8aad..272eba016d4a 100644 --- a/modules/stochastic_tools/test/tests/samplers/AdaptiveImportanceSampler/ais.i +++ b/modules/stochastic_tools/test/tests/samplers/AdaptiveImportanceSampler/ais.i @@ -27,6 +27,8 @@ inputs_reporter = 'adaptive_MC/inputs' use_absolute_value = true seed = 1012 + num_random_seeds = 100 + execute_on = 'initial multiapp_fixed_point_begin' [] [] diff --git a/modules/stochastic_tools/test/tests/samplers/ParallelActiveLearning/BayesianALTrain.i b/modules/stochastic_tools/test/tests/samplers/ParallelActiveLearning/BayesianALTrain.i index 0a13879ac697..3936f31055f0 100644 --- a/modules/stochastic_tools/test/tests/samplers/ParallelActiveLearning/BayesianALTrain.i +++ b/modules/stochastic_tools/test/tests/samplers/ParallelActiveLearning/BayesianALTrain.i @@ -37,9 +37,10 @@ num_parallel_proposals = 5 num_tries = 100 seed = 200 + num_random_seeds = 100 file_name = 'confg.csv' initial_values = '0.1 0.1' - execute_on = PRE_MULTIAPP_SETUP + execute_on = 'PRE_MULTIAPP_SETUP TIMESTEP_END' [] [] @@ -87,6 +88,7 @@ gp_evaluator = GP_eval acquisition = 'BayesianPosterior' likelihoods = 'gaussian' + execute_on = timestep_begin [] [] diff --git a/modules/stochastic_tools/test/tests/samplers/ParallelActiveLearning/parallelAL.i b/modules/stochastic_tools/test/tests/samplers/ParallelActiveLearning/parallelAL.i index 3675a5d30e75..61806ea37284 100644 --- a/modules/stochastic_tools/test/tests/samplers/ParallelActiveLearning/parallelAL.i +++ b/modules/stochastic_tools/test/tests/samplers/ParallelActiveLearning/parallelAL.i @@ -28,8 +28,9 @@ num_parallel_proposals = 5 num_tries = 1000 seed = 100 + num_random_seeds = 100 initial_values = '0.1 0.1' - execute_on = PRE_MULTIAPP_SETUP + execute_on = 'PRE_MULTIAPP_SETUP timestep_end' [] [] @@ -71,6 +72,7 @@ al_gp = GP_al_trainer gp_evaluator = GP_eval acquisition = 'expectedimprovement' + execute_on = 'timestep_begin' [] [] diff --git a/modules/stochastic_tools/test/tests/samplers/ParallelSubsetSimulation/pss.i b/modules/stochastic_tools/test/tests/samplers/ParallelSubsetSimulation/pss.i index 44f0a07b8ae6..c4f3a5def1b5 100644 --- a/modules/stochastic_tools/test/tests/samplers/ParallelSubsetSimulation/pss.i +++ b/modules/stochastic_tools/test/tests/samplers/ParallelSubsetSimulation/pss.i @@ -24,6 +24,8 @@ output_reporter = 'constant/reporter_transfer:average:value' inputs_reporter = 'adaptive_MC/inputs' seed = 1012 + num_random_seeds = 200 + execute_on = 'initial timestep_end' [] [] @@ -61,6 +63,7 @@ output_value = constant/reporter_transfer:average:value inputs = 'inputs' sampler = sample + execute_on = 'timestep_begin' [] [] diff --git a/modules/stochastic_tools/test/tests/samplers/dynamic_size/gold/main_out.json b/modules/stochastic_tools/test/tests/samplers/dynamic_size/gold/main_out.json index 41a96449fce3..5c0d0cc9d4b5 100644 --- a/modules/stochastic_tools/test/tests/samplers/dynamic_size/gold/main_out.json +++ b/modules/stochastic_tools/test/tests/samplers/dynamic_size/gold/main_out.json @@ -25,12 +25,12 @@ { "sample": { "dynamic_0": [ - 6.032349346546173, 7.261791444464234, 2.001991393376338, 4.290312259867861, 8.506488872074817, - 2.739231225479595 + 2.739231225479595, + 8.726142492886463 ] }, "time": 1.0, @@ -39,13 +39,13 @@ { "sample": { "dynamic_0": [ - 2.147169837112487, 8.691771413013935, 3.213266993258947, 6.560900182666523, 5.648661504406296, 7.299977540580029, - 9.38874201734549 + 9.38874201734549, + 4.223848495474664 ] }, "time": 2.0, diff --git a/modules/stochastic_tools/test/tests/samplers/latin_hypercube/gold/latin_hypercube_out_data_0000.csv b/modules/stochastic_tools/test/tests/samplers/latin_hypercube/gold/latin_hypercube_out_data_0000.csv index 4657c710a6d8..7f07f4d08228 100644 --- a/modules/stochastic_tools/test/tests/samplers/latin_hypercube/gold/latin_hypercube_out_data_0000.csv +++ b/modules/stochastic_tools/test/tests/samplers/latin_hypercube/gold/latin_hypercube_out_data_0000.csv @@ -1,11 +1,11 @@ sample_0,sample_1 -164.19671860092,11.455396456473 -146.47652728229,19.493240744487 -151.93419045758,16.486928113439 -174.35833951485,15.198578399749 -183.2880646629,13.501852007384 -118.89451008078,17.998317007305 -134.49019805906,18.350466868864 -196.07289000623,10.940273753361 -102.44571531458,14.457793714244 -126.67420481225,12.181492186207 +172.44571531458,17.889451008078 +116.67420481225,18.449019805906 +186.47652728229,19.193419045758 +104.19671860092,14.435833951485 +163.2880646629,13.607289000623 +135.68982854737,10.834795505332 +141.06854691633,15.228372590603 +159.2731941567,16.935403319373 +193.36613448385,12.684540570385 +121.81342277833,11.586294316285 diff --git a/modules/stochastic_tools/test/tests/samplers/latin_hypercube/gold/latin_hypercube_out_data_0001.csv b/modules/stochastic_tools/test/tests/samplers/latin_hypercube/gold/latin_hypercube_out_data_0001.csv index ab2f5412948e..f01eacd636fe 100644 --- a/modules/stochastic_tools/test/tests/samplers/latin_hypercube/gold/latin_hypercube_out_data_0001.csv +++ b/modules/stochastic_tools/test/tests/samplers/latin_hypercube/gold/latin_hypercube_out_data_0001.csv @@ -1,11 +1,11 @@ sample_0,sample_1 -181.81342277833,11.748076943341 -163.36613448385,15.217216353775 -132.28372590603,13.183667604489 -149.2731941567,10.378117714195 -176.84540570385,19.453221159821 -121.06854691633,18.456686357055 -105.68982854737,17.80906106452 -195.86294316285,12.143695709061 -159.35403319373,14.0505733378 -118.34795505332,16.831497657159 +133.83223254182,11.436652471915 +110.35898900931,10.772229834065 +148.90677750949,12.36134603176 +179.42419578237,19.427278272153 +152.31748021717,17.489835179995 +194.74512892475,18.220482824976 +163.43495756545,13.531115895728 +126.02918815036,15.389118936071 +187.40598172195,14.980611945353 +103.42105808988,16.24833583321 diff --git a/modules/stochastic_tools/test/tests/samplers/latin_hypercube/gold/latin_hypercube_small_data_0000.csv b/modules/stochastic_tools/test/tests/samplers/latin_hypercube/gold/latin_hypercube_small_data_0000.csv index 1df9399b1360..224cdf09d7c8 100644 --- a/modules/stochastic_tools/test/tests/samplers/latin_hypercube/gold/latin_hypercube_small_data_0000.csv +++ b/modules/stochastic_tools/test/tests/samplers/latin_hypercube/gold/latin_hypercube_small_data_0000.csv @@ -1,3 +1,3 @@ sample_0,sample_1 -194.4725504039,17.276982282367 -112.22857657292,14.701368766803 +112.22857657292,19.44725504039 +183.37102406126,12.245099029532 diff --git a/modules/stochastic_tools/test/tests/samplers/latin_hypercube/gold/latin_hypercube_small_data_0001.csv b/modules/stochastic_tools/test/tests/samplers/latin_hypercube/gold/latin_hypercube_small_data_0001.csv index 8e1ccc3768d7..c76531e08148 100644 --- a/modules/stochastic_tools/test/tests/samplers/latin_hypercube/gold/latin_hypercube_small_data_0001.csv +++ b/modules/stochastic_tools/test/tests/samplers/latin_hypercube/gold/latin_hypercube_small_data_0001.csv @@ -1,3 +1,3 @@ sample_0,sample_1 -172.45099029532,17.509260036919 -133.37102406126,10.907460931034 +182.38263641144,10.967095228789 +120.98359300461,17.179169757425 diff --git a/modules/stochastic_tools/test/tests/samplers/mcmc/gold/des_5prop.json b/modules/stochastic_tools/test/tests/samplers/mcmc/gold/des_5prop.json index b7fe197895ae..37d4751b50e9 100644 --- a/modules/stochastic_tools/test/tests/samplers/mcmc/gold/des_5prop.json +++ b/modules/stochastic_tools/test/tests/samplers/mcmc/gold/des_5prop.json @@ -133,24 +133,24 @@ "mcmc_reporter": { "inputs": [ [ - -1.4820258793890648, - -0.6151890803293827 + 0.1, + 0.1 ], [ - -0.4967511920819634, - -0.3004783969190312 + 0.1, + 0.1 ], [ - 0.007752342311301286, - -0.09027480045486813 + 0.1, + 0.1 ], [ - 2.3523040131058344, - -0.529586904497553 + 0.1, + 0.1 ], [ - 0.6217381479931623, - -0.8625185543183977 + 0.1, + 0.1 ] ], "noise": 0.0, diff --git a/modules/stochastic_tools/test/tests/samplers/mcmc/gold/des_5prop_var.json b/modules/stochastic_tools/test/tests/samplers/mcmc/gold/des_5prop_var.json index d0244725881d..251b5fb66bba 100644 --- a/modules/stochastic_tools/test/tests/samplers/mcmc/gold/des_5prop_var.json +++ b/modules/stochastic_tools/test/tests/samplers/mcmc/gold/des_5prop_var.json @@ -122,24 +122,24 @@ "mcmc_reporter": { "inputs": [ [ - -1.4820258793890648, - -0.6151890803293827 + 0.1, + 0.1 ], [ - -0.4967511920819634, - -0.3004783969190312 + 0.1, + 0.1 ], [ - 0.37899624497629225, - -1.5795654951651612 + 0.1, + 0.1 ], [ - 1.4228832875601982, - -0.7320502717637679 + 0.1, + 0.1 ], [ - 0.6220898958609982, - 1.7665539146749398 + 0.1, + 0.1 ] ], "noise": 0.0, diff --git a/modules/stochastic_tools/test/tests/samplers/mcmc/gold/imh_5prop.json b/modules/stochastic_tools/test/tests/samplers/mcmc/gold/imh_5prop.json index 2c402680f65e..21a98d0d5dad 100644 --- a/modules/stochastic_tools/test/tests/samplers/mcmc/gold/imh_5prop.json +++ b/modules/stochastic_tools/test/tests/samplers/mcmc/gold/imh_5prop.json @@ -137,24 +137,24 @@ "mcmc_reporter": { "inputs": [ [ - 0.0424499745659241, - 0.03911894688212181 + 0.1, + 0.1 ], [ - 0.19000647285369757, - 0.1100295238944248 + 0.1, + 0.1 ], [ - 0.042490963881673185, - 0.025898706030546767 + 0.1, + 0.1 ], [ - 0.02648203329171317, - 0.06924054598353087 + 0.1, + 0.1 ], [ - 0.20231647876098566, - 0.08578661353082914 + 0.1, + 0.1 ] ], "noise": 0.0, @@ -171,8 +171,8 @@ 0.07329136264166623 ], "seed_input": [ - 0.20231647876098566, - 0.08578661353082914 + 0.1, + 0.1 ], "tpm": [ 1.0, diff --git a/modules/stochastic_tools/test/tests/samplers/mcmc/gold/mcmc_base.json b/modules/stochastic_tools/test/tests/samplers/mcmc/gold/mcmc_base.json index aa938cdf2fa6..4cb5f2bbe3fb 100644 --- a/modules/stochastic_tools/test/tests/samplers/mcmc/gold/mcmc_base.json +++ b/modules/stochastic_tools/test/tests/samplers/mcmc/gold/mcmc_base.json @@ -101,12 +101,12 @@ "mcmc_reporter": { "inputs": [ [ - -1.151000508681518, - -1.2176210623575638 + 0.1, + 0.1 ], [ - 1.800129457073951, - 0.20059047788849593 + 0.1, + 0.1 ] ], "noise": 0.0, diff --git a/modules/stochastic_tools/test/tests/samplers/mcmc/gold/mcmc_base_bounds.json b/modules/stochastic_tools/test/tests/samplers/mcmc/gold/mcmc_base_bounds.json index aa938cdf2fa6..4cb5f2bbe3fb 100644 --- a/modules/stochastic_tools/test/tests/samplers/mcmc/gold/mcmc_base_bounds.json +++ b/modules/stochastic_tools/test/tests/samplers/mcmc/gold/mcmc_base_bounds.json @@ -101,12 +101,12 @@ "mcmc_reporter": { "inputs": [ [ - -1.151000508681518, - -1.2176210623575638 + 0.1, + 0.1 ], [ - 1.800129457073951, - 0.20059047788849593 + 0.1, + 0.1 ] ], "noise": 0.0, diff --git a/modules/stochastic_tools/test/tests/samplers/mcmc/gold/ss_5prop.json b/modules/stochastic_tools/test/tests/samplers/mcmc/gold/ss_5prop.json index 28679797ab37..e3df3fb62e09 100644 --- a/modules/stochastic_tools/test/tests/samplers/mcmc/gold/ss_5prop.json +++ b/modules/stochastic_tools/test/tests/samplers/mcmc/gold/ss_5prop.json @@ -133,24 +133,24 @@ "mcmc_reporter": { "inputs": [ [ - 0.20059047788849593, - -1.1501807223665363 + 0.1, + 0.1 ], [ - -0.6151890803293827, - 2.046329575219713 + 0.1, + 0.1 ], [ - 0.3465047883523662, - -0.6846181095208007 + 0.1, + 0.1 ], [ - 0.16348449143171506, - 1.379721328078273 + 0.1, + 0.1 ], [ - 0.37899624497629225, - -0.09027480045486813 + 0.1, + 0.1 ] ], "noise": 0.0, diff --git a/modules/stochastic_tools/test/tests/samplers/mcmc/main_base.i b/modules/stochastic_tools/test/tests/samplers/mcmc/main_base.i index b21f0cdca17e..e5751a907781 100644 --- a/modules/stochastic_tools/test/tests/samplers/mcmc/main_base.i +++ b/modules/stochastic_tools/test/tests/samplers/mcmc/main_base.i @@ -30,8 +30,9 @@ num_parallel_proposals = 2 initial_values = '0.1 0.1' file_name = 'confg.csv' - execute_on = PRE_MULTIAPP_SETUP + execute_on = 'PRE_MULTIAPP_SETUP timestep_end' seed = 2547 + num_random_seeds = 100 [] [] @@ -76,6 +77,7 @@ output_value = constant/reporter_transfer:average:value sampler = sample likelihoods = 'gaussian' + execute_on = 'timestep_begin' [] [] diff --git a/modules/stochastic_tools/test/tests/samplers/mcmc/main_des.i b/modules/stochastic_tools/test/tests/samplers/mcmc/main_des.i index d0a86d799c38..844bcfbf52ba 100644 --- a/modules/stochastic_tools/test/tests/samplers/mcmc/main_des.i +++ b/modules/stochastic_tools/test/tests/samplers/mcmc/main_des.i @@ -29,8 +29,9 @@ prior_distributions = 'left right' num_parallel_proposals = 5 file_name = 'confg.csv' - execute_on = PRE_MULTIAPP_SETUP + execute_on = 'PRE_MULTIAPP_SETUP TIMESTEP_END' seed = 2547 + num_random_seeds = 100 initial_values = '0.1 0.1' previous_state = 'mcmc_reporter/inputs' previous_state_var = 'mcmc_reporter/variance' @@ -78,6 +79,7 @@ output_value = constant/reporter_transfer:average:value sampler = sample likelihoods = 'gaussian' + execute_on = 'timestep_begin' [] [] diff --git a/modules/stochastic_tools/test/tests/samplers/mcmc/main_des_var.i b/modules/stochastic_tools/test/tests/samplers/mcmc/main_des_var.i index fa2452150ae8..3e4351261bd1 100644 --- a/modules/stochastic_tools/test/tests/samplers/mcmc/main_des_var.i +++ b/modules/stochastic_tools/test/tests/samplers/mcmc/main_des_var.i @@ -34,8 +34,9 @@ prior_distributions = 'left right' num_parallel_proposals = 5 file_name = 'confg.csv' - execute_on = PRE_MULTIAPP_SETUP + execute_on = 'PRE_MULTIAPP_SETUP TIMESTEP_END' seed = 2547 + num_random_seeds = 100 initial_values = '0.1 0.1' previous_state = 'mcmc_reporter/inputs' previous_state_var = 'mcmc_reporter/variance' @@ -79,6 +80,7 @@ output_value = constant/reporter_transfer:average:value sampler = sample likelihoods = 'gaussian' + execute_on = 'timestep_begin' [] [] diff --git a/modules/stochastic_tools/test/tests/samplers/mcmc/main_imh.i b/modules/stochastic_tools/test/tests/samplers/mcmc/main_imh.i index dcee6b40a3d7..451b2c491898 100644 --- a/modules/stochastic_tools/test/tests/samplers/mcmc/main_imh.i +++ b/modules/stochastic_tools/test/tests/samplers/mcmc/main_imh.i @@ -30,8 +30,9 @@ # previous_state = 'mcmc_reporter/inputs' num_parallel_proposals = 5 file_name = 'confg.csv' - execute_on = PRE_MULTIAPP_SETUP + execute_on = 'PRE_MULTIAPP_SETUP TIMESTEP_END' seed = 2547 + num_random_seeds = 100 std_prop = '0.05 0.05' initial_values = '0.1 0.1' seed_inputs = 'mcmc_reporter/seed_input' @@ -79,6 +80,7 @@ output_value = constant/reporter_transfer:average:value sampler = sample likelihoods = 'gaussian' + execute_on = 'timestep_begin' [] [] diff --git a/modules/stochastic_tools/test/tests/samplers/mcmc/main_ss.i b/modules/stochastic_tools/test/tests/samplers/mcmc/main_ss.i index 39ceb68a5908..4e011727459b 100644 --- a/modules/stochastic_tools/test/tests/samplers/mcmc/main_ss.i +++ b/modules/stochastic_tools/test/tests/samplers/mcmc/main_ss.i @@ -29,8 +29,9 @@ prior_distributions = 'left right' num_parallel_proposals = 5 file_name = 'confg.csv' - execute_on = PRE_MULTIAPP_SETUP + execute_on = 'PRE_MULTIAPP_SETUP TIMESTEP_END' seed = 2547 + num_random_seeds = 100 initial_values = '0.1 0.1' previous_state = 'mcmc_reporter/inputs' previous_state_var = 'mcmc_reporter/variance' @@ -78,6 +79,7 @@ output_value = constant/reporter_transfer:average:value sampler = sample likelihoods = 'gaussian' + execute_on = timestep_begin [] [] diff --git a/modules/stochastic_tools/test/tests/surrogates/cross_validation/gold/poly_reg_vec_out.json b/modules/stochastic_tools/test/tests/surrogates/cross_validation/gold/poly_reg_vec_out.json index 9fdedbe45f95..d9a5791e4bed 100644 --- a/modules/stochastic_tools/test/tests/surrogates/cross_validation/gold/poly_reg_vec_out.json +++ b/modules/stochastic_tools/test/tests/surrogates/cross_validation/gold/poly_reg_vec_out.json @@ -14,54 +14,54 @@ "cv_scores": { "pr_surrogate": [ [ - 0.39228163619112805, - 0.36817483431068343, - 0.19838417441426281 + 0.5639504668748508, + 0.6038682214506194, + 0.49843176621298735 ], [ - 0.3874386534834154, - 0.36362946681090325, - 0.19593498760444017 + 0.5569881155550612, + 0.5964130585925984, + 0.49227828788802297 ], [ - 0.37290970409822854, - 0.34999336373278744, - 0.18858742566653902 + 0.5361010622665149, + 0.5740475709003013, + 0.47381785310088714 ], [ - 0.34869478879639354, - 0.3272665219457356, - 0.17634148968178365 + 0.501289304448875, + 0.5367717543340342, + 0.44305045964896683 ], [ - 0.3147939068872063, - 0.29544894458545773, - 0.1591971799923226 + 0.4525528443975183, + 0.4845856114137542, + 0.3999761094130786 ], [ - 0.2712070581257691, - 0.2545406295497551, - 0.1371544935141087 + 0.38989168071670555, + 0.4174891414650064, + 0.34459480174310675 ], [ - 0.21793424306134365, - 0.20454157557170052, - 0.1102134312498814 + 0.31330581560234566, + 0.3354823468872781, + 0.27690653738130844 ], [ - 0.1549754623603091, - 0.14545178865297465, - 0.07837399554442515 + 0.2227952466994414, + 0.2385652240858907, + 0.1969113155966501 ], [ - 0.0823307141340953, - 0.07727126147093685, - 0.04163618465490677 + 0.11835997487605741, + 0.12673777524251906, + 0.10460913644205212 ], [ - 1.4598912791818302e-12, - 3.013237410572986e-13, - 2.920667743334236e-13 + 2.5357517214610497e-13, + 2.9536706862851543e-13, + 1.3451608044987588e-13 ] ] }, @@ -69,4 +69,4 @@ "time_step": 2 } ] -} +} \ No newline at end of file diff --git a/modules/stochastic_tools/test/tests/surrogates/multioutput_gp/gold/mogp_lmc_out.json b/modules/stochastic_tools/test/tests/surrogates/multioutput_gp/gold/mogp_lmc_out.json index df5f804a76e0..4c9b669f12d9 100644 --- a/modules/stochastic_tools/test/tests/surrogates/multioutput_gp/gold/mogp_lmc_out.json +++ b/modules/stochastic_tools/test/tests/surrogates/multioutput_gp/gold/mogp_lmc_out.json @@ -69,46 +69,46 @@ "eval_test": { "mogp": [ [ - 1079.5504087003249, - 1075.7692619474292 + 999.9730073364786, + 995.9865853885307 ], [ - 1218.0140276241268, - 1214.1984968231504 + 913.875162766298, + 911.0353974038018 ], [ - 1146.3252482744906, - 1141.4803686249772 + 1081.9407187058193, + 1077.5777502118683 ], [ - 1008.205433803455, - 1004.7163073438328 + 1122.9164147827867, + 1119.1055656357187 ], [ - 984.914743543104, - 980.4296617766602 + 1221.612826747968, + 1217.0799888657987 ] ], "mogp_std": [ [ - 0.4205492681822833, - 0.3508496804652267 + 1.7929545070829407, + 1.498087212499234 ], [ - 5.013585535855138, - 4.18266066914317 + 85.15192795645504, + 71.14793704346155 ], [ - 3.546419329151843, - 2.9586547470167384 + 0.8367776605959218, + 0.6991621416491969 ], [ - 1.2850556886716182, - 1.0720774281319578 + 0.5612000829824193, + 0.4689057444544821 ], [ - 7.784615170432469, - 6.494434664673946 + 3.3676867934954413, + 2.8138407868740596 ] ] }, @@ -140,48 +140,48 @@ }, "test_params": { "test_0": [ - 15.7355174464422, - 15.503553594448407, - 12.233592276953424, - 17.060268838826943, - 13.339869309671009 + 14.916260099009754, + 21.471331024177008, + 13.64173243113679, + 15.606554486473595, + 13.174244995144239 ], "test_1": [ - 1000.8228474885008, - 1139.6182925278092, - 1046.3026637606572, - 935.7445601572424, - 890.641719542586 + 916.9934654835504, + 828.8272171608788, + 991.3196102527208, + 1043.7431628125269, + 1126.7652444132264 ] }, "time": 2.0, "time_step": 2, "train_params": { "train_0": [ - 12.718054364287969, - 15.918473419240122, - 12.424959220511393, - 16.428240850263645, - 16.893176439469773, - 19.626963232906053, - 14.957446012929386, - 15.139897805359167, - 14.417027312478066, - 13.813236996491042 + 13.309291115550094, + 15.915661282875138, + 12.33700093310706, + 13.816254474259654, + 14.637449073682674, + 13.973898841881988, + 16.266396685150163, + 17.112962742526317, + 15.360332546139038, + 17.638184131778473 ], "train_1": [ - 1163.5963741616458, - 1047.7074769942144, - 1075.0551262941908, - 933.3550386727048, - 826.9745573064158, - 900.402623498398, - 1112.338211090383, - 1005.5659774649754, - 983.3829236911387, - 959.8028514303128 + 981.5831456146575, + 1021.5572993079797, + 1146.020290135013, + 1041.9086791445945, + 944.5598090000127, + 949.5937102220256, + 860.8313221237175, + 1114.7610139029823, + 1081.3899223980245, + 900.1924401569784 ] } } ] -} +} \ No newline at end of file diff --git a/modules/stochastic_tools/test/tests/surrogates/multioutput_gp/gold/mogp_lmc_tuned_out.json b/modules/stochastic_tools/test/tests/surrogates/multioutput_gp/gold/mogp_lmc_tuned_out.json index 1ce3027d614e..4407f580b889 100644 --- a/modules/stochastic_tools/test/tests/surrogates/multioutput_gp/gold/mogp_lmc_tuned_out.json +++ b/modules/stochastic_tools/test/tests/surrogates/multioutput_gp/gold/mogp_lmc_tuned_out.json @@ -69,119 +69,119 @@ "eval_test": { "mogp": [ [ - 1079.5270760906988, - 1075.7459299718184 + 999.990383203881, + 996.0030762567673 ], [ - 1218.1709855578933, - 1214.35298275913 + 910.5549625664881, + 907.7537120775887 ], [ - 1146.4481311923983, - 1141.6004941293086 + 1081.9517914877429, + 1077.5892437043653 ], [ - 1008.2169947555705, - 1004.7274950904595 + 1122.9405001536138, + 1119.129499757143 ], [ - 984.8519799854911, - 980.3710519287231 + 1221.4505993546463, + 1216.9197013049982 ] ], "mogp_std": [ [ - 0.21956508562322755, - 0.16456589756038692 + 0.9797574184271025, + 0.7390727880608372 ], [ - 2.7740958716761748, - 2.079208430485741 + 51.195379787848296, + 38.61885744755256 ], [ - 1.9871689339660743, - 1.4894000031062107 + 0.45415194805112247, + 0.34258617506745204 ], [ - 0.718871702923493, - 0.5388004503530526 + 0.313301154101191, + 0.23633641664779773 ], [ - 4.435081177817905, - 3.324131032693366 + 1.9364418593933657, + 1.46074064560913 ] ] }, "hyperparams": { "covar:length_factor0": [ - 3.8014545458929785 + 3.8012173068387693 ], "covar:length_factor1": [ - 2.8255111697852247 + 2.817689126704668 ], "covar:noise_variance": [ 0.0 ], "covar:signal_variance": [ - 2.031851154853702 + 2.0358904441567236 ], "lmc:acoeff_00": [ - 0.8055415690112186 + 0.8225257100582211 ], "lmc:acoeff_01": [ - 0.7942250628239875 + 0.8122545583753501 ], "lmc:lambda_00": [ - 2.5080966924599517 + 2.5095065546397626 ], "lmc:lambda_01": [ - 1.1557080583863042 + 1.1609486867864975 ] }, "test_params": { "test_0": [ - 15.7355174464422, - 15.503553594448407, - 12.233592276953424, - 17.060268838826946, - 13.339869309671009 + 14.916260099009754, + 21.471331024177008, + 13.64173243113679, + 15.606554486473595, + 13.174244995144239 ], "test_1": [ - 1000.8228474885009, - 1139.6182925278092, - 1046.3026637606572, - 935.7445601572424, - 890.641719542586 + 916.9934654835504, + 828.8272171608788, + 991.3196102527208, + 1043.7431628125269, + 1126.7652444132264 ] }, "time": 2.0, "time_step": 2, "train_params": { "train_0": [ - 12.718054364287967, - 15.918473419240122, - 12.424959220511393, - 16.428240850263645, - 16.893176439469773, - 19.626963232906053, - 14.957446012929386, - 15.139897805359167, - 14.417027312478066, - 13.813236996491042 + 13.309291115550094, + 15.915661282875138, + 12.33700093310706, + 13.816254474259654, + 14.637449073682674, + 13.973898841881988, + 16.266396685150163, + 17.112962742526317, + 15.360332546139038, + 17.638184131778473 ], "train_1": [ - 1163.5963741616458, - 1047.7074769942144, - 1075.055126294191, - 933.3550386727048, - 826.9745573064158, - 900.402623498398, - 1112.338211090383, - 1005.5659774649754, - 983.3829236911387, - 959.8028514303128 + 981.5831456146575, + 1021.5572993079797, + 1146.020290135013, + 1041.9086791445945, + 944.5598090000127, + 949.5937102220256, + 860.8313221237175, + 1114.7610139029823, + 1081.3899223980245, + 900.1924401569784 ] } } ] -} +} \ No newline at end of file diff --git a/modules/stochastic_tools/test/tests/surrogates/nearest_point/gold/np_vec_out.json b/modules/stochastic_tools/test/tests/surrogates/nearest_point/gold/np_vec_out.json index 60148e6fc1ff..797a872471bb 100644 --- a/modules/stochastic_tools/test/tests/surrogates/nearest_point/gold/np_vec_out.json +++ b/modules/stochastic_tools/test/tests/surrogates/nearest_point/gold/np_vec_out.json @@ -16,123 +16,123 @@ "eval": { "np_surrogate": [ [ - 301.1560951357245, - 301.141822356779, - 301.09900401853855, - 301.0276401223924, - 300.92773066701693, - 300.7992756520809, - 300.64227507599446, - 300.456728943366, - 300.24263725119044, + 300.7789814472635, + 300.7693643922704, + 300.74051322757055, + 300.69242795315074, + 300.6251085687841, + 300.5385550745946, + 300.43276747067443, + 300.30774575692885, + 300.1634899333918, 300.0 ], [ - 300.918559754473, - 300.9072195110201, - 300.87319878138675, - 300.81649756117093, - 300.73711585178137, - 300.6350536579572, - 300.51031097439505, - 300.36288780647806, - 300.192784146221, + 303.0143754870068, + 302.9771609738536, + 302.86551743970847, + 302.67944487821245, + 302.41894329250266, + 302.08401268186236, + 301.6746530506307, + 301.1908643918829, + 300.6326467084406, 299.99999999999994 ], [ - 300.4961940823748, - 300.4900682294792, - 300.4716906690211, - 300.4410614053511, - 300.398180435213, - 300.3430477593552, - 300.27566338085916, - 300.1960272906678, - 300.10413949775045, + 300.95483231918814, + 300.94304426589514, + 300.9076801059234, + 300.84873983939235, + 300.7662234660961, + 300.6601309860459, + 300.5304623994907, + 300.37721770653536, + 300.2003969065855, 300.0 ], [ - 302.04504732191833, - 302.0197998246835, - 301.9440573310685, - 301.8178198435339, - 301.6410873595378, - 301.4138598784298, - 301.13613740309444, - 300.8079199315849, - 300.4292074635516, + 302.1807661052252, + 302.1538430665809, + 302.07307395108785, + 301.9384587591528, + 301.74999749136185, + 301.5076901463325, + 301.21153672441653, + 300.8615372264014, + 300.4576916517092, 300.0 ], [ - 300.52259768517035, - 300.5161458619069, - 300.4967903920899, - 300.46453127572744, - 300.4193685128082, - 300.3613021033409, - 300.2903320473225, - 300.2064583447627, - 300.10968099565287, + 300.4701521905414, + 300.46434784278483, + 300.4469347978368, + 300.41791305777934, + 300.37728262125466, + 300.32504348901017, + 300.26119566040285, + 300.1857391369796, + 300.0986739170043, 300.0 ], [ - 300.39829455507476, - 300.3933773385804, - 300.37862568922424, - 300.354039605448, - 300.3196190880399, - 300.2753641381967, - 300.22127475371207, - 300.15735093620765, - 300.0835926858058, - 299.99999999999994 + 301.05338514427353, + 301.0403803896625, + 301.00136612640523, + 300.93634235281246, + 300.84530906804224, + 300.72826627242824, + 300.585213970764, + 300.41615215611506, + 300.22108083309394, + 300.0 ], [ - 300.66671462128954, - 300.658483576623, - 300.63379044233113, - 300.5926352189785, - 300.5350179065822, - 300.46093850391395, - 300.37039701240286, - 300.2633934310553, - 300.13992776025935, + 301.4243211558448, + 301.4067369419056, + 301.35398430562884, + 301.2660632470466, + 301.1429737643208, + 300.9847158590496, + 300.7912895310364, + 300.56269477858643, + 300.2989316011793, 300.0 ], [ - 301.61762700541937, - 301.5976563011386, - 301.5377441890913, - 301.4378906705972, - 301.29809574125005, - 301.1183594074736, - 300.8986816689825, - 300.63906252032643, - 300.3395019656584, + 300.3954060849819, + 300.39052452827497, + 300.37587985857317, + 300.35147207545833, + 300.31730117894506, + 300.2733671699184, + 300.2196700473374, + 300.1562098104848, + 300.082986461737, 300.0 ], [ - 301.09887779918324, - 301.08531140687467, - 301.0446122308759, - 300.9767802671886, - 300.88181551867956, - 300.7597179855753, - 300.6104876658181, - 300.4341245621745, - 300.23062867327343, + 300.244187170522, + 300.24117251415163, + 300.23212854638103, + 300.21705526435017, + 300.1959526680285, + 300.168820761993, + 300.1356595404561, + 300.09646900642497, + 300.0512491590699, 300.0 ], [ - 300.8793677166114, - 300.8685113239527, - 300.83594215003563, - 300.7816601912647, - 300.7056654511175, - 300.60795792608207, - 300.48853761980774, - 300.3474045290813, - 300.1845586567317, + 301.43209203340376, + 301.4144118853661, + 301.3613714397615, + 301.2729706974534, + 301.1492096569896, + 300.9900883209893, + 300.7956066850989, + 300.5657647537965, + 300.3005625255833, 300.0 ] ] @@ -141,4 +141,4 @@ "time_step": 1 } ] -} +} \ No newline at end of file diff --git a/modules/stochastic_tools/test/tests/surrogates/pod_rb/boundary/gold/surr_out_res_0001.csv b/modules/stochastic_tools/test/tests/surrogates/pod_rb/boundary/gold/surr_out_res_0001.csv index b7fc60a67f38..5c7c708497e5 100644 --- a/modules/stochastic_tools/test/tests/surrogates/pod_rb/boundary/gold/surr_out_res_0001.csv +++ b/modules/stochastic_tools/test/tests/surrogates/pod_rb/boundary/gold/surr_out_res_0001.csv @@ -1,11 +1,11 @@ rbpod:nodal_max -0.8299344749096 -0.79753642947107 -1.049097403152 -1.016095473237 -2.6193849406566 -1.4543333557344 -1.496885459918 -0.932488663847 -0.71468267891463 -1.1262858340591 +1.3041030388159 +0.85104839533939 +1.5163135241144 +0.85425758698512 +1.8115117542964 +1.0294537358406 +1.0837771676986 +0.63221020694505 +0.55685954129473 +1.2287316790502 diff --git a/modules/stochastic_tools/test/tests/surrogates/pod_rb/internal/gold/eigenvalues_u.csv b/modules/stochastic_tools/test/tests/surrogates/pod_rb/internal/gold/eigenvalues_u.csv index 8bb1fc369392..1e6cecef7caa 100644 --- a/modules/stochastic_tools/test/tests/surrogates/pod_rb/internal/gold/eigenvalues_u.csv +++ b/modules/stochastic_tools/test/tests/surrogates/pod_rb/internal/gold/eigenvalues_u.csv @@ -1,4 +1,4 @@ evs -4.04715302e+01 -3.75134244e-02 -3.63247800e-06 +3.62369329e+01 +1.49306776e-02 +4.87946367e-06 diff --git a/modules/stochastic_tools/test/tests/surrogates/pod_rb/internal/gold/surr_out_res_0001.csv b/modules/stochastic_tools/test/tests/surrogates/pod_rb/internal/gold/surr_out_res_0001.csv index fca5f1f5d7c6..389f0a18e02f 100644 --- a/modules/stochastic_tools/test/tests/surrogates/pod_rb/internal/gold/surr_out_res_0001.csv +++ b/modules/stochastic_tools/test/tests/surrogates/pod_rb/internal/gold/surr_out_res_0001.csv @@ -1,11 +1,11 @@ rbpod:nodal_max -1.2792722913989 -0.61527786545129 -0.90816145926636 -1.3686463006526 -0.64360768638772 -0.5782669093333 -1.1785954811739 -1.0180183285229 -1.2118482050335 -1.6674669956512 +1.2909730605806 +0.75578242067587 +1.48479695763 +0.85834136611366 +1.8172798196487 +1.0815648290895 +1.0739156134323 +0.41957850591789 +0.52225761522085 +1.2043779571205 diff --git a/modules/stochastic_tools/test/tests/surrogates/pod_rb/internal/gold/trainer_and_surr_out_res_0002.csv b/modules/stochastic_tools/test/tests/surrogates/pod_rb/internal/gold/trainer_and_surr_out_res_0002.csv index fca5f1f5d7c6..389f0a18e02f 100644 --- a/modules/stochastic_tools/test/tests/surrogates/pod_rb/internal/gold/trainer_and_surr_out_res_0002.csv +++ b/modules/stochastic_tools/test/tests/surrogates/pod_rb/internal/gold/trainer_and_surr_out_res_0002.csv @@ -1,11 +1,11 @@ rbpod:nodal_max -1.2792722913989 -0.61527786545129 -0.90816145926636 -1.3686463006526 -0.64360768638772 -0.5782669093333 -1.1785954811739 -1.0180183285229 -1.2118482050335 -1.6674669956512 +1.2909730605806 +0.75578242067587 +1.48479695763 +0.85834136611366 +1.8172798196487 +1.0815648290895 +1.0739156134323 +0.41957850591789 +0.52225761522085 +1.2043779571205 diff --git a/modules/stochastic_tools/test/tests/surrogates/poly_chaos/main_2d_quad.i b/modules/stochastic_tools/test/tests/surrogates/poly_chaos/main_2d_quad.i index 027b42927595..eeb3357c14bd 100644 --- a/modules/stochastic_tools/test/tests/surrogates/poly_chaos/main_2d_quad.i +++ b/modules/stochastic_tools/test/tests/surrogates/poly_chaos/main_2d_quad.i @@ -19,12 +19,10 @@ type = MonteCarlo num_rows = 100 distributions = 'D_dist S_dist' - execute_on = timestep_end [] [quadrature] type = Quadrature distributions = 'D_dist S_dist' - execute_on = INITIAL order = 5 [] [] diff --git a/modules/stochastic_tools/test/tests/surrogates/poly_chaos/main_2dnorm_quad.i b/modules/stochastic_tools/test/tests/surrogates/poly_chaos/main_2dnorm_quad.i index 8a43cbe9bf91..d09778ccbc24 100644 --- a/modules/stochastic_tools/test/tests/surrogates/poly_chaos/main_2dnorm_quad.i +++ b/modules/stochastic_tools/test/tests/surrogates/poly_chaos/main_2dnorm_quad.i @@ -19,12 +19,10 @@ type = MonteCarlo num_rows = 100 distributions = 'D_dist S_dist' - execute_on = timestep_end [] [quadrature] type = Quadrature distributions = 'D_dist S_dist' - execute_on = INITIAL order = 5 [] [] diff --git a/modules/stochastic_tools/test/tests/surrogates/polynomial_regression/gold/poly_reg_vec_out.json b/modules/stochastic_tools/test/tests/surrogates/polynomial_regression/gold/poly_reg_vec_out.json index 3d6469179889..8ff018a9d245 100644 --- a/modules/stochastic_tools/test/tests/surrogates/polynomial_regression/gold/poly_reg_vec_out.json +++ b/modules/stochastic_tools/test/tests/surrogates/polynomial_regression/gold/poly_reg_vec_out.json @@ -16,124 +16,124 @@ "eval": { "pr_surrogate": [ [ - 301.13570737712007, - 301.12168629824043, - 301.0796230628788, - 301.00951766902546, - 300.91137011708776, - 300.78518040866703, - 300.6309485423772, - 300.44867451978155, - 300.2383583390011, - 300.0000000000006 + 300.68995758624897, + 300.68143959147335, + 300.65588560645676, + 300.61329563241634, + 300.5536696679164, + 300.4770077137481, + 300.3833097699095, + 300.2725758362943, + 300.14480591326185, + 300.00000000000296 ], [ - 300.93304770434247, - 300.921528596832, - 300.886971275307, - 300.82937573781095, - 300.74874198563043, - 300.6450700184281, - 300.5183598358236, - 300.36861143964757, - 300.1958248270709, - 300.00000000000193 + 302.87016135906674, + 302.83472726691315, + 302.72842499568026, + 302.55125454088653, + 302.30321590474597, + 301.9843090867282, + 301.5945340896902, + 301.13389090904917, + 300.60237954574234, + 300.0000000000003 ], [ - 300.51838600798754, - 300.51198618091706, - 300.4927866979977, - 300.4607875622228, - 300.4159887714615, - 300.35839032621243, - 300.28799222845606, - 300.2047944718225, - 300.1087970629016, - 299.9999999999985 + 301.0390304049892, + 301.026202869154, + 300.98772026217836, + 300.9235825830053, + 300.8337898317473, + 300.71834200815647, + 300.57723911453434, + 300.410481148138, + 300.21806810996355, + 299.9999999999994 ], [ - 302.0217475836702, - 301.99678773742596, - 301.921908196783, - 301.7971089646525, - 301.6223900378719, - 301.3977514165789, - 301.12319310384544, - 300.7987150964782, - 300.4243173948312, - 300.0000000000003 + 302.23353825126577, + 302.20596370502864, + 302.1232400661828, + 301.98536733443416, + 301.79234551054793, + 301.54417459362674, + 301.24085458377556, + 300.882385481743, + 300.4687672873387, + 299.9999999999961 ], [ - 300.5620093370334, - 300.55507095025035, - 300.53425579048036, - 300.49956385582294, - 300.4509951479506, - 300.38854966610154, - 300.31222740960374, - 300.22202838057706, - 300.1179525773837, - 300.00000000000045 + 300.59436606267906, + 300.5870282105972, + 300.56501465262966, + 300.5283253893506, + 300.47696042070214, + 300.41091974684883, + 300.330203367688, + 300.2348112838321, + 300.1247434948852, + 300.00000000000034 ], [ - 300.3388603715956, - 300.3346769101145, - 300.32212652551607, - 300.3012092187148, - 300.2719249883924, - 300.2342738364555, - 300.18825576253886, - 300.13387076388597, - 300.071118844153, - 299.9999999999985 + 300.8623642671996, + 300.85171779480606, + 300.8197783773216, + 300.76654601568777, + 300.6920207084674, + 300.5962024563222, + 300.4790912595838, + 300.34068711768936, + 300.18099003133733, + 300.00000000000165 ], [ - 300.68727344729984, - 300.6787885899666, - 300.6533340179853, - 300.6109097311589, - 300.55151572977326, - 300.47515201339013, - 300.3818185826264, - 300.27151543648085, - 300.1442425752968, - 300.000000000001 + 301.61275999341416, + 301.59284937496955, + 301.53311752408587, + 301.43356443842475, + 301.2941901174413, + 301.1149945631503, + 300.8959777753477, + 300.637139751523, + 300.3384804929227, + 300.00000000000244 ], [ - 301.6504016367478, - 301.6300263077265, - 301.5689003207173, - 301.4670236771793, - 301.32439637302036, - 301.1410184136293, - 300.9168897980191, - 300.6520105233496, - 300.3463805921977, - 299.9999999999976 + 300.3667979913619, + 300.3622696210482, + 300.3486845105444, + 300.3260426593886, + 300.29434406686005, + 300.2535887353348, + 300.20377666213346, + 300.1449078484877, + 300.07698229438785, + 299.99999999999926 ], [ - 301.0887384682577, - 301.0752972528015, - 301.0349736071001, - 300.9677675282569, - 300.8736790184276, - 300.75270807751315, - 300.6048547042595, - 300.43011890021876, - 300.2285006653157, - 299.99999999999926 + 300.19555282720324, + 300.19313859452575, + 300.1858958981168, + 300.17382473595774, + 300.15692510790944, + 300.13519701770326, + 300.1086404603696, + 300.0772554382002, + 300.0410419510221, + 299.99999999999534 ], [ - 300.86320374318444, - 300.8525469067633, - 300.8205763988967, - 300.76729221680887, - 300.6926943624107, - 300.5967828354301, - 300.47955763483867, - 300.34101876346233, - 300.1811662179442, - 300.0000000000018 + 301.4839703948227, + 301.4656497722298, + 301.41068790567954, + 301.3190847952565, + 301.1908404399877, + 301.0259548406054, + 300.8244279972761, + 300.58625990917767, + 300.3114505769319, + 300.0000000000024 ] ] }, @@ -141,4 +141,4 @@ "time_step": 1 } ] -} +} \ No newline at end of file diff --git a/test/src/samplers/TestSampler.C b/test/src/samplers/TestSampler.C index 3ee09aeae4a6..587508a4802b 100644 --- a/test/src/samplers/TestSampler.C +++ b/test/src/samplers/TestSampler.C @@ -75,7 +75,7 @@ TestSampler::computeSample(dof_id_type row_index, dof_id_type col_index) setNumberOfRandomSeeds(1980); if (_use_rand) - return getRand(); + return getRand(row_index * getNumberOfCols() + col_index); else return ((row_index + 1) * 10) + col_index; } diff --git a/test/tests/samplers/base/errors.i b/test/tests/samplers/base/errors.i index 63f5125fbbbb..1c8ecc475e6c 100644 --- a/test/tests/samplers/base/errors.i +++ b/test/tests/samplers/base/errors.i @@ -13,7 +13,6 @@ [Samplers] [sample] type = TestSampler - execute_on = 'INITIAL TIMESTEP_END' [] [] diff --git a/unit/src/MooseRandomPerturbationTest.C b/unit/src/MooseRandomPerturbationTest.C new file mode 100644 index 000000000000..23f0976a4062 --- /dev/null +++ b/unit/src/MooseRandomPerturbationTest.C @@ -0,0 +1,145 @@ +//* This file is part of the MOOSE framework +//* https://mooseframework.inl.gov +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#include "gtest/gtest.h" + +#include "MooseRandomPerturbation.h" + +#include "randistrs.h" + +/// Tests valid permutation +TEST(MooseRandomPerturbation, permute) +{ + unsigned int num_trials = 10; + unsigned int max_vector_length = 1000; + unsigned int seed = 1993; + + mt_state state; + mts_seed32new(&state, seed); + for (unsigned int trial = 0; trial < num_trials; ++trial) + { + auto seed = static_cast(mts_lrand(&state)); + unsigned int n = rds_iuniform(&state, 0, max_vector_length); + MooseRandomPerturbation generator(seed, n); + + std::vector permutation(n); + for (unsigned int x = 0; x < n; ++x) + permutation[x] = generator.permute(x); + + std::vector sorted_perm = permutation; + std::sort(sorted_perm.begin(), sorted_perm.end()); + for (unsigned int x = 0; x < n; ++x) + EXPECT_EQ(sorted_perm[x], x); + } +} + +/// Test that the permutation is invertible +TEST(MooseRandomPerturbation, invert) +{ + unsigned int num_trials = 10; + unsigned int max_vector_length = 1000; + unsigned int seed = 1993; + + mt_state state; + mts_seed32new(&state, seed); + for (unsigned int trial = 0; trial < num_trials; ++trial) + { + auto generator_seed = static_cast(mts_lrand(&state)); + unsigned int n = rds_iuniform(&state, 0, max_vector_length); + MooseRandomPerturbation generator(generator_seed, n); + + std::vector permutation(n); + for (unsigned int x = 0; x < n; ++x) + { + auto y = generator.permute(x); + auto xinv = generator.invert(y); + EXPECT_EQ(xinv, x); + } + } +} + +/// Tests that permutation works over a range of bits +TEST(MooseRandomPerturbation, bits) +{ + unsigned int max_bits = 29; // Can go up to 32, but is slow + unsigned int num_trials = 10; + unsigned int seed = 1993; + + mt_state state; + mts_seed32new(&state, seed); + unsigned int max_n = 0; + for (unsigned int bits = 1; bits <= max_bits; ++bits) + { + auto min_n = max_n + 1; + max_n = static_cast((uint64_t(1) << bits) - 1); + + auto generator_seed = static_cast(mts_lrand(&state)); + unsigned int n = rds_iuniform(&state, min_n, max_n); + MooseRandomPerturbation generator(generator_seed, n); + + for (unsigned int trial = 0; trial < num_trials; ++trial) + { + uint32_t x = rds_iuniform(&state, 0, n); + auto y = generator.permute(x); + auto xinv = generator.invert(y); + EXPECT_EQ(xinv, x); + } + } +} + +/// Tests that permutations are unique for a given seed +TEST(MooseRandomPerturbation, unique) +{ + unsigned int num_trials = 10; + unsigned int n = 1000; + unsigned int seed = 1993; + + mt_state state; + mts_seed32new(&state, seed); + std::vector> permutations(num_trials, std::vector(n)); + for (unsigned int trial = 0; trial < num_trials; ++trial) + { + auto seed = static_cast(mts_lrand(&state)); + MooseRandomPerturbation generator(seed, n); + + for (unsigned int x = 0; x < n; ++x) + permutations[trial][x] = generator.permute(x); + + for (unsigned int test = 0; test < trial; ++test) + EXPECT_NE(permutations[trial], permutations[test]); + } +} + +/// Tests permutations are reproducible +TEST(MooseRandomPerturbation, reproduce) +{ + unsigned int num_trials = 10; + unsigned int max_vector_length = 1000; + unsigned int num_tests = 100; + unsigned int seed = 1993; + + mt_state state; + mts_seed32new(&state, seed); + for (unsigned int trial = 0; trial < num_trials; ++trial) + { + auto seed = static_cast(mts_lrand(&state)); + unsigned int n = rds_iuniform(&state, 0, max_vector_length); + MooseRandomPerturbation generator(seed, n); + + std::vector permutation(n); + for (unsigned int x = 0; x < n; ++x) + permutation[x] = generator.permute(x); + + for (unsigned int test = 0; test < num_tests; ++test) + { + uint32_t x = rds_iuniform(&state, 0, n); + EXPECT_EQ(permutation[x], generator.permute(x)); + } + } +}