private SamplingWeightsCalculator(string variableName, int mode, int pathType, double vot, int minute)
        {
            Framework.DomainModels.Persisters.IPersisterReader <IZone> zoneReader =
                Global
                .ContainerDaySim.GetInstance <IPersistenceFactory <IZone> >()
                .Reader;

            Framework.DomainModels.Persisters.IPersisterReader <IParcel> parcelReader =
                Global
                .ContainerDaySim
                .GetInstance <IPersistenceFactory <IParcel> >()
                .Reader;

            IParcelCreator parcelCreator =
                Global
                .ContainerDaySim
                .GetInstance <IWrapperFactory <IParcelCreator> >()
                .Creator;

            _eligibleZones =
                zoneReader
                .Where(z => z.DestinationEligible)
                .ToDictionary(z => z.Id, z => z);

            foreach (IParcel parcel in parcelReader)
            {
                if (_eligibleZones.TryGetValue(parcel.ZoneId, out IZone zone))
                {
                    _eligibleParcels.Add(parcelCreator.CreateWrapper(parcel));
                }

                if (_parcelCounts.ContainsKey(parcel.ZoneId))
                {
                    _parcelCounts[parcel.ZoneId]++;
                }
                else
                {
                    _parcelCounts.Add(parcel.ZoneId, 1);
                }
            }

            _zoneCount    = zoneReader.Count;
            _segmentCount = Global.ContainerDaySim.GetInstance <SamplingWeightsSettingsFactory>().SamplingWeightsSettings.SizeFactors.GetLength(0);
            _variableName = variableName;
            _mode         = mode;
            _pathType     = pathType;
            _vot          = vot;
            _minute       = minute;
        }
        private ISubzone[][] CalculateZoneSubzones()
        {
            SubzoneFactory subzoneFactory = new SubzoneFactory(Global.Configuration);

            ISubzone[][] zoneSubzones = new ISubzone[_zoneCount][];

            for (int id = 0; id < _zoneCount; id++)
            {
                ISubzone[] subzones = new ISubzone[TOTAL_SUBZONES];

                zoneSubzones[id] = subzones;

                for (int subzone = 0; subzone < TOTAL_SUBZONES; subzone++)
                {
                    subzones[subzone] = subzoneFactory.Create(subzone);
                }
            }

            Framework.DomainModels.Persisters.IPersisterReader <IParcel> parcelReader =
                Global
                .ContainerDaySim
                .GetInstance <IPersistenceFactory <IParcel> >()
                .Reader;

            IParcelCreator parcelCreator =
                Global
                .ContainerDaySim
                .GetInstance <IWrapperFactory <IParcelCreator> >()
                .Creator;

            foreach (IParcel parcel in parcelReader)
            {
                Framework.DomainModels.Wrappers.IParcelWrapper parcelWrapper = parcelCreator.CreateWrapper(parcel);

                ISubzone[] subzones = zoneSubzones[parcelWrapper.ZoneId];
                // var subzone = (parcel.GetDistanceToTransit() > 0 && parcel.GetDistanceToTransit() <= .5) ? 0 : 1;
                // JLBscale replaced above with following:
                int subzone = (parcelWrapper.GetDistanceToTransit() / Global.Settings.DistanceUnitsPerMile > 0 && parcelWrapper.GetDistanceToTransit() / Global.Settings.DistanceUnitsPerMile <= .5) ? 0 : 1;

                subzones[subzone].Households           += parcelWrapper.Households;
                subzones[subzone].StudentsK8           += parcelWrapper.StudentsK8;
                subzones[subzone].StudentsHighSchool   += parcelWrapper.StudentsHighSchool;
                subzones[subzone].StudentsUniversity   += parcelWrapper.StudentsUniversity;
                subzones[subzone].EmploymentEducation  += parcelWrapper.EmploymentEducation;
                subzones[subzone].EmploymentFood       += parcelWrapper.EmploymentFood;
                subzones[subzone].EmploymentGovernment += parcelWrapper.EmploymentGovernment;
                subzones[subzone].EmploymentIndustrial += parcelWrapper.EmploymentIndustrial;
                subzones[subzone].EmploymentMedical    += parcelWrapper.EmploymentMedical;
                subzones[subzone].EmploymentOffice     += parcelWrapper.EmploymentOffice;
                subzones[subzone].EmploymentRetail     += parcelWrapper.EmploymentRetail;
                subzones[subzone].EmploymentService    += parcelWrapper.EmploymentService;
                subzones[subzone].EmploymentTotal      += parcelWrapper.EmploymentTotal;
                //Removed following that are not defined the same way in actum.  Need to accommodate parking soem other way
                //subzones[subzone].ParkingOffStreetPaidDailySpaces += parcelWrapper.ParkingOffStreetPaidDailySpaces;
                //subzones[subzone].ParkingOffStreetPaidHourlySpaces += parcelWrapper.ParkingOffStreetPaidHourlySpaces;
            }

            foreach (ISubzone[] subzones in _eligibleZones.Values.Select(zone => zoneSubzones[zone.Id]))
            {
                for (int subzone = 0; subzone < TOTAL_SUBZONES; subzone++)
                {
                    double       hou = subzones[subzone].Households;
                    double       k12 = subzones[subzone].StudentsK8 + subzones[subzone].StudentsHighSchool;
                    double       uni = subzones[subzone].StudentsUniversity;
                    double       edu = subzones[subzone].EmploymentEducation;
                    double       foo = subzones[subzone].EmploymentFood;
                    double       gov = subzones[subzone].EmploymentGovernment;
                    double       ind = subzones[subzone].EmploymentIndustrial;
                    double       med = subzones[subzone].EmploymentMedical;
                    double       off = subzones[subzone].EmploymentOffice;
                    double       ret = subzones[subzone].EmploymentRetail;
                    double       ser = subzones[subzone].EmploymentService;
                    double       tot = subzones[subzone].EmploymentTotal;
                    const double oth = 0;

                    double subtotal = foo + ret + ser + med;


                    //subzones[subzone].MixedUseMeasure = Math.Log(1 + subtotal * (subzones[subzone]).ParkingOffStreetPaidHourlySpaces * 100 / Math.Max(subtotal + (subzones[subzone]).ParkingOffStreetPaidHourlySpaces * 100, Constants.EPSILON));
                    //zeroed out above MixedUseMeasure because it relies on parking variable not available for actum
                    subzones[subzone].MixedUseMeasure = 0;

                    subzones[subzone].SetSize(Global.Settings.Purposes.HomeBasedComposite, ComputeSize(Math.Exp(HBG019) * edu + Math.Exp(HBG020) * foo + Math.Exp(HBG021) * gov + Math.Exp(HBG022) * off + Math.Exp(HBG023) * oth + Math.Exp(HBG024) * ret + Math.Exp(HBG025) * ser + Math.Exp(HBG026) * med + Math.Exp(HBG027) * ind + Math.Exp(HBG029) * hou + Math.Exp(HBG030) * uni + Math.Exp(HBG031) * k12));
                    subzones[subzone].SetSize(Global.Settings.Purposes.WorkBased, ComputeSize(Math.Exp(WBG019) * edu + Math.Exp(WBG020) * foo + Math.Exp(WBG021) * gov + Math.Exp(WBG022) * off + Math.Exp(WBG023) * oth + Math.Exp(WBG024) * ret + Math.Exp(WBG025) * ser + Math.Exp(WBG026) * med + Math.Exp(WBG027) * ind + Math.Exp(WBG029) * hou + Math.Exp(WBG030) * uni));
                    subzones[subzone].SetSize(Global.Settings.Purposes.Escort, ComputeSize(Math.Exp(PSG067) * edu + Math.Exp(PSG068) * foo + Math.Exp(PSG069) * gov + Math.Exp(PSG070) * off + Math.Exp(PSG071) * oth + Math.Exp(PSG072) * ret + Math.Exp(PSG073) * ser + Math.Exp(PSG074) * med + Math.Exp(PSG075) * ind + Math.Exp(PSG077) * hou + Math.Exp(PSG078) * uni + k12));
                    subzones[subzone].SetSize(Global.Settings.Purposes.PersonalBusiness, ComputeSize(Math.Exp(PSG080) * edu + Math.Exp(PSG081) * foo + Math.Exp(PSG082) * gov + Math.Exp(PSG083) * off + Math.Exp(PSG084) * oth + Math.Exp(PSG085) * ret + Math.Exp(PSG086) * ser + Math.Exp(PSG087) * med + Math.Exp(PSG088) * ind + Math.Exp(PSG090) * hou + Math.Exp(PSG091) * uni));
                    subzones[subzone].SetSize(Global.Settings.Purposes.Shopping, ComputeSize(Math.Exp(PSG094) * foo + Math.Exp(PSG095) * gov + Math.Exp(PSG097) * oth + Math.Exp(PSG098) * ret + Math.Exp(PSG099) * ser + Math.Exp(PSG100) * med + Math.Exp(PSG103) * hou + Math.Exp(PSG105) * k12));
                    subzones[subzone].SetSize(Global.Settings.Purposes.Meal, ComputeSize(Math.Exp(PSG107) * foo + Math.Exp(PSG115) * tot + Math.Exp(PSG117) * uni));
                    subzones[subzone].SetSize(Global.Settings.Purposes.Social, ComputeSize(Math.Exp(PSG119) * edu + Math.Exp(PSG120) * foo + Math.Exp(PSG121) * gov + Math.Exp(PSG122) * off + Math.Exp(PSG123) * oth + Math.Exp(PSG125) * ser + Math.Exp(PSG126) * med + Math.Exp(PSG129) * hou + Math.Exp(PSG130) * uni));
                }
            }

            return(zoneSubzones);
        }
