public DMSAction getAction(string str) { if (str == "error") { var errrorA = new DMSAction("error"); return(errrorA); } return(getAction(getStateByString(str))); }
public DMSAction getAction(State state) { DMSAction action = null; int indexOfActualState = S.IndexOf(ActualState); if (lastAction != null) { //построение цепи Маркова // lastAction.jumpCounter[indexOfActualState]++; // lastAction.ProbabilityOfNextStates[indexOfActualState] = lastAction.jumpCounter[indexOfActualState] / lastAction.attemptsNumber; /////////////////////////// } /*string s = "S" + i.ToString()+ " = "; * for (int k = 0; k < tempState.p.Length; k++) * { * s += tempState.p[k].value + ','; * } * log(s); */ double Qmax = double.MinValue; double CountMin = double.MaxValue; if (r.NextDouble() < epsilon) { //исследование for (int k = 0; k < S[indexOfActualState].A.Count; k++) { if (CountMin > S[indexOfActualState].A[k].attemptsNumber) { action = S[indexOfActualState].A[k]; CountMin = S[indexOfActualState].A[k].attemptsNumber; } } } else { //эксплуатация for (int k = 0; k < S[indexOfActualState].A.Count; k++) { if (Qmax < S[indexOfActualState].A[k].Q) { action = S[indexOfActualState].A[k]; Qmax = S[indexOfActualState].A[k].Q; } } } if (action == null) { action.type = ""; } action.attemptsNumber++; lastAction = action; indexOfLastState = indexOfActualState; indexOfLastAction = S[indexOfActualState].A.IndexOf(action); // log(action.type); return(action); }