main.java.burlap.mdp.singleagent.model.DelegatedModel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of burlap Show documentation
Show all versions of burlap Show documentation
The Brown-UMBC Reinforcement Learning and Planning (BURLAP) Java code library is for the use and
development of single or multi-agent planning and learning algorithms and domains to accompany them. The library
uses a highly flexible state/observation representation where you define states with your own Java classes, enabling
support for domains that discrete, continuous, relational, or anything else. Planning and learning algorithms range from classic forward search
planning to value-function-based stochastic planning and learning algorithms.
The newest version!
package burlap.mdp.singleagent.model;
import burlap.mdp.core.action.Action;
import burlap.mdp.core.state.State;
import burlap.mdp.singleagent.environment.EnvironmentOutcome;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* An implementation of {@link FullModel} that will delegate transition estimates for different actions to different
* {@link SampleModel} or {@link FullModel} implementations. Also contains a default {@link SampleModel} to use
* for actions that do not have specific delegates assigned.
* @author James MacGlashan.
*/
public class DelegatedModel implements FullModel {
SampleModel defaultMode;
Map delgates = new HashMap();
public DelegatedModel(SampleModel defaultMode) {
this.defaultMode = defaultMode;
}
@Override
public List transitions(State s, Action a) {
SampleModel delgate = delgates.get(a.actionName());
if(delgate == null){
if(!(defaultMode instanceof FullModel)){
throw new RuntimeException("Cannot get transitions because the model for the input action is only a SampleModel");
}
return ((FullModel)defaultMode).transitions(s, a);
}
return ((FullModel)delgate).transitions(s, a);
}
@Override
public EnvironmentOutcome sample(State s, Action a) {
SampleModel delgate = delgates.get(a.actionName());
if(delgate == null){
return defaultMode.sample(s, a);
}
return delgate.sample(s, a);
}
@Override
public boolean terminal(State s) {
return defaultMode.terminal(s);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy