MachineIntelligenceCore:ReinforcementLearning
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator
mic::environments::Environment Class Referenceabstract

Abstract class representing an environment. More...

#include <Environment.hpp>

Inheritance diagram for mic::environments::Environment:
Collaboration diagram for mic::environments::Environment:

Public Member Functions

 Environment (std::string node_name_)
 
virtual ~Environment ()
 
virtual void initializeEnvironment ()=0
 
mic::types::TensorXfPtr & getEnvironment ()
 
virtual size_t getEnvironmentWidth ()
 
virtual size_t getEnvironmentHeight ()
 
virtual size_t getEnvironmentSize ()
 
virtual size_t getObservationWidth ()
 
virtual size_t getObservationHeight ()
 
virtual size_t getObservationSize ()
 
virtual size_t getChannels ()
 
size_t getROISize ()
 
virtual std::string environmentToString ()=0
 
virtual std::string observationToString ()=0
 
virtual mic::types::MatrixXfPtr encodeEnvironment ()=0
 
virtual mic::types::MatrixXfPtr encodeObservation ()=0
 
virtual mic::types::Position2D getAgentPosition ()=0
 
bool moveAgent (mic::types::Action2DInterface ac_)
 
virtual bool moveAgentToPosition (mic::types::Position2D pos_)=0
 
virtual void moveAgentToInitialPosition ()
 
virtual float getStateReward (mic::types::Position2D pos_)=0
 
virtual bool isStateAllowed (long x_, long y_)
 
virtual bool isStateAllowed (mic::types::Position2D pos_)=0
 
virtual bool isStateTerminal (long x_, long y_)
 
virtual bool isStateTerminal (mic::types::Position2D pos_)=0
 
virtual bool isActionAllowed (long x_, long y_, size_t action_)
 
virtual bool isActionAllowed (mic::types::Position2D pos_, mic::types::Action2DInterface ac_)
 
virtual bool isActionAllowed (mic::types::Action2DInterface ac_)
 

Protected Attributes

mic::configuration::Property
< size_t > 
width
 Property: width of the environment. More...
 
mic::configuration::Property
< size_t > 
height
 Property: height of the environment. More...
 
mic::configuration::Property
< size_t > 
roi_size
 Property: size of the ROI (region of interest). More...
 
size_t channels
 Number of channels. More...
 
bool pomdp_flag
 Flag related to. More...
 
mic::types::Position2D initial_position
 Property: initial position of the agent. More...
 
mic::types::TensorXfPtr environment_grid
 Tensor storing the environment. More...
 
mic::types::TensorXfPtr observation_grid
 

Detailed Description

Abstract class representing an environment.

Author
tkornuta

Definition at line 40 of file Environment.hpp.

Constructor & Destructor Documentation

mic::environments::Environment::Environment ( std::string  node_name_)

Constructor. Registers properties.

Parameters
node_name_Name of the node in configuration file.

Definition at line 28 of file Environment.cpp.

References height, pomdp_flag, roi_size, and width.

mic::environments::Environment::~Environment ( )
virtual

Virtual destructor. Empty.

Definition at line 43 of file Environment.cpp.

Member Function Documentation

virtual mic::types::MatrixXfPtr mic::environments::Environment::encodeEnvironment ( )
pure virtual

Encodes the current state of the environment in as a matrix of size [1, width * height * channels].

Returns
Matrix of size [1, width * height * channels].

Implemented in mic::environments::Gridworld, mic::environments::MazeOfDigits, and mic::environments::MNISTDigit.

virtual mic::types::MatrixXfPtr mic::environments::Environment::encodeObservation ( )
pure virtual

Encodes the current observation taken in the environment in as a matrix of size [1, roi_size * roi_size * channels].

Returns
Matrix of size [1, roi_size * roi_size * channels].

Implemented in mic::environments::Gridworld, mic::environments::MazeOfDigits, and mic::environments::MNISTDigit.

virtual std::string mic::environments::Environment::environmentToString ( )
pure virtual

Returns the current state of the environment in the form of a string.

Returns
String with description of the environment.

Implemented in mic::environments::Gridworld, mic::environments::MazeOfDigits, and mic::environments::MNISTDigit.

virtual mic::types::Position2D mic::environments::Environment::getAgentPosition ( )
pure virtual

