MachineIntelligenceCore:ReinforcementLearning
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator
mic::environments::MNISTDigit Class Reference

Class emulating the MNISTDigit digit environment. More...

#include <MNISTDigit.hpp>

Inheritance diagram for mic::environments::MNISTDigit:
Collaboration diagram for mic::environments::MNISTDigit:

Public Member Functions

 MNISTDigit (std::string node_name_="mnist_digit")
 
 MNISTDigit (const mic::environments::MNISTDigit &md_)
 
virtual ~MNISTDigit ()
 
mic::environments::MNISTDigitoperator= (const mic::environments::MNISTDigit &md_)
 
virtual void initializePropertyDependentVariables ()
 
virtual void initializeEnvironment ()
 
mic::types::TensorXfPtr getObservation ()
 
virtual std::string environmentToString ()
 
virtual std::string observationToString ()
 
virtual mic::types::MatrixXfPtr encodeEnvironment ()
 
virtual mic::types::MatrixXfPtr encodeObservation ()
 
virtual mic::types::Position2D getAgentPosition ()
 
virtual bool moveAgentToPosition (mic::types::Position2D pos_)
 
virtual float getStateReward (mic::types::Position2D pos_)
 
virtual bool isStateAllowed (mic::types::Position2D pos_)
 
virtual bool isStateTerminal (mic::types::Position2D pos_)
 
unsigned int optimalPathLength ()
 
- Public Member Functions inherited from mic::environments::Environment
 Environment (std::string node_name_)
 
virtual ~Environment ()
 
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 ()
 
bool moveAgent (mic::types::Action2DInterface ac_)
 
virtual void moveAgentToInitialPosition ()
 
virtual bool isStateAllowed (long x_, long y_)
 
virtual bool isStateTerminal (long x_, long y_)
 
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 Member Functions

std::string toString (mic::types::TensorXfPtr env_)
 

Protected Attributes

mic::importers::MNISTMatrixImporter
< float > 
mnist_importer
 Importer responsible for loading MNIST dataset. More...
 
mic::configuration::Property
< size_t > 
sample_number
 
mic::configuration::Property
< short > 
agent_x
 
mic::configuration::Property
< short > 
agent_y
 
mic::configuration::Property
< short > 
goal_x
 
mic::configuration::Property
< short > 
goal_y
 
unsigned int optimal_path_length
 
- Protected Attributes inherited from mic::environments::Environment
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

Class emulating the MNISTDigit digit environment.

Author
tkornuta

Definition at line 50 of file MNISTDigit.hpp.

Constructor & Destructor Documentation

mic::environments::MNISTDigit::MNISTDigit ( std::string  node_name_ = "mnist_digit")

Constructor. Registers properties.

Parameters
node_name_Name of the node in configuration file.

Definition at line 29 of file MNISTDigit.cpp.

References agent_x, agent_y, mic::environments::Environment::channels, mic::environments::Count, goal_x, goal_y, and sample_number.

mic::environments::MNISTDigit::MNISTDigit ( const mic::environments::MNISTDigit md_)

Copying constructor.

Parameters
md_MNIST digit to be cloned.
mic::environments::MNISTDigit::~MNISTDigit ( )
virtual

Destructor. Empty for now.

Definition at line 48 of file MNISTDigit.cpp.

Member Function Documentation

mic::types::MatrixXfPtr mic::environments::MNISTDigit::encodeEnvironment ( )
virtual

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

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

Implements mic::environments::Environment.

Definition at line 174 of file MNISTDigit.cpp.

References mic::environments::Environment::channels, mic::environments::Environment::environment_grid, mic::environments::Environment::height, and mic::environments::Environment::width.

Referenced by encodeObservation().

mic::types::MatrixXfPtr mic::environments::MNISTDigit::encodeObservation ( )
virtual
std::string mic::environments::MNISTDigit::environmentToString ( )
virtual

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

Returns
String with description of the MNISTDigit.

Implements mic::environments::Environment.

Definition at line 160 of file MNISTDigit.cpp.

References mic::environments::Environment::environment_grid, and toString().

Referenced by mic::application::MNISTDigitDLRERPOMDP::performSingleStep().

float mic::environments::MNISTDigit::getStateReward ( mic::types::Position2D  pos_)
virtual

Returns the reward associated with the given state.

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

Implements mic::environments::Environment.

Definition at line 271 of file MNISTDigit.cpp.

References mic::environments::Environment::environment_grid, and mic::environments::Goals.

