public class SimulatedEnvironment extends java.lang.Object implements StateSettableEnvironment, TaskSettableEnvironment, EnvironmentServerInterface
Environment that simulates interactions using the Action.performAction(burlap.oomdp.core.states.State, burlap.oomdp.singleagent.GroundedAction)
method of the the Domain provided to this Environment. The rewards and terminal states are similarly tracked using a
provided RewardFunction and TerminalFunction. Initial states of the environment
are defined using a StateGenerator. If no StateGenerator is specified,
but an initial State is provided in a constructor, then the StateGenerator is
set to a ConstantStateGenerator so that upon resetEnvironment() method calls,
the initial state is the same as the original input state.
State of
the environment. Copies of the state are returned to prevent tampering of the internal environment state.
Environment will not allow states to change when the current
environment state is a terminal state (as specified by the input TerminalFunction); instead, the
same current state will be returned with a reward of zero if someone attempts to interact with the environment through executeAction(burlap.oomdp.singleagent.GroundedAction).
In this case, the environment state will have to be manually changed with resetEnvironment() or setCurStateTo(burlap.oomdp.core.states.State)
to a non-terminal state before actions will affect the state again. Alternatively, you can allow actions to affect the state from
terminal states with the setAllowActionFromTerminalStates(boolean) method.| Modifier and Type | Field and Description |
|---|---|
protected boolean |
allowActionFromTerminalStates
A flag indicating whether the environment will respond to actions from a terminal state.
|
protected State |
curState
The current state of the environment
|
protected Domain |
domain
The domain of this environment
|
protected double |
lastReward
The last reward generated from this environment.
|
protected java.util.List<EnvironmentObserver> |
observers
The
EnvironmentObserver objects that will be notified of Environment
events. |
protected RewardFunction |
rf
The reward function of this environment
|
protected StateGenerator |
stateGenerator
The state generator used to generate new states when the environment is reset with
resetEnvironment(); |
protected TerminalFunction |
tf
The terminal function for this environment
|
| Constructor and Description |
|---|
SimulatedEnvironment(Domain domain,
RewardFunction rf,
TerminalFunction tf) |
SimulatedEnvironment(Domain domain,
RewardFunction rf,
TerminalFunction tf,
State initialState) |
SimulatedEnvironment(Domain domain,
RewardFunction rf,
TerminalFunction tf,
StateGenerator stateGenerator) |
| Modifier and Type | Method and Description |
|---|---|
void |
addObservers(EnvironmentObserver... observers)
Adds one or more
EnvironmentObservers |
void |
clearAllObservers()
Clears all
EnvironmentObservers from this server. |
EnvironmentOutcome |
executeAction(GroundedAction ga)
Executes the specified action in this environment
|
State |
getCurrentObservation()
Returns the current observation of the environment as a
State. |
Domain |
getDomain() |
double |
getLastReward()
Returns the last reward returned by the environment
|
java.util.List<EnvironmentObserver> |
getObservers()
Returns all
EnvironmentObservers registered with this server. |
RewardFunction |
getRf()
Returns the
RewardFunction this Environment uses
to determine rewards. |
StateGenerator |
getStateGenerator() |
TerminalFunction |
getTf()
Returns the
TerminalFunction this Environment uses
to determine terminal states |
boolean |
isInTerminalState()
Returns whether the environment is in a terminal state that prevents further action by the agent.
|
void |
removeObservers(EnvironmentObserver... observers)
Removes one or more
EnvironmentObservers from this server. |
void |
resetEnvironment()
Resets this environment to some initial state, if the functionality exists.
|
void |
setAllowActionFromTerminalStates(boolean allowActionFromTerminalStates)
Sets whether the environment will respond to actions from a terminal state.
|
void |
setCurStateTo(State s)
Sets the current state of the environment to the specified state.
|
void |
setDomain(Domain domain) |
void |
setRf(RewardFunction rf)
Sets the
RewardFunction of this Environment to
the specified reward function. |
void |
setStateGenerator(StateGenerator stateGenerator) |
void |
setTf(TerminalFunction tf)
Sets the
TerminalFunction of this Environment to
the specified terminal function. |
protected Domain domain
protected RewardFunction rf
protected TerminalFunction tf
protected StateGenerator stateGenerator
resetEnvironment();protected State curState
protected double lastReward
protected boolean allowActionFromTerminalStates
executeAction(burlap.oomdp.singleagent.GroundedAction)
method will result in no change in state and to enable action again, the Environment state will have to be
manually changed with the resetEnvironment() method or the setCurStateTo(burlap.oomdp.core.states.State) method.
If this value is true, then actions will be carried out according to the domain's transition dynamics.protected java.util.List<EnvironmentObserver> observers
EnvironmentObserver objects that will be notified of Environment
events.public SimulatedEnvironment(Domain domain, RewardFunction rf, TerminalFunction tf)
public SimulatedEnvironment(Domain domain, RewardFunction rf, TerminalFunction tf, State initialState)
public SimulatedEnvironment(Domain domain, RewardFunction rf, TerminalFunction tf, StateGenerator stateGenerator)
public Domain getDomain()
public void setDomain(Domain domain)
public RewardFunction getRf()
TaskSettableEnvironmentRewardFunction this Environment uses
to determine rewards.getRf in interface TaskSettableEnvironmentRewardFunctionpublic void setRf(RewardFunction rf)
TaskSettableEnvironmentRewardFunction of this Environment to
the specified reward function.setRf in interface TaskSettableEnvironmentrf - the new RewardFunction of the Environment.public TerminalFunction getTf()
TaskSettableEnvironmentTerminalFunction this Environment uses
to determine terminal statesgetTf in interface TaskSettableEnvironmentTerminalFunctionpublic void setTf(TerminalFunction tf)
TaskSettableEnvironmentTerminalFunction of this Environment to
the specified terminal function.setTf in interface TaskSettableEnvironmenttf - the new TerminalFunction of the Environment.public StateGenerator getStateGenerator()
public void setStateGenerator(StateGenerator stateGenerator)
public void addObservers(EnvironmentObserver... observers)
EnvironmentServerInterfaceEnvironmentObserversaddObservers in interface EnvironmentServerInterfaceobservers - and EnvironmentObserverpublic void clearAllObservers()
EnvironmentServerInterfaceEnvironmentObservers from this server.clearAllObservers in interface EnvironmentServerInterfacepublic void removeObservers(EnvironmentObserver... observers)
EnvironmentServerInterfaceEnvironmentObservers from this server.removeObservers in interface EnvironmentServerInterfaceobservers - the EnvironmentObservers to remove.public java.util.List<EnvironmentObserver> getObservers()
EnvironmentServerInterfaceEnvironmentObservers registered with this server.getObservers in interface EnvironmentServerInterfaceEnvironmentObservers registered with this server.public void setAllowActionFromTerminalStates(boolean allowActionFromTerminalStates)
executeAction(burlap.oomdp.singleagent.GroundedAction)
method will result in no change in state and to enable action again, the Environment state will have to be
manually changed with the resetEnvironment() method or the setCurStateTo(burlap.oomdp.core.states.State) method.
If this value is true, then actions will be carried out according to the domain's transition dynamics.allowActionFromTerminalStates - if false, then actions are not allowed from terminal states; if true, then they are allowed.public void setCurStateTo(State s)
StateSettableEnvironmentsetCurStateTo in interface StateSettableEnvironments - the state to which this Environment will be set.public State getCurrentObservation()
EnvironmentState.getCurrentObservation in interface EnvironmentState.public EnvironmentOutcome executeAction(GroundedAction ga)
EnvironmentexecuteAction in interface Environmentga - the GroundedAction that is to be performed in this environment.public double getLastReward()
EnvironmentgetLastReward in interface Environmentpublic boolean isInTerminalState()
EnvironmentisInTerminalState in interface Environmentpublic void resetEnvironment()
EnvironmentresetEnvironment in interface Environment