From 2c009f8b137ec5631577cc620b512bea29d04cb9 Mon Sep 17 00:00:00 2001 From: mabcal Date: Mon, 22 Oct 2018 17:57:54 -0700 Subject: [PATCH] Close #177 Close #178 Close #179 --- DaySim.Framework/Core/Configuration.cs | 8 ++--- .../AggregateLogsumsCalculator.cs | 20 +++++------ .../AggregateLogsumsCalculator_Actum.cs | 34 +++++++++---------- .../AggregateLogsumsExporter.cs | 12 +++++-- DaySim/Engine.cs | 2 +- DaySim/Sampling/SamplingWeightsCalculator.cs | 24 ++++++------- 6 files changed, 53 insertions(+), 47 deletions(-) diff --git a/DaySim.Framework/Core/Configuration.cs b/DaySim.Framework/Core/Configuration.cs index 57282f62..fa3414de 100644 --- a/DaySim.Framework/Core/Configuration.cs +++ b/DaySim.Framework/Core/Configuration.cs @@ -1000,8 +1000,8 @@ public sealed class Configuration { [XmlAttribute] public int RandomSeed { get; set; } - [XmlAttribute] - public bool ShouldLoadAggregateLogsumsFromFile { get; set; } + //[XmlAttribute] + //public bool ShouldLoadAggregateLogsumsFromFile { get; set; } [XmlAttribute] public bool ShouldOutputAggregateLogsums { get; set; } @@ -1010,8 +1010,8 @@ public sealed class Configuration { public string OutputAggregateLogsumsPath { get; set; } - [XmlAttribute] - public bool ShouldLoadSamplingWeightsFromFile { get; set; } + //[XmlAttribute] + //public bool ShouldLoadSamplingWeightsFromFile { get; set; } [XmlAttribute] public bool ShouldOutputSamplingWeights { get; set; } diff --git a/DaySim/AggregateLogsums/AggregateLogsumsCalculator.cs b/DaySim/AggregateLogsums/AggregateLogsumsCalculator.cs index 6abe0ec4..37291963 100644 --- a/DaySim/AggregateLogsums/AggregateLogsumsCalculator.cs +++ b/DaySim/AggregateLogsums/AggregateLogsumsCalculator.cs @@ -281,9 +281,9 @@ public sealed class AggregateLogsumsCalculator : IAggregateLogsumsCalculator { public AggregateLogsumsCalculator() { FileInfo file = Global.AggregateLogsumsPath.ToFile(); - if (Global.Configuration.ShouldLoadAggregateLogsumsFromFile && file.Exists) { - return; - } + //if (Global.Configuration.ShouldLoadAggregateLogsumsFromFile && file.Exists) { + // return; + //} Framework.DomainModels.Persisters.IPersisterReader zoneReader = Global @@ -299,11 +299,11 @@ public AggregateLogsumsCalculator() { public void Calculate(IRandomUtility randomUtility) { FileInfo file = Global.AggregateLogsumsPath.ToFile(); - if (Global.Configuration.ShouldLoadAggregateLogsumsFromFile && file.Exists) { - Global.AggregateLogsums = LoadAggregateLogsumsFromFile(file); + //if (Global.Configuration.ShouldLoadAggregateLogsumsFromFile && file.Exists) { + // Global.AggregateLogsums = LoadAggregateLogsumsFromFile(file); - return; - } + // return; + // } Global.AggregateLogsums = new double[_zoneCount][][][][]; @@ -329,9 +329,9 @@ public void Calculate(IRandomUtility randomUtility) { } } - if (Global.Configuration.ShouldLoadAggregateLogsumsFromFile && !file.Exists) { - SaveAggregateLogsumsToFile(file); - } + //if (Global.Configuration.ShouldLoadAggregateLogsumsFromFile && !file.Exists) { + // SaveAggregateLogsumsToFile(file); + //} } private void CalculateZone(IRandomUtility randomUtility, int id) { diff --git a/DaySim/AggregateLogsums/AggregateLogsumsCalculator_Actum.cs b/DaySim/AggregateLogsums/AggregateLogsumsCalculator_Actum.cs index b0f072ea..78306b92 100644 --- a/DaySim/AggregateLogsums/AggregateLogsumsCalculator_Actum.cs +++ b/DaySim/AggregateLogsums/AggregateLogsumsCalculator_Actum.cs @@ -1,4 +1,4 @@ -// Copyright 2005-2008 Mark A. Bradley and John L. Bowman +// Copyright 2005-2008 Mark A. Bradley and John L. Bowman // Copyright 2011-2013 John Bowman, Mark Bradley, and RSG, Inc. // You may not possess or use this file without a License for its use. // Unless required by applicable law or agreed to in writing, software @@ -280,9 +280,9 @@ public sealed class AggregateLogsumsCalculator_Actum : IAggregateLogsumsCalculat public AggregateLogsumsCalculator_Actum() { FileInfo file = Global.AggregateLogsumsPath.ToFile(); - if (Global.Configuration.ShouldLoadAggregateLogsumsFromFile && file.Exists) { - return; - } + //if (Global.Configuration.ShouldLoadAggregateLogsumsFromFile && file.Exists) { + // return; + //} Framework.DomainModels.Persisters.IPersisterReader zoneReader = Global @@ -298,11 +298,11 @@ public AggregateLogsumsCalculator_Actum() { public void Calculate(IRandomUtility randomUtility) { FileInfo file = Global.AggregateLogsumsPath.ToFile(); - if (Global.Configuration.ShouldLoadAggregateLogsumsFromFile && file.Exists) { - Global.AggregateLogsums = LoadAggregateLogsumsFromFile(file); + //if (Global.Configuration.ShouldLoadAggregateLogsumsFromFile && file.Exists) { + // Global.AggregateLogsums = LoadAggregateLogsumsFromFile(file); - return; - } + // return; + // } Global.AggregateLogsums = new double[_zoneCount][][][][]; @@ -329,22 +329,22 @@ public void Calculate(IRandomUtility randomUtility) { } } - if (Global.Configuration.ShouldLoadAggregateLogsumsFromFile && !file.Exists) { - SaveAggregateLogsumsToFile(file); - } + //if (Global.Configuration.ShouldLoadAggregateLogsumsFromFile && !file.Exists) { + // SaveAggregateLogsumsToFile(file); + //} } private void CalculateZone(IRandomUtility randomUtility, int id) { Global.AggregateLogsums[id] = ComputeZone(randomUtility, id); } - private double[][][][][] LoadAggregateLogsumsFromFile(FileInfo file) { - using (FileStream stream = file.Open(FileMode.Open, FileAccess.Read, FileShare.Read)) { - BinaryFormatter formatter = new BinaryFormatter(); + //private double[][][][][] LoadAggregateLogsumsFromFile(FileInfo file) { + // using (FileStream stream = file.Open(FileMode.Open, FileAccess.Read, FileShare.Read)) { + // BinaryFormatter formatter = new BinaryFormatter(); - return (double[][][][][])formatter.Deserialize(stream); - } - } + // return (double[][][][][])formatter.Deserialize(stream); + // } + //} private void SaveAggregateLogsumsToFile(FileInfo file) { using (FileStream stream = file.Open(FileMode.Create, FileAccess.Write, FileShare.Read)) { diff --git a/DaySim/AggregateLogsums/AggregateLogsumsExporter.cs b/DaySim/AggregateLogsums/AggregateLogsumsExporter.cs index c09f79be..751dbdc6 100644 --- a/DaySim/AggregateLogsums/AggregateLogsumsExporter.cs +++ b/DaySim/AggregateLogsums/AggregateLogsumsExporter.cs @@ -45,7 +45,11 @@ private static void RunExport(string path) { FileInfo file = new FileInfo(Path.Combine(directory, string.Format("{0}.{1}{2}", filename, purpose, extension))); using (StreamWriter writer = new StreamWriter(file.Open(FileMode.Create, FileAccess.Write, FileShare.Read))) { - writer.WriteLine("ZONE\tCHILD/SHO\tCHILD/LON\tCHILD/NAV\tNOCAR/SHO\tNOCAR/LON\tNOCAR/NAV\tCCOMP/SHO\tCCOMP/LON\tCCOMP/NAV\tCFULL/SHO\tCFULL/LON\tCFULL/NAV"); + writer.Write("ZONE\t"); + writer.Write("CHILD/LVOT/CLOSE\tCHILD/LVOT/FAR\tCHILD/LVOT/NAV\tCHILD/MVOT/CLOSE\tCHILD/MVOT/FAR\tCHILD/MVOT/NAV\tCHILD/HVOT/CLOSE\tCHILD/HVOT/FAR\tCHILD/HVOT/NAV\t"); + writer.Write("NOCAR/LVOT/CLOSE\tNOCAR/LVOT/FAR\tNOCAR/LVOT/NAV\tNOCAR/MVOT/CLOSE\tNOCAR/MVOT/FAR\tNOCAR/MVOT/NAV\tNOCAR/HVOT/CLOSE\tNOCAR/HVOT/FAR\tNOCAR/HVOT/NAV\t"); + writer.Write("CCOMP/LVOT/CLOSE\tCCOMP/LVOT/FAR\tCCOMP/LVOT/NAV\tCCOMP/MVOT/CLOSE\tCCOMP/MVOT/FAR\tCCOMP/MVOT/NAV\tCCOMP/HVOT/CLOSE\tCCOMP/HVOT/FAR\tCCOMP/HVOT/NAV\t"); + writer.WriteLine("FULLCO/LVOT/CLOSE\tFULLCO/LVOT/FAR\tFULLCO/LVOT/NAV\tFULLCO/MVOT/CLOSE\tFULLCO/MVOT/FAR\tFULLCO/MVOT/NAV\tFULLCO/HVOT/CLOSE\tFULLCO/HVOT/FAR\tFULLCO/HVOT/NAV"); for (int id = 0; id < zoneCount; id++) { IZone zone = zoneReader.Seek(id); @@ -64,7 +68,9 @@ private static void RunExport(string path) { for (int transitAccess = Global.Settings.TransitAccesses.Gt0AndLteQtrMi; transitAccess < Global.Settings.TransitAccesses.TotalTransitAccesses; transitAccess++) { writer.Write(string.Format("{0,9:f5}", transitAccesses[transitAccess])); - if ((carOwnership + 1) * (transitAccess + 1) != Global.Settings.CarOwnerships.TotalCarOwnerships * Global.Settings.TransitAccesses.TotalTransitAccesses) { + if (carOwnership + 1 != Global.Settings.CarOwnerships.TotalCarOwnerships || + votALSegment + 1 != Global.Settings.VotALSegments.TotalVotALSegments || + transitAccess + 1 != Global.Settings.TransitAccesses.TotalTransitAccesses) { writer.Write("\t"); } } @@ -79,4 +85,4 @@ private static void RunExport(string path) { } } } -} \ No newline at end of file +} diff --git a/DaySim/Engine.cs b/DaySim/Engine.cs index b698b499..f3e4a3bb 100644 --- a/DaySim/Engine.cs +++ b/DaySim/Engine.cs @@ -1115,7 +1115,7 @@ public static void InitializeParcelStopAreaIndex(TextReader reader) { } private static void BeginLoadMicrozoneToBikeCarParkAndRideNodeDistances() { - if (!Global.StopAreaIsEnabled) { + if (!Global.StopAreaIsEnabled|| Global.Configuration.DataType != "Actum") { return; } if (string.IsNullOrEmpty(Global.Configuration.MicrozoneToParkAndRideNodeIndexPath)) { diff --git a/DaySim/Sampling/SamplingWeightsCalculator.cs b/DaySim/Sampling/SamplingWeightsCalculator.cs index 1477e578..b2f4a185 100644 --- a/DaySim/Sampling/SamplingWeightsCalculator.cs +++ b/DaySim/Sampling/SamplingWeightsCalculator.cs @@ -90,24 +90,24 @@ public static void Calculate(string variableName, int mode, int pathType, double private static void CalculateSegment(SamplingWeightsCalculator samplingWeightsCalculator, int segment) { FileInfo file = new FileInfo(string.Format(Global.SamplingWeightsPath, segment)); - if (Global.Configuration.ShouldLoadSamplingWeightsFromFile && file.Exists) { - Global.SegmentZones[segment] = LoadSamplingWeightsFromFile(file); + //if (Global.Configuration.ShouldLoadSamplingWeightsFromFile && file.Exists) { + // Global.SegmentZones[segment] = LoadSamplingWeightsFromFile(file); - return; - } + // return; + //} Global.SegmentZones[segment] = samplingWeightsCalculator.ComputeSegment(segment); - if (Global.Configuration.ShouldLoadSamplingWeightsFromFile && !file.Exists) { - SaveSamplingWeightsToFile(file, segment); - } + //if (Global.Configuration.ShouldLoadSamplingWeightsFromFile && !file.Exists) { + // SaveSamplingWeightsToFile(file, segment); + //} } - private static SegmentZone[] LoadSamplingWeightsFromFile(FileInfo file) { - using (FileStream stream = file.Open(FileMode.Open, FileAccess.Read, FileShare.Read)) { - return SegmentZoneFormatter.Deserialize(stream); - } - } + //private static SegmentZone[] LoadSamplingWeightsFromFile(FileInfo file) { + // using (FileStream stream = file.Open(FileMode.Open, FileAccess.Read, FileShare.Read)) { + // return SegmentZoneFormatter.Deserialize(stream); + // } + //} private static void SaveSamplingWeightsToFile(FileInfo file, int segment) { using (FileStream stream = file.Open(FileMode.Create, FileAccess.Write, FileShare.Read)) {