public decimal GetVarianceWithOtherTimedState(TimedState otherTimedState) { return(nodeStates .Select(nodeState => nodeState.Key) .Select(node => Math.Abs(nodeStates[node] - otherTimedState.nodeStates[node])) .Sum()); }
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); }
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); }
public decimal GetVarianceWithOtherTimedNodeState(TimedState otherTimedState) { return(timedState.GetVarianceWithOtherTimedState(otherTimedState)); }
public TimedNodeWeights(TimedState timedState) { this.timedState = timedState; resultingNodes = new List <Node>(); }