Exemplo n.º 1
0
 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());
 }
Exemplo n.º 2
0
        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=from_xtmf", 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++)
                    {
                        build.AppendFormat("{0,-4:G} {1,-4:G} {2,-6:G}\r\n",
                                           convertedO, flatZones[d].ZoneNumber, mc.ToEmmeFloat(tally[o][d]));
                    }
                });
                for (int i = 0; i < numberOfZones; i++)
                {
                    writer.Write(builders[i]);
                }
            }

            try
            {
                if (mc.CheckToolExists(_ImportToolName))
                {
                    mc.Run(_ImportToolName, "\"" + Path.GetFullPath(outputFileName) + "\" " + ScenarioNumber);
                }
                else
                {
                    mc.Run(_OldImportToolName, "\"" + Path.GetFullPath(outputFileName) + "\" " + ScenarioNumber);
                }
            }
            finally
            {
                if (useTempFile)
                {
                    File.Delete(outputFileName);
                }
            }
        }
Exemplo n.º 3
0
 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();
 }