Esempio n. 1
0
 public static CalcParameters MakeGoodDefaults()
 {
     CalcParameters cp = CalcParameters.GetNew();
     cp.SetStartDate(2018, 1, 1).SetEndDate(2018, 12, 31);
     cp.SetInternalTimeResolution(new TimeSpan(0, 1, 0)).SetExternalTimeResolution(new TimeSpan(0, 1, 0));
     cp.SetCsvCharacter(";");
     cp.SetLoadTypePriority(LoadTypePriority.RecommendedForHouses);
     cp.DisableShowSettlingPeriod();
     cp.SetSettlingDays(3);
     cp.SetRandomSeed(17,false);
     cp.SetWriteExcelColumn(false);
     cp.SetAffordanceRepetitionCount(3);
     cp.CheckSettings();
     return cp;
 }
Esempio n. 2
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();
     }
 }
Esempio n. 3
0
 public CalcParameters MakeCalculationParametersFromConfig([NotNull] CalcStartParameterSet csps, bool forceRandom)
 {
     CalcParameters cp = CalcParameters.GetNew();
     cp.LoadtypesToPostprocess = csps.LoadTypesToProcess;
     cp.SetDeleteDatFiles(csps.DeleteDatFiles);
     cp.SetWriteExcelColumn (csps.WriteExcelColumn);
     cp.SetManyOptionsWithClear(csps.CalcOptions);
     FileFactoryAndTrackerDummy fftd = new FileFactoryAndTrackerDummy();
     var container =PostProcessingManager.RegisterEverything(csps.ResultPath,csps.CalculationProfiler, fftd);
     using (var scope = container.BeginLifetimeScope())
     {
         var odm = scope.Resolve<OptionDependencyManager>();
         odm.EnableRequiredOptions(cp.Options);
     }
     cp.SetShowSettlingPeriod(csps.ShowSettlingPeriod);
     cp.SetRandomSeed(csps.SelectedRandomSeed, forceRandom);
     cp.SetCsvCharacter(csps.CsvCharacter);
     cp.SetStartDate(csps.OfficialSimulationStartTime);
     cp.SetEndDate(csps.OfficialSimulationEndTime.AddDays(1));
     cp.SetInternalTimeResolution(csps.InternalTimeResolution);
     cp.SetExternalTimeResolution(csps.ExternalTimeResolution);
     cp.SetLoadTypePriority(csps.LoadTypePriority);
     cp.SetSettlingDays(csps.SettlingDays);
     cp.SetAffordanceRepetitionCount(csps.AffordanceRepetitionCount);
     cp.DeviceProfileHeaderMode = csps.DeviceProfileHeaderMode;
     cp.IgnorePreviousActivitesWhenNeeded = csps.IgnorePreviousActivitiesWhenNeeded;
     cp.TransportationEnabled = csps.TransportationEnabled;
     if (cp.TransportationEnabled && csps.CalcTarget.CalcObjectType == CalcObjectType.House) {
         if (csps.ChargingStationSet != null) {
             throw new LPGException("trying to set transportation options on a house. that won't work.");
         }
         if (csps.TransportationDeviceSet != null)
         {
             throw new LPGException("trying to set transportation options on a house. that won't work.");
         }
         if (csps.TravelRouteSet != null)
         {
             throw new LPGException("trying to set transportation options on a house. that won't work.");
         }
     }
     if (cp.TransportationEnabled && csps.CalcTarget.CalcObjectType == CalcObjectType.ModularHousehold)
     {
         if (csps.ChargingStationSet == null)
         {
             throw new LPGException("Trying to set transportation options on a household without charging station set. That won't work.");
         }
         if (csps.TransportationDeviceSet == null)
         {
             throw new LPGException("Trying to set transportation options on a household without transportation device set. That won't work.");
         }
         if (csps.TravelRouteSet != null)
         {
             throw new LPGException("trying to set transportation options on a house. that won't work.");
         }
     }
     cp.CheckSettings();
     //transport mode
     /*if (csps.TransportationDeviceSet != null || csps.TravelRouteSet != null) {
         cp.SetTransportMode(true);
         if (csps.TransportationDeviceSet == null ) {
             throw new DataIntegrityException("Only a transportation device set was defined, but not a travel route set. This can't work.");
         }
         if (csps.TravelRouteSet == null)
         {
             throw new DataIntegrityException("Only a travel route set was defined, but not a transportation device set. This can't work.");
         }
     }*/
     return cp;
 }