private string GenerageArgumentString(ModellerController controller) { var scenarioString = string.Join(",", ScenarioNumbers.Select(v => v.ToString())); var linkString = "\"" + string.Join(",", TransitLinesConsidered.Select(b => b.ReturnFilter(controller))) + "\""; return("\"" + scenarioString + "\" " + linkString + "\"" + Path.GetFullPath(RevenueResults) + "\" "); }
private string GetArguments(ModellerController controller) { var scenarioString = string.Join(",", ScenarioNumbers.Select(v => v.ToString())); var penaltyString = "\"" + string.Join(",", BoardingPenalties.Select(b => b.ReturnFilter(controller))) + "\""; return("\"" + scenarioString + "\" " + penaltyString); }
internal string ReturnFilter(ModellerController controller) { string filterExpression = Label.Replace('"', '\'') + ":"; if (!String.IsNullOrWhiteSpace(CustomFilter)) { filterExpression += CustomFilter.Replace('"', '\''); } else if (!String.IsNullOrWhiteSpace(LineFilter) && !String.IsNullOrWhiteSpace(ModeFilter)) { filterExpression += (LineFilter.Contains("=") ? LineFilter.Replace('"', '\'') : "line=" + LineFilter.Replace('"', '\'')) + " and " + (ModeFilter.Contains("=") ? ModeFilter.Replace('"', '\'') : "mode=" + ModeFilter.Replace('"', '\'')); } else if (!String.IsNullOrWhiteSpace(LineFilter)) { filterExpression += (LineFilter.Contains("=") ? LineFilter.Replace('"', '\'') : "line=" + LineFilter.Replace('"', '\'')); } else { filterExpression += (ModeFilter.Contains("=") ? ModeFilter.Replace('"', '\'') : "mode=" + ModeFilter.Replace('"', '\'')); } return(filterExpression); }
private string GenerageArgumentString(ModellerController controller) { var scenarioString = string.Join(",", ScenarioNumbers.Select(v => v.ToString())); var filterString = "\"" + string.Join(",", OperatorsToConsider.Select(b => b.ReturnFilter(controller))) + "\""; return("\"" + scenarioString + "\" " + filterString + "\"" + Path.GetFullPath(RidershipResults) + "\" "); }
private void Dispose(bool all) { if (this.Controller != null) { this.Controller.Dispose(); this.Controller = null; } }
public void RunPostAssignments() { ExecuteToolList(FinalIteration); if (Controller != null) { Controller.Dispose(); Controller = null; } }
private void Dispose(bool all) { if (all) { GC.SuppressFinalize(this); } Controller?.Dispose(); Controller = null; }
public void RunPostAssignments() { this.ExecuteToolList(this.FinalIteration); if (this.Controller != null) { this.Controller.Dispose(); this.Controller = null; } }
internal string ReturnFilter(ModellerController controller) { string filterExpression = Label.Replace('"', '\'') + ":"; filterExpression += (TransitLineFilter.Contains("=") ? TransitLineFilter.Replace('"', '\'') : "line=" + TransitLineFilter.Replace('"', '\'')); return(filterExpression); }
internal string ReturnFilter(ModellerController controller) { return(Label.Replace('"', '\'') + ":" + (!String.IsNullOrWhiteSpace(LineFilter) ? "line=" + LineFilter.Replace('"', '\'') : "") + (!String.IsNullOrWhiteSpace(LineFilter) && !String.IsNullOrWhiteSpace(ModeFilter) ? " and " : "") + (!String.IsNullOrWhiteSpace(ModeFilter) ? "mode=" + (ModeFilter == "\"" ? "'" : ModeFilter) : "") + ": " + controller.ToEmmeFloat(Penalty).ToString() + ": " + controller.ToEmmeFloat(IVTTPerception).ToString()); }
private void AttachCentroids(ModellerController controller, List <int> nodesToExplore, List <int> newControids, List <int> currentlyExploring) { //The goal is to execute our new tool in order to controller.Run(this, AttachCentroidToNodeTool, string.Join(" ", Scenario.ToString(), "\"" + string.Join(";", currentlyExploring.Select(i => nodesToExplore[i].ToString())) + "\"", "\"" + string.Join(";", newControids.Select(i => i.ToString())) + "\"" )); }
public void Start() { // Create the bridge between XTMF and emme's modeller using (ModellerController emme = new ModellerController(this.EmmeProjectFile, this.PerformanceTesting)) { if (this.CleanLogbook) { emme.CleanLogbook(); } // now that we have the connection, run the tool emme.Run(this.MacroName, this.MacroArguments); } }
private void PassMatrixIntoEmme(ModellerController mc) { var flatZones = this.Root.ZoneSystem.ZoneArray.GetFlatData(); var numberOfZones = flatZones.Length; // Load the data from the flows and save it to our temporary file string outputFileName = Path.GetTempFileName(); float[][] tally = new float[numberOfZones][]; for (int i = 0; i < numberOfZones; i++) { tally[i] = new float[numberOfZones]; } for (int i = Tallies.Count - 1; i >= 0; i--) { Tallies[i].IncludeTally(tally); } using (StreamWriter writer = new StreamWriter(outputFileName)) { writer.WriteLine("t matrices\r\nd matrix=mf{0}\r\na matrix=mf{0} name=drvtot default=0 descr=generated", this.DemandMatrixNumber); StringBuilder[] builders = new StringBuilder[numberOfZones]; Parallel.For(0, numberOfZones, delegate(int o) { var build = builders[o] = new StringBuilder(); var strBuilder = new StringBuilder(10); var convertedO = flatZones[o].ZoneNumber; for (int d = 0; d < numberOfZones; d++) { this.ToEmmeFloat(tally[o][d], strBuilder); build.AppendFormat("{0,-4:G} {1,-4:G} {2,-4:G}\r\n", convertedO, flatZones[d].ZoneNumber, strBuilder); } }); for (int i = 0; i < numberOfZones; i++) { writer.Write(builders[i]); } } try { mc.Run("TMG2.XTMF.ImportMatrix", "\"" + outputFileName + "\" " + ScenarioNumber); } finally { File.Delete(outputFileName); } }
internal static void InitializeEMME() { if (Modeller == null) { lock (typeof(Helper)) { if (Modeller == null) { //Load the configuration var configFile = new FileInfo("TMG.EMME.Test.Configuration.json"); if (!configFile.Exists) { Assert.Fail("Configuration file \"TMG.EMME.Test.Configuration.json\" does not exist please create it to run tests."); } else { var reader = new Utf8JsonReader(File.ReadAllBytes(configFile.FullName)); while (reader.Read()) { if (reader.TokenType == JsonTokenType.PropertyName) { if (reader.ValueTextEquals(ProjectFileProperty)) { reader.Read(); ProjectFile = reader.GetString(); } } } } // in this case we are debugging the unit test if (Debugger.IsAttached) { Modeller = new ModellerController(null, ProjectFile, "DEBUG_EMME", launchInNewProcess: false); } else { Modeller = new ModellerController(null, ProjectFile); } } } } }
private void ExecuteToolList(List <IEmmeTool> tools) { if (Execute) { if (Controller == null) { Controller = new ModellerController(this, EmmeProjectFile, EmmeDatabank, PerformanceAnalysis); } CurrentProgress = 0.0f; ProgressIncrement = 1.0f / tools.Count; foreach (var tool in tools) { CurrentToolStatus = tool.Name; GetToolProgress = (() => tool.Progress); tool.Execute(Controller); CurrentProgress += ProgressIncrement; GetToolProgress = (() => 0.0f); } } }
private void ExecuteToolList(List <IEmmeTool> tools) { if (this.Execute) { if (this.Controller == null) { this.Controller = new ModellerController(this.EmmeProjectFile, this.PerformanceAnalysis); } this.currentProgress = 0.0f; this.progressIncrement = 1.0f / tools.Count; foreach (var tool in tools) { this.currentToolStatus = tool.Name; getToolProgress = (() => tool.Progress); tool.Execute(this.Controller); currentProgress += progressIncrement; getToolProgress = (() => 0.0f); } } }
static Helper() { //Load the configuration var configFile = new FileInfo("TMG.EMME.Test.Configuration.json"); if (!configFile.Exists) { Assert.Fail("Configuration file \"TMG.EMME.Test.Configuration.json\" does not exist please create it to run tests."); } else { using (var reader = new JsonTextReader(configFile.OpenText())) { while (reader.Read()) { if (reader.TokenType == JsonToken.PropertyName) { switch (reader.Value) { case "ProjectFile": ProjectFile = reader.ReadAsString(); break; } } } } } // in this case we are debugging the unit test if (Debugger.IsAttached) { Modeller = new ModellerController(null, ProjectFile, "DEBUG_EMME", launchInNewProcess: false); } else { Modeller = new ModellerController(null, ProjectFile); } }
internal string ReturnFilter(ModellerController controller) { string filter = Label.Replace('"', '\'') + ":" + "link=" + ijLink.Replace('"', '\''); return(filter); }
private void PassMatrixIntoEmme(ModellerController mc) { var flatZones = Root.ZoneSystem.ZoneArray.GetFlatData(); var numberOfZones = flatZones.Length; // Load the data from the flows and save it to our temporary file var useTempFile = String.IsNullOrWhiteSpace(DemandFileName); string outputFileName = useTempFile ? Path.GetTempFileName() : DemandFileName; float[][] tally = new float[numberOfZones][]; for (int i = 0; i < numberOfZones; i++) { tally[i] = new float[numberOfZones]; } for (int i = Tallies.Count - 1; i >= 0; i--) { Tallies[i].IncludeTally(tally); } var dir = Path.GetDirectoryName(outputFileName); if (!String.IsNullOrWhiteSpace(dir) && !Directory.Exists(dir)) { Directory.CreateDirectory(dir); } using (StreamWriter writer = new StreamWriter(outputFileName)) { writer.WriteLine("t matrices\r\na matrix=mf{0} name=drvtot default=0 descr=generated", DemandMatrixNumber); StringBuilder[] builders = new StringBuilder[numberOfZones]; Parallel.For(0, numberOfZones, delegate(int o) { var build = builders[o] = new StringBuilder(); var strBuilder = new StringBuilder(10); var convertedO = flatZones[o].ZoneNumber; for (int d = 0; d < numberOfZones; d++) { Controller.ToEmmeFloat(tally[o][d], strBuilder); build.AppendFormat("{0,-4:G} {1,-4:G} {2}\r\n", convertedO, flatZones[d].ZoneNumber, strBuilder); } }); for (int i = 0; i < numberOfZones; i++) { writer.Write(builders[i]); } } try { if (mc.CheckToolExists(this, NewImportToolName)) { mc.Run(this, NewImportToolName, "\"" + Path.GetFullPath(outputFileName) + "\" " + ScenarioNumber); } else { mc.Run(this, OldImportToolName, "\"" + Path.GetFullPath(outputFileName) + "\" " + ScenarioNumber); } } finally { if (useTempFile) { File.Delete(outputFileName); } } }
private string GetArguments(ModellerController controller) { var scenarioString = string.Join(",", ScenarioNumbers.Select(v => v.ToString())); var penaltyString = "\"" + string.Join(",", BoardingPenalties.Select(b => b.ReturnFilter(controller))) + "\""; return "\""+scenarioString + "\" "+ penaltyString; }
internal string ReturnFilter(ModellerController controller) { return Label.Replace('"', '\'') + ":" + (!String.IsNullOrWhiteSpace(LineFilter) ? "line=" + LineFilter.Replace('"', '\'') : "") + (!String.IsNullOrWhiteSpace(LineFilter) && !String.IsNullOrWhiteSpace(ModeFilter) ? " and " : "") + (!String.IsNullOrWhiteSpace(ModeFilter) ? "mode=" + (ModeFilter == "\"" ? "'" : ModeFilter) : "") + ": " + controller.ToEmmeFloat(Penalty).ToString() + ": " + controller.ToEmmeFloat(IVTTPerception).ToString(); }
internal string ReturnFilter(ModellerController controller) { return(TimePeriodLabel.Replace('"', '\'') + ":" + ScenarioNumber.ToString()); }