示例#1
0
 public decimal GetVarianceWithOtherTimedState(TimedState otherTimedState)
 {
     return(nodeStates
            .Select(nodeState => nodeState.Key)
            .Select(node => Math.Abs(nodeStates[node] - otherTimedState.nodeStates[node]))
            .Sum());
 }
示例#2
0
        private TimedNodeWeights GetTimeNodesWeights(TimedState currentTimedState)
        {
            if (timedNodeWeightses.ContainsKey(currentTimedState.Identifier))
            {
                return(timedNodeWeightses[currentTimedState.Identifier]);
            }

            var newTimedState = new TimedNodeWeights(currentTimedState);

            timedNodeWeightses[currentTimedState.Identifier] = newTimedState;

            return(newTimedState);
        }
示例#3
0
        private TimedNodeWeights GetClosestTimedNodeWeights(TimedState timeNodeWeights)
        {
            var closestTimedNodeWeights = timedNodeWeightses.First().Value;
            var closestDifference       = decimal.MaxValue;

            foreach (var timedNodeWeights in timedNodeWeightses)
            {
                var otherTimedNodeWeights = timedNodeWeights.Value;
                var difference            = otherTimedNodeWeights.GetVarianceWithOtherTimedNodeState(timeNodeWeights);

                if (difference == 0m)
                {
                    return(otherTimedNodeWeights);
                }

                if (difference < closestDifference)
                {
                    closestTimedNodeWeights = otherTimedNodeWeights;
                    closestDifference       = difference;
                }
            }

            return(closestTimedNodeWeights);
        }
        public ContextState(IEnumerable <Node> nodes)
        {
            var nodeContextStates = nodes.ToDictionary(node => node, node => 0m);

            currentTimedState = new TimedState(nodeContextStates);
        }
 public void UpdateState(Node node)
 {
     currentTimedState = currentTimedState.GetUpdatedTimedState(node);
 }
示例#6
0
 public decimal GetVarianceWithOtherTimedNodeState(TimedState otherTimedState)
 {
     return(timedState.GetVarianceWithOtherTimedState(otherTimedState));
 }
示例#7
0
 public TimedNodeWeights(TimedState timedState)
 {
     this.timedState = timedState;
     resultingNodes  = new List <Node>();
 }