示例#1
0
 public bool Equals(LongByte p)
 {
     // Return true if the fields match.
     // Note that the base class is not invoked because it is
     // System.Object, which defines Equals as reference equality.
     return(Value == p.Value);
 }
示例#2
0
        public NodeData(INode node, DataSourceBuilder builder, Evaluation e = null)
        {
            if (builder is null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            if (node is null)
            {
                throw new ArgumentNullException(nameof(node));
            }

            double ColumnInstances = e != null ? e.Scores[node.Key].ColumnInstances : builder.Result.ColumnInstances[node.Key];

            Node   = node ?? throw new ArgumentNullException(nameof(node));
            Score  = Node.GetScore(builder.Result.BaseRate);
            Weight = builder.Result.GraphInstances / ColumnInstances;
            LongByte Key = new LongByte(Node.Key);

            Data = new Dictionary <string, object>()
            {
                ["Accuracy"]        = node.Accuracy.Current,
                ["Next Accuracy"]   = node.Accuracy.Next,
                ["Weight"]          = Weight,
                ["Score"]           = Score,
                ["Weighted Score"]  = Score * Weight,
                ["GraphInstances"]  = builder.Result.GraphInstances,
                ["ColumnInstances"] = ColumnInstances,
                ["Match None"]      = node[MatchResult.None],
                ["Match Route"]     = node[MatchResult.Route],
                ["Match Predictor"] = node[MatchResult.Output],
                ["Match Both"]      = node[MatchResult.Both],
                ["Key"]             = new LongByte(Node.Key),
                ["Name"]            = builder.GetNodeName(node)
            };

            if (e != null)
            {
                int h = 0;
                foreach (string s in e.CalculatedData.Keys)
                {
                    Data.Add(s, Key.HasBitAt(h++) ? e.CalculatedData[s] : "");
                }
            }

            int i = 0;

            foreach (string s in builder.Registrations.Select(r => r.Header))
            {
                Data.Add($"{s}_Bit", Key.HasBitAt(i++) ? 1 : 0);
            }
        }
示例#3
0
        public void MatchRoute(INode n, long Key)
        {
            if (n is null)
            {
                throw new ArgumentNullException(nameof(n));
            }

            if (Key == 0)
            {
                throw new ArgumentException("Can not match node with key = 0", nameof(n));
            }

            if (!this.MatchedRoutes.ContainsKey(Key))
            {
                this.MatchedRoutes.TryAdd(Key, n);

                if (this.AnalysisResults.ColumnInstances.ContainsKey(Key))
                {
                    if (!this.Scores.TryGetValue(Key, out AnalysisScore score))
                    {
                        score = new AnalysisScore();
                        this.Scores.TryAdd(Key, score);
                    }

                    score.Value    = n.GetScore(this.Result.BaseRate);
                    score.OldCount = (double)this.AnalysisResults.GraphInstances / this.AnalysisResults.ColumnInstances[Key];
                    score.OldValue = n.GetScore(this.Result.BaseRate);
                    score.ColumnInstances++;

                    LongByte lb = new LongByte(Key);

                    while (lb > 0)
                    {
                        if (!this.Scores.TryGetValue(lb, out AnalysisScore s))
                        {
                            s = new AnalysisScore();
                            this.Scores.TryAdd(lb, s);
                        }

                        s.ColumnInstances++;

                        lb.TrimLeft();
                    }
                }
            }
        }
示例#4
0
 public LongByte And(LongByte other)
 {
     return(Value & other);
 }
示例#5
0
 public ValidationResult(LongByte @checked)
 {
     IsValid = true;
     Checked = @checked;
 }
示例#6
0
 public ValidationResult(IRouteConstraint violation, LongByte @checked)
 {
     IsValid = false;
     Violations.Add(violation);
     Checked = @checked;
 }
示例#7
0
 public ValidationResult(string message, LongByte @checked)
 {
     IsValid = false;
     Message = message;
     Checked = @checked;
 }