Skip to content

Commit

Permalink
Close #177 Close #178 Close #179
Browse files Browse the repository at this point in the history
  • Loading branch information
mabcal committed Oct 23, 2018
1 parent f3fe400 commit 2c009f8
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 47 deletions.
8 changes: 4 additions & 4 deletions DaySim.Framework/Core/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand All @@ -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; }
Expand Down
20 changes: 10 additions & 10 deletions DaySim/AggregateLogsums/AggregateLogsumsCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<IZone> zoneReader =
Global
Expand All @@ -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][][][][];

Expand All @@ -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) {
Expand Down
34 changes: 17 additions & 17 deletions DaySim/AggregateLogsums/AggregateLogsumsCalculator_Actum.cs
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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<IZone> zoneReader =
Global
Expand All @@ -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][][][][];

Expand All @@ -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)) {
Expand Down
12 changes: 9 additions & 3 deletions DaySim/AggregateLogsums/AggregateLogsumsExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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");
}
}
Expand All @@ -79,4 +85,4 @@ private static void RunExport(string path) {
}
}
}
}
}
2 changes: 1 addition & 1 deletion DaySim/Engine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
24 changes: 12 additions & 12 deletions DaySim/Sampling/SamplingWeightsCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 2c009f8

Please sign in to comment.