/// <summary> /// Get the Congestion Probability from a node on RG (ChannalX_Y, X: id of From Channel, Y: id of To Channel) /// </summary> /// <param name="now"></param> /// <returns></returns> private double GetProbabilityFromChannel(EventBAPairSafety now) { //double upper_bound = 0.999999d; //double lower_bound = 0.8d; //Random random = new Random(); //double result = random.NextDouble() * (upper_bound - lower_bound) + lower_bound; double result = 1d; // Will not work if the name of ChannelX_Y has been changed before this verification is launched Regex reg_channel = new Regex(@"Channel([0-9]+_[0-9]+)"); Match match = reg_channel.Match(now.configuration.Event); if (match.Success) { string _regProb = "prob" + match.Groups[1].Value + "=([0-9]+)"; Regex regProb = new Regex(@_regProb); EventStepSim stepSim = new EventStepSim(now.configuration); Match matchProb = regProb.Match(stepSim.StepToString); if (matchProb.Success) { result = double.Parse(matchProb.Groups[1].Value) / 100; } } return(result); }
public void parse(List <object[]> nodesData, List <string[]> edgesData, List <List <double[]> > nodesInfo, List <List <double[]> > edgesInfo, DictionaryJ <string, GraphDataConfiguration> graphDataConfigs) { try { DictionaryJ <String, object[]> nodesMap = new DictionaryJ <String, object[]>(); foreach (Edge edge in Graph.Edges) { String sourceNodeId = edge.SourceNode.LabelText; String targetNodeId = edge.TargetNode.LabelText; object[] sourceNodeData; // length=4 [1:type, 2:id, 3;label, 4:additionalinfo] if (!string.IsNullOrEmpty(edge.LabelText) && !nodesMap.ContainsKey(sourceNodeId)) { EventStepSim userData = edge.SourceNode.UserData as EventStepSim; sourceNodeData = new object[4]; sourceNodeData[0] = "REGULAR"; sourceNodeData[1] = sourceNodeId; sourceNodeData[2] = String.Format("[{0}] {1}", sourceNodeId, userData.ToString()); PAT.GenericDiff.graph.Graph configGraph = configGraphBuilder.execute(this.side, userData.Config, sourceNodeId); sourceNodeData[3] = configGraph; nodesData.Add(sourceNodeData); nodesInfo.Add(extractNodeInfos(userData.Config.GlobalEnv, configGraph, graphDataConfigs["REGULAR"].elementInfoTemplates)); nodesMap.put(sourceNodeId, sourceNodeData); } object[] targetNodeData; // length=4 [1:type, 2:id, 3;label, 4:additionalinfo] if (!nodesMap.ContainsKey(targetNodeId)) { EventStepSim userData = edge.TargetNode.UserData as EventStepSim; targetNodeData = new object[4]; targetNodeData[0] = !string.IsNullOrEmpty(edge.LabelText) ? "REGULAR" : "INIT"; targetNodeData[1] = targetNodeId; targetNodeData[2] = String.Format("[{0}] {1}", targetNodeId, userData.ToString()); PAT.GenericDiff.graph.Graph configGraph = configGraphBuilder.execute(this.side, userData.Config, targetNodeId); targetNodeData[3] = configGraph; nodesData.Add(targetNodeData); nodesInfo.Add(extractNodeInfos(userData.Config.GlobalEnv, configGraph, graphDataConfigs[!string.IsNullOrEmpty(edge.LabelText) ? "REGULAR" : "INIT"].elementInfoTemplates)); nodesMap.put(targetNodeId, targetNodeData); } if (!string.IsNullOrEmpty(edge.LabelText)) { String[] edgeData = new String[5]; edgeData[0] = "TRANSITION"; edgeData[1] = edge.LabelText; edgeData[2] = sourceNodeId; edgeData[3] = targetNodeId; edgesData.Add(edgeData); edgesInfo.Add(extractEdgeInfos(edge.LabelText, graphDataConfigs["TRANSITION"].elementInfoTemplates)); } } } catch (Exception e) { //e.printStackTrace(); } if (!compareConfigGraph) { if (compareParameterizedSystem) { adjustNodeInfosForParameterizedSystems(nodesInfo, graphDataConfigs); } else { adjustNodeInfosRegular(nodesInfo, graphDataConfigs); } } }