|
|
| relg ()=default |
| | Default constructor — creates an empty generator with no data, drawing from the birth-generator singleton.
|
| |
| | relg (sources from) |
| | A generator with no data that draws from the given library instances (which must outlive it).
|
| |
|
| relg (const relg &)=delete |
| | Not copyable.
|
| |
|
relg & | operator= (const relg &)=delete |
| | Not copyable.
|
| |
|
| relg (relg &&) noexcept=default |
| | Movable.
|
| |
|
relg & | operator= (relg &&) noexcept=default |
| | Movable.
|
| |
|
| ~relg ()=default |
| | Destructor.
|
| |
| family | get_family (const family_request &request) |
| | Generate a random family. Use family_request{} for the defaults.
|
| |
| family | get_family (const family_request &request, std::uint64_t call_seed) const |
| | Generate a deterministic family.
|
| |
| family | expand (const family &base, std::size_t member, family_request request, std::uint64_t call_seed) const |
| | Generate the family of a member of a family, so that the two agree.
|
| |
| family | expand (const family &base, std::size_t member, const family_request &request) |
| | Generate a random family of a member of a family; see the seeded overload.
|
| |
| std::vector< family > | get_family_batch (const family_request &request, const core::batch_options &options) |
| | Generate a batch of family results from a seed drawn like get_family() draws its own.
|
| |
| std::vector< family > | get_family_batch (const family_request &request, const core::batch_options &options, std::uint64_t batch_seed) const |
| | Generate a batch of family results, deterministically.
|
| |
| template<typename Sink > |
| void | for_each_family (const family_request &request, const core::batch_options &options, std::uint64_t batch_seed, Sink &&sink) const |
| | Stream a batch of family results to a sink without holding the whole batch.
|
| |
| template<typename Sink > |
| void | for_each_family (const family_request &request, const core::batch_options &options, Sink &&sink) |
| | Stream a batch of family results with a batch seed drawn like get_family() draws its own.
|
| |
| bool | has_data () const |
| | Check whether this generator and birth-generator have data.
|
| |
| bool | has_family_data () const |
| | Check whether the family tables are loaded (birth-generator is not asked).
|
| |
| std::vector< std::string > | countries () const |
| | The countries with figures of their own in any table.
|
| |
| void | load (const std::filesystem::path &dir) |
| | Load data from a resource directory, replacing all data and layers loaded before.
|
| |
| bool | load (dataset tier) |
| | Load a dataset tier, replacing all data and layers loaded before.
|
| |
| void | extend (const std::filesystem::path &path, core::layer_mode mode=core::layer_mode::override) |
| | Add data layers from a directory or a file.
|
| |
| const core::layer_info & | extend (family_table which, core::tsv_document doc, core::layer_mode mode=core::layer_mode::override) |
| | Add a data layer to one table.
|
| |
| const core::layer_info & | extend_from_string (family_table which, std::string_view text, std::string source, core::layer_mode mode=core::layer_mode::override) |
| | Add a data layer to one table from TSV text (for example from a WebAssembly host).
|
| |
| const std::vector< core::layer_info > & | layers (family_table which) const |
| | The layers in effect for one table, in order.
|
| |
| std::uint64_t | data_hash () const |
| | Hash of the loaded data: this generator's tables and birth-generator's data. Recorded in each result's signature().
|
| |
Relationship Generator: builds believable families around a person.
A family is drawn from demography: the mother's age at the anchor's birth from her country's fertility by age, the father from the typical difference in marriage ages, the number of siblings from the total fertility rate of the anchor's birth year (the family size seen from a child is size-biased, so a family with more children is more likely to be the anchor's), and who is alive from a Gompertz survival curve that matches the country's life expectancy. Everything is drawn from named streams split from the call seed ("anchor", "parents", "mother", "father", "siblings", "grandparents"), so asking for grandparents or for no siblings does not change the rest. Output is identical on every compiler and platform (dasmig-core).
The anchor, the country's age pyramid and life expectancy come from birth-generator (the singleton by default, or an instance passed in).
Can be used as a singleton via instance() or constructed independently.
- Thread safety
- get_family(request, seed) is const and only calls const members of birth-generator, so it may run concurrently. get_family(request) draws from the generator's engine and needs external synchronisation on the same instance; so do load() and extend().
Definition at line 633 of file relgen.hpp.
Generate the family of a member of a family, so that the two agree.
The member's own birth, sex, name and country are kept, and so are the relatives base already has for the member: their parents (and the grandparents, if base has them), siblings and half-siblings, and the partners and children that base lists. Whatever base does not hold is drawn, as get_family() draws it: a partner, say, whom base left out is drawn again, and children whose other parent base left out are kept without that partner.
Only what base lists is kept: a member that base generated with partners = false or down = 0 has its partners or children drawn again. The request's anchor is ignored (member takes its place), and so is its reference_date (that of base is used); up, down, siblings, partners, names, name_culture and weighted apply.
- Parameters
-
| base | The family the member belongs to. |
| member | The member's id (base.members[member]). |
| request | What to generate around the member. |
| call_seed | Seed; the same base, member, request and seed give the same family. |
- Returns
- The member's family; its anchor is the member.
- Exceptions
-
| std::invalid_argument | If member is not an id of base. |
Definition at line 1155 of file relgen.hpp.
| std::vector< family > dasmig::relg::get_family_batch |
( |
const family_request & |
request, |
|
|
const core::batch_options & |
options, |
|
|
std::uint64_t |
batch_seed |
|
) |
| const |
|
inline |
Generate a batch of family results, deterministically.
Item i is exactly get_family(request, core::item_seed(batch_seed, options.first + i)), so an item replays on its own, a range can be generated directly, two batches that follow each other equal one, and the output does not depend on options.threads.
- Parameters
-
| request | What every item is generated from. |
| options | Count, first index, threads and uniqueness (see core::unique_rule; the rule must be made for family). |
| batch_seed | Seed of the whole batch. |
- Returns
- The results, in index order.
- Exceptions
-
| std::invalid_argument | If the request or options are invalid. |
| std::runtime_error | If no data has been loaded, or a unique batch runs out of attempts. |
Definition at line 1207 of file relgen.hpp.