public void CalcPersonDesiresTest() { CalcParameters calcParameters = CalcParametersFactory.MakeGoodDefaults(); var r = new Random(1); using (CalcRepo calcRepo = new CalcRepo(calcParameters: calcParameters, rnd: r)) { var cpd = new CalcPersonDesires(calcRepo); var cd1 = new CalcDesire("blub0", 1, 0.5m, 0.1m, 1, 1, 1, -1, null, "", ""); cpd.AddDesires(cd1); var cd2 = new CalcDesire("blub1", 2, 0.5m, 0.1m, 1, 1, 1, -1, null, "", ""); cpd.AddDesires(cd2); Logger.Info("CalcPersonDesiresTest:" + cd1.Value + " ; " + cd2.Value); // satisfaction var satis1 = new CalcDesire("blub", 1, 0.5m, 12, 1, 1, 60, -1, null, "", "") { Value = 1 }; var satisfactionValues = new List <CalcDesire> { satis1 }; Logger.Info(cd1.Value + " ; " + cd2.Value); for (var i = 0; i < 20; i++) { TimeStep ts = new TimeStep(i, 0, false); cpd.ApplyDecay(ts); cpd.ApplyAffordanceEffect(satisfactionValues, true, "blub"); Logger.Info(cd1.Value + " ; " + cd2.Value); } } }
private static void CheckIfDesireViolatesCategory([NotNull] PersonDesireDto desire, [NotNull] CalcPersonDesires calcDesires, [NotNull] CalcPerson person, [NotNull] string householdName) { string desirecategory = desire.DesireCategory; if (string.IsNullOrWhiteSpace(desirecategory)) { return; } if (calcDesires.Desires.ContainsKey(desire.DesireID)) { return; } var existingDesireCategories = calcDesires.Desires.Values.Select(x => x.DesireCategory).Distinct().ToList(); if (existingDesireCategories.Contains(desirecategory)) { var existingdesires = calcDesires.Desires.Values.Where(x => x.DesireCategory == desirecategory).ToList(); var source = existingdesires[0]; throw new DataIntegrityException("Trying to add two desires from the desire category " + Environment.NewLine + desirecategory + " to the person " + person.Name + " in the household " + householdName + ". This is not permitted. " + "Please fix. The first desire was " + Environment.NewLine + source.Name + " from " + source.SourceTrait + " and the second desire was " + Environment.NewLine + desire.Name + " from " + desire.SourceTrait + Environment.NewLine); } }
public DesireEntry([NotNull] CalcPerson pPerson, [NotNull] TimeStep pTimestep, [NotNull] CalcPersonDesires pDesires, [NotNull] DesiresLogFile dlf, [NotNull] CalcParameters calcParameters) { CPerson = pPerson; _timestep = pTimestep; _lf = dlf; _calcParameters = calcParameters; _desirevalues = new decimal[dlf.DesireColumn.Count]; foreach (var calcDesire in pDesires.Desires.Values) { _desirevalues[dlf.DesireColumn[calcDesire.Name]] = calcDesire.Value; } _dsc = new DateStampCreator(calcParameters); }