private float GetLogPr(DtmcGroup Dtmc, int firstReqPos) { float result = 0; if (firstReqPos == 0 || firstReqPos == Requests.Count) { return(0f); } var firstIndex = Dtmc.UniqueRequest.IndexOf(Dtmc.UniqueRequest.Find(x => x.NameType == Requests[firstReqPos - 1])); var nextIndex = Dtmc.UniqueRequest.IndexOf(Dtmc.UniqueRequest.Find(x => x.NameType == Requests[firstReqPos])); if (nextIndex == -1 || firstIndex == -1) { result += 0.00001f; } else { result += Dtmc.Probability[firstIndex, nextIndex]; } if (result == 0) { result += 0.00001f; } result += (float)Math.Log10(result); return(result); }
private void LoadDtmcDataset(string[] textLines) { var dtmcGroup = new DtmcGroup(); foreach (var line in textLines) { var session = new Session(); var requests = line.Split(); requests = requests.Where(x => !string.IsNullOrEmpty(x)).ToArray(); if (requests[0] == "R") { session.RealType = SessionTypes.Robot; } else if (requests[0] == "H") { session.RealType = SessionTypes.Human; } for (var i = 2; i < requests.Length; i++) { var currentRequest = new Request(); session.AddRequest(requests[i]); currentRequest.NameType = requests[i].First().ToString().ToUpper() + requests[i].Substring(1); dtmcGroup.AddUniqueRequest(currentRequest); } dtmcGroup.Sessions.Add(session); dtmcGroup.UniqueRequest.Sort((x, y) => string.Compare(x.NameType, y.NameType, StringComparison.Ordinal)); } dtmcGroup.GivenName = "Grupa " + dtmcGroup.Sessions[0].RealType; dtmcGroup.CalculateDTMC(); StoreGroup(dtmcGroup); }
private float GetStartChanceValue(DtmcGroup dtmc) { float result; try { var firstElement = dtmc.UniqueRequest.Find(x => x.NameType == Requests[0]); if (firstElement == null) { result = 0.00001f; } else { result = firstElement.StarChances == 0 ? 0.00001f : (float)Math.Log10(firstElement.StarChances); } } catch (ArgumentNullException ex) { result = 0; } return(result); }