24 #include <utils/RandomGenerator.hpp>
27 namespace environments {
30 mnist_importer(
"mnist_importer"),
31 sample_number(
"sample_number", 0),
32 agent_x(
"agent_x",-1),
33 agent_y(
"agent_y",-1),
90 mic::types::MNISTSample<> sample;
100 for (
size_t x=0; x<
width; x++)
101 for (
size_t y=0; y<
height; y++)
103 LOG(LINFO) <<
"Digit: " << (*sample.label());
117 gx = (
goal_x < 0) ? RAN_GEN->uniRandInt(0,width) :
goal_x;
118 gy = (
goal_y < 0) ? RAN_GEN->uniRandInt(0,height) :
goal_y;
129 for (
size_t x=0; x<env_->dim(0); x++)
133 for (
size_t y=0; y<env_->dim(1); y++){
135 for (
size_t x=0; x<env_->dim(0); x++) {
154 for (
size_t x=0; x<env_->dim(0); x++)
178 mic::types::MatrixXfPtr encoded_grid (
new mic::types::MatrixXf(*
environment_grid));
187 LOG(LDEBUG) <<
"encodeObservation()";
197 mic::types::MatrixXfPtr encoded_obs (
new mic::types::MatrixXf(*obs));
209 LOG(LDEBUG) <<
"getObservation()";
217 for (
long oy=0, ey=(p.y-delta); oy<(
long)
roi_size; oy++, ey++){
218 for (
long ox=0, ex=(p.x-delta); ox<(
long)
roi_size; ox++, ex++) {
220 if ((ex < 0) || ((
size_t)ex >= width) || (ey < 0) || ((
size_t)ey >= height)){
239 mic::types::Position2D position;
240 for (
size_t y=0; y<
height; y++){
241 for (
size_t x=0; x<
width; x++) {
254 LOG(LDEBUG) <<
"New agent position = " << pos_;
281 if ((pos_.x < 0) || ((
size_t)pos_.x >= width))
284 if ((pos_.y < 0) || ((
size_t)pos_.y >= height))
292 if ((pos_.x < 0) || ((
size_t)pos_.x >= width))
295 if ((pos_.y < 0) || ((
size_t)pos_.y >= height))
mic::types::TensorXfPtr getObservation()
virtual bool moveAgentToPosition(mic::types::Position2D pos_)
virtual bool isStateTerminal(mic::types::Position2D pos_)
virtual std::string observationToString()
unsigned int optimal_path_length
Channel storing image intensities (this is a grayscale image)
Abstract class representing an environment.
std::string toString(mic::types::TensorXfPtr env_)
virtual void initializeEnvironment()
size_t channels
Number of channels.
virtual mic::types::MatrixXfPtr encodeObservation()
virtual void initializePropertyDependentVariables()
mic::configuration::Property< size_t > sample_number
virtual void moveAgentToInitialPosition()
mic::configuration::Property< size_t > width
Property: width of the environment.
MNISTDigit(std::string node_name_="mnist_digit")
Class emulating the MNISTDigit digit environment.
bool pomdp_flag
Flag related to.
Channel storing the agent position.
mic::configuration::Property< short > agent_x
virtual mic::types::Position2D getAgentPosition()
virtual std::string environmentToString()
virtual mic::types::MatrixXfPtr encodeEnvironment()
mic::configuration::Property< size_t > roi_size
Property: size of the ROI (region of interest).
virtual float getStateReward(mic::types::Position2D pos_)
mic::configuration::Property< short > goal_y
mic::environments::MNISTDigit & operator=(const mic::environments::MNISTDigit &md_)
mic::types::TensorXfPtr observation_grid
virtual bool isStateAllowed(mic::types::Position2D pos_)
mic::importers::MNISTMatrixImporter< float > mnist_importer
Importer responsible for loading MNIST dataset.
mic::types::TensorXfPtr environment_grid
Tensor storing the environment.
mic::configuration::Property< short > goal_x
mic::configuration::Property< short > agent_y
mic::types::Position2D initial_position
Property: initial position of the agent.
mic::configuration::Property< size_t > height
Property: height of the environment.