PetaVision  Alpha
RequireAllZeroActivityProbe.hpp
1 /*
2  * RequireAllZeroActivityProbe.hpp
3  *
4  * Created on: Mar 26, 2014
5  * Author: pschultz
6  *
7  * This probe checks whether the target layer has a nonzero activity.
8  * It is designed to be used with GenericSystemTest-type system tests.
9  *
10  * It records whether a nonzero activity is ever found, but it does not
11  * immediately exit with an error at that point. Instead,
12  * the public method getNonzeroFound() returns the value. This method
13  * can then be checked after HyPerCol::run() returns and before the HyPerCol
14  * is deleted, e.g. in buildandrun's customexit hook.
15  */
16 
17 #ifndef REQUIREALLZEROACTIVITYPROBE_HPP_
18 #define REQUIREALLZEROACTIVITYPROBE_HPP_
19 
20 #include "../columns/HyPerCol.hpp"
21 #include "StatsProbe.hpp"
22 
23 namespace PV {
24 
26  public:
27  RequireAllZeroActivityProbe(const char *name, HyPerCol *hc);
28  virtual ~RequireAllZeroActivityProbe();
29  virtual Response::Status outputState(double timed) override;
30 
31  bool getNonzeroFound() { return nonzeroFound; }
32  double getNonzeroTime() { return nonzeroTime; }
33 
34  protected:
36  int ioParamsFillGroup(enum ParamsIOFlag ioFlag) override;
37  int initialize(const char *name, HyPerCol *hc);
38  virtual void ioParam_buffer(enum ParamsIOFlag ioFlag) override;
39 
56  virtual void ioParam_exitOnFailure(enum ParamsIOFlag ioFlag);
68  virtual void ioParam_immediateExitOnFailure(enum ParamsIOFlag ioFlag); // End of list of RequireAllZeroActivityProbe parameters.
70 
71  private:
72  int initialize_base();
73 
74  void nonzeroFoundMessage(double badTime, bool isRoot, bool fatalError);
75 
76  protected:
77  bool nonzeroFound = false;
78  bool exitOnFailure = true;
79  bool immediateExitOnFailure = true;
80  double nonzeroTime = 0.0;
81 }; // end class RequireAllZeroActivityProbe
82 
83 } /* namespace PV */
84 #endif /* REQUIREALLZEROACTIVITYPROBE_HPP_ */
virtual void ioParam_immediateExitOnFailure(enum ParamsIOFlag ioFlag)
immediateExitOnFailure: determines when finding a nonzero value causes an exit with an error...
virtual Response::Status outputState(double timed) override
int ioParamsFillGroup(enum ParamsIOFlag ioFlag) override
virtual void ioParam_exitOnFailure(enum ParamsIOFlag ioFlag)
exitOnFailure: If true, will error out if a nonzero value is encountered. Default is true...