Referenced by mic::application::MNISTDigitDLRERPOMDP::performSingleStep().

bool mic::environments::MNISTDigit::isStateAllowed ( mic::types::Position2D  pos_)
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.

Implements mic::environments::Environment.

Definition at line 280 of file MNISTDigit.cpp.

Referenced by moveAgentToPosition(), and mic::application::MNISTDigitDLRERPOMDP::streamNetworkResponseTable().

bool mic::environments::MNISTDigit::isStateTerminal ( mic::types::Position2D  pos_)
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.

Implements mic::environments::Environment.

Definition at line 291 of file MNISTDigit.cpp.

References mic::environments::Environment::environment_grid, and mic::environments::Goals.

Referenced by mic::application::MNISTDigitDLRERPOMDP::performSingleStep(), and mic::application::MNISTDigitDLRERPOMDP::streamNetworkResponseTable().

bool mic::environments::MNISTDigit::moveAgentToPosition ( mic::types::Position2D  pos_)
virtual

Moves the agent to the position. Type of move (deterministic vs stochastic) depends on the environment (the same goes to e.g. circular world assumption).

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

Implements mic::environments::Environment.

Definition at line 253 of file MNISTDigit.cpp.

References mic::environments::Agent, getAgentPosition(), and isStateAllowed().

Referenced by mic::application::MNISTDigitDLRERPOMDP::getPredictedRewardsForGivenState(), mic::application::MNISTDigitDLRERPOMDP::performSingleStep(), and mic::application::MNISTDigitDLRERPOMDP::streamNetworkResponseTable().

std::string mic::environments::MNISTDigit::observationToString ( )
virtual

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

Returns
String with description of the observation.

Implements mic::environments::Environment.

Definition at line 164 of file MNISTDigit.cpp.

References mic::environments::Environment::environment_grid, getObservation(), mic::environments::Environment::pomdp_flag, and toString().

Referenced by mic::application::MNISTDigitDLRERPOMDP::performSingleStep().

unsigned int mic::environments::MNISTDigit::optimalPathLength ( )
inline

Returns the length of optimal path from agent initial position to goal.

Returns

Definition at line 159 of file MNISTDigit.hpp.

References optimal_path_length.

Referenced by mic::application::MNISTDigitDLRERPOMDP::finishCurrentEpisode().

std::string mic::environments::MNISTDigit::toString ( mic::types::TensorXfPtr  env_)
protected

Returns the current state of the environment passed as an argument in the form of a string.

Parameters
env_Environment (tensor) to be described.
Returns
String with description of the environment.

Definition at line 125 of file MNISTDigit.cpp.

References mic::environments::Agent, and mic::environments::Goals.

Referenced by environmentToString(), and observationToString().

Member Data Documentation

mic::configuration::Property<short> mic::environments::MNISTDigit::agent_x
protected

Property: initial agent x position.

Definition at line 176 of file MNISTDigit.hpp.

Referenced by initializeEnvironment(), and MNISTDigit().

mic::configuration::Property<short> mic::environments::MNISTDigit::agent_y
protected

Property: initial agent y position.

Definition at line 181 of file MNISTDigit.hpp.

Referenced by initializeEnvironment(), and MNISTDigit().

mic::configuration::Property<short> mic::environments::MNISTDigit::goal_x
protected

Property: initial goal x position.

Definition at line 186 of file MNISTDigit.hpp.

Referenced by initializeEnvironment(), and MNISTDigit().

mic::configuration::Property<short> mic::environments::MNISTDigit::goal_y
protected

Property: initial goal y position.

Definition at line 191 of file MNISTDigit.hpp.

Referenced by initializeEnvironment(), and MNISTDigit().

mic::importers::MNISTMatrixImporter<float> mic::environments::MNISTDigit::mnist_importer
protected

Importer responsible for loading MNIST dataset.

Definition at line 166 of file MNISTDigit.hpp.

Referenced by initializeEnvironment(), and initializePropertyDependentVariables().

unsigned int mic::environments::MNISTDigit::optimal_path_length
protected

Optimal number of steps from initial agent position to goal.

Definition at line 196 of file MNISTDigit.hpp.

Referenced by initializeEnvironment(), and optimalPathLength().

mic::configuration::Property<size_t> mic::environments::MNISTDigit::sample_number
protected

Property: MNISTDigit digit - number of sample.

Definition at line 171 of file MNISTDigit.hpp.

Referenced by initializeEnvironment(), and MNISTDigit().


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