-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #578 from astrorama/feature/rng_seed_config
Use rng seed instead of time()
- Loading branch information
Showing
6 changed files
with
97 additions
and
11 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
SEImplementation/SEImplementation/Configuration/RngConfig.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* RngConfig.h | ||
* | ||
* Created on: Mar 21, 2024 | ||
* Author: mschefer | ||
*/ | ||
|
||
#ifndef _SEIMPLEMENTATION_CONFIGURATION_RNGCONFIG_H_ | ||
#define _SEIMPLEMENTATION_CONFIGURATION_RNGCONFIG_H_ | ||
|
||
#include "Configuration/Configuration.h" | ||
#include "AlexandriaKernel/ThreadPool.h" | ||
|
||
namespace SourceXtractor { | ||
|
||
class RngConfig : public Euclid::Configuration::Configuration { | ||
public: | ||
explicit RngConfig(long manager_id); | ||
|
||
virtual ~RngConfig() = default; | ||
|
||
std::map<std::string, OptionDescriptionList> getProgramOptions() override; | ||
|
||
void initialize(const UserValues& args) override; | ||
|
||
unsigned int getSeed() const { | ||
return m_seed; | ||
} | ||
|
||
private: | ||
unsigned int m_seed; | ||
}; | ||
|
||
|
||
} | ||
|
||
|
||
#endif /* _SEIMPLEMENTATION_CONFIGURATION_RNGCONFIG_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** Copyright © 2019-2024 Université de Genève, LMU Munich - Faculty of Physics, IAP-CNRS/Sorbonne Université | ||
* | ||
* This library is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU Lesser General Public License as published by the Free | ||
* Software Foundation; either version 3.0 of the License, or (at your option) | ||
* any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | ||
* details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this library; if not, write to the Free Software Foundation, Inc., | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
|
||
#include <boost/thread.hpp> | ||
|
||
#include "SEImplementation/Configuration/RngConfig.h" | ||
|
||
using namespace Euclid::Configuration; | ||
namespace po = boost::program_options; | ||
|
||
namespace SourceXtractor { | ||
|
||
static const std::string RNG_SEED {"rng-seed"}; | ||
|
||
RngConfig::RngConfig(long manager_id) : Configuration(manager_id), m_seed(42) {} | ||
|
||
auto RngConfig::getProgramOptions() -> std::map<std::string, OptionDescriptionList> { | ||
return { {"Random number generation", { | ||
{RNG_SEED.c_str(), po::value<unsigned int>()->default_value(42), "Random number generator seed"}, | ||
}}}; | ||
} | ||
|
||
void RngConfig::initialize(const UserValues& args) { | ||
m_seed = args.at(RNG_SEED).as<unsigned int>(); | ||
} | ||
|
||
} // SourceXtractor namespace | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters