示例#1
0
        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);
            }
        }
示例#2
0
        public List <CalcPerson> MakeCalcPersons([NotNull][ItemNotNull] List <CalcPersonDto> persons,
                                                 [NotNull] CalcLocation startLocation,
                                                 [NotNull] string householdName)
        {
            var calcPersons = new List <CalcPerson>();
            Dictionary <string, SharedDesireValue> sharedDesireValues = new Dictionary <string, SharedDesireValue>();

            foreach (var hhPerson in persons)
            {
                var isSick        = SetBitArrayWithDateSpans(hhPerson.SicknessSpans);
                var vacationTimes = SetBitArrayWithDateSpans(hhPerson.VacationSpans);

                var cp = new CalcPerson(hhPerson, startLocation, isSick, vacationTimes, _calcRepo);

                /* repetitionCount, _random,hhPerson.Person.Age, hhPerson.Person.Gender, _logFile,
                 * householdKey, startLocation, traitTagName, householdName, _calcParameters, isSick,
                 * Guid.NewGuid().ToStrGuid());*/
                // vacations setzen
                foreach (PersonDesireDto desire in hhPerson.Desires)
                {
                    AddDesireToPerson(desire, cp, sharedDesireValues, householdName);
                }


                calcPersons.Add(cp);
            }

            return(calcPersons);
        }