Calculates the agent position.

Returns
Agent position.

Implemented in mic::environments::Gridworld, mic::environments::MazeOfDigits, and mic::environments::MNISTDigit.

Referenced by isActionAllowed(), and moveAgent().

virtual size_t mic::environments::Environment::getChannels ( )
inlinevirtual

Returns number of channels (depth) of the environment.

Returns
Height.

Definition at line 105 of file Environment.hpp.

References channels.

mic::types::TensorXfPtr& mic::environments::Environment::getEnvironment ( )
inline

Returns the tensor storing the environment.

Returns
Tensor storing the environment.

Definition at line 63 of file Environment.hpp.

References environment_grid.

Referenced by mic::application::MazeOfDigitsDLRERPOMPD::initializePropertyDependentVariables(), and mic::application::MNISTDigitDLRERPOMDP::initializePropertyDependentVariables().

virtual size_t mic::environments::Environment::getEnvironmentSize ( )
inlinevirtual
size_t mic::environments::Environment::getROISize ( )
inline

Returns size of the region of interest.

Returns
ROI size.

Definition at line 111 of file Environment.hpp.

References roi_size.

virtual float mic::environments::Environment::getStateReward ( mic::types::Position2D  pos_)
pure virtual

Returns the reward associated with the given state.

Parameters
pos_Position (state).
Returns
Reward for being in given state (r).

Implemented in mic::environments::Gridworld, mic::environments::MazeOfDigits, and mic::environments::MNISTDigit.

virtual void mic::environments::Environment::initializeEnvironment ( )
pure virtual

(Re)initializes the environment - gets given MNIST digit (sample number), sets agent, goal etc.

Implemented in mic::environments::MazeOfDigits, mic::environments::Gridworld, and mic::environments::MNISTDigit.

bool mic::environments::Environment::isActionAllowed ( long  x_,
long  y_,
size_t  action_ 
)
virtual

Checks whether performing given action starting in given state is allowed.

Parameters
x_X state coordinate
y_Y state coordinate
action_Action to be performed starting from given state.
Returns
True if action is allowed, false otherwise.

Definition at line 70 of file Environment.cpp.

References isStateAllowed().

Referenced by mic::application::GridworldValueIteration::computeBestValue(), mic::application::GridworldQLearning::computeBestValue(), mic::application::GridworldDeepQLearning::computeBestValueForCurrentState(), mic::application::GridworldDRLExperienceReplay::computeBestValueForGivenStateAndPredictions(), mic::application::GridworldDRLExperienceReplayPOMDP::computeBestValueForGivenStateAndPredictions(), mic::application::MazeOfDigitsDLRERPOMPD::computeBestValueForGivenStateAndPredictions(), mic::application::MNISTDigitDLRERPOMDP::computeBestValueForGivenStateAndPredictions(), mic::application::GridworldValueIteration::computeQValueFromValues(), mic::application::GridworldQLearning::selectBestAction(), mic::application::GridworldDeepQLearning::selectBestActionForCurrentState(), mic::application::GridworldDRLExperienceReplay::selectBestActionForGivenState(), mic::application::GridworldDRLExperienceReplayPOMDP::selectBestActionForGivenState(), mic::application::MazeOfDigitsDLRERPOMPD::selectBestActionForGivenState(), mic::application::MNISTDigitDLRERPOMDP::selectBestActionForGivenState(), mic::application::GridworldDeepQLearning::streamNetworkResponseTable(), mic::application::GridworldDRLExperienceReplay::streamNetworkResponseTable(), mic::application::GridworldDRLExperienceReplayPOMDP::streamNetworkResponseTable(), mic::application::MazeOfDigitsDLRERPOMPD::streamNetworkResponseTable(), mic::application::MNISTDigitDLRERPOMDP::streamNetworkResponseTable(), and mic::application::GridworldQLearning::streamQStateTable().

bool mic::environments::Environment::isActionAllowed ( mic::types::Position2D  pos_,
mic::types::Action2DInterface  ac_ 
)
virtual

Checks whether performing given action starting in given state is allowed.

Parameters
pos_Starting state (position).
ac_Action to be performed.
Returns
True if action is allowed, false otherwise.

Definition at line 79 of file Environment.cpp.

References isStateAllowed().

