private static double GetSchoolCarbonProduction(List <ComputationUnit> homes, List <ComputationUnit> schools) { if (schools.Count == 0) { return(0); } // 初始化 schoolCollections Dictionary <ComputationUnit, List <ComputationUnit> > schoolCollections = new Dictionary <ComputationUnit, List <ComputationUnit> >(); foreach (var school in schools) { schoolCollections.Add(school, new List <ComputationUnit>()); } // 划分教学片区 foreach (var home in homes) { ComputationUnit shool = GetNearestSchool(home, schools); List <ComputationUnit> schoolAreas = schoolCollections[shool]; schoolAreas.Add(home); } // 分片区计算 double sum = 0; foreach (var reagion in schoolCollections) { sum += GetOneReagionCarbonProduction(reagion.Key, reagion.Value); } return(sum); }
public ComputationUnit(ComputationUnit other) { this.Feature = other.Feature; this.UnitType = other.UnitType; this.Type = other.Type; this.MixOfficePercent = other.MixOfficePercent; this.MixIndustryPercent = other.MixIndustryPercent; this.MixEducationPercent = other.MixEducationPercent; this.MixHotelPercent = other.MixHotelPercent; this.MixGreenFieldPercent = other.MixGreenFieldPercent; this.MixOtherPercent = other.MixOtherPercent; this.MixRetailPercent = other.MixRetailPercent; this.MixResidencialPercent = other.MixResidencialPercent; this.FAR = other.FAR; this.Levels = other.Levels; this.PerCapitaResidencial = other.PerCapitaResidencial; this.PerCapitaOffice = other.PerCapitaOffice; this.PerCapitaIndustry = other.PerCapitaIndustry; this.Populations = other.Populations; this.EnergySavingCoefficient = other.EnergySavingCoefficient; this.GreenField = other.GreenField; this.Position = other.Position; UpdateFeature(); }
private double GetCuPropertyValue(ComputationUnit cu) { double result = cu.GetPropertyValue(Property) .TryToString() .TryParseToDouble(); return(_selector(result, cu)); }
public LcTypeTheme() { var dict = new Dictionary <string, Color> { { "Office", Colors.Magenta }, { "Residencial", Colors.Yellow }, { "Hotel", Colors.SkyBlue }, { "Retail", Colors.Red }, { "Education", Colors.Chocolate }, { "GreenField", Colors.Green }, { "Industry", Colors.DimGray }, { "Other", Colors.LightGray }, { "Mixed", Colors.LightBlue }, { "Unknown", Colors.LightCoral }, }; var name = new Dictionary <string, string> { { "Office", "办公" }, { "Residencial", "居住" }, { "Hotel", "旅馆" }, { "Retail", "商业" }, { "Education", "教育" }, { "GreenField", "绿地" }, { "Industry", "工业" }, { "Other", "其他" }, { "Mixed", "混合" }, { "Unknown", "未知" }, }; //英文版添加 var nameE = new Dictionary <string, string> { { "Office", "Office" }, { "Residencial", "Residencial" }, { "Hotel", "Hotel" }, { "Retail", "Retail" }, { "Education", "Education" }, { "GreenField", "GreenField" }, { "Industry", "Industry" }, { "Other", "Other" }, { "Mixed", "Mixed" }, { "Unknown", "Unknown" }, }; DictColor = new Dictionary <string, Color>(); foreach (var entry in dict) { if (LocalizationHelper.CurrentLocale == Locales.ZH_CN) { DictColor[name[entry.Key]] = entry.Value; } else { DictColor[nameE[entry.Key]] = entry.Value; } this.AddCondition(f => ComputationUnit.Get(f).Type.ToString() == entry.Key, entry.Value); } }
public static BuildingResult _GetBuildingCarbonProduction(ComputationUnit building) { BuildingResult result = new BuildingResult(); if (building.Type == BuildingType.GreenField || building.Type == BuildingType.Unknown) { return(result); } double energyUsingRatio = 1 - building.EnergySavingCoefficient.Value / 100; double otherCleanEnergyRatio = Parameter.Base.OtherCleanEnergyRatio / 100; BuildingType computeBuildingType = building.Type; if (building.Type == BuildingType.Education || building.Type == BuildingType.Industry || building.Type == BuildingType.Other || building.Type == BuildingType.Office) { computeBuildingType = building.IsHighBuilding() ? BuildingType.HighOffice : BuildingType.HighOffice; } else if (building.Type == BuildingType.Residencial) { computeBuildingType = building.IsHighBuilding() ? BuildingType.HighResidencial : BuildingType.MidHighResidencial; } // 1. 建材准备 result.Material = building.Floor * GetPrepareConstructionProduction(computeBuildingType, Parameter.Building) * energyUsingRatio; // 2. 建造过程 result.Construction = building.Floor * GetConstructionProduction(computeBuildingType, building.Structure) * energyUsingRatio; // 3. 运行维护 // a. 空调 result.Maintenance.AirConditioning = building.Floor * GetOperationProduction(computeBuildingType, Parameter.Maintenance.AirConditioning) * Parameter.Base.ElectricityProductionFactor * (1 - otherCleanEnergyRatio) * energyUsingRatio; // b. 照明 result.Maintenance.Lighting = building.Floor * GetOperationProduction(computeBuildingType, Parameter.Maintenance.Lighting) * Parameter.Base.ElectricityProductionFactor * (1 - otherCleanEnergyRatio) * energyUsingRatio; // c. 设备 result.Maintenance.Equipment = building.Floor * GetOperationProduction(computeBuildingType, Parameter.Maintenance.Equipment) * Parameter.Base.ElectricityProductionFactor * (1 - otherCleanEnergyRatio) * energyUsingRatio; // d. 供暖 result.Maintenance.Heating = building.Floor * GetOperationProduction(computeBuildingType, Parameter.Maintenance.Heating) * Parameter.Base.GasProductionFactor * (1 - otherCleanEnergyRatio) * energyUsingRatio; // 4. 拆毁回收 result.Recycle = building.Floor * GetRecycleProduction(computeBuildingType, building.Structure) * energyUsingRatio; return(result); }
void LatestMap_BeforeSave(object sender, EventArgs e) { (sender as Map).Layers.ForEach(layer => { layer.Features.ForEach(f => { ComputationUnit.Get(f).UpdateFeature(); }); }); }
public static void Attach(IFeature f, bool createNew = false) { if (createNew) { var cu = new ComputationUnit(f); cu.Area = f.Area(); f.Data[KEY] = cu; } else { f.Data[KEY] = new ComputationUnit(f); } }
public void SwitchBuildingParcel() { if (_objs != null) { foreach (var o in _objs) { ComputationUnit unit = o as ComputationUnit; unit.UpdateResult(); unit.UpdateFeature(); } PropGrid.Refresh(); } }
public void RefreshComputation() { if (_objs != null) { foreach (var o in _objs) { ComputationUnit unit = o as ComputationUnit; unit.UpdatePopulation(); unit.UpdateResult(); unit.UpdateFeature(); } PropGrid.Refresh(); } }
void SelectionSet_SelectionChanged() { if (SelectionSet.Contents.Count > 1) { _propPanel.SetObjects(SelectionSet.Contents.Select(f => ComputationUnit.Get(f)).ToArray()); } else if (SelectionSet.Contents.Count > 0) { _propPanel.SetObjects(ComputationUnit.Get(SelectionSet.Contents.First())); } else { _propPanel.SetObjects(); } }
private static double GetOneReagionCarbonProduction(ComputationUnit school, List <ComputationUnit> homes) { double studentRate = Parameter.Trip.StudentRate; var pos = school.Position; double[] dists3 = homes.Select(f => f.Position.EzDistTo(pos) / 1000).ToArray(); double[] pops3 = homes.Select(f => f.Populations).ToArray(); double sumPops3 = pops3.Sum(); double[] proportions3 = pops3.Select(p => p / sumPops3).ToArray(); double result = GetInsideCarbonProductionOfGivenRParcel(sumPops3 * studentRate, dists3, proportions3, Parameter.Trip.TripFrequencyOfSchool); return(result); }
private static ComputationUnit GetNearestSchool(ComputationUnit home, List <ComputationUnit> schools) { ComputationUnit result = null; double minDistance = double.MaxValue; foreach (var school in schools) { double distance = home.Position.Dist(school.Position); if (distance < minDistance) { result = school; } } return(result); }
private void PropertyValueChanged(ComputationUnit unit, string changedProperty) { if (changedProperty == "FAR" || changedProperty == "Levels" || changedProperty == "Type" || changedProperty == "Area" || changedProperty == "Levels" || changedProperty == "PerCapitaLivingSpace") { unit.UpdatePopulation(); } if (unit.Type == BuildingType.Mixed) { unit.IsValidMixedValue(); unit.UpdatePopulation(); } unit.UpdateResult(); unit.UpdateFeature(); }
public static double GetGreenCarbonConsumption(ComputationUnit unit) { double result = 0; if (unit.Type == BuildingType.Mixed) { ComputationUnit tmp = new ComputationUnit(unit); tmp.Area = unit.Area * unit.MixGreenFieldPercent; tmp.Type = BuildingType.GreenField; result = GetGreenCarbonConsumption(tmp); } else if (unit.Type == BuildingType.GreenField) { switch (unit.GreenField) { case GreenFieldType.Bush: result = unit.Area * Parameter.Green.BushesUnit; break; case GreenFieldType.Farm: result = unit.Area * Parameter.Green.FarmUnit; break; case GreenFieldType.Park: result = unit.Area * Parameter.Green.ParkUnit; break; case GreenFieldType.Forest: result = unit.Area * Parameter.Green.ForestUnit; break; default: result = 0; break; } } unit.GreenFieldConsumption = result; return(result); }
private void InitializeFeature(IFeature f, string layerName) { if (string.IsNullOrWhiteSpace(f["layerName"])) { f["layerName"] = layerName; } if (string.IsNullOrWhiteSpace(f["far"])) { f["far"] = "1.0"; } if (string.IsNullOrWhiteSpace(f["levels"])) { f["levels"] = "5"; } if (string.IsNullOrWhiteSpace(f["escType"])) { f["escType"] = Parameter.Base.Standard.EnergyType.ToString(); } if (string.IsNullOrWhiteSpace(f["escValue"])) { f["escValue"] = Parameter.Base.Standard.TempValue.ToString(); } if (string.IsNullOrWhiteSpace(f["perResi"])) { f["perResi"] = Parameter.Trip.PerCapitaResidencial.ToString(); } if (string.IsNullOrWhiteSpace(f["perOffic"])) { f["perOffic"] = Parameter.Trip.PerCapitaOffice.ToString(); } if (string.IsNullOrWhiteSpace(f["perIndu"])) { f["perIndu"] = Parameter.Trip.PerCapitaIndustry.ToString(); } ComputationUnit.Attach(f); }
public static BuildingResult GetBuildingCarbonProduction(ComputationUnit building) { BuildingResult result = new BuildingResult(); if (building.Type == BuildingType.Mixed) { List <BuildingResult> resultList = new List <BuildingResult>(); if (building.MixEducationPercent != 0.0 || building.MixIndustryPercent != 0.0 || building.MixOfficePercent != 0.0 || building.MixOtherPercent != 0.0) // 教育和工业属同一类型:办公 { ComputationUnit tmp = new ComputationUnit(building); tmp.Area = building.Area * (building.MixEducationPercent + building.MixIndustryPercent + building.MixOfficePercent + building.MixOtherPercent); if (tmp.IsHighBuilding()) { tmp.Type = BuildingType.HighOffice; } else { tmp.Type = BuildingType.MidHighOffice; } resultList.Add(_GetBuildingCarbonProduction(tmp)); } if (building.MixGreenFieldPercent != 0.0) { ComputationUnit tmp = new ComputationUnit(building); tmp.Area = building.Area * building.MixRetailPercent; tmp.Type = BuildingType.GreenField; resultList.Add(_GetBuildingCarbonProduction(tmp)); } if (building.MixHotelPercent != 0.0) { ComputationUnit tmp = new ComputationUnit(building); tmp.Area = building.Area * building.MixHotelPercent; tmp.Type = BuildingType.Hotel; resultList.Add(_GetBuildingCarbonProduction(tmp)); } if (building.MixResidencialPercent != 0.0) { ComputationUnit tmp = new ComputationUnit(building); tmp.Area = building.Area * building.MixResidencialPercent; if (tmp.IsHighBuilding()) { tmp.Type = BuildingType.HighResidencial; } else { tmp.Type = BuildingType.MidHighResidencial; } resultList.Add(_GetBuildingCarbonProduction(tmp)); } if (building.MixRetailPercent != 0.0) { ComputationUnit tmp = new ComputationUnit(building); tmp.Area = building.Area * building.MixRetailPercent; tmp.Type = BuildingType.Retail; resultList.Add(_GetBuildingCarbonProduction(tmp)); } foreach (var r in resultList) { result.Material += r.Material; result.Construction += r.Construction; result.Maintenance.AirConditioning += r.Maintenance.AirConditioning; result.Maintenance.Lighting += r.Maintenance.Lighting; result.Maintenance.Equipment += r.Maintenance.Equipment; result.Maintenance.Heating += r.Maintenance.Heating; result.Recycle += r.Recycle; } building.CarbonProduction = result; return(result); } else { result = _GetBuildingCarbonProduction(building); } building.CarbonProduction = result; return(result); }
public List <ComputationUnit> SplitAllMixedUnits() { List <ComputationUnit> resultList = new List <ComputationUnit>(); UpdateAllUnits(); foreach (var unit in AllUnits) { if (unit.Type == BuildingType.Mixed) { if (unit.MixOfficePercent != 0.0) { ComputationUnit tmp = new ComputationUnit(unit); tmp.Type = BuildingType.Office; tmp.Area = unit.Area * unit.MixOfficePercent; tmp.UpdatePopulation(); resultList.Add(tmp); } if (unit.MixIndustryPercent != 0.0) { ComputationUnit tmp = new ComputationUnit(unit); tmp.Type = BuildingType.Industry; tmp.Area = unit.Area * unit.MixIndustryPercent; tmp.UpdatePopulation(); resultList.Add(tmp); } if (unit.MixEducationPercent != 0.0) { ComputationUnit tmp = new ComputationUnit(unit); tmp.Type = BuildingType.Education; tmp.Area = unit.Area * unit.MixEducationPercent; tmp.UpdatePopulation(); resultList.Add(tmp); } if (unit.MixHotelPercent != 0.0) { ComputationUnit tmp = new ComputationUnit(unit); tmp.Type = BuildingType.Hotel; tmp.Area = unit.Area * unit.MixHotelPercent; tmp.UpdatePopulation(); resultList.Add(tmp); } if (unit.MixGreenFieldPercent != 0.0) { ComputationUnit tmp = new ComputationUnit(unit); tmp.Type = BuildingType.GreenField; tmp.Area = unit.Area * unit.MixGreenFieldPercent; tmp.UpdatePopulation(); resultList.Add(tmp); } if (unit.MixOtherPercent != 0.0) { ComputationUnit tmp = new ComputationUnit(unit); tmp.Type = BuildingType.Other; tmp.Area = unit.Area * unit.MixOtherPercent; tmp.UpdatePopulation(); resultList.Add(tmp); } if (unit.MixRetailPercent != 0.0) { ComputationUnit tmp = new ComputationUnit(unit); tmp.Type = BuildingType.Retail; tmp.Area = unit.Area * unit.MixRetailPercent; tmp.UpdatePopulation(); resultList.Add(tmp); } if (unit.MixResidencialPercent != 0.0) { ComputationUnit tmp = new ComputationUnit(unit); tmp.Type = BuildingType.Residencial; tmp.Area = unit.Area * unit.MixResidencialPercent; tmp.UpdatePopulation(); resultList.Add(tmp); } } else { resultList.Add(unit); } } return(resultList); }
public override double GetValue(IFeature f) { var cu = ComputationUnit.Get(f); return(GetCuPropertyValue(cu)); }
public static void Set(IFeature f, ComputationUnit cu) { f.Data[KEY] = cu; }