mirror of
https://github.com/JHUAPL/kami.git
synced 2026-01-09 19:47:58 -05:00
Simplify the interface to random. I really have no idea why I let you set the RNG later, anyway.
This commit is contained in:
@@ -88,9 +88,9 @@ namespace kami {
|
||||
* @param rng [in] A uniform random number generator of type `std::mt19937`,
|
||||
* used as the source of randomness.
|
||||
*
|
||||
* @returns a shared pointer to this instance of `RandomScheduler`
|
||||
* @returns a shared pointer to the random number generator
|
||||
*/
|
||||
std::shared_ptr<RandomScheduler> set_rng(std::shared_ptr<std::ranlux24> rng);
|
||||
std::shared_ptr<std::ranlux24> set_rng(std::shared_ptr<std::ranlux24> rng);
|
||||
|
||||
/**
|
||||
* @brief Get the RNG
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <random>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <kami/model.h>
|
||||
@@ -40,13 +41,16 @@ namespace kami {
|
||||
}
|
||||
|
||||
std::optional<std::shared_ptr<std::vector<AgentID>>> RandomScheduler::step(std::shared_ptr<Model> model, std::shared_ptr<std::vector<AgentID>> agent_list) {
|
||||
shuffle(agent_list->begin(),agent_list->end(), *_rng);
|
||||
if (_rng == nullptr)
|
||||
return std::nullopt;
|
||||
|
||||
shuffle(agent_list->begin(), agent_list->end(), *_rng);
|
||||
return std::move(this->SequentialScheduler::step(model, agent_list));
|
||||
}
|
||||
|
||||
std::shared_ptr<RandomScheduler> RandomScheduler::set_rng(std::shared_ptr<std::ranlux24> rng) {
|
||||
std::shared_ptr<std::ranlux24> RandomScheduler::set_rng(std::shared_ptr<std::ranlux24> rng) {
|
||||
this->_rng = std::move(rng);
|
||||
return shared_from_this();
|
||||
return _rng;
|
||||
}
|
||||
|
||||
std::shared_ptr<std::ranlux24> RandomScheduler::get_rng() { return (this->_rng); }
|
||||
|
||||
Reference in New Issue
Block a user