Esempio n. 1
0
            static void CreateGlobalconfig(
                string folder,
                string configFileName,
                AnalysisMode analysisMode,
                SortedList <string, DiagnosticDescriptor> sortedRulesById)
            {
                var text           = GetGlobalconfigText(analysisMode, sortedRulesById);
                var directory      = Directory.CreateDirectory(folder);
                var configFilePath = Path.Combine(directory.FullName, configFileName);

                File.WriteAllText(configFilePath, text);
                return;
Esempio n. 2
0
 /// <summary>
 /// Constructor required for creating a project.
 /// </summary>
 /// <param name="analMode"></param>
 public ProjectData(AnalysisMode analMode)
 {
     //_filePath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
     _fileName     = "";
     _analystName  = "";
     _agency       = "";
     _analysisDate = System.DateTime.Now;
     _userNotes    = "";
     //_analMode = AnalysisMode.HCM2016;
     _analMode = analMode;
     _directionAnalysisMode = DirectionType.PeakDirection;
     //_mode = ModeType.Multimodal;
     _mode        = ModeType.AutoOnly;
     _period      = StudyPeriod.StandardK;
     _ffsCalc     = FFSCalcMethod.PostSpeed;
     _losCriteria = LevelServiceCriteria.FDOT2ClassSpeed;
 }
Esempio n. 3
0
        public static IEnumerable <Model> CreateConfigurations <T>(AnalysisMode mode)
            where T : ObserverController
        {
            yield return(CreateConfiguration <T>(m => m.Ictss1(), nameof(Ictss1), mode));

            yield return(CreateConfiguration <T>(m => m.Ictss2(), nameof(Ictss2), mode));

            yield return(CreateConfiguration <T>(m => m.Ictss3(), nameof(Ictss3), mode));

            yield return(CreateConfiguration <T>(m => m.Ictss4(), nameof(Ictss4), mode));

            yield return(CreateConfiguration <T>(m => m.Ictss5(), nameof(Ictss5), mode));

            yield return(CreateConfiguration <T>(m => m.Ictss6(), nameof(Ictss6), mode));

            yield return(CreateConfiguration <T>(m => m.Ictss7(), nameof(Ictss7), mode));
        }
Esempio n. 4
0
        private int GetIndex(AnalysisMode mode)
        {
            switch (mode)
            {
            case AnalysisMode.PlayerAbsolute:   return(0);

            case AnalysisMode.PlayerRelative:   return(1);

            case AnalysisMode.OpponentAbsolute: return(2);

            case AnalysisMode.OpponentRelative: return(3);

            case AnalysisMode.Result:           return(4);

            default:
                throw new ArgumentOutOfRangeException("GetIndex failed to find passed AnalysisMode.");
            }
        }
Esempio n. 5
0
 public MethodFlowAnalysis(
     AnalysisMode mode,
     SemanticModel model,
     List <Assignment> assignments,
     ImmutableArray <ISymbol> alwaysAssignedToNotNull,
     Branch branchTree,
     List <Branch> lambdas,
     bool hasConstraints,
     List <ReturnStatementSyntax> returnStatements)
 {
     this.Mode                    = mode;
     this.model                   = model;
     this.assignments             = assignments;
     this.AlwaysAssignedToNotNull = alwaysAssignedToNotNull;
     this.BranchTree              = branchTree;
     this.Lambdas                 = lambdas;
     this.HasConstraints          = hasConstraints;
     this.ReturnStatements        = returnStatements;
 }
Esempio n. 6
0
 public void RunRandomizer()
 {
     if (File.Exists(Agent.GeneralConfiguration.TempFile))
     {
         File.Delete(Agent.GeneralConfiguration.TempFile);
     }
     Agent.InitializeRng();
     Uniso.RemoveSectorMetadata(Agent.GeneralConfiguration.InputFile, Agent.GeneralConfiguration.TempFile);
     LoadData();
     if (Agent.GeneralConfiguration.RunAnalysis)
     {
         AnalysisMode.RunAnalysis();
         Uniso.InjectLogicalSectors(Agent.GeneralConfiguration.TempFile, Agent.GeneralConfiguration.InputFile, Agent.GeneralConfiguration.OutputFile);
         return;
     }
     ApplyOptions();
     ApplyRandomizers();
     ApplyModes();
     Uniso.InjectLogicalSectors(Agent.GeneralConfiguration.TempFile, Agent.GeneralConfiguration.InputFile, Agent.GeneralConfiguration.OutputFile);
 }
Esempio n. 7
0
        public Analysis(AnalysisMode type, TrackList <AudioTrack> audioTracks, TimeSpan windowLength, TimeSpan intervalLength, int sampleRate)
        {
            if (audioTracks.Count < 2)
            {
                // there must be at least 2 tracks, otherwise there's nothing to compare
                throw new Exception("there must be at least 2 audio tracks");
            }
            if (intervalLength < windowLength)
            {
                throw new ArgumentException("intervalLength must be at least as long as the windowLength");
            }

            this.type            = type;
            this.audioTracks     = audioTracks;
            this.windowLength    = windowLength;
            this.intervalLength  = intervalLength;
            this.sampleRate      = sampleRate;
            this.progressMonitor = ProgressMonitor.GlobalInstance;

            switch (type)
            {
            case AnalysisMode.CrossCorrelationOffset:
                analyzeSection = AnalysisFunctions.CrossCorrelationOffset;
                break;

            case AnalysisMode.Correlation:
                analyzeSection = CrossCorrelation.Correlate;
                break;

            case AnalysisMode.Interference:
                analyzeSection = AnalysisFunctions.DestructiveInterference;
                break;

            case AnalysisMode.FrequencyDistribution:
                analyzeSection = AnalysisFunctions.FrequencyDistribution;
                break;

            default:
                throw new NotImplementedException(type + " not implemented");
            }
        }
Esempio n. 8
0
        // This is kinda duplicated in ClassAnalyzer.CheckExpressionForNull
        private ExpressionStatus GetAssignmentStatus(
            ExpressionSyntax expression,
            SyntaxNode parent,
            ValueType valueOfExpression,
            AnalysisMode mode = AnalysisMode.Normal)
        {
            if (valueOfExpression == ValueType.NotNull)
            {
                // Argument cannot be null, so move to the next
                return(ExpressionStatus.Assigned);
            }
            if (valueOfExpression == ValueType.Null)
            {
                return(ExpressionStatus.NotAssigned);
            }
            var conversion = context.SemanticModel.GetConversion(expression).MethodSymbol;

            if (conversion != null)
            {
                // If a conversion method was called, then we shouldn't look at any analysis on the symbol, only analysis on the method.
                return(conversion.HasNotNull() ? ExpressionStatus.Assigned : ExpressionStatus.NotAssigned);
            }

            var methodInfo = expression.GetParentMethod(context.SemanticModel);

            if (methodInfo.Item1 != null)
            {
                var analysis = Cache.Get(context.SemanticModel).GetMethodAnalysis(methodInfo.Item1, methodInfo.Item2, methodInfo.Item3, mode);
                if (analysis.HasConstraints)
                {
                    needsConstraintChecking[methodInfo.Item1] = analysis;
                }
                return(analysis.IsAlwaysAssigned(expression, parent));
            }
            return(ExpressionStatus.NotAssigned);
        }
Esempio n. 9
0
 public ParseCommand()
     : base("Parser", "parse", "Parse a packet log file")
 {
     Options = new OptionSet
     {
         $"Usage: {Program.Name} {Name} PKTFILE [OPTIONS]",
         string.Empty,
         "Available options:",
         string.Empty,
         {
             "o|output=",
             $"Specify output file (defaults to input file name with extension changed to `{ParsedExtension}`)",
             o => _output = o
         },
         {
             "r|regex=",
             "Add a game message name regex to filter packets by (uses Perl 5 regex syntax)",
             (string r) => _regexes.Add(new Regex(r, FilterRegexOptions))
         },
         {
             "e|header",
             $"Enable/disable printing the packet log header before parsing (defaults to `{_header}`)",
             e => _header = e != null
         },
         {
             "s|stats",
             $"Enable/disable printing parsing and analysis statistics before exiting (defaults to `{_stats}`)",
             s => _stats = s != null
         },
         {
             "u|summary",
             $"Enable/disable printing a summary of known and unknown packets before exiting (defaults to `{_summary}`)",
             u => _summary = u != null
         },
         {
             "x|hex-dump=",
             $"Specify hex dump mode (defaults to `{_hex}`)",
             (HexDumpMode x) => _hex = x
         },
         {
             "p|parse",
             $"Enable/disable parsing of known packets (defaults to `{_parse}`)",
             p => _parse = p != null
         },
         {
             "z|backend=",
             $"Specify packet serializer backend (defaults to `{_backend}`)",
             (PacketSerializerBackend z) => _backend = z
         },
         {
             "t|roundtrips=",
             $"Specify the number of times to roundtrip parsed packets (defaults to `{_roundtrips}`)",
             (int t) => _roundtrips = t
         },
         {
             "a|analyze=",
             $"Specify analysis mode (defaults to `{_analysis}`)",
             (AnalysisMode a) => _analysis = a
         },
         {
             "m|min-string-length=",
             $"Specify minimum string length for analysis (defaults to `{_length}`)",
             (int m) => _length = m
         },
         {
             "w|allow-white-space",
             $"Enable/disable showing potential strings consisting only of white space (defaults to `{_whiteSpace}`)",
             w => _whiteSpace = w != null
         },
         {
             "c|allow-control-chars",
             $"Enable/disable showing potential strings containing control characters (defaults to `{_control}`)",
             c => _control = c != null
         },
         string.Empty,
         "Hex dump modes:",
         string.Empty,
         $"  {HexDumpMode.None}: Don't do hex dumps",
         $"  {HexDumpMode.Unknown}: Do hex dumps for packets with unknown structure (default)",
         $"  {HexDumpMode.All}: Do hex dumps for all packets",
         string.Empty,
         "Packet serializer backends:",
         string.Empty,
         $"  {PacketSerializerBackend.Reflection}: Reflection-based serializer (default)",
         $"  {PacketSerializerBackend.Compiler}: Runtime-compiled serializer",
         string.Empty,
         "Analysis modes:",
         string.Empty,
         $"  {AnalysisMode.None}: Don't perform analysis (default)",
         $"  {AnalysisMode.Unknown}: Analyze packets with unknown structure",
         $"  {AnalysisMode.All}: Analyze all packets",
     };
 }
Esempio n. 10
0
 public MethodFlowAnalyzer(SemanticModel model, AnalysisMode mode)
 {
     this.model       = model;
     this.mode        = mode;
     expressionParser = new ExpressionToCondition(model);
 }
Esempio n. 11
0
        public static ArterialData NewArterial(AnalysisMode ProjectAnalMode, float analysisDirectionDemandVol = 800, int numLanes = 2)
        {
            // Timers

            /*TimerData Timer1 = new TimerData(1, NemaMovementNumbers.WBLeft, 15.9f, 3, 35.27f, 51.16f, 3.13f, 30.73f, 12.646f, 0.311f, 0.995f, 0);
             * TimerData Timer2 = new TimerData(5, NemaMovementNumbers.EBLeft, 16.1f, 3, 35.27f, 51.37f, 3.13f, 30.73f, 12.829f, 0.322f, 0.996f, 0);
             * TimerData Timer3 = new TimerData(2, NemaMovementNumbers.EBThru, 52.84f, 4, 51.16f, 4f, 0, 0, 0, 0, 0, 0);
             * TimerData Timer4 = new TimerData(6, NemaMovementNumbers.WBThru, 52.63f, 4, 51.37f, 4f, 0, 0, 0, 0, 0, 0);
             * TimerData Timer5 = new TimerData(3, NemaMovementNumbers.NBLeft, 9.13f, 3, 4, 13.13f, 3.13f, 17, 6.442f, 0.099f, 0.938f, 0);
             * TimerData Timer6 = new TimerData(7, NemaMovementNumbers.SBLeft, 9.13f, 3, 4, 13.13f, 3.13f, 17, 6.442f, 0.099f, 0.938f, 0);
             * TimerData Timer7 = new TimerData(4, NemaMovementNumbers.SBThru, 22.13f, 4, 13.14f, 35.27f, 3.06f, 31.87f, 16.165f, 1.968f, 1, 0.016f);
             * TimerData Timer8 = new TimerData(8, NemaMovementNumbers.NBThru, 22.13f, 4, 13.14f, 35.27f, 3.06f, 31.87f, 16.165f, 1.968f, 1, 0.016f);*/

            List <SegmentData> Segments = new List <SegmentData>();

            // Intersection 1 / First Ave. //// "Segment-less" Intersection
            TimerData        TimerWBL = new TimerData(11.50f, 4.00f, 39.75f, 51.25f, 3.13f, 35.25f, 7.886f, 0.120f, 0.936f, 0.000f);
            TimerData        TimerEBT = new TimerData(76.75f, 4.00f, 51.25f, 4.00f, 0.00f, 0.00f, 0.000f, 0.000f, 0.000f, 0.000f);
            TimerData        TimerNBL = new TimerData(9.59f, 4.00f, 4.00f, 13.59f, 3.13f, 8.00f, 6.389f, 0.009f, 0.873f, 1.000f);
            TimerData        TimerSBT = new TimerData(26.16f, 4.00f, 13.59f, 39.75f, 3.06f, 37.41f, 20.199f, 1.963f, 1.000f, 0.009f);
            TimerData        TimerEBL = new TimerData(11.45f, 4.00f, 39.75f, 51.20f, 3.13f, 35.25f, 7.832f, 0.120f, 0.936f, 0.000f);
            TimerData        TimerWBT = new TimerData(76.80f, 4.00f, 51.20f, 4.00f, 0.00f, 0.00f, 0.000f, 0.000f, 0.000f, 0.000f);
            TimerData        TimerSBL = new TimerData(9.59f, 4.00f, 4.00f, 13.59f, 3.13f, 8.00f, 6.389f, 0.009f, 0.873f, 1.000f);
            TimerData        TimerNBT = new TimerData(26.16f, 4.00f, 13.59f, 39.75f, 3.06f, 37.41f, 20.199f, 1.963f, 1.000f, 0.009f);
            List <TimerData> Timers   = new List <TimerData> {
                TimerWBL, TimerEBL, TimerEBT, TimerWBT, TimerNBL, TimerSBL, TimerSBT, TimerNBT
            };

            IntersectionData newIntersection;
            LinkData         newLink;
            int upstreamIntersectionWidth = 0;

            newIntersection = CreateIntersection(Timers, numLanes, ProjectAnalMode, 60);
            newLink         = new LinkData(0, numLanes, 35, 0.94f, MedianType.None);
            Segments.Add(new SegmentData(0, newLink, newIntersection, AreaType.LargeUrbanized, newLink.PostSpeedMPH + 5, upstreamIntersectionWidth));
            upstreamIntersectionWidth = newIntersection.CrossStreetWidth;
            Segments[0].Link.AccessPoints.Add(CreateAPIntersection(1f / 3f, Segments[0].Intersection.Signal.CycleLengthSec));
            Segments[0].Link.AccessPoints.Add(CreateAPIntersection(2f / 3f, Segments[0].Intersection.Signal.CycleLengthSec));

            // Intersection 2 / Second Ave.
            TimerWBL = new TimerData(11.50f, 4.00f, 39.75f, 51.25f, 3.13f, 35.25f, 7.886f, 0.120f, 0.936f, 0.000f);
            TimerEBT = new TimerData(76.75f, 4.00f, 51.25f, 4.00f, 0.00f, 0.00f, 0.000f, 0.000f, 0.000f, 0.000f);
            TimerNBL = new TimerData(9.59f, 4.00f, 4.00f, 13.59f, 3.13f, 8.00f, 6.389f, 0.009f, 0.873f, 1.000f);
            TimerSBT = new TimerData(26.16f, 4.00f, 13.59f, 39.75f, 3.06f, 37.41f, 20.199f, 1.963f, 1.000f, 0.009f);
            TimerEBL = new TimerData(11.49f, 4.00f, 39.75f, 51.24f, 3.13f, 35.25f, 7.877f, 0.120f, 0.936f, 0.000f);
            TimerWBT = new TimerData(76.76f, 4.00f, 51.24f, 4.00f, 0.00f, 0.00f, 0.000f, 0.000f, 0.000f, 0.000f);
            TimerSBL = new TimerData(9.59f, 4.00f, 4.00f, 13.59f, 3.13f, 8.00f, 6.389f, 0.009f, 0.873f, 1.000f);
            TimerNBT = new TimerData(26.16f, 4.00f, 13.59f, 39.75f, 3.06f, 37.41f, 20.199f, 1.963f, 1.000f, 0.009f);
            Timers   = new List <TimerData> {
                TimerWBL, TimerEBL, TimerEBT, TimerWBT, TimerNBL, TimerSBL, TimerSBT, TimerNBT
            };

            newIntersection = CreateIntersection(Timers, numLanes, ProjectAnalMode, 60);
            newLink         = new LinkData(1320 - upstreamIntersectionWidth, numLanes, 35, 0.94f, MedianType.None);
            Segments.Add(new SegmentData(1, newLink, newIntersection, AreaType.LargeUrbanized, newLink.PostSpeedMPH + 5, upstreamIntersectionWidth));
            upstreamIntersectionWidth = newIntersection.CrossStreetWidth;
            Segments[1].Link.AccessPoints.Add(CreateAPIntersection(1f / 3f, Segments[0].Intersection.Signal.CycleLengthSec));
            Segments[1].Link.AccessPoints.Add(CreateAPIntersection(2f / 3f, Segments[0].Intersection.Signal.CycleLengthSec));

            // Intersection 3 / Third Ave.
            TimerWBL = new TimerData(11.50f, 4.00f, 39.75f, 51.25f, 3.13f, 35.25f, 7.885f, 0.120f, 0.936f, 0.000f);
            TimerEBT = new TimerData(76.75f, 4.00f, 51.25f, 4.00f, 0.00f, 0.00f, 0.000f, 0.000f, 0.000f, 0.000f);
            TimerNBL = new TimerData(9.59f, 4.00f, 4.00f, 13.59f, 3.13f, 8.00f, 6.389f, 0.009f, 0.873f, 1.000f);
            TimerSBT = new TimerData(26.16f, 4.00f, 13.59f, 39.75f, 3.06f, 37.41f, 20.199f, 1.963f, 1.000f, 0.009f);
            TimerEBL = new TimerData(11.48f, 4.00f, 39.75f, 51.23f, 3.13f, 35.25f, 7.872f, 0.119f, 0.936f, 0.000f);
            TimerWBT = new TimerData(76.77f, 4.00f, 51.23f, 4.00f, 0.00f, 0.00f, 0.000f, 0.000f, 0.000f, 0.000f);
            TimerSBL = new TimerData(9.59f, 4.00f, 4.00f, 13.59f, 3.13f, 8.00f, 6.389f, 0.009f, 0.873f, 1.000f);
            TimerNBT = new TimerData(26.16f, 4.00f, 13.59f, 39.75f, 3.06f, 37.41f, 20.199f, 1.963f, 1.000f, 0.009f);
            Timers   = new List <TimerData> {
                TimerWBL, TimerEBL, TimerEBT, TimerWBT, TimerNBL, TimerSBL, TimerSBT, TimerNBT
            };

            newIntersection = CreateIntersection(Timers, numLanes, ProjectAnalMode, 60);
            newLink         = new LinkData(1320 - upstreamIntersectionWidth, numLanes, 35, 0.94f, MedianType.None);
            Segments.Add(new SegmentData(2, newLink, newIntersection, AreaType.LargeUrbanized, newLink.PostSpeedMPH + 5, upstreamIntersectionWidth));
            upstreamIntersectionWidth = newIntersection.CrossStreetWidth;
            Segments[2].Link.AccessPoints.Add(CreateAPIntersection(1f / 3f, Segments[0].Intersection.Signal.CycleLengthSec));
            Segments[2].Link.AccessPoints.Add(CreateAPIntersection(2f / 3f, Segments[0].Intersection.Signal.CycleLengthSec));

            // Intersection 4 / Fourth Ave.
            TimerWBL = new TimerData(11.50f, 4.00f, 39.75f, 51.25f, 3.19f, 35.25f, 7.884f, 0.125f, 0.936f, 0.000f);
            TimerEBT = new TimerData(76.75f, 4.00f, 51.25f, 4.00f, 0.00f, 0.00f, 0.000f, 0.000f, 0.000f, 0.000f);
            TimerNBL = new TimerData(9.59f, 4.00f, 4.00f, 13.59f, 3.13f, 8.00f, 6.389f, 0.009f, 0.873f, 1.000f);
            TimerSBT = new TimerData(26.16f, 4.00f, 13.59f, 39.75f, 3.06f, 37.41f, 20.199f, 1.963f, 1.000f, 0.009f);
            TimerEBL = new TimerData(11.48f, 4.00f, 39.75f, 51.23f, 3.13f, 35.25f, 7.868f, 0.119f, 0.936f, 0.000f);
            TimerWBT = new TimerData(76.77f, 4.00f, 51.23f, 4.00f, 0.00f, 0.00f, 0.000f, 0.000f, 0.000f, 0.000f);
            TimerSBL = new TimerData(9.59f, 4.00f, 4.00f, 13.59f, 3.13f, 8.00f, 6.389f, 0.009f, 0.873f, 1.000f);
            TimerNBT = new TimerData(26.16f, 4.00f, 13.59f, 39.75f, 3.06f, 37.41f, 20.199f, 1.963f, 1.000f, 0.009f);
            Timers   = new List <TimerData> {
                TimerWBL, TimerEBL, TimerEBT, TimerWBT, TimerNBL, TimerSBL, TimerSBT, TimerNBT
            };

            newIntersection = CreateIntersection(Timers, numLanes, ProjectAnalMode, 60);
            newLink         = new LinkData(1320 - upstreamIntersectionWidth, numLanes, 35, 0.94f, MedianType.None);
            Segments.Add(new SegmentData(3, newLink, newIntersection, AreaType.LargeUrbanized, newLink.PostSpeedMPH + 5, upstreamIntersectionWidth));
            upstreamIntersectionWidth = newIntersection.CrossStreetWidth;
            Segments[3].Link.AccessPoints.Add(CreateAPIntersection(1f / 3f, Segments[0].Intersection.Signal.CycleLengthSec));
            Segments[3].Link.AccessPoints.Add(CreateAPIntersection(2f / 3f, Segments[0].Intersection.Signal.CycleLengthSec));

            // Intersection 5 / Fifth Ave.
            TimerWBL = new TimerData(11.50f, 4.00f, 39.75f, 51.25f, 3.19f, 35.25f, 7.883f, 0.125f, 0.936f, 0.000f);
            TimerEBT = new TimerData(76.75f, 4.00f, 51.25f, 4.00f, 0.00f, 0.00f, 0.000f, 0.000f, 0.000f, 0.000f);
            TimerNBL = new TimerData(9.59f, 4.00f, 4.00f, 13.59f, 3.13f, 8.00f, 6.389f, 0.009f, 0.873f, 1.000f);
            TimerSBT = new TimerData(26.16f, 4.00f, 13.59f, 39.75f, 3.06f, 37.41f, 20.199f, 1.963f, 1.000f, 0.009f);
            TimerEBL = new TimerData(11.48f, 4.00f, 39.75f, 51.23f, 3.19f, 35.25f, 7.865f, 0.125f, 0.936f, 0.000f);
            TimerWBT = new TimerData(76.77f, 4.00f, 51.23f, 4.00f, 0.00f, 0.00f, 0.000f, 0.000f, 0.000f, 0.000f);
            TimerSBL = new TimerData(9.59f, 4.00f, 4.00f, 13.59f, 3.13f, 8.00f, 6.389f, 0.009f, 0.873f, 1.000f);
            TimerNBT = new TimerData(26.16f, 4.00f, 13.59f, 39.75f, 3.06f, 37.41f, 20.199f, 1.963f, 1.000f, 0.009f);
            Timers   = new List <TimerData> {
                TimerWBL, TimerEBL, TimerEBT, TimerWBT, TimerNBL, TimerSBL, TimerSBT, TimerNBT
            };

            newIntersection = CreateIntersection(Timers, numLanes, ProjectAnalMode, 60);
            newLink         = new LinkData(660 - upstreamIntersectionWidth, numLanes, 30, 0.88f, MedianType.None);
            Segments.Add(new SegmentData(4, newLink, newIntersection, AreaType.LargeUrbanized, newLink.PostSpeedMPH + 5, upstreamIntersectionWidth));
            upstreamIntersectionWidth = newIntersection.CrossStreetWidth;
            Segments[4].Link.AccessPoints.Add(CreateAPIntersection(1f / 3f, Segments[0].Intersection.Signal.CycleLengthSec));
            Segments[4].Link.AccessPoints.Add(CreateAPIntersection(2f / 3f, Segments[0].Intersection.Signal.CycleLengthSec));

            // Intersection 6 / Sixth Ave.
            TimerWBL = new TimerData(11.45f, 4.00f, 39.75f, 51.20f, 3.19f, 35.25f, 7.832f, 0.125f, 0.936f, 0.000f);
            TimerEBT = new TimerData(76.80f, 4.00f, 51.20f, 4.00f, 0.00f, 0.00f, 0.000f, 0.000f, 0.000f, 0.000f);
            TimerNBL = new TimerData(9.59f, 4.00f, 4.00f, 13.59f, 3.13f, 8.00f, 6.389f, 0.009f, 0.873f, 1.000f);
            TimerSBT = new TimerData(26.16f, 4.00f, 13.59f, 39.75f, 3.06f, 37.41f, 20.199f, 1.963f, 1.000f, 0.009f);
            TimerEBL = new TimerData(11.48f, 4.00f, 39.75f, 51.23f, 3.19f, 35.25f, 7.864f, 0.125f, 0.936f, 0.000f);
            TimerWBT = new TimerData(76.77f, 4.00f, 51.23f, 4.00f, 0.00f, 0.00f, 0.000f, 0.000f, 0.000f, 0.000f);
            TimerSBL = new TimerData(9.59f, 4.00f, 4.00f, 13.59f, 3.13f, 8.00f, 6.389f, 0.009f, 0.873f, 1.000f);
            TimerNBT = new TimerData(26.16f, 4.00f, 13.59f, 39.75f, 3.06f, 37.41f, 20.199f, 1.963f, 1.000f, 0.009f);
            Timers   = new List <TimerData> {
                TimerWBL, TimerEBL, TimerEBT, TimerWBT, TimerNBL, TimerSBL, TimerSBT, TimerNBT
            };

            newIntersection = CreateIntersection(Timers, numLanes, ProjectAnalMode, 60);
            newLink         = new LinkData(660 - upstreamIntersectionWidth, numLanes, 30, 0.88f, MedianType.None);
            Segments.Add(new SegmentData(5, newLink, newIntersection, AreaType.LargeUrbanized, newLink.PostSpeedMPH + 5, upstreamIntersectionWidth));
            Segments[5].Link.AccessPoints.Add(CreateAPIntersection(1f / 3f, Segments[0].Intersection.Signal.CycleLengthSec));
            Segments[5].Link.AccessPoints.Add(CreateAPIntersection(2f / 3f, Segments[0].Intersection.Signal.CycleLengthSec));

            ArterialData newArterial = new ArterialData(AreaType.LargeUrbanized, ArterialClass.ClassI, TravelDirection.Eastbound, Segments);

            ChangeArterialVolume(ref newArterial, analysisDirectionDemandVol);

            // Calcs Arterial code
            foreach (SegmentData segment in newArterial.Segments)
            {
                newArterial.LengthMiles += segment.Link.LengthFt / 5280;
                foreach (ApproachData approach in segment.Intersection.Approaches)
                {
                    foreach (LaneGroupData laneGroup in approach.LaneGroups)
                    {
                        laneGroup.SignalPhase.GreenEffectiveSec = Math.Max(laneGroup.SignalPhase.Timer.Duration - laneGroup.SignalPhase.Timer.IntergreenTimeSec - laneGroup.SignalPhase.StartUpLostTimeSec + laneGroup.SignalPhase.EndUseSec, 0);
                        laneGroup.PctHeavyVehicles = 0; // 3%
                    }
                }
            }
            //newArterial.ThreshDelay = newArterial.GetLOSBoundaries_Delay(newArterial.Area);
            //newArterial.ThreshSpeed = newArterial.GetLOSBoundaries_Speed(artClass: 2);
            newArterial.AnalysisTravelDir = TravelDirection.Eastbound;

            return(newArterial);
        }
Esempio n. 12
0
        public static Model CreateConfiguration <T>(Action <Model> initializer, string name, AnalysisMode mode)
            where T : ObserverController
        {
            var model = new Model(name);

            initializer(model);
            model.CreateObserverController <T>();
            model.SetAnalysisMode(mode);

            return(model);
        }
Esempio n. 13
0
        static bool HandleArguments(ref string[] args)
        {
            var asm     = Assembly.GetExecutingAssembly();
            var name    = asm.GetName().Name;
            var version = false;
            var help    = false;
            var set     = new OptionSet
            {
                $"This is {name}, part of the {nameof(Alkahest)} project.",
                "",
                "Usage:",
                "",
                $"  {name} [options...] [--] <file>",
                "",
                "General",
                {
                    "h|?|help",
                    "Print version and exit.",
                    h => help = h != null
                },
                {
                    "v|version",
                    "Print help and exit.",
                    v => version = v != null
                },
                {
                    "o|output",
                    "Specify output text file.",
                    o => _output = o
                },
                {
                    "r|regex=",
                    "Add an opcode regex to filter packets by. Uses Perl 5 regex syntax.",
                    (string ar) => _regexes.Add(ar)
                },
                {
                    "e|header",
                    "Output packet log header information before parsing.",
                    e => _header = e != null
                },
                {
                    "s|stats",
                    "Output parsing and analysis statistics before exiting.",
                    s => _stats = s != null
                },
                {
                    "u|summary",
                    "Output a summary of known and unknown packets before exiting.",
                    u => _summary = u != null
                },
                "Parsing",
                {
                    "x|hex-dump=",
                    "Specify hex dump mode.",
                    (HexDumpMode x) => _hex = x
                },
                {
                    "p|parse",
                    "Enable/disable parsing of known packets.",
                    p => _parse = p != null
                },
                {
                    "z|backend=",
                    "Specify packet serializer backend.",
                    (PacketSerializerBackend z) => _backend = z
                },
                {
                    "t|roundtrips=",
                    "Specify the number of times to roundtrip parsed packets.",
                    (int t) => _roundtrips = t
                },
                "Analysis",
                {
                    "a|analyze=",
                    "Specify analysis mode.",
                    (AnalysisMode a) => _analysis = a
                },
                {
                    "m|min-string-length=",
                    "Specify minimum string length.",
                    (int m) => _length = m
                },
                {
                    "w|allow-white-space",
                    "Enable/disable showing strings consisting only of white space.",
                    w => _whiteSpace = w != null
                },
                {
                    "c|allow-control-chars",
                    "Enable/disable showing strings containing control characters.",
                    c => _control = c != null
                },
                "",
                "Hex dump modes:",
                "",
                $"  {HexDumpMode.None}: Don't do hex dumps.",
                $"  {HexDumpMode.Unknown}: Do hex dumps for packets with unknown structure.",
                $"  {HexDumpMode.All}: Do hex dumps for all packets.",
                "",
                "Packet serializer backends:",
                "",
                $"  {PacketSerializerBackend.Reflection}: Reflection-based serializer (default).",
                $"  {PacketSerializerBackend.Compiler}: Runtime-compiled serializer (default).",
                "",
                "Analysis modes:",
                "",
                $"  {AnalysisMode.None}: Don't perform analysis (default).",
                $"  {AnalysisMode.Unknown}: Analyze packets with unknown structure.",
                $"  {AnalysisMode.All}: Analyze all packets."
            };

            args = set.Parse(args).ToArray();

            if (version)
            {
                Console.WriteLine("{0} {1}", name,
                                  asm.GetCustomAttribute <AssemblyInformationalVersionAttribute>()
                                  .InformationalVersion);
                return(false);
            }

            if (help)
            {
                set.WriteOptionDescriptions(Console.Out);
                return(false);
            }

            return(true);
        }
Esempio n. 14
0
 private static void ProcessSingleTrxFile(string trxFileName, string label, AnalysisMode mode)
 {
     var oldColor = Console.ForegroundColor;
     try
     {
         if (!File.Exists(trxFileName))
         {
             Console.Write(label.PadRight(35));
             Console.ForegroundColor = ConsoleColor.Red;
             Console.WriteLine("TRX file not found!");
         }
         else
         {
             XElement element = XElement.Load(trxFileName);
             var analyzer = new MSTestResultsFileAnalyzer(element.Name.Namespace);
             analyzer.Label = label;
             analyzer.Mode = mode;
             analyzer.DumpSummary(element);
         }
     }
     finally
     {
         Console.ForegroundColor = oldColor;
     }
 }
Esempio n. 15
0
 public MethodBodyWalker(SemanticModel model, AnalysisMode mode)
 {
     this.model = model;
     this.mode  = mode;
 }
 public SleepBoutAnalysis(AnalysisMode mode, bool?lightOn = null)
 {
     this.Mode    = mode;
     this.LightOn = lightOn;
 }
Esempio n. 17
0
        public MethodFlowAnalysis GetMethodAnalysis(ISymbol methodSymbol, BlockSyntax body, IEnumerable <SyntaxNode> statements, AnalysisMode mode)
        {
            var key      = methodSymbol.ContainingNamespace.Name + "." + methodSymbol.ToDisplayString() + "_" + mode;
            var existing = methodCache.Get <string, MethodFlowAnalysis>(key);

            if (existing != null)
            {
                return(existing);
            }
            lock (methodCache)
            {
                existing = methodCache.Get <string, MethodFlowAnalysis>(key);
                if (existing == null)
                {
                    existing = new MethodFlowAnalyzer(Model, mode).Analyze(body, statements);
                    methodCache.Add <string, MethodFlowAnalysis>(key, existing, TimeSpan.FromSeconds(20), CacheItemPriority.Normal);
                }
                return(existing);
            }
        }
Esempio n. 18
0
        /// <summary>
        ///
        /// Finds the selector associated with a set of decision factors
        ///
        /// </summary>
        /// <param name="depth">The number of previous rounds being analyzed</param>
        /// <param name="mode">The type of analysis being used to analyze previous rounds</param>
        /// <param name="assumedHistory">The collection of rounds available to be analyzed</param>
        /// <returns>The Selector associated with the input decision factors</returns>

        Selector <MoveType> FindSelector(int depth, AnalysisMode mode, MoveHistory assumedHistory)
        {
            int firstIndex = GetIndex(mode);

            // Find correct SelectionTree
            Selector <MoveType> selector = null;
            int secondIndex = -1;
            int thirdIndex  = -1;
            int fourthIndex = -1;

            if (depth == 0)
            {
                selector = zeroMoveTree;
            }
            else
            {
                switch (mode)
                {
                case AnalysisMode.PlayerAbsolute:
                    secondIndex = GetIndex(assumedHistory.Rounds[0].PlayerAbsolute);
                    if (depth > 1)
                    {
                        thirdIndex = GetIndex(assumedHistory.Rounds[1].PlayerAbsolute);
                    }
                    if (depth > 2)
                    {
                        fourthIndex = GetIndex(assumedHistory.Rounds[2].PlayerAbsolute);
                    }
                    break;

                case AnalysisMode.PlayerRelative:
                    secondIndex = GetIndex(assumedHistory.Rounds[0].PlayerRelative);
                    if (depth > 1)
                    {
                        thirdIndex = GetIndex(assumedHistory.Rounds[1].PlayerRelative);
                    }
                    if (depth > 2)
                    {
                        fourthIndex = GetIndex(assumedHistory.Rounds[2].PlayerRelative);
                    }
                    break;

                case AnalysisMode.OpponentAbsolute:
                    secondIndex = GetIndex(assumedHistory.Rounds[0].OpponentAbsolute);
                    if (depth > 1)
                    {
                        thirdIndex = GetIndex(assumedHistory.Rounds[1].OpponentAbsolute);
                    }
                    if (depth > 2)
                    {
                        fourthIndex = GetIndex(assumedHistory.Rounds[2].OpponentAbsolute);
                    }
                    break;

                case AnalysisMode.OpponentRelative:
                    secondIndex = GetIndex(assumedHistory.Rounds[0].OpponentRelative);
                    if (depth > 1)
                    {
                        thirdIndex = GetIndex(assumedHistory.Rounds[1].OpponentRelative);
                    }
                    if (depth > 2)
                    {
                        fourthIndex = GetIndex(assumedHistory.Rounds[2].OpponentRelative);
                    }
                    break;

                case AnalysisMode.Result:
                    secondIndex = GetIndex(assumedHistory.Rounds[0].Result);
                    if (depth > 1)
                    {
                        thirdIndex = GetIndex(assumedHistory.Rounds[1].Result);
                    }
                    if (depth > 2)
                    {
                        fourthIndex = GetIndex(assumedHistory.Rounds[2].Result);
                    }
                    break;

                default:
                    throw new InvalidOperationException("FindSelector couldn't resolve AnalysisMode enumeration.");
                }

                if (depth == 1)
                {
                    selector = oneMoveTree[firstIndex, secondIndex];
                }
                else if (depth == 2)
                {
                    selector = twoMoveTree[firstIndex, secondIndex, thirdIndex];
                }
                else if (depth == 3)
                {
                    selector = threeMoveTree[firstIndex, secondIndex, thirdIndex, fourthIndex];
                }
            }

            return(selector);
        }
        public static ArterialData NewArterial(ServiceVolumeTableFDOT arterialInputs, AnalysisMode ProjectAnalMode, float analysisDirectionDemandVol = 800, int numLanes = 2)
        {
            arterialInputs.Signal.EffGreen     = arterialInputs.Signal.CalcEffectiveGreen(arterialInputs.Signal.EffGreenToCycleLengthRatio, arterialInputs.Signal.CycleLengthSec);
            arterialInputs.Signal.EffGreenLeft = arterialInputs.Signal.CalcEffectiveGreen(0.1f, arterialInputs.Signal.CycleLengthSec);
            List <SegmentData> Segments        = new List <SegmentData>();
            IntersectionData   newIntersection = CreateIntersection(numLanes, arterialInputs.Signal.CycleLengthSec, arterialInputs.SerVolAreaType, ProjectAnalMode);

            newIntersection.Signal.ControlType = arterialInputs.Signal.SigType;
            LinkData newLink;
            float    segmentLength;

            for (int intIndex = 0; intIndex < arterialInputs.Roadway.NumIntersections; intIndex++)
            {
                if (intIndex == 0)
                {
                    segmentLength = 0;
                }
                else
                {
                    segmentLength = arterialInputs.Roadway.ArterialLenghtFt / (arterialInputs.Roadway.NumIntersections - 1);
                }

                newLink = new LinkData(segmentLength - newIntersection.CrossStreetWidth, numLanes, arterialInputs.Roadway.PostedSpeedMPH, arterialInputs.Roadway.PropCurbRightSide, arterialInputs.Roadway.Median);
                Segments.Add(new SegmentData(intIndex, newLink, newIntersection, arterialInputs.SerVolAreaType, arterialInputs.Roadway.PostedSpeedMPH, newIntersection.CrossStreetWidth));
            }

            ArterialData newArterial = new ArterialData(arterialInputs, Segments);

            ChangeArterialVolume(ref newArterial, analysisDirectionDemandVol);

            // Calcs Arterial code
            foreach (SegmentData segment in newArterial.Segments)
            {
                foreach (ApproachData approach in segment.Intersection.Approaches)
                {
                    approach.PctLeftTurns  = arterialInputs.Traffic.PctLeftTurns;
                    approach.PctRightTurns = arterialInputs.Traffic.PctRightTurns;
                    foreach (LaneGroupData laneGroup in approach.LaneGroups)
                    {
                        if (laneGroup.Type == LaneMovementsAllowed.LeftOnly)
                        {
                            laneGroup.SignalPhase.GreenEffectiveSec = arterialInputs.Signal.EffGreenLeft;
                            laneGroup.TurnBayLeftLengthFeet         = arterialInputs.Roadway.TurnBayLeftLengthFeet;
                        }
                        else
                        {
                            laneGroup.SignalPhase.GreenEffectiveSec = arterialInputs.Signal.EffGreen;
                        }
                        laneGroup.BaseSatFlow      = arterialInputs.Traffic.BaseSatFlow;
                        laneGroup.PctHeavyVehicles = arterialInputs.Traffic.PctHeavyVeh;
                        laneGroup.ArvType          = arterialInputs.Signal.ArvType;
                        float[] PlatoonRatioValues = new float[] { 0.333f, 0.667f, 1.0f, 1.333f, 1.667f, 2.0f };
                        laneGroup.PlatoonRatio   = PlatoonRatioValues[laneGroup.ArvType - 1];
                        laneGroup.PeakHourFactor = arterialInputs.Traffic.PHF;
                    }
                }
            }
            newArterial.Thresholds.Delay  = newArterial.Thresholds.GetLOSBoundaries_Delay(newArterial.Area);
            newArterial.Thresholds.Speed  = newArterial.Thresholds.GetLOSBoundaries_Speed(arterialInputs.Roadway.PostedSpeedMPH);
            newArterial.AnalysisTravelDir = arterialInputs.Roadway.AnalysisTravelDir;

            return(newArterial);
        }
Esempio n. 20
0
                // Local functions
                static string GetGlobalconfigText(
                    AnalysisMode analysisMode,
                    SortedList <string, DiagnosticDescriptor> sortedRulesById
                    )
                {
                    var result = new StringBuilder();

                    StartGlobalconfig();
                    AddRules(analysisMode);
                    return(result.ToString());

                    void StartGlobalconfig()
                    {
                        result.AppendLine("# NOTE: Requires **VS2019 16.7** or later");
                        result.AppendLine();
                        result.AppendLine($"# Style rules with '{analysisMode}' analysis mode");
                        result.AppendLine();
                        result.AppendLine("is_global = true");
                        result.AppendLine();

                        // Append 'global_level' to ensure conflicts are properly resolved between different global configs:
                        //   1. Lowest precedence (-1): SDK config file generated by us.
                        //   2. Highest predence (non-negative integer): User provided config.
                        // See https://github.com/dotnet/roslyn/issues/48634 for further details.
                        result.AppendLine("global_level = -1");
                        result.AppendLine();
                    }

                    bool AddRules(AnalysisMode analysisMode)
                    {
                        Debug.Assert(sortedRulesById.Count > 0);

                        var addedRule = false;

                        foreach (var rule in sortedRulesById)
                        {
                            if (AddRule(rule.Value))
                            {
                                addedRule = true;
                            }
                        }

                        return(addedRule);

                        bool AddRule(DiagnosticDescriptor rule)
                        {
                            var(isEnabledByDefault, severity) = GetEnabledByDefaultAndSeverity(
                                rule,
                                analysisMode
                                );
                            if (
                                rule.IsEnabledByDefault == isEnabledByDefault &&
                                severity == rule.DefaultSeverity
                                )
                            {
                                // Rule had the same default severity and enabled state.
                                // We do not need to generate any entry.
                                return(false);
                            }

                            var severityString = isEnabledByDefault
                                ? severity.ToEditorConfigString()
                                : EditorConfigSeverityStrings.None;

                            result.AppendLine();
                            result.AppendLine($"# {rule.Id}: {rule.Title}");
                            result.AppendLine(
                                $"dotnet_diagnostic.{rule.Id}.severity = {severityString}"
                                );
                            return(true);
                        }

                        (bool isEnabledByDefault, DiagnosticSeverity effectiveSeverity) GetEnabledByDefaultAndSeverity(
                            DiagnosticDescriptor rule,
                            AnalysisMode analysisMode
                            )
                        {
                            Debug.Assert(
                                rule.CustomTags.Any(
                                    c =>
                                    c == s_neverTag ||
                                    c == s_whenExplicitlyEnabledTag ||
                                    c == s_recommendedTag ||
                                    c == s_highlyRecommendedTag
                                    ),
                                $"DiagnosticDescriptor for '{rule.Id}' must have a {nameof(EnforceOnBuild)} custom tag"
                                );

                            bool isEnabledInNonDefaultMode;

                            switch (analysisMode)
                            {
                            case AnalysisMode.None:
                                // Disable all rules by default.
                                return(isEnabledByDefault : false, DiagnosticSeverity.Warning);

                            case AnalysisMode.All:
                                // Escalate all rules which can be enabled on build.
                                isEnabledInNonDefaultMode = !rule.CustomTags.Contains(
                                    s_neverTag
                                    );
                                break;

                            case AnalysisMode.Minimum:
                                // Escalate all highly recommended rules.
                                isEnabledInNonDefaultMode = rule.CustomTags.Contains(
                                    s_highlyRecommendedTag
                                    );
                                break;

                            case AnalysisMode.Recommended:
                                // Escalate all recommended and highly recommended rules.
                                isEnabledInNonDefaultMode =
                                    rule.CustomTags.Contains(s_highlyRecommendedTag) ||
                                    rule.CustomTags.Contains(s_recommendedTag);
                                break;

                            case AnalysisMode.Default:
                                // Retain the default severity and enabled by default values.
                                isEnabledInNonDefaultMode = false;
                                break;

                            default:
                                throw ExceptionUtilities.UnexpectedValue(analysisMode);
                            }

                            return(
                                isEnabledByDefault : rule.IsEnabledByDefault,
                                effectiveSeverity : isEnabledInNonDefaultMode
                                  ? DiagnosticSeverity.Warning
                                : rule.DefaultSeverity
                                );
                        }
                    }
                }
Esempio n. 21
0
        static bool HandleArguments(ref string[] args)
        {
            var version = false;
            var help    = false;
            var set     = new OptionSet
            {
                "General",
                {
                    "h|?|help",
                    "Print version and exit.",
                    h => help = h != null
                },
                {
                    "v|version",
                    "Print help and exit.",
                    v => version = v != null
                },
                {
                    "o|output",
                    "Specify output text file.",
                    o => _output = o
                },
                {
                    "r|regex=",
                    "Add an opcode regex to filter packets by. Uses Perl 5 regex syntax.",
                    (string ar) => _regexes.Add(ar)
                },
                {
                    "s|stats",
                    "Output parsing and analysis statistics before exiting.",
                    s => _stats = s != null
                },
                "Parsing",
                {
                    "x|hex-dump=",
                    "Specify hex dump mode.",
                    (HexDumpMode x) => _hex = x
                },
                {
                    "p|parse",
                    "Enable/disable parsing of known packets.",
                    p => _parse = p != null
                },
                {
                    "t|roundtrips=",
                    "Specify the number of times to roundtrip parsed packets.",
                    (int t) => _roundtrips = t
                },
                "Analysis",
                {
                    "a|analyze=",
                    "Specify analysis mode.",
                    (AnalysisMode a) => _analysis = a
                },
                {
                    "m|min-string-length",
                    "Specify minimum string length.",
                    (int m) => _length = m
                },
                {
                    "w|allow-white-space",
                    "Enable/disable showing strings consisting only of white space.",
                    w => _whiteSpace = w != null
                },
                {
                    "c|allow-control-chars",
                    "Enable/disable showing strings containing control characters.",
                    c => _control = c != null
                }
            };

            args = set.Parse(args).ToArray();

            if (version)
            {
                ShowVersion();
                return(false);
            }

            if (help)
            {
                ShowHelp(set);
                return(false);
            }

            return(true);
        }
Esempio n. 22
0
 private static void ProcessDirectory(string parentDirectory, AnalysisMode mode)
 {
     foreach (string subDir in Directory.GetDirectories(parentDirectory))
     {
         if (Directory.GetFiles(subDir, "*.UnitTests.dll").Length > 0)
         {
             string trxFile = Path.Combine(subDir, "TestResults.trx");
             ProcessSingleTrxFile(trxFile, Path.GetFileName(subDir), mode);
         }
     }
 }
Esempio n. 23
0
 public SelectionMethod(int length, AnalysisMode mode)
 {
     Depth = length;
     Mode  = mode;
 }
Esempio n. 24
0
 public AnalyzerTestBase(ITestOutputHelper output) : base(output)
 {
     Configuration.Logging.LogsToRetain = int.MaxValue;
     Configuration.Logging.LogExecution = true;
     AnalysisMode = AnalysisMode.None;
 }
Esempio n. 25
0
        /// <summary>
        ///
        /// Updates the MovePicker's selection weights based on the results of a previous decision
        ///
        /// </summary>
        /// <param name="decision"></param>
        /// <param name="result"></param>

        public void Feedback(Decision decision, ResultType result)
        {
            int          depth          = decision.SelectionMethod.Depth;
            AnalysisMode mode           = decision.SelectionMethod.Mode;
            int          firstIndex     = GetIndex(mode);
            MoveHistory  assumedHistory = decision.AssumedHistory;

            Selector <MoveType> selectionTree = FindSelector(depth, mode, assumedHistory);

            switch (result)
            {
            case ResultType.Win:
                if (rewardWin)
                {
                    selectionTree.Reward(decision.PickedMove);
                    depthSelector.Reward(depth);
                    if (depth > 1)
                    {
                        modeSelector.Reward(mode);
                    }
                }
                else if (punishWin)
                {
                    selectionTree.Punish(decision.PickedMove);
                    depthSelector.Punish(depth);
                    if (depth > 1)
                    {
                        modeSelector.Punish(mode);
                    }
                }
                break;

            case ResultType.Loss:
                if (rewardLoss)
                {
                    selectionTree.Reward(decision.PickedMove);
                    depthSelector.Reward(depth);
                    if (depth > 1)
                    {
                        modeSelector.Reward(mode);
                    }
                }
                else if (punishLoss)
                {
                    selectionTree.Punish(decision.PickedMove);
                    depthSelector.Punish(depth);
                    if (depth > 1)
                    {
                        modeSelector.Punish(mode);
                    }
                }
                break;


            case ResultType.Draw:
                if (rewardDraw)
                {
                    selectionTree.Reward(decision.PickedMove);
                    depthSelector.Reward(depth);
                    if (depth > 1)
                    {
                        modeSelector.Reward(mode);
                    }
                }
                else if (punishDraw)
                {
                    selectionTree.Punish(decision.PickedMove);
                    depthSelector.Punish(depth);
                    if (depth > 1)
                    {
                        modeSelector.Punish(mode);
                    }
                }
                break;

            default:
                break;
            }
        }
Esempio n. 26
0
 public Analysis(AnalysisMode type, TrackList <AudioTrack> audioTracks, TimeSpan windowLength, TimeSpan intervalLength, int sampleRate,
                 ProgressMonitor progressMonitor)
     : this(type, audioTracks, windowLength, intervalLength, sampleRate)
 {
     this.progressMonitor = progressMonitor;
 }
        public static IntersectionData NewIntersection(List <TimerData> Timers, int numThruLanes, AnalysisMode ProjectAnalMode, int crossStreetWidth)
        {
            List <ApproachData>    newApproaches = new List <ApproachData>();
            List <LaneGroupData>   newLaneGroups = new List <LaneGroupData>();
            List <LaneData>        newLanes;
            List <SignalPhaseData> Phases = new List <SignalPhaseData>();

            // Intersection Signal Data
            //Example problem specifies permitted left turn for NB LT. Use protected until permitted delay calculations are implemented.
            SignalPhaseData WBLSignalPhase = new SignalPhaseData(nemaPhaseId: 1, nemaMvmtId: NemaMovementNumbers.WBLeft, phaseType: PhasingType.Protected, greenTime: 20, yellowTime: 3, allRedTime: 1, startUpLostTime: 2, timer: Timers[0]);
            SignalPhaseData EBLSignalPhase = new SignalPhaseData(5, NemaMovementNumbers.EBLeft, PhasingType.Protected, 20, 3, 1, 2, Timers[1]);
            SignalPhaseData EBTSignalPhase = new SignalPhaseData(2, NemaMovementNumbers.EBThru, PhasingType.Protected, 45, 3, 1, 2, Timers[2]);
            SignalPhaseData WBTSignalPhase = new SignalPhaseData(6, NemaMovementNumbers.WBThru, PhasingType.Protected, 45, 3, 1, 2, Timers[3]);
            SignalPhaseData NBLSignalPhase = new SignalPhaseData(3, NemaMovementNumbers.NBLeft, PhasingType.Protected, 8, 3, 1, 2, Timers[4]);
            SignalPhaseData SBLSignalPhase = new SignalPhaseData(7, NemaMovementNumbers.SBLeft, PhasingType.Protected, 8, 3, 1, 2, Timers[5]);
            SignalPhaseData SBTSignalPhase = new SignalPhaseData(4, NemaMovementNumbers.SBThru, PhasingType.Protected, 35, 3, 1, 2, Timers[6]);
            SignalPhaseData NBTSignalPhase = new SignalPhaseData(8, NemaMovementNumbers.NBThru, PhasingType.Protected, 35, 3, 1, 2, Timers[7]);

            Phases.Add(WBLSignalPhase);
            Phases.Add(EBTSignalPhase);
            Phases.Add(NBLSignalPhase);
            Phases.Add(SBTSignalPhase);
            Phases.Add(EBLSignalPhase);
            Phases.Add(WBTSignalPhase);
            Phases.Add(SBLSignalPhase);
            Phases.Add(NBTSignalPhase);

            LaneData[] numLeftLanes = new LaneData[1];

            newLanes = CreateLanes(numThruLanes, 0);
            newLaneGroups.Add(new LaneGroupData(1, "NB Thru+Right", LaneMovementsAllowed.ThruRightShared, NemaMovementNumbers.NBThru, TravelDirection.Northbound, newLanes, NBTSignalPhase, arvType: 3));
            newLanes = CreateLanes(numThruLanes, numThruLanes);
            newLaneGroups.Add(new LaneGroupData(2, "NB Left", LaneMovementsAllowed.LeftOnly, NemaMovementNumbers.NBLeft, TravelDirection.Northbound, newLanes, NBLSignalPhase, arvType: 3));
            newApproaches.Add(new ApproachData(1, TravelDirection.Northbound, "NB", 0, newLaneGroups));


            newLaneGroups = new List <LaneGroupData>();
            newLanes      = CreateLanes(numThruLanes, 0);
            newLaneGroups.Add(new LaneGroupData(1, "EB Thru+Right", LaneMovementsAllowed.ThruRightShared, NemaMovementNumbers.EBThru, TravelDirection.Eastbound, newLanes, EBTSignalPhase, arvType: 4));
            newLanes = CreateLanes(numThruLanes, numThruLanes);
            newLaneGroups.Add(new LaneGroupData(2, "EB Left", LaneMovementsAllowed.LeftOnly, NemaMovementNumbers.EBLeft, TravelDirection.Eastbound, newLanes, EBLSignalPhase, arvType: 3));
            newApproaches.Add(new ApproachData(2, TravelDirection.Eastbound, "EB", 0, newLaneGroups));


            newLaneGroups = new List <LaneGroupData>();
            newLanes      = CreateLanes(numThruLanes, 0);
            newLaneGroups.Add(new LaneGroupData(1, "SB Thru+Right", LaneMovementsAllowed.ThruRightShared, NemaMovementNumbers.SBThru, TravelDirection.Southbound, newLanes, SBTSignalPhase, arvType: 3));
            newLanes = CreateLanes(numThruLanes, numThruLanes);
            newLaneGroups.Add(new LaneGroupData(2, "SB Left", LaneMovementsAllowed.LeftOnly, NemaMovementNumbers.SBLeft, TravelDirection.Southbound, newLanes, SBLSignalPhase, arvType: 3));
            newApproaches.Add(new ApproachData(3, TravelDirection.Southbound, "SB", 0, newLaneGroups));


            newLaneGroups = new List <LaneGroupData>();
            newLanes      = CreateLanes(numThruLanes, 0);
            newLaneGroups.Add(new LaneGroupData(1, "WB Thru+Right", LaneMovementsAllowed.ThruRightShared, NemaMovementNumbers.WBThru, TravelDirection.Westbound, newLanes, WBTSignalPhase, arvType: 4));
            newLanes = CreateLanes(numThruLanes, numThruLanes);
            newLaneGroups.Add(new LaneGroupData(2, "WB Left", LaneMovementsAllowed.LeftOnly, NemaMovementNumbers.WBLeft, TravelDirection.Westbound, newLanes, WBLSignalPhase, arvType: 3));
            newApproaches.Add(new ApproachData(4, TravelDirection.Westbound, "WB", 0, newLaneGroups));

            SignalCycleData newSignalData = new SignalCycleData(SigControlType.Pretimed, 124, Phases);

            IntersectionData newIntersection = new IntersectionData(1, AreaType.LargeUrbanized, ArterialClass.ClassI, newApproaches, newSignalData, ProjectAnalMode, crossStreetWidth);

            return(newIntersection);
        }
        public static IntersectionData CreateIntersection(int numThruLanes, int cycleLengthSec, AreaType ArtAreaType, AnalysisMode ProjAnalMode)
        {
            List <TimerData>       Timers        = TimerData.GetStandardTimers();
            List <ApproachData>    newApproaches = new List <ApproachData>();
            List <LaneGroupData>   newLaneGroups = new List <LaneGroupData>();
            List <LaneData>        newLanes;
            List <SignalPhaseData> Phases = new List <SignalPhaseData>();

            // Intersection Signal Data
            SignalPhaseData WBLSignalPhase = new SignalPhaseData(nemaPhaseId: 1, nemaMvmtId: NemaMovementNumbers.WBLeft, phaseType: PhasingType.Protected, greenTime: 20, yellowTime: 3, allRedTime: 1, startUpLostTime: 2, timer: Timers[0]);
            SignalPhaseData EBLSignalPhase = new SignalPhaseData(5, NemaMovementNumbers.EBLeft, PhasingType.Protected, 20, 3, 1, 2, Timers[1]);
            SignalPhaseData EBTSignalPhase = new SignalPhaseData(2, NemaMovementNumbers.EBThru, PhasingType.Protected, 45, 3, 1, 2, Timers[2]);
            SignalPhaseData WBTSignalPhase = new SignalPhaseData(6, NemaMovementNumbers.WBThru, PhasingType.Protected, 45, 3, 1, 2, Timers[3]);
            SignalPhaseData NBLSignalPhase = new SignalPhaseData(3, NemaMovementNumbers.NBLeft, PhasingType.Protected, 8, 3, 1, 2, Timers[4]);
            SignalPhaseData SBLSignalPhase = new SignalPhaseData(7, NemaMovementNumbers.SBLeft, PhasingType.Protected, 8, 3, 1, 2, Timers[5]);
            SignalPhaseData SBTSignalPhase = new SignalPhaseData(4, NemaMovementNumbers.SBThru, PhasingType.Protected, 35, 3, 1, 2, Timers[6]);
            SignalPhaseData NBTSignalPhase = new SignalPhaseData(8, NemaMovementNumbers.NBThru, PhasingType.Protected, 35, 3, 1, 2, Timers[7]);

            Phases.Add(WBLSignalPhase);
            Phases.Add(EBTSignalPhase);
            Phases.Add(NBLSignalPhase);
            Phases.Add(SBTSignalPhase);
            Phases.Add(EBLSignalPhase);
            Phases.Add(WBTSignalPhase);
            Phases.Add(SBLSignalPhase);
            Phases.Add(NBTSignalPhase);

            newLanes = CreateArterial_HCMExample1.CreateLanes(numThruLanes, 0);
            newLaneGroups.Add(new LaneGroupData(1, "NB Thru+Right", LaneMovementsAllowed.ThruRightShared, NemaMovementNumbers.NBThru, TravelDirection.Northbound, newLanes, NBTSignalPhase, arvType: 3));
            newLanes = CreateArterial_HCMExample1.CreateLanes(numThruLanes, numThruLanes);
            newLaneGroups.Add(new LaneGroupData(2, "NB Left", LaneMovementsAllowed.LeftOnly, NemaMovementNumbers.NBLeft, TravelDirection.Northbound, newLanes, NBLSignalPhase, arvType: 3));
            newApproaches.Add(new ApproachData(1, TravelDirection.Northbound, "NB", 0, newLaneGroups));

            newLaneGroups = new List <LaneGroupData>();
            newLanes      = CreateArterial_HCMExample1.CreateLanes(numThruLanes, 0);
            newLaneGroups.Add(new LaneGroupData(1, "EB Thru+Right", LaneMovementsAllowed.ThruRightShared, NemaMovementNumbers.EBThru, TravelDirection.Eastbound, newLanes, EBTSignalPhase, arvType: 3));
            newLanes = CreateArterial_HCMExample1.CreateLanes(numThruLanes, numThruLanes);
            newLaneGroups.Add(new LaneGroupData(2, "EB Left", LaneMovementsAllowed.LeftOnly, NemaMovementNumbers.EBLeft, TravelDirection.Eastbound, newLanes, EBLSignalPhase, arvType: 3));
            newApproaches.Add(new ApproachData(2, TravelDirection.Eastbound, "EB", 0, newLaneGroups));

            newLaneGroups = new List <LaneGroupData>();
            newLanes      = CreateArterial_HCMExample1.CreateLanes(numThruLanes, 0);
            newLaneGroups.Add(new LaneGroupData(1, "SB Thru+Right", LaneMovementsAllowed.ThruRightShared, NemaMovementNumbers.SBThru, TravelDirection.Southbound, newLanes, SBTSignalPhase, arvType: 3));
            newLanes = CreateArterial_HCMExample1.CreateLanes(numThruLanes, numThruLanes);
            newLaneGroups.Add(new LaneGroupData(2, "SB Left", LaneMovementsAllowed.LeftOnly, NemaMovementNumbers.SBLeft, TravelDirection.Southbound, newLanes, SBLSignalPhase, arvType: 3));
            newApproaches.Add(new ApproachData(3, TravelDirection.Southbound, "SB", 0, newLaneGroups));

            newLaneGroups = new List <LaneGroupData>();
            newLanes      = CreateArterial_HCMExample1.CreateLanes(numThruLanes, 0);
            newLaneGroups.Add(new LaneGroupData(1, "WB Thru+Right", LaneMovementsAllowed.ThruRightShared, NemaMovementNumbers.WBThru, TravelDirection.Westbound, newLanes, WBTSignalPhase, arvType: 3));
            newLanes = CreateArterial_HCMExample1.CreateLanes(numThruLanes, numThruLanes);
            newLaneGroups.Add(new LaneGroupData(2, "WB Left", LaneMovementsAllowed.LeftOnly, NemaMovementNumbers.WBLeft, TravelDirection.Westbound, newLanes, WBLSignalPhase, arvType: 3));
            newApproaches.Add(new ApproachData(4, TravelDirection.Westbound, "WB", 0, newLaneGroups));

            SignalCycleData newSignalData = new SignalCycleData(SigControlType.CoordinatedActuated, cycleLengthSec, Phases);

            IntersectionData newIntersection = new IntersectionData(1, ArtAreaType, ArterialClass.ClassI, newApproaches, newSignalData, ProjAnalMode);

            return(newIntersection);
        }