PetaVision  Alpha
FirmThresholdCostFnLCAProbe.cpp
1 /*
2  * FirmThresholdCostFnLCAProbe.cpp
3  *
4  * Created on: Oct 9, 2015
5  * Author: pschultz
6  */
7 
8 #include "FirmThresholdCostFnLCAProbe.hpp"
9 #include "../layers/HyPerLCALayer.hpp"
10 
11 namespace PV {
12 
13 FirmThresholdCostFnLCAProbe::FirmThresholdCostFnLCAProbe(const char *name, HyPerCol *hc) {
14  initialize_base();
15  initialize(name, hc);
16 }
17 
18 FirmThresholdCostFnLCAProbe::FirmThresholdCostFnLCAProbe() { initialize_base(); }
19 
21  std::shared_ptr<CommunicateInitInfoMessage const> message) {
22  auto status = FirmThresholdCostFnProbe::communicateInitInfo(message);
23  if (!Response::completed(status)) {
24  return status;
25  }
26  assert(targetLayer);
27  bool failed = false;
28  HyPerLCALayer *targetLCALayer = dynamic_cast<HyPerLCALayer *>(targetLayer);
29  if (targetLCALayer == nullptr) {
30  if (parent->columnId() == 0) {
31  ErrorLog().printf(
32  "%s: targetLayer \"%s\" is not an LCA layer.\n",
33  getDescription_c(),
34  getTargetName());
35  }
36  failed = true;
37  }
38  if (targetLCALayer->layerListsVerticesInParams() == true) {
39  if (parent->columnId() == 0) {
40  ErrorLog().printf(
41  "%s: LCAProbes require targetLayer \"%s\" to use "
42  "VThresh etc. instead of "
43  "verticesV/verticesV.\n",
44  getDescription_c(),
45  getTargetName());
46  }
47  failed = true;
48  }
49  if (failed) {
50  MPI_Barrier(parent->getCommunicator()->communicator());
51  exit(EXIT_FAILURE);
52  }
53  coefficient = targetLCALayer->getVThresh();
54  return Response::SUCCESS;
55 }
56 
57 } /* namespace PV */
bool layerListsVerticesInParams() const
Definition: ANNLayer.hpp:30
const char * getTargetName()
Definition: BaseProbe.hpp:83
static bool completed(Status &a)
Definition: Response.hpp:49
virtual Response::Status communicateInitInfo(std::shared_ptr< CommunicateInitInfoMessage const > message) override
virtual Response::Status communicateInitInfo(std::shared_ptr< CommunicateInitInfoMessage const > message) override