Пример #1
0
 private ModellerControllerParameter[] GetParameters()
 {
     /*
      * def __call__(self, xtmf_ScenarioNumber, LineFilterExpression, xtmf_LineODMatrixNumber,
      *    xtmf_AggOriginMatrixNumber, xtmf_AggDestinationMatrixNumber, xtmf_AutoODMatrixId, xtmf_AccessStationRange, xtmf_ZoneCentroidRange):
      */
     return(new[]
     {
         new ModellerControllerParameter("xtmf_ScenarioNumber", ScenarioNumber.ToString()),
         new ModellerControllerParameter("LineFilterExpression", LineFilterExpression),
         new ModellerControllerParameter("xtmf_LineODMatrixNumber", LineODMatrixNumber.ToString()),
         new ModellerControllerParameter("xtmf_AggOriginMatrixNumber", AggOriginMatrixNumber.ToString()),
         new ModellerControllerParameter("xtmf_AggDestinationMatrixNumber", AggDestinationMatrixNumber.ToString()),
         new ModellerControllerParameter("xtmf_AutoODMatrixId", AutoODMatrixId.ToString()),
         new ModellerControllerParameter("xtmf_AccessStationRange", StationCentroids.ToString()),
         new ModellerControllerParameter("xtmf_ZoneCentroidRange", ZoneCentroids.ToString())
     });
 }
