org.micropsi.nodenet
Class Gate

java.lang.Object
  extended byorg.micropsi.nodenet.Gate

public final class Gate
extends java.lang.Object

The links between NetEntitys originate from Gates. Gates have parameters that affect the way activation is propagated, similar to neurons in connectionist networks. The output of a gate is calculated by one of the functions defined in the class GateOutputFunctions. These functions may make use of the parameters activation, maximum, minimum and the "unbound" parameter theta, the latter with different semantics for each output function.
Whatever the output function may calculated, it's value is then multiplied by the gate parameter "ampfactor", the result again checked to be between minimum and maximum.

Additionaly, gates calculate the decay of the attached link's weights whenever these links are used.

Every gate has a type that MUST be unique within one entity.


Constructor Summary
protected Gate(int type, NetEntity center, int decayType)
          Constructor for the gate, setting it's type, center-entity and the decay type of the links.
 
Method Summary
protected  void addLink(Link link)
          Adds a link to the gate.
protected  void calculateDecays(long netstep)
          Calculates the decay for all attached links.
protected  boolean confirmActivation()
          Confirms the current activation as authoritative during the next cycle
protected  void deleteLink(Link link)
          Deletes a link from the gate.
protected  void destroy()
          Frees as many references as possible to avoid too much gc activity
protected  double getActivation()
          Returns the gate's "raw" activation, without having it multiplied or checked it against anything.
 double getAmpfactor()
          Returns the ampfactor.
 double getConfirmedActivation()
          Returns the confirmed activation of this gate.
 OutputFunctionParameter[] getCurrentOutputFunctionParameters()
          Returns the current parameters of the output function.
 int getDecayCalculatorType()
          Returns the decayCalculatorType.
 double getGateFactor()
          Returns the gateFactor.
protected  long getLastDecayCalculation()
           
 Link getLinkAt(int n)
          Returns the nth link attached to this gate
 java.util.Iterator getLinks()
          Returns an iterator with instances of Link.
 Link getLinkTo(java.lang.String entityID, int slot)
          Returns a specific link
 double getMaximum()
          Returns the maximum output of the gate.
 double getMinimum()
          Returns the minimum output of the (active) gate
 NetEntity getNetEntity()
          Returns the gate's "center" entity, the entity that the gate belongs to.
 int getNumberOfLinks()
          Returns the number of links
 OutputFunctionIF getOutputFunction()
          Retuns the type of the output function used in this gate
 double getOutputFunctionParameter(java.lang.String parameterName)
          Returns the current value of a given output function parameter
 int getType()
          Returns the type
 boolean hasLinks()
          Returns true if there are links at this gate
 boolean isActive()
          Checks if the gate is "active", that is: if the gate's activation ist !
protected  void setActivation(double activation)
          Sets the activation.
protected  void setAmpfactor(double ampfactor)
          Sets the ampfactor.
protected  void setConfirmedActivation(double activation)
          Sets the confirmed activation.
protected  void setDecayCalculatorType(int decayCalculatorType)
          Sets the decayCalculatorType.
protected  void setGateFactor(double factor)
          Sets the gate factor.
protected  void setLastDecayCalculation(long lastDecayCalculation)
          Sets the lastDecayCalculation.
protected  void setMaximum(double maximum)
          Sets the maximum.
protected  void setMinimum(double minimum)
          Method setMinimum.
protected  void setOutputFunction(OutputFunctionIF function)
          Sets the output function.
protected  void setOutputFunctionParameter(java.lang.String parameterName, double value)
          Sets one of tge output function's constant parameters.
protected  void setOutputFunctionParameters(OutputFunctionParameter[] ofParams)
          Sets all output function parameters at once.
 java.lang.String toString()
           
protected  void unlinkCompletely()
          Unlinks the entity completely - for cleaning up or to prepare the entity for deletion.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Gate

protected Gate(int type,
               NetEntity center,
               int decayType)
Constructor for the gate, setting it's type, center-entity and the decay type of the links.

Parameters:
type - the gate's type
center - the NetEntity that the gate belongs to
decayType - the type of decay to be applied
Method Detail

getNetEntity

public NetEntity getNetEntity()
Returns the gate's "center" entity, the entity that the gate belongs to.

Returns:
NetEntity the entity

addLink

protected void addLink(Link link)
Adds a link to the gate. This method is low-level and does not care for the net's integrity in any way.

Parameters:
link - the link to be added to the gate.

deleteLink

protected void deleteLink(Link link)
Deletes a link from the gate. (Must be the instance of the link!) This method is low-level and does not care for integrity.

Parameters:
link - the link to be deleted

unlinkCompletely

protected void unlinkCompletely()
                         throws NetIntegrityException
Unlinks the entity completely - for cleaning up or to prepare the entity for deletion. This is a high-level method and ensures that the link references are dropped correctly by the gate and the linked slots.

Throws:
NetIntegrityException - if there are bad links at this gate.

getLinks

