Ejemplo n.º 1
0
 public void Start()
 {
     using (ModellerController controller = new ModellerController(this, EmmeProjectFile, EmmeDatabank, PerformanceTesting))
     {
         if (CleanLogbook)
         {
             controller.CleanLogbook(this);
         }
         string ret = null;
         controller.Run(this, EmmeToolName, EmmeToolArguments, (p) => Progress = p, ref ret);
     }
 }
Ejemplo n.º 2
0
 public void Start()
 {
     if (this.Tools.Count == 0 | !this.Execute)
     {
         return;
     }
     using (Controller controller = new ModellerController(this.EmmeProjectFile))
     {
         var length = this.Tools.Count;
         int i      = 0;
         CalculateProgress = new Func <float>(() => this.Tools[i].Progress * (1.0f / length) + (i / (float)length));
         for ( ; i < length; i++)
         {
             this.Tools[i].Execute(controller);
         }
     }
     this.CalculateProgress = null;
 }
Ejemplo n.º 3
0
 public void Start()
 {
     if (Tools.Count == 0 | !Execute)
     {
         return;
     }
     using (Controller controller = new ModellerController(this, EmmeProjectFile, EmmeDatabank, String.IsNullOrWhiteSpace(EmmePath) ? null : EmmePath))
     {
         var length = Tools.Count;
         int i      = 0;
         // ReSharper disable AccessToModifiedClosure
         CalculateProgress = () => Tools[i].Progress * (1.0f / length) + (i / (float)length);
         for (; i < length; i++)
         {
             Tools[i].Execute(controller);
         }
     }
     CalculateProgress = null;
 }
Ejemplo n.º 4
0
 private string GenerageArgumentString(ModellerController controller)
 {
     var scenarioString = string.Join(",", ScenarioNumbers.Select(v => v.ToString()));
     var linkString = "\"" + string.Join(";", LinksConsidered.Select(b => b.ReturnFilter(controller))) + "\"";
     return "\"" + scenarioString + "\" " + linkString + "\"" + Path.GetFullPath(LinkVolumeResults) + "\" " + TransitFlag.ToString();
 }
Ejemplo n.º 5
0
 internal string ReturnFilter(ModellerController controller)
 {
     string filter = Label.Replace('"', '\'') + ":" + "link=" + ijLink.Replace('"', '\'');
     return filter;
 }
Ejemplo n.º 6
0
 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) + "\" ";
 }
Ejemplo n.º 7
0
            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;
            }
Ejemplo n.º 8
0
 public void Start()
 {
     if ( this.Tools.Count == 0 | !this.Execute ) return;
     using ( Controller controller = new ModellerController( this.EmmeProjectFile ) )
     {
         var length = this.Tools.Count;
         int i = 0;
         CalculateProgress = new Func<float>( () => this.Tools[i].Progress * ( 1.0f / length ) + ( i / (float)length ) );
         for ( ; i < length; i++ )
         {
             this.Tools[i].Execute( controller );
         }
     }
     this.CalculateProgress = null;
 }
Ejemplo n.º 9
0
 public void Start()
 {
     using ( ModellerController controller = new ModellerController( this.EmmeProjectFile, this.PerformanceTesting ) )
     {
         if ( this.CleanLogbook )
         {
             controller.CleanLogbook();
         }
         string ret = null;
         controller.Run( this.EmmeToolName, this.EmmeToolArguments, (p) => this.Progress = p, ref ret );
     }
 }
Ejemplo n.º 10
0
 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 );
         }
     }
 }
Ejemplo n.º 11
0
 private void Dispose(bool all)
 {
     if ( this.Controller != null )
     {
         this.Controller.Dispose();
         this.Controller = null;
     }
 }
Ejemplo n.º 12
0
 public void RunPostAssignments()
 {
     this.ExecuteToolList( this.FinalIteration );
     if ( this.Controller != null )
     {
         this.Controller.Dispose();
         this.Controller = null;
     }
 }
Ejemplo n.º 13
0
 internal string ReturnFilter(ModellerController controller)
 {
     return TimePeriodLabel.Replace('"', '\'') + ":" + ScenarioNumber.ToString();
 }
Ejemplo n.º 14
0
        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 );
            }
        }
Ejemplo n.º 15
0
            internal string ReturnFilter(ModellerController controller)
            {
                string filterExpression = Label.Replace('"', '\'') + ":";

                filterExpression +=
                        (TransitLineFilter.Contains("=") ? TransitLineFilter.Replace('"', '\'') : "line=" + TransitLineFilter.Replace('"', '\''));

                return filterExpression;
            }
Ejemplo n.º 16
0
        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
            var useTempFile = String.IsNullOrWhiteSpace( this.DemandFileName );
            string outputFileName = useTempFile ? Path.GetTempFileName() : this.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", 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
            {
                if(mc.CheckToolExists(NewImportToolName))
                {
                    mc.Run(NewImportToolName, "\"" + Path.GetFullPath(outputFileName) + "\" " + ScenarioNumber);
                }
                else
                {
                    mc.Run(OldImportToolName, "\"" + Path.GetFullPath(outputFileName) + "\" " + ScenarioNumber);
                }
            }
            finally
            {
                if ( useTempFile )
                {
                    File.Delete( outputFileName );
                }
            }
        }
Ejemplo n.º 17
0
 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);
     }
 }