public double Compute(NetworkVertex networkVertex, double[] newValue, double[] oldValue = null) { var totalArea = 0.0; networkVertex.States.ForEach((state, i) => { totalArea += (state.SafeMax - state.SafeMin) * newValue[i]; }); var neededArea = totalArea * this.percentile; var currentArea = 0.0; var k = 0; foreach (var state in networkVertex.States) { var thisArea = (state.SafeMax - state.SafeMin) * newValue[k]; if (currentArea + thisArea > neededArea) { return(state.SafeMin + (neededArea - currentArea) / newValue[k]); } currentArea += thisArea; k++; } return(networkVertex.States.Last().SafeMax); }
public double[,] GetBeliefStatistic(NetworkVertex networkVertex, IVertexValueComputer valueComputer, IEnumerable <string> sectionIds) { foreach (var sectionId in (IEnumerable <string>) this.sectionEvidences.Keys) { Console.WriteLine(sectionId); } return(null); }
private string FormPotentialString(NetworkVertex networkVertex, double[,] table, string[] parentNodeKeys, int row = 0, int col = 0, int level = 0) { var potentialString = ""; parentNodeKeys = parentNodeKeys ?? this.GetParentIds(networkVertex.Key); if (!parentNodeKeys.Any()) { potentialString += "("; foreach (var state in networkVertex.States) { potentialString += table[row++, col]; if (state != networkVertex.States.Last()) { potentialString += " "; } } potentialString += ")"; } else { var currentNodeKey = parentNodeKeys.First(); var currentNodeStates = this.Vertices[currentNodeKey].States; var nCols = parentNodeKeys.Except(currentNodeKey).Aggregate(1, (current, parentNodeKey) => current * this.Vertices[parentNodeKey].States.Count); potentialString += "("; foreach (var state in currentNodeStates) { potentialString += this.FormPotentialString(networkVertex, table, parentNodeKeys.Except(currentNodeKey).ToArray(), row, col, level + 1); col += nCols; if (state != currentNodeStates.Last()) { potentialString += "\n\t\t " + String.Concat(Enumerable.Repeat(" ", level)); } } potentialString += ")"; } return(potentialString); }
public double[,] GetBeliefs(NetworkVertex networkVertex, string sectionId, IEnumerable <int> years) { var sectionBelief = this.GetBelief(sectionId); var nRows = networkVertex.States.Count; var nCols = years.Count(); var beliefs = new double[nRows, nCols]; for (var col = 0; col < nCols; col++) { for (var row = 0; row < nRows; row++) { beliefs[row, col] = sectionBelief[years.ElementAt(col)][networkVertex.Key][row]; } } return(beliefs); }
public double[,] GetBeliefs(NetworkVertex networkVertex, IEnumerable <string> sectionIds, int year) { var sectionIdList = sectionIds as IList <string> ?? sectionIds.ToList(); var nRows = sectionIdList.Count(); var nCols = networkVertex.States.Count; var beliefs = new double[nRows, nCols]; for (var row = 0; row < nRows; row++) { var sectionBelief = this.GetBelief(sectionIdList[row]); for (var col = 0; col < nCols; col++) { beliefs[row, col] = sectionBelief[year][networkVertex.Key][col]; } } return(beliefs); }
public double[,] GetEvidenceStatistic(NetworkVertex networkVertex, IVertexValueComputer valueComputer, IEnumerable <string> sectionIds) { var sectionIdList = sectionIds as IList <string> ?? sectionIds.ToList(); var nRows = sectionIdList.Count(); var nCols = this.GetEvidence(sectionIdList.First()).Keys.Count; var statistic = new double[nRows, nCols]; var row = 0; foreach (var sectionId in sectionIdList) { var col = 0; var sectionEvidence = this.GetEvidence(sectionId); if (sectionEvidence == null) { continue; } foreach (var year in sectionEvidence.Keys) { if (sectionEvidence[year][networkVertex.Key].Value != null) { statistic[row, col] = valueComputer.Compute(networkVertex, sectionEvidence[year][networkVertex.Key].Value, null); } col++; } row++; } return(statistic); }
public double Compute(NetworkVertex networkVertex, double[] newValue, double[] oldValue) { return(newValue[this.stateIndex] - oldValue[this.stateIndex]); }
public double Compute(NetworkVertex networkVertex, double[] newValue, double[] oldValue) { return(networkVertex.StandardDeviation(newValue, oldValue)); }
public double Compute(NetworkVertex networkVertex, double[] newValue, double[] oldValue) { return(networkVertex.MeanDifference(newValue, oldValue)); }
public double Compute(NetworkVertex networkVertex, double[] newValue, double[] oldValue) { return(networkVertex.Entropy(newValue, oldValue)); }
public double[,] GetEvidenceStatistic(NetworkVertex networkVertex, IVertexValueComputer valueComputer) { return(this.GetEvidenceStatistic(networkVertex, valueComputer, this.GetSectionIds())); }
public double[,] GetBeliefStatistic(IVertexValueComputer valueComputer, NetworkVertex networkVertex) { return(this.GetBeliefStatistic(valueComputer, networkVertex, this.GetSectionIds())); }