- 3.0.2 core module.
SingleActivation.hpp
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "../activations/ActivationBase.hpp"
6 
7 namespace ct {
8 namespace core {
9 namespace tpl {
10 
11 template <typename SCALAR, typename TRAIT = typename ct::core::tpl::TraitSelector<SCALAR>::Trait>
12 class SingleActivation : public ActivationBase<SCALAR>
13 {
14 public:
16  SingleActivation(const SCALAR t_on, const SCALAR t_off) : t_on_(t_on), t_off_(t_off) {}
17  virtual ~SingleActivation() {}
18  SingleActivation(const SingleActivation& arg) : t_on_(arg.t_on_), t_off_(arg.t_off_) {}
19  virtual void loadConfigFile(const std::string& filename, const std::string& termName, bool verbose = false) override
20  {
21  boost::property_tree::ptree pt;
22  boost::property_tree::read_info(filename, pt);
23  t_on_ = pt.get<SCALAR>(termName + ".t_on");
24  t_off_ = pt.get<SCALAR>(termName + ".t_off");
25  }
26 
28  virtual bool isActive(const SCALAR t) override { return (t >= t_on_ && t < t_off_); }
30  virtual SCALAR computeActivation(const SCALAR t) override { return SCALAR(1.0); }
31  virtual void printInfo() override
32  {
33  std::cout << "Cost Function active between values: " << t_on_ << "s and: " << t_off_ << "s" << std::endl;
34  }
35 
36 private:
38  SCALAR t_on_;
40  SCALAR t_off_;
41 };
42 
43 } // namespace tpl
44 
46 } // namespace core
47 } // namespace ct
SingleActivation()
Definition: SingleActivation.hpp:15
SingleActivation(const SingleActivation &arg)
Definition: SingleActivation.hpp:18
virtual void loadConfigFile(const std::string &filename, const std::string &termName, bool verbose=false) override
load activations from file
Definition: SingleActivation.hpp:19
CppAD::AD< CppAD::cg::CG< double > > SCALAR
Definition: ActivationBase.hpp:18
const bool verbose
Definition: JacobianCGTest.h:19
virtual bool isActive(const SCALAR t) override
this activation is active in a strict time window
Definition: SingleActivation.hpp:28
virtual void printInfo() override
print to console
Definition: SingleActivation.hpp:31
virtual SCALAR computeActivation(const SCALAR t) override
within this time-window, the activation is saturated
Definition: SingleActivation.hpp:30
virtual ~SingleActivation()
Definition: SingleActivation.hpp:17
SingleActivation(const SCALAR t_on, const SCALAR t_off)
Definition: SingleActivation.hpp:16
Definition: SingleActivation.hpp:12