Exemple #3
0
        public static void LoadData()
        {
            Framework.DomainModels.Persisters.IPersisterReader <IParcel> parcelReader =
                Global
                .ContainerDaySim.GetInstance <IPersistenceFactory <IParcel> >()
                .Reader;

            IParcelCreator parcelCreator =
                Global
                .ContainerDaySim
                .GetInstance <IWrapperFactory <IParcelCreator> >()
                .Creator;

            Parcels = new Dictionary <int, IParcelWrapper>(parcelReader.Count);

            Framework.DomainModels.Persisters.IPersisterReader <IZone> zoneReader =
                Global
                .ContainerDaySim
                .GetInstance <IPersistenceFactory <IZone> >()
                .Reader;

            //            ZoneTotals = new Dictionary<int, ZoneTotals>(zoneReader.Count);
            ZoneKeys = new Dictionary <int, int>(zoneReader.Count);

            Dictionary <int, IZone> zones = new Dictionary <int, IZone>();

            foreach (IZone zone in zoneReader)
            {
                ZoneKeys.Add(zone.Id, zone.Key);
                zones.Add(zone.Id, zone);
            }

            Dictionary <int, Framework.ShadowPricing.IShadowPriceParcel> shadowPrices = ShadowPriceReader.ReadShadowPrices();

            foreach (IParcel parcel in parcelReader)
            {
                IParcelWrapper parcelWrapper = parcelCreator.CreateWrapper(parcel);

                Parcels.Add(parcel.Id, parcelWrapper);


                if (zones.TryGetValue(parcel.ZoneId, out IZone zone))
                {
                    parcelWrapper.District = zone.External;
                }

                parcelWrapper.SetShadowPricing(zones, shadowPrices);

                //                ZoneTotals zoneTotals;
                //
                //                if (!ZoneTotals.TryGetValue(parcel.ZoneId, out zoneTotals)) {
                //                    zoneTotals = new ZoneTotals();
                //
                //                    ZoneTotals.Add(parcel.ZoneId, zoneTotals);
                //                }
                //
                //                zoneTotals.SumTotals(parcel);
            }

            if (Global.DestinationParkingNodeIsEnabled)
            {
                DestinationParkingNodeDao = new DestinationParkingNodeDao();
            }
            if (Global.ParkAndRideNodeIsEnabled)
            {
                ParkAndRideNodeDao = new ParkAndRideNodeDao();
            }
        }