13 #ifndef NUTOOLS_RANDOMUTILS_PROVIDERS_STANDARDPOLICIES_H 14 #define NUTOOLS_RANDOMUTILS_PROVIDERS_STANDARDPOLICIES_H 1 25 #include "nutools/RandomUtils/Providers/RandomSeedPolicyBase.h" 26 #include "nutools/RandomUtils/Providers/EngineId.h" 39 template <
typename SEED>
40 class AutoIncrementPolicy:
public CheckedRangePolicy<SEED> {
67 (
"maxUniqueEngines",
"",
"checkRange");
73 virtual void print(std::ostream& out)
const override;
81 {
return next_seed++; }
87 template <
typename SEED>
98 template <
typename SEED>
111 template <
typename SEED>
144 virtual void print(std::ostream& out)
const override;
149 unsigned int nSeedsPerJob;
153 {
return next_seed++; }
160 template <
typename SEED>
174 "\nDEPRECATION WARNING: 'baseSeed' parameter has been deprecated" 175 " for linearMapping policy, in favour of 'nJob'." 176 "\nPlease update your configuration accordingly." 181 nSeedsPerJob = pset.
get<
seed_t>(
"maxUniqueEngines");
191 template <
typename SEED>
196 <<
"\n seeds per job: " << nSeedsPerJob;
205 template <
typename SEED>
241 virtual void print(std::ostream& out)
const override;
251 {
return base_t::getInstanceSeed(
id); }
259 template <
typename SEED>
262 out <<
"\n seeds directly from the configuration";
273 template <
typename SEED>
283 base_t(
"preDefinedOffset")
314 (
"maxUniqueEngines",
"",
"checkRange");
320 virtual void print(std::ostream& out)
const override;
327 {
return base_seed + base_t::getInstanceSeed(
id); }
334 template <
typename SEED>
338 base_seed = pset.
get<
seed_t>(
"baseSeed");
344 template <
typename SEED>
347 out <<
"\n base seed: " << base_seed;
356 #endif // NUTOOLS_RANDOMUTILS_PROVIDERS_STANDARDPOLICIES_H Base class for policies reacting at engine instance level.
virtual void configure(fhicl::ParameterSet const &pset) override
Configure this policy.
virtual seed_t createSeed(SeedMasterHelper::EngineId const &) override
Returns the next random number.
SEED seed_t
type of the random seed
virtual bool yieldsUniqueSeeds() const override
Returns whether the returned seed should be unique: for us it "no".
virtual seed_t createSeed(SeedMasterHelper::EngineId const &id) override
Returns the seed stored in the parameter set.
virtual void print(std::ostream &out) const override
Prints the configuration of this policy.
virtual void print(std::ostream &out) const override
Prints the configuration of this policy.
virtual void configure(fhicl::ParameterSet const &pset) override
Configure this policy.
virtual void configure(fhicl::ParameterSet const &pset) override
Configure this policy.
void static_configure(fhicl::ParameterSet const &pset)
Implementation of the "preDefinedOffset" policy.
typename base_t::seed_t seed_t
void static_configure(fhicl::ParameterSet const &)
void SetCheck(bool doCheck=true)
Sets whether to perform the check or not.
virtual void print(std::ostream &out) const override
Prints information on the configuration of this policy.
void SetNSeeds(seed_t nSeeds)
Sets the number of seeds directly.
Interface for a policy implementation.
virtual void configure(fhicl::ParameterSet const &pset) override
Configure this policy.
Implementation of the "autoIncrement" policy.
T get(std::string const &key) const
PredefinedOffsetPolicy(fhicl::ParameterSet const &pset)
Implementation of the "preDefinedSeed" policy.
virtual void configure(fhicl::ParameterSet const &pset) override
Configure this policy.
RangeCheckHelper< seed_t > range_check
Identifier for a engine, made of module name and optional instance name.
bool get_if_present(std::string const &key, T &value) const
seed_t next_seed
next seed delivered
Implementation of the "linearMapping" policy.
virtual seed_t createSeed(SeedMasterHelper::EngineId const &) override
Returns the next random number.
PredefinedSeedPolicy(fhicl::ParameterSet const &pset)
Range-checked policy (abstract)
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
LinearMappingPolicy(fhicl::ParameterSet const &pset)
virtual seed_t createSeed(SeedMasterHelper::EngineId const &id) override
Returns the seed stored in the parameter set.
virtual void print(std::ostream &out) const override
Prints the configuration of this policy.
void static_configure(fhicl::ParameterSet const &)
void SetConfigLabels(std::string maxSeedsLabel="maxUniqueEngines", std::string baseSeedLabel="baseSeed", std::string checkRangeLabel="checkRange")
void SetBaseSeed(seed_t base_seed)
Sets the base seed directly.
virtual void print(std::ostream &out) const override
Prints the configuration of this policy.
void CheckRangeConfiguration() const
Check that the configuration is complete.
AutoIncrementPolicy(fhicl::ParameterSet const &pset)
void static_configure(fhicl::ParameterSet const &)