org.micropsi.nodenet
Class NodeSpaceModule

java.lang.Object
  extended byorg.micropsi.nodenet.NetEntity
      extended byorg.micropsi.nodenet.Module
          extended byorg.micropsi.nodenet.NodeSpaceModule
All Implemented Interfaces:
NetIntegrityIF

public class NodeSpaceModule
extends Module

NodeSpaceModules (aka NodeSpaces) are modules that contain nodes. Besides any number of concept, register, sensor and actor nodes, NodeSpaces contain exactly one of the special node types: associator, dissociator, activator, deactivator and one directional acivator for each gate type.

NodeSpaces are modules, hence they are hierarchical. Any non-special node to be member of a NodeSpace is also a member of all higher NodeSpaces within the NodeSpace's branch.

As modules, NodeSpaces can have Gates and Slots themselves. The values of the slots can be read within the NodeSpace by sensor nodes, the gates can be written via actor nodes - the dataSources and dataTargets will be created automatically with the slots and gates.
This makes modules very flexible: It is possible to replace some module written in Java (as a NativeModule) by a module working with node scripts (in a NodeSpace) afterwards without having to change the system - if the timing is the same or the timining does not matter.


Field Summary
protected  double DISSOCIATIONCONST
          The NodeSpace's dissociation constant.
protected  double LEARNINGCONST
          learning constant for associator learning
protected  double STRENGTHENINGCONST
          learning constant for strenthening of used links
 
Fields inherited from class org.micropsi.nodenet.Module
moduleManager, parent
 
Fields inherited from class org.micropsi.nodenet.NetEntity
entityManager, gates, slots
 
Fields inherited from interface org.micropsi.nodenet.NetIntegrityIF
BAD_KEY, BAD_LINK, BAD_OUTPUT_FUNCTION, BAD_SLOT, DUPLICATE_KEY, UNKNOWN_ENTITY, UNKNOWN_MODULE
 
Constructor Summary
protected NodeSpaceModule(java.lang.String id, java.lang.String parent, ModuleManager moduleManager, NetEntityManager entityManager, SensActRegistry sensActRegistry)
          Creates a new NodeSpaceModule.
 
Method Summary
protected  void attachEntity(java.lang.String id, boolean levelOne)
          Attaches an entity to this nodespace and makes it a member.
protected  void calculateGates()
          Calculates the gates.
protected  void changeParameter(int parameterType, int subID, java.lang.String newValue)
          Changes a parameter of this entity or one of it's slots, gates or hidden implementation.
 boolean containsEntity(java.lang.String entityID)
          Checks if the NodeSpace contains the given entity.
 boolean containsEntityDirectly(java.lang.String entityID)
          Checks if the NodeSpace directly contains the given entity
protected  Gate createGate(int gateType)
          Creates a new gate for the NodeSpace and creates the corresponding DataTarget.
protected  Slot createSlot(int slotType)
          Creates a slot and generates the corresponding DataSource.
protected  void deleteGate(int gateType)
          Deletes a gate and removes the corresponding DataTarget.
protected  void deleteSlot(int slotType)
          Deletes a slot and removes the corresponding DataSource.
 void destroy()
          Frees as many references as possible to avoid too much gc activity
 NetEntity getActCat()
          Returns the NodeSpace's ActCat node Can be null if there is no such node assigned to the NodeSpace.
 NetEntity getActExp()
          Returns the NodeSpace's ActExp node Can be null if there is no such node assigned to the NodeSpace.
 NetEntity getActivator()
          Returns the NodeSpace's Activator node Can be null if there is no such node assigned to the NodeSpace.
protected  java.util.Iterator getActiveEntityIDs()
          Returns the IDs of all entities that are currently active AND members of the NodeSpace
 NetEntity getActPor()
          Returns the NodeSpace's ActPor node Can be null if there is no such node assigned to the NodeSpace.
 NetEntity getActRef()
          Returns the NodeSpace's ActRef node Can be null if there is no such node assigned to the NodeSpace.
 NetEntity getActRet()
          Returns the NodeSpace's ActRet node Can be null if there is no such node assigned to the NodeSpace.
 NetEntity getActSub()
          Returns the NodeSpace's ActSub node Can be null if there is no such node assigned to the NodeSpace.
 NetEntity getActSur()
          Returns the NodeSpace's ActSur node Can be null if there is no such node assigned to the NodeSpace.
 NetEntity getActSym()
          Returns the NodeSpace's ActSym node Can be null if there is no such node assigned to the NodeSpace.
 java.util.Iterator getAllEntities()
          Returns all entities (instances) that are members of the NodeSpace.
 java.util.Iterator getAllLevelOneEntities()
          Returns all entities (instances) that are direct members of the NodeSpace (not of one of the contained NodeSpaces)
 NetEntity getAssociator()
          Returns the NodeSpace's associator Can be null if there is no such node assigned to the NodeSpace.
 NetEntity getDeactivator()
          Returns the NodeSpace's deactivator.
 double getDissociationConstant()
          Returns the NodeSpace's dissociation constant.
 NetEntity getDissociator()
          Returns the NodeSpaces's dissociator.
protected  NetEntityManager getEntityManager()
          Returns the EntityManager
 int getEntityType()
          Returns the type of the entity
 double getLearningConstant()
          Retuns the net's learning constant.
 double getStrengtheningConstant()
          Returns the net's strengthening constant (for strengthening-by-use link weight modifications)
 boolean hasDeletedLinks()
          Returns true if links have been deleted at any of the directly contained nodes of this nodespace within the last net cycle.
 void notifyObservers()
          Notifies all registered observers of changes within the module.
 void registerObserver(NodeSpaceObserverIF observer)
          Register an observer to monitor changes in the NodeSpace.
protected  void reportEntityDeletion(java.lang.String id)
          Called from the outside to notify the module of the fact that some entity was deleted
protected  void setHasDeletedLinks(boolean b)
          Sets the "deleted links" flag.
 void unregisterObserver(NodeSpaceObserverIF observer)
          Unregister an observer.
 
Methods inherited from class org.micropsi.nodenet.Module
changeParent, getParent, isRoot
 
Methods inherited from class org.micropsi.nodenet.NetEntity
addGate, addSlot, checkIntegrity, confirmNewActivation, createLinkTo, createLinkTo, deleteLink, getEntityName, getFirstLinkAt, getGate, getGates, getID, getLastLinkAt, getLink, getNumberOfGates, getNumberOfSlots, getParentID, getSlot, getSlots, hasName, isActive, propagateActivation, reportIntegrityStatus, setEntityName, setParentID, toString, unlinkCompletely, updateDecayState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DISSOCIATIONCONST

protected double DISSOCIATIONCONST
The NodeSpace's dissociation constant.

See Also:
DissociatorNode

LEARNINGCONST

protected double LEARNINGCONST
learning constant for associator learning


STRENGTHENINGCONST

protected double STRENGTHENINGCONST
learning constant for strenthening of used links

Constructor Detail

NodeSpaceModule

protected NodeSpaceModule(java.lang.String id,
                          java.lang.String parent,
                          ModuleManager moduleManager,
                          NetEntityManager entityManager,
                          SensActRegistry sensActRegistry)
                   throws NetIntegrityException
Creates a new NodeSpaceModule. This method must only be called by the NetEntityFactory!

Parameters:
id - the ID of the module/entity
parent - the NodeSpace's parent module
moduleManager - the module manager
entityManager - the entity manager
sensActRegistry - the SensActRegistry
Throws:
NetIntegrityException - if the ID already exists within the net
Method Detail

attachEntity

protected void attachEntity(java.lang.String id,
                            boolean levelOne)
                     throws NetIntegrityException
