Пример #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);
        }
Пример #4
0
        public ContextState(IEnumerable <Node> nodes)
        {
            var nodeContextStates = nodes.ToDictionary(node => node, node => 0m);

            currentTimedState = new TimedState(nodeContextStates);
        }
Пример #5
0
 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>();
 }