private Value GetExpectation(IMarkovAction <TState> action, TState state, IValueFunction <TState> previousFunction) { var expectation = new Value(0.0, 0.0); foreach (var nextState in action[state]) { var probability = action[state, nextState]; if (probability == 0) { continue; } var totalReward = 0.0; foreach (var reward in Rewards) { totalReward += reward[state, nextState, action]; } var prevValue = previousFunction[nextState]; var rewardValue = new Value(totalReward + (Discount * prevValue.Mean), prevValue.Variance + (totalReward * totalReward) + (2 * Discount * prevValue.Mean * totalReward)); expectation += probability * rewardValue; } return(expectation); }
public Neuron(IValue input, IValueFunction function, double bias) { this.input = input; this.function = function; this.bias = bias; }
public TResult ExecuteFunction <TResult>(IValueFunction <TResult> valueFunction) { GetOrCreateContext(valueFunction.GetType()); return(valueFunction.Execute(_wrappedContext)); }