UTILITIES¶
Utility classes
Overview:
LogfileOutputFolderHandlerPopulationFactoryToyPopulationFactoryHouseholdLinkerthread_poolRandomManagerRandomGeneratorInverseCDFDistanceMetrics
UTILITIES¶
-
class LogFile¶
Class to handle logging Singleton LogFile structure Usage: // Configure std::filesystem::path logfilepath(“log.log”) // path to log file LogFile::Instance()->configure(0, logfilepath); // Configure logger // ALTERNATIVELY LOG.configure(0, logfilepath);.
// Write to Logs LOG << LOG_LEVEL_ERROR << “Encountered Error” << std::endl; LOG << LOG_LEVEL_NORMAL << “Started Simulation” << std::endl;
// Cleanup LogFile::Close();
Public Functions
-
void configure(unsigned int level, std::filesystem::path path)¶
Close the currently open file, and delete the single LogFile instance.
-
void setLevel(unsigned int level)¶
Set the current logging level
-
const std::string prepare(unsigned int level)¶
Prepare the logger to recieve a log line by configuring the log level
-
bool isFileSet() const¶
- Returns:
true if Set() has been called.
-
void lock()¶
Lock the logfile for multithreaded logging
-
void unlock()¶
Unlock the logfile for multithreaded logging
-
void enable_cout()¶
Configure the logger to output to both std::cout and the output file
-
void disable_cout()¶
Configure the logger to output to output file only and not std::cout
-
void configure(unsigned int level, std::filesystem::path path)¶
-
class OutputFolderHandler¶
Output Folder Handling Class Class which handles opening a folder Creates folder if it doesn’t exist Can clear the folder after opening Public method which allows opening a file within this folder for writing.
Public Functions
-
OutputFolderHandler(const std::filesystem::path &directory_path, bool cleanOutputDirectory = true)¶
Construct a new Output File Handler object.
- Parameters:
directory_path – Path to output directory
cleanOutputDirectory – Flag whether to clear contents of output directory
-
ofstreamPtr OpenOutputFile(const std::string &rFileName, std::ios_base::openmode mode = std::ios::out | std::ios::trunc) const¶
Make outputfile and return ofstream for the file Construct a new file inside of the OutputFolderHandler’s directory.
- Parameters:
rFileName – New filename
mode – std::ios_base::openmode Mode with which to open file
- Returns:
ofstreamPtr
-
OutputFolderHandler(const std::filesystem::path &directory_path, bool cleanOutputDirectory = true)¶
-
class PopulationFactory¶
Public Functions
-
PopulationPtr makePopulation()¶
-
PopulationPtr makePopulation(size_t n_cells, size_t n_microcells, size_t n_people)¶
Create a Basic Population.
Create a Population with n_cells, n_microcells :class:
Microcellin each cell, and n_people :class:Peoplein each microcell.- Parameters:
n_cells –
n_microcells –
n_people –
- Returns:
PopulationPtr
-
void addCell(PopulationPtr population)¶
-
void addCells(PopulationPtr population, size_t n)¶
-
void addPlace(PopulationPtr population)¶
-
void addPlaces(PopulationPtr population, size_t n)¶
-
PopulationPtr makePopulation()¶
-
class ToyPopulationFactory¶
Public Functions
-
PopulationPtr makePopulation(size_t populationSize, size_t nCells, size_t nMicrocells, size_t nHouseholds, size_t nPlaces, std::optional<size_t> seed)¶
-
PopulationPtr makePopulation(size_t populationSize, size_t nCells, size_t nMicrocells, size_t nHouseholds, size_t nPlaces, std::optional<size_t> seed)¶
-
class HouseholdLinker¶
Public Functions
-
void linkHouseholds(PopulationPtr population, size_t n_households, int percInHousehold, std::optional<size_t> seed)¶
Link households Create n_households per microcell. Person has percInHousehold to be in a household. People who should be in a household are randomly assigned to a household in their microcell.
- Parameters:
population –
n_households –
percInHousehold –
-
void linkHouseholds(PopulationPtr population, size_t n_households, int percInHousehold, std::optional<size_t> seed)¶
Warning
doxygenclass: Cannot find class “epiabm::thread_pool” in doxygen xml output for project “cEpiabm” from directory: build/xml
-
class RandomManager¶
-
class RandomGenerator¶
Public Functions
-
inline RandomGenerator(unsigned int seed, size_t threadNum)¶
-
inline RandomGenerator(unsigned int seed, size_t threadNum, std::thread::id threadId)¶
-
~RandomGenerator() = default¶
-
inline std::mt19937_64 &generator()¶
-
template<typename T>
inline T randi(T max)¶ Generate Random Integer Random integer between 0 and max inclusive.
- Template Parameters:
T – Integer Type
- Parameters:
max –
- Returns:
T Generated Random Number
-
inline RandomGenerator(unsigned int seed, size_t threadNum)¶
-
class InverseCDF¶
Public Functions
-
InverseCDF()¶
-
InverseCDF(double mean)¶
-
void setNegLog(double startValue)¶
-
void assignExponent()¶
-
void assignExponent(double value)¶
-
unsigned short choose(double timestepsPerDay, RandomGenerator &generator)¶
-
std::array<double, InverseCDF::RES + 1> &getValues()¶
-
double &operator[](size_t i)¶
-
double mean()¶
Public Static Attributes
-
static const size_t RES = 20¶
-
InverseCDF()¶
-
class DistanceMetrics¶