public void Init() { IdentificatorModel = new IdentificatorModel(this, _idControl); NameModel = new NameModel(this); RelationshipModel = GetRelationshipModel2(Model, new FamilyModel(this)); RegstatusModel = new RegstatusModel(this); AdressModel = new AdressModel(this); SivilstatusModel = new SivilstatusModel(this); _randomizer = new Randomizer(); }
public static PersonWithMetadata GetInitialPerson(IdentificatorModel inIdentificatorModel, int?predefinedAge = null, bool?predefinedIsFemale = null) { var p = new PersonWithMetadata() { Person = new Person(), PredefinedAge = predefinedAge, PrefinedIsFemale = predefinedIsFemale }; p.Age = predefinedAge ?? inIdentificatorModel.GetRandomAge()(); p.AgeQuants = BaseModel.GetAgeQuant(p.Age); return(p); }
private IEnumerable <Person> DoNextBunch(int howMany) { _persons = new Dictionary <string, PersonWithMetadata>(howMany); var stopw = new Stopwatch(); stopw.Start(); while (howMany-- > 0) { var nextPerson = GetInitialPerson(); nextPerson.Randy = _randomizer; nextPerson.BooleanSamples = Model.Statistics.BinaryGenerator.NextRow(Model.Statistics.GetClosestStatisticByAgeQuant(nextPerson)); IdentificatorModel.SetProperties(nextPerson); NameModel.SetProperties(nextPerson); RegstatusModel.SetProperties(nextPerson); AdressModel.SetProperties(nextPerson); RelationshipModel.SetProperties(nextPerson); nextPerson.Person.DateCustody = Model.Statistics.GetClosestStatisticByAgeQuant(nextPerson).DateCustody.GetDateTimeFromModel(nextPerson, nextPerson.Person.Custody); //disse er offisielt sett null //nextPerson.Person.WithoutLegalCapacity = MultivariateBinaryGenerator.Sample(PersonStatisticKeys.HasWithoutLegalCapacity, nextPerson.BooleanSamples, Model.Statistics.GetClosestStatisticByAgeQuant(nextPerson).WithoutLegalCapacity, _randomizer); //nextPerson.Person.DateWithoutLegalCapacity = Model.Statistics.GetClosestStatisticByAgeQuant(nextPerson).DateWithoutLegalCapacity.GetDateTimeFromModel(nextPerson, nextPerson.Person.WithoutLegalCapacity); nextPerson.Person.WorkPermit = MultivariateBinaryGenerator.Sample(PersonStatisticKeys.HasWorkPermit, nextPerson.BooleanSamples, Model.Statistics.GetClosestStatisticByAgeQuant(nextPerson).WorkPermit, _randomizer); nextPerson.Person.DateWorkPermit = Model.Statistics.GetClosestStatisticByAgeQuant(nextPerson).DateWorkPermit.GetDateTimeFromModel(nextPerson, nextPerson.Person.WorkPermit); nextPerson.Person.ParentalResponsibility = Model.Statistics.GetClosestStatisticByAgeQuant(nextPerson).ParentalResponsibility.Sample(_randomizer); nextPerson.Person.DateParentalResponsibility = Model.Statistics.GetClosestStatisticByAgeQuant(nextPerson).DateParentalResponsibility.GetDateTimeFromModel(nextPerson, nextPerson.Person.ParentalResponsibility); nextPerson.Person.StatusCountryCode = MultivariateBinaryGenerator.Sample(PersonStatisticKeys.HasStatusCountryCode, nextPerson.BooleanSamples, Model.Statistics.StatusCountryCode, _randomizer); SetCityzenship(nextPerson); _persons.Add(nextPerson.Person.NIN, nextPerson); if (!string.IsNullOrEmpty(nextPerson.Person.OldNIN)) { var clone = Cloner.Clone(nextPerson); clone.Person.NewNIN = nextPerson.Person.NIN; clone.Person.OldNIN = null; clone.Person.NIN = nextPerson.Person.OldNIN; clone.Married = false; clone.NumberOfKids = 0; clone.MotherSearch = null; clone.FatherSearch = null; clone.Person.FathersNIN = null; clone.Person.MothersNIN = null; clone.Person.SpouseNIN = null; _persons.Add(clone.Person.NIN, clone); } } stopw.Stop(); ConsoleWriteline("Done generating isolated persons. It took " + stopw.Elapsed.TotalMinutes + " minutes"); stopw.Restart(); RelationshipModel.BringPeopleTogether(_persons, _randomizer, ConsoleWriteline); foreach (var person in _persons) { SivilstatusModel.SetProperties(person.Value); } stopw.Stop(); ConsoleWriteline("Done generating relationsship within persons. It took " + stopw.Elapsed.TotalMinutes + " minutes"); return(_persons.Values.Select(x => x.Person)); }