public bool Execute(Controller controller)
        {
            var mc = controller as ModellerController;
            if (mc == null)
            {
                throw new XTMFRuntimeException("Controller is not a ModellerController");
            }
            string result = "";
            mc.Run(_ToolName, this.ScenarioNumber.ToString(), (p => this._Progress = p), ref result);
            var modelResults = this._ParsePythonResults(result);

            StringBuilder builder = new StringBuilder();
            builder.Append(this.Root.CurrentTask.Generation);
            builder.Append(',');
            builder.Append(this.Root.CurrentTask.Index);
            builder.Append(',');
            var func = this.Root.RetrieveValue;
            builder.Append((func == null) ? "null" : func().ToString());
            foreach (var f in modelResults)
            {
                builder.Append(',');
                builder.Append(f);
            }
            foreach (var val in this.Root.CurrentTask.ParameterValues)
            {
                builder.Append(',');
                builder.Append(val.ToString());
            }
            builder.AppendLine();

            //now that we have built up the data, send it to the host
            this.SendToHost(builder.ToString());
            Console.WriteLine("Extracted line boardings from Emme.");
            return true;
        }
        public bool Execute(Controller controller)
        {
            var mc = controller as ModellerController;
            if (mc == null)
            {
                throw new XTMFRuntimeException("Controller is not a ModellerController");
            }

            var args = string.Join(" ", this.ScenarioNumber, this.PartitionId, "mf" + this.DemandMatrixNumber.ToString());
            string result = "";
            mc.Run(_ToolName, args, (p => this._Progress = p), ref result);
            var modelResults = this._ParsePythonResults(result);

            StringBuilder builder = new StringBuilder();
            foreach (var line in modelResults)
            {
                builder.Append(this.Root.CurrentTask.Generation);
                builder.Append(' ');
                builder.Append(this.Root.CurrentTask.Index);
                builder.Append(' ');
                var func = this.Root.RetrieveValue;
                builder.Append((func == null) ? "null" : func().ToString());
                builder.Append(' ');
                builder.Append(line);
                builder.AppendLine();
            }

            //now that we have built up the data, send it to the host
            this.SendToHost(builder.ToString());

            Console.WriteLine("Extracted aggregate matrices from Emme");
            return true;
        }
        public bool Execute(Controller controller)
        {
            var mc = controller as ModellerController;
            if(mc == null)
                throw new XTMFRuntimeException("Controller is not a ModellerController!");

            var s = string.Join(",", this.AttributeIdsToExport.ToArray());

            if(string.IsNullOrWhiteSpace(this.AttributeIdsToExport.ToString()))
                s += "\"\"";

            var args = string.Join(" ", this.ScenarioNumber,
                                        "\"" + Path.GetFullPath(this.ExportFile.GetFilePath()) + "\"",
                                        s);

            Console.WriteLine("Export network from scenario " + this.ScenarioNumber.ToString() + " to file " + this.ExportFile.GetFilePath());

            var result = "";
            if(mc.CheckToolExists(_ToolName))
            {
                return mc.Run(_ToolName, args, (p => this.Progress = p), ref result);
            }
            else
            {
                return mc.Run(_OldToolName, args, (p => this.Progress = p), ref result);
            }
        }
Exemple #4
0
 public bool Execute(Controller controller)
 {
     ModellerController modeller;
     if((modeller = controller as ModellerController) != null)
     {
         modeller.WriteToLogbook = WriteToLogbook;
         return true;
     }
     return false;
 }
Exemple #5
0
        public bool Execute(Controller controller)
        {
            var modeller = controller as ModellerController;
            if (modeller == null)
            {
                throw new XTMFRuntimeException("In '" + Name + "' we were not given a modeller controller!");
            }

            return modeller.Run(_ToolName, GenerageArgumentString(modeller));
        }
Exemple #6
0
        public bool Execute(Controller controller)
        {
            var mc = controller as ModellerController;
            if (mc == null)
                throw new XTMFRuntimeException("Controller is not a ModellerController!");

            string args = string.Join(" ", this.ScenarioNumber, "mf" + this.ResultMatrixNumber);
            string result = null;
            return mc.Run(_ToolName, args, (p => this.Progress = p), ref result);
        }
        public bool Execute(Controller controller)
        {
            this._progress = 0.0f;
            this._RunningTool = null;

            if (this.EmmeToolsToRun.Count == 0) return true;

            var mc = controller as ModellerController;
            if (mc == null)
                throw new XTMFRuntimeException("Controller is not a ModellerController!");

            float numberOfTasks = (float) (this.AttributesToCreate.Count + 1);
            bool[] createdAttributes = new bool[this.AttributesToCreate.Count];

            /*
            def __call__(self, xtmf_ScenarioNumber, xtmf_AttributeId, xtmf_AttributeDomain,
                 xtmf_AttributeDefault, xtmf_DeleteFlag):
            */

            try
            {
                for (int i = 0; i < createdAttributes.Length; i++)
                {
                    var attData = this.AttributesToCreate[i];
                    var args = string.Join(" ", this.ScenarioNumber, attData.Id, attData.Domain, attData.DefaultValue, false);
                    createdAttributes[i] = mc.Run(_ToolName, args);
                    this._progress = (float)( i /  createdAttributes.Length / numberOfTasks);
                }
                this._progress = 1.0f / numberOfTasks;

                foreach (var tool in this.EmmeToolsToRun)
                {
                    tool.Execute(mc);
                    this._progress += 1.0f / numberOfTasks;
                }
            }
            finally
            {
                if (this.DeleteFlag)
                {
                    for (int i = 0; i < createdAttributes.Length; i++)
                    {
                        if (createdAttributes[i])
                        {
                            var attData = this.AttributesToCreate[i];
                            var args = string.Join(" ", this.ScenarioNumber, attData.Id, attData.Domain, attData.DefaultValue, true);
                            mc.Run(_ToolName, args);
                        }
                    }
                }
            }

            return true;
        }
        public bool Execute(Controller controller)
        {
            var mc = controller as ModellerController;
            if (mc == null)
            {
                throw new XTMFRuntimeException("Controller is not a ModellerController");
            }

            string args = this.ScenarioNumber + " " + this.CountpostAttributeId + " " + this.AlternateCountpostAttributeId + " " + this.ExportFile.GetFilePath();
            string result = "";

            return mc.Run(ToolName, args, (p => this.Progress = p), ref result);
        }
Exemple #9
0
        public bool Execute(Controller controller)
        {
            var mc = controller as ModellerController;
            if (mc == null)
            {
                throw new XTMFRuntimeException("Controller is not a ModellerController");
            }

            string args = this.ScenarioNumber + " " + this.ResultAttributeId + " " + this.TollZoneAttributeId + " " + this.LightZoneToll + " " + this.RegularZoneToll;
            string result = "";

            return mc.Run(ToolName, args, (p => this.Progress = p), ref result);
        }
        public bool Execute(Controller controller)
        {
            var mc = controller as ModellerController;
            if ( mc == null )
                throw new XTMFRuntimeException( "Controller is not a modeller controller!" );

            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=\"{1}\" default=0 descr=\"{2}\"", this.MatrixId, this.MatrixName, this.MatrixDescription );
                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] );
                }
            }

            string ret = null;
            mc.Run( "TMG2.XTMF.ImportMatrix", "\"" + Path.GetFullPath( outputFileName ) + "\" " + ScenarioNumber,
                ( (p) => { this.Progress = p; } ), ref ret );

            File.Delete( outputFileName );

            return true;
        }
        public bool Execute(Controller controller)
        {
            var mc = controller as ModellerController;
            if (mc == null)
                throw new XTMFRuntimeException("Controller is not a ModellerController!");

            var reportFilePath = "\"" + this.ReportFile.GetFilePath() + "\"";
            var aggregationFilePath = this.LineAggregationFile == null ? "" :  "\"" + this.LineAggregationFile.GetFilePath() + "\"";

            var args = string.Join(" ", this.ScenarioNumber,
                                        reportFilePath,
                                        aggregationFilePath);

            var result = "";
            return mc.Run(_ToolName, args, (p => this.Progress = p), ref result);
        }
        public bool Execute(Controller controller)
        {
            var mc = controller as ModellerController;
            if ( mc == null )
                throw new XTMFRuntimeException( "Controller is not a modeller controller!" );

            string filepath = Path.GetFullPath( FileName );
            if(mc.CheckToolExists(_ToolName))
            {
                return mc.Run(_ToolName, this.MatrixNumber + " \"" + filepath + "\"" + ScenarioNumber);
            }
            else
            {
                return mc.Run(_OldToolName, this.MatrixNumber + " \"" + filepath + "\"" + ScenarioNumber);
            }
        }
        public bool Execute(Controller controller)
        {
            var mc = controller as ModellerController;
            if ( mc == null )
                throw new XTMFRuntimeException( "Controller is not a modeller controller!" );

            string result = null;

            var toolName = ToolName;
            if (!mc.CheckToolExists(toolName))
            {
                toolName = AlternateToolName;
            }

            return mc.Run(toolName, ScenarioNumber.ToString(), (p => this.Progress = p), ref result);
        }
Exemple #14
0
        public bool Execute(Controller controller)
        {
            var mc = controller as ModellerController;
            if ( mc == null )
                throw new XTMFRuntimeException( "Controller is not a modeller controller!" );

            var sb = new StringBuilder();
            sb.AppendFormat( "{0} {1}", MacroFile, Arguments );
            if(mc.CheckToolExists(_ToolName))
            {
                return mc.Run(_ToolName, sb.ToString());
            }
            else
            {
                return mc.Run(_OldToolName, sb.ToString());
            }
        }
        public bool Execute(Controller controller)
        {
            var mc = controller as ModellerController;
            if ( mc == null )
                throw new XTMFRuntimeException( "Controller is not a modeller controller!" );

            var sb = new StringBuilder();
            sb.AppendFormat( "{0} {1} {2} {3}",
                this.ScenarioNumber, this.Modes, this.ScreenlineFile, this.ReportFile );

            /*
             * ScrenarioNumner, ModesStr, OpenPath, SavePath
             * */

            string result = null;
            return mc.Run("tmg.analysis.traffic.export_screenline_results", sb.ToString(), ( p => this.Progress = p ), ref result );
        }
        public bool Execute(Controller controller)
        {
            var mc = controller as ModellerController;
            if ( mc == null )
                throw new XTMFRuntimeException( "Controller is not a ModellerController" );

            /*
            bool isTrue = mc.CheckToolExists("TMG2.Common.Editing");
            bool isFalse = mc.CheckToolExists("Garbage namespace");

            isTrue.ToString();
            isFalse.ToString();

            throw new NotImplementedException();
             * */

            return true;
        }
        public bool Execute(Controller controller)
        {
            var mc = controller as ModellerController;
            if ( mc == null )
            {
                throw new XTMFRuntimeException( "Controller is not a ModellerController" );
            }
            string result = "";
            mc.Run( _ToolName, this.ScenarioNumber.ToString(), ( p => this._Progress = p ), ref result );

            StringBuilder builder = new StringBuilder();
            builder.Append(this.Root.CurrentTask.Generation);
            builder.Append(',');
            builder.Append(this.Root.CurrentTask.Index);

            //Append the fitness value for this task
            builder.Append(',');
            var func = this.Root.RetrieveValue;
            builder.Append((func == null) ? "null" : func().ToString());

            //Results coming out of Emme/Python are already a string of comma-separated values
            builder.Append(',');
            builder.Append(result);

            foreach ( var val in this.Root.CurrentTask.ParameterValues )
            {
                builder.Append( ',' );
                builder.Append( val.ToString() );
            }
            builder.AppendLine();
            if(SaveToFile == null)
            {
                //now that we have built up the data, send it to the host
                this.SendToHost(builder.ToString());
            }
            else
            {
                using (StreamWriter writer = new StreamWriter(SaveToFile) )
                {
                    writer.WriteLine(builder.ToString());
                }
            }
            return true;
        }