bool mic::environments::Environment::isActionAllowed ( mic::types::Action2DInterface  ac_)
virtual

Checks whether performing given action from the current agent state is allowed.

Parameters
ac_Action to be performed.
Returns
True if action is allowed, false otherwise.

Definition at line 85 of file Environment.cpp.

References getAgentPosition(), and isStateAllowed().

bool mic::environments::Environment::isStateAllowed ( long  x_,
long  y_ 
)
virtual

Checks if position is allowed, i.e. within the gridworld boundaries and there is no wall at that place.

Parameters
x_X state coordinate
y_Y state coordinate
Returns
True if the position is allowed, false otherwise.

Definition at line 62 of file Environment.cpp.

Referenced by isActionAllowed().

virtual bool mic::environments::Environment::isStateAllowed ( mic::types::Position2D  pos_)
pure virtual

Checks if position is allowed, i.e. within the gridworld boundaries and there is no wall at that place.

Parameters
pos_Position to be checked.
Returns
True if the position is allowed, false otherwise.

Implemented in mic::environments::Gridworld, mic::environments::MazeOfDigits, and mic::environments::MNISTDigit.

bool mic::environments::Environment::isStateTerminal ( long  x_,
long  y_ 
)
virtual

Checks if position is terminal, i.e. agent is standing in a pit or reached the goal. Returns reward associated with given state.

Parameters
x_X state coordinate
y_Y state coordinate
Returns
The reward associated with "final" action (might be positive or negative), equal to zero means that the position is not final.

Definition at line 66 of file Environment.cpp.

virtual bool mic::environments::Environment::isStateTerminal ( mic::types::Position2D  pos_)
pure virtual

Checks if position is terminal, i.e. agent is standing in a pit or reached the goal. Returns reward associated with given state.

Parameters
pos_Position (state) to be checked.
Returns
The reward associated with "final" action (might be positive or negative), equal to zero means that the position is not final.

Implemented in mic::environments::Gridworld, mic::environments::MazeOfDigits, and mic::environments::MNISTDigit.

bool mic::environments::Environment::moveAgent ( mic::types::Action2DInterface  ac_)
void mic::environments::Environment::moveAgentToInitialPosition ( )
virtual

Moves the agent to the initial position.

Parameters
pos_Position to be checked.
pos_The position to be set.

Definition at line 57 of file Environment.cpp.

References initial_position, and moveAgentToPosition().

Referenced by mic::environments::MNISTDigit::initializeEnvironment().

virtual bool mic::environments::Environment::moveAgentToPosition ( mic::types::Position2D  pos_)
pure virtual

Moves the agent to given position.

Parameters
pos_Desired position of the agent.
Returns
True if position is valid and was reached, false otherwise.

Implemented in mic::environments::Gridworld, mic::environments::MazeOfDigits, and mic::environments::MNISTDigit.

Referenced by moveAgent(), and moveAgentToInitialPosition().

virtual std::string mic::environments::Environment::observationToString ( )
pure virtual

Returns the current observation taken in the environment in the form of a string.

Returns
String with description of the observation.

Implemented in mic::environments::Gridworld, mic::environments::MazeOfDigits, and mic::environments::MNISTDigit.

Member Data Documentation

size_t mic::environments::Environment::channels
protected

Number of channels.

Definition at line 244 of file Environment.hpp.

Referenced by mic::environments::MNISTDigit::encodeEnvironment(), mic::environments::MazeOfDigits::encodeEnvironment(), mic::environments::Gridworld::encodeEnvironment(), mic::environments::MNISTDigit::encodeObservation(), mic::environments::Gridworld::encodeObservation(), getChannels(), getEnvironmentSize(), mic::environments::MazeOfDigits::getObservationSize(), getObservationSize(), mic::environments::Gridworld::Gridworld(), mic::environments::Gridworld::initBookGrid(), mic::environments::Gridworld::initBridgeGrid(), mic::environments::Gridworld::initClassicCliffGrid(), mic::environments::Gridworld::initDebug2x2Grid(), mic::environments::Gridworld::initDebug3x3Grid(), mic::environments::Gridworld::initDiscountGrid(), mic::environments::Gridworld::initExemplaryDQLGrid(), mic::environments::Gridworld::initExemplaryGrid(), mic::environments::MazeOfDigits::initExemplaryMaze(), mic::environments::MazeOfDigits::initFullyRandomMaze(), mic::environments::Gridworld::initHardRandomGrid(), mic::environments::Gridworld::initializeEnvironment(), mic::environments::MNISTDigit::initializePropertyDependentVariables(), mic::environments::Gridworld::initMazeGrid(), mic::environments::Gridworld::initModifiedDQLGrid(), mic::environments::MazeOfDigits::initRandomPathMaze(), mic::environments::MazeOfDigits::initRandomStructuredMaze(), mic::environments::Gridworld::initSimpleRandomGrid(), mic::environments::MazeOfDigits::MazeOfDigits(), mic::environments::MNISTDigit::MNISTDigit(), mic::environments::MazeOfDigits::operator=(), mic::environments::MNISTDigit::operator=(), and mic::environments::Gridworld::operator=().

