trying to initialize env_type var in same header

This commit is contained in:
shubham1206agra
2022-05-09 21:00:51 +05:30
parent 61550e0678
commit e19c00a008
3 changed files with 13 additions and 30 deletions
@@ -2,7 +2,6 @@
# Anything not in this list will not be compiled into mlpack.
set(SOURCES
env_type.hpp
env_type.cpp
mountain_car.hpp
cart_pole.hpp
continuous_mountain_car.hpp
@@ -1,29 +0,0 @@
/**
* @file methods/reinforcement_learning/environment/env_type.cpp
* @author Nishant Kumar
*
* This file defines the static variables used by the discrete and continuous
* environments.
*
* mlpack is free software; you may redistribute it and/or modify it under the
* terms of the 3-clause BSD license. You should have received a copy of the
* 3-clause BSD license along with mlpack. If not, see
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
*/
#include "env_type.hpp"
namespace mlpack {
namespace rl {
// Instantiate static members.
size_t DiscreteActionEnv::State::dimension = 0;
size_t DiscreteActionEnv::Action::size = 0;
size_t DiscreteActionEnv::rewardSize = 0;
size_t ContinuousActionEnv::State::dimension = 0;
size_t ContinuousActionEnv::Action::size = 0;
size_t ContinuousActionEnv::rewardSize = 0;
} // namespace rl
} // namespace mlpack
@@ -206,6 +206,19 @@ class ContinuousActionEnv
static size_t rewardSize;
};
#ifndef MLPACK_METHODS_RL_ENVIRONMENT_ENV_TYPE_VARIABLES
#define MLPACK_METHODS_RL_ENVIRONMENT_ENV_TYPE_VARIABLES
size_t DiscreteActionEnv::State::dimension = 0;
size_t DiscreteActionEnv::Action::size = 0;
size_t DiscreteActionEnv::rewardSize = 0;
size_t ContinuousActionEnv::State::dimension = 0;
size_t ContinuousActionEnv::Action::size = 0;
size_t ContinuousActionEnv::rewardSize = 0;
#endif
} // namespace rl
} // namespace mlpack