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
EnvironmentObserver s |
void |
clearAllObservers()
Clears all
EnvironmentObserver s 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
EnvironmentObserver s 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
EnvironmentObserver s 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()
TaskSettableEnvironment
RewardFunction
this Environment
uses
to determine rewards.getRf
in interface TaskSettableEnvironment
RewardFunction
public void setRf(RewardFunction rf)
TaskSettableEnvironment
RewardFunction
of this Environment
to
the specified reward function.setRf
in interface TaskSettableEnvironment
rf
- the new RewardFunction
of the Environment
.public TerminalFunction getTf()
TaskSettableEnvironment
TerminalFunction
this Environment
uses
to determine terminal statesgetTf
in interface TaskSettableEnvironment
TerminalFunction
public void setTf(TerminalFunction tf)
TaskSettableEnvironment
TerminalFunction
of this Environment
to
the specified terminal function.setTf
in interface TaskSettableEnvironment
tf
- the new TerminalFunction
of the Environment
.public StateGenerator getStateGenerator()
public void setStateGenerator(StateGenerator stateGenerator)
public void addObservers(EnvironmentObserver... observers)
EnvironmentServerInterface
EnvironmentObserver
saddObservers
in interface EnvironmentServerInterface
observers
- and EnvironmentObserver
public void clearAllObservers()
EnvironmentServerInterface
EnvironmentObserver
s from this server.clearAllObservers
in interface EnvironmentServerInterface
public void removeObservers(EnvironmentObserver... observers)
EnvironmentServerInterface
EnvironmentObserver
s from this server.removeObservers
in interface EnvironmentServerInterface
observers
- the EnvironmentObserver
s to remove.public java.util.List<EnvironmentObserver> getObservers()
EnvironmentServerInterface
EnvironmentObserver
s registered with this server.getObservers
in interface EnvironmentServerInterface
EnvironmentObserver
s 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)
StateSettableEnvironment
setCurStateTo
in interface StateSettableEnvironment
s
- the state to which this Environment
will be set.public State getCurrentObservation()
Environment
State
.getCurrentObservation
in interface Environment
State
.public EnvironmentOutcome executeAction(GroundedAction ga)
Environment
executeAction
in interface Environment
ga
- the GroundedAction that is to be performed in this environment.public double getLastReward()
Environment
getLastReward
in interface Environment
public boolean isInTerminalState()
Environment
isInTerminalState
in interface Environment
public void resetEnvironment()
Environment
resetEnvironment
in interface Environment