aima.core.probability.mdp.impl.MDP Maven / Gradle / Ivy
package aima.core.probability.mdp.impl;
import java.util.Set;
import aima.core.agent.Action;
import aima.core.probability.mdp.ActionsFunction;
import aima.core.probability.mdp.MarkovDecisionProcess;
import aima.core.probability.mdp.RewardFunction;
import aima.core.probability.mdp.TransitionProbabilityFunction;
/**
* Default implementation of the MarkovDecisionProcess interface.
*
* @param
* the state type.
* @param
* the action type.
*
* @author Ciaran O'Reilly
* @author Ravi Mohan
*/
public class MDP implements MarkovDecisionProcess {
private Set states = null;
private S initialState = null;
private ActionsFunction actionsFunction = null;
private TransitionProbabilityFunction transitionProbabilityFunction = null;
private RewardFunction rewardFunction = null;
public MDP(Set states, S initialState,
ActionsFunction actionsFunction,
TransitionProbabilityFunction transitionProbabilityFunction,
RewardFunction rewardFunction) {
this.states = states;
this.initialState = initialState;
this.actionsFunction = actionsFunction;
this.transitionProbabilityFunction = transitionProbabilityFunction;
this.rewardFunction = rewardFunction;
}
//
// START-MarkovDecisionProcess
@Override
public Set states() {
return states;
}
@Override
public S getInitialState() {
return initialState;
}
@Override
public Set actions(S s) {
return actionsFunction.actions(s);
}
@Override
public double transitionProbability(S sDelta, S s, A a) {
return transitionProbabilityFunction.probability(sDelta, s, a);
}
@Override
public double reward(S s) {
return rewardFunction.reward(s);
}
// END-MarkovDecisionProcess
//
}