示例#3
0
        private void AddDesireToPerson([NotNull] PersonDesireDto desire,
                                       [NotNull] CalcPerson calcPerson,
                                       [NotNull] Dictionary <string, SharedDesireValue> sharedDesireValues,
                                       [NotNull] string householdName)
        {
            var sdv = GetSharedDesireValue(desire, sharedDesireValues);
            var cd1 = new CalcDesire(desire.Name,
                                     desire.DesireID,
                                     desire.Threshold,
                                     desire.DecayTime,
                                     1,
                                     desire.Weight,
                                     _calcRepo.CalcParameters.TimeStepsPerHour,
                                     desire.CriticalThreshold,
                                     sdv,
                                     desire.SourceTrait,
                                     desire.DesireCategory);

            if (desire.HealthStatus == HealthStatus.Healthy || desire.HealthStatus == HealthStatus.HealthyOrSick)
            {
                CheckIfDesireViolatesCategory(desire, calcPerson.PersonDesires, calcPerson, householdName);
                calcPerson.PersonDesires.AddDesires(cd1);
            }

            if (desire.HealthStatus == HealthStatus.Sick || desire.HealthStatus == HealthStatus.HealthyOrSick)
            {
                CheckIfDesireViolatesCategory(desire, calcPerson.SicknessDesires, calcPerson, householdName);
                calcPerson.SicknessDesires.AddDesires(cd1);
            }
        }
        public void PickRandomAffordanceFromEquallyAttractiveOnesTest()
        {
            using (var wd = new WorkingDir(Utili.GetCurrentMethodAndClass())) {
                CalcParameters calcParameters = CalcParametersFactory.MakeGoodDefaults();
                calcParameters.AffordanceRepetitionCount = 0;
                wd.InputDataLogger.AddSaver(new HouseholdKeyLogger(wd.SqlResultLoggingService));
                wd.InputDataLogger.AddSaver(new ResultFileEntryLogger(wd.SqlResultLoggingService));
                using (var fft = new FileFactoryAndTracker(wd.WorkingDirectory, "blub", wd.InputDataLogger)) {
                    fft.RegisterHousehold(Constants.GeneralHouseholdKey, "general", HouseholdKeyType.General, "desc", null, null);
                    //SqlResultLoggingService srls = new SqlResultLoggingService(wd.WorkingDirectory);
                    //DateStampCreator dsc = new DateStampCreator(calcParameters);
                    Random rnd = new Random();
                    //OnlineLoggingData old = new OnlineLoggingData(dsc, wd.InputDataLogger, calcParameters);
                    using (var lf = new LogFile(calcParameters, fft)) {
                        CalcProfile            cp  = new CalcProfile("cp1", Guid.NewGuid().ToStrGuid(), TimeSpan.FromMinutes(1), ProfileType.Absolute, "bla");
                        CalcVariableRepository crv = new CalcVariableRepository();
                        BitArray isBusy            = new BitArray(calcParameters.InternalTimesteps, false);
                        using CalcRepo calcRepo = new CalcRepo(lf: lf, calcParameters: calcParameters, rnd: rnd);
                        CalcAffordance aff1 = new CalcAffordance("aff1", cp, null, false, new List <CalcDesire>(), 10, 20, PermittedGender.All, true,
                                                                 1, LPGColors.AliceBlue, null, false, false, null, null, ActionAfterInterruption.GoBackToOld, "", 900, false, "",
                                                                 Guid.NewGuid().ToStrGuid(), crv, new List <CalcAffordance.DeviceEnergyProfileTuple>(), isBusy, BodilyActivityLevel.Low,
                                                                 calcRepo);
                        CalcAffordance aff2 = new CalcAffordance("aff2", cp, null, false, new List <CalcDesire>(), 10, 20, PermittedGender.All, true,
                                                                 1, LPGColors.AliceBlue, null, false, false, null, null, ActionAfterInterruption.GoBackToOld, "", 100, false, "",
                                                                 Guid.NewGuid().ToStrGuid(), crv, new List <CalcAffordance.DeviceEnergyProfileTuple>(), isBusy, BodilyActivityLevel.Low,
                                                                 calcRepo);

                        List <ICalcAffordanceBase> affs = new List <ICalcAffordanceBase> {
                            aff1,
                            aff2
                        };
                        int           aff1C        = 0;
                        int           aff2C        = 0;
                        BitArray      isSick       = new BitArray(calcParameters.InternalTimesteps);
                        BitArray      isOnVacation = new BitArray(calcParameters.InternalTimesteps);
                        CalcPersonDto calcPerson   = CalcPersonDto.MakeExamplePerson();
                        CalcPerson    cperson      = new CalcPerson(calcPerson, null, isSick, isOnVacation, calcRepo);
                        TimeStep      ts           = new TimeStep(1, 0, true);
                        for (int i = 0; i < 1000; i++)
                        {
                            ICalcAffordanceBase cab = cperson.PickRandomAffordanceFromEquallyAttractiveOnes(affs, ts, null, new HouseholdKey("bla"));
                            if (cab == aff1)
                            {
                                aff1C++;
                            }

                            if (cab == aff2)
                            {
                                aff2C++;
                            }
                        }

                        aff1C.Should().BeApproximatelyWithinPercent(900, 0.1);
                        Logger.Info("Number of selections for 90%:" + aff1C + ", 10%:" + aff2C);
                    }
                }
                wd.CleanUp();
            }
        }
 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);
 }
        public void FileFactoryAndTrackerTest()
        {
            Config.IsInUnitTesting = true;
            using (var wd = new WorkingDir(Utili.GetCurrentMethodAndClass()))
            {
                wd.InputDataLogger.AddSaver(new HouseholdKeyLogger(wd.SqlResultLoggingService));
                wd.InputDataLogger.AddSaver(new ResultFileEntryLogger(wd.SqlResultLoggingService));
                CalcParameters  calcParameters = CalcParametersFactory.MakeGoodDefaults();
                var             clt            = new CalcLoadType("calcloadtype", "kwh", "kW", 0.001, true, Guid.NewGuid().ToStrGuid());
                BitArray        isSick         = new BitArray(calcParameters.InternalTimesteps);
                BitArray        isOnVacation   = new BitArray(calcParameters.InternalTimesteps);
                var             personDto      = CalcPersonDto.MakeExamplePerson();
                Random          r  = new Random();
                Mock <ILogFile> lf = new Mock <ILogFile>();
                using (CalcRepo calcRepo = new CalcRepo(rnd: r, lf: lf.Object, calcParameters: calcParameters))
                {
                    CalcLocation cloc = new CalcLocation("blub", Guid.NewGuid().ToStrGuid());
                    var          cp   = new CalcPerson(personDto,
                                                       cloc, isSick, isOnVacation, calcRepo);

                    /*"personname", 1, 1, null, 1, PermittedGender.Female, lf: null,
                     * householdKey: "hh1", startingLocation: null, traitTag: "traittag",
                     * householdName: "hhname0",calcParameters:calcParameters,isSick:isSick, guid:Guid.NewGuid().ToStrGuid());
                     */
                    var fft = new FileFactoryAndTracker(wd.WorkingDirectory, "testhh", wd.InputDataLogger);
                    fft.RegisterHousehold(new HouseholdKey("hh1"), "test key", HouseholdKeyType.Household, "desc", null, null);
                    fft.RegisterHousehold(Constants.GeneralHouseholdKey, "general key", HouseholdKeyType.General, "desc", null, null);
                    fft.MakeFile <StreamWriter>("file1", "desc", true, ResultFileID.Actions,
                                                new HouseholdKey("hh1"), TargetDirectory.Charts, TimeSpan.FromMinutes(1),
                                                CalcOption.HouseholdContents,
                                                clt.ConvertToLoadTypeInformation(),
                                                cp.MakePersonInformation());
                    //fft.ResultFileList.WriteResultEntries(wd.WorkingDirectory);
                    ResultFileEntryLogger rfel = new ResultFileEntryLogger(wd.SqlResultLoggingService);
                    var rfes = rfel.Load();
                    rfes.Count.Should().BeGreaterThan(0);
                    //ResultFileList.ReadResultEntries(wd.WorkingDirectory);
                    fft.GetResultFileEntry(ResultFileID.Actions, clt.Name, new HouseholdKey("hh1"), cp.MakePersonInformation(), null);
                    fft.Dispose();
                }
                wd.CleanUp();
            }
        }