Attaches an entity to this nodespace and makes it a member. (Members of a NodeSpaces are Members of all parent NodeSpaces also!).
Note that this does not make the NodeSpace the parent of the attached entity - this is something confusingly different. Although Modules attached to a NodeSpace are normally children of this space, but there is no such thing as a parent/child relation with Nodes: Nodes have no parents as modules do, they are just member of a NodeSpace.

Parameters:
id - the ID of the entity to be attached.
Throws:
NetIntegrityException - if there is no such entity

createGate

protected Gate createGate(int gateType)
                   throws NetIntegrityException
Creates a new gate for the NodeSpace and creates the corresponding DataTarget.

Parameters:
gateType - the type of the gate to be created
Returns:
Gate the newly created gate
Throws:
NetIntegrityException - if the NodeSpace already has a gate of that type

deleteGate

protected void deleteGate(int gateType)
                   throws NetIntegrityException
Deletes a gate and removes the corresponding DataTarget.

Overrides:
deleteGate in class NetEntity
Parameters:
gateType - the type of the gate to be removed
Throws:
NetIntegrityException - if there is no such gate

createSlot

protected Slot createSlot(int slotType)
                   throws NetIntegrityException
Creates a slot and generates the corresponding DataSource.

Parameters:
slotType - the type of the slot to be created.
Returns:
Slot the newly created slot
Throws:
NetIntegrityException - if the NodeSpace already has a slot of that type

deleteSlot

protected void deleteSlot(int slotType)
                   throws NetIntegrityException
Deletes a slot and removes the corresponding DataSource.

Overrides:
deleteSlot in class NetEntity
Parameters:
slotType - the type of the slot to be removed
Throws:
NetIntegrityException - if the space has no such slot

containsEntity

public boolean containsEntity(java.lang.String entityID)
Checks if the NodeSpace contains the given entity.

Parameters:
entityID - the ID of the entity
Returns:
boolean true if the entity is a member of the space

containsEntityDirectly

public boolean containsEntityDirectly(java.lang.String entityID)
Checks if the NodeSpace directly contains the given entity

Parameters:
entityID - the ID of the entity
Returns:
boolean true if the entity is a direct member of the space

getAllEntities

public java.util.Iterator getAllEntities()
Returns all entities (instances) that are members of the NodeSpace.

Returns:
Iterator the entities

getAllLevelOneEntities

public java.util.Iterator getAllLevelOneEntities()
Returns all entities (instances) that are direct members of the NodeSpace (not of one of the contained NodeSpaces)

Returns:
Iterator

getActiveEntityIDs

protected java.util.Iterator getActiveEntityIDs()
Returns the IDs of all entities that are currently active AND members of the NodeSpace

Returns:
Iterator the ids of the active entities within the space

getEntityManager

protected NetEntityManager getEntityManager()
Returns the EntityManager

Returns:
NetEntityManager

getDissociationConstant

public double getDissociationConstant()
Returns the NodeSpace's dissociation constant.

Returns:
double the dissociation constant

getLearningConstant

public double getLearningConstant()
Retuns the net's learning constant.

Returns:
double the learning constant.

getStrengtheningConstant

public double getStrengtheningConstant()
Returns the net's strengthening constant (for strengthening-by-use link weight modifications)

Returns:
double the strengthening constant.

reportEntityDeletion

protected void reportEntityDeletion(java.lang.String id)
Description copied from class: Module
Called from the outside to notify the module of the fact that some entity was deleted

Specified by:
reportEntityDeletion in class Module
Parameters:
id - the deleted entity's ID.
See Also:
Module.reportEntityDeletion(String)

registerObserver

public void registerObserver(NodeSpaceObserverIF observer)
Register an observer to monitor changes in the NodeSpace.

Parameters:
observer - the observer

unregisterObserver

public void unregisterObserver(NodeSpaceObserverIF observer)
Unregister an observer.

Parameters:
observer - the observer

notifyObservers

public void notifyObservers()
Description copied from class: Module
Notifies all registered observers of changes within the module.

Specified by:
notifyObservers in class Module
See Also:
Module.notifyObservers()