Пример #2
0
        public bool Execute(Controller controller)
        {
            Progress = 0;
            var mc = controller as ModellerController;

            if (mc == null)
            {
                throw new XTMFRuntimeException(this, "Controller is not a ModellerController!");
            }

            string walkPerception = String.Empty;

            // join all walk perceptions into one string
            foreach (var c in Classes)
            {
                walkPerception = string.Join(";", walkPerception, string.Join("::", c.WalkPerceptions.Select(walk => Controller.ToEmmeFloat(walk.WalkValue) + ":" + walk.LineFilter)));
            }
            walkPerception = '\"' + walkPerception.Substring(1, walkPerception.Length - 1) + '\"';

            ModellerControllerParameter[] GetParameters()
            {
                return(new[]
                {
                    new ModellerControllerParameter("xtmf_ScenarioNumber", ScenarioNumber.ToString()),
                    new ModellerControllerParameter("xtmf_DemandMatrixString", ProduceMatrixString(c => c.DemandMatrixNumber)),
                    new ModellerControllerParameter("xtmf_NameString", (string.Join(",", from c in Classes
                                                                                    select c.Name))),
                    new ModellerControllerParameter("WalkSpeed", WalkSpeed.ToString()),
                    new ModellerControllerParameter("xtmf_WalkPerceptionString", walkPerception),
                    new ModellerControllerParameter("xtmf_WalkPerceptionAttributeIdString", string.Join(",", from c in Classes
                                                                                                        select c.WalkPerceptionAttribute)),
                    new ModellerControllerParameter("xtmf_ClassWaitPerceptionString", string.Join(",", from c in Classes
                                                                                                  select Controller.ToEmmeFloat(c.WaitTimePerception))),
                    new ModellerControllerParameter("xtmf_ClassBoardPerceptionString", string.Join(",", from c in Classes
                                                                                                   select Controller.ToEmmeFloat(c.BoardingPerception))),
                    new ModellerControllerParameter("xtmf_ClassFarePerceptionString", string.Join(",", from c in Classes
                                                                                                  select Controller.ToEmmeFloat(c.FarePerception))),
                    new ModellerControllerParameter("xtmf_ClassModeList", string.Join(",", from c in Classes
                                                                                      select c.ModeList)),
                    new ModellerControllerParameter("HeadwayFractionAttributeId", HeadwayFractionAttribute),
                    new ModellerControllerParameter("xtmf_LinkFareAttributeIdString", string.Join(",", from c in Classes
                                                                                                  select c.LinkFareAttribute)),
                    new ModellerControllerParameter("xtmf_SegmentFareAttributeIdString", string.Join(",", from c in Classes
                                                                                                     select c.SegmentFareAttribute)),
                    new ModellerControllerParameter("EffectiveHeadwayAttributeId", EffectiveHeadwayAttributeId.ToString()),
                    new ModellerControllerParameter("EffectiveHeadwaySlope", Controller.ToEmmeFloat(EffectiveHeadwaySlope)),
                    new ModellerControllerParameter("AssignmentPeriod", Controller.ToEmmeFloat(RepresentativeHourFactor)),
                    new ModellerControllerParameter("Iterations", MaxIterations.ToString()),
                    new ModellerControllerParameter("NormGap", Controller.ToEmmeFloat(NormalizedGap)),
                    new ModellerControllerParameter("RelGap", Controller.ToEmmeFloat(RelativeGap)),
                    new ModellerControllerParameter("xtmf_InVehicleTimeMatrixString", ProduceMatrixString(c => c.InVehicleMatrixNumber)),
                    new ModellerControllerParameter("xtmf_WaitTimeMatrixString", ProduceMatrixString(c => c.WaitMatrixNumber)),
                    new ModellerControllerParameter("xtmf_WalkTimeMatrixString", ProduceMatrixString(c => c.WalkMatrixNumber)),
                    new ModellerControllerParameter("xtmf_FareMatrixString", ProduceMatrixString(c => c.FareMatrixNumber)),
                    new ModellerControllerParameter("xtmf_CongestionMatrixString", ProduceMatrixString(c => c.CongestionMatrixNumber)),
                    new ModellerControllerParameter("xtmf_PenaltyMatrixString", ProduceMatrixString(c => c.BoardingPenaltyMatrixNumber)),
                    new ModellerControllerParameter("xtmf_ImpedanceMatrixString", ProduceMatrixString(c => c.PerceivedTravelTimeMatrixNumber)),
                    new ModellerControllerParameter("xtmf_OriginDistributionLogitScale", Controller.ToEmmeFloat(ConnectorLogitScale)),
                    new ModellerControllerParameter("CalculateCongestedIvttFlag", ExtractCongestedInVehicleTimeFlag.ToString()),
                    new ModellerControllerParameter("CongestionExponentString", string.Join(",", from ttf in TTF
                                                                                            select ttf.TTFNumber.ToString() + ":"
                                                                                            + Controller.ToEmmeFloat(ttf.CongestionPerception) + ":"
                                                                                            + Controller.ToEmmeFloat(ttf.CongestionExponent))),
                    new ModellerControllerParameter("xtmf_congestedAssignment", ApplyCongestion.ToString()),
                    new ModellerControllerParameter("xtmf_CSVFile", GetFileLocationOrNone(IterationCSVFile)),
                    new ModellerControllerParameter("xtmf_SurfaceTransitSpeed", GetSurfaceSpeedModel()),
                    new ModellerControllerParameter("xtmf_WalkAllWayFlag", WalkAllWayFlag.ToString()),
                    new ModellerControllerParameter("xtmf_XRowTTFRange", XRowTTF.ToString())
                });
            }

            /*def __call__(self, xtmf_ScenarioNumber, xtmf_DemandMatrixString, xtmf_NameString,\
             * WalkSpeed, xtmf_WalkPerceptionString, xtmf_WalkPerceptionAttributeIdString, \
             * xtmf_ClassWaitPerceptionString, xtmf_ClassBoardPerceptionString, xtmf_ClassFarePerceptionString, xtmf_ClassModeList,\
             * HeadwayFractionAttributeId, xtmf_LinkFareAttributeIdString, xtmf_SegmentFareAttributeIdString, \
             * EffectiveHeadwayAttributeId, EffectiveHeadwaySlope,  AssignmentPeriod, \
             * Iterations, NormGap, RelGap, \
             * xtmf_InVehicleTimeMatrixString, xtmf_WaitTimeMatrixString, xtmf_WalkTimeMatrixString, xtmf_FareMatrixString, xtmf_CongestionMatrixString, xtmf_PenaltyMatrixString, xtmf_ImpedanceMatrixString, \
             * xtmf_OriginDistributionLogitScale, CalculateCongestedIvttFlag, CongestionExponentString, xtmf_congestedAssignment):
             */

            var args = string.Join(" ", ScenarioNumber,
                                   ProduceMatrixString(c => c.DemandMatrixNumber),
                                   "\"" + (string.Join(",", from c in Classes
                                                       select c.Name)).Replace('"', '\'') + "\"",
                                   Controller.ToEmmeFloat(WalkSpeed),
                                   walkPerception,
                                   "\"" + (string.Join(",", from c in Classes
                                                       select c.WalkPerceptionAttribute)).Replace('"', '\'') + "\"",
                                   "\"" + string.Join(",", from c in Classes
                                                      select Controller.ToEmmeFloat(c.WaitTimePerception)) + "\"",
                                   "\"" + string.Join(",", from c in Classes
                                                      select Controller.ToEmmeFloat(c.BoardingPerception)) + "\"",
                                   "\"" + string.Join(",", from c in Classes
                                                      select Controller.ToEmmeFloat(c.FarePerception)) + "\"",
                                   "\"" + string.Join(",", from c in Classes
                                                      select c.ModeList) + "\"",
                                   HeadwayFractionAttribute,
                                   "\"" + (string.Join(",", from c in Classes
                                                       select c.LinkFareAttribute)).Replace('"', '\'') + "\"",
                                   "\"" + (string.Join(",", from c in Classes
                                                       select c.SegmentFareAttribute)).Replace('"', '\'') + "\"",
                                   EffectiveHeadwayAttributeId,
                                   Controller.ToEmmeFloat(EffectiveHeadwaySlope),
                                   Controller.ToEmmeFloat(RepresentativeHourFactor),
                                   MaxIterations,
                                   Controller.ToEmmeFloat(NormalizedGap),
                                   Controller.ToEmmeFloat(RelativeGap),
                                   ProduceMatrixString(c => c.InVehicleMatrixNumber),
                                   ProduceMatrixString(c => c.WaitMatrixNumber),
                                   ProduceMatrixString(c => c.WalkMatrixNumber),
                                   ProduceMatrixString(c => c.FareMatrixNumber),
                                   ProduceMatrixString(c => c.CongestionMatrixNumber),
                                   ProduceMatrixString(c => c.BoardingPenaltyMatrixNumber),
                                   ProduceMatrixString(c => c.PerceivedTravelTimeMatrixNumber),
                                   Controller.ToEmmeFloat(ConnectorLogitScale),
                                   ExtractCongestedInVehicleTimeFlag,
                                   string.Join(",", from ttf in TTF
                                               select ttf.TTFNumber.ToString() + ":"
                                               + Controller.ToEmmeFloat(ttf.CongestionPerception) + ":"
                                               + Controller.ToEmmeFloat(ttf.CongestionExponent)),
                                   ApplyCongestion,
                                   GetFileLocationOrNone(IterationCSVFile)
                                   );

            if (SurfaceTransitSpeedModel != null)
            {
                args = string.Join(" ", args, "\"" + string.Join(",", from model in SurfaceTransitSpeedModel
                                                                 select Controller.ToEmmeFloat(model.BoardingDuration) + ":"
                                                                 + Controller.ToEmmeFloat(model.AlightingDuration) + ":"
                                                                 + Controller.ToEmmeFloat(model.DefaultDuration) + ":"
                                                                 + Controller.ToEmmeFloat(model.Correlation) + ":"
                                                                 + model.ModeFilterExpression + ":"
                                                                 + model.LineFilterExpression + ":"
                                                                 + Controller.ToEmmeFloat(model.ErowSpeed)
                                                                 ) + "\"");
            }
            else
            {
                args = string.Join(" ", args, false.ToString());
            }

            var result = "";


            //return mc.Run(this, ToolName, GetParameters(), (p => Progress = p), ref result);
            return(mc.Run(this, ToolName, GetParameters(), (p => Progress = p), ref result));
        }
Пример #3
0
        public string SplitAndJoin(ByteBlock text)
        {
            RangeSet words = this.splitter.Split(text);

            return(words.ToString(text.Array));
        }