示例#7
0
 public void BasicTest()
 {
     using (WorkingDir wd = new WorkingDir(Utili.GetCurrentMethodAndClass()))
     {
         wd.InputDataLogger.AddSaver(new ResultFileEntryLogger(wd.SqlResultLoggingService));
         wd.InputDataLogger.AddSaver(new HouseholdKeyLogger(wd.SqlResultLoggingService));
         CalcParameters calcParameters = CalcParametersFactory.MakeGoodDefaults().EnableShowSettlingPeriod().SetSettlingDays(5);
         using (FileFactoryAndTracker fft = new FileFactoryAndTracker(wd.WorkingDirectory, "blub", wd.InputDataLogger))
         {
             fft.RegisterGeneralHouse();
             fft.RegisterHousehold(new HouseholdKey("HH1"), "test", HouseholdKeyType.Household, "desc",
                                   null, null);
             ThoughtsLogFile tlf = new ThoughtsLogFile(fft, calcParameters);
             Random          rnd = new Random();
             //NormalRandom nr = new NormalRandom(0, 0.1, rnd);
             // this array is pure nonsense and only to make it stop crashing the unit test
             //_calcParameters.InternalDateTimeForSteps = new List<DateTime>(4);
             //for (int i = 0; i < 4; i++)
             //{
             //  _calcParameters.InternalDateTimeForSteps.Add(DateTime.Now);
             //}
             CalcLocation    cloc         = new CalcLocation("cloc", Guid.NewGuid().ToStrGuid());
             BitArray        isSick       = new BitArray(calcParameters.InternalTimesteps);
             BitArray        isOnVacation = new BitArray(calcParameters.InternalTimesteps);
             CalcPersonDto   dto          = CalcPersonDto.MakeExamplePerson();
             Mock <ILogFile> lf           = new Mock <ILogFile>();
             NormalRandom    nr           = new NormalRandom(0, 0.1, rnd);
             using (CalcRepo calcRepo = new CalcRepo(rnd: rnd, lf: lf.Object, calcParameters: calcParameters, normalRandom: nr))
             {
                 CalcPerson cp = new CalcPerson(dto,
                                                cloc, isSick, isOnVacation, calcRepo);
                 //"personName", 0, 1, rnd, 1, PermittedGender.Male, null, "HH1" ,cloc,"traittag", "hhname0",calcParameters,isSick,Guid.NewGuid().ToStrGuid());
                 TimeStep     ts = new TimeStep(0, 0, false);
                 ThoughtEntry te = new ThoughtEntry(cp, ts, "blua");
                 calcParameters.SetSettlingDays(0);
                 tlf.WriteEntry(te, new HouseholdKey("HH1"));
             }
             tlf.Dispose();
         }
         wd.CleanUp();
     }
 }