getEntityType

public int getEntityType()
Description copied from class: NetEntity
Returns the type of the entity

Specified by:
getEntityType in class NetEntity
Returns:
int the type
See Also:
NetEntity.getEntityType()

calculateGates

protected void calculateGates()
                       throws NetIntegrityException
Description copied from class: NetEntity
Calculates the gates.

Specified by:
calculateGates in class NetEntity
Throws:
NetIntegrityException
See Also:
NetEntity.calculateGates()

changeParameter

protected void changeParameter(int parameterType,
                               int subID,
                               java.lang.String newValue)
                        throws NetIntegrityException
Description copied from class: NetEntity
Changes a parameter of this entity or one of it's slots, gates or hidden implementation. Possible values of parameterType can be found in NetParametersIF.

Overrides:
changeParameter in class NetEntity
Parameters:
parameterType - the parameter to be changed
subID - the subid. Depending on the parameterType used, this can be the type of a slot, a gate or the key of a parameter of a hidden implementation (typically of a NativeModule)
newValue - The new value as String
Throws:
NetIntegrityException - if the slot or gate was not found
See Also:
NetEntity.changeParameter(int, int, String)

getActCat

public NetEntity getActCat()
Returns the NodeSpace's ActCat node Can be null if there is no such node assigned to the NodeSpace.

Returns:
NetEntity the ActCat

getActExp

public NetEntity getActExp()
Returns the NodeSpace's ActExp node Can be null if there is no such node assigned to the NodeSpace.

Returns:
NetEntity the ActExp node

getActivator

public NetEntity getActivator()
Returns the NodeSpace's Activator node Can be null if there is no such node assigned to the NodeSpace.

Returns:
NetEntity the activator

getActPor

public NetEntity getActPor()
Returns the NodeSpace's ActPor node Can be null if there is no such node assigned to the NodeSpace.

Returns:
NetEntity the ActPor node

getActRet

public NetEntity getActRet()
Returns the NodeSpace's ActRet node Can be null if there is no such node assigned to the NodeSpace.

Returns:
NetEntity the ActRet node

getActSub

public NetEntity getActSub()
Returns the NodeSpace's ActSub node Can be null if there is no such node assigned to the NodeSpace.

Returns:
NetEntity the ActSub node

getActSur

public NetEntity getActSur()
Returns the NodeSpace's ActSur node Can be null if there is no such node assigned to the NodeSpace.

Returns:
NetEntity the ActSur node

getActSym

public NetEntity getActSym()
Returns the NodeSpace's ActSym node Can be null if there is no such node assigned to the NodeSpace.

Returns:
NetEntity the ActSym node

getActRef

public NetEntity getActRef()
Returns the NodeSpace's ActRef node Can be null if there is no such node assigned to the NodeSpace.

Returns:
NetEntity the ActRef node

getAssociator

public NetEntity getAssociator()
Returns the NodeSpace's associator Can be null if there is no such node assigned to the NodeSpace.

Returns:
NetEntity the associator

getDeactivator

public NetEntity getDeactivator()
Returns the NodeSpace's deactivator. Can be null if there is no such node assigned to the NodeSpace.

Returns:
NetEntity the deactivator

getDissociator

public NetEntity getDissociator()
Returns the NodeSpaces's dissociator. Can be null if there is no such node assigned to the NodeSpace.

Returns:
NetEntity the dissociator

setHasDeletedLinks

protected void setHasDeletedLinks(boolean b)
Sets the "deleted links" flag. This happens when a link gets deleted from inside the net (by a native module).


hasDeletedLinks

public boolean hasDeletedLinks()
Returns true if links have been deleted at any of the directly contained nodes of this nodespace within the last net cycle.

Returns:
true if links have been deleted

destroy

public void destroy()
Description copied from class: NetEntity
Frees as many references as possible to avoid too much gc activity

Overrides:
destroy in class NetEntity

(c) by Micropsi Project: http://www.cognitive-agents.org

.