PetaVision  Alpha
AdaptiveTimeScaleProbe.hpp
1 /*
2  * AdaptiveTimeScaleProbe.hpp
3  *
4  * Created on: Aug 18, 2016
5  * Author: pschultz
6  */
7 
8 #ifndef ADAPTIVETIMESCALEPROBE_HPP_
9 #define ADAPTIVETIMESCALEPROBE_HPP_
10 
11 #include "BaseProbe.hpp"
12 #include "ColProbe.hpp"
13 #include "components/AdaptiveTimeScaleController.hpp"
14 #include "layers/HyPerLayer.hpp"
15 
16 namespace PV {
17 
18 // AdaptiveTimeScaleProbe to be a subclass of ColProbe since it doesn't belong
19 // to a layer or connection, and the HyPerCol has to know of its existence to
20 // call various methods. It doesn't use any ColProbe-specific behavior other
21 // than ColProbe inserting the probe into the HyPerCol's list of ColProbes.
22 // Once the observer pattern is more fully implemented, it could probably
23 // derive straight from BaseProbe.
25  protected:
37  virtual void ioParam_targetName(enum ParamsIOFlag ioFlag) override;
38 
44  virtual void ioParam_baseMax(enum ParamsIOFlag ioFlag);
45 
49  virtual void ioParam_baseMin(enum ParamsIOFlag ioFlag);
50 
56  virtual void ioParam_tauFactor(enum ParamsIOFlag ioFlag);
57 
63  virtual void ioParam_growthFactor(enum ParamsIOFlag ioFlag);
64 
65  // writeTimeScales was marked obsolete Jul 27, 2017.
69  virtual void ioParam_writeTimeScales(enum ParamsIOFlag ioFlag);
70 
76  virtual void ioParam_writeTimeScaleFieldnames(enum ParamsIOFlag ioFlag);
79  public:
80  AdaptiveTimeScaleProbe(char const *name, HyPerCol *hc);
81  virtual ~AdaptiveTimeScaleProbe();
82  virtual Response::Status respond(std::shared_ptr<BaseMessage const> message) override;
83  virtual Response::Status
84  communicateInitInfo(std::shared_ptr<CommunicateInitInfoMessage const> message) override;
85  virtual Response::Status allocateDataStructures() override;
86  virtual Response::Status outputState(double timeValue) override;
87 
88  protected:
90  int initialize(char const *name, HyPerCol *hc);
91  int ioParamsFillGroup(enum ParamsIOFlag ioFlag) override;
92  virtual Response::Status registerData(Checkpointer *checkpointer) override;
93  Response::Status respondAdaptTimestep(std::shared_ptr<AdaptTimestepMessage const> message);
94  bool needRecalc(double timeValue) override {
95  return parent->simulationTime() > getLastUpdateTime();
96  }
97  double referenceUpdateTime() const override { return parent->simulationTime(); }
98  virtual void calcValues(double timeValue) override;
99  virtual bool needUpdate(double timeValue, double dt) override { return true; }
100  virtual void allocateTimeScaleController();
101 
102  protected:
103  double mBaseMax = 1.0;
104  double mBaseMin = 1.0;
105  double tauFactor = 1.0;
106  double mGrowthFactor = 1.0;
107  bool mWriteTimeScaleFieldnames = true;
108 
109  BaseProbe *mTargetProbe = nullptr;
110  AdaptiveTimeScaleController *mAdaptiveTimeScaleController = nullptr;
111 };
112 
113 } /* namespace PV */
114 
115 #endif /* ADAPTIVETIMESCALEPROBE_HPP_ */
int ioParamsFillGroup(enum ParamsIOFlag ioFlag) override
double referenceUpdateTime() const override
virtual void ioParam_baseMin(enum ParamsIOFlag ioFlag)
baseMin: Specifies the minimum timescale allowed.
double getLastUpdateTime()
Definition: BaseProbe.hpp:102
virtual void ioParam_tauFactor(enum ParamsIOFlag ioFlag)
tauFactor: If Specifies the coefficient on the effective decay rate used to compute the timescale...
virtual bool needUpdate(double timeValue, double dt) override
virtual void calcValues(double timeValue) override
virtual void ioParam_baseMax(enum ParamsIOFlag ioFlag)
baseMax: Specifies the initial maximum timescale allowed. The maximum timescale is allowed to increas...
bool needRecalc(double timeValue) override
virtual void ioParam_targetName(enum ParamsIOFlag ioFlag) override
targetName: the name of the probe that this probe attaches to. The target probe&#39;s values are used as ...
virtual void ioParam_growthFactor(enum ParamsIOFlag ioFlag)
dtChangeMin: Specifies the percentage by which the maximum timescale increases when the timescale rea...
virtual void ioParam_writeTimeScaleFieldnames(enum ParamsIOFlag ioFlag)
writeTimeScaleFieldnames: A flag to determine if fieldnames are written to the HyPerCol_timescales fi...
virtual Response::Status communicateInitInfo(std::shared_ptr< CommunicateInitInfoMessage const > message) override
virtual Response::Status registerData(Checkpointer *checkpointer) override
virtual Response::Status outputState(double timeValue) override
virtual void ioParam_writeTimeScales(enum ParamsIOFlag ioFlag)
writeTimeScales is obsolete, as it is redundant with textOutputFlag.