Exemple #18
0
        public bool Execute(Controller controller)
        {
            var mc = controller as ModellerController;
            if (mc == null)
            {
                throw new XTMFRuntimeException("Controller is not a ModellerController");
            }

            var args = string.Join(" ", this.ScenarioNumber, this.LineAggregationFile.GetFilePath(), this.CheckAggregationFile);
            string result = "";
            mc.Run(_ToolName, args, (p => this.Progress = p), ref result);

            var modelResults = this.ParseResults(result);
            var observations = this.LoadObservedBoardingsFile();

            this.CalcFitness(observations, modelResults);

            return true;
        }
        public bool Execute(Controller controller)
        {
            var mc = controller as ModellerController;
            if ( mc == null )
                throw new XTMFRuntimeException( "Controller is not a modeller controller!" );

            var sb = new StringBuilder();
            sb.AppendFormat( "{0} {1}",
                ScenarioNumber, InputFile.GetFileName( Root.InputBaseDirectory ) );
            string result = null;
            if(mc.CheckToolExists(_ToolName))
            {
                return mc.Run(_ToolName, sb.ToString(), (p => this.Progress = p), ref result);
            }
            else
            {
                return mc.Run(_OldToolName, sb.ToString(), (p => this.Progress = p), ref result);
            }
        }
Exemple #20
0
        public bool Execute(Controller controller)
        {
            var mc = controller as ModellerController;
            if ( mc == null )
                throw new XTMFRuntimeException( "Controller is not a modeller controller!" );

            var sb = new StringBuilder();
            sb.AppendFormat( "{0} {1}",
                this.ScenarioNumber, this.MatrixResultNumber );
            string result = null;

            var toolName = ToolName;
            if (!mc.CheckToolExists(toolName))
            {
                toolName = AlternateToolName;
            }

            return mc.Run(toolName, sb.ToString(), (p => this.Progress = p), ref result);
        }
        public bool Execute(Controller controller)
        {
            var mc = controller as ModellerController;
            if ( mc == null )
                throw new XTMFRuntimeException( "Controller is not a modeller controller!" );

            var args = new StringBuilder();
            args.AppendFormat( "{0} {1} {2} {3} {4} {5}",
                ScenarioNumber, ModeString, IVTTMatrixNumber, WalkMatrixNumber, WaitMatrixNumber, BoardingMatrixNumber );

            var toolName = ToolName;
            if (!mc.CheckToolExists(toolName))
            {
                toolName = AlternateToolName;
            }

            string result = null;
            return mc.Run(toolName, args.ToString(), (p => this.Progress = p), ref result);
        }
Exemple #22
0
        public bool Execute(Controller controller)
        {
            var mc = controller as ModellerController;
            if (mc == null)
            {
                throw new XTMFRuntimeException("In '" + Name + "' we were not given a modeler controller!");
            }
            var fullPathToDirectory = Path.GetFullPath(Path.GetDirectoryName(ResultsFile));

            string timePeriods = "";

            foreach(var timePeriod in TimePeriodToConsider)
            {
                timePeriods += timePeriod.ReturnFilter(mc) + ",";
            }

            var args = string.Join(" ", timePeriods, "\"" + fullPathToDirectory + "\"" , CostPerKm.ToString());

            return mc.Run(_ToolName, null);
        }
Exemple #23
0
 public bool Execute(Controller controller)
 {
     var modeller = controller as ModellerController;
     if(modeller != null)
     {
         if(!File.Exists(BaseZoneShapeFile))
         {
             throw new XTMFRuntimeException("In '" + BinaryMatrixFile + "' the base zone shape file does not exist!");
         }
         if(!File.Exists(BinaryMatrixFile))
         {
             throw new XTMFRuntimeException("In '" + BinaryMatrixFile + "' the binary matrix file does not exist!");
         }
         if(!modeller.CheckToolExists(ToolNamespace))
         {
             throw new XTMFRuntimeException("We were unable to find a tool in the EMME project called " + ToolNamespace);
         }
         return modeller.Run(ToolNamespace, BuildArguments());
     }
     return false;
 }
Exemple #24
0
        public bool Execute(Controller controller)
        {
            var mc = controller as ModellerController;
            if (mc == null)
                throw new XTMFRuntimeException("Controller is not a ModellerController!");

            var args = string.Join(" ", "\""+this.MatrixFile.GetFilePath()+ "\"",
                                        this.ScenarioNumber);

            Console.WriteLine("Importing matrix into scenario " + this.ScenarioNumber.ToString() + " from file " + this.MatrixFile.GetFilePath());

            var result = "";
            if(mc.CheckToolExists(_ToolName))
            {
                return mc.Run(_ToolName, args, (p => this.Progress = p), ref result);
            }
            else
            {
                return mc.Run(_OldToolName, args, (p => this.Progress = p), ref result);
            }
        }
        public bool Execute(Controller controller)
        {
            var mc = controller as ModellerController;
            if(mc == null)
                throw new XTMFRuntimeException("Controller is not a ModellerController!");

            var args = string.Join(" ", this.MatrixType, this.MatrixNumber, "\"" + this.Filepath.GetFilePath() + "\"", this.ScenarioNumber);

            /*

                def __call__(self, MatrixType, MatrixNumber, FileName, ScenarioNumber):
            */

            var result = "";
            if(mc.CheckToolExists(_ToolName))
            {
                return mc.Run(_ToolName, args, (p => this.Progress = p), ref result);
            }
            else
            {
                return mc.Run(_OldToolName, args, (p => this.Progress = p), ref result);
            }
        }
Exemple #26
0
 public bool Execute(Controller controller)
 {
     var modeller = controller as ModellerController;
     if (modeller == null)
     {
         throw new XTMFRuntimeException("In '" + Name + "' we were not given a modeller controller!");
     }
     float value;
     string result = null;
     if(modeller.Run(_ToolName, GetParameters(), ref result))
     {
         if (float.TryParse(result, out value))
         {
             ISetableDataSource<float> dataSource = ((ISetableDataSource<float>)SumOfReport.GetDataSource());
             if (!dataSource.Loaded)
             {
                 dataSource.LoadData();
             }
             dataSource.SetData(value);
         }
         return true;
     }
     return false;
 }
Exemple #27
0
        public bool Execute(Controller controller)
        {
            var mc = controller as ModellerController;
            if ( mc == null )
                throw new XTMFRuntimeException( "Controller is not a modeller controller!" );

            var sb = new StringBuilder();
            sb.AppendFormat( "{0} {1} {2} {3} {4}",
                ScenarioNumber, FlagGo, FlagPremTTC, FlagVIVA, FlagZUM );
            string result = null;

            /*
            ScenarioNumber, FlagGO, FlagPremTTC, FlagVIVA, \
                 FlagZum
            */
            if(mc.CheckToolExists(_ToolName))
            {
                return mc.Run(_ToolName, sb.ToString(), (p => this.Progress = p), ref result);
            }
            else
            {
                return mc.Run(_OldToolName, sb.ToString(), (p => this.Progress = p), ref result);
            }
        }
