private static void ExportRankedWeights(TextWriter writer, int key, IPersisterReader <IZone> zoneReader, IEnumerable <WeightSegmentItem> segmentItems) { foreach (WeightSegmentItem segmentItem in segmentItems) { IZone zone = zoneReader.Seek(segmentItem.Id); writer.Write(key); writer.Write("\t"); writer.Write(zone.Key); writer.Write("\t"); writer.Write(segmentItem.Value.ToString("f7")); writer.WriteLine(); } }
public PersonDayWrapper(IPersonDay personDay, IPersonWrapper personWrapper, IHouseholdDayWrapper householdDayWrapper) { _personDay = personDay; _exporter = Global .Kernel .Get <IPersistenceFactory <IPersonDay> >() .Exporter; // person day fields _personDayCreator = Global .Kernel .Get <IWrapperFactory <IPersonDayCreator> >() .Creator; // tour fields _tourReader = Global .Kernel .Get <IPersistenceFactory <ITour> >() .Reader; _tourCreator = Global .Kernel .Get <IWrapperFactory <ITourCreator> >() .Creator; // relations properties Household = personWrapper.Household; Person = personWrapper; HouseholdDay = householdDayWrapper; // domain model properies SetExpansionFactor(); // flags/choice model/etc. properties TimeWindow = new TimeWindow(); }
public HalfTour(TourWrapper tour) { _t = tour; // trip fields _tripReader = Global .ContainerDaySim .GetInstance <IPersistenceFactory <ITrip> >() .Reader; _tripWrapperCreator = Global .ContainerDaySim .GetInstance <IWrapperFactory <ITripCreator> >() .Creator; }
public HalfTour(TourWrapper tour) { _t = tour; // trip fields _tripReader = Global .Kernel .Get <IPersistenceFactory <ITrip> >() .Reader; _tripWrapperCreator = Global .Kernel .Get <IWrapperFactory <ITripCreator> >() .Creator; }
public HouseholdWrapper(IHousehold household) { _household = household; _exporter = Global .Kernel .Get <IPersistenceFactory <IHousehold> >() .Exporter; // person fields _personReader = Global .Kernel .Get <IPersistenceFactory <IPerson> >() .Reader; _personCreator = Global .Kernel .Get <IWrapperFactory <IPersonCreator> >() .Creator; // household day fields _householdDayReader = Global .Kernel .Get <IPersistenceFactory <IHouseholdDay> >() .Reader; _householdDayCreator = Global .Kernel .Get <IWrapperFactory <IHouseholdDayCreator> >() .Creator; RandomUtility = new RandomUtility(); }
private static void RunExport(string path) { string directory = Path.GetDirectoryName(path); if (directory == null) { return; } string filename = Path.GetFileNameWithoutExtension(path); string extension = Path.GetExtension(path); int segmentCount = Global.SegmentZones.GetLength(0); IPersisterReader <IZone> zoneReader = Global .ContainerDaySim.GetInstance <IPersistenceFactory <IZone> >() .Reader; for (int segment = 0; segment < segmentCount; segment++) { FileInfo file = new FileInfo(Path.Combine(directory, string.Format("{0}.{1}{2}", filename, segment, extension))); using (StreamWriter writer = new StreamWriter(file.Open(FileMode.Create, FileAccess.Write, FileShare.Read))) { SegmentZone[] segmentZones = Global.SegmentZones[segment]; int zoneCount = segmentZones.GetLength(0); FileInfo sizesFile = new FileInfo(Path.Combine(directory, string.Format("{0}.{1}.sizes{2}", filename, segment, extension))); StreamWriter sizesWriter = new StreamWriter(sizesFile.Open(FileMode.Create, FileAccess.Write, FileShare.Read)); FileInfo weightsFile = new FileInfo(Path.Combine(directory, string.Format("{0}.{1}.weights{2}", filename, segment, extension))); StreamWriter weightsWriter = new StreamWriter(weightsFile.Open(FileMode.Create, FileAccess.Write, FileShare.Read)); for (int zoneId = 0; zoneId < zoneCount; zoneId++) { SegmentZone segmentZone = segmentZones[zoneId]; if (segmentZone == null) { continue; } IZone zone = zoneReader.Seek(zoneId); writer.Write(zone.Key); writer.Write("\t"); writer.Write(segmentZone.TotalSize.ToString("f7")); writer.Write("\t"); writer.Write(segmentZone.TotalWeight.ToString("f7")); writer.WriteLine(); ExportRankedSizes(sizesWriter, zone.Key, segmentZone.RankedSizes); ExportRankedWeights(weightsWriter, zone.Key, zoneReader, segmentZone.RankedWeights); sizesWriter.Flush(); weightsWriter.Flush(); } sizesWriter.Dispose(); weightsWriter.Dispose(); } Global.PrintFile.WriteFileInfo(file, true); } }
public HouseholdDayWrapper(IHouseholdDay householdDay, IHouseholdWrapper householdWrapper) { _householdDay = householdDay; _exporter = Global .Kernel .Get <IPersistenceFactory <IHouseholdDay> >() .Exporter; // household day fields _householdDayCreator = Global .Kernel .Get <IWrapperFactory <IHouseholdDayCreator> >() .Creator; // person day fields _personDayReader = Global .Kernel .Get <IPersistenceFactory <IPersonDay> >() .Reader; _personDayCreator = Global .Kernel .Get <IWrapperFactory <IPersonDayCreator> >() .Creator; // joint tour fields _jointTourReader = Global .Kernel .Get <IPersistenceFactory <IJointTour> >() .Reader; _jointTourCreator = Global .Kernel .Get <IWrapperFactory <IJointTourCreator> >() .Creator; // full half tour fields _fullHalfTourReader = Global .Kernel .Get <IPersistenceFactory <IFullHalfTour> >() .Reader; _fullHalfTourCreator = Global .Kernel .Get <IWrapperFactory <IFullHalfTourCreator> >() .Creator; // partial half tour fields _partialHalfTourReader = Global .Kernel .Get <IPersistenceFactory <IPartialHalfTour> >() .Reader; _partialHalfTourCreator = Global .Kernel .Get <IWrapperFactory <IPartialHalfTourCreator> >() .Creator; // relations properties Household = householdWrapper; SetPersonDays(); // domain model properies SetExpansionFactor(); if (!Global.Settings.UseJointTours) { return; } SetJointTours(); SetFullHalfTours(); SetPartialHalfTours(); }