示例#8
0
        public void TestBasics()
        {
            // needs major redesign of calcperson class
            using (WorkingDir wd = new WorkingDir(Utili.GetCurrentMethodAndClass()))
            {// StreamFactory sf = new StreamFactory();
                DateTime       startdate      = new DateTime(2018, 1, 1);
                DateTime       enddate        = startdate.AddMinutes(100);
                CalcParameters calcParameters = CalcParametersFactory.MakeGoodDefaults().SetStartDate(startdate).SetEndDate(enddate).EnableShowSettlingPeriod().SetSettlingDays(0);
                wd.InputDataLogger.AddSaver(new HouseholdKeyLogger(wd.SqlResultLoggingService));
                wd.InputDataLogger.AddSaver(new ResultFileEntryLogger(wd.SqlResultLoggingService));
                using (var fft = new FileFactoryAndTracker(wd.WorkingDirectory, "test1", wd.InputDataLogger))
                {
                    fft.RegisterHousehold(Constants.GeneralHouseholdKey, "general", HouseholdKeyType.General, "desc", null, null);
                    //SqlResultLoggingService srls = new SqlResultLoggingService(wd.WorkingDirectory);
                    CalculationProfiler profiler = new CalculationProfiler();
                    CalcRepo            calcRepo = CalcRepo.Make(calcParameters, wd.InputDataLogger, wd.WorkingDirectory, "name", profiler);
                    DesiresLogFile      dlf      = new DesiresLogFile(fft, calcParameters);
                    CalcDesire          cd1      = new CalcDesire("desire1", 1, 0.5m, 12, 1, 1, 60, -1, null, "", "");

                    //NormalRandom nr = new NormalRandom(0, 0.1, r);
                    CalcLocation  cloc         = new CalcLocation("cloc", Guid.NewGuid().ToStrGuid());
                    BitArray      isSick       = new BitArray(calcParameters.InternalTimesteps);
                    BitArray      isOnVacation = new BitArray(calcParameters.InternalTimesteps);
                    CalcPersonDto calcPerson   = CalcPersonDto.MakeExamplePerson();
                    CalcPerson    cp           = new CalcPerson(calcPerson, cloc,
                                                                isSick, isOnVacation, calcRepo);
                    //"bla", 1, 5, r, 48, PermittedGender.Male, lf, "HH1", cloc, "traittag", "hhname0",calcParameters,isSick,Guid.NewGuid().ToStrGuid());
                    cp.PersonDesires.AddDesires(cd1);
                    dlf.RegisterDesires(cp.PersonDesires.Desires.Values);
                    TimeStep    ts = new TimeStep(0, 0, true);
                    DesireEntry de = new DesireEntry(cp, ts, cp.PersonDesires, dlf, calcParameters);
                    fft.RegisterHousehold(new HouseholdKey("hh1"), "bla", HouseholdKeyType.Household, "desc", null, null);
                    dlf.WriteEntry(de, new HouseholdKey("hh1"));
                    dlf.Dispose();
                }
                wd.CleanUp();
            }
        }
        public void CheckForCriticalThreshold([NotNull] CalcPerson person, [NotNull] TimeStep time, [NotNull] FileFactoryAndTracker fft,
                                              [NotNull] HouseholdKey householdKey)
        {
            if (time.ExternalStep < 0 &&
                !time.ShowSettling)
            {
                return;
            }

            var builder = new StringBuilder();

            foreach (var calcDesire in Desires)
            {
                if (calcDesire.Value.CriticalThreshold > 0)
                {
                    if (calcDesire.Value.Value < calcDesire.Value.CriticalThreshold)
                    {
                        builder.Append("1");
                    }
                    else
                    {
                        builder.Append("0");
                    }
                    builder.Append(_calcRepo.CalcParameters.CSVCharacter);
                }
            }
            if (builder.Length > 0)
            {
                var sb = new StringBuilder();
                _dsc.GenerateDateStampForTimestep(time, sb);

                if (_sw == null)
                {
                    var personNumber = _persons.Count;
                    _persons.Add(new Tuple <string, HouseholdKey>(person.Name, householdKey), personNumber);
                    _sw = fft.MakeFile <StreamWriter>(
                        "CriticalThresholdViolations." + householdKey + "." + person + ".csv",
                        "Lists the critical threshold violations for " + person, true,
                        ResultFileID.CriticalThresholdViolations, householdKey,
                        TargetDirectory.Debugging, _calcRepo.CalcParameters.InternalStepsize, CalcOption.CriticalViolations, null, person.MakePersonInformation());
                    var header = _dsc.GenerateDateStampHeader();
                    foreach (var calcDesire in Desires)
                    {
                        if (calcDesire.Value.CriticalThreshold > 0)
                        {
#pragma warning disable CC0039 // Don't concatenate strings in loops
                            header += calcDesire.Value.Name;
                            header += _calcRepo.CalcParameters.CSVCharacter;
#pragma warning restore CC0039 // Don't concatenate strings in loops
                        }
                    }
                    if (_sw == null)
                    {
                        throw new LPGException("SW was null");
                    }
                    _sw.WriteLine(header);
                }
                sb.Append(builder);
                _sw.WriteLine(sb);
            }
        }
 public ThoughtEntry([NotNull] CalcPerson pPerson, [NotNull] TimeStep pTimestep, [NotNull] string pThought)
 {
     Person   = pPerson;
     Timestep = pTimestep;
     Thought  = pThought;
 }
        public void TestInterruptionTest()
        {
            using var wd = new WorkingDir(Utili.GetCurrentMethodAndClass());
            DateTime       startdate      = new DateTime(2018, 1, 1);
            DateTime       enddate        = startdate.AddMinutes(100);
            CalcParameters calcParameters = CalcParametersFactory.MakeGoodDefaults().SetStartDate(startdate).SetEndDate(enddate).SetSettlingDays(0).EnableShowSettlingPeriod().DisableShowSettlingPeriod().SetAffordanceRepetitionCount(1);
            //var r = new Random(1);
            //var nr = new NormalRandom(0, 1, r);
            var desire1 = new CalcDesire("desire1", 1, 0.5m, 4, 1, 1, 60, -1, null, "", "");
            var lt      = new CalcLoadType("calcLoadtype1", "kwh", "W", 1, true, Guid.NewGuid().ToStrGuid());

            //var variableOperator = new VariableOperator();
            using var fft = new FileFactoryAndTracker(wd.WorkingDirectory, "blub", wd.InputDataLogger);
            var key = new HouseholdKey("HH1");

            wd.InputDataLogger.AddSaver(new ActionEntryLogger(wd.SqlResultLoggingService));
            wd.InputDataLogger.AddSaver(new ColumnEntryLogger(wd.SqlResultLoggingService));
            wd.InputDataLogger.AddSaver(new HouseholdKeyLogger(wd.SqlResultLoggingService));
            wd.InputDataLogger.AddSaver(new ResultFileEntryLogger(wd.SqlResultLoggingService));
            wd.InputDataLogger.AddSaver(new LocationEntryLogger(wd.SqlResultLoggingService));
            fft.RegisterHousehold(key, "hh1", HouseholdKeyType.Household, "desc", null, null);
            fft.RegisterHousehold(Constants.GeneralHouseholdKey, "General", HouseholdKeyType.General, "Desc", null, null);
            //SqlResultLoggingService srls = new SqlResultLoggingService(wd.WorkingDirectory);
            DateStampCreator dsc = new DateStampCreator(calcParameters);

            using OnlineLoggingData old = new OnlineLoggingData(dsc, wd.InputDataLogger, calcParameters);
            using var lf = new LogFile(calcParameters, fft);
            var           cloc         = new CalcLocation("loc1", Guid.NewGuid().ToStrGuid());
            BitArray      isSick       = new BitArray(calcParameters.InternalTimesteps);
            BitArray      isOnVacation = new BitArray(calcParameters.InternalTimesteps);
            CalcPersonDto calcPerson   = CalcPersonDto.MakeExamplePerson();
            var           odap         = new OnlineDeviceActivationProcessor(old, calcParameters, fft);
            Random        rnd          = new Random();
            NormalRandom  nr           = new NormalRandom(0, 1, rnd);

            using CalcRepo calcRepo = new CalcRepo(lf: lf, odap: odap, calcParameters: calcParameters, rnd: rnd, normalRandom: nr, onlineLoggingData: old);
            var cp = new CalcPerson(calcPerson, cloc, isSick, isOnVacation, calcRepo);

            //"blub", 1, 1, r,20, PermittedGender.Male, lf, "HH1", cloc,"traittag","hhname0", calcParameters,isSick, Guid.NewGuid().ToStrGuid());
            cp.PersonDesires.AddDesires(desire1);
            cp.SicknessDesires.AddDesires(desire1);
            var deviceLoads = new List <CalcDeviceLoad>
            {
                new CalcDeviceLoad("devload1", 1, lt, 100, 1)
            };
            var           devCategoryGuid = Guid.NewGuid().ToStrGuid();
            CalcDeviceDto cdd1            = new CalcDeviceDto("cdevice1", devCategoryGuid, key,
                                                              OefcDeviceType.Device, "category", "", Guid.NewGuid().ToStrGuid(),
                                                              cloc.Guid, cloc.Name);
            var           cdev1 = new CalcDevice(deviceLoads, cloc, cdd1, calcRepo);
            CalcDeviceDto cdd2  = new CalcDeviceDto("cdevice2", devCategoryGuid, key,
                                                    OefcDeviceType.Device, "category", "", Guid.NewGuid().ToStrGuid(),
                                                    cloc.Guid, cloc.Name);
            var           cdev2 = new CalcDevice(deviceLoads, cloc, cdd2, calcRepo);
            CalcDeviceDto cdd3  = new CalcDeviceDto("cdevice3", devCategoryGuid, key,
                                                    OefcDeviceType.Device, "category", "", Guid.NewGuid().ToStrGuid(),
                                                    cloc.Guid, cloc.Name);
            var cdev3 = new CalcDevice(deviceLoads, cloc, cdd3, calcRepo);

            cloc.Devices.Add(cdev1);
            cloc.Devices.Add(cdev2);
            cloc.Devices.Add(cdev3);
            var daylight = new BitArray(100);

            daylight.SetAll(true);
            DayLightStatus dls = new DayLightStatus(daylight);

            double[] newValues = { 1, 1, 1.0, 1, 1, 1, 1, 1 };
            var      newList   = new List <double>(newValues);
            var      cprof     = new CalcProfile("cp1", Guid.NewGuid().ToStrGuid(), newList, ProfileType.Relative, "bla");

            var desires = new List <CalcDesire>
            {
                desire1
            };
            var color = new ColorRGB(255, 0, 0);
            CalcVariableRepository crv = new CalcVariableRepository();
            BitArray isBusy            = new BitArray(calcParameters.InternalTimesteps, false);
            var      aff1 = new CalcAffordance("aff1", cprof, cloc, false, desires, 1, 100,
                                               PermittedGender.All, false, 0, color, "aff category", true, false,
                                               new List <CalcAffordanceVariableOp>(), new List <VariableRequirement>(),
                                               ActionAfterInterruption.GoBackToOld, "bla", 100, false, "",
                                               Guid.NewGuid().ToStrGuid(), crv
                                               , new List <CalcAffordance.DeviceEnergyProfileTuple>(), isBusy, BodilyActivityLevel.Low, calcRepo);

            aff1.AddDeviceTuple(cdev1, cprof, lt, 0, calcParameters.InternalStepsize, 1, 1);
            cloc.AddAffordance(aff1);
            var aff2 = new CalcAffordance("aff2", cprof, cloc, false, desires, 1, 100,
                                          PermittedGender.All, false, 0, color, "aff category", false, false,
                                          new List <CalcAffordanceVariableOp>(), new List <VariableRequirement>(),
                                          ActionAfterInterruption.GoBackToOld, "bla", 100, false, "", Guid.NewGuid().ToStrGuid(), crv
                                          , new List <CalcAffordance.DeviceEnergyProfileTuple>(), isBusy, BodilyActivityLevel.Low, calcRepo);

            aff2.AddDeviceTuple(cdev2, cprof, lt, 0, calcParameters.InternalStepsize, 1, 1);
            cloc.AddAffordance(aff2);
            var clocs = new List <CalcLocation>
            {
                cloc
            };
            BitArray isBusySub         = new BitArray(calcParameters.InternalTimesteps, false);
            var      calcSubAffordance = new CalcSubAffordance("subaffname", cloc, desires, 0,
                                                               100, 1,
                                                               PermittedGender.All, "subaff", false, true,
                                                               aff1, new List <CalcAffordanceVariableOp>(), 100,
                                                               "testing", Guid.NewGuid().ToStrGuid(), isBusySub, crv, BodilyActivityLevel.Low,
                                                               calcRepo);

            aff2.SubAffordances.Add(calcSubAffordance);
            calcSubAffordance.SetDurations(2);
            var persons = new List <CalcPerson>
            {
                cp
            };

            for (var i = 0; i < 100; i++)
            {
                TimeStep ts = new TimeStep(i, 0, true);
                cp.NextStep(ts, clocs, dls, new HouseholdKey("hh1"), persons, 1);
            }

            //wd.CleanUp();
        }