Exemple #28
0
        public bool Execute(Controller controller)
        {
            var mc = controller as ModellerController;
            if(mc == null)
                throw new XTMFRuntimeException("Controller is not a ModellerController!");

            var args = string.Join(" ", ScenarioNumber,
                                        DemandMatrixNumber,
                                        mc.ToEmmeFloat(WaitTimePerception),
                                        mc.ToEmmeFloat(WalkSpeed),
                                        mc.ToEmmeFloat(WalkPerceptionToronto),
                                        mc.ToEmmeFloat(WalkPerceptionNonToronto),
                                        mc.ToEmmeFloat(WalkPerceptionTorontoConnectors),
                                        mc.ToEmmeFloat(WalkPerceptionNonTorontoConnectors),
                                        mc.ToEmmeFloat(WalkPerceptionPD1),
                                        WalkPerceptionAttribute,
                                        HeadwayFractionAttribute,
                                        LinkFareAttribute,
                                        SegmentFareAttribute,
                                        EffectiveHeadwayAttributeId,
                                        mc.ToEmmeFloat(EffectiveHeadwaySlope),
                                        mc.ToEmmeFloat(BoardingPerception),
                                        mc.ToEmmeFloat(FarePerception),
                                        mc.ToEmmeFloat(RepresentativeHourFactor),
                                        MaxIterations,
                                        mc.ToEmmeFloat(NormalizedGap),
                                        mc.ToEmmeFloat(RelativeGap),
                                        InVehicleMatrixNumber,
                                        WaitMatrixNumber,
                                        WalkMatrixNumber,
                                        FareMatrixNumber,
                                        CongestionMatrixNumber,
                                        BoardingMatrixNumber,
                                        mc.ToEmmeFloat(ConnectorLogitScale),
                                        ExtractCongestedInVehicleTimeFlag,
                                        string.Join(",", from ttf in TTF
                                                         select ttf.TTFNumber.ToString() + ":"
                                                         + mc.ToEmmeFloat(ttf.CongestionPerception).ToString() + ":"
                                                         + mc.ToEmmeFloat(ttf.CongestionExponent))
                                        );

            var result = "";
            return mc.Run(_ToolName, args, (p => Progress = p), ref result);
        }
        public bool Execute(Controller controller)
        {
            var mc = controller as ModellerController;
            if ( mc == null )
                throw new XTMFRuntimeException( "Controller is not a ModellerController!" );

            if ( this.DemandMatrixNumber != 0 )
            {
                PassMatrixIntoEmme( mc );
            }

            //Setup space-delimited args for the Emme tool
            var sb = new StringBuilder();
            sb.AppendFormat( "{0} {1} {2} {3} {4} {5} {6} {7} {8} {9}",
                ScenarioNumber, DemandMatrixNumber, ModeString, WaitPerception, WalkPerception,
                InVehiclePerception, BoardingPerception, UseAdditionalDemand, WaitFactor, UseEM4Options );
            string result = null;
            if(mc.CheckToolExists(ToolName))
            {
                return mc.Run(ToolName, sb.ToString(), (p => this.Progress = p), ref result);
            }
            else
            {
                return mc.Run(OldToolName, sb.ToString(), (p => this.Progress = p), ref result);
            }

            /*
             * ScenarioNumber, DemandMatrixNumber, ModeString, WaitPerception,
                 WalkPerception, InVehiclePerception, BoardingPerception, UseAdditiveDemand,
                 WaitFactor, UseEM4Options
             */
        }
        public bool Execute(Controller controller)
        {
            var mc = controller as ModellerController;
            if ( mc == null )
                throw new XTMFRuntimeException( "Controller is not a modeller controller!" );

            PassMatrixIntoEmme( mc );

            var sb = new StringBuilder();
            /*
            sb.AppendFormat("{0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10} {11} {12}",
                this.ScenarioNumber, this.DemandMatrixNumber, this.TravelTimeMatrixNumber, this.CostMatrixNumber,
                this.TollMatrixNumber, this.Factor, this.GasCost, this.TollUnitCost, this.TollPerceptionFactor,
                this.MaxIterations, this.RelativeGap, this.BestRelativeGap, this.NormalizedGap);
            */
            if(mc.CheckToolExists(_ToolName))
            {
                return mc.Run(_ToolName, sb.ToString());
            }
            else
            {
                return mc.Run(_OldToolName, sb.ToString());
            }
        }