public java.util.Iterator getLinks()
Returns an iterator with instances of Link. Do not call remove() or the net's integrity will be violated badly.

Returns:
Iterator the links

getLinkAt

public Link getLinkAt(int n)
Returns the nth link attached to this gate

Parameters:
n - the index of the link
Returns:
Link the link or null if there is no nth link

getLinkTo

public Link getLinkTo(java.lang.String entityID,
                      int slot)
               throws NetIntegrityException
Returns a specific link

Parameters:
entityID - the ID of the linked entity
slot - the slot where the link ends
Returns:
Link the link or null if there is no such link
Throws:
NetIntegrityException - if the requested link is bad

setGateFactor

protected void setGateFactor(double factor)
Sets the gate factor.

Parameters:
factor - the gateFactor.

getGateFactor

public double getGateFactor()
Returns the gateFactor.

Returns:
double the gateFactor

getActivation

protected double getActivation()
Returns the gate's "raw" activation, without having it multiplied or checked it against anything. This should only be used for transporting or saving the net's state, not for any logical operation!

Returns:
double the raw activation of the gate.

getConfirmedActivation

public double getConfirmedActivation()
Returns the confirmed activation of this gate.

Returns:
double

confirmActivation

protected boolean confirmActivation()
Confirms the current activation as authoritative during the next cycle


isActive

public boolean isActive()
Checks if the gate is "active", that is: if the gate's activation ist != 0

Returns:
boolean true if the gate is active

calculateDecays

protected void calculateDecays(long netstep)
                        throws NetIntegrityException
Calculates the decay for all attached links. This actually changes the weights of the links!

Parameters:
netstep -
Throws:
NetIntegrityException

getType

public int getType()
Returns the type

Returns:
int the type

getAmpfactor

public double getAmpfactor()
Returns the ampfactor.

Returns:
double the ampfactor

getDecayCalculatorType

public int getDecayCalculatorType()
Returns the decayCalculatorType.

Returns:
int

getOutputFunction

public OutputFunctionIF getOutputFunction()
Retuns the type of the output function used in this gate

Returns:
int

getMaximum

public double getMaximum()
Returns the maximum output of the gate.

Returns:
double

getMinimum

public double getMinimum()
Returns the minimum output of the (active) gate

Returns:
double

setActivation

protected void setActivation(double activation)
Sets the activation.

Parameters:
activation - The activation to set

setConfirmedActivation

protected void setConfirmedActivation(double activation)
Sets the confirmed activation. This should only be called for persistency reasons!

Parameters:
activation - The activation to set

setAmpfactor

protected void setAmpfactor(double ampfactor)
Sets the ampfactor.

Parameters:
ampfactor - The ampfactor to set

setDecayCalculatorType

protected void setDecayCalculatorType(int decayCalculatorType)
Sets the decayCalculatorType.

Parameters:
decayCalculatorType - The decayCalculatorType to set

setOutputFunction

protected void setOutputFunction(OutputFunctionIF function)
Sets the output function.

Parameters:
function - The function to be used.

setMaximum

protected void setMaximum(double maximum)
Sets the maximum.

Parameters:
maximum - The maximum to set

getCurrentOutputFunctionParameters

public OutputFunctionParameter[] getCurrentOutputFunctionParameters()
Returns the current parameters of the output function.

Returns:
an array with parameters, filled with current values. Never null.

getOutputFunctionParameter

public double getOutputFunctionParameter(java.lang.String parameterName)
Returns the current value of a given output function parameter

Parameters:
parameterName - the name of the parameter
Returns:
the current value of the parameter
Throws:
java.lang.IllegalArgumentException - if the output function of this gate does not support the given parameter

setOutputFunctionParameter

protected void setOutputFunctionParameter(java.lang.String parameterName,
                                          double value)
Sets one of tge output function's constant parameters.

Parameters:
parameterName - the name of the parameter
value - the new value
Throws:
java.lang.IllegalArgumentException - if the output function does not have this parameter

setOutputFunctionParameters

protected void setOutputFunctionParameters(OutputFunctionParameter[] ofParams)
Sets all output function parameters at once. This method does not check wheter the gate's output function supports the given parameters.

Parameters:
ofParams - the parameters.

setMinimum

protected void setMinimum(double minimum)
Method setMinimum.

Parameters:
minimum -

getNumberOfLinks

public int getNumberOfLinks()
Returns the number of links

Returns:
int

hasLinks

public boolean hasLinks()
Returns true if there are links at this gate

Returns:
boolean

getLastDecayCalculation

protected long getLastDecayCalculation()
Returns:
long

setLastDecayCalculation

protected void setLastDecayCalculation(long lastDecayCalculation)
Sets the lastDecayCalculation.

Parameters:
lastDecayCalculation - The lastDecayCalculation to set

toString

public java.lang.String toString()
See Also:
Object.toString()

destroy

protected void destroy()
Frees as many references as possible to avoid too much gc activity


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

.