mic::types::TensorXfPtr mic::environments::Environment::environment_grid
protected

Tensor storing the environment.

Definition at line 253 of file Environment.hpp.

Referenced by mic::environments::MazeOfDigits::encodeAgentGrid(), mic::environments::Gridworld::encodeAgentGrid(), mic::environments::MNISTDigit::encodeEnvironment(), mic::environments::MazeOfDigits::encodeEnvironment(), mic::environments::Gridworld::encodeEnvironment(), mic::environments::MNISTDigit::environmentToString(), mic::environments::MazeOfDigits::environmentToString(), mic::environments::Gridworld::environmentToString(), mic::environments::MNISTDigit::getAgentPosition(), mic::environments::MazeOfDigits::getAgentPosition(), mic::environments::Gridworld::getAgentPosition(), getEnvironment(), mic::environments::MNISTDigit::getStateReward(), mic::environments::MazeOfDigits::getStateReward(), mic::environments::Gridworld::getStateReward(), mic::environments::Gridworld::Gridworld(), mic::environments::Gridworld::initBookGrid(), mic::environments::Gridworld::initBridgeGrid(), mic::environments::Gridworld::initClassicCliffGrid(), mic::environments::Gridworld::initDebug2x2Grid(), mic::environments::Gridworld::initDebug3x3Grid(), mic::environments::Gridworld::initDiscountGrid(), mic::environments::Gridworld::initExemplaryDQLGrid(), mic::environments::Gridworld::initExemplaryGrid(), mic::environments::MazeOfDigits::initExemplaryMaze(), mic::environments::MazeOfDigits::initFullyRandomMaze(), mic::environments::Gridworld::initHardRandomGrid(), mic::environments::MNISTDigit::initializeEnvironment(), mic::environments::MNISTDigit::initializePropertyDependentVariables(), mic::environments::Gridworld::initMazeGrid(), mic::environments::Gridworld::initModifiedDQLGrid(), mic::environments::MazeOfDigits::initRandomPathMaze(), mic::environments::MazeOfDigits::initRandomStructuredMaze(), mic::environments::Gridworld::initSimpleRandomGrid(), mic::environments::Gridworld::isGridTraversible(), mic::environments::MazeOfDigits::isStateAllowed(), mic::environments::Gridworld::isStateAllowed(), mic::environments::MNISTDigit::isStateTerminal(), mic::environments::MazeOfDigits::isStateTerminal(), mic::environments::Gridworld::isStateTerminal(), mic::environments::MazeOfDigits::MazeOfDigits(), mic::environments::MNISTDigit::observationToString(), mic::environments::MazeOfDigits::observationToString(), mic::environments::Gridworld::observationToString(), mic::environments::MNISTDigit::operator=(), mic::environments::MazeOfDigits::operator=(), mic::environments::Gridworld::operator=(), mic::environments::MazeOfDigits::reRandomAgentPosition(), and mic::environments::MazeOfDigits::setBiggerDigit().

mic::configuration::Property<size_t> mic::environments::Environment::height
protected

Property: height of the environment.

Definition at line 238 of file Environment.hpp.

