Regions¶
Region¶
- 
class nupic::Region¶
- Represents a set of one or more “identical” nodes in a Network. - Constructors - Note
- Region constructors are not available in the public API. Internally regions are created and owned by Network.
 - Inherits from nupic::Serializable< RegionProto > - Region information - 
Network *getNetwork()¶
- Get the network containing this region. - Return
- The network containing this region
 
 - 
const std::string &getName() const¶
- Get the name of the region. - Return
- The region’s name
 
 - 
const Dimensions &getDimensions() const¶
- Get the dimensions of the region. - Return
- The region’s dimensions
 
 - 
void setDimensions(Dimensions &dimensions)¶
- Assign width and height to the region. - Parameters
- dimensions: A Dimensions object that describes the width and height
 
 
 - Element interface methods - 
const std::string &getType() const¶
- Get the type of the region. - Return
- The node type as a string
 
 - 
const Spec *getSpec() const¶
- Get the spec of the region. - Return
- The spec that describes this region
 
 - 
static const Spec *getSpecFromType(const std::string &nodeType)¶
- Get the Spec of a region type without an instance. - Return
- The Spec that describes this region type
- Parameters
- nodeType: A region type as a string
 
 
 - Parameter getters and setters - 
Int32 getParameterInt32(const std::string &name) const¶
- Get the parameter as an - Int32value.- Return
- The value of the parameter
- Parameters
- name: The name of the parameter
 
 
 - 
UInt32 getParameterUInt32(const std::string &name) const¶
- Get the parameter as an - UInt32value.- Return
- The value of the parameter
- Parameters
- name: The name of the parameter
 
 
 - 
Int64 getParameterInt64(const std::string &name) const¶
- Get the parameter as an - Int64value.- Return
- The value of the parameter
- Parameters
- name: The name of the parameter
 
 
 - 
UInt64 getParameterUInt64(const std::string &name) const¶
- Get the parameter as an - UInt64value.- Return
- The value of the parameter
- Parameters
- name: The name of the parameter
 
 
 - 
Real32 getParameterReal32(const std::string &name) const¶
- Get the parameter as an - Real32value.- Return
- The value of the parameter
- Parameters
- name: The name of the parameter
 
 
 - 
Real64 getParameterReal64(const std::string &name) const¶
- Get the parameter as an - Real64value.- Return
- The value of the parameter
- Parameters
- name: The name of the parameter
 
 
 - 
Handle getParameterHandle(const std::string &name) const¶
- Get the parameter as an - Handlevalue.- Return
- The value of the parameter
- Parameters
- name: The name of the parameter
 
 
 - 
bool getParameterBool(const std::string &name) const¶
- Get a bool parameter. - Return
- The value of the parameter
- Parameters
- name: The name of the parameter
 
 
 - 
void setParameterInt32(const std::string &name, Int32 value)¶
- Set the parameter to an Int32 value. - Parameters
- name: The name of the parameter
- value: The value of the parameter
 
 
 - 
void setParameterUInt32(const std::string &name, UInt32 value)¶
- Set the parameter to an UInt32 value. - Parameters
- name: The name of the parameter
- value: The value of the parameter
 
 
 - 
void setParameterInt64(const std::string &name, Int64 value)¶
- Set the parameter to an Int64 value. - Parameters
- name: The name of the parameter
- value: The value of the parameter
 
 
 - 
void setParameterUInt64(const std::string &name, UInt64 value)¶
- Set the parameter to an UInt64 value. - Parameters
- name: The name of the parameter
- value: The value of the parameter
 
 
 - 
void setParameterReal32(const std::string &name, Real32 value)¶
- Set the parameter to a Real32 value. - Parameters
- name: The name of the parameter
- value: The value of the parameter
 
 
 - 
void setParameterReal64(const std::string &name, Real64 value)¶
- Set the parameter to a Real64 value. - Parameters
- name: The name of the parameter
- value: The value of the parameter
 
 
 - 
void setParameterHandle(const std::string &name, Handle value)¶
- Set the parameter to a Handle value. - Parameters
- name: The name of the parameter
- value: The value of the parameter
 
 
 - 
void setParameterBool(const std::string &name, bool value)¶
- Set the parameter to a bool value. - Parameters
- name: The name of the parameter
- value: The value of the parameter
 
 
 - 
void getParameterArray(const std::string &name, Array &array) const¶
- Get the parameter as an - Arrayvalue.- array is a memory buffer. If the buffer is allocated, the value is copied into the supplied buffer; otherwise array would be asked to allocate the buffer and copy into it. - Parameters
- name: The name of the parameter
- array: The value of the parameter
 
 - A typical use might be that the caller would supply an unallocated buffer on the first call and then reuse the memory buffer on subsequent calls, i.e. - { // no buffer allocated Array buffer(NTA_BasicTypeInt64); // buffer is allocated, and owned by Array object getParameterArray("foo", buffer); // uses already-allocated buffer getParameterArray("foo", buffer); } // Array destructor called -- frees the buffer - Throws an exception if the supplied array is not big enough. 
 - 
void setParameterArray(const std::string &name, const Array &array)¶
- Set the parameter to an - Arrayvalue.- Note
- array must be initialized before calling setParameterArray().
- Parameters
- name: The name of the parameter
- array: The value of the parameter
 
 
 - 
void setParameterString(const std::string &name, const std::string &s)¶
- Set the parameter to a - std::stringvalue.- Strings are handled internally as Byte Arrays, but this interface is clumsy. setParameterString() and getParameterString() internally use byte arrays but converts to/from strings. - Parameters
- name: The name of the parameter
- s: The value of the parameter
 
 - setParameterString() is implemented with one copy (from the string into the node) but getParameterString() requires a second copy so that there are temporarily three copies of the data in memory (in the node, in an internal Array object, and in the string returned to the user) 
 - 
std::string getParameterString(const std::string &name)¶
- Get the parameter as a - std::stringvalue.- Return
- The value of the parameter
- See
- setParameterString()
- Parameters
- name: The name of the parameter
 
 
 - Tells whether the parameter is shared. - Return
- Whether the parameter is shared
- Parameters
- name: The name of the parameter
 
 - Throws an exception if it’s not overridden - Note
- This method must be overridden by subclasses.
 
 - Inputs and outputs - 
void prepareInputs()¶
- Copies data into the inputs of this region, using the links that are attached to each input. 
 - 
virtual ArrayRef getInputData(const std::string &inputName) const¶
- Get the input data. - Return
- An ArrayRefthat contains the input data.
- Parameters
- inputName: The name of the target input
 
 
 - 
virtual ArrayRef getOutputData(const std::string &outputName) const¶
- Get the output data. - Return
- An ArrayRefthat contains the output data.
- Parameters
- outputName: The name of the target output
 
 
 - 
virtual size_t getInputCount(const std::string &inputName) const¶
- Get the count of input data. - Return
- The count of input data
- Parameters
- inputName: The name of the target input
 
 
 - 
virtual size_t getOutputCount(const std::string &outputName) const¶
- Get the count of output data. - Return
- The count of output data
- Parameters
- outputName: The name of the target output
 
 
 - Operations - 
virtual void enable()¶
 - 
virtual void disable()¶
 - 
virtual std::string executeCommand(const std::vector<std::string> &args)¶
- Request the underlying region to execute a command. - Return
- The result value of command execution is a string determined by the underlying region.
- Parameters
- args: A list of strings that the actual region will interpret. The first string is the command name. The other arguments are optional.
 
 
 - 
void compute()¶
- Perform one step of the region computation. 
 - Profiling - 
void enableProfiling()¶
- Enable profiling of the compute and execute operations. 
 - 
void disableProfiling()¶
- Disable profiling of the compute and execute operations. 
 - 
void resetProfiling()¶
- Reset the compute and execute timers. 
 - 
const Timer &getComputeTimer() const¶
- Get the timer used to profile the compute operation. - Return
- The Timer object used to profile the compute operation
 
 - 
const Timer &getExecuteTimer() const¶
- Get the timer used to profile the execute operation. - Return
- The Timer object used to profile the execute operation
 
 
RegionImpl¶
- 
class nupic::RegionImpl¶
- Inherits from nupic::Serializable< capnp::AnyPointer > - Subclassed by nupic::ScalarSensor - Public Functions - 
virtual void serialize(BundleIO &bundle) = 0¶
- Can’t declare a static method in an interface. - But RegionFactory expects to find this method. Caller gets ownership. 
 - 
virtual void initialize() = 0¶
- Inputs/Outputs are made available in initialize() It is always called after the constructor (or load from serialized state) 
 - 
virtual void getParameterFromBuffer(const std::string &name, Int64 index, IWriteBuffer &value) = 0¶
- Get a parameter from a write buffer. - This method is called only by the typed getParameter* methods in the RegionImpl base class - Must be implemented by all subclasses. - Parameters
- index: A node index. (-1) indicates a region-level parameter
 
 
 - 
virtual void setParameterFromBuffer(const std::string &name, Int64 index, IReadBuffer &value) = 0¶
- Set a parameter from a read buffer. - This method is called only by the RegionImpl base class type-specific setParameter* methods Must be implemented by all subclasses. - Parameters
- index: A node index. (-1) indicates a region-level parameter
 
 
 - 
virtual size_t getParameterArrayCount(const std::string &name, Int64 index)¶
- Array-valued parameters may have a size determined at runtime. - This method returns the number of elements in the named parameter. If parameter is not an array type, may throw an exception or return 1. - Must be implemented only if the node has one or more array parameters with a dynamically-determined length. 
 - isParameterShared must be available after construction Default implementation all parameters are shared Tests whether a parameter is node or region level 
 
- 
virtual void