diff --git a/src/mlpack/methods/reinforcement_learning/environment/CMakeLists.txt b/src/mlpack/methods/reinforcement_learning/environment/CMakeLists.txt index be5d1f3486..77d822aced 100644 --- a/src/mlpack/methods/reinforcement_learning/environment/CMakeLists.txt +++ b/src/mlpack/methods/reinforcement_learning/environment/CMakeLists.txt @@ -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 diff --git a/src/mlpack/methods/reinforcement_learning/environment/env_type.cpp b/src/mlpack/methods/reinforcement_learning/environment/env_type.cpp deleted file mode 100644 index 98f0799199..0000000000 --- a/src/mlpack/methods/reinforcement_learning/environment/env_type.cpp +++ /dev/null @@ -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 diff --git a/src/mlpack/methods/reinforcement_learning/environment/env_type.hpp b/src/mlpack/methods/reinforcement_learning/environment/env_type.hpp index 46a4c746bf..98bd8963b9 100644 --- a/src/mlpack/methods/reinforcement_learning/environment/env_type.hpp +++ b/src/mlpack/methods/reinforcement_learning/environment/env_type.hpp @@ -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