Referenced by mic::environments::MazeOfDigits::encodeAgentGrid(), mic::environments::Gridworld::encodeAgentGrid(), mic::environments::MNISTDigit::encodeEnvironment(), mic::environments::MazeOfDigits::encodeEnvironment(), mic::environments::Gridworld::encodeEnvironment(), Environment(), mic::environments::MNISTDigit::getAgentPosition(), mic::environments::MazeOfDigits::getAgentPosition(), mic::environments::Gridworld::getAgentPosition(), getEnvironmentHeight(), getEnvironmentSize(), getObservationHeight(), mic::environments::MazeOfDigits::getObservationSize(), getObservationSize(), mic::environments::Gridworld::Gridworld(), mic::environments::Gridworld::initBookGrid(), mic::environments::Gridworld::initBridgeGrid(), mic::environments::Gridworld::initClassicCliffGrid(), mic::environments::Gridworld::initDebug2x2Grid(), mic::environments::Gridworld::initDebug3x3Grid(), mic::environments::Gridworld::initDiscountGrid(), mic::environments::Gridworld::initExemplaryDQLGrid(), mic::environments::Gridworld::initExemplaryGrid(), mic::environments::MazeOfDigits::initExemplaryMaze(), mic::environments::MazeOfDigits::initFullyRandomMaze(), mic::environments::Gridworld::initHardRandomGrid(), mic::environments::MNISTDigit::initializeEnvironment(), mic::environments::Gridworld::initializeEnvironment(), mic::environments::MazeOfDigits::initializeEnvironment(), mic::environments::MNISTDigit::initializePropertyDependentVariables(), mic::environments::Gridworld::initMazeGrid(), mic::environments::Gridworld::initModifiedDQLGrid(), mic::environments::MazeOfDigits::initRandomPathMaze(), mic::environments::MazeOfDigits::initRandomStructuredMaze(), mic::environments::Gridworld::initSimpleRandomGrid(), mic::environments::MazeOfDigits::MazeOfDigits(), mic::environments::MNISTDigit::operator=(), mic::environments::MazeOfDigits::operator=(), mic::environments::Gridworld::operator=(), and mic::environments::MazeOfDigits::reRandomAgentPosition().

mic::configuration::Property<size_t> mic::environments::Environment::width
protected

Property: width of the environment.

Definition at line 235 of file Environment.hpp.

Referenced by mic::environments::MazeOfDigits::encodeAgentGrid(), mic::environments::Gridworld::encodeAgentGrid(), mic::environments::MNISTDigit::encodeEnvironment(), mic::environments::MazeOfDigits::encodeEnvironment(), mic::environments::Gridworld::encodeEnvironment(), Environment(), mic::environments::MNISTDigit::getAgentPosition(), mic::environments::MazeOfDigits::getAgentPosition(), mic::environments::Gridworld::getAgentPosition(), getEnvironmentSize(), getEnvironmentWidth(), mic::environments::MazeOfDigits::getObservationSize(), getObservationSize(), getObservationWidth(), mic::environments::Gridworld::Gridworld(), mic::environments::Gridworld::initBookGrid(), mic::environments::Gridworld::initBridgeGrid(), mic::environments::Gridworld::initClassicCliffGrid(), mic::environments::Gridworld::initDebug2x2Grid(), mic::environments::Gridworld::initDebug3x3Grid(), mic::environments::Gridworld::initDiscountGrid(), mic::environments::Gridworld::initExemplaryDQLGrid(), mic::environments::Gridworld::initExemplaryGrid(), mic::environments::MazeOfDigits::initExemplaryMaze(), mic::environments::MazeOfDigits::initFullyRandomMaze(), mic::environments::Gridworld::initHardRandomGrid(), mic::environments::MNISTDigit::initializeEnvironment(), mic::environments::Gridworld::initializeEnvironment(), mic::environments::MazeOfDigits::initializeEnvironment(), mic::environments::MNISTDigit::initializePropertyDependentVariables(), mic::environments::Gridworld::initMazeGrid(), mic::environments::Gridworld::initModifiedDQLGrid(), mic::environments::MazeOfDigits::initRandomPathMaze(), mic::environments::MazeOfDigits::initRandomStructuredMaze(), mic::environments::Gridworld::initSimpleRandomGrid(), mic::environments::MazeOfDigits::MazeOfDigits(), mic::environments::MNISTDigit::operator=(), mic::environments::MazeOfDigits::operator=(), mic::environments::Gridworld::operator=(), and mic::environments::MazeOfDigits::reRandomAgentPosition().


The documentation for this class was generated from the following files: