NuPIC Core
Core algorithms for NuPIC(the Numenta Platform for Intelligent Computing), implemented in C++
 All Classes Namespaces Files Functions Typedefs Enumerations Enumerator Friends Pages
List of all members
nupic::Region Class Reference

Represents a set of one or more "identical" nodes in a Network. More...

#include <Region.hpp>

Region information

NetworkgetNetwork ()
 Get the network containing this region. More...
 
const std::string & getName () const
 Get the name of the region. More...
 
const DimensionsgetDimensions () const
 Get the dimensions of the region. More...
 
void setDimensions (Dimensions &dimensions)
 Assign width and height to the region. More...
 

Element interface methods

Todo:
What does "Element interface methods" mean here?
const std::string & getType () const
 Get the type of the region. More...
 
const Spec * getSpec () const
 Get the spec of the region. More...
 
static const Spec * getSpecFromType (const std::string &nodeType)
 Get the Spec of a region type without an instance. More...
 
static void registerPyRegion (const std::string module, const std::string className)
 
static void registerCPPRegion (const std::string name, GenericRegisteredRegionImpl *wrapper)
 
static void unregisterPyRegion (const std::string className)
 
static void unregisterCPPRegion (const std::string name)
 

Parameter getters and setters

Int32 getParameterInt32 (const std::string &name) const
 Get the parameter as an Int32 value. More...
 
UInt32 getParameterUInt32 (const std::string &name) const
 Get the parameter as an UInt32 value. More...
 
Int64 getParameterInt64 (const std::string &name) const
 Get the parameter as an Int64 value. More...
 
UInt64 getParameterUInt64 (const std::string &name) const
 Get the parameter as an UInt64 value. More...
 
Real32 getParameterReal32 (const std::string &name) const
 Get the parameter as an Real32 value. More...
 
Real64 getParameterReal64 (const std::string &name) const
 Get the parameter as an Real64 value. More...
 
Handle getParameterHandle (const std::string &name) const
 Get the parameter as an Handle value. More...
 
void setParameterInt32 (const std::string &name, Int32 value)
 Set the parameter to an Int32 value. More...
 
void setParameterUInt32 (const std::string &name, UInt32 value)
 Set the parameter to an UInt32 value. More...
 
void setParameterInt64 (const std::string &name, Int64 value)
 Set the parameter to an Int64 value. More...
 
void setParameterUInt64 (const std::string &name, UInt64 value)
 Set the parameter to an UInt64 value. More...
 
void setParameterReal32 (const std::string &name, Real32 value)
 Set the parameter to a Real32 value. More...
 
void setParameterReal64 (const std::string &name, Real64 value)
 Set the parameter to a Real64 value. More...
 
void setParameterHandle (const std::string &name, Handle value)
 Set the parameter to a Handle value. More...
 
void getParameterArray (const std::string &name, Array &array) const
 Get the parameter as an Array value. More...
 
void setParameterArray (const std::string &name, const Array &array)
 Set the parameter to an Array value. More...
 
void setParameterString (const std::string &name, const std::string &s)
 Set the parameter to a std::string value. More...
 
std::string getParameterString (const std::string &name)
 Get the parameter as a std::string value. More...
 
bool isParameterShared (const std::string &name) const
 Tells whether the parameter is shared. More...
 

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. More...
 
virtual ArrayRef getOutputData (const std::string &outputName) const
 Get the output data. More...
 
virtual size_t getInputCount (const std::string &inputName) const
 Get the count of input data. More...
 
virtual size_t getOutputCount (const std::string &outputName) const
 Get the count of output data. More...
 

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. More...
 
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. More...
 
const Timer & getExecuteTimer () const
 Get the timer used to profile the execute operation. More...
 

Detailed Description

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.

Definition at line 71 of file Region.hpp.

Member Function Documentation

virtual void nupic::Region::disable ( )
virtual
Todo:
Region::disable() not implemented, should it be part of API at all?
virtual void nupic::Region::enable ( )
virtual
Todo:
Region::enable() not implemented, should it be part of API at all?
virtual std::string nupic::Region::executeCommand ( const std::vector< std::string > &  args)
virtual

Request the underlying region to execute a command.

Parameters
argsA list of strings that the actual region will interpret. The first string is the command name. The other arguments are optional.
Returns
The result value of command execution is a string determined by the underlying region.
const Timer& nupic::Region::getComputeTimer ( ) const

Get the timer used to profile the compute operation.

Returns
The Timer object used to profile the compute operation
const Dimensions& nupic::Region::getDimensions ( ) const

Get the dimensions of the region.

Returns
The region's dimensions
const Timer& nupic::Region::getExecuteTimer ( ) const

Get the timer used to profile the execute operation.

Returns
The Timer object used to profile the execute operation
virtual size_t nupic::Region::getInputCount ( const std::string &  inputName) const
virtual

Get the count of input data.

Parameters
inputNameThe name of the target input
Returns
The count of input data
Todo:
are getOutput/InputCount needed? count can be obtained from the array objects.
virtual ArrayRef nupic::Region::getInputData ( const std::string &  inputName) const
virtual

Get the input data.

Parameters
inputNameThe name of the target input
Returns
An ArrayRef that contains the input data.
const std::string& nupic::Region::getName ( ) const

Get the name of the region.

Returns
The region's name
Network* nupic::Region::getNetwork ( )

Get the network containing this region.

Returns
The network containing this region
virtual size_t nupic::Region::getOutputCount ( const std::string &  outputName) const
virtual

Get the count of output data.

Parameters
outputNameThe name of the target output
Returns
The count of output data
Todo:
are getOutput/InputCount needed? count can be obtained from the array objects.
virtual ArrayRef nupic::Region::getOutputData ( const std::string &  outputName) const
virtual

Get the output data.

Parameters
outputNameThe name of the target output
Returns
An ArrayRef that contains the output data.
void nupic::Region::getParameterArray ( const std::string &  name,
Array &  array 
) const

Get the parameter as an Array value.

Parameters
nameThe name of the parameter
[out]arrayThe value of the parameter

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.

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.

Handle nupic::Region::getParameterHandle ( const std::string &  name) const

Get the parameter as an Handle value.

Parameters
nameThe name of the parameter
Returns
The value of the parameter
Int32 nupic::Region::getParameterInt32 ( const std::string &  name) const

Get the parameter as an Int32 value.

Parameters
nameThe name of the parameter
Returns
The value of the parameter
Int64 nupic::Region::getParameterInt64 ( const std::string &  name) const

Get the parameter as an Int64 value.

Parameters
nameThe name of the parameter
Returns
The value of the parameter
Real32 nupic::Region::getParameterReal32 ( const std::string &  name) const

Get the parameter as an Real32 value.

Parameters
nameThe name of the parameter
Returns
The value of the parameter
Real64 nupic::Region::getParameterReal64 ( const std::string &  name) const

Get the parameter as an Real64 value.

Parameters
nameThe name of the parameter
Returns
The value of the parameter
std::string nupic::Region::getParameterString ( const std::string &  name)

Get the parameter as a std::string value.

Parameters
nameThe name of the parameter
Returns
The value of the parameter
See Also
setParameterString()
UInt32 nupic::Region::getParameterUInt32 ( const std::string &  name) const

Get the parameter as an UInt32 value.

Parameters
nameThe name of the parameter
Returns
The value of the parameter
UInt64 nupic::Region::getParameterUInt64 ( const std::string &  name) const

Get the parameter as an UInt64 value.

Parameters
nameThe name of the parameter
Returns
The value of the parameter
const Spec* nupic::Region::getSpec ( ) const

Get the spec of the region.

Returns
The spec that describes this region
static const Spec* nupic::Region::getSpecFromType ( const std::string &  nodeType)
static

Get the Spec of a region type without an instance.

Parameters
nodeTypeA region type as a string
Returns
The Spec that describes this region type
const std::string& nupic::Region::getType ( ) const

Get the type of the region.

Returns
The node type as a string
bool nupic::Region::isParameterShared ( const std::string &  name) const

Tells whether the parameter is shared.

Parameters
nameThe name of the parameter
Returns
Whether the parameter is shared
Todo:
figure out what "shared" means here
Note
This method must be overridden by subclasses.

Throws an exception if it's not overridden

void nupic::Region::setDimensions ( Dimensions dimensions)

Assign width and height to the region.

Parameters
dimensionsA Dimensions object that describes the width and height
void nupic::Region::setParameterArray ( const std::string &  name,
const Array &  array 
)

Set the parameter to an Array value.

Parameters
nameThe name of the parameter
arrayThe value of the parameter
Note
array must be initialized before calling setParameterArray().
void nupic::Region::setParameterHandle ( const std::string &  name,
Handle  value 
)

Set the parameter to a Handle value.

Parameters
nameThe name of the parameter
valueThe value of the parameter
void nupic::Region::setParameterInt32 ( const std::string &  name,
Int32  value 
)

Set the parameter to an Int32 value.

Parameters
nameThe name of the parameter
valueThe value of the parameter
void nupic::Region::setParameterInt64 ( const std::string &  name,
Int64  value 
)

Set the parameter to an Int64 value.

Parameters
nameThe name of the parameter
valueThe value of the parameter
void nupic::Region::setParameterReal32 ( const std::string &  name,
Real32  value 
)

Set the parameter to a Real32 value.

Parameters
nameThe name of the parameter
valueThe value of the parameter
void nupic::Region::setParameterReal64 ( const std::string &  name,
Real64  value 
)

Set the parameter to a Real64 value.

Parameters
nameThe name of the parameter
valueThe value of the parameter
void nupic::Region::setParameterString ( const std::string &  name,
const std::string &  s 
)

Set the parameter to a std::string value.

Parameters
nameThe name of the parameter
sThe value of the parameter

Strings are handled internally as Byte Arrays, but this interface is clumsy. setParameterString() and getParameterString() internally use byte arrays but converts to/from strings.

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)

void nupic::Region::setParameterUInt32 ( const std::string &  name,
UInt32  value 
)

Set the parameter to an UInt32 value.

Parameters
nameThe name of the parameter
valueThe value of the parameter
void nupic::Region::setParameterUInt64 ( const std::string &  name,
UInt64  value 
)

Set the parameter to an UInt64 value.

Parameters
nameThe name of the parameter
valueThe value of the parameter

The documentation for